sketchboard-app 1.0.7 → 1.0.8
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/uninstall.js +31 -31
- package/package.json +1 -1
package/bin/uninstall.js
CHANGED
|
@@ -19,59 +19,59 @@ try {
|
|
|
19
19
|
}
|
|
20
20
|
} catch { /* ignore */ }
|
|
21
21
|
|
|
22
|
-
// ── Banner ────────────────────────────────────────────────────────────────────
|
|
23
22
|
const shortPath = DATA_DIR.length > 48 ? "..." + DATA_DIR.slice(-45) : DATA_DIR;
|
|
24
23
|
|
|
24
|
+
// ── Banner ────────────────────────────────────────────────────────────────────
|
|
25
25
|
process.stdout.write("\n");
|
|
26
26
|
process.stdout.write(" ╔════════════════════════════════════════════════════╗\n");
|
|
27
27
|
process.stdout.write(" ║ SketchBoard Uninstaller ║\n");
|
|
28
28
|
process.stdout.write(" ╠════════════════════════════════════════════════════╣\n");
|
|
29
29
|
|
|
30
30
|
if (exists && drawingCount > 0) {
|
|
31
|
-
|
|
31
|
+
const label = ` ║ ${drawingCount} drawing(s) saved at:`;
|
|
32
|
+
process.stdout.write(label.padEnd(54) + "║\n");
|
|
32
33
|
process.stdout.write(` ║ ${shortPath.padEnd(50)} ║\n`);
|
|
33
34
|
} else if (exists) {
|
|
34
|
-
process.stdout.write(` ║ Data folder
|
|
35
|
-
process.stdout.write(` ║ ${shortPath.padEnd(50)} ║\n`);
|
|
35
|
+
process.stdout.write(` ║ Data folder: ${shortPath.padEnd(37)}║\n`);
|
|
36
36
|
} else {
|
|
37
37
|
process.stdout.write(" ║ No data folder found — nothing to delete. ║\n");
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
process.stdout.write(" ╚════════════════════════════════════════════════════╝\n");
|
|
41
41
|
process.stdout.write("\n");
|
|
42
|
-
process.stdout.write("
|
|
43
|
-
process.stdout.write("
|
|
44
|
-
process.stdout.write("
|
|
45
|
-
process.stdout.write("
|
|
42
|
+
process.stdout.write(" [1] Soft uninstall — keep your drawings (default)\n");
|
|
43
|
+
process.stdout.write(" [2] Full uninstall — delete all drawings\n");
|
|
44
|
+
process.stdout.write("\n");
|
|
45
|
+
process.stdout.write(" Press 1 or 2 (auto-selects 1 after 30 s): ");
|
|
46
46
|
|
|
47
|
-
// ── Read from the real console
|
|
48
|
-
|
|
47
|
+
// ── Read a single keypress from the real console ──────────────────────────────
|
|
48
|
+
// `choice` on Windows reads directly from CONIN$ (bypasses npm's stdin pipe).
|
|
49
|
+
// `bash /dev/tty` on Unix does the same.
|
|
50
|
+
function readChoice() {
|
|
49
51
|
if (process.platform === "win32") {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
["-NoProfile", "-Command", "$Host.UI.ReadLine()"],
|
|
55
|
-
{ stdio: ["inherit", "pipe", "inherit"], timeout: 30_000 },
|
|
52
|
+
const r = spawnSync(
|
|
53
|
+
"choice",
|
|
54
|
+
["/c", "12", "/n", "/t", "30", "/d", "1"],
|
|
55
|
+
{ stdio: ["inherit", "pipe", "inherit"], timeout: 35_000 },
|
|
56
56
|
);
|
|
57
|
-
|
|
58
|
-
return
|
|
59
|
-
} else {
|
|
60
|
-
// On Unix, read directly from /dev/tty (bypasses piped stdin).
|
|
61
|
-
const result = spawnSync(
|
|
62
|
-
"bash",
|
|
63
|
-
["-c", "read -r ans </dev/tty && printf '%s' \"$ans\""],
|
|
64
|
-
{ stdio: ["inherit", "pipe", "inherit"], timeout: 30_000 },
|
|
65
|
-
);
|
|
66
|
-
if (result.error || result.status !== 0) return "";
|
|
67
|
-
return (result.stdout || "").toString().trim();
|
|
57
|
+
// choice exits with code 1 for key '1', code 2 for key '2'
|
|
58
|
+
return r.status === 2 ? "2" : "1";
|
|
68
59
|
}
|
|
60
|
+
|
|
61
|
+
// Unix: read one char directly from /dev/tty
|
|
62
|
+
const r = spawnSync(
|
|
63
|
+
"bash",
|
|
64
|
+
["-c", "IFS= read -r -n1 ans </dev/tty && printf '%s' \"$ans\""],
|
|
65
|
+
{ stdio: ["inherit", "pipe", "inherit"], timeout: 35_000 },
|
|
66
|
+
);
|
|
67
|
+
const ch = (r.stdout || "").toString().trim();
|
|
68
|
+
return ch === "2" ? "2" : "1";
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
const answer =
|
|
72
|
-
process.stdout.write("\n");
|
|
71
|
+
const answer = readChoice();
|
|
72
|
+
process.stdout.write(answer + "\n\n");
|
|
73
73
|
|
|
74
|
-
// ── Act on
|
|
74
|
+
// ── Act on choice ─────────────────────────────────────────────────────────────
|
|
75
75
|
if (answer === "2") {
|
|
76
76
|
if (exists) {
|
|
77
77
|
try {
|
|
@@ -82,7 +82,7 @@ if (answer === "2") {
|
|
|
82
82
|
}
|
|
83
83
|
} catch (err) {
|
|
84
84
|
process.stderr.write(` ✗ Could not delete ${DATA_DIR}: ${err.message}\n`);
|
|
85
|
-
process.stderr.write("
|
|
85
|
+
process.stderr.write(" Delete it manually in File Explorer.\n");
|
|
86
86
|
}
|
|
87
87
|
} else {
|
|
88
88
|
process.stdout.write(" (No data folder to delete)\n");
|