mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 07:09:20 +08:00
feat: 调整部署脚本
This commit is contained in:
@@ -66,24 +66,24 @@ export function assertArtifactsExist(service: Service): void {
|
||||
}
|
||||
}
|
||||
|
||||
/** 打包并上传目录到远程 data 目录 */
|
||||
/** 打包并上传目录到远程 app 目录 */
|
||||
export async function uploadArtifactDirectory(
|
||||
conn: Client,
|
||||
localDir: string,
|
||||
remoteDataDir: string,
|
||||
remoteAppDir: string,
|
||||
): Promise<void> {
|
||||
await ensureRemoteDir(conn, remoteDataDir);
|
||||
const parentDir = remoteDataDir.replace(/\/data\/?$/, '');
|
||||
await ensureRemoteDir(conn, remoteAppDir);
|
||||
const parentDir = remoteAppDir.replace(/\/app\/?$/, '');
|
||||
const tmpTar = getLocalTempPath(`ecom-upload-${Date.now()}.tar.gz`);
|
||||
const remoteTar = `${parentDir}/upload.tar.gz`;
|
||||
|
||||
printInfo(`上传产物到 ${remoteDataDir} ...`);
|
||||
printInfo(`上传产物到 ${remoteAppDir} ...`);
|
||||
createTarGz(localDir, tmpTar);
|
||||
await uploadFile(conn, tmpTar, remoteTar);
|
||||
|
||||
const { code, stderr } = await execRemote(
|
||||
conn,
|
||||
`mkdir -p "${remoteDataDir}" && rm -rf "${remoteDataDir}"/* && tar -xzf "${remoteTar}" -C "${remoteDataDir}" && rm -f "${remoteTar}"`,
|
||||
`mkdir -p "${remoteAppDir}" && rm -rf "${remoteAppDir}"/* && tar -xzf "${remoteTar}" -C "${remoteAppDir}" && rm -f "${remoteTar}"`,
|
||||
);
|
||||
if (code !== 0) throw new Error(`远程解压失败: ${stderr}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user