refactor: 去掉冗余的 node_modules 复制步骤,简化部署流程
This commit is contained in:
parent
b4ad9c53c6
commit
d2445c7309
@ -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',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user