formatting code

This commit is contained in:
junjie.miao
2025-05-08 16:58:08 +08:00
parent bcbdd1f9b0
commit 3b9eaa6e0a

View File

@ -15,98 +15,98 @@ CURR_DIR=`pwd`
USER=`whoami` USER=`whoami`
market(){ market(){
if [[ -z "$2" || -z "$3" || -z "$4" ]]; then if [[ -z "$2" || -z "$3" || -z "$4" ]]; then
echo "" echo ""
echo "Usage: "$0" market [plugin author] [plugin name] [plugin version]" echo "Usage: "$0" market [plugin author] [plugin name] [plugin version]"
echo "Example:" echo "Example:"
echo " "$0" market junjiem mcp_sse 0.0.1" echo " "$0" market junjiem mcp_sse 0.0.1"
echo " "$0" market langgenius agent 0.0.9" echo " "$0" market langgenius agent 0.0.9"
echo "" echo ""
exit 1 exit 1
fi fi
echo "From the Dify Marketplace downloading ..." echo "From the Dify Marketplace downloading ..."
PLUGIN_AUTHOR=$2 PLUGIN_AUTHOR=$2
PLUGIN_NAME=$3 PLUGIN_NAME=$3
PLUGIN_VERSION=$4 PLUGIN_VERSION=$4
PLUGIN_PACKAGE_PATH=${CURR_DIR}/${PLUGIN_AUTHOR}-${PLUGIN_NAME}_${PLUGIN_VERSION}.difypkg PLUGIN_PACKAGE_PATH=${CURR_DIR}/${PLUGIN_AUTHOR}-${PLUGIN_NAME}_${PLUGIN_VERSION}.difypkg
PLUGIN_DOWNLOAD_URL=${MARKETPLACE_API_URL}/api/v1/plugins/${PLUGIN_AUTHOR}/${PLUGIN_NAME}/${PLUGIN_VERSION}/download PLUGIN_DOWNLOAD_URL=${MARKETPLACE_API_URL}/api/v1/plugins/${PLUGIN_AUTHOR}/${PLUGIN_NAME}/${PLUGIN_VERSION}/download
echo "Downloading ${PLUGIN_DOWNLOAD_URL} ..." echo "Downloading ${PLUGIN_DOWNLOAD_URL} ..."
curl -L -o ${PLUGIN_PACKAGE_PATH} ${PLUGIN_DOWNLOAD_URL} curl -L -o ${PLUGIN_PACKAGE_PATH} ${PLUGIN_DOWNLOAD_URL}
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "Download failed, please check the plugin author, name and version." echo "Download failed, please check the plugin author, name and version."
exit 1 exit 1
fi fi
echo "Download success." echo "Download success."
repackage ${PLUGIN_PACKAGE_PATH} repackage ${PLUGIN_PACKAGE_PATH}
} }
github(){ github(){
if [[ -z "$2" || -z "$3" || -z "$4" ]]; then if [[ -z "$2" || -z "$3" || -z "$4" ]]; then
echo "" echo ""
echo "Usage: "$0" github [Github repo] [Release title] [Assets name (include .difypkg suffix)]" echo "Usage: "$0" github [Github repo] [Release title] [Assets name (include .difypkg suffix)]"
echo "Example:" echo "Example:"
echo " "$0" github junjiem/dify-plugin-tools-dbquery v0.0.2 db_query.difypkg" echo " "$0" github junjiem/dify-plugin-tools-dbquery v0.0.2 db_query.difypkg"
echo " "$0" github https://github.com/junjiem/dify-plugin-agent-mcp_sse 0.0.1 agent-mcp_see.difypkg" echo " "$0" github https://github.com/junjiem/dify-plugin-agent-mcp_sse 0.0.1 agent-mcp_see.difypkg"
echo "" echo ""
exit 1 exit 1
fi fi
echo "From the Github downloading ..." echo "From the Github downloading ..."
GITHUB_REPO=$2 GITHUB_REPO=$2
if [[ "${GITHUB_REPO}" != "${GITHUB_API_URL}"* ]]; then if [[ "${GITHUB_REPO}" != "${GITHUB_API_URL}"* ]]; then
GITHUB_REPO="${GITHUB_API_URL}/${GITHUB_REPO}" GITHUB_REPO="${GITHUB_API_URL}/${GITHUB_REPO}"
fi fi
RELEASE_TITLE=$3 RELEASE_TITLE=$3
ASSETS_NAME=$4 ASSETS_NAME=$4
PLUGIN_NAME="${ASSETS_NAME%.difypkg}" PLUGIN_NAME="${ASSETS_NAME%.difypkg}"
PLUGIN_PACKAGE_PATH=${CURR_DIR}/${PLUGIN_NAME}-${RELEASE_TITLE}.difypkg PLUGIN_PACKAGE_PATH=${CURR_DIR}/${PLUGIN_NAME}-${RELEASE_TITLE}.difypkg
PLUGIN_DOWNLOAD_URL=${GITHUB_REPO}/releases/download/${RELEASE_TITLE}/${ASSETS_NAME} PLUGIN_DOWNLOAD_URL=${GITHUB_REPO}/releases/download/${RELEASE_TITLE}/${ASSETS_NAME}
echo "Downloading ${PLUGIN_DOWNLOAD_URL} ..." echo "Downloading ${PLUGIN_DOWNLOAD_URL} ..."
curl -L -o ${PLUGIN_PACKAGE_PATH} ${PLUGIN_DOWNLOAD_URL} curl -L -o ${PLUGIN_PACKAGE_PATH} ${PLUGIN_DOWNLOAD_URL}
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "Download failed, please check the github repo, release title and assets name." echo "Download failed, please check the github repo, release title and assets name."
exit 1 exit 1
fi fi
echo "Download success." echo "Download success."
repackage ${PLUGIN_PACKAGE_PATH} repackage ${PLUGIN_PACKAGE_PATH}
} }
_local(){ _local(){
echo $2 echo $2
if [[ -z "$2" ]]; then if [[ -z "$2" ]]; then
echo "" echo ""
echo "Usage: "$0" local [difypkg path]" echo "Usage: "$0" local [difypkg path]"
echo "Example:" echo "Example:"
echo " "$0" local ./db_query.difypkg" echo " "$0" local ./db_query.difypkg"
echo " "$0" local /root/dify-plugin/db_query.difypkg" echo " "$0" local /root/dify-plugin/db_query.difypkg"
echo "" echo ""
exit 1 exit 1
fi fi
PLUGIN_PACKAGE_PATH=`realpath $2` PLUGIN_PACKAGE_PATH=`realpath $2`
repackage ${PLUGIN_PACKAGE_PATH} repackage ${PLUGIN_PACKAGE_PATH}
} }
repackage(){ repackage(){
local PACKAGE_PATH=$1 local PACKAGE_PATH=$1
PACKAGE_NAME_WITH_EXTENSION=`basename ${PACKAGE_PATH}` PACKAGE_NAME_WITH_EXTENSION=`basename ${PACKAGE_PATH}`
PACKAGE_NAME="${PACKAGE_NAME_WITH_EXTENSION%.*}" PACKAGE_NAME="${PACKAGE_NAME_WITH_EXTENSION%.*}"
echo "Unziping ..." echo "Unziping ..."
install_unzip install_unzip
unzip -o ${PACKAGE_PATH} -d ${CURR_DIR}/${PACKAGE_NAME} unzip -o ${PACKAGE_PATH} -d ${CURR_DIR}/${PACKAGE_NAME}
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "Unzip failed." echo "Unzip failed."
exit 1 exit 1
fi fi
echo "Unzip success." echo "Unzip success."
echo "Repackaging ..." echo "Repackaging ..."
cd ${CURR_DIR}/${PACKAGE_NAME} cd ${CURR_DIR}/${PACKAGE_NAME}
pip download -r requirements.txt -d ./wheels --index-url ${PIP_MIRROR_URL} pip download -r requirements.txt -d ./wheels --index-url ${PIP_MIRROR_URL}
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "Pip download failed." echo "Pip download failed."
exit 1 exit 1
fi fi
sed -i '1i\--no-index --find-links=./wheels/' requirements.txt sed -i '1i\--no-index --find-links=./wheels/' requirements.txt
if [ -f .difyignore ]; then if [ -f .difyignore ]; then
sed -i '/^wheels\//d' .difyignore sed -i '/^wheels\//d' .difyignore
fi fi
cd ${CURR_DIR} cd ${CURR_DIR}
chmod 755 ${CURR_DIR}/dify-plugin-linux-amd64-5g chmod 755 ${CURR_DIR}/dify-plugin-linux-amd64-5g
@ -115,14 +115,14 @@ repackage(){
} }
install_unzip(){ install_unzip(){
if ! command -v unzip &> /dev/null; then if ! command -v unzip &> /dev/null; then
echo "Installing unzip ..." echo "Installing unzip ..."
yum -y install unzip yum -y install unzip
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Install unzip failed." echo "Install unzip failed."
exit 1 exit 1
fi fi
fi fi
} }
case "$1" in case "$1" in