ai-project-manage-cli 6.0.62 → 6.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +29 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4394,6 +4394,30 @@ function execCommand(client, command) {
|
|
|
4394
4394
|
});
|
|
4395
4395
|
});
|
|
4396
4396
|
}
|
|
4397
|
+
function shellSingleQuote(value) {
|
|
4398
|
+
return `'${value.replace(/'/g, `'"'"'`)}'`;
|
|
4399
|
+
}
|
|
4400
|
+
function buildClearRemoteDirExceptZipCommand(target) {
|
|
4401
|
+
const normalized = target.replace(/\\/g, "/").replace(/\/$/, "");
|
|
4402
|
+
const quotedTarget = shellSingleQuote(normalized);
|
|
4403
|
+
const script = [
|
|
4404
|
+
`T=${quotedTarget}`,
|
|
4405
|
+
"S=$(mktemp -d)",
|
|
4406
|
+
'while IFS= read -r -d "" z; do',
|
|
4407
|
+
'r="${z#${T}/}"',
|
|
4408
|
+
'mkdir -p "${S}/$(dirname "$r")"',
|
|
4409
|
+
'mv "$z" "${S}/${r}"',
|
|
4410
|
+
'done < <(find "$T" -mindepth 1 -type f -iname "*.zip" -print0)',
|
|
4411
|
+
'rm -rf "${T}"/*',
|
|
4412
|
+
'while IFS= read -r -d "" r; do',
|
|
4413
|
+
'r="${r#./}"',
|
|
4414
|
+
'mkdir -p "${T}/$(dirname "$r")"',
|
|
4415
|
+
'mv "${S}/${r}" "${T}/${r}"',
|
|
4416
|
+
'done < <(cd "$S" 2>/dev/null && find . -type f -print0)',
|
|
4417
|
+
'rm -rf "$S"'
|
|
4418
|
+
].join("; ");
|
|
4419
|
+
return `bash -c ${shellSingleQuote(script)}`;
|
|
4420
|
+
}
|
|
4397
4421
|
async function uploadAndMaybeExtract(settings, localZip, extract) {
|
|
4398
4422
|
const remoteZipPath = `${settings.remotePath.replace(/\/$/, "")}/dist.zip`;
|
|
4399
4423
|
console.error(
|
|
@@ -4414,12 +4438,13 @@ async function uploadAndMaybeExtract(settings, localZip, extract) {
|
|
|
4414
4438
|
console.error(` \u2713 ${localZip} -> ${remoteZipPath}`);
|
|
4415
4439
|
if (extract) {
|
|
4416
4440
|
const target = settings.remotePath.replace(/\/$/, "");
|
|
4441
|
+
const client = sftp.client;
|
|
4442
|
+
const clearCmd = buildClearRemoteDirExceptZipCommand(target);
|
|
4443
|
+
console.error(`\u8FDC\u7A0B\u6E05\u7406\u89E3\u538B\u76EE\u5F55: ${clearCmd}`);
|
|
4444
|
+
await execCommand(client, clearCmd);
|
|
4417
4445
|
const unzipCmd = `unzip -o "${remoteZipPath}" -d "${target}"`;
|
|
4418
4446
|
console.error(`\u8FDC\u7A0B\u89E3\u538B: ${unzipCmd}`);
|
|
4419
|
-
await execCommand(
|
|
4420
|
-
sftp.client,
|
|
4421
|
-
unzipCmd
|
|
4422
|
-
);
|
|
4447
|
+
await execCommand(client, unzipCmd);
|
|
4423
4448
|
console.error("\u8FDC\u7A0B\u89E3\u538B\u5B8C\u6210!");
|
|
4424
4449
|
}
|
|
4425
4450
|
console.error(extract ? "\u90E8\u7F72\u5B8C\u6210!" : "\u4E0A\u4F20\u5B8C\u6210!");
|