@rightkit/release 0.6.40 → 0.6.42

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.
Files changed (85) hide show
  1. package/README.md +110 -11
  2. package/admission-files.mjs +40 -0
  3. package/admission-host.mjs +2 -1
  4. package/app-check.mjs +303 -16
  5. package/app-closure.mjs +6 -4
  6. package/bin/rightkit-gate.mjs +177 -32
  7. package/cargo-contract.mjs +17 -31
  8. package/cargo-license-notices.mjs +129 -19
  9. package/cargo-target-shim.mjs +14 -0
  10. package/carried-cargo.mjs +2 -4
  11. package/cli/right-release.mjs +24 -2
  12. package/cross-targets.mjs +24 -0
  13. package/deterministic-scans.mjs +150 -58
  14. package/development-signing.mjs +25 -2
  15. package/development.mjs +34 -1
  16. package/direct-release-command.mjs +154 -0
  17. package/disk-policy.mjs +16 -0
  18. package/feature-coverage.mjs +134 -0
  19. package/gate-coverage.mjs +38 -0
  20. package/gate-stages.mjs +1 -0
  21. package/ghsa-audit.mjs +95 -0
  22. package/install-app.mjs +33 -5
  23. package/install-channels.mjs +301 -0
  24. package/interactive-session-run.mjs +105 -0
  25. package/legal-contract.mjs +10 -1
  26. package/legion-freeze-consumer.mjs +241 -0
  27. package/linux-publish.mjs +136 -0
  28. package/local-publish.mjs +31 -8
  29. package/nsis-pack.mjs +95 -0
  30. package/nsis-upgrade-template.mjs +93 -0
  31. package/outdated-command.mjs +19 -0
  32. package/ownership-class-rules.mjs +32 -10
  33. package/ownership-mandatory-set.json +23 -0
  34. package/ownership-mandatory-set.mjs +66 -8
  35. package/package-recipe-targets.mjs +54 -19
  36. package/package.json +1 -1
  37. package/payload-root-install.mjs +123 -0
  38. package/plugin-delivery.mjs +141 -0
  39. package/prebuild-gates.mjs +8 -4
  40. package/preflight.mjs +6 -1
  41. package/provision-model-bundle.mjs +172 -0
  42. package/pub-upload.mjs +1 -1
  43. package/publish-local-npm.mjs +34 -9
  44. package/publish-retention.mjs +106 -0
  45. package/publish-update.mjs +15 -8
  46. package/qa-build-features.mjs +24 -15
  47. package/qa-contract.mjs +5 -6
  48. package/qa-control-scan.mjs +14 -0
  49. package/qa-web-pairing.mjs +76 -0
  50. package/r2-s3-multipart.mjs +190 -0
  51. package/r2-verified-upload.mjs +28 -16
  52. package/recipe-build.mjs +53 -3
  53. package/release-checks.mjs +53 -2
  54. package/release-config.mjs +8 -3
  55. package/release-invocation.mjs +12 -2
  56. package/release-pin-floor.mjs +44 -0
  57. package/release-qa-audit.mjs +18 -2
  58. package/release-qa-command.mjs +17 -1
  59. package/release-qa-policy.mjs +30 -3
  60. package/release-switch-cfg.mjs +271 -0
  61. package/release-switch-registry.json +60 -1
  62. package/release-switch-scan.mjs +398 -23
  63. package/release.mjs +97 -6
  64. package/render-views.mjs +141 -0
  65. package/rightkit-registry-resolver.mjs +1 -1
  66. package/rightkit-versions.json +140 -103
  67. package/runtime-artifact-manifest.mjs +9 -0
  68. package/runtime-manifest-refresh.mjs +88 -0
  69. package/rustright-stage.mjs +197 -0
  70. package/scan-digest.mjs +15 -9
  71. package/scan-tool-enrolment.mjs +1 -1
  72. package/security-policy.mjs +196 -0
  73. package/shell-contract.mjs +32 -0
  74. package/snapshot-broker.mjs +8 -1
  75. package/snapshot-check.mjs +58 -0
  76. package/snapshot-request.mjs +25 -2
  77. package/stage-commands.mjs +33 -4
  78. package/stage-receipt.mjs +115 -0
  79. package/stage-sidecar.mjs +188 -17
  80. package/stage-xcframework.mjs +118 -0
  81. package/suite-api.generated.mjs +16 -1
  82. package/unit-gate.mjs +14 -2
  83. package/upload-large.mjs +4 -4
  84. package/upload-release.mjs +6 -0
  85. package/win-package-recipe.mjs +26 -4
