@adea-ai/app-framework-release-tools 0.9.1 → 0.11.0

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
@@ -38,7 +38,10 @@ __export(exports_src, {
38
38
  inspectDailyBatch: () => inspectDailyBatch,
39
39
  inspectDailyPreSigning: () => inspectDailyPreSigning,
40
40
  inspectStagedStep: () => inspectStagedStep,
41
+ packageChannelNames: () => packageChannelNames,
42
+ parsePackageChannelManifest: () => parsePackageChannelManifest,
41
43
  planDailyReleaseMatrix: () => planDailyReleaseMatrix,
44
+ planPackageChannels: () => planPackageChannels,
42
45
  planQualificationRun: () => planQualificationRun2,
43
46
  planReleaseAssets: () => planReleaseAssets2,
44
47
  promoteDailyBatch: () => promoteDailyBatch,
@@ -791,6 +794,10 @@ import { Cause, Data, Effect, Exit } from "effect";
791
794
 
792
795
  class ReleaseFailure extends Data.TaggedError("ReleaseFailure") {
793
796
  }
797
+
798
+ class PublicReleaseError extends Error {
799
+ name = "PublicReleaseError";
800
+ }
794
801
  var refuse = (reason, message) => Effect.fail(new ReleaseFailure({ reason, message }));
795
802
  var fail = (message) => refuse("refused", message);
796
803
  var stepFailure = (error) => new ReleaseFailure({
@@ -1901,20 +1908,26 @@ import { join as join2, resolve } from "path";
1901
1908
  // ../../src/installer/hosted-runner.ts
1902
1909
  import { isAbsolute } from "path";
1903
1910
  var JOB_NUMBER = /^[1-9]\d{0,19}$/;
1904
- function isHostedRunner(env) {
1911
+ function hostedRunnerRefusal(env) {
1905
1912
  if (env.CI !== "true")
1906
- return false;
1913
+ return "CI is not true";
1907
1914
  if (env.GITHUB_ACTIONS === "true")
1908
- return env.RUNNER_ENVIRONMENT === "github-hosted";
1915
+ return env.RUNNER_ENVIRONMENT === "github-hosted" ? undefined : "RUNNER_ENVIRONMENT is not github-hosted";
1909
1916
  if (env.FRAMEWORK_DISPOSABLE_RUNNER !== "true")
1910
- return false;
1917
+ return "FRAMEWORK_DISPOSABLE_RUNNER is not true";
1911
1918
  if (env.GITLAB_CI === "true")
1912
- return JOB_NUMBER.test(env.CI_JOB_ID ?? "");
1913
- 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;
1914
1926
  }
1915
1927
  function assertHostedRunner(env, subject) {
1916
- if (!isHostedRunner(env))
1917
- 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})`);
1918
1931
  }
1919
1932
  function runnerTemp(env) {
1920
1933
  const path = env.GITHUB_ACTIONS === "true" ? env.RUNNER_TEMP : env.TMPDIR;
@@ -1989,10 +2002,18 @@ function assertPayloadLayout(options) {
1989
2002
  if (!entries.includes(fold ? name.toLowerCase() : name))
1990
2003
  throw new Error(`Payload missing ${name}`);
1991
2004
  }
1992
- const containsCef = entries.some((name) => /(?:^|\/)(?:chromium embedded framework|libcef\.dll|libcef\.so)$/i.test(name));
1993
- if (containsCef !== (renderer === "cef"))
2005
+ if (payloadRenderer(entries) !== renderer)
1994
2006
  throw new Error("Payload does not match selected renderer");
1995
2007
  }
2008
+ function payloadRenderer(entries) {
2009
+ return entries.some((name) => /(?:^|\/)(?:chromium embedded framework|libcef\.dll|libcef\.so)$/i.test(name)) ? "cef" : "native";
2010
+ }
2011
+ function acceptedUpdateRenderers(renderer, accepted) {
2012
+ const all = [renderer, ...accepted ?? []];
2013
+ if (all.some((item) => item !== "native" && item !== "cef"))
2014
+ throw new Error("Invalid installer profile");
2015
+ return [...new Set(all)];
2016
+ }
1996
2017
  function assertInstallerLayout(platform, appName, entries) {
1997
2018
  assertPortableAppName(appName);
1998
2019
  if (platform !== "windows-x64" && platform !== "linux-x64" && platform !== "linux-arm64")
@@ -3565,11 +3586,24 @@ async function promoteDailyBatch(store, candidate, signer, keys) {
3565
3586
  throw new Error("Daily promotion could not be read back");
3566
3587
  return selected;
3567
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
+ }
3568
3600
  async function rollbackDailyBatch(store, current, target, signer, keys) {
3569
3601
  const appId = current.manifest.identity.appId;
3570
3602
  const slug = current.manifest.identity.feedApp;
3571
3603
  if (target.manifest.identity.appId !== appId || target.manifest.identity.feedApp !== slug || !hex2.test(target.manifestDigest))
3572
3604
  throw new Error("Invalid rollback target");
3605
+ if (target.manifestDigest === current.manifestDigest)
3606
+ throw new Error("Rollback target is the current Daily batch");
3573
3607
  const selected = await readDailyBatch(store, { appId, feedApp: slug }, keys);
3574
3608
  if (!selected || selected.version !== current.version)
3575
3609
  throw new Error("Daily pointer changed during rollback");
@@ -4406,6 +4440,8 @@ function planDailyReleaseMatrix(config, tag) {
4406
4440
  const requirements = parsed.requirements(tag);
4407
4441
  const profile = config.dailyReleaseProfile;
4408
4442
  const expanded = profile === expandedDesktopDailyProfile;
4443
+ requireThat(config.dailyInstallerSigning === undefined || config.dailyInstallerSigning === "required", 'dailyInstallerSigning must be "required" when present');
4444
+ const installerSigning = expanded || config.dailyInstallerSigning === "required";
4409
4445
  const checks = [];
4410
4446
  const primaryAssets = [];
4411
4447
  for (const platform of expanded ? expandedPlatforms : platforms) {
@@ -4450,10 +4486,12 @@ function planDailyReleaseMatrix(config, tag) {
4450
4486
  discoveryPolicies(config, tag);
4451
4487
  const all = [...primaryAssets, ...requirements.releaseAssets];
4452
4488
  requireThat(new Set(all).size === all.length, "Daily release assets are not unique");
4453
- return { appId: config.appId, profile, assets: all, checks };
4489
+ return { appId: config.appId, profile, installerSigning, assets: all, checks };
4454
4490
  }
4455
- function requiresDailyInstallerSigning(profile, check) {
4456
- return profile === expandedDesktopDailyProfile && (check.format === "dmg" || check.format === "windows-setup");
4491
+ function requiresDailyInstallerSigning(matrix, check) {
4492
+ if (!matrix.installerSigning)
4493
+ return false;
4494
+ return matrix.profile === expandedDesktopDailyProfile ? check.format === "dmg" || check.format === "windows-setup" : check.format === "dmg";
4457
4495
  }
4458
4496
  function priorDailyInstallerNames(config, tag, check) {
4459
4497
  const plan = planDailyReleaseMatrix(config, tag);
@@ -4534,7 +4572,7 @@ var verifiedMatrix = (options, verifyPrior) => Effect16.gen(function* () {
4534
4572
  const valid = yield* attempt(() => validateDailyNativeEvidence(raw.value, "framework/daily-native-receipt/v2", {
4535
4573
  appId: matrix.appId,
4536
4574
  profile: matrix.profile,
4537
- signing: requiresDailyInstallerSigning(matrix.profile, check) ? installerSigningPolicy(config, check) : undefined,
4575
+ signing: requiresDailyInstallerSigning(matrix, check) ? installerSigningPolicy(config, check) : undefined,
4538
4576
  identity,
4539
4577
  check,
4540
4578
  assets: check.assets.map((name) => inventory.get(name)),
@@ -4733,7 +4771,7 @@ var createDailyNativeReceiptEffect = (options, worker, observedSigning) => Effec
4733
4771
  const [os, arch] = platformTargets[check.platform];
4734
4772
  if (worker.os !== os || worker.arch !== arch)
4735
4773
  return yield* fail(`Daily native check requires ${check.platform}`);
4736
- const signing = requiresDailyInstallerSigning(matrix.profile, check) ? yield* attempt(() => installerSigningPolicy(config, check)) : undefined;
4774
+ const signing = requiresDailyInstallerSigning(matrix, check) ? yield* attempt(() => installerSigningPolicy(config, check)) : undefined;
4737
4775
  if (signing && !observedSigning)
4738
4776
  return yield* fail("Expanded Daily installers require proof from the live native observer");
4739
4777
  const fs = yield* ReleaseFs;
@@ -5779,6 +5817,72 @@ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
5779
5817
  };
5780
5818
  return yield* writeStagedTree(options.out, feed, uploads, releaseDocuments(feed, updated, release));
5781
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
+ });
5782
5886
  function stablePlatforms(config) {
5783
5887
  const value = isRecord(config) ? config.stablePlatforms : undefined;
5784
5888
  if (value === undefined)
@@ -7637,7 +7741,8 @@ async function extractVerifiedUpdate(options) {
7637
7741
  return extractBoundArchive(options, descriptor, async (file) => verifyReleaseStream(file.createReadStream({ autoClose: false, start: 0 }), descriptor));
7638
7742
  }
7639
7743
  async function extractBoundArchive(options, descriptor, verifyBeforeExtraction) {
7640
- const { archive, platform, renderer, appName, maxCompressedBytes, maxExpandedBytes } = options;
7744
+ const { archive, platform, appName, maxCompressedBytes, maxExpandedBytes } = options;
7745
+ const accepted = acceptedUpdateRenderers(options.renderer, options.acceptedRenderers);
7641
7746
  if (!isAbsolute6(archive) || !isAbsolute6(options.directory) || !Number.isSafeInteger(maxCompressedBytes) || maxCompressedBytes < 1 || !Number.isSafeInteger(descriptor.asset.size) || descriptor.asset.size < 1 || descriptor.asset.size > maxCompressedBytes || !/^[a-f0-9]{64}$/.test(descriptor.asset.sha256) || !Number.isSafeInteger(maxExpandedBytes) || maxExpandedBytes < 1)
7642
7747
  throw new Error("Invalid update extraction context");
7643
7748
  assertPortableAppName(appName);
@@ -7723,7 +7828,7 @@ async function extractBoundArchive(options, descriptor, verifyBeforeExtraction)
7723
7828
  if (seen.has(key) || seen.size >= 200000)
7724
7829
  return reject();
7725
7830
  const relative = normalized.slice(archiveRoot.length + 1), linkTarget = typeof entry.linkpath === "string" ? entry.linkpath : "";
7726
- const cefLink = (platform === "linux-x64" || platform === "linux-arm64") && renderer === "cef" && entry.type === "SymbolicLink" && isLinuxCefLibraryLink(relative, linkTarget);
7831
+ const cefLink = (platform === "linux-x64" || platform === "linux-arm64") && accepted.includes("cef") && entry.type === "SymbolicLink" && isLinuxCefLibraryLink(relative, linkTarget);
7727
7832
  if (entry.type !== "File" && entry.type !== "Directory" && !cefLink)
7728
7833
  return reject();
7729
7834
  seen.add(key);
@@ -7788,6 +7893,9 @@ async function extractBoundArchive(options, descriptor, verifyBeforeExtraction)
7788
7893
  }
7789
7894
  }
7790
7895
  await rm8(decompressed);
7896
+ const renderer = payloadRenderer(entries);
7897
+ if (!accepted.includes(renderer))
7898
+ throw new Error("Payload does not match selected renderer");
7791
7899
  assertPayloadLayout({ platform, renderer, appName, entries, sidecars });
7792
7900
  const prefix = isMacInstallerPlatform(platform) ? join21(`${appName}.app`, "Contents") : appName.replaceAll(" ", "");
7793
7901
  const resources = join21(payloadRoot, prefix, "Resources");
@@ -8619,6 +8727,7 @@ async function stageUpdateSwap(options) {
8619
8727
  directory: preparing,
8620
8728
  platform: plan.platform,
8621
8729
  renderer: plan.renderer,
8730
+ ...options.acceptedRenderers ? { acceptedRenderers: options.acceptedRenderers } : {},
8622
8731
  appName: plan.appName,
8623
8732
  maxCompressedBytes: options.maxCompressedBytes,
8624
8733
  maxExpandedBytes: options.maxExpandedBytes,
@@ -10237,6 +10346,7 @@ import { basename as basename17, isAbsolute as isAbsolute8, join as join38, reso
10237
10346
  import { promisify as promisify5 } from "util";
10238
10347
 
10239
10348
  // src/library/windows-standalone-bootstrap.ts
10349
+ var WINDOWS_PACKAGE_MANAGER_SWITCH = "--package-manager=winget";
10240
10350
  var windowsBootstrapSource = String.raw`
10241
10351
  #define WIN32_LEAN_AND_MEAN
10242
10352
  #include <windows.h>
@@ -10295,10 +10405,28 @@ static BOOL write_exclusive(const wchar_t *path, const unsigned char *bytes, DWO
10295
10405
  return CloseHandle(file) && ok;
10296
10406
  }
10297
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
+
10298
10424
  int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous, LPWSTR command, int show) {
10299
10425
  (void)instance; (void)previous; (void)show;
10300
- // No undocumented silent or arbitrary installer arguments are forwarded.
10301
- 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) {
10302
10430
  MessageBoxW(NULL, L"This installer accepts no command-line options.", APP_NAME, MB_OK | MB_ICONERROR);
10303
10431
  return 2;
10304
10432
  }
@@ -10350,6 +10478,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous, LPWSTR command, int
10350
10478
  cleanup:
10351
10479
  DeleteFileW(archive); DeleteFileW(meta); DeleteFileW(child);
10352
10480
  RemoveDirectoryW(hidden); CloseHandle(guard); RemoveDirectoryW(work);
10481
+ if (code == 0 && package_manager && !write_package_manager_marker()) code = 2;
10353
10482
  if (code == 0) return 0;
10354
10483
  fail:
10355
10484
  MessageBoxW(NULL, L"Installation did not complete.", APP_NAME, MB_OK | MB_ICONERROR);
@@ -10490,6 +10619,7 @@ async function buildStandaloneWindowsExe(options) {
10490
10619
  throw new Error("Unexpected pinned Zig compiler version");
10491
10620
  await writeFile14(join38(work, "app.h"), [
10492
10621
  `#define APP_NAME L"${appName}"`,
10622
+ `#define APP_ID L"${appId}"`,
10493
10623
  `#define SETUP_SIZE ${setup.size}u`,
10494
10624
  `#define METADATA_SIZE ${metadata.size}u`,
10495
10625
  `#define ARCHIVE_SIZE ${archive.size}u`
@@ -10537,6 +10667,554 @@ async function buildStandaloneWindowsExe(options) {
10537
10667
  await rm13(work, { recursive: true, force: true });
10538
10668
  }
10539
10669
  }
10670
+ // src/library/package-channels.ts
10671
+ var packageChannelNames = [
10672
+ "homebrew",
10673
+ "winget",
10674
+ "apt",
10675
+ "pacman",
10676
+ "rpm",
10677
+ "flatpak"
10678
+ ];
10679
+ function ensure(ok, message) {
10680
+ if (!ok)
10681
+ throw new Error(message);
10682
+ }
10683
+ function object(value, label) {
10684
+ ensure(typeof value === "object" && value !== null && !Array.isArray(value), `Expected ${label} to be a JSON object`);
10685
+ return value;
10686
+ }
10687
+ function keys2(row, label, required, optional = []) {
10688
+ for (const key of required)
10689
+ ensure(Object.hasOwn(row, key), `Missing ${label}.${key}`);
10690
+ for (const key of Object.keys(row))
10691
+ ensure(required.includes(key) || optional.includes(key), `Unknown ${label}.${key}`);
10692
+ }
10693
+ function text3(value, label, pattern, max = 200) {
10694
+ ensure(typeof value === "string" && value.length > 0 && value.length <= max && !Array.from(value).some((c) => c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127) && (!pattern || pattern.test(value)), `Invalid ${label}`);
10695
+ return value;
10696
+ }
10697
+ function https(value, label, directory) {
10698
+ const url = new URL(text3(value, label, undefined, 500));
10699
+ ensure(url.protocol === "https:" && !url.username && !url.password && !url.search && !url.hash, `Expected canonical HTTPS URL for ${label}`);
10700
+ ensure(url.href === value, `Expected canonical HTTPS URL for ${label}`);
10701
+ ensure(url.pathname.endsWith("/") === directory, `Expected ${label} to ${directory ? "" : "not "}end in /`);
10702
+ return url;
10703
+ }
10704
+ var tagPattern3 = /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
10705
+ var sha256Pattern = /^[a-f0-9]{64}$/;
10706
+ var gitShaPattern = /^[a-f0-9]{40}$/;
10707
+ var filePattern = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
10708
+ var templatePattern = /^[A-Za-z0-9][A-Za-z0-9._-]*\{tag\}[A-Za-z0-9._-]*$/;
10709
+ var packagePattern = /^[a-z0-9][a-z0-9+.-]{0,62}$/;
10710
+ var reverseDns = /^[A-Za-z_][A-Za-z0-9_-]*(\.[A-Za-z_][A-Za-z0-9_-]*){2,}$/;
10711
+ var relativePath2 = /^[A-Za-z0-9][A-Za-z0-9._-]*(\/[A-Za-z0-9][A-Za-z0-9._-]*)*$/;
10712
+ var quoted = JSON.stringify;
10713
+ var ruby = (value) => JSON.stringify(value).replace(/#(?=[{@$])/g, "\\#");
10714
+ var shell = (value) => `'${value.replaceAll("'", "'\\''")}'`;
10715
+ function parseAsset(value) {
10716
+ const row = object(value, "manifest asset");
10717
+ const size = row.size;
10718
+ ensure(typeof size === "number" && Number.isSafeInteger(size) && size > 0, "Invalid asset size");
10719
+ const sha256 = row.sha256 ?? row.digest;
10720
+ return {
10721
+ name: text3(row.name, "asset name", filePattern),
10722
+ size,
10723
+ sha256: text3(sha256, "asset SHA-256", sha256Pattern)
10724
+ };
10725
+ }
10726
+ function parsePackageChannelManifest(value) {
10727
+ const doc = object(value, "manifest");
10728
+ let raw;
10729
+ let manifest;
10730
+ if (doc.schema === "framework/daily-batch/v1") {
10731
+ const identity = object(doc.identity, "manifest identity");
10732
+ ensure(Array.isArray(doc.artifacts), "Expected Daily batch artifacts");
10733
+ raw = doc.artifacts;
10734
+ manifest = {
10735
+ appId: text3(identity.appId, "manifest appId"),
10736
+ tag: text3(identity.tag, "release tag", tagPattern3),
10737
+ channel: "daily",
10738
+ sourceSha: text3(identity.sourceSha, "source SHA", gitShaPattern)
10739
+ };
10740
+ } else {
10741
+ ensure(doc.schema === undefined, "Unsupported manifest schema");
10742
+ ensure(doc.channel === "daily" || doc.channel === "stable", "Expected release channel");
10743
+ ensure(Array.isArray(doc.assets), "Expected release assets");
10744
+ raw = doc.assets;
10745
+ manifest = {
10746
+ appId: null,
10747
+ tag: text3(doc.tag, "release tag", tagPattern3),
10748
+ channel: doc.channel,
10749
+ sourceSha: null
10750
+ };
10751
+ }
10752
+ ensure(raw.length > 0 && raw.length <= 512, "Expected a bounded asset inventory");
10753
+ const assets = new Map;
10754
+ for (const entry of raw) {
10755
+ const asset = parseAsset(entry);
10756
+ ensure(!assets.has(asset.name), `Duplicate manifest asset ${asset.name}`);
10757
+ assets.set(asset.name, asset);
10758
+ }
10759
+ return { ...manifest, assets };
10760
+ }
10761
+ function exact2(context, template, label, suffixes) {
10762
+ const name = text3(template, `${label} artifact template`, templatePattern).replace("{tag}", context.manifest.tag);
10763
+ ensure(suffixes.some((suffix) => name.endsWith(suffix)), `Expected ${label} artifact ending in ${suffixes.join(" or ")}`);
10764
+ const asset = context.manifest.assets.get(name);
10765
+ ensure(asset, `The manifest has no ${name}`);
10766
+ return {
10767
+ ...asset,
10768
+ url: new URL(`${context.manifest.tag}/${name}`, context.common.releaseBase).href
10769
+ };
10770
+ }
10771
+ function stageInput(context, asset) {
10772
+ return {
10773
+ path: "stage-input.json",
10774
+ contents: JSON.stringify({
10775
+ schema: "framework/package-channel-stage-input/v1",
10776
+ appId: context.common.appId,
10777
+ tag: context.manifest.tag,
10778
+ channel: context.manifest.channel,
10779
+ sourceSha: context.manifest.sourceSha,
10780
+ asset
10781
+ }, null, 2) + `
10782
+ `
10783
+ };
10784
+ }
10785
+ function homebrew(context, row) {
10786
+ keys2(row, "homebrew", ["tap", "token", "bundle", "artifact"]);
10787
+ const tap = text3(row.tap, "Homebrew tap", /^[A-Za-z0-9][A-Za-z0-9-]*\/homebrew-[a-z0-9][a-z0-9-]*$/);
10788
+ const stableToken = text3(row.token, "cask token", /^[a-z0-9]+(?:-[a-z0-9]+)*$/);
10789
+ const bundle = text3(row.bundle, "app bundle", /^[A-Za-z0-9][A-Za-z0-9 ._-]*\.app$/);
10790
+ const asset = exact2(context, row.artifact, "Homebrew", [".dmg"]);
10791
+ const stable = context.manifest.channel === "stable";
10792
+ const token = stable ? stableToken : `${stableToken}@daily`;
10793
+ const [owner, repository] = tap.split("/");
10794
+ const tapName = `${owner}/${repository.slice("homebrew-".length)}`;
10795
+ const { name, description, homepage } = context.common;
10796
+ return {
10797
+ status: "planned",
10798
+ catalogEligible: stable,
10799
+ asset,
10800
+ files: [
10801
+ {
10802
+ path: `Casks/${token}.rb`,
10803
+ contents: `cask ${ruby(token)} do
10804
+ version ${ruby(context.version)}
10805
+ sha256 ${ruby(asset.sha256)}
10806
+
10807
+ url ${ruby(asset.url)}
10808
+ name ${ruby(stable ? name : `${name} Daily`)}
10809
+ desc ${ruby(description)}
10810
+ homepage ${ruby(homepage)}
10811
+
10812
+ depends_on arch: :arm64
10813
+ conflicts_with cask: ${ruby(stable ? `${stableToken}@daily` : stableToken)}
10814
+
10815
+ app ${ruby(bundle)}
10816
+ end
10817
+ `
10818
+ }
10819
+ ],
10820
+ install: `brew install --cask ${tapName}/${token}`
10821
+ };
10822
+ }
10823
+ function winget(context, row) {
10824
+ keys2(row, "winget", ["identifier", "publisher", "artifact"], ["nestedInstaller", "silent", "silentWithProgress"]);
10825
+ const stableId = text3(row.identifier, "WinGet package identifier", /^[A-Za-z0-9][A-Za-z0-9-]*(\.[A-Za-z0-9][A-Za-z0-9-]*)+$/);
10826
+ const publisher = text3(row.publisher, "WinGet publisher");
10827
+ const asset = exact2(context, row.artifact, "WinGet", [".exe", ".zip"]);
10828
+ const direct = asset.name.endsWith(".exe");
10829
+ ensure(direct === (row.nestedInstaller === undefined), direct ? "A direct .exe installer takes no nestedInstaller" : "A .zip installer needs nestedInstaller");
10830
+ const nested = direct ? undefined : text3(row.nestedInstaller, "nested executable", /^[A-Za-z0-9][A-Za-z0-9 ._-]*\.exe$/i);
10831
+ ensure(!direct || row.silent === undefined && row.silentWithProgress === undefined, "A direct .exe installer takes the package-manager switch, not silent flags");
10832
+ const flags = /^[-/][a-zA-Z0-9_-]+(?: [-/][a-zA-Z0-9_-]+)*$/;
10833
+ const silent = direct ? WINDOWS_PACKAGE_MANAGER_SWITCH : text3(row.silent, "silent flags", flags);
10834
+ const progress = direct ? WINDOWS_PACKAGE_MANAGER_SWITCH : text3(row.silentWithProgress, "silent progress flags", flags);
10835
+ const stable = context.manifest.channel === "stable";
10836
+ const id = stable ? stableId : `${stableId}.Daily`;
10837
+ const { name, description, homepage, license } = context.common;
10838
+ const schemaVersion = "1.12.0";
10839
+ const base = `manifests/${id[0].toLowerCase()}/${id.replaceAll(".", "/")}/${context.version}/${id}`;
10840
+ const manifest = (type, body) => `# yaml-language-server: $schema=https://aka.ms/winget-manifest.${type}.${schemaVersion}.schema.json
10841
+ PackageIdentifier: ${quoted(id)}
10842
+ PackageVersion: ${quoted(context.version)}
10843
+ ${body}ManifestType: ${type}
10844
+ ManifestVersion: ${schemaVersion}
10845
+ `;
10846
+ return {
10847
+ status: "planned",
10848
+ catalogEligible: stable,
10849
+ asset,
10850
+ files: [
10851
+ { path: `${base}.yaml`, contents: manifest("version", `DefaultLocale: en-US
10852
+ `) },
10853
+ {
10854
+ path: `${base}.installer.yaml`,
10855
+ contents: manifest("installer", `${direct ? "InstallerType: exe" : `InstallerType: zip
10856
+ NestedInstallerType: exe
10857
+ NestedInstallerFiles:
10858
+ - RelativeFilePath: ${quoted(nested)}`}
10859
+ InstallerSwitches:
10860
+ Silent: ${quoted(silent)}
10861
+ SilentWithProgress: ${quoted(progress)}
10862
+ UpgradeBehavior: install
10863
+ Installers:
10864
+ - Architecture: x64
10865
+ InstallerUrl: ${quoted(asset.url)}
10866
+ InstallerSha256: ${asset.sha256.toUpperCase()}
10867
+ `)
10868
+ },
10869
+ {
10870
+ path: `${base}.locale.en-US.yaml`,
10871
+ contents: manifest("defaultLocale", `PackageLocale: en-US
10872
+ Publisher: ${quoted(publisher)}
10873
+ PublisherUrl: ${quoted(homepage)}
10874
+ PackageName: ${quoted(stable ? name : `${name} Daily`)}
10875
+ PackageUrl: ${quoted(homepage)}
10876
+ License: ${quoted(license)}
10877
+ ShortDescription: ${quoted(description)}
10878
+ `)
10879
+ }
10880
+ ],
10881
+ install: stable ? `winget install --exact --id ${id}` : `winget install --manifest ${base.slice(0, base.lastIndexOf("/")).replaceAll("/", "\\")}`
10882
+ };
10883
+ }
10884
+ function apt(context, row) {
10885
+ keys2(row, "apt", ["packageName", "artifact", "repository", "suite", "keyUrl"], ["component"]);
10886
+ const pkg = text3(row.packageName, "Debian package name", packagePattern);
10887
+ const asset = exact2(context, row.artifact, "APT", [".deb"]);
10888
+ const repository = https(row.repository, "APT repository", true).href;
10889
+ const suite = text3(row.suite, "APT suite", /^(daily|stable)$/);
10890
+ ensure(suite === context.manifest.channel, `APT suite ${suite} does not match the ${context.manifest.channel} manifest`);
10891
+ const component = text3(row.component ?? "main", "APT component", /^main$/);
10892
+ const keyUrl = https(row.keyUrl, "APT key URL", false).href;
10893
+ const keyring = `/usr/share/keyrings/${pkg}-archive-keyring.gpg`;
10894
+ const sources = `${pkg}.sources`;
10895
+ return {
10896
+ status: "planned",
10897
+ catalogEligible: false,
10898
+ asset,
10899
+ files: [
10900
+ {
10901
+ path: sources,
10902
+ contents: `Types: deb
10903
+ URIs: ${repository}
10904
+ Suites: ${suite}
10905
+ Components: ${component}
10906
+ Architectures: amd64
10907
+ Signed-By: ${keyring}
10908
+ `
10909
+ },
10910
+ stageInput(context, asset)
10911
+ ],
10912
+ install: [
10913
+ `curl -fsSL ${shell(keyUrl)} | sudo gpg --dearmor -o ${keyring}`,
10914
+ `curl -fsSL ${shell(repository + sources)} | sudo tee /etc/apt/sources.list.d/${sources} >/dev/null`,
10915
+ `sudo apt update`,
10916
+ `sudo apt install ${pkg}`
10917
+ ].join(" && ")
10918
+ };
10919
+ }
10920
+ function pacman(context, row) {
10921
+ keys2(row, "pacman", ["packageName", "repository", "base", "keyUrl"], ["keyFingerprint"]);
10922
+ const pkg = text3(row.packageName, "Arch package name", /^[a-z0-9@_+][a-z0-9@._+-]{0,62}$/);
10923
+ const repo = text3(row.repository, "pacman repository name", /^[a-z0-9][a-z0-9_-]{0,63}$/);
10924
+ const base = https(row.base, "pacman repository base", true).href;
10925
+ const keyUrl = https(row.keyUrl, "pacman key URL", false).href;
10926
+ ensure(row.keyFingerprint !== undefined, "Needs keyFingerprint: the pacman signing key is not pinned");
10927
+ const fingerprint = text3(row.keyFingerprint, "pacman key fingerprint", /^[A-F0-9]{40}$/);
10928
+ const snippet = `[${repo}]
10929
+ SigLevel = Required TrustedOnly
10930
+ Server = ${base}$arch
10931
+ `;
10932
+ return {
10933
+ status: "planned",
10934
+ catalogEligible: false,
10935
+ asset: null,
10936
+ files: [
10937
+ { path: "pacman.conf.snippet", contents: snippet },
10938
+ {
10939
+ path: "stage-input.json",
10940
+ contents: JSON.stringify({
10941
+ schema: "framework/package-channel-stage-input/v1",
10942
+ appId: context.common.appId,
10943
+ tag: context.manifest.tag,
10944
+ channel: context.manifest.channel,
10945
+ sourceSha: context.manifest.sourceSha,
10946
+ packageName: pkg,
10947
+ repository: repo,
10948
+ keyFingerprint: fingerprint
10949
+ }, null, 2) + `
10950
+ `
10951
+ }
10952
+ ],
10953
+ install: [
10954
+ `curl -fsSL ${shell(keyUrl)} | sudo pacman-key --add -`,
10955
+ `sudo pacman-key --lsign-key ${fingerprint}`,
10956
+ `printf ${shell(snippet.replaceAll(`
10957
+ `, "\\n"))} | sudo tee -a /etc/pacman.conf >/dev/null`,
10958
+ `sudo pacman -Sy ${pkg}`
10959
+ ].join(" && ")
10960
+ };
10961
+ }
10962
+ function linuxPayload(context, row, label) {
10963
+ const asset = exact2(context, row.artifact, label, [".tar.zst", ".tar.gz", ".tar.xz"]);
10964
+ const bundleRoot = text3(row.bundleRoot, `${label} bundle root`, filePattern);
10965
+ const launcher = text3(row.launcher, `${label} launcher`, relativePath2);
10966
+ ensure(!launcher.split("/").includes(".."), `Invalid ${label} launcher`);
10967
+ const formatEnvironment = text3(row.formatEnvironment, `${label} format environment`, /^[A-Z][A-Z0-9_]*_LINUX_PACKAGE_FORMAT$/);
10968
+ return { asset, bundleRoot, launcher, formatEnvironment };
10969
+ }
10970
+ function rpm(context, row) {
10971
+ keys2(row, "rpm", [
10972
+ "packageName",
10973
+ "artifact",
10974
+ "repoId",
10975
+ "repository",
10976
+ "keyUrl",
10977
+ "bundleRoot",
10978
+ "launcher",
10979
+ "executable",
10980
+ "formatEnvironment"
10981
+ ], ["requires"]);
10982
+ const pkg = text3(row.packageName, "RPM package name", /^[a-z0-9][a-z0-9._+-]{0,62}$/);
10983
+ const { asset, bundleRoot, launcher, formatEnvironment } = linuxPayload(context, row, "RPM");
10984
+ const repoId = text3(row.repoId, "RPM repository id", /^[a-z0-9][a-z0-9_-]{0,63}$/);
10985
+ const repository = https(row.repository, "RPM repository", true).href;
10986
+ const keyUrl = https(row.keyUrl, "RPM key URL", false).href;
10987
+ const executable = text3(row.executable, "RPM executable", /^[a-z0-9][a-z0-9._-]{0,63}$/);
10988
+ const requires = row.requires ?? [];
10989
+ ensure(Array.isArray(requires) && requires.length <= 64, "Invalid RPM requires");
10990
+ const requireLines = requires.map((entry) => `Requires: ${text3(entry, "RPM requirement", /^[A-Za-z0-9][A-Za-z0-9._+()-]*( (>=|=|<=) [A-Za-z0-9._+~^-]+)?$/)}
10991
+ `);
10992
+ const { name, description, homepage, license } = context.common;
10993
+ const spec = `# Generated by @adea-ai/app-framework-release-tools from ${asset.name}.
10994
+ # Repackages the verified portable payload; check Source0 against the SHA-256 before building.
10995
+ %global debug_package %{nil}
10996
+ %global __strip /bin/true
10997
+ %global _build_id_links none
10998
+ %global payload_sha256 ${asset.sha256}
10999
+
11000
+ Name: ${pkg}
11001
+ Version: ${context.version}
11002
+ Release: 1
11003
+ Summary: ${description}
11004
+ License: ${license}
11005
+ URL: ${homepage}
11006
+ Source0: ${asset.url}
11007
+ ExclusiveArch: x86_64
11008
+ AutoReqProv: no
11009
+ ${requireLines.join("")}
11010
+ %description
11011
+ ${name}: ${description}
11012
+
11013
+ %prep
11014
+ echo "%{payload_sha256} %{SOURCE0}" | sha256sum --check --strict
11015
+ %setup -q -c -T
11016
+ tar --no-same-owner -xf %{SOURCE0}
11017
+ test -d ${shell(bundleRoot)}
11018
+
11019
+ %install
11020
+ mkdir -p %{buildroot}%{_libdir}/${pkg} %{buildroot}%{_bindir}
11021
+ cp -a ${shell(bundleRoot)}/. %{buildroot}%{_libdir}/${pkg}/
11022
+ printf 'rpm\\n' > %{buildroot}%{_libdir}/${pkg}/Resources/app/.adea-linux-package
11023
+ cat > %{buildroot}%{_bindir}/${executable} <<'LAUNCHER'
11024
+ #!/bin/sh
11025
+ export ${formatEnvironment}=rpm
11026
+ exec %{_libdir}/${pkg}/${launcher} "$@"
11027
+ LAUNCHER
11028
+ chmod 0755 %{buildroot}%{_bindir}/${executable}
11029
+
11030
+ %files
11031
+ %{_libdir}/${pkg}
11032
+ %{_bindir}/${executable}
11033
+ `;
11034
+ const repoFile = `[${repoId}]
11035
+ name=${name} ${context.manifest.channel}
11036
+ baseurl=${repository}${context.manifest.channel}/$basearch/
11037
+ enabled=1
11038
+ gpgcheck=1
11039
+ repo_gpgcheck=1
11040
+ gpgkey=${keyUrl}
11041
+ `;
11042
+ return {
11043
+ status: "planned",
11044
+ catalogEligible: false,
11045
+ asset,
11046
+ files: [
11047
+ { path: `${pkg}.spec`, contents: spec },
11048
+ { path: `${repoId}.repo`, contents: repoFile },
11049
+ stageInput(context, asset)
11050
+ ],
11051
+ install: [
11052
+ `sudo curl -fsSLo /etc/yum.repos.d/${repoId}.repo ${shell(repository + repoId + ".repo")}`,
11053
+ `sudo dnf install ${pkg}`
11054
+ ].join(" && ")
11055
+ };
11056
+ }
11057
+ var yaml = (value) => JSON.stringify(value);
11058
+ var systemTalkDenied = /^(org\.freedesktop\.(Flatpak|DBus|systemd1)|org\.gtk\.GDBus)(\.|$)/;
11059
+ function flatpak(context, row) {
11060
+ keys2(row, "flatpak", [
11061
+ "applicationId",
11062
+ "artifact",
11063
+ "runtime",
11064
+ "runtimeVersion",
11065
+ "sdk",
11066
+ "bundleRoot",
11067
+ "launcher",
11068
+ "command",
11069
+ "formatEnvironment",
11070
+ "remote",
11071
+ "permissions"
11072
+ ]);
11073
+ const id = text3(row.applicationId, "Flatpak application id", reverseDns);
11074
+ const { asset, bundleRoot, launcher, formatEnvironment } = linuxPayload(context, row, "Flatpak");
11075
+ const runtime = text3(row.runtime, "Flatpak runtime", reverseDns);
11076
+ const sdk = text3(row.sdk, "Flatpak SDK", reverseDns);
11077
+ const runtimeVersion = text3(row.runtimeVersion, "Flatpak runtime version", /^[0-9][0-9.]*$/);
11078
+ const command = text3(row.command, "Flatpak command", /^[a-z0-9][a-z0-9._-]{0,63}$/);
11079
+ const remote = object(row.remote, "flatpak.remote");
11080
+ keys2(remote, "flatpak.remote", ["name", "url"]);
11081
+ const remoteName = text3(remote.name, "Flatpak remote name", /^[a-z0-9][a-z0-9_-]{0,63}$/);
11082
+ const remoteUrl = https(remote.url, "Flatpak remote URL", false).href;
11083
+ ensure(remoteUrl.endsWith(".flatpakrepo"), "Expected a .flatpakrepo remote URL");
11084
+ const permissions = object(row.permissions, "flatpak.permissions");
11085
+ keys2(permissions, "flatpak.permissions", ["network", "sockets", "devices", "sessionTalkNames"]);
11086
+ ensure(typeof permissions.network === "boolean", "Invalid Flatpak network permission");
11087
+ const list = (value, label, allowed) => {
11088
+ ensure(Array.isArray(value) && value.length <= 16, `Invalid Flatpak ${label}`);
11089
+ for (const entry of value)
11090
+ ensure(typeof entry === "string" && allowed(entry), `Unsafe Flatpak ${label}: ${String(entry)}`);
11091
+ ensure(new Set(value).size === value.length, `Duplicate Flatpak ${label}`);
11092
+ return value;
11093
+ };
11094
+ const sockets = list(permissions.sockets, "socket", (s) => s === "wayland" || s === "pulseaudio");
11095
+ const devices = list(permissions.devices, "device", (d) => d === "dri");
11096
+ const talk = list(permissions.sessionTalkNames, "session talk name", (n) => /^[A-Za-z_][\w-]*(\.[A-Za-z_][\w-]*)+$/.test(n) && !systemTalkDenied.test(n));
11097
+ const finishArgs = [
11098
+ ...permissions.network ? ["--share=network"] : [],
11099
+ "--share=ipc",
11100
+ ...sockets.map((s) => `--socket=${s}`),
11101
+ ...sockets.includes("wayland") ? ["--socket=fallback-x11"] : [],
11102
+ ...devices.map((d) => `--device=${d}`),
11103
+ ...talk.map((n) => `--talk-name=${n}`),
11104
+ `--env=${formatEnvironment}=flatpak`
11105
+ ];
11106
+ const manifest = `# Generated by @adea-ai/app-framework-release-tools from ${asset.name}.
11107
+ app-id: ${yaml(id)}
11108
+ runtime: ${yaml(runtime)}
11109
+ runtime-version: ${yaml(runtimeVersion)}
11110
+ sdk: ${yaml(sdk)}
11111
+ command: ${yaml(command)}
11112
+ finish-args:
11113
+ ${finishArgs.map((arg) => ` - ${yaml(arg)}`).join(`
11114
+ `)}
11115
+ modules:
11116
+ - name: ${yaml(id)}
11117
+ buildsystem: simple
11118
+ build-commands:
11119
+ - ${yaml(`mkdir -p /app/lib/${command} /app/bin`)}
11120
+ - ${yaml(`cp -a ${bundleRoot}/. /app/lib/${command}/`)}
11121
+ - ${yaml(`printf 'flatpak\\n' > /app/lib/${command}/Resources/app/.adea-linux-package`)}
11122
+ - ${yaml(`printf '#!/bin/sh\\nexport ${formatEnvironment}=flatpak\\nexec /app/lib/${command}/${launcher} "$@"\\n' > /app/bin/${command}`)}
11123
+ - ${yaml(`chmod 0755 /app/bin/${command}`)}
11124
+ sources:
11125
+ - type: archive
11126
+ url: ${yaml(asset.url)}
11127
+ sha256: ${yaml(asset.sha256)}
11128
+ strip-components: 0
11129
+ `;
11130
+ return {
11131
+ status: "planned",
11132
+ catalogEligible: false,
11133
+ asset,
11134
+ files: [
11135
+ { path: `${id}.yml`, contents: manifest },
11136
+ {
11137
+ path: `${id}.flatpakrepo.snippet`,
11138
+ contents: `[Flatpak Repo]
11139
+ Title=${context.common.name}
11140
+ Url=${new URL("./", remoteUrl).href}
11141
+ `
11142
+ }
11143
+ ],
11144
+ install: [
11145
+ `flatpak remote-add --user --if-not-exists ${remoteName} ${shell(remoteUrl)}`,
11146
+ `flatpak install --user ${remoteName} ${id}`
11147
+ ].join(" && ")
11148
+ };
11149
+ }
11150
+ var planners = { homebrew, winget, apt, pacman, rpm, flatpak };
11151
+ function parseCommon(policy) {
11152
+ keys2(policy, "policy", ["schema", "appId", "name", "description", "homepage", "license", "releaseBase", "channels"], ["downloads"]);
11153
+ ensure(policy.schema === "framework/package-channels/v1", "Unsupported package channel policy");
11154
+ return {
11155
+ appId: text3(policy.appId, "appId", /^(?=.{1,128}$)[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/),
11156
+ name: text3(policy.name, "product name"),
11157
+ description: text3(policy.description, "description"),
11158
+ homepage: https(policy.homepage, "homepage", true).href,
11159
+ license: text3(policy.license, "license", /^[A-Za-z0-9][A-Za-z0-9.+-]*( (AND|OR) [A-Za-z0-9][A-Za-z0-9.+-]*)*$/),
11160
+ releaseBase: https(policy.releaseBase, "release base", true)
11161
+ };
11162
+ }
11163
+ function downloads(context, value) {
11164
+ if (value === undefined)
11165
+ return [];
11166
+ ensure(Array.isArray(value) && value.length <= 32, "Invalid downloads");
11167
+ return value.map((entry) => {
11168
+ const row = object(entry, "download");
11169
+ keys2(row, "download", ["platform", "label", "artifact"]);
11170
+ const platform = text3(row.platform, "download platform", /^(macos|windows|linux)-(arm64|x64)$/);
11171
+ return {
11172
+ platform,
11173
+ label: text3(row.label, "download label"),
11174
+ ...exact2(context, row.artifact, "download", [
11175
+ ".dmg",
11176
+ "-Setup.exe",
11177
+ "-Setup.zip",
11178
+ ".deb",
11179
+ ".AppImage",
11180
+ ".rpm",
11181
+ "-Setup.tar.gz"
11182
+ ])
11183
+ };
11184
+ });
11185
+ }
11186
+ function planPackageChannels(input) {
11187
+ const policy = object(input.policy, "policy");
11188
+ const common = parseCommon(policy);
11189
+ const manifest = parsePackageChannelManifest(input.manifest);
11190
+ ensure(manifest.appId === null || manifest.appId === common.appId, "The manifest belongs to a different app");
11191
+ const configured = object(policy.channels, "policy.channels");
11192
+ keys2(configured, "policy.channels", [], packageChannelNames);
11193
+ const requested = input.channels ?? packageChannelNames.filter((n) => Object.hasOwn(configured, n));
11194
+ ensure(requested.length > 0, "No package channels requested");
11195
+ ensure(new Set(requested).size === requested.length, "Duplicate package channel");
11196
+ const context = { common, manifest, version: manifest.tag.slice(1) };
11197
+ const channels = {};
11198
+ for (const name of requested) {
11199
+ ensure(packageChannelNames.includes(name), `Unknown package channel ${String(name)}`);
11200
+ try {
11201
+ ensure(Object.hasOwn(configured, name), `The policy does not configure ${name}`);
11202
+ channels[name] = planners[name](context, object(configured[name], `policy.channels.${name}`));
11203
+ } catch (error) {
11204
+ channels[name] = { status: "failed", reason: error.message };
11205
+ }
11206
+ }
11207
+ return {
11208
+ schema: "framework/package-channel-plan/v1",
11209
+ appId: common.appId,
11210
+ tag: manifest.tag,
11211
+ version: context.version,
11212
+ channel: manifest.channel,
11213
+ sourceSha: manifest.sourceSha,
11214
+ downloads: downloads(context, policy.downloads),
11215
+ channels
11216
+ };
11217
+ }
10540
11218
  export {
10541
11219
  assertStandaloneWindowsPayload,
10542
11220
  buildLinuxFormats,
@@ -10559,7 +11237,10 @@ export {
10559
11237
  inspectDailyBatch,
10560
11238
  inspectDailyPreSigning,
10561
11239
  inspectStagedStep,
11240
+ packageChannelNames,
11241
+ parsePackageChannelManifest,
10562
11242
  planDailyReleaseMatrix,
11243
+ planPackageChannels,
10563
11244
  planQualificationRun2 as planQualificationRun,
10564
11245
  planReleaseAssets2 as planReleaseAssets,
10565
11246
  promoteDailyBatch,