@adea-ai/app-framework 0.37.2 → 0.38.1

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 (32) hide show
  1. package/README.md +69 -22
  2. package/dist/app/create-application.js +2 -12
  3. package/dist/cli/developer-app-cli.d.ts +2 -0
  4. package/dist/cli/developer-app-cli.js +38 -0
  5. package/dist/cli/release-cut-cli.js +2 -1
  6. package/dist/cli/release-promote-cli.js +1 -0
  7. package/dist/desktop/client-dev-proxy.d.ts +16 -0
  8. package/dist/desktop/client-dev-proxy.js +84 -0
  9. package/dist/desktop/desktop-host.d.ts +5 -0
  10. package/dist/desktop/desktop-host.js +5 -2
  11. package/dist/developer-app/developer-app.d.ts +113 -0
  12. package/dist/developer-app/developer-app.js +326 -0
  13. package/dist/framework-source.json +1 -1
  14. package/dist/native/desktop-build-hook.d.ts +2 -0
  15. package/dist/native/desktop-build-hook.js +5 -0
  16. package/dist/release/local-release.d.ts +2 -0
  17. package/dist/release/local-release.js +71 -69
  18. package/dist/release/release-config.js +2 -2
  19. package/dist/release/release-promotion-command.d.ts +1 -0
  20. package/dist/release/release-promotion-command.js +1 -0
  21. package/dist/release/release-promotion.d.ts +11 -1
  22. package/dist/release/release-promotion.js +26 -1
  23. package/dist/update-helper.bundle.js +7 -3
  24. package/dist/updates/helper/resume-staging.d.ts +3 -0
  25. package/dist/updates/helper/resume-staging.js +11 -3
  26. package/dist/updates/helper/update-helper.js +2 -2
  27. package/dist/updates/helper/update-resume.js +41 -6
  28. package/dist/updates/install/update-swap.d.ts +11 -1
  29. package/dist/updates/install/update-swap.js +14 -3
  30. package/package.json +11 -2
  31. package/templates/application/.github/workflows/release-please.yml +1 -2
  32. package/templates/application/.github/workflows/release.yml +6 -8
