yaver-cli 1.96.10 → 1.96.12
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/package.json +1 -1
- package/src/preuninstall.js +42 -15
package/package.json
CHANGED
package/src/preuninstall.js
CHANGED
|
@@ -1,23 +1,50 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// npm preuninstall hook — best-effort
|
|
3
|
-
//
|
|
4
|
-
//
|
|
2
|
+
// npm preuninstall hook — best-effort cleanup before the binary is removed.
|
|
3
|
+
//
|
|
4
|
+
// Two cleanup steps, both fire-and-forget. Order matters: notify Convex
|
|
5
|
+
// FIRST while the agent process still has its token + deviceId in memory,
|
|
6
|
+
// THEN unregister MCP integrations.
|
|
7
|
+
//
|
|
8
|
+
// 1. `yaver wipe --including-auth --yes` — stops the running agent and
|
|
9
|
+
// deletes the device record from Convex so mobile / web stop showing
|
|
10
|
+
// it as live the moment npm uninstall completes (instead of waiting
|
|
11
|
+
// 90 s for the heartbeat-staleness gate). Skipped via env
|
|
12
|
+
// YAVER_SKIP_PREUNINSTALL_WIPE=1 if a user wants `npm uninstall +
|
|
13
|
+
// reinstall` without losing their device row.
|
|
14
|
+
//
|
|
15
|
+
// 2. `yaver mcp unregister` — removes Claude Desktop / Claude Code /
|
|
16
|
+
// Codex / Cursor / VS Code / Windsurf / Zed entries.
|
|
5
17
|
//
|
|
6
18
|
// Must NEVER fail the uninstall. If yaver is not on PATH, silently succeed.
|
|
7
19
|
|
|
8
20
|
const { spawnSync } = require("node:child_process");
|
|
9
21
|
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
function envEnabled(name) {
|
|
23
|
+
const raw = String(process.env[name] || "").trim().toLowerCase();
|
|
24
|
+
return raw === "1" || raw === "true" || raw === "yes";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function safeRun(cmd, args, timeoutMs) {
|
|
28
|
+
try {
|
|
29
|
+
const res = spawnSync(cmd, args, {
|
|
30
|
+
// Send output to stderr so npm's progress bar isn't disturbed.
|
|
31
|
+
stdio: ["ignore", "ignore", "inherit"],
|
|
32
|
+
timeout: timeoutMs,
|
|
33
|
+
});
|
|
34
|
+
if (res.error && res.error.code === "ENOENT") return false;
|
|
35
|
+
return true;
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
18
38
|
}
|
|
19
|
-
// Ignore exit code; we always succeed so npm uninstall can finish.
|
|
20
|
-
process.exit(0);
|
|
21
|
-
} catch {
|
|
22
|
-
process.exit(0);
|
|
23
39
|
}
|
|
40
|
+
|
|
41
|
+
if (!envEnabled("YAVER_SKIP_PREUNINSTALL_WIPE")) {
|
|
42
|
+
// 8 s budget: stops agent (~500 ms), tells Convex (~5 s shutdown
|
|
43
|
+
// timeout), wipes ~/.yaver. Plenty of slack but bounded so a slow
|
|
44
|
+
// network never strands `npm uninstall`.
|
|
45
|
+
safeRun("yaver", ["wipe", "--including-auth", "--yes"], 8_000);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
safeRun("yaver", ["mcp", "unregister"], 15_000);
|
|
49
|
+
|
|
50
|
+
process.exit(0);
|