fix: 从活跃版本复制 node_modules 替代全量下载,npm install 秒过
This commit is contained in:
parent
80d84888a4
commit
f692a767f8
@ -165,7 +165,7 @@ function main() {
|
||||
`REMOTE_ARCHIVE=${quoteForBash(remoteArchive)}`,
|
||||
`ACTIVE_DIR=${quoteForBash(`${config.deployRoot}/${currentVersion}`)}`,
|
||||
'cd "$TARGET_DIR"',
|
||||
// 清理旧代码(保留 logs/run/tmp/.deploy 等运行时目录)
|
||||
// 清理旧代码(保留 logs/run/tmp/node_modules/.deploy 等运行时目录)
|
||||
`find . -mindepth 1 -maxdepth 1 ${cleanupGuard} -exec rm -rf {} +`,
|
||||
'tar -xzf "$REMOTE_ARCHIVE" -C "$TARGET_DIR"',
|
||||
'rm -f "$REMOTE_ARCHIVE"',
|
||||
@ -184,9 +184,14 @@ function main() {
|
||||
' fi',
|
||||
' fi',
|
||||
'fi',
|
||||
// 清理旧 node_modules 后全新安装,避免残留导致 semver 冲突
|
||||
'echo "正在清理旧 node_modules ..."',
|
||||
'rm -rf "$TARGET_DIR/node_modules"',
|
||||
// 从活跃版本复制 node_modules(蓝绿部署核心优化,避免每次全量下载)
|
||||
'if [ -d "$ACTIVE_DIR/node_modules" ]; then',
|
||||
' echo "正在从活跃版本 ($ACTIVE_DIR) 复制 node_modules ..."',
|
||||
' rm -rf "$TARGET_DIR/node_modules"',
|
||||
' cp -a "$ACTIVE_DIR/node_modules" "$TARGET_DIR/node_modules"',
|
||||
' echo "node_modules 复制完成"',
|
||||
'fi',
|
||||
// 增量更新依赖(node_modules 已存在,仅校验变更)
|
||||
'npm install --production',
|
||||
].join('\n');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user