From d2445c730927b66bf76ce79cabf936e64e4fb2a0 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Sat, 25 Jul 2026 02:06:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=8E=BB=E6=8E=89=E5=86=97?= =?UTF-8?q?=E4=BD=99=E7=9A=84=20node=5Fmodules=20=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E6=AD=A5=E9=AA=A4=EF=BC=8C=E7=AE=80=E5=8C=96=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/deploy-remote.cjs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/script/deploy-remote.cjs b/script/deploy-remote.cjs index 9c70177..7576ab1 100644 --- a/script/deploy-remote.cjs +++ b/script/deploy-remote.cjs @@ -164,19 +164,13 @@ function main() { `TARGET_DIR=${quoteForBash(targetDir)}`, `REMOTE_ARCHIVE=${quoteForBash(remoteArchive)}`, `ACTIVE_DIR=${quoteForBash(`${config.deployRoot}/${currentVersion}`)}`, - // 从活跃版本复制 node_modules(蓝绿部署核心优化) - 'if [ ! -d "$TARGET_DIR/node_modules" ] && [ -d "$ACTIVE_DIR/node_modules" ]; then', - ' echo "正在从活跃版本 ($ACTIVE_DIR) 复制 node_modules ..."', - ' cp -a "$ACTIVE_DIR/node_modules" "$TARGET_DIR/node_modules"', - ' echo "node_modules 复制完成"', - 'fi', 'cd "$TARGET_DIR"', + // 清理旧代码(保留 logs/run/tmp/.deploy 等运行时目录) `find . -mindepth 1 -maxdepth 1 ${cleanupGuard} -exec rm -rf {} +`, 'tar -xzf "$REMOTE_ARCHIVE" -C "$TARGET_DIR"', 'rm -f "$REMOTE_ARCHIVE"', // 保留 config 目录 'if [ ! -d "$TARGET_DIR/config" ]; then', - ` ACTIVE_DIR=${quoteForBash(`${config.deployRoot}/${currentVersion}`)}`, ' if [ -d "$ACTIVE_DIR/config" ]; then', ' cp -a "$ACTIVE_DIR/config" "$TARGET_DIR/config"', ' echo "已从活跃版本 ($ACTIVE_DIR) 复制 config 目录"', @@ -190,7 +184,7 @@ function main() { ' fi', ' fi', 'fi', - // 清理 node_modules 后重新安装,避免残留状态导致 npm semver 冲突 + // 清理旧 node_modules 后全新安装,避免残留导致 semver 冲突 'echo "正在清理旧 node_modules ..."', 'rm -rf "$TARGET_DIR/node_modules"', 'npm install --production',