@adea-ai/app-framework-release-tools 0.10.0 → 0.11.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.
package/dist/index.js CHANGED
@@ -794,6 +794,10 @@ import { Cause, Data, Effect, Exit } from "effect";
794
794
 
795
795
  class ReleaseFailure extends Data.TaggedError("ReleaseFailure") {
796
796
  }
797
+
798
+ class PublicReleaseError extends Error {
799
+ name = "PublicReleaseError";
800
+ }
797
801
  var refuse = (reason, message) => Effect.fail(new ReleaseFailure({ reason, message }));
798
802
  var fail = (message) => refuse("refused", message);
799
803
  var stepFailure = (error) => new ReleaseFailure({
@@ -1904,20 +1908,26 @@ import { join as join2, resolve } from "path";
1904
1908
  // ../../src/installer/hosted-runner.ts
1905
1909
  import { isAbsolute } from "path";
1906
1910
  var JOB_NUMBER = /^[1-9]\d{0,19}$/;
1907
- function isHostedRunner(env) {
1911
+ function hostedRunnerRefusal(env) {
1908
1912
  if (env.CI !== "true")
1909
- return false;
1913
+ return "CI is not true";
1910
1914
  if (env.GITHUB_ACTIONS === "true")
1911
- return env.RUNNER_ENVIRONMENT === "github-hosted";
1915
+ return env.RUNNER_ENVIRONMENT === "github-hosted" ? undefined : "RUNNER_ENVIRONMENT is not github-hosted";
1912
1916
  if (env.FRAMEWORK_DISPOSABLE_RUNNER !== "true")
1913
- return false;
1917
+ return "FRAMEWORK_DISPOSABLE_RUNNER is not true";
1914
1918
  if (env.GITLAB_CI === "true")
1915
- return JOB_NUMBER.test(env.CI_JOB_ID ?? "");
1916
- return env.CIRCLECI === "true" && JOB_NUMBER.test(env.CIRCLE_BUILD_NUM ?? "");
1919
+ return JOB_NUMBER.test(env.CI_JOB_ID ?? "") ? undefined : "CI_JOB_ID is not a job number";
1920
+ if (env.CIRCLECI !== "true")
1921
+ return "neither GITLAB_CI nor CIRCLECI is true";
1922
+ return JOB_NUMBER.test(env.CIRCLE_BUILD_NUM ?? "") ? undefined : "CIRCLE_BUILD_NUM is not a job number";
1923
+ }
1924
+ function isHostedRunner(env) {
1925
+ return hostedRunnerRefusal(env) === undefined;
1917
1926
  }
1918
1927
  function assertHostedRunner(env, subject) {
1919
- if (!isHostedRunner(env))
1920
- throw new Error(`${subject} requires a disposable hosted runner`);
1928
+ const refusal = hostedRunnerRefusal(env);
1929
+ if (refusal !== undefined)
1930
+ throw new Error(`${subject} requires a disposable hosted runner (${refusal})`);
1921
1931
  }
1922
1932
  function runnerTemp(env) {
1923
1933
  const path = env.GITHUB_ACTIONS === "true" ? env.RUNNER_TEMP : env.TMPDIR;
@@ -3576,11 +3586,24 @@ async function promoteDailyBatch(store, candidate, signer, keys) {
3576
3586
  throw new Error("Daily promotion could not be read back");
3577
3587
  return selected;
3578
3588
  }
3589
+ async function readDailyBatchByDigest(store, target, manifestDigest) {
3590
+ if (!app.test(target.appId) || !feedApp.test(target.feedApp) || !hex2.test(manifestDigest))
3591
+ throw new Error("Invalid Daily batch target");
3592
+ const bytes = await readSmall(await store.readObject(`${prefix(target.feedApp, manifestDigest)}/manifest.json`), 262144);
3593
+ if (hash(bytes) !== manifestDigest)
3594
+ throw new Error("Daily batch manifest changed");
3595
+ const manifest = parseManifest(parseJson(bytes));
3596
+ if (manifest.identity.appId !== target.appId || manifest.identity.feedApp !== target.feedApp)
3597
+ throw new Error("Daily batch app mismatch");
3598
+ return Object.freeze({ version: "", sequence: 0, manifestDigest, manifest });
3599
+ }
3579
3600
  async function rollbackDailyBatch(store, current, target, signer, keys) {
3580
3601
  const appId = current.manifest.identity.appId;
3581
3602
  const slug = current.manifest.identity.feedApp;
3582
3603
  if (target.manifest.identity.appId !== appId || target.manifest.identity.feedApp !== slug || !hex2.test(target.manifestDigest))
3583
3604
  throw new Error("Invalid rollback target");
3605
+ if (target.manifestDigest === current.manifestDigest)
3606
+ throw new Error("Rollback target is the current Daily batch");
3584
3607
  const selected = await readDailyBatch(store, { appId, feedApp: slug }, keys);
3585
3608
  if (!selected || selected.version !== current.version)
3586
3609
  throw new Error("Daily pointer changed during rollback");
@@ -5794,6 +5817,72 @@ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
5794
5817
  };
5795
5818
  return yield* writeStagedTree(options.out, feed, uploads, releaseDocuments(feed, updated, release));
5796
5819
  });
5820
+ var linuxPackageFormats = [
5821
+ {
5822
+ extension: ".deb",
5823
+ magic: (head) => head.subarray(0, 8).toString("latin1") === `!<arch>
5824
+ `
5825
+ },
5826
+ {
5827
+ extension: ".AppImage",
5828
+ magic: (head) => head.subarray(0, 4).equals(Buffer.from([127, 69, 76, 70])) && head.subarray(8, 11).equals(Buffer.from([65, 73, 2]))
5829
+ }
5830
+ ];
5831
+ var stageLocalPackagesEffect = (options) => Effect21.gen(function* () {
5832
+ const fs = yield* ReleaseFs;
5833
+ const { tag, sourceSha } = options;
5834
+ const local = localConfig(options.config);
5835
+ const feed = local.feed;
5836
+ const requirements = local.requirements(tag);
5837
+ const allowed = new Map;
5838
+ for (const platform of ["linux-x64", "linux-arm64"])
5839
+ for (const archive of requirements.platforms[platform] ?? [])
5840
+ if (archive.endsWith(".tar.zst"))
5841
+ for (const { extension } of linuxPackageFormats)
5842
+ allowed.set(archive.slice(0, -".tar.zst".length) + extension, archive);
5843
+ const directory = resolve9(options.directory);
5844
+ const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
5845
+ if (!entries.length || entries.some((entry) => !entry.isFile() || !allowed.has(entry.name)))
5846
+ return yield* fail("Staged directory holds files that are not this tag's Linux packages");
5847
+ const names = entries.map((entry) => entry.name).toSorted();
5848
+ const staged = yield* Effect21.forEach(names, (name) => fileIdentityEffect(join14(directory, name), name), { concurrency: "unbounded" });
5849
+ for (const name of names) {
5850
+ const format = linuxPackageFormats.find(({ extension }) => name.endsWith(extension));
5851
+ const head = Buffer.alloc(16);
5852
+ const file = yield* step(() => fs.open(join14(directory, name), "r"));
5853
+ yield* step(() => file.read(head, 0, 16, 0)).pipe(Effect21.ensuring(Effect21.promise(() => file.close().catch(() => {
5854
+ return;
5855
+ }))));
5856
+ if (!format.magic(head))
5857
+ return yield* fail(`Not a ${format.extension} package: ${name}`);
5858
+ }
5859
+ const [ledger, remote] = yield* Effect21.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, tag)], { concurrency: "unbounded" });
5860
+ const entry = ledger.releases.find((item) => item.tag === tag);
5861
+ if (!entry || !remote || entry.kind !== remote.channel || Date.parse(entry.publishedAt) !== Date.parse(remote.publishedAt))
5862
+ return yield* fail("The feed has not published this tag; publish its release first");
5863
+ if (entry.sourceSha !== sourceSha)
5864
+ return yield* fail("The feed publishes this tag from another source commit");
5865
+ const merged = [...remote.assets];
5866
+ const uploads = [];
5867
+ for (const artifact of staged) {
5868
+ if (!merged.some((asset) => asset.name === allowed.get(artifact.name)))
5869
+ return yield* fail(`The feed has no ${allowed.get(artifact.name)} for ${artifact.name}`);
5870
+ const existing = merged.find((asset) => asset.name === artifact.name);
5871
+ if (existing) {
5872
+ if (existing.size !== artifact.size || "sha256:" + existing.sha256 !== artifact.digest)
5873
+ return yield* fail(`Immutable asset conflict: ${artifact.name}`);
5874
+ continue;
5875
+ }
5876
+ merged.push({ name: artifact.name, size: artifact.size, sha256: artifact.digest.slice(7) });
5877
+ uploads.push({
5878
+ key: feedAssetKey(feed, tag, artifact.name),
5879
+ path: join14(directory, artifact.name),
5880
+ artifact
5881
+ });
5882
+ }
5883
+ const release = { ...remote, assets: merged };
5884
+ return yield* writeStagedTree(options.out, feed, uploads, releaseDocuments(feed, ledger, release));
5885
+ });
5797
5886
  function stablePlatforms(config) {
5798
5887
  const value = isRecord(config) ? config.stablePlatforms : undefined;
5799
5888
  if (value === undefined)
@@ -10257,6 +10346,7 @@ import { basename as basename17, isAbsolute as isAbsolute8, join as join38, reso
10257
10346
  import { promisify as promisify5 } from "util";
10258
10347
 
10259
10348
  // src/library/windows-standalone-bootstrap.ts
10349
+ var WINDOWS_PACKAGE_MANAGER_SWITCH = "--package-manager=winget";
10260
10350
  var windowsBootstrapSource = String.raw`
10261
10351
  #define WIN32_LEAN_AND_MEAN
10262
10352
  #include <windows.h>
@@ -10315,10 +10405,28 @@ static BOOL write_exclusive(const wchar_t *path, const unsigned char *bytes, DWO
10315
10405
  return CloseHandle(file) && ok;
10316
10406
  }
10317
10407
 
10408
+ // Marks the installed app root as package-manager owned. The root must already exist as a real
10409
+ // directory (the inner Setup created it); the marker is replaced, never followed through a link.
10410
+ static BOOL write_package_manager_marker(void) {
10411
+ wchar_t local[MAX_PATH], root[MAX_PATH], marker[MAX_PATH];
10412
+ DWORD n = GetEnvironmentVariableW(L"LOCALAPPDATA", local, MAX_PATH);
10413
+ if (!n || n >= MAX_PATH) return FALSE;
10414
+ int m = swprintf(root, MAX_PATH, L"%ls\\%ls\\stable\\app", local, APP_ID);
10415
+ if (m <= 0 || m >= MAX_PATH || !join_path(marker, root, L".package-manager")) return FALSE;
10416
+ DWORD attributes = GetFileAttributesW(root);
10417
+ if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY)
10418
+ || (attributes & FILE_ATTRIBUTE_REPARSE_POINT)) return FALSE;
10419
+ DeleteFileW(marker);
10420
+ static const unsigned char owner[] = "winget\n";
10421
+ return write_exclusive(marker, owner, sizeof owner - 1);
10422
+ }
10423
+
10318
10424
  int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous, LPWSTR command, int show) {
10319
10425
  (void)instance; (void)previous; (void)show;
10320
- // No undocumented silent or arbitrary installer arguments are forwarded.
10321
- if (command[0]) {
10426
+ // No undocumented silent or arbitrary installer arguments are forwarded. The only option is
10427
+ // the exact package-manager switch, which is not forwarded either: it marks the install.
10428
+ BOOL package_manager = wcscmp(command, L"${WINDOWS_PACKAGE_MANAGER_SWITCH}") == 0;
10429
+ if (command[0] && !package_manager) {
10322
10430
  MessageBoxW(NULL, L"This installer accepts no command-line options.", APP_NAME, MB_OK | MB_ICONERROR);
10323
10431
  return 2;
10324
10432
  }
@@ -10370,6 +10478,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous, LPWSTR command, int
10370
10478
  cleanup:
10371
10479
  DeleteFileW(archive); DeleteFileW(meta); DeleteFileW(child);
10372
10480
  RemoveDirectoryW(hidden); CloseHandle(guard); RemoveDirectoryW(work);
10481
+ if (code == 0 && package_manager && !write_package_manager_marker()) code = 2;
10373
10482
  if (code == 0) return 0;
10374
10483
  fail:
10375
10484
  MessageBoxW(NULL, L"Installation did not complete.", APP_NAME, MB_OK | MB_ICONERROR);
@@ -10510,6 +10619,7 @@ async function buildStandaloneWindowsExe(options) {
10510
10619
  throw new Error("Unexpected pinned Zig compiler version");
10511
10620
  await writeFile14(join38(work, "app.h"), [
10512
10621
  `#define APP_NAME L"${appName}"`,
10622
+ `#define APP_ID L"${appId}"`,
10513
10623
  `#define SETUP_SIZE ${setup.size}u`,
10514
10624
  `#define METADATA_SIZE ${metadata.size}u`,
10515
10625
  `#define ARCHIVE_SIZE ${archive.size}u`
@@ -10557,6 +10667,26 @@ async function buildStandaloneWindowsExe(options) {
10557
10667
  await rm13(work, { recursive: true, force: true });
10558
10668
  }
10559
10669
  }
10670
+ // src/library/homebrew-cask.ts
10671
+ var ruby = (value) => JSON.stringify(value).replace(/#(?=[{@$])/g, "\\#");
10672
+ var DEFAULT_HOMEBREW_MINIMUM_MACOS = "sonoma";
10673
+ var MACOS_CODENAMES = ["ventura", "sonoma", "sequoia", "tahoe"];
10674
+ function homebrewMinimumMacos(value) {
10675
+ if (value === undefined)
10676
+ return DEFAULT_HOMEBREW_MINIMUM_MACOS;
10677
+ if (typeof value !== "string" || !MACOS_CODENAMES.includes(value))
10678
+ throw new Error(`Invalid Homebrew minimum macOS (one of ${MACOS_CODENAMES.join(", ")})`);
10679
+ return value;
10680
+ }
10681
+ function homebrewRequirements(options) {
10682
+ return [
10683
+ ...options.conflictsWith ? [` conflicts_with cask: ${ruby(options.conflictsWith)}`] : [],
10684
+ ...options.arm64Only ? [" depends_on arch: :arm64"] : [],
10685
+ ` depends_on macos: ">= :${options.minimumMacos}"`
10686
+ ].join(`
10687
+ `);
10688
+ }
10689
+
10560
10690
  // src/library/package-channels.ts
10561
10691
  var packageChannelNames = [
10562
10692
  "homebrew",
@@ -10600,7 +10730,7 @@ var packagePattern = /^[a-z0-9][a-z0-9+.-]{0,62}$/;
10600
10730
  var reverseDns = /^[A-Za-z_][A-Za-z0-9_-]*(\.[A-Za-z_][A-Za-z0-9_-]*){2,}$/;
10601
10731
  var relativePath2 = /^[A-Za-z0-9][A-Za-z0-9._-]*(\/[A-Za-z0-9][A-Za-z0-9._-]*)*$/;
10602
10732
  var quoted = JSON.stringify;
10603
- var ruby = (value) => JSON.stringify(value).replace(/#(?=[{@$])/g, "\\#");
10733
+ var ruby2 = (value) => JSON.stringify(value).replace(/#(?=[{@$])/g, "\\#");
10604
10734
  var shell = (value) => `'${value.replaceAll("'", "'\\''")}'`;
10605
10735
  function parseAsset(value) {
10606
10736
  const row = object(value, "manifest asset");
@@ -10673,7 +10803,8 @@ function stageInput(context, asset) {
10673
10803
  };
10674
10804
  }
10675
10805
  function homebrew(context, row) {
10676
- keys2(row, "homebrew", ["tap", "token", "bundle", "artifact"]);
10806
+ keys2(row, "homebrew", ["tap", "token", "bundle", "artifact"], ["minimumMacos"]);
10807
+ const minimumMacos = homebrewMinimumMacos(row.minimumMacos);
10677
10808
  const tap = text3(row.tap, "Homebrew tap", /^[A-Za-z0-9][A-Za-z0-9-]*\/homebrew-[a-z0-9][a-z0-9-]*$/);
10678
10809
  const stableToken = text3(row.token, "cask token", /^[a-z0-9]+(?:-[a-z0-9]+)*$/);
10679
10810
  const bundle = text3(row.bundle, "app bundle", /^[A-Za-z0-9][A-Za-z0-9 ._-]*\.app$/);
@@ -10690,19 +10821,22 @@ function homebrew(context, row) {
10690
10821
  files: [
10691
10822
  {
10692
10823
  path: `Casks/${token}.rb`,
10693
- contents: `cask ${ruby(token)} do
10694
- version ${ruby(context.version)}
10695
- sha256 ${ruby(asset.sha256)}
10696
-
10697
- url ${ruby(asset.url)}
10698
- name ${ruby(stable ? name : `${name} Daily`)}
10699
- desc ${ruby(description)}
10700
- homepage ${ruby(homepage)}
10701
-
10702
- depends_on arch: :arm64
10703
- conflicts_with cask: ${ruby(stable ? `${stableToken}@daily` : stableToken)}
10704
-
10705
- app ${ruby(bundle)}
10824
+ contents: `cask ${ruby2(token)} do
10825
+ version ${ruby2(context.version)}
10826
+ sha256 ${ruby2(asset.sha256)}
10827
+
10828
+ url ${ruby2(asset.url)}
10829
+ name ${ruby2(stable ? name : `${name} Daily`)}
10830
+ desc ${ruby2(description)}
10831
+ homepage ${ruby2(homepage)}
10832
+
10833
+ ${homebrewRequirements({
10834
+ conflictsWith: stable ? `${stableToken}@daily` : stableToken,
10835
+ arm64Only: true,
10836
+ minimumMacos
10837
+ })}
10838
+
10839
+ app ${ruby2(bundle)}
10706
10840
  end
10707
10841
  `
10708
10842
  }
@@ -10711,16 +10845,17 @@ end
10711
10845
  };
10712
10846
  }
10713
10847
  function winget(context, row) {
10714
- keys2(row, "winget", ["identifier", "publisher", "artifact", "silent", "silentWithProgress"], ["nestedInstaller"]);
10848
+ keys2(row, "winget", ["identifier", "publisher", "artifact"], ["nestedInstaller", "silent", "silentWithProgress"]);
10715
10849
  const stableId = text3(row.identifier, "WinGet package identifier", /^[A-Za-z0-9][A-Za-z0-9-]*(\.[A-Za-z0-9][A-Za-z0-9-]*)+$/);
10716
10850
  const publisher = text3(row.publisher, "WinGet publisher");
10717
10851
  const asset = exact2(context, row.artifact, "WinGet", [".exe", ".zip"]);
10718
10852
  const direct = asset.name.endsWith(".exe");
10719
10853
  ensure(direct === (row.nestedInstaller === undefined), direct ? "A direct .exe installer takes no nestedInstaller" : "A .zip installer needs nestedInstaller");
10720
10854
  const nested = direct ? undefined : text3(row.nestedInstaller, "nested executable", /^[A-Za-z0-9][A-Za-z0-9 ._-]*\.exe$/i);
10855
+ ensure(!direct || row.silent === undefined && row.silentWithProgress === undefined, "A direct .exe installer takes the package-manager switch, not silent flags");
10721
10856
  const flags = /^[-/][a-zA-Z0-9_-]+(?: [-/][a-zA-Z0-9_-]+)*$/;
10722
- const silent = text3(row.silent, "silent flags", flags);
10723
- const progress = text3(row.silentWithProgress, "silent progress flags", flags);
10857
+ const silent = direct ? WINDOWS_PACKAGE_MANAGER_SWITCH : text3(row.silent, "silent flags", flags);
10858
+ const progress = direct ? WINDOWS_PACKAGE_MANAGER_SWITCH : text3(row.silentWithProgress, "silent progress flags", flags);
10724
10859
  const stable = context.manifest.channel === "stable";
10725
10860
  const id = stable ? stableId : `${stableId}.Daily`;
10726
10861
  const { name, description, homepage, license } = context.common;
@@ -1 +1 @@
1
- {"version":"0.10.0","commit":"15725353a83f706e8e7cb1340e7da4a7a5e4f0bd"}
1
+ {"version":"0.11.1","commit":"9b687fbf274c05670c32f4e928d89ddac0a5aa65"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adea-ai/app-framework-release-tools",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "description": "Host-side release tooling for @adea-ai/app-framework apps, on Effect: the release CLIs and the framework package publish. Installing it never adds Effect to the framework itself.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {