sftp-push-sync 1.0.13 → 1.0.14
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/bin/sftp-push-sync.mjs +30 -16
- package/package.json +1 -1
package/bin/sftp-push-sync.mjs
CHANGED
|
@@ -53,7 +53,8 @@ const EXC = pc.redBright("-"); // Excluded
|
|
|
53
53
|
|
|
54
54
|
const hr1 = () => "─".repeat(65); // horizontal line -
|
|
55
55
|
const hr2 = () => "=".repeat(65); // horizontal line =
|
|
56
|
-
const tab_a = () => " ".repeat(3); // indentation for formatting the output.
|
|
56
|
+
const tab_a = () => " ".repeat(3); // indentation for formatting the terminal output.
|
|
57
|
+
const tab_b = () => " ".repeat(6);
|
|
57
58
|
|
|
58
59
|
// ---------------------------------------------------------------------------
|
|
59
60
|
// CLI arguments
|
|
@@ -72,7 +73,7 @@ if (args.includes("--laconic")) cliLogLevel = "laconic";
|
|
|
72
73
|
|
|
73
74
|
if (!TARGET) {
|
|
74
75
|
console.error(pc.red("❌ Please specify a connection profile:"));
|
|
75
|
-
console.error(pc.yellow(
|
|
76
|
+
console.error(pc.yellow(`${tab_a()}sftp-push-sync staging --dry-run`));
|
|
76
77
|
process.exit(1);
|
|
77
78
|
}
|
|
78
79
|
|
|
@@ -242,8 +243,11 @@ let progressActive = false;
|
|
|
242
243
|
function clearProgressLine() {
|
|
243
244
|
if (!process.stdout.isTTY || !progressActive) return;
|
|
244
245
|
const width = process.stdout.columns || 80;
|
|
245
|
-
const blank = " ".repeat(width
|
|
246
|
-
|
|
246
|
+
const blank = " ".repeat(width);
|
|
247
|
+
|
|
248
|
+
// Beide Progress-Zeilen leeren
|
|
249
|
+
process.stdout.write("\r" + blank + "\n" + blank + "\r");
|
|
250
|
+
|
|
247
251
|
progressActive = false;
|
|
248
252
|
}
|
|
249
253
|
|
|
@@ -421,8 +425,8 @@ async function walkLocal(root) {
|
|
|
421
425
|
scanned += 1;
|
|
422
426
|
const chunk = IS_VERBOSE ? 1 : SCAN_CHUNK;
|
|
423
427
|
if (scanned === 1 || scanned % chunk === 0) {
|
|
424
|
-
// totally unknown →
|
|
425
|
-
updateProgress2(
|
|
428
|
+
// totally unknown → total = 0 → no automatic \n
|
|
429
|
+
updateProgress2(`${tab_a()}Scan local: `, scanned, 0, rel);
|
|
426
430
|
}
|
|
427
431
|
}
|
|
428
432
|
}
|
|
@@ -432,7 +436,7 @@ async function walkLocal(root) {
|
|
|
432
436
|
|
|
433
437
|
if (scanned > 0) {
|
|
434
438
|
// last line + neat finish
|
|
435
|
-
updateProgress2(
|
|
439
|
+
updateProgress2(`${tab_a()}Scan local: `, scanned, 0, "fertig");
|
|
436
440
|
process.stdout.write("\n");
|
|
437
441
|
progressActive = false;
|
|
438
442
|
}
|
|
@@ -473,7 +477,7 @@ async function walkRemote(sftp, remoteRoot) {
|
|
|
473
477
|
scanned += 1;
|
|
474
478
|
const chunk = IS_VERBOSE ? 1 : SCAN_CHUNK;
|
|
475
479
|
if (scanned === 1 || scanned % chunk === 0) {
|
|
476
|
-
updateProgress2(
|
|
480
|
+
updateProgress2(`${tab_a()}Scan remote: `, scanned, 0, rel);
|
|
477
481
|
}
|
|
478
482
|
}
|
|
479
483
|
}
|
|
@@ -482,7 +486,7 @@ async function walkRemote(sftp, remoteRoot) {
|
|
|
482
486
|
await recurse(remoteRoot);
|
|
483
487
|
|
|
484
488
|
if (scanned > 0) {
|
|
485
|
-
updateProgress2(
|
|
489
|
+
updateProgress2(`${tab_a()}Scan remote: `, scanned, 0, "fertig");
|
|
486
490
|
process.stdout.write("\n");
|
|
487
491
|
progressActive = false;
|
|
488
492
|
}
|
|
@@ -616,11 +620,11 @@ async function main() {
|
|
|
616
620
|
)
|
|
617
621
|
);
|
|
618
622
|
log(`${tab_a()}Connection: ${pc.cyan(TARGET)}`);
|
|
619
|
-
log(
|
|
620
|
-
log(`${tab_a()}Host:
|
|
621
|
-
log(`${tab_a()}Local:
|
|
623
|
+
log(`${tab_a()}Worker: ${CONNECTION.workers}`);
|
|
624
|
+
log(`${tab_a()}Host: ${pc.green(CONNECTION.host)}:${pc.green(CONNECTION.port)}`);
|
|
625
|
+
log(`${tab_a()}Local: ${pc.green(CONNECTION.localRoot)}`);
|
|
622
626
|
log(`${tab_a()}Remote: ${pc.green(CONNECTION.remoteRoot)}`);
|
|
623
|
-
if (DRY_RUN) log(pc.yellow(
|
|
627
|
+
if (DRY_RUN) log(pc.yellow(`${tab_a()}Mode: DRY-RUN (no changes)`));
|
|
624
628
|
if (RUN_UPLOAD_LIST || RUN_DOWNLOAD_LIST) {
|
|
625
629
|
log(
|
|
626
630
|
pc.blue(
|
|
@@ -761,8 +765,8 @@ async function main() {
|
|
|
761
765
|
|
|
762
766
|
if (IS_VERBOSE) {
|
|
763
767
|
vlog(`${tab_a()}${CHA} Hash different (binary): ${rel}`);
|
|
764
|
-
vlog(`${
|
|
765
|
-
vlog(`${
|
|
768
|
+
vlog(`${tab_b()}local: ${localHash}`);
|
|
769
|
+
vlog(`${tab_b()}remote: ${remoteHash}`);
|
|
766
770
|
}
|
|
767
771
|
|
|
768
772
|
toUpdate.push({ rel, local: l, remote: r, remotePath });
|
|
@@ -772,6 +776,11 @@ async function main() {
|
|
|
772
776
|
}
|
|
773
777
|
}
|
|
774
778
|
|
|
779
|
+
// Wenn Phase 3 nichts gefunden hat, explizit sagen
|
|
780
|
+
if (toAdd.length === 0 && toUpdate.length === 0) {
|
|
781
|
+
log(`${tab_a()}No differences found. Everything is up to date.`);
|
|
782
|
+
}
|
|
783
|
+
|
|
775
784
|
log(
|
|
776
785
|
"\n" + pc.bold(pc.cyan("🧹 Phase 4: Removing orphaned remote files …"))
|
|
777
786
|
);
|
|
@@ -785,6 +794,11 @@ async function main() {
|
|
|
785
794
|
}
|
|
786
795
|
}
|
|
787
796
|
|
|
797
|
+
// Auch für Phase 4 eine „nix zu tun“-Meldung
|
|
798
|
+
if (toDelete.length === 0) {
|
|
799
|
+
log(`${tab_a()}No orphaned remote files found.`);
|
|
800
|
+
}
|
|
801
|
+
|
|
788
802
|
// -------------------------------------------------------------------
|
|
789
803
|
// Phase 5: Execute changes (parallel, worker-based)
|
|
790
804
|
// -------------------------------------------------------------------
|
|
@@ -982,4 +996,4 @@ async function main() {
|
|
|
982
996
|
log(`${hr2()}\n\n`);
|
|
983
997
|
}
|
|
984
998
|
|
|
985
|
-
main();
|
|
999
|
+
main();
|