@@ -0,0 +1,326 @@
1
+ import { dirname, isAbsolute, join, resolve } from "node:path";
2
+ import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, symlinkSync, watch, writeFileSync } from "node:fs";
3
+ import { spawn, spawnSync } from "node:child_process";
4
+ import { homedir } from "node:os";
5
+ // src/developer-app/developer-app.ts
6
+ /**
7
+ * The developer app: one persistent, hot-reloading desktop app per framework app that
8
+ * runs straight from the developer's checkout. With GitButler the checkout is every
9
+ * applied branch merged together, so the window always shows the combined state of all
10
+ * parallel work, with no build or publish step. It replaces dev releases: a public app
11
+ * ships only daily and stable.
12
+ *
13
+ * - The UI comes from the app's dev server (Vite), proxied by the shell, so client
14
+ * edits hot-reload in place (see `client-dev-proxy.ts`).
15
+ * - Shell source edits restart the shell process.
16
+ * - It is its own app: "<Name> (Dev)", identifier "<identifier>.live", its own data
17
+ * folder and port, so it runs beside an installed copy of the public app.
18
+ * - `installDeveloperAppLauncher` adds a small launcher app (Spotlight, Launchpad,
19
+ * Dock) that starts it from the checkout.
20
+ */
21
+ /** Set for every developer app build and run; the build hook and the shell read it. */
22
+ var DEVELOPER_APP_VARIABLE = "ADEA_DEVELOPER_APP";
23
+ /** The developer app's display name, for the build hook's bundle naming. */
24
+ var DEVELOPER_APP_NAME_VARIABLE = "ADEA_DEVELOPER_APP_NAME";
25
+ var NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9 ._-]{0,62}$/;
26
+ var IDENTIFIER_PATTERN = /^[a-z0-9-]+(?:\.[a-z0-9-]+)+$/i;
27
+ var strings = (list) => Array.isArray(list) && list.every((item) => typeof item === "string" && item.length > 0);
28
+ var stringRecord = (map) => map === void 0 || typeof map === "object" && map !== null && !Array.isArray(map) && Object.values(map).every((item) => typeof item === "string");
29
+ /** Check a developer app config, resolving its paths against `base`. */
30
+ function parseDeveloperAppConfig(value, base) {
31
+ const config = value;
32
+ if (!config || typeof config !== "object" || typeof config.name !== "string" || !NAME_PATTERN.test(config.name) || typeof config.identifier !== "string" || !IDENTIFIER_PATTERN.test(config.identifier) || typeof config.shellDirectory !== "string" || config.watch !== void 0 && !strings(config.watch) || !config.ui || typeof config.ui.directory !== "string" || !strings(config.ui.command) || config.ui.command.length === 0 || !Number.isInteger(config.ui.port) || config.ui.port < 1024 || config.ui.port > 65535 || config.ui.warm !== void 0 && (!strings(config.ui.warm) || config.ui.warm.some((path) => !path.startsWith("/"))) || !stringRecord(config.ui.env) || !stringRecord(config.shellEnv) || config.prepare !== void 0 && (!Array.isArray(config.prepare) || config.prepare.some((command) => !strings(command) || command.length === 0)) || config.icon !== void 0 && typeof config.icon !== "string") throw new Error("Invalid developer app configuration");
33
+ const at = (path) => isAbsolute(path) ? path : resolve(base, path);
34
+ const shellDirectory = at(config.shellDirectory);
35
+ return {
36
+ ...config,
37
+ name: config.name,
38
+ identifier: config.identifier,
39
+ shellDirectory,
40
+ ui: {
41
+ ...config.ui,
42
+ directory: at(config.ui.directory)
43
+ },
44
+ ...config.icon === void 0 ? {} : { icon: at(config.icon) }
45
+ };
46
+ }
47
+ /** Read and check a developer app config file (JSON); paths resolve from its folder. */
48
+ function readDeveloperAppConfig(path) {
49
+ return parseDeveloperAppConfig(JSON.parse(readFileSync(path, "utf8")), dirname(resolve(path)));
50
+ }
51
+ /** The developer app's own identity, kept apart from the public app's. */
52
+ function developerAppIdentity(app) {
53
+ return {
54
+ name: `${app.name} (Dev)`,
55
+ identifier: `${app.identifier}.live`,
56
+ buildFolder: "build.noindex",
57
+ icons: "build.noindex/developer-icon.iconset"
58
+ };
59
+ }
60
+ /** Whether this process builds or runs the developer app. */
61
+ var isDeveloperApp = (env = process.env) => env[DEVELOPER_APP_VARIABLE] === "1";
62
+ /**
63
+ * Electrobun names a non-stable bundle `${name}-${channel}.app` and cannot be told
64
+ * otherwise. This moves the bundle to "<Name> (Dev).app" (the name macOS shows in
65
+ * Finder, Activity Monitor and permission prompts) and leaves a relative symlink at the
66
+ * channel path, which `electrobun dev` launches and rebuilds through. Returns the
67
+ * bundle path, or undefined when there is no bundle.
68
+ */
69
+ function nameDeveloperBundle(buildDir, appName, displayName) {
70
+ const bundle = `${displayName}.app`;
71
+ const target = join(buildDir, bundle);
72
+ const built = readdirSync(buildDir).find((entry) => entry !== bundle && entry.startsWith(`${appName}-`) && entry.endsWith(".app"));
73
+ if (!built) return existsSync(target) ? target : void 0;
74
+ const builtPath = join(buildDir, built);
75
+ if (lstatSync(builtPath).isSymbolicLink()) return target;
76
+ rmSync(target, {
77
+ recursive: true,
78
+ force: true
79
+ });
80
+ renameSync(builtPath, target);
81
+ symlinkSync(bundle, builtPath);
82
+ return target;
83
+ }
84
+ /** The build hook's developer app step (macOS): bundle and Info.plist named "<Name> (Dev)". */
85
+ function finishDeveloperBundle(env = process.env) {
86
+ const displayName = env[DEVELOPER_APP_NAME_VARIABLE];
87
+ const buildDir = env.ELECTROBUN_BUILD_DIR;
88
+ const appName = env.ELECTROBUN_APP_NAME;
89
+ if (!isDeveloperApp(env) || process.platform !== "darwin" || !displayName) return void 0;
90
+ if (!buildDir || !appName || !existsSync(buildDir)) return void 0;
91
+ const bundle = nameDeveloperBundle(buildDir, appName, displayName);
92
+ if (!bundle) return void 0;
93
+ const plist = join(bundle, "Contents", "Info.plist");
94
+ if (existsSync(plist)) for (const key of ["CFBundleName", "CFBundleDisplayName"]) spawnSync("plutil", [
95
+ "-replace",
96
+ key,
97
+ "-string",
98
+ displayName,
99
+ plist
100
+ ], { stdio: "ignore" });
101
+ return bundle;
102
+ }
103
+ /**
104
+ * Debounced shell restarts: a shell source edit restarts the running shell. An edit
105
+ * before the shell's first start is ignored, because that start builds current files.
106
+ */
107
+ function createShellRestarter(options) {
108
+ const { currentShell, restart, delayMs = 400, log = () => {} } = options;
109
+ let timer;
110
+ let inFlight = false;
111
+ let pending;
112
+ const run = (file) => {
113
+ const shell = currentShell();
114
+ if (!shell || shell.exitCode !== null) return;
115
+ inFlight = true;
116
+ log(`developer app: ${file} changed, restarting the shell…`);
117
+ restart(shell).catch(() => void 0).finally(() => {
118
+ inFlight = false;
119
+ const next = pending;
120
+ pending = void 0;
121
+ if (next !== void 0) run(next);
122
+ });
123
+ };
124
+ return (file) => {
125
+ if (!file || /\.test\.tsx?$/.test(file)) return;
126
+ clearTimeout(timer);
127
+ timer = setTimeout(() => {
128
+ if (inFlight) pending = file;
129
+ else run(file);
130
+ }, delayMs);
131
+ };
132
+ }
133
+ var ICON_SIZES = [
134
+ 16,
135
+ 32,
136
+ 128,
137
+ 256,
138
+ 512
139
+ ];
140
+ function writeIconset(png, iconset) {
141
+ mkdirSync(iconset, { recursive: true });
142
+ for (const size of ICON_SIZES) for (const [scale, suffix] of [[1, ""], [2, "@2x"]]) {
143
+ const pixels = String(Math.min(size * scale, 512));
144
+ const out = join(iconset, `icon_${size}x${size}${suffix}.png`);
145
+ spawnSync("sips", [
146
+ "-z",
147
+ pixels,
148
+ pixels,
149
+ png,
150
+ "--out",
151
+ out
152
+ ], { stdio: "ignore" });
153
+ }
154
+ }
155
+ /** The shell environment for a developer app run. */
156
+ function developerAppShellEnv(config, env = process.env) {
157
+ return {
158
+ ...env,
159
+ ...config.shellEnv,
160
+ [DEVELOPER_APP_VARIABLE]: "1",
161
+ [DEVELOPER_APP_NAME_VARIABLE]: developerAppIdentity(config).name,
162
+ ADEA_CLIENT_DEV_URL: `http://127.0.0.1:${config.ui.port}`
163
+ };
164
+ }
165
+ /** Stop a child and the process group it leads. */
166
+ function stopGroup(child) {
167
+ try {
168
+ process.kill(-child.pid, "SIGTERM");
169
+ } catch {
170
+ child.kill("SIGTERM");
171
+ }
172
+ }
173
+ /**
174
+ * Run the developer app from the checkout until its window closes or the process is
175
+ * stopped: the UI dev server first, then the shell once the dev server answers.
176
+ */
177
+ async function runDeveloperApp(config, options = {}) {
178
+ const log = options.log ?? ((line) => console.log(line));
179
+ const identity = developerAppIdentity(config);
180
+ for (const command of config.prepare ?? []) {
181
+ const result = spawnSync(command[0], command.slice(1), {
182
+ cwd: config.shellDirectory,
183
+ stdio: "inherit",
184
+ env: {
185
+ ...process.env,
186
+ [DEVELOPER_APP_VARIABLE]: "1"
187
+ }
188
+ });
189
+ if (result.status !== 0) process.exit(result.status ?? 1);
190
+ }
191
+ if (config.icon && process.platform === "darwin") writeIconset(config.icon, join(config.shellDirectory, identity.icons));
192
+ const children = /* @__PURE__ */ new Set();
193
+ const start = (command, spawnOptions) => {
194
+ const child = spawn(command[0], command.slice(1), {
195
+ stdio: "inherit",
196
+ detached: true,
197
+ ...spawnOptions
198
+ });
199
+ children.add(child);
200
+ child.on("exit", () => children.delete(child));
201
+ return child;
202
+ };
203
+ const shutdown = (code) => {
204
+ for (const child of children) stopGroup(child);
205
+ process.exit(code);
206
+ };
207
+ process.on("SIGINT", () => shutdown(0));
208
+ process.on("SIGTERM", () => shutdown(0));
209
+ start(config.ui.command, {
210
+ cwd: config.ui.directory,
211
+ env: {
212
+ ...process.env,
213
+ ...config.ui.env,
214
+ [DEVELOPER_APP_VARIABLE]: "1"
215
+ }
216
+ }).on("exit", (code) => {
217
+ log(`developer app: the UI dev server exited (${code ?? "signal"})`);
218
+ shutdown(code ?? 1);
219
+ });
220
+ const origin = `http://127.0.0.1:${config.ui.port}`;
221
+ log("developer app: starting the UI dev server…");
222
+ for (;;) {
223
+ try {
224
+ if ((await fetch(origin + "/")).status < 500) break;
225
+ } catch {}
226
+ await new Promise((done) => setTimeout(done, 500));
227
+ }
228
+ for (const path of config.ui.warm ?? []) await fetch(origin + path, { signal: AbortSignal.timeout(12e4) }).catch(() => void 0);
229
+ log(`developer app: UI on ${origin} (hot reload); starting ${identity.name}`);
230
+ let shell;
231
+ let restarting = false;
232
+ const shellEnv = developerAppShellEnv(config);
233
+ const startShell = () => {
234
+ shell = start([
235
+ "bunx",
236
+ "--bun",
237
+ "electrobun",
238
+ "dev"
239
+ ], {
240
+ cwd: config.shellDirectory,
241
+ env: shellEnv
242
+ });
243
+ shell.on("exit", (code) => {
244
+ if (restarting) return;
245
+ log(`developer app: the shell exited (${code ?? "signal"})`);
246
+ shutdown(code ?? 0);
247
+ });
248
+ };
249
+ const onChange = createShellRestarter({
250
+ currentShell: () => shell,
251
+ log,
252
+ restart: (running) => new Promise((started) => {
253
+ restarting = true;
254
+ running.once("exit", () => {
255
+ restarting = false;
256
+ startShell();
257
+ started();
258
+ });
259
+ stopGroup(running);
260
+ })
261
+ });
262
+ for (const folder of config.watch ?? ["src"]) watch(join(config.shellDirectory, folder), { recursive: true }, (_event, file) => onChange(file ? String(file) : null));
263
+ startShell();
264
+ return new Promise(() => {});
265
+ }
266
+ var quote = (value) => `'${value.replaceAll("'", `'\\''`)}'`;
267
+ /**
268
+ * Install the developer app's launcher (macOS): "<Name> (Dev).app" in `directory`
269
+ * (default /Applications), which runs `command` from `checkout` in a login shell, so it
270
+ * finds bun on the same PATH as a terminal. Output goes to ~/Library/Logs/<Name> (Dev).log.
271
+ */
272
+ function installDeveloperAppLauncher(options) {
273
+ if (process.platform !== "darwin") throw new Error("The developer app launcher is macOS-only");
274
+ const identity = developerAppIdentity(options.config);
275
+ const app = join(options.directory ?? "/Applications", `${identity.name}.app`);
276
+ const contents = join(app, "Contents");
277
+ const log = join(homedir(), "Library", "Logs", `${identity.name}.log`);
278
+ const executable = "developer-app";
279
+ rmSync(app, {
280
+ recursive: true,
281
+ force: true
282
+ });
283
+ mkdirSync(join(contents, "MacOS"), { recursive: true });
284
+ mkdirSync(join(contents, "Resources"), { recursive: true });
285
+ const notice = `display notification "Starting from the checkout. The window opens in about a minute." with title "${identity.name.replaceAll("\"", "")}"`;
286
+ writeFileSync(join(contents, "MacOS", executable), `#!/bin/zsh -l
287
+ osascript -e ${quote(notice)} >/dev/null 2>&1 &
288
+ cd ${quote(options.checkout)} || exit 1
289
+ exec ${options.command.map(quote).join(" ")} >> ${quote(log)} 2>&1
290
+ `);
291
+ chmodSync(join(contents, "MacOS", executable), 493);
292
+ writeFileSync(join(contents, "Info.plist"), `<?xml version="1.0" encoding="UTF-8"?>
293
+ <plist version="1.0">
294
+ <dict>
295
+ <key>CFBundleName</key><string>${identity.name}</string>
296
+ <key>CFBundleDisplayName</key><string>${identity.name}</string>
297
+ <key>CFBundleIdentifier</key><string>${identity.identifier}.launcher</string>
298
+ <key>CFBundleExecutable</key><string>${executable}</string>
299
+ <key>CFBundleIconFile</key><string>AppIcon</string>
300
+ <key>CFBundlePackageType</key><string>APPL</string>
301
+ <key>CFBundleVersion</key><string>1</string>
302
+ <key>LSUIElement</key><true/>
303
+ </dict>
304
+ </plist>
305
+ `);
306
+ if (options.config.icon) {
307
+ const iconset = join(contents, "Resources", "AppIcon.iconset");
308
+ writeIconset(options.config.icon, iconset);
309
+ spawnSync("iconutil", [
310
+ "-c",
311
+ "icns",
312
+ iconset,
313
+ "-o",
314
+ join(contents, "Resources", "AppIcon.icns")
315
+ ]);
316
+ rmSync(iconset, {
317
+ recursive: true,
318
+ force: true
319
+ });
320
+ }
321
+ return {
322
+ app,
323
+ log
324
+ };
325
+ }
326
+ export { DEVELOPER_APP_NAME_VARIABLE, DEVELOPER_APP_VARIABLE, createShellRestarter, developerAppIdentity, developerAppShellEnv, finishDeveloperBundle, installDeveloperAppLauncher, isDeveloperApp, nameDeveloperBundle, parseDeveloperAppConfig, readDeveloperAppConfig, runDeveloperApp };
@@ -1 +1 @@
1
- {"version":"0.37.2","commit":"54bc60527c162b7a41ee4714e14760c78e88168d"}
1
+ {"version":"0.38.1","commit":"e274fac589670aacfa7817fcfb093356c417273f"}
@@ -3,5 +3,7 @@
3
3
  * On Windows it applies the pinned WebView2 runtime correction. On every
