1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| #!/bin/bash
if [ -z "$1" ]; then echo "使用方法: $0 <API_NAME>" echo "例如: $0 qwen-free-api" exit 1 fi
API_NAME="$1"
SAVE_DIR=$(echo "$API_NAME" | sed 's/-free-/2/')
INSTALL_DIR=~/domains/$SAVE_DIR
VERSION=$(curl -s "https://api.github.com/repos/LLM-Red-Team/$API_NAME/releases/latest" | jq -r '.tag_name')
if [ -z "$VERSION" ] || [ "$VERSION" == "null" ]; then echo "无法获取最新版本号,退出脚本。" exit 1 fi
echo "最新版本号为:$VERSION"
if [ -d "$INSTALL_DIR" ]; then rm -rf "$INSTALL_DIR" echo "已删除旧版本:$INSTALL_DIR" else echo "未找到旧版本,跳过删除步骤。" fi
cd ~/domains wget https://github.com/LLM-Red-Team/$API_NAME/archive/refs/tags/$VERSION.tar.gz tar -zxvf $VERSION.tar.gz mv $API_NAME-$VERSION/ $SAVE_DIR
cd $SAVE_DIR
cp package.json package.json.bak
if grep -q '"sharp"' package.json; then jq '.resolutions["sharp"] = {"platform": "linuxmusl"}' package.json.bak > package.json.tmp && mv package.json.tmp package.json echo "已将 sharp 依赖更新为 'platform: linuxmusl'" fi
jq '.resolutions["rollup"] = "npm:@rollup/wasm-node" | .overrides["rollup"] = "npm:@rollup/wasm-node"' package.json > package.json.tmp && mv package.json.tmp package.json
npm i npm run build
echo "$API_NAME 更新完成,版本:$VERSION,保存在目录:$INSTALL_DIR"
|