sketchboard-app 1.0.4 → 1.0.5
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 +97 -0
- package/package.json +3 -2
package/bin/uninstall.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const readline = require("readline");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const os = require("os");
|
|
9
|
+
|
|
10
|
+
const DATA_DIR = process.env.SKETCHBOARD_DATA || path.join(os.homedir(), ".sketchboard");
|
|
11
|
+
const exists = fs.existsSync(DATA_DIR);
|
|
12
|
+
|
|
13
|
+
// Non-interactive environment (CI/pipe) — skip prompt, keep data
|
|
14
|
+
if (!process.stdin.isTTY) {
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// ── Count saved drawings ──────────────────────────────────────────────────────
|
|
19
|
+
let drawingCount = 0;
|
|
20
|
+
try {
|
|
21
|
+
const drawingsDir = path.join(DATA_DIR, "drawings");
|
|
22
|
+
if (fs.existsSync(drawingsDir)) {
|
|
23
|
+
drawingCount = fs.readdirSync(drawingsDir).filter((f) => f.endsWith(".json")).length;
|
|
24
|
+
}
|
|
25
|
+
} catch { /* ignore */ }
|
|
26
|
+
|
|
27
|
+
// ── Banner ────────────────────────────────────────────────────────────────────
|
|
28
|
+
const shortPath = DATA_DIR.length > 46 ? "..." + DATA_DIR.slice(-43) : DATA_DIR;
|
|
29
|
+
|
|
30
|
+
console.log(`
|
|
31
|
+
╔════════════════════════════════════════════════════╗
|
|
32
|
+
║ SketchBoard Uninstaller ║
|
|
33
|
+
╠════════════════════════════════════════════════════╣`);
|
|
34
|
+
|
|
35
|
+
if (exists && drawingCount > 0) {
|
|
36
|
+
console.log(` ║ ║
|
|
37
|
+
║ You have ${String(drawingCount).padEnd(3)} saved drawing(s) at: ║
|
|
38
|
+
║ ${shortPath.padEnd(50)} ║
|
|
39
|
+
║ ║`);
|
|
40
|
+
} else if (exists) {
|
|
41
|
+
console.log(` ║ ║
|
|
42
|
+
║ Data folder exists (no drawings saved yet): ║
|
|
43
|
+
║ ${shortPath.padEnd(50)} ║
|
|
44
|
+
║ ║`);
|
|
45
|
+
} else {
|
|
46
|
+
console.log(` ║ ║
|
|
47
|
+
║ No data folder found — nothing to delete. ║
|
|
48
|
+
║ ║`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
console.log(` ╚════════════════════════════════════════════════════╝
|
|
52
|
+
`);
|
|
53
|
+
|
|
54
|
+
console.log(" How would you like to uninstall?\n");
|
|
55
|
+
console.log(" [1] Soft uninstall — remove the app, keep your drawings (default)");
|
|
56
|
+
console.log(" [2] Full uninstall — remove the app AND delete all drawings\n");
|
|
57
|
+
|
|
58
|
+
// ── Prompt ────────────────────────────────────────────────────────────────────
|
|
59
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
60
|
+
|
|
61
|
+
// Safety timeout — if no answer in 30s, default to soft uninstall
|
|
62
|
+
const timeout = setTimeout(() => {
|
|
63
|
+
rl.close();
|
|
64
|
+
console.log("\n (Timed out — defaulting to soft uninstall. Your drawings are safe.)\n");
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}, 30_000);
|
|
67
|
+
|
|
68
|
+
rl.question(" Your choice (1 or 2, press Enter for 1): ", (answer) => {
|
|
69
|
+
clearTimeout(timeout);
|
|
70
|
+
rl.close();
|
|
71
|
+
|
|
72
|
+
const choice = answer.trim();
|
|
73
|
+
|
|
74
|
+
if (choice === "2") {
|
|
75
|
+
console.log();
|
|
76
|
+
if (exists) {
|
|
77
|
+
try {
|
|
78
|
+
fs.rmSync(DATA_DIR, { recursive: true, force: true });
|
|
79
|
+
console.log(` ✓ Deleted ${DATA_DIR}`);
|
|
80
|
+
if (drawingCount > 0) {
|
|
81
|
+
console.log(` ✓ ${drawingCount} drawing(s) removed`);
|
|
82
|
+
}
|
|
83
|
+
} catch (err) {
|
|
84
|
+
console.error(` ✗ Could not delete ${DATA_DIR}: ${err.message}`);
|
|
85
|
+
console.error(" You can delete it manually in File Explorer.\n");
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
console.log(" (No data folder found — nothing to delete)");
|
|
89
|
+
}
|
|
90
|
+
console.log("\n Proceeding with full uninstall...\n");
|
|
91
|
+
} else {
|
|
92
|
+
console.log("\n Your drawings are safe.");
|
|
93
|
+
console.log(" Proceeding with soft uninstall...\n");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
process.exit(0);
|
|
97
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sketchboard-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "SketchBoard — local-first whiteboard app. Run with: npx sketchboard-app",
|
|
5
5
|
"main": "server.js",
|
|
6
6
|
"bin": {
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
17
|
"start": "NODE_ENV=production node server.js",
|
|
18
|
-
"dev": "nodemon server.js"
|
|
18
|
+
"dev": "nodemon server.js",
|
|
19
|
+
"preuninstall": "node bin/uninstall.js"
|
|
19
20
|
},
|
|
20
21
|
"dependencies": {
|
|
21
22
|
"compression": "^1.7.4",
|