@bivy/bivy 0.8.3-staging.119 → 0.8.3-staging.121
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/bivy.mjs +7 -8
- package/bin/uninstall-paths.mjs +24 -0
- package/package.json +1 -1
package/bin/bivy.mjs
CHANGED
|
@@ -36,7 +36,7 @@ import vm from "node:vm";
|
|
|
36
36
|
import { selectStaleSessions, sessionActivityMs } from "./prune-sessions.mjs";
|
|
37
37
|
import { resolveSessionsLimit, truncateSavedSessions } from "./sessions-list.mjs";
|
|
38
38
|
import { renderManagedBlock, upsertManagedBlock, removeManagedBlock, rcFileForShell } from "./shim-path.mjs";
|
|
39
|
-
import {
|
|
39
|
+
import { removeInstallAndState } from "./uninstall-paths.mjs";
|
|
40
40
|
import { findAvailablePort, reconcilePort } from "./port-picker.mjs";
|
|
41
41
|
import { resolveAttachSessionId } from "./attach-session-id.mjs";
|
|
42
42
|
|
|
@@ -4126,14 +4126,13 @@ async function cmdUninstall(args = []) {
|
|
|
4126
4126
|
console.log(c.green(`Removed ${removed} worktree(s).`));
|
|
4127
4127
|
}
|
|
4128
4128
|
|
|
4129
|
-
// Delete
|
|
4130
|
-
//
|
|
4131
|
-
//
|
|
4132
|
-
//
|
|
4133
|
-
//
|
|
4134
|
-
// removed as normal.
|
|
4129
|
+
// Delete all local state and, for a packaged install, the package itself.
|
|
4130
|
+
// npm-global installs keep state outside repoRoot (normally ~/.bivy), while
|
|
4131
|
+
// tarball installs keep it below repoRoot; removeInstallAndState handles
|
|
4132
|
+
// both layouts. With --keep-sessions, the transcripts and session index
|
|
4133
|
+
// remain in place while config, credentials, relay enrollment, etc. go.
|
|
4135
4134
|
const keepPaths = keepSessions ? [sessionsDir, metadataPath].filter((p) => fs.existsSync(p)) : [];
|
|
4136
|
-
|
|
4135
|
+
removeInstallAndState(repoRoot, appDir, { keepInstall: isGitCheckout, keepState: keepPaths });
|
|
4137
4136
|
fs.rmSync(symlink, { force: true });
|
|
4138
4137
|
|
|
4139
4138
|
console.log(c.green("\nBivy uninstalled from this machine."));
|
package/bin/uninstall-paths.mjs
CHANGED
|
@@ -46,3 +46,27 @@ export function removeExcept(root, keep) {
|
|
|
46
46
|
};
|
|
47
47
|
walk(root);
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
function isInside(parent, candidate) {
|
|
51
|
+
const relative = path.relative(path.resolve(parent), path.resolve(candidate));
|
|
52
|
+
return relative === "" || (relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Remove the state directory and, for packaged installs, the install directory.
|
|
57
|
+
* Tarball installs keep state below the install directory, while npm-global
|
|
58
|
+
* installs keep it separately (normally ~/.bivy), so both layouts must be
|
|
59
|
+
* handled without deleting paths requested by --keep-sessions.
|
|
60
|
+
*/
|
|
61
|
+
export function removeInstallAndState(installDir, stateDir, { keepInstall = false, keepState = [] } = {}) {
|
|
62
|
+
if (keepInstall) {
|
|
63
|
+
removeExcept(stateDir, keepState);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (isInside(installDir, stateDir)) {
|
|
67
|
+
removeExcept(installDir, keepState);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
removeExcept(stateDir, keepState);
|
|
71
|
+
fs.rmSync(installDir, { recursive: true, force: true });
|
|
72
|
+
}
|
package/package.json
CHANGED