4
4
  * platform it replaces bundled CEF helpers with the build that exposes
5
5
  * Electrobun's bridges to the main frame only; bundles without CEF are untouched.
6
+ * For a developer app build (`ADEA_DEVELOPER_APP=1`) it names the macOS bundle
7
+ * "<Name> (Dev)" (see developer-app.ts).
6
8
  */
7
9
  export default function secureDesktopBuild(): Promise<void>;
@@ -1,12 +1,15 @@
1
1
  import { cefHelperFailure, installPatchedCefHelpers } from "./cef-helper.js";
2
2
  import { installOptInPosixLaunchLeaseLauncher } from "./posix-launcher-build.js";
3
3
  import secureWindowsBuild from "./windows-build-hook.js";
4
+ import { finishDeveloperBundle } from "../developer-app/developer-app.js";
4
5
  // src/native/desktop-build-hook.ts
5
6
  /**
6
7
  * Electrobun postBuild hook; runs before release hashing, packaging and signing.
7
8
  * On Windows it applies the pinned WebView2 runtime correction. On every
8
9
  * platform it replaces bundled CEF helpers with the build that exposes
9
10
  * Electrobun's bridges to the main frame only; bundles without CEF are untouched.
11
+ * For a developer app build (`ADEA_DEVELOPER_APP=1`) it names the macOS bundle
12
+ * "<Name> (Dev)" (see developer-app.ts).
10
13
  */
