@rightkit/release 0.2.59 → 0.2.61

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.
@@ -17,7 +17,11 @@ export function isolatedCargoMetadataEnv(cargoHome, env = process.env) {
17
17
  }
18
18
 
19
19
  export function cargoExecutable(platform = process.platform) {
20
- return platform === "win32" ? "cargo.exe" : "cargo";
20
+ return platform === "win32" ? "rustup" : "cargo";
21
+ }
22
+
23
+ export function cargoArguments(args, platform = process.platform) {
24
+ return platform === "win32" ? ["run", "stable", "cargo", ...args] : args;
21
25
  }
22
26
 
23
27
  export function validateRightKitCargoContract(root, publishedVersions, label = path.basename(root)) {
@@ -77,7 +81,7 @@ export function assertNoRightKitCargoOverrides(manifestPath, repoRoot, label) {
77
81
  function readCargoManifestDependencies(manifestPath, cargoHome, label) {
78
82
  const result = spawnSync(
79
83
  cargoExecutable(),
80
- ["metadata", "--no-deps", "--offline", "--format-version", "1", "--manifest-path", manifestPath],
84
+ cargoArguments(["metadata", "--no-deps", "--offline", "--format-version", "1", "--manifest-path", manifestPath]),
81
85
  {
82
86
  cwd: path.dirname(manifestPath),
83
87
  encoding: "utf8",
@@ -78,8 +78,11 @@ export function publishGitHubRelease(plan, { repo, dryRun = false, run = runComm
78
78
  const existing = run("gh", ["release", "view", plan.tag, "--repo", repo, "--json", "tagName"], { allowFailure: true });
79
79
  if (dryRun) return { status: existing.ok ? plan.kind === "addon" ? "would-verify" : "would-update" : "would-create", tag: plan.tag, assets: plan.assets };
80
80
  if (plan.kind === "addon" && existing.ok) {
81
+ const missing = plan.assets.filter((asset) => inspectRemoteAsset(plan.tag, repo, asset, run) === "missing");
82
+ if (missing.length === 0) return { status: "already-verified", tag: plan.tag, assets: plan.assets, manifestUrl: plan.manifestUrl };
83
+ run("gh", ["release", "upload", plan.tag, ...missing, "--repo", repo]);
81
84
  for (const asset of plan.assets) verifyRemoteAsset(plan.tag, repo, asset, run);
82
- return { status: "already-verified", tag: plan.tag, assets: plan.assets, manifestUrl: plan.manifestUrl };
85
+ return { status: "resumed-verified", tag: plan.tag, assets: plan.assets, manifestUrl: plan.manifestUrl };
83
86
  }
84
87
  if (!existing.ok) {
85
88
  const notesFile = plan.notesFile;
@@ -87,7 +90,7 @@ export function publishGitHubRelease(plan, { repo, dryRun = false, run = runComm
87
90
  run("gh", ["release", "create", plan.tag, "--repo", repo, "--title", plan.title, "--notes-file", notesFile]);
88
91
  rmSync(notesFile, { force: true });
89
92
  }
90
- run("gh", ["release", "upload", plan.tag, ...plan.assets, "--repo", repo, "--clobber"]);
93
+ run("gh", ["release", "upload", plan.tag, ...plan.assets, "--repo", repo, ...(plan.kind === "addon" ? [] : ["--clobber"])]);
91
94
  for (const asset of plan.assets) verifyRemoteAsset(plan.tag, repo, asset, run);
92
95
  return { status: "verified", tag: plan.tag, assets: plan.assets, manifestUrl: plan.manifestUrl };
93
96
  }
@@ -110,13 +113,23 @@ function verifyPlatformTrust(plan) {
110
113
  }
111
114
 
112
115
  function verifyRemoteAsset(tag, repo, asset, run) {
116
+ if (inspectRemoteAsset(tag, repo, asset, run) !== "match") throw new Error(`GitHub release asset missing: ${path.basename(asset)}`);
117
+ }
118
+
119
+ function inspectRemoteAsset(tag, repo, asset, run) {
113
120
  const verifyDir = `${path.dirname(asset)}/verify-${path.basename(asset)}`;
114
121
  rmSync(verifyDir, { recursive: true, force: true });
115
122
  mkdirSync(verifyDir, { recursive: true });
116
- run("gh", ["release", "download", tag, "--repo", repo, "--pattern", path.basename(asset), "--dir", verifyDir]);
123
+ const result = run("gh", ["release", "download", tag, "--repo", repo, "--pattern", path.basename(asset), "--dir", verifyDir], { allowFailure: true });
124
+ if (!result.ok) {
125
+ rmSync(verifyDir, { recursive: true, force: true });
126
+ if (/no assets match|not found/i.test(`${result.output ?? ""}\n${result.error ?? ""}`)) return "missing";
127
+ throw new Error(`cannot inspect GitHub release asset: ${path.basename(asset)}: ${result.error || result.output}`);
128
+ }
117
129
  const downloaded = path.join(verifyDir, path.basename(asset));
118
130
  if (!existsSync(downloaded) || sha256(downloaded) !== sha256(asset)) throw new Error(`GitHub release asset hash mismatch: ${path.basename(asset)}`);
119
131
  rmSync(verifyDir, { recursive: true, force: true });
132
+ return "match";
120
133
  }
121
134
 
122
135
  function sha256(file) {
@@ -80,10 +80,24 @@ test("existing GitHub add-on release is verified without upload mutation", () =>
80
80
  calls.push(args);
81
81
  if (args[0] === "repo") return JSON.stringify({ visibility: "PUBLIC" });
82
82
  if (args[0] === "release" && args[1] === "view") return options.allowFailure ? { ok: true } : "";
83
- if (args[0] === "release" && args[1] === "download") { mkdirSync(args[args.indexOf("--dir") + 1], { recursive: true }); writeFileSync(path.join(args[args.indexOf("--dir") + 1], path.basename(asset)), "sealed"); return ""; }
83
+ if (args[0] === "release" && args[1] === "download") { mkdirSync(args[args.indexOf("--dir") + 1], { recursive: true }); writeFileSync(path.join(args[args.indexOf("--dir") + 1], path.basename(asset)), "sealed"); return options.allowFailure ? { ok: true, output: "" } : ""; }
84
84
  throw new Error(`unexpected mutation: ${args.join(" ")}`);
85
85
  };
86
86
  const result = publishGitHubRelease({ kind: "addon", manifest: { files: [] }, sealedDir: path.dirname(asset), tag: "immutable", assets: [asset], manifestUrl: "https://example.test/manifest" }, { repo: "Orthic-Labs/Membrane", run });
87
87
  assert.equal(result.status, "already-verified");
88
88
  assert.equal(calls.some((args) => args[0] === "release" && args[1] === "upload"), false);
89
89
  });
90
+
91
+ test("partial GitHub add-on release uploads only missing assets then verifies all", () => {
92
+ const root = mkdtempSync(path.join(os.tmpdir(), "right-release-resume-")); const first = path.join(root, "first"); const second = path.join(root, "second"); writeFileSync(first, "one"); writeFileSync(second, "two");
93
+ const remote = new Map([["first", "one"]]); const uploads = [];
94
+ const run = (_command, args, options = {}) => {
95
+ if (args[0] === "repo") return JSON.stringify({ visibility: "PUBLIC" });
96
+ if (args[0] === "release" && args[1] === "view") return { ok: true };
97
+ if (args[0] === "release" && args[1] === "download") { const name = args[args.indexOf("--pattern") + 1]; if (!remote.has(name)) return { ok: false, error: "no assets match" }; const dir = args[args.indexOf("--dir") + 1]; mkdirSync(dir, { recursive: true }); writeFileSync(path.join(dir, name), remote.get(name)); return { ok: true, output: "" }; }
98
+ if (args[0] === "release" && args[1] === "upload") { for (const value of args.slice(3, args.indexOf("--repo"))) { uploads.push(path.basename(value)); remote.set(path.basename(value), readFileSync(value, "utf8")); } return ""; }
99
+ throw new Error(`unexpected call: ${args.join(" ")}`);
100
+ };
101
+ const result = publishGitHubRelease({ kind: "addon", manifest: { files: [] }, sealedDir: root, tag: "immutable", assets: [first, second], manifestUrl: "https://example.test/manifest" }, { repo: "Orthic-Labs/Membrane", run });
102
+ assert.equal(result.status, "resumed-verified"); assert.deepEqual(uploads, ["second"]);
103
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rightkit/release",
3
- "version": "0.2.59",
3
+ "version": "0.2.61",
4
4
  "description": "Portable Right Suite release CLI/SDK: signed installers, updater artifacts, patch/update routing, hardening, R2 publish, and RightApps registration.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,6 +8,7 @@ import test, { after } from "node:test";
8
8
  import {
9
9
  assertNoRightKitCargoOverrides,
10
10
  assertPublishedRightKitCargoDependencies,
11
+ cargoArguments,
11
12
  cargoExecutable,
12
13
  validateRightKitCargoContract,
13
14
  } from "./cargo-contract.mjs";
@@ -464,7 +465,7 @@ test("RightKit exposes one current version manifest", () => {
464
465
  "@rightkit/legal": "0.3.0",
465
466
  "@rightkit/legal-ui": "0.1.1",
466
467
  "@rightkit/license": "0.1.6",
467
- "@rightkit/release": "0.2.59",
468
+ "@rightkit/release": "0.2.61",
468
469
  "@rightkit/qa": "0.2.0",
469
470
  });
470
471
  assert.deepEqual(versions.legacyNpm, {
@@ -495,8 +496,9 @@ test("RightKit exposes one current version manifest", () => {
495
496
  getCurrentCargoVersionContract();
496
497
  });
497
498
 
498
- test("Cargo metadata uses the native Windows executable", () => {
499
- assert.equal(cargoExecutable("win32"), "cargo.exe");
499
+ test("Cargo metadata uses native rustup on Windows", () => {
500
+ assert.equal(cargoExecutable("win32"), "rustup");
501
+ assert.deepEqual(cargoArguments(["metadata"], "win32"), ["run", "stable", "cargo", "metadata"]);
500
502
  assert.equal(cargoExecutable("darwin"), "cargo");
501
503
  });
502
504
 
@@ -18,7 +18,7 @@
18
18
  "@rightkit/legal": "0.3.0",
19
19
  "@rightkit/legal-ui": "0.1.1",
20
20
  "@rightkit/license": "0.1.6",
21
- "@rightkit/release": "0.2.59",
21
+ "@rightkit/release": "0.2.61",
22
22
  "@rightkit/qa": "0.2.0"
23
23
  },
24
24
  "legacyNpm": {