Import the supplied management frontend, including request encryption, withdrawal updates, and vendored dependencies. Use incoming versions for overlapping source files and retain existing environment configuration absent from the supplied directory.
52 lines
1.5 KiB
Bash
Executable File
52 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
# 在系统自带「终端」里运行本脚本(不要用 Cursor Agent 终端),可避免 .vscode/.idea 目录被拦截导致安装失败。
|
||
set -euo pipefail
|
||
|
||
cd "$(dirname "$0")"
|
||
|
||
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
|
||
if [ -s "$NVM_DIR/nvm.sh" ]; then
|
||
# shellcheck disable=SC1090
|
||
. "$NVM_DIR/nvm.sh"
|
||
nvm use 20 >/dev/null || nvm use default >/dev/null || true
|
||
fi
|
||
|
||
echo "==> Node: $(node -v)"
|
||
echo "==> npm: $(npm -v)"
|
||
|
||
if ! command -v pnpm >/dev/null 2>&1; then
|
||
echo "==> 安装 pnpm..."
|
||
npm install -g pnpm@9 --registry=https://registry.npmjs.org/
|
||
fi
|
||
echo "==> pnpm: $(pnpm -v)"
|
||
|
||
cat > .npmrc <<'EOF'
|
||
registry=https://registry.npmjs.org/
|
||
node-linker=hoisted
|
||
shamefully-hoist=true
|
||
EOF
|
||
|
||
echo "==> 清理旧依赖..."
|
||
rm -rf node_modules
|
||
|
||
echo "==> 安装依赖(约需几分钟)..."
|
||
pnpm install --registry=https://registry.npmjs.org/
|
||
|
||
# 兜底:补齐 rollup 原生可选依赖(npm optional 偶发缺失)
|
||
ARCH="$(uname -m)"
|
||
if [ "$ARCH" = "x86_64" ]; then
|
||
pnpm add -D @rollup/rollup-darwin-x64 --registry=https://registry.npmjs.org/ || true
|
||
elif [ "$ARCH" = "arm64" ]; then
|
||
pnpm add -D @rollup/rollup-darwin-arm64 --registry=https://registry.npmjs.org/ || true
|
||
fi
|
||
|
||
if [ ! -x node_modules/.bin/vite ] && [ ! -f node_modules/vite/bin/vite.js ]; then
|
||
echo "ERROR: vite 仍未安装成功,请把上方报错发我"
|
||
exit 1
|
||
fi
|
||
|
||
echo "==> 启动开发服务(连接远程后端 .env.dev)..."
|
||
# 端口 80 可能需要权限,改用 5173
|
||
export VITE_PORT=5173
|
||
pnpm exec vite --mode dev --port 5173 --host 0.0.0.0
|