11
14
  async function secureDesktopBuild() {
12
15
  await secureWindowsBuild();
@@ -23,5 +26,7 @@ async function secureDesktopBuild() {
23
26
  } catch {
24
27
  throw new Error("Pinned POSIX launcher preparation failed");
25
28
  }
29
+ const developerBundle = finishDeveloperBundle(process.env);
30
+ if (developerBundle) process.stdout.write(`Named the developer app bundle: ${developerBundle}\n`);
26
31
  }
27
32
  export { secureDesktopBuild as default };
@@ -112,6 +112,7 @@ export declare function runLocalPromotion(options: {
112
112
  out: string;
113
113
  now: string;
114
114
  held: boolean;
115
+ soakBypassTag?: string;
115
116
  repository: string;
116
117
  fetch: FetchFunction;
117
118
  }): Promise<{
@@ -125,6 +126,7 @@ export declare function runLocalPromotion(options: {
125
126
  } | {
126
127
  status: 'stable';
127
128
  tag: string;
129
+ soakBypassed?: true;
128
130
  reasons?: string[] | undefined;
129
131
  plan?: Readonly<{
130
132
  schema: 1;
@@ -375,80 +375,82 @@ async function runLocalPromotion(options) {
375
375
  const qualified = /* @__PURE__ */ new Map();
376
376
  const reasons = [];
377
377
  let selectionChanged = false;
378
- const result = await promoteDailyRelease({
379
- now: timestamp(options.now),
380
- held: options.held,
381
- soakHours: local.soakHours,
382
- provider: {
383
- async list() {
384
- return ledger.releases.map((entry, index) => ({
385
- id: ledger.releases.length - index,
386
- tag: entry.tag,
387
- body: entry.kind === "dev" ? `adea-channel:dev\n\nSource: ${entry.sourceSha}` : entry.kind === "stable" ? `<!-- adea-stable:v1 ${entry.tag} -->\n<!-- adea-stable-time:${entry.promotedAt} -->` : "",
388
- draft: false,
389
- prerelease: entry.kind !== "stable",
390
- publishedAt: entry.publishedAt
391
- }));
392
- },
393
- async qualify(release) {
394
- if (selectionChanged) return false;
395
- let verified;
396
- try {
397
- verified = await verifyFeedRelease({
398
- config: local.config,
399
- feed,
400
- tag: release.tag,
401
- repository: options.repository,
402
- keys: local.keys,
403
- fetch: options.fetch,
404
- channels: ["stable"],
405
- expectedLedger: ledger
406
- });
407
- } catch (error) {
408
- if (error instanceof ReleaseFeedSnapshotChanged) {
409
- selectionChanged = true;
410
- return false;
411
- }
412
- throw error;
413
- }
414
- const { release: verifiedRelease, platforms } = verified;
415
- qualified.set(release.tag, {
416
- release: verifiedRelease,
417
- platforms
378
+ const provider = {
379
+ async list() {
380
+ return ledger.releases.map((entry, index) => ({
381
+ id: ledger.releases.length - index,
382
+ tag: entry.tag,
383
+ body: entry.kind === "dev" ? `adea-channel:dev\n\nSource: ${entry.sourceSha}` : entry.kind === "stable" ? `<!-- adea-stable:v1 ${entry.tag} -->\n<!-- adea-stable-time:${entry.promotedAt} -->` : "",
384
+ draft: false,
385
+ prerelease: entry.kind !== "stable",
386
+ publishedAt: entry.publishedAt
387
+ }));
388
+ },
389
+ async qualify(release) {
390
+ if (selectionChanged) return false;
391
+ let verified;
392
+ try {
393
+ verified = await verifyFeedRelease({
394
+ config: local.config,
395
+ feed,
396
+ tag: release.tag,
397
+ repository: options.repository,
398
+ keys: local.keys,
399
+ fetch: options.fetch,
400
+ channels: ["stable"],
401
+ expectedLedger: ledger
418
402
  });
419
- const missing = required.filter((name) => !platforms.includes(name));
420
- if (missing.length) {
421
- reasons.push(`${release.tag} lacks ${missing.join(", ")}; publish them or relax stablePlatforms in release-config.json`);
403
+ } catch (error) {
404
+ if (error instanceof ReleaseFeedSnapshotChanged) {
405
+ selectionChanged = true;
422
406
  return false;
423
407
  }
424
- return true;
425
- },
426
- async markStable(selected, at) {
427
- const verification = qualified.get(selected.tag);
428
- const absent = Object.keys(platformTargets).filter((name) => !verification?.platforms.includes(name));
429
- const entry = ledger.releases.find((item) => item.tag === selected.tag);
430
- const [currentLedger, remote] = await Promise.all([readFeedLedger(feed, options.fetch), readFeedRelease(feed, selected.tag, options.fetch)]);
431
- if (!entry || !remote || !verification || entry.kind === "dev" || JSON.stringify(currentLedger) !== JSON.stringify(ledger) || JSON.stringify(remote) !== JSON.stringify(verification.release)) throw new Error("Release feed changed or is unavailable during promotion");
432
- const promoted = {
433
- tag: entry.tag,
434
- kind: "stable",
435
- version: entry.version,
436
- sourceSha: entry.sourceSha,
437
- publishedAt: entry.publishedAt,
438
- promotedAt: entry.promotedAt ?? timestamp(at)
439
- };
440
- const updated = parseReleaseLedger({
441
- schema: 1,
442
- app: feed.app,
443
- releases: ledger.releases.map((item) => item.tag === entry.tag ? promoted : item)
444
- }, feed.app);
445
- plan = await writeStagedTree(options.out, feed, [], releaseDocuments(feed, updated, {
446
- ...remote,
447
- channel: "stable",
448
- ...absent.length ? { missingPlatforms: absent } : {}
449
- }));
408
+ throw error;
409
+ }
410
+ const { release: verifiedRelease, platforms } = verified;
411
+ qualified.set(release.tag, {
412
+ release: verifiedRelease,
413
+ platforms
414
+ });
415
+ const missing = required.filter((name) => !platforms.includes(name));
416
+ if (missing.length) {
417
+ reasons.push(`${release.tag} lacks ${missing.join(", ")}; publish them or relax stablePlatforms in release-config.json`);
418
+ return false;
450
419
  }
420
+ return true;
421
+ },
422
+ async markStable(selected, at) {
423
+ const verification = qualified.get(selected.tag);
424
+ const absent = Object.keys(platformTargets).filter((name) => !verification?.platforms.includes(name));
425
+ const entry = ledger.releases.find((item) => item.tag === selected.tag);
426
+ const [currentLedger, remote] = await Promise.all([readFeedLedger(feed, options.fetch), readFeedRelease(feed, selected.tag, options.fetch)]);
427
+ if (!entry || !remote || !verification || entry.kind === "dev" || JSON.stringify(currentLedger) !== JSON.stringify(ledger) || JSON.stringify(remote) !== JSON.stringify(verification.release)) throw new Error("Release feed changed or is unavailable during promotion");
428
+ const promoted = {
429
+ tag: entry.tag,
430
+ kind: "stable",
431
+ version: entry.version,
432
+ sourceSha: entry.sourceSha,
433
+ publishedAt: entry.publishedAt,
434
+ promotedAt: entry.promotedAt ?? timestamp(at)
435
+ };
436
+ const updated = parseReleaseLedger({
437
+ schema: 1,
438
+ app: feed.app,
439
+ releases: ledger.releases.map((item) => item.tag === entry.tag ? promoted : item)
440
+ }, feed.app);
441
+ plan = await writeStagedTree(options.out, feed, [], releaseDocuments(feed, updated, {
442
+ ...remote,
443
+ channel: "stable",
444
+ ...absent.length ? { missingPlatforms: absent } : {}
445
+ }));
451
446
  }
447
+ };
448
+ const result = await promoteDailyRelease({
449
+ now: timestamp(options.now),
450
+ held: options.held,
451
+ soakHours: local.soakHours,
452
+ ...options.soakBypassTag ? { soakBypassTag: options.soakBypassTag } : {},
453
+ provider
452
454
  });
453
455
  if (selectionChanged) throw new Error("Release feed changed or is unavailable during promotion");
454
456
  return {
@@ -51,7 +51,7 @@ var workflowFile = (path) => path.slice(18);
51
51
  var workflowPath = (value) => typeof value === "string" && value.length <= 200 && value.startsWith(workflowDirectory) && /^[A-Za-z0-9][A-Za-z0-9._-]*\.ya?ml$/.test(workflowFile(value));
52
52
  /** Validate shared daily, dev and stable asset requirements. */
53
53
  function parseReleaseConfig(config) {
54
- if (!isRecord(config) || !isRecord(config.platforms) || !strings(config.releaseAssets) || !strings(config.dailyDiscoveryAssets) || !strings(config.stableDiscoveryAssets) || !strings(config.devDiscoveryAssets) || !Number.isSafeInteger(config.soakHours) || Number(config.soakHours) < 0 || Number(config.soakHours) > 8760) throw new Error("Invalid release configuration");
54
+ if (!isRecord(config) || !isRecord(config.platforms) || !strings(config.releaseAssets) || !strings(config.dailyDiscoveryAssets) || !strings(config.stableDiscoveryAssets) || config.devDiscoveryAssets !== void 0 && !strings(config.devDiscoveryAssets) || !Number.isSafeInteger(config.soakHours) || Number(config.soakHours) < 0 || Number(config.soakHours) > 8760) throw new Error("Invalid release configuration");
55
55
  const workflows = config.releaseWorkflows;
56
56
  let releaseWorkflows;
57
57
  if (workflows !== void 0) {
@@ -98,7 +98,7 @@ function parseReleaseConfig(config) {
98
98
  const releaseAssets = [...config.releaseAssets];
99
99
  const daily = [...config.dailyDiscoveryAssets];
100
100
  const stable = [...config.stableDiscoveryAssets];
101
- const dev = [...config.devDiscoveryAssets];
101
+ const dev = config.devDiscoveryAssets === void 0 ? [] : [...config.devDiscoveryAssets];
102
102
  if (daily.some((name) => !releaseAssets.includes(name) || stable.includes(name) || dev.includes(name)) || stable.some((name) => !releaseAssets.includes(name) || dev.includes(name)) || dev.some((name) => !releaseAssets.includes(name))) throw new Error("Daily, stable and dev discovery assets must be distinct release assets");
103
103
  const requirements = (tag) => {
104
104
  if (!/^v\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(tag) || tag.length > 65) throw new Error("Invalid release tag");
@@ -9,4 +9,5 @@ export declare function runPromotionCommand(options: {
9
9
  } | {
10
10
  status: 'stable';
11
11
  tag: string;
12
+ soakBypassed?: true;
12
13
  }>;
@@ -22,6 +22,7 @@ async function runPromotionCommand(options) {
22
22
  now: options.now ?? (/* @__PURE__ */ new Date()).toISOString(),
23
23
  held: env.STABLE_PROMOTION_HELD === "true",
24
24
  soakHours,
25
+ ...env.STABLE_SOAK_BYPASS_TAG ? { soakBypassTag: env.STABLE_SOAK_BYPASS_TAG } : {},
25
26
  provider
26
27
  });
27
28
  }
@@ -15,15 +15,25 @@ export type PromotionProvider = {
15
15
  /** Idempotently mark the already-qualified release stable and record the supplied time. */
16
16
  markStable(release: PromotionRelease, at: string): Promise<void>;
17
17
  };
18
- /** Promote only a successfully qualified daily after the configured batch soak. */
18
+ /**
19
+ * Promote only a successfully qualified daily after the configured batch soak.
20
+ *
21
+ * `soakBypassTag` replaces a bad stable without waiting for the soak: it names exactly one pending
22
+ * daily (newer than the current stable, never a downgrade), which is promoted at once if it
23
+ * qualifies. Nothing else changes: qualification is still required, a hold still wins, and a tag
24
+ * that is not a pending daily is refused rather than ignored. Callers read it from a protected
25
+ * variable (STABLE_SOAK_BYPASS_TAG) set for one release and removed after it.
26
+ */
19
27
  export declare function promoteDailyRelease(options: {
20
28
  now: string;
21
29
  held?: boolean;
22
30
  soakHours?: number;
31
+ soakBypassTag?: string;
23
32
  provider: PromotionProvider;
24
33
  }): Promise<{
25
34
  status: 'held' | 'soaking' | 'unqualified';
26
35
  } | {
27
36
  status: 'stable';
28
37
  tag: string;
38
+ soakBypassed?: true;
29
39
  }>;
@@ -15,9 +15,19 @@ function stableTime(release) {
15
15
  return value;
16
16
  }
17
17
  var eligibleTag = (tag) => tag.length <= 65 && /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag);
18
- /** Promote only a successfully qualified daily after the configured batch soak. */
18
+ /**
19
+ * Promote only a successfully qualified daily after the configured batch soak.
20
+ *
21
+ * `soakBypassTag` replaces a bad stable without waiting for the soak: it names exactly one pending
22
+ * daily (newer than the current stable, never a downgrade), which is promoted at once if it
23
+ * qualifies. Nothing else changes: qualification is still required, a hold still wins, and a tag
24
+ * that is not a pending daily is refused rather than ignored. Callers read it from a protected
25
+ * variable (STABLE_SOAK_BYPASS_TAG) set for one release and removed after it.
26
+ */
19
27
  async function promoteDailyRelease(options) {
20
28
  if (options.held) return { status: "held" };
29
+ const bypass = options.soakBypassTag;
30
+ if (bypass !== void 0 && !eligibleTag(bypass)) throw new Error("Invalid soak bypass tag");
21
31
  const now = Date.parse(options.now);
22
32
  const hours = options.soakHours ?? 96;
23
33
  if (!Number.isFinite(now) || !Number.isSafeInteger(hours) || hours < 0 || hours > 8760) throw new Error("Invalid promotion clock or soak");
@@ -36,6 +46,21 @@ async function promoteDailyRelease(options) {
36
46
  const observedStable = releases.filter((release) => !release.draft && !release.prerelease && Date.parse(release.publishedAt) <= now && eligibleTag(release.tag)).sort(compareVersion).at(-1);
37
47
  const batch = dailies.filter((release) => release.prerelease && (!stable || order(release, stable) > 0) && (!observedStable || versionLessThan(observedStable.tag, release.tag)));
38
48
  const anchor = stable && (!observedStable || stable.tag === observedStable.tag) ? stableTime(stable) : observedStable?.publishedAt ?? batch[0]?.publishedAt;
49
+ if (bypass !== void 0) {
50
+ const named = batch.find((release) => release.tag === bypass);
51
+ if (!named) throw new Error(`Soak bypass tag ${bypass} is not a pending daily`);
52
+ let qualified = false;
53
+ try {
54
+ qualified = await options.provider.qualify(named) === true;
55
+ } catch {}
56
+ if (!qualified) return { status: "unqualified" };
57
+ await options.provider.markStable(named, options.now);
58
+ return {
59
+ status: "stable",
60
+ tag: named.tag,
61
+ soakBypassed: true
62
+ };
63
+ }
39
64
  const candidates = anchor !== void 0 && now - Date.parse(anchor) >= hours * 36e5 ? [...batch].reverse() : [];
40
65
  candidates.sort((a, b) => versionLessThan(a.tag, b.tag) ? 1 : versionLessThan(b.tag, a.tag) ? -1 : order(b, a));
41
66
  if (stable && (!observedStable || stable.tag === observedStable.tag)) candidates.push(stable);