@@ -0,0 +1,271 @@
1
+ // Source-structure helpers for the release-switch scan (rightkit#937, #939, #1045, #1169). Pure text functions, no I/O except
2
+ // `buildScriptRefs`, which reads the build scripts it is given. They answer three questions the line-oriented source walk cannot:
3
+ //
4
+ // - Is this position inside an item the Rust compiler drops from a release build? (`rustCfgGatedRanges`, `rustFileGates`)
5
+ // Only an attribute `#[cfg(...)]` / `#![cfg(...)]` counts. `cfg!(...)` is a runtime boolean over a live branch: the code
6
+ // inside it is compiled into the release binary, so it is never an enclosure.
7
+ // - Is this position inside a Swift `#if <CONDITION>` branch that requires the declared condition? (`swiftConditionEnclosed`)
8
+ // - Which paths does a build script compile or watch? (`buildScriptRefs`: include!/include_str!/include_bytes!, cc::Build
9
+ // file/files/include, `cargo:rerun-if-changed`, plus the manifest's `build = "..."`.)
10
+ import { existsSync, readFileSync } from "node:fs";
11
+ import path from "node:path";
12
+
13
+ // ---------------------------------------------------------------------------------------------------------------------
14
+ // Rust.
15
+
16
+ // Same length as `text`: comments, string literals and char literals become spaces (newlines kept), so brace and paren counting
17
+ // never trips on `"}"`, `'{'` or `// {`, and every index still points at the same character of the original text.
18
+ export function maskRust(text) {
19
+ return String(text).replace(/\/\/[^\n]*|\/\*[\s\S]*?\*\/|b?r(#*)"[\s\S]*?"\1|b?"(?:\\[\s\S]|[^"\\])*"|b?'(?:\\[^']*|[^\\'\n])'/g, (m) => m.replace(/[^\n]/g, " "));
20
+ }
21
+
22
+ const OPEN = { "(": ")", "[": "]", "{": "}" };
23
+ const CLOSE = new Set([")", "]", "}"]);
24
+
25
+ // Index of the bracket that closes the one at `open` (masked text), or -1.
26
+ function matchingClose(masked, open) {
27
+ let depth = 0;
28
+ for (let i = open; i < masked.length; i += 1) {
29
+ const c = masked[i];
30
+ if (OPEN[c]) depth += 1;
31
+ else if (CLOSE.has(c)) { depth -= 1; if (depth === 0) return i; }
32
+ }
33
+ return -1;
34
+ }
35
+
36
+ function splitTopLevel(text, separator) {
37
+ const parts = []; let depth = 0; let start = 0;
38
+ for (let i = 0; i < text.length; i += 1) {
39
+ const c = text[i];
40
+ if (OPEN[c]) depth += 1;
41
+ else if (CLOSE.has(c)) depth -= 1;
42
+ else if (depth === 0 && text.startsWith(separator, i)) { parts.push(text.slice(start, i)); start = i + separator.length; i += separator.length - 1; }
43
+ }
44
+ parts.push(text.slice(start));
45
+ return parts;
46
+ }
47
+
48
+ const squash = (s) => String(s).replace(/\s+/g, "");
49
+
50
+ // Does the cfg predicate `expr` hold only when `predicate` holds? `predicate` is one of `feature = "x"`, `test`, `debug_assertions`.
51
+ // `all(..)` needs one argument that implies it, `any(..)` needs every argument to, `not(..)` never does.
52
+ export function cfgImplies(expr, predicate) {
53
+ const e = String(expr).trim();
54
+ const call = /^(all|any|not)\s*\(([\s\S]*)\)$/.exec(e);
55
+ if (call) {
56
+ if (call[1] === "not") return false;
57
+ const args = splitTopLevel(call[2], ",").map((a) => a.trim()).filter(Boolean);
58
+ if (args.length === 0) return false;
59
+ return call[1] === "all" ? args.some((a) => cfgImplies(a, predicate)) : args.every((a) => cfgImplies(a, predicate));
60
+ }
61
+ return squash(e) === squash(predicate);
62
+ }
63
+
64
+ /** The cfg predicate a switches.json `compiledOut` value (`feature:<n>`, `cfg:test`, `cfg:debug_assertions`) stands for, or null. */
65
+ export function cfgPredicateOf(compiledOut) {
66
+ const feature = /^feature:([A-Za-z0-9_-]+)$/.exec(compiledOut ?? "");
67
+ if (feature) return `feature = "${feature[1]}"`;
68
+ if (compiledOut === "cfg:test") return "test";
69
+ if (compiledOut === "cfg:debug_assertions") return "debug_assertions";
70
+ return null;
71
+ }
72
+
73
+ // Start of the unmatched `{` that encloses `index` (masked text), and its closing brace; null at file level.
74
+ function enclosingBlock(masked, index) {
75
+ let depth = 0;
76
+ for (let i = index - 1; i >= 0; i -= 1) {
77
+ if (masked[i] === "}") depth += 1;
78
+ else if (masked[i] === "{") {
79
+ if (depth === 0) { const close = matchingClose(masked, i); return close < 0 ? [i, masked.length] : [i, close + 1]; }
80
+ depth -= 1;
81
+ }
82
+ }
83
+ return null;
84
+ }
85
+
86
+ // The end (exclusive) of the item or statement that starts at `from`: the first `;` outside every bracket, or the `}` that closes
87
+ // the first top-level `{ }` group (`fn`, `impl`, `mod {}`, a block).
88
+ function itemEnd(masked, from) {
89
+ let depth = 0; let sawBlock = false;
90
+ for (let i = from; i < masked.length; i += 1) {
91
+ const c = masked[i];
92
+ if (OPEN[c]) { if (c === "{" && depth === 0) sawBlock = true; depth += 1; }
93
+ else if (CLOSE.has(c)) { depth -= 1; if (depth < 0) return i; if (depth === 0 && sawBlock && c === "}") return i + 1; }
94
+ else if (c === ";" && depth === 0) return i + 1;
95
+ }
96
+ return masked.length;
97
+ }
98
+
99
+ // Every `#[cfg(...)]` / `#![cfg(...)]` in a Rust file: { start, end, inner (the cfg predicate text), inside (true for `#!`) }.
100
+ function cfgAttributes(text, masked) {
101
+ const out = [];
102
+ for (const m of masked.matchAll(/#(!?)\s*\[\s*cfg\s*\(/g)) {
103
+ const open = m.index + m[0].length - 1;
104
+ const close = matchingClose(masked, open);
105
+ if (close < 0) continue;
106
+ const bracket = /^\s*\]/.exec(masked.slice(close + 1));
107
+ if (!bracket) continue;
108
+ out.push({ start: m.index, end: close + 1 + bracket[0].length, inner: text.slice(open + 1, close), inside: m[1] === "!" });
109
+ }
110
+ return out;
111
+ }
112
+
113
+ /**
114
+ * The [start, end) ranges of `text` that exist only when `predicate` holds: the item or statement after each outer
115
+ * `#[cfg(P)]` (further attributes skipped), the block around an inner `#![cfg(P)]` (the whole file when it opens the file).
116
+ */
117
+ export function rustCfgGatedRanges(text, predicate) {
118
+ const masked = maskRust(text);
119
+ const ranges = [];
120
+ for (const attr of cfgAttributes(text, masked)) {
121
+ if (!cfgImplies(attr.inner, predicate)) continue;
122
+ if (attr.inside) {
123
+ const block = enclosingBlock(masked, attr.start);
124
+ ranges.push(block ?? [0, text.length]);
125
+ continue;
126
+ }
127
+ let from = attr.end;
128
+ for (let again = true; again;) {
129
+ again = false;
130
+ const next = /^\s*#\s*\[/.exec(masked.slice(from));
131
+ if (next) { const close = matchingClose(masked, from + next[0].length - 1); if (close >= 0) { from = close + 1; again = true; } }
132
+ }
133
+ ranges.push([attr.end, itemEnd(masked, from)]);
134
+ }
135
+ return ranges;
136
+ }
137
+
138
+ // `mod name;` declarations of a file with the cfg predicate texts written on them (innermost first is not needed: all are ANDed).
139
+ function moduleDeclarations(text) {
140
+ const masked = maskRust(text);
141
+ const out = [];
142
+ for (const m of masked.matchAll(/((?:#\s*\[[^\]]*\]\s*)*)(?:pub(?:\s*\([^)]*\))?\s+)?\bmod\s+([A-Za-z_][A-Za-z0-9_]*)\s*;/g)) {
143
+ const exprs = [];
144
+ for (const attr of m[1].matchAll(/#\s*\[\s*cfg\s*\(/g)) {
145
+ const open = m.index + attr.index + attr[0].length - 1;
146
+ const close = matchingClose(masked, open);
147
+ if (close >= 0) exprs.push(text.slice(open + 1, close));
148
+ }
149
+ out.push({ name: m[2], exprs });
150
+ }
151
+ return out;
152
+ }
153
+
154
+ // The files a `mod name;` in `file` names: `<base>/name.rs` or `<base>/name/mod.rs`, with `<base>` the directory of
155
+ // lib.rs/main.rs/mod.rs, else the directory named after the file.
156
+ function moduleFiles(file, name, exists) {
157
+ const dir = path.dirname(file); const stem = path.basename(file, ".rs");
158
+ const base = ["lib", "main", "mod"].includes(stem) ? dir : path.join(dir, stem);
159
+ return [path.join(base, `${name}.rs`), path.join(base, name, "mod.rs")].filter((candidate) => exists(candidate));
160
+ }
161
+
162
+ /**
163
+ * Per Rust file, the cfg predicate texts that gate the whole file because a parent declares it `#[cfg(..)] mod name;`
164
+ * (followed through nested `mod` declarations). `files` is { file: absolute path, text }[]. Returns Map<file, string[]>.
165
+ */
166
+ export function rustFileGates(files) {
167
+ const texts = new Map(files.map(({ file, text }) => [file, text]));
168
+ const exists = (candidate) => texts.has(candidate);
169
+ const declarations = new Map([...texts].map(([file, text]) => [file, moduleDeclarations(text)]));
170
+ const gates = new Map();
171
+ for (let changed = true; changed;) {
172
+ changed = false;
173
+ for (const [file, decls] of declarations) {
174
+ const inherited = gates.get(file) ?? [];
175
+ for (const decl of decls) {
176
+ const wanted = [...decl.exprs, ...inherited];
177
+ if (wanted.length === 0) continue;
178
+ for (const child of moduleFiles(file, decl.name, exists)) {
179
+ const have = gates.get(child) ?? [];
180
+ const missing = wanted.filter((expr) => !have.includes(expr));
181
+ if (missing.length) { gates.set(child, [...have, ...missing]); changed = true; }
182
+ }
183
+ }
184
+ }
185
+ }
186
+ return gates;
187
+ }
188
+
189
+ // ---------------------------------------------------------------------------------------------------------------------
190
+ // Swift.
191
+
192
+ function outerParenthesised(e) {
193
+ if (!e.startsWith("(") || !e.endsWith(")")) return false;
194
+ let depth = 0;
195
+ for (let i = 0; i < e.length; i += 1) {
196
+ if (e[i] === "(") depth += 1;
197
+ else if (e[i] === ")") { depth -= 1; if (depth === 0 && i < e.length - 1) return false; }
198
+ }
199
+ return true;
200
+ }
201
+
202
+ // Does the Swift compilation-condition expression hold only when `condition` is defined? `A && COND` and `COND` do; `COND || A`,
203
+ // `!COND` and `os(macOS)` do not.
204
+ export function swiftExprRequires(expr, condition) {
205
+ const e = String(expr).trim();
206
+ const ors = splitTopLevel(e, "||");
207
+ if (ors.length > 1) return ors.every((part) => swiftExprRequires(part, condition));
208
+ const ands = splitTopLevel(e, "&&");
209
+ if (ands.length > 1) return ands.some((part) => swiftExprRequires(part, condition));
210
+ if (outerParenthesised(e)) return swiftExprRequires(e.slice(1, -1), condition);
211
+ return e === condition;
212
+ }
213
+
214
+ /** Does `text`'s position `index` sit in a Swift `#if` / `#elseif` branch that requires `condition`? (`#else` never does.) */
215
+ export function swiftConditionEnclosed(text, index, condition) {
216
+ const stack = [];
217
+ const directive = /^[ \t]*#(if|elseif|else|endif)\b([^\n]*)/gm;
218
+ for (let m = directive.exec(text); m && m.index < index; m = directive.exec(text)) {
219
+ const expr = m[2].replace(/\/\/.*$/, "").trim();
220
+ if (m[1] === "if") stack.push(swiftExprRequires(expr, condition));
221
+ else if (m[1] === "elseif") { if (stack.length) stack[stack.length - 1] = swiftExprRequires(expr, condition); }
222
+ else if (m[1] === "else") { if (stack.length) stack[stack.length - 1] = false; }
223
+ else stack.pop();
224
+ }
225
+ return stack.some(Boolean);
226
+ }
227
+
228
+ // ---------------------------------------------------------------------------------------------------------------------
229
+ // Build scripts.
230
+
231
+ const quoted = (text) => [...String(text).matchAll(/"((?:\\.|[^"\\])*)"/g)].map((m) => m[1]);
232
+
233
+ /**
234
+ * Existing paths a crate's build script compiles or watches: string literals given to `include!`/`include_str!`/`include_bytes!`
235
+ * (relative to the build script's directory), `cc::Build` `file`/`files`/`include`/`flag("-I..")`, and `cargo:rerun-if-changed=` /
236
+ * `cargo::rerun-if-changed=` (relative to the crate directory, which is the script's working directory), plus the script file
237
+ * itself. `dirs` are crate directories; each one's `build.rs` and a `build = "<path>"` of its Cargo.toml are read.
238
+ * Not followed: a path assembled at run time (`format!`, `join` of a variable) and anything a script imports by `mod`.
239
+ */
240
+ export function buildScriptRefs(dirs) {
241
+ const refs = new Set();
242
+ for (const dir of new Set(dirs)) {
243
+ const scripts = new Set();
244
+ if (existsSync(path.join(dir, "build.rs"))) scripts.add(path.join(dir, "build.rs"));
245
+ try {
246
+ const declared = /^\s*build\s*=\s*"([^"]+)"/m.exec(readFileSync(path.join(dir, "Cargo.toml"), "utf8"));
247
+ if (declared && existsSync(path.resolve(dir, declared[1]))) scripts.add(path.resolve(dir, declared[1]));
248
+ } catch { /* no readable Cargo.toml */ }
249
+ for (const script of scripts) {
250
+ refs.add(script);
251
+ let text;
252
+ try { text = readFileSync(script, "utf8"); } catch { continue; }
253
+ const masked = maskRust(text);
254
+ const add = (base, rel) => {
255
+ if (!rel || /^[a-z][a-z0-9+.-]*:\/\//i.test(rel)) return;
256
+ const abs = path.resolve(base, rel);
257
+ if (existsSync(abs)) refs.add(abs);
258
+ };
259
+ for (const m of masked.matchAll(/\binclude(?:_str|_bytes)?\s*!\s*\(/g)) {
260
+ const close = matchingClose(masked, m.index + m[0].length - 1);
261
+ for (const lit of quoted(text.slice(m.index, close < 0 ? text.length : close))) add(path.dirname(script), lit);
262
+ }
263
+ for (const m of masked.matchAll(/\.\s*(?:files?|include|flag|flag_if_supported)\s*\(/g)) {
264
+ const close = matchingClose(masked, m.index + m[0].length - 1);
265
+ for (const lit of quoted(text.slice(m.index, close < 0 ? text.length : close))) add(dir, lit.replace(/^-I\s*/, ""));
266
+ }
267
+ for (const m of text.matchAll(/cargo::?rerun-if-changed=([^"\\\n]+)/g)) add(dir, m[1].trim());
268
+ }
269
+ }
270
+ return refs;
271
+ }
@@ -12,6 +12,7 @@
12
12
  "isolated-test-keychain",
13
13
  "demo",
14
14
  "dev-overrides",
15
+ "webview-automation",
15
16
  "qa-probes",
16
17
  "qa-env",
17
18
  "dev-worker-override",
@@ -124,6 +125,10 @@
124
125
  {
125
126
  "name": "--demo",
126
127
  "class": "S1"
128
+ },
129
+ {
130
+ "name": "TAURI_WEBVIEW_AUTOMATION",
131
+ "class": "S1"
127
132
  }
128
133
  ],
129
134
  "conditionalForbiddenFeatures": {
@@ -131,5 +136,59 @@
131
136
  "devtools",
132
137
  "content-devtools"
133
138
  ]
134
- }
139
+ },
140
+ "webQa": {
141
+ "marker": "RIGHTKIT-QA-WEB-COMPILED",
142
+ "define": "__RIGHTKIT_QA__",
143
+ "retired": [
144
+ "VITE_VIEWRIGHT_BROWSER_QA",
145
+ "VITE_RIGHTKIT_BROWSER_QA",
146
+ "VITE_RIGHTKIT_QA",
147
+ "__RIGHTKIT_MOCK__"
148
+ ]
149
+ },
150
+ "osProvided": [
151
+ "HOME",
152
+ "HOMEDRIVE",
153
+ "HOMEPATH",
154
+ "USERPROFILE",
155
+ "APPDATA",
156
+ "LOCALAPPDATA",
157
+ "PROGRAMDATA",
158
+ "ALLUSERSPROFILE",
159
+ "PATH",
160
+ "PATHEXT",
161
+ "SystemRoot",
162
+ "SYSTEMROOT",
163
+ "SystemDrive",
164
+ "windir",
165
+ "WINDIR",
166
+ "COMSPEC",
167
+ "ProgramFiles",
168
+ "ProgramFiles(x86)",
169
+ "ProgramW6432",
170
+ "TEMP",
171
+ "TMP",
172
+ "TMPDIR",
173
+ "USER",
174
+ "USERNAME",
175
+ "LOGNAME",
176
+ "XDG_CONFIG_HOME",
177
+ "XDG_DATA_HOME",
178
+ "XDG_CACHE_HOME",
179
+ "XDG_STATE_HOME",
180
+ "XDG_RUNTIME_DIR"
181
+ ],
182
+ "presenceOwners": [
183
+ {
184
+ "name": "ORT_DYLIB_PATH",
185
+ "mechanism": "clear",
186
+ "crate": "rightkit-onnx"
187
+ },
188
+ {
189
+ "name": "WEBVIEW2_*",
190
+ "mechanism": "set",
191
+ "crate": "rightkit-tauri-shell"
192
+ }
193
+ ]
135
194
  }