@rightkit/release 0.6.79 → 0.6.81
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/acceptance-lines.mjs +18 -15
- package/acceptance-lines.test.mjs +979 -0
- package/acceptance-result.mjs +58 -1
- package/bin/darwin/rightkit-swap +0 -0
- package/bin/darwin/rightkit-swap.sha256 +1 -0
- package/bin/rightkit-gate.mjs +29 -5
- package/cargo-license-notices.mjs +5 -1
- package/cli/right-release.mjs +0 -0
- package/gate-release-admission.mjs +1 -1
- package/install-app.mjs +20 -1
- package/local-publish.mjs +14 -8
- package/ownership-mandatory-set.json +120 -0
- package/package.json +10 -11
- package/publish-cargo.mjs +7 -3
- package/publish-local-npm.mjs +75 -35
- package/rightkit-registry-resolver.mjs +12 -2
- package/rightkit-versions.json +159 -91
- package/seam-broker.mjs +30 -10
- package/shell-contract.mjs +36 -0
- package/swap-helper-bundle.mjs +16 -0
- package/unit-gate.mjs +4 -2
package/publish-local-npm.mjs
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// `right-release publish-local npm --package @rightkit/<name> --commit <sha>`: the local npm route (Adrian, 2026-11-03, rightkit#1471:
|
|
3
3
|
// "i want you to publish it from local. the npm and crates are both local. we will do a provenance skip fuck your ci. feel free to push
|
|
4
|
-
// but no ci"). Mac
|
|
5
|
-
// this process, never printed, never on a command line, never left on disk.
|
|
4
|
+
// but no ci"). On the Mac the token is the granular @rightkit token with 2FA bypass in the Keychain item npm-rightkit-publish, read inside
|
|
5
|
+
// this process, never printed, never on a command line, never left on disk. On Windows (Adrian, 2026-11-25: npm is signed in on the Dell
|
|
6
|
+
// too; publishing is local on the Mac and the Dell) npm publishes with the account's own npm sign-in, the .npmrc in the account's profile
|
|
7
|
+
// folder (os.userInfo().homedir, not $HOME, which an agent profile can move); this process never reads it. Elsewhere it is refused.
|
|
8
|
+
// `--archive <tgz>` publishes that exact packed file instead of packing the commit (it must be the commit's package and version): the
|
|
9
|
+
// gate package is published as the archive its acceptance run admitted (GATE-CONTRACT NN31), with its Mac-signed helper inside.
|
|
6
10
|
//
|
|
7
11
|
// It publishes exactly the bytes of one commit, and only after:
|
|
8
12
|
// 1. the commit is on origin/main (pushed; [skip ci] is fine);
|
|
@@ -55,9 +59,10 @@ export function checkoutStoreDir(repo, readFile = (f) => fs.readFileSync(f, "utf
|
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
export function parseArgs(argv) {
|
|
58
|
-
const out = { kind: argv[0], pkg: null, commit: null, repo: process.cwd() };
|
|
62
|
+
const out = { kind: argv[0], pkg: null, commit: null, repo: process.cwd(), archive: null };
|
|
59
63
|
for (let i = 1; i < argv.length; i += 1) {
|
|
60
64
|
if (argv[i] === "--package") out.pkg = argv[++i];
|
|
65
|
+
else if (argv[i] === "--archive") out.archive = path.resolve(argv[++i] ?? fail("--archive <packed .tgz> needs a file"));
|
|
61
66
|
else if (argv[i] === "--commit") out.commit = argv[++i];
|
|
62
67
|
else if (argv[i] === "--repo") out.repo = path.resolve(argv[++i]);
|
|
63
68
|
else fail(`unknown option ${argv[i]}`);
|
|
@@ -68,9 +73,23 @@ export function parseArgs(argv) {
|
|
|
68
73
|
return out;
|
|
69
74
|
}
|
|
70
75
|
|
|
71
|
-
|
|
76
|
+
/** The account's own npm config on Windows: <profile folder>/.npmrc, where `npm login` on that account writes its sign-in. */
|
|
77
|
+
export const accountNpmrc = () => path.join(os.userInfo().homedir, ".npmrc");
|
|
78
|
+
|
|
79
|
+
/** npm and pnpm are .cmd shims on Windows, which Node starts only through cmd.exe; elsewhere they run as they are. Arguments here are
|
|
80
|
+
* validated names, versions, hex shas and paths this process made, so cmd.exe sees no caller text. */
|
|
81
|
+
export function toolCommand(command, args, platform = process.platform, comspec = process.env.ComSpec || "cmd.exe") {
|
|
82
|
+
if (platform === "win32" && (command === "npm" || command === "pnpm")) return [comspec, ["/d", "/s", "/c", command, ...args]];
|
|
83
|
+
return [command, args];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function publishLocalNpm(argv, { run = spawnSync, log = console.log, platform = process.platform, readToken = () => readKeychainToken(run), npmrc = accountNpmrc, exists = fs.existsSync, verifyTries = 20, verifyDelaySeconds = 15 } = {}) {
|
|
72
87
|
const o = parseArgs(argv);
|
|
73
|
-
if (platform !== "darwin") fail(`publish-local npm runs on the Mac (the token is the Keychain item ${NPM_KEYCHAIN_SERVICE}); this host is ${platform}`);
|
|
88
|
+
if (platform !== "darwin" && platform !== "win32") fail(`publish-local npm runs on the Mac (the token is the Keychain item ${NPM_KEYCHAIN_SERVICE}) or Windows (the account's own npm sign-in); this host is ${platform}`);
|
|
89
|
+
const userNpmrc = platform === "win32" ? npmrc() : null;
|
|
90
|
+
if (userNpmrc && !exists(userNpmrc)) fail(`publish-local npm on Windows publishes with this account's npm sign-in, and ${userNpmrc} does not exist: run npm login on this account once`);
|
|
91
|
+
const tool = (command, args, options) => { const [c, a] = toolCommand(command, args, platform); return run(c, a, options); };
|
|
92
|
+
const pause = (seconds) => (platform === "win32" ? Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, seconds * 1000) : run("sleep", [String(seconds)]));
|
|
74
93
|
const git = (args) => {
|
|
75
94
|
const r = run("git", args, { cwd: o.repo, encoding: "utf8", maxBuffer: 1 << 26 });
|
|
76
95
|
if (r.status !== 0) fail(`git ${args.join(" ")} failed: ${String(r.stderr ?? "").trim()}`);
|
|
@@ -93,39 +112,60 @@ export function publishLocalNpm(argv, { run = spawnSync, log = console.log, plat
|
|
|
93
112
|
if (classA.status !== 0) fail(`Class A failed for npm:${o.pkg} on ${commit} (exit ${classA.status}); nothing published`);
|
|
94
113
|
|
|
95
114
|
// The agent volume, not the internal drive: the export holds a full install (workspace rule: run output under /Volumes/D/scratch).
|
|
96
|
-
const scratchRoot =
|
|
115
|
+
const scratchRoot = ["/Volumes/D/scratch", "D:\\scratch"].find((d) => fs.existsSync(d)) ?? os.tmpdir();
|
|
97
116
|
const work = fs.mkdtempSync(path.join(scratchRoot, "rk-publish-local-"));
|
|
98
117
|
try {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
let tgzFile;
|
|
119
|
+
if (o.archive) {
|
|
120
|
+
// The exact file given: it must be this commit's package at this version (its own package/package.json says so).
|
|
121
|
+
if (!fs.existsSync(o.archive)) fail(`--archive ${o.archive} does not exist`);
|
|
122
|
+
tgzFile = path.join(work, path.basename(o.archive));
|
|
123
|
+
fs.copyFileSync(o.archive, tgzFile, fs.constants.COPYFILE_EXCL);
|
|
124
|
+
const inner = run("tar", ["-xzOf", tgzFile, "package/package.json"], { encoding: "utf8", maxBuffer: 1 << 24 });
|
|
125
|
+
let packedManifest = null;
|
|
126
|
+
try { packedManifest = inner.status === 0 ? JSON.parse(String(inner.stdout ?? "")) : null; } catch { packedManifest = null; }
|
|
127
|
+
if (!packedManifest) fail(`--archive ${o.archive} has no readable package/package.json`);
|
|
128
|
+
if (packedManifest.name !== o.pkg || packedManifest.version !== version) fail(`--archive ${o.archive} is ${packedManifest.name}@${packedManifest.version}, not ${o.pkg}@${version} of ${commit.slice(0, 12)}`);
|
|
129
|
+
} else {
|
|
130
|
+
const tree = path.join(work, "tree");
|
|
131
|
+
fs.mkdirSync(tree);
|
|
132
|
+
const archive = run("git", ["archive", "--format=tar", commit], { cwd: o.repo, maxBuffer: 1 << 30 });
|
|
133
|
+
if (archive.status !== 0) fail(`git archive ${commit} failed`);
|
|
134
|
+
const tarIn = run("tar", ["-x", "-f", "-", "-C", tree], { input: archive.stdout });
|
|
135
|
+
if (tarIn.status !== 0) fail("unpacking the commit's tree failed");
|
|
136
|
+
// The package and its workspace dependencies, from the commit's lockfile only, offline from the store; no dependency's install scripts run.
|
|
137
|
+
const install = tool("pnpm", ["install", "--frozen-lockfile", "--offline", "--ignore-scripts", "--ignore-pnpmfile", "--store-dir", checkoutStoreDir(o.repo), "--filter", `${o.pkg}...`], { cwd: tree, encoding: "utf8", maxBuffer: 1 << 28 });
|
|
138
|
+
if (install.status !== 0) fail(`pnpm install (offline, frozen lockfile) for ${o.pkg} failed: ${String(install.stderr || install.stdout || "").trim().split(/\r?\n/).slice(-3).join(" | ")}`);
|
|
139
|
+
// Workspace dependencies resolve through their dist/ (gitignored, so not in the export): build them first, in dependency order.
|
|
140
|
+
const deps = tool("pnpm", ["-r", "--filter", `${o.pkg}^...`, "run", "--if-present", "build"], { cwd: tree, encoding: "utf8", maxBuffer: 1 << 28 });
|
|
141
|
+
if (deps.status !== 0) fail(`building ${o.pkg}'s workspace dependencies failed: ${String(deps.stderr || deps.stdout || "").trim().split(/\r?\n/).slice(-3).join(" | ")}`);
|
|
142
|
+
const pkgDir = path.join(tree, dir);
|
|
143
|
+
const packed = tool("pnpm", ["pack", "--pack-destination", work], { cwd: pkgDir, encoding: "utf8" });
|
|
144
|
+
if (packed.status !== 0) fail(`pnpm pack failed: ${String(packed.stderr ?? packed.stdout ?? "").trim().split(/\r?\n/).slice(-3).join(" | ")}`);
|
|
145
|
+
const tgz = fs.readdirSync(work).find((f) => f.endsWith(".tgz"));
|
|
146
|
+
if (!tgz) fail("pnpm pack wrote no tarball");
|
|
147
|
+
tgzFile = path.join(work, tgz);
|
|
148
|
+
}
|
|
149
|
+
const bytes = fs.readFileSync(tgzFile);
|
|
117
150
|
const sha1 = crypto.createHash("sha1").update(bytes).digest("hex");
|
|
118
|
-
log(`publish-local: packed ${
|
|
151
|
+
log(`publish-local: ${o.archive ? "given" : "packed"} ${path.basename(tgzFile)} sha1 ${sha1}`);
|
|
119
152
|
|
|
120
|
-
// GATE-CONTRACT NN31: the gate package is published only with a passing contract-test receipt for this exact file. Before
|
|
121
|
-
try { gateReleaseGuard({ name: o.pkg, archiveFile:
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
153
|
+
// GATE-CONTRACT NN31: the gate package is published only with a passing contract-test receipt for this exact file. Before any credential is used.
|
|
154
|
+
try { gateReleaseGuard({ name: o.pkg, archiveFile: tgzFile, commit }); } catch (error) { fail(error.message); }
|
|
155
|
+
const publishArgs = ["publish", tgzFile, "--access", "public", "--provenance=false", "--registry", REGISTRY];
|
|
156
|
+
let pub;
|
|
157
|
+
if (userNpmrc) {
|
|
158
|
+
// Windows: npm reads the account's own sign-in from that file itself; this process neither reads it nor passes a token.
|
|
159
|
+
pub = tool("npm", [...publishArgs, "--userconfig", userNpmrc], { encoding: "utf8" });
|
|
160
|
+
if (pub.status !== 0) fail(`npm publish failed:\n${`${pub.stdout ?? ""}${pub.stderr ?? ""}`.trim()}`);
|
|
161
|
+
} else {
|
|
162
|
+
const token = readToken();
|
|
163
|
+
const userconfig = path.join(work, "npmrc");
|
|
164
|
+
fs.writeFileSync(userconfig, "//registry.npmjs.org/:_authToken=${RIGHTKIT_NPM_TOKEN}\n", { mode: 0o600 });
|
|
165
|
+
const redact = (text) => String(text ?? "").split(token).join("<redacted>");
|
|
166
|
+
pub = tool("npm", [...publishArgs, "--userconfig", userconfig], { encoding: "utf8", env: { ...process.env, RIGHTKIT_NPM_TOKEN: token } });
|
|
167
|
+
if (pub.status !== 0) fail(`npm publish failed:\n${redact(`${pub.stdout ?? ""}${pub.stderr ?? ""}`).trim()}`);
|
|
168
|
+
}
|
|
129
169
|
|
|
130
170
|
// The registry may take a moment to serve a new version. Every try asks the registry directly, logs its status when it has no answer, and the
|
|
131
171
|
// command fails only after the whole wait (verifyTries x verifyDelaySeconds); a served version with another shasum fails at once.
|
|
@@ -137,7 +177,7 @@ export function publishLocalNpm(argv, { run = spawnSync, log = console.log, plat
|
|
|
137
177
|
else {
|
|
138
178
|
last = doc.error ?? `HTTP ${doc.status} without dist.shasum`;
|
|
139
179
|
log(`publish-local: registry try ${i}/${verifyTries} for ${o.pkg}@${version}: ${last}${i < verifyTries ? `; retrying in ${verifyDelaySeconds}s` : ""}`);
|
|
140
|
-
if (i < verifyTries)
|
|
180
|
+
if (i < verifyTries) pause(verifyDelaySeconds);
|
|
141
181
|
}
|
|
142
182
|
}
|
|
143
183
|
if (!shasum) fail(`registry never served ${o.pkg}@${version} after ${verifyTries} tries ${verifyDelaySeconds}s apart (last: ${last}); the publish itself succeeded, so check ${REGISTRY}${o.pkg.replace("/", "%2f")}/${version} before publishing again`);
|
|
@@ -661,7 +661,11 @@ function holdFor(holds, name) {
|
|
|
661
661
|
* (`tasks`), never permission to seal a stale pin; no exception is derived from right-update's hold list.
|
|
662
662
|
* - otherwise (doctor): the same rows are informational `newer` lines.
|
|
663
663
|
*/
|
|
664
|
-
export function evaluateRightKitFreshness(snapshot, holds, { enforce = false } = {}) {
|
|
664
|
+
export function evaluateRightKitFreshness(snapshot, holds, { enforce = false, declared = null } = {}) {
|
|
665
|
+
// `declared`: the RightKit names the app's own manifests declare (`${ecosystem}\0${name}`). A stale entry the app does not declare is a
|
|
666
|
+
// transitive lock entry: only the RightKit units that depend on it can move it, so it is reported, never refused (Pulse 0.6.80: rightkit-fs
|
|
667
|
+
// 0.4.19, required ^0.4 by the latest rightkit-http, -pdf and others). With no set given every entry is judged as before.
|
|
668
|
+
const isDirect = (entry) => !declared || declared.has(`${entry.ecosystem}\0${entry.name}`);
|
|
665
669
|
const refusals = [];
|
|
666
670
|
const newer = [];
|
|
667
671
|
const tasks = [];
|
|
@@ -673,6 +677,10 @@ export function evaluateRightKitFreshness(snapshot, holds, { enforce = false } =
|
|
|
673
677
|
const seen = newest.get(`${entry.ecosystem}\0${entry.name}`);
|
|
674
678
|
if (!seen || compareVersions(entry.version, seen.latest) >= 0) continue;
|
|
675
679
|
const age = seen.via === "cache" ? ` (latest from cached observation ${seen.observedAt}, ${formatAge(seen.ageMs)} old; last-observed, not current)` : "";
|
|
680
|
+
if (!isDirect(entry)) {
|
|
681
|
+
warnings.push(`${entry.name} ${entry.version} is in the lock only through other RightKit units (latest ${seen.latest}${age}); the app does not declare it, so it moves when those units republish on the new version`);
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
676
684
|
const hold = holdFor(holds, entry.name);
|
|
677
685
|
const line = `${entry.name} pinned ${entry.version} -> latest ${seen.latest}${age}: ${FIX}`;
|
|
678
686
|
if (hold) tasks.push(`${entry.name} pinned ${entry.version}, latest ${seen.latest}: held by .rightkit/update.json (${hold}); migration lane task, not current and not permission to seal`);
|
|
@@ -721,7 +729,9 @@ export async function prepareRightKitResolution({ root, snapshotFile = null, bou
|
|
|
721
729
|
// Freshness is an admission gate. A bound snapshot is frozen evidence: seal, resume and upload never re-check it,
|
|
722
730
|
// so a publication after admission neither mutates nor restarts an admitted build.
|
|
723
731
|
const enforce = admission && source === "resolved";
|
|
724
|
-
|
|
732
|
+
let declared = null;
|
|
733
|
+
try { declared = new Set(declaredRightKitDependencies(root, ownedRightKitNames(versions, ownership), options.extraLocks ?? []).map((d) => `${d.ecosystem}\0${d.name}`)); } catch { declared = null; }
|
|
734
|
+
const freshness = evaluateRightKitFreshness(snapshot, readUpdateHolds(root), { enforce, declared });
|
|
725
735
|
if (freshness.refusals.length) {
|
|
726
736
|
throw new RightKitRegistryError("stale-pin", `RightKit pins are behind the latest published version (build admission refused):\n${freshness.refusals.map((p) => `- ${p}`).join("\n")}`, { problems: freshness.refusals });
|
|
727
737
|
}
|