@rightkit/release 0.2.159 → 0.2.160
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/disk-command.mjs +53 -8
- package/package.json +1 -1
- package/rightkit-versions.json +4 -3
package/disk-command.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { existsSync, mkdirSync, realpathSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
6
|
import { spawnSync } from "./background-process.mjs";
|
|
7
|
+
import { compareVersions } from "./rightkit-sync.mjs";
|
|
7
8
|
import {
|
|
8
9
|
DISK_EXIT_WARNING, applySweep, checkDisk, formatBytes, listOpenPaths, logEvent, planSweep, platformKey, purgeHoldings, readDiskPolicy,
|
|
9
10
|
} from "./disk-policy.mjs";
|
|
@@ -65,13 +66,57 @@ export function insideGitCheckout(file, exists = existsSync) {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
const CLI_TAIL = path.join("@rightkit", "release", "cli", "right-release.mjs");
|
|
70
|
+
const SHIM_TARGET = /(%~dp0|%dp0%|\$basedir|\$PSScriptRoot)?([^\s"'%$=;~]*node_modules[\\/]@rightkit[\\/]release[\\/]cli[\\/]right-release\.mjs)/;
|
|
71
|
+
|
|
72
|
+
/** Target `cli/right-release.mjs` behind the `right-release` bin on PATH: the realpath of the bin when it is the script
|
|
73
|
+
* itself, otherwise the path a pnpm/npm shim (.cmd, .ps1 or sh script) names, resolved against the shim's directory. */
|
|
74
|
+
export function cliFromPathBin({ env = process.env, exists = existsSync, readFile = (f) => readFileSync(f, "utf8") } = {}) {
|
|
75
|
+
const found = [];
|
|
76
|
+
for (const dir of String(env.PATH ?? env.Path ?? "").split(path.delimiter).filter(Boolean)) {
|
|
77
|
+
for (const name of ["right-release", "right-release.cmd", "right-release.ps1", "right-release.mjs"]) {
|
|
78
|
+
const bin = path.join(dir, name);
|
|
79
|
+
if (!exists(bin)) continue;
|
|
80
|
+
let real = bin;
|
|
81
|
+
try { real = realpathSync(bin); } catch { /* keep lexical */ }
|
|
82
|
+
if (real.endsWith(path.join("cli", "right-release.mjs"))) { found.push(real); continue; }
|
|
83
|
+
try {
|
|
84
|
+
const m = SHIM_TARGET.exec(readFile(real));
|
|
85
|
+
if (m) found.push(path.resolve(dir, (m[1] ? m[2].replace(/^[\\/]+/, "") : m[2]).split(/[\\/]/).join(path.sep)));
|
|
86
|
+
} catch { /* unreadable shim */ }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return found;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const versionOf = (cli, readFile) => {
|
|
93
|
+
try { return JSON.parse(readFile(path.join(path.dirname(cli), "..", "package.json"))).version; } catch { return "0.0.0"; }
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/** Global-root candidates: `<root>/@rightkit/release/...` (npm, pnpm <= 10) and `<root>/<hash>/node_modules/@rightkit/release/...`
|
|
97
|
+
* (pnpm 11 global layout), highest installed version first. */
|
|
98
|
+
export function cliFromGlobalRoots(roots, { exists = existsSync, readdir = (d) => readdirSync(d), readFile = (f) => readFileSync(f, "utf8") } = {}) {
|
|
99
|
+
const found = [];
|
|
100
|
+
for (const root of roots) {
|
|
101
|
+
found.push(path.join(root, CLI_TAIL));
|
|
102
|
+
let names = [];
|
|
103
|
+
try { names = readdir(root); } catch { /* root absent */ }
|
|
104
|
+
for (const name of names) found.push(path.join(root, name, "node_modules", CLI_TAIL));
|
|
105
|
+
}
|
|
106
|
+
return found.filter((f) => exists(f))
|
|
107
|
+
.map((f) => ({ f, v: versionOf(f, readFile) }))
|
|
108
|
+
.sort((x, y) => { try { return compareVersions(y.v, x.v); } catch { return 0; } })
|
|
109
|
+
.map((x) => x.f);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Installed @rightkit/release CLI for the Windows task: explicit --cli / RIGHT_RELEASE_INSTALLED_CLI, else the target of the
|
|
113
|
+
* `right-release` bin on PATH, else the global package roots (`npm root -g`, `pnpm root -g`, hashed pnpm 11 layout included).
|
|
114
|
+
* Only a candidate inside a git checkout is refused; the installed package may itself run install. */
|
|
115
|
+
export function resolveInstalledCli({ explicit, env = process.env, globalRoots = defaultGlobalRoots, exists = existsSync, readFile, readdir, pathBin = cliFromPathBin } = {}) {
|
|
116
|
+
const fixed = explicit || env.RIGHT_RELEASE_INSTALLED_CLI;
|
|
117
|
+
const candidates = fixed
|
|
118
|
+
? [fixed]
|
|
119
|
+
: [...pathBin({ env, exists, ...(readFile ? { readFile } : {}) }), ...cliFromGlobalRoots(globalRoots({ env }), { exists, ...(readFile ? { readFile } : {}), ...(readdir ? { readdir } : {}) })];
|
|
75
120
|
for (const candidate of candidates) {
|
|
76
121
|
if (!exists(candidate)) continue;
|
|
77
122
|
let real = candidate;
|
package/package.json
CHANGED
package/rightkit-versions.json
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@rightkit/qa": "0.4.8",
|
|
32
32
|
"@rightkit/qa-chrome": "0.1.6",
|
|
33
33
|
"@rightkit/react-shell": "0.6.4",
|
|
34
|
-
"@rightkit/release": "0.2.
|
|
34
|
+
"@rightkit/release": "0.2.160",
|
|
35
35
|
"@rightkit/settings-ui": "0.4.4",
|
|
36
36
|
"@rightkit/tauri": "0.2.1",
|
|
37
37
|
"@rightkit/tauri-shell": "0.1.1",
|
|
@@ -200,7 +200,8 @@
|
|
|
200
200
|
"0.2.151",
|
|
201
201
|
"0.2.155",
|
|
202
202
|
"0.2.156",
|
|
203
|
-
"0.2.158"
|
|
203
|
+
"0.2.158",
|
|
204
|
+
"0.2.159"
|
|
204
205
|
],
|
|
205
206
|
"@rightkit/qa": [
|
|
206
207
|
"0.1.0",
|
|
@@ -509,7 +510,7 @@
|
|
|
509
510
|
"@rightkit/qa": "0.4.8",
|
|
510
511
|
"@rightkit/qa-chrome": "0.1.6",
|
|
511
512
|
"@rightkit/react-shell": "0.6.4",
|
|
512
|
-
"@rightkit/release": "0.2.
|
|
513
|
+
"@rightkit/release": "0.2.159",
|
|
513
514
|
"@rightkit/settings-ui": "0.4.4",
|
|
514
515
|
"@rightkit/shell": "0.1.1",
|
|
515
516
|
"@rightkit/tauri": "0.2.1",
|