@adea-ai/app-framework-release-tools 0.9.0 → 0.10.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,
@@ -1989,10 +1992,18 @@ function assertPayloadLayout(options) {
1989
1992
  if (!entries.includes(fold ? name.toLowerCase() : name))
1990
1993
  throw new Error(`Payload missing ${name}`);
1991
1994
  }
1992
- const containsCef = entries.some((name) => /(?:^|\/)(?:chromium embedded framework|libcef\.dll|libcef\.so)$/i.test(name));
1993
- if (containsCef !== (renderer === "cef"))
1995
+ if (payloadRenderer(entries) !== renderer)
1994
1996
  throw new Error("Payload does not match selected renderer");
1995
1997
  }
1998
+ function payloadRenderer(entries) {
1999
+ return entries.some((name) => /(?:^|\/)(?:chromium embedded framework|libcef\.dll|libcef\.so)$/i.test(name)) ? "cef" : "native";
2000
+ }
2001
+ function acceptedUpdateRenderers(renderer, accepted) {
2002
+ const all = [renderer, ...accepted ?? []];
2003
+ if (all.some((item) => item !== "native" && item !== "cef"))
2004
+ throw new Error("Invalid installer profile");
2005
+ return [...new Set(all)];
2006
+ }
1996
2007
  function assertInstallerLayout(platform, appName, entries) {
1997
2008
  assertPortableAppName(appName);
1998
2009
  if (platform !== "windows-x64" && platform !== "linux-x64" && platform !== "linux-arm64")
@@ -4406,6 +4417,8 @@ function planDailyReleaseMatrix(config, tag) {
4406
4417
  const requirements = parsed.requirements(tag);
4407
4418
  const profile = config.dailyReleaseProfile;
4408
4419
  const expanded = profile === expandedDesktopDailyProfile;
4420
+ requireThat(config.dailyInstallerSigning === undefined || config.dailyInstallerSigning === "required", 'dailyInstallerSigning must be "required" when present');
4421
+ const installerSigning = expanded || config.dailyInstallerSigning === "required";
4409
4422
  const checks = [];
4410
4423
  const primaryAssets = [];
4411
4424
  for (const platform of expanded ? expandedPlatforms : platforms) {
@@ -4450,10 +4463,12 @@ function planDailyReleaseMatrix(config, tag) {
4450
4463
  discoveryPolicies(config, tag);
4451
4464
  const all = [...primaryAssets, ...requirements.releaseAssets];
4452
4465
  requireThat(new Set(all).size === all.length, "Daily release assets are not unique");
4453
- return { appId: config.appId, profile, assets: all, checks };
4466
+ return { appId: config.appId, profile, installerSigning, assets: all, checks };
4454
4467
  }
4455
- function requiresDailyInstallerSigning(profile, check) {
4456
- return profile === expandedDesktopDailyProfile && (check.format === "dmg" || check.format === "windows-setup");
4468
+ function requiresDailyInstallerSigning(matrix, check) {
4469
+ if (!matrix.installerSigning)
4470
+ return false;
4471
+ return matrix.profile === expandedDesktopDailyProfile ? check.format === "dmg" || check.format === "windows-setup" : check.format === "dmg";
4457
4472
  }
4458
4473
  function priorDailyInstallerNames(config, tag, check) {
4459
4474
  const plan = planDailyReleaseMatrix(config, tag);
@@ -4534,7 +4549,7 @@ var verifiedMatrix = (options, verifyPrior) => Effect16.gen(function* () {
4534
4549
  const valid = yield* attempt(() => validateDailyNativeEvidence(raw.value, "framework/daily-native-receipt/v2", {
4535
4550
  appId: matrix.appId,
4536
4551
  profile: matrix.profile,
4537
- signing: requiresDailyInstallerSigning(matrix.profile, check) ? installerSigningPolicy(config, check) : undefined,
4552
+ signing: requiresDailyInstallerSigning(matrix, check) ? installerSigningPolicy(config, check) : undefined,
4538
4553
  identity,
4539
4554
  check,
4540
4555
  assets: check.assets.map((name) => inventory.get(name)),
@@ -4733,7 +4748,7 @@ var createDailyNativeReceiptEffect = (options, worker, observedSigning) => Effec
4733
4748
  const [os, arch] = platformTargets[check.platform];
4734
4749
  if (worker.os !== os || worker.arch !== arch)
4735
4750
  return yield* fail(`Daily native check requires ${check.platform}`);
4736
- const signing = requiresDailyInstallerSigning(matrix.profile, check) ? yield* attempt(() => installerSigningPolicy(config, check)) : undefined;
4751
+ const signing = requiresDailyInstallerSigning(matrix, check) ? yield* attempt(() => installerSigningPolicy(config, check)) : undefined;
4737
4752
  if (signing && !observedSigning)
4738
4753
  return yield* fail("Expanded Daily installers require proof from the live native observer");
4739
4754
  const fs = yield* ReleaseFs;
@@ -7637,7 +7652,8 @@ async function extractVerifiedUpdate(options) {
7637
7652
  return extractBoundArchive(options, descriptor, async (file) => verifyReleaseStream(file.createReadStream({ autoClose: false, start: 0 }), descriptor));
7638
7653
  }
7639
7654
  async function extractBoundArchive(options, descriptor, verifyBeforeExtraction) {
7640
- const { archive, platform, renderer, appName, maxCompressedBytes, maxExpandedBytes } = options;
7655
+ const { archive, platform, appName, maxCompressedBytes, maxExpandedBytes } = options;
7656
+ const accepted = acceptedUpdateRenderers(options.renderer, options.acceptedRenderers);
7641
7657
  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
7658
  throw new Error("Invalid update extraction context");
7643
7659
  assertPortableAppName(appName);
@@ -7723,7 +7739,7 @@ async function extractBoundArchive(options, descriptor, verifyBeforeExtraction)
7723
7739
  if (seen.has(key) || seen.size >= 200000)
7724
7740
  return reject();
7725
7741
  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);
7742
+ const cefLink = (platform === "linux-x64" || platform === "linux-arm64") && accepted.includes("cef") && entry.type === "SymbolicLink" && isLinuxCefLibraryLink(relative, linkTarget);
7727
7743
  if (entry.type !== "File" && entry.type !== "Directory" && !cefLink)
7728
7744
  return reject();
7729
7745
  seen.add(key);
@@ -7788,6 +7804,9 @@ async function extractBoundArchive(options, descriptor, verifyBeforeExtraction)
7788
7804
  }
7789
7805
  }
7790
7806
  await rm8(decompressed);
7807
+ const renderer = payloadRenderer(entries);
7808
+ if (!accepted.includes(renderer))
7809
+ throw new Error("Payload does not match selected renderer");
7791
7810
  assertPayloadLayout({ platform, renderer, appName, entries, sidecars });
7792
7811
  const prefix = isMacInstallerPlatform(platform) ? join21(`${appName}.app`, "Contents") : appName.replaceAll(" ", "");
7793
7812
  const resources = join21(payloadRoot, prefix, "Resources");
@@ -8619,6 +8638,7 @@ async function stageUpdateSwap(options) {
8619
8638
  directory: preparing,
8620
8639
  platform: plan.platform,
8621
8640
  renderer: plan.renderer,
8641
+ ...options.acceptedRenderers ? { acceptedRenderers: options.acceptedRenderers } : {},
8622
8642
  appName: plan.appName,
8623
8643
  maxCompressedBytes: options.maxCompressedBytes,
8624
8644
  maxExpandedBytes: options.maxExpandedBytes,
@@ -10537,6 +10557,553 @@ async function buildStandaloneWindowsExe(options) {
10537
10557
  await rm13(work, { recursive: true, force: true });
10538
10558
  }
10539
10559
  }
10560
+ // src/library/package-channels.ts
10561
+ var packageChannelNames = [
10562
+ "homebrew",
10563
+ "winget",
10564
+ "apt",
10565
+ "pacman",
10566
+ "rpm",
10567
+ "flatpak"
10568
+ ];
10569
+ function ensure(ok, message) {
10570
+ if (!ok)
10571
+ throw new Error(message);
10572
+ }
10573
+ function object(value, label) {
10574
+ ensure(typeof value === "object" && value !== null && !Array.isArray(value), `Expected ${label} to be a JSON object`);
10575
+ return value;
10576
+ }
10577
+ function keys2(row, label, required, optional = []) {
10578
+ for (const key of required)
10579
+ ensure(Object.hasOwn(row, key), `Missing ${label}.${key}`);
10580
+ for (const key of Object.keys(row))
10581
+ ensure(required.includes(key) || optional.includes(key), `Unknown ${label}.${key}`);
10582
+ }
10583
+ function text3(value, label, pattern, max = 200) {
10584
+ 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}`);
10585
+ return value;
10586
+ }
10587
+ function https(value, label, directory) {
10588
+ const url = new URL(text3(value, label, undefined, 500));
10589
+ ensure(url.protocol === "https:" && !url.username && !url.password && !url.search && !url.hash, `Expected canonical HTTPS URL for ${label}`);
10590
+ ensure(url.href === value, `Expected canonical HTTPS URL for ${label}`);
10591
+ ensure(url.pathname.endsWith("/") === directory, `Expected ${label} to ${directory ? "" : "not "}end in /`);
10592
+ return url;
10593
+ }
10594
+ var tagPattern3 = /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
10595
+ var sha256Pattern = /^[a-f0-9]{64}$/;
10596
+ var gitShaPattern = /^[a-f0-9]{40}$/;
10597
+ var filePattern = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
10598
+ var templatePattern = /^[A-Za-z0-9][A-Za-z0-9._-]*\{tag\}[A-Za-z0-9._-]*$/;
10599
+ var packagePattern = /^[a-z0-9][a-z0-9+.-]{0,62}$/;
10600
+ var reverseDns = /^[A-Za-z_][A-Za-z0-9_-]*(\.[A-Za-z_][A-Za-z0-9_-]*){2,}$/;
10601
+ var relativePath2 = /^[A-Za-z0-9][A-Za-z0-9._-]*(\/[A-Za-z0-9][A-Za-z0-9._-]*)*$/;
10602
+ var quoted = JSON.stringify;
10603
+ var ruby = (value) => JSON.stringify(value).replace(/#(?=[{@$])/g, "\\#");
10604
+ var shell = (value) => `'${value.replaceAll("'", "'\\''")}'`;
10605
+ function parseAsset(value) {
10606
+ const row = object(value, "manifest asset");
10607
+ const size = row.size;
10608
+ ensure(typeof size === "number" && Number.isSafeInteger(size) && size > 0, "Invalid asset size");
10609
+ const sha256 = row.sha256 ?? row.digest;
10610
+ return {
10611
+ name: text3(row.name, "asset name", filePattern),
10612
+ size,
10613
+ sha256: text3(sha256, "asset SHA-256", sha256Pattern)
10614
+ };
10615
+ }
10616
+ function parsePackageChannelManifest(value) {
10617
+ const doc = object(value, "manifest");
10618
+ let raw;
10619
+ let manifest;
10620
+ if (doc.schema === "framework/daily-batch/v1") {
10621
+ const identity = object(doc.identity, "manifest identity");
10622
+ ensure(Array.isArray(doc.artifacts), "Expected Daily batch artifacts");
10623
+ raw = doc.artifacts;
10624
+ manifest = {
10625
+ appId: text3(identity.appId, "manifest appId"),
10626
+ tag: text3(identity.tag, "release tag", tagPattern3),
10627
+ channel: "daily",
10628
+ sourceSha: text3(identity.sourceSha, "source SHA", gitShaPattern)
10629
+ };
10630
+ } else {
10631
+ ensure(doc.schema === undefined, "Unsupported manifest schema");
10632
+ ensure(doc.channel === "daily" || doc.channel === "stable", "Expected release channel");
10633
+ ensure(Array.isArray(doc.assets), "Expected release assets");
10634
+ raw = doc.assets;
10635
+ manifest = {
10636
+ appId: null,
10637
+ tag: text3(doc.tag, "release tag", tagPattern3),
10638
+ channel: doc.channel,
10639
+ sourceSha: null
10640
+ };
10641
+ }
10642
+ ensure(raw.length > 0 && raw.length <= 512, "Expected a bounded asset inventory");
10643
+ const assets = new Map;
10644
+ for (const entry of raw) {
10645
+ const asset = parseAsset(entry);
10646
+ ensure(!assets.has(asset.name), `Duplicate manifest asset ${asset.name}`);
10647
+ assets.set(asset.name, asset);
10648
+ }
10649
+ return { ...manifest, assets };
10650
+ }
10651
+ function exact2(context, template, label, suffixes) {
10652
+ const name = text3(template, `${label} artifact template`, templatePattern).replace("{tag}", context.manifest.tag);
10653
+ ensure(suffixes.some((suffix) => name.endsWith(suffix)), `Expected ${label} artifact ending in ${suffixes.join(" or ")}`);
10654
+ const asset = context.manifest.assets.get(name);
10655
+ ensure(asset, `The manifest has no ${name}`);
10656
+ return {
10657
+ ...asset,
10658
+ url: new URL(`${context.manifest.tag}/${name}`, context.common.releaseBase).href
10659
+ };
10660
+ }
10661
+ function stageInput(context, asset) {
10662
+ return {
10663
+ path: "stage-input.json",
10664
+ contents: JSON.stringify({
10665
+ schema: "framework/package-channel-stage-input/v1",
10666
+ appId: context.common.appId,
10667
+ tag: context.manifest.tag,
10668
+ channel: context.manifest.channel,
10669
+ sourceSha: context.manifest.sourceSha,
10670
+ asset
10671
+ }, null, 2) + `
10672
+ `
10673
+ };
10674
+ }
10675
+ function homebrew(context, row) {
10676
+ keys2(row, "homebrew", ["tap", "token", "bundle", "artifact"]);
10677
+ const tap = text3(row.tap, "Homebrew tap", /^[A-Za-z0-9][A-Za-z0-9-]*\/homebrew-[a-z0-9][a-z0-9-]*$/);
10678
+ const stableToken = text3(row.token, "cask token", /^[a-z0-9]+(?:-[a-z0-9]+)*$/);
10679
+ const bundle = text3(row.bundle, "app bundle", /^[A-Za-z0-9][A-Za-z0-9 ._-]*\.app$/);
10680
+ const asset = exact2(context, row.artifact, "Homebrew", [".dmg"]);
10681
+ const stable = context.manifest.channel === "stable";
10682
+ const token = stable ? stableToken : `${stableToken}@daily`;
10683
+ const [owner, repository] = tap.split("/");
10684
+ const tapName = `${owner}/${repository.slice("homebrew-".length)}`;
10685
+ const { name, description, homepage } = context.common;
10686
+ return {
10687
+ status: "planned",
10688
+ catalogEligible: stable,
10689
+ asset,
10690
+ files: [
10691
+ {
10692
+ 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)}
10706
+ end
10707
+ `
10708
+ }
10709
+ ],
10710
+ install: `brew install --cask ${tapName}/${token}`
10711
+ };
10712
+ }
10713
+ function winget(context, row) {
10714
+ keys2(row, "winget", ["identifier", "publisher", "artifact", "silent", "silentWithProgress"], ["nestedInstaller"]);
10715
+ 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
+ const publisher = text3(row.publisher, "WinGet publisher");
10717
+ const asset = exact2(context, row.artifact, "WinGet", [".exe", ".zip"]);
10718
+ const direct = asset.name.endsWith(".exe");
10719
+ ensure(direct === (row.nestedInstaller === undefined), direct ? "A direct .exe installer takes no nestedInstaller" : "A .zip installer needs nestedInstaller");
10720
+ const nested = direct ? undefined : text3(row.nestedInstaller, "nested executable", /^[A-Za-z0-9][A-Za-z0-9 ._-]*\.exe$/i);
10721
+ 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);
10724
+ const stable = context.manifest.channel === "stable";
10725
+ const id = stable ? stableId : `${stableId}.Daily`;
10726
+ const { name, description, homepage, license } = context.common;
10727
+ const schemaVersion = "1.12.0";
10728
+ const base = `manifests/${id[0].toLowerCase()}/${id.replaceAll(".", "/")}/${context.version}/${id}`;
10729
+ const manifest = (type, body) => `# yaml-language-server: $schema=https://aka.ms/winget-manifest.${type}.${schemaVersion}.schema.json
10730
+ PackageIdentifier: ${quoted(id)}
10731
+ PackageVersion: ${quoted(context.version)}
10732
+ ${body}ManifestType: ${type}
10733
+ ManifestVersion: ${schemaVersion}
10734
+ `;
10735
+ return {
10736
+ status: "planned",
10737
+ catalogEligible: stable,
10738
+ asset,
10739
+ files: [
10740
+ { path: `${base}.yaml`, contents: manifest("version", `DefaultLocale: en-US
10741
+ `) },
10742
+ {
10743
+ path: `${base}.installer.yaml`,
10744
+ contents: manifest("installer", `${direct ? "InstallerType: exe" : `InstallerType: zip
10745
+ NestedInstallerType: exe
10746
+ NestedInstallerFiles:
10747
+ - RelativeFilePath: ${quoted(nested)}`}
10748
+ InstallerSwitches:
10749
+ Silent: ${quoted(silent)}
10750
+ SilentWithProgress: ${quoted(progress)}
10751
+ UpgradeBehavior: install
10752
+ Installers:
10753
+ - Architecture: x64
10754
+ InstallerUrl: ${quoted(asset.url)}
10755
+ InstallerSha256: ${asset.sha256.toUpperCase()}
10756
+ `)
10757
+ },
10758
+ {
10759
+ path: `${base}.locale.en-US.yaml`,
10760
+ contents: manifest("defaultLocale", `PackageLocale: en-US
10761
+ Publisher: ${quoted(publisher)}
10762
+ PublisherUrl: ${quoted(homepage)}
10763
+ PackageName: ${quoted(stable ? name : `${name} Daily`)}
10764
+ PackageUrl: ${quoted(homepage)}
10765
+ License: ${quoted(license)}
10766
+ ShortDescription: ${quoted(description)}
10767
+ `)
10768
+ }
10769
+ ],
10770
+ install: stable ? `winget install --exact --id ${id}` : `winget install --manifest ${base.slice(0, base.lastIndexOf("/")).replaceAll("/", "\\")}`
10771
+ };
10772
+ }
10773
+ function apt(context, row) {
10774
+ keys2(row, "apt", ["packageName", "artifact", "repository", "suite", "keyUrl"], ["component"]);
10775
+ const pkg = text3(row.packageName, "Debian package name", packagePattern);
10776
+ const asset = exact2(context, row.artifact, "APT", [".deb"]);
10777
+ const repository = https(row.repository, "APT repository", true).href;
10778
+ const suite = text3(row.suite, "APT suite", /^(daily|stable)$/);
10779
+ ensure(suite === context.manifest.channel, `APT suite ${suite} does not match the ${context.manifest.channel} manifest`);
10780
+ const component = text3(row.component ?? "main", "APT component", /^main$/);
10781
+ const keyUrl = https(row.keyUrl, "APT key URL", false).href;
10782
+ const keyring = `/usr/share/keyrings/${pkg}-archive-keyring.gpg`;
10783
+ const sources = `${pkg}.sources`;
10784
+ return {
10785
+ status: "planned",
10786
+ catalogEligible: false,
10787
+ asset,
10788
+ files: [
10789
+ {
10790
+ path: sources,
10791
+ contents: `Types: deb
10792
+ URIs: ${repository}
10793
+ Suites: ${suite}
10794
+ Components: ${component}
10795
+ Architectures: amd64
10796
+ Signed-By: ${keyring}
10797
+ `
10798
+ },
10799
+ stageInput(context, asset)
10800
+ ],
10801
+ install: [
10802
+ `curl -fsSL ${shell(keyUrl)} | sudo gpg --dearmor -o ${keyring}`,
10803
+ `curl -fsSL ${shell(repository + sources)} | sudo tee /etc/apt/sources.list.d/${sources} >/dev/null`,
10804
+ `sudo apt update`,
10805
+ `sudo apt install ${pkg}`
10806
+ ].join(" && ")
10807
+ };
10808
+ }
10809
+ function pacman(context, row) {
10810
+ keys2(row, "pacman", ["packageName", "repository", "base", "keyUrl"], ["keyFingerprint"]);
10811
+ const pkg = text3(row.packageName, "Arch package name", /^[a-z0-9@_+][a-z0-9@._+-]{0,62}$/);
10812
+ const repo = text3(row.repository, "pacman repository name", /^[a-z0-9][a-z0-9_-]{0,63}$/);
10813
+ const base = https(row.base, "pacman repository base", true).href;
10814
+ const keyUrl = https(row.keyUrl, "pacman key URL", false).href;
10815
+ ensure(row.keyFingerprint !== undefined, "Needs keyFingerprint: the pacman signing key is not pinned");
10816
+ const fingerprint = text3(row.keyFingerprint, "pacman key fingerprint", /^[A-F0-9]{40}$/);
10817
+ const snippet = `[${repo}]
10818
+ SigLevel = Required TrustedOnly
10819
+ Server = ${base}$arch
10820
+ `;
10821
+ return {
10822
+ status: "planned",
10823
+ catalogEligible: false,
10824
+ asset: null,
10825
+ files: [
10826
+ { path: "pacman.conf.snippet", contents: snippet },
10827
+ {
10828
+ path: "stage-input.json",
10829
+ contents: JSON.stringify({
10830
+ schema: "framework/package-channel-stage-input/v1",
10831
+ appId: context.common.appId,
10832
+ tag: context.manifest.tag,
10833
+ channel: context.manifest.channel,
10834
+ sourceSha: context.manifest.sourceSha,
10835
+ packageName: pkg,
10836
+ repository: repo,
10837
+ keyFingerprint: fingerprint
10838
+ }, null, 2) + `
10839
+ `
10840
+ }
10841
+ ],
10842
+ install: [
10843
+ `curl -fsSL ${shell(keyUrl)} | sudo pacman-key --add -`,
10844
+ `sudo pacman-key --lsign-key ${fingerprint}`,
10845
+ `printf ${shell(snippet.replaceAll(`
10846
+ `, "\\n"))} | sudo tee -a /etc/pacman.conf >/dev/null`,
10847
+ `sudo pacman -Sy ${pkg}`
10848
+ ].join(" && ")
10849
+ };
10850
+ }
10851
+ function linuxPayload(context, row, label) {
10852
+ const asset = exact2(context, row.artifact, label, [".tar.zst", ".tar.gz", ".tar.xz"]);
10853
+ const bundleRoot = text3(row.bundleRoot, `${label} bundle root`, filePattern);
10854
+ const launcher = text3(row.launcher, `${label} launcher`, relativePath2);
10855
+ ensure(!launcher.split("/").includes(".."), `Invalid ${label} launcher`);
10856
+ const formatEnvironment = text3(row.formatEnvironment, `${label} format environment`, /^[A-Z][A-Z0-9_]*_LINUX_PACKAGE_FORMAT$/);
10857
+ return { asset, bundleRoot, launcher, formatEnvironment };
10858
+ }
10859
+ function rpm(context, row) {
10860
+ keys2(row, "rpm", [
10861
+ "packageName",
10862
+ "artifact",
10863
+ "repoId",
10864
+ "repository",
10865
+ "keyUrl",
10866
+ "bundleRoot",
10867
+ "launcher",
10868
+ "executable",
10869
+ "formatEnvironment"
10870
+ ], ["requires"]);
10871
+ const pkg = text3(row.packageName, "RPM package name", /^[a-z0-9][a-z0-9._+-]{0,62}$/);
10872
+ const { asset, bundleRoot, launcher, formatEnvironment } = linuxPayload(context, row, "RPM");
10873
+ const repoId = text3(row.repoId, "RPM repository id", /^[a-z0-9][a-z0-9_-]{0,63}$/);
10874
+ const repository = https(row.repository, "RPM repository", true).href;
10875
+ const keyUrl = https(row.keyUrl, "RPM key URL", false).href;
10876
+ const executable = text3(row.executable, "RPM executable", /^[a-z0-9][a-z0-9._-]{0,63}$/);
10877
+ const requires = row.requires ?? [];
10878
+ ensure(Array.isArray(requires) && requires.length <= 64, "Invalid RPM requires");
10879
+ const requireLines = requires.map((entry) => `Requires: ${text3(entry, "RPM requirement", /^[A-Za-z0-9][A-Za-z0-9._+()-]*( (>=|=|<=) [A-Za-z0-9._+~^-]+)?$/)}
10880
+ `);
10881
+ const { name, description, homepage, license } = context.common;
10882
+ const spec = `# Generated by @adea-ai/app-framework-release-tools from ${asset.name}.
10883
+ # Repackages the verified portable payload; check Source0 against the SHA-256 before building.
10884
+ %global debug_package %{nil}
10885
+ %global __strip /bin/true
10886
+ %global _build_id_links none
10887
+ %global payload_sha256 ${asset.sha256}
10888
+
10889
+ Name: ${pkg}
10890
+ Version: ${context.version}
10891
+ Release: 1
10892
+ Summary: ${description}
10893
+ License: ${license}
10894
+ URL: ${homepage}
10895
+ Source0: ${asset.url}
10896
+ ExclusiveArch: x86_64
10897
+ AutoReqProv: no
10898
+ ${requireLines.join("")}
10899
+ %description
10900
+ ${name}: ${description}
10901
+
10902
+ %prep
10903
+ echo "%{payload_sha256} %{SOURCE0}" | sha256sum --check --strict
10904
+ %setup -q -c -T
10905
+ tar --no-same-owner -xf %{SOURCE0}
10906
+ test -d ${shell(bundleRoot)}
10907
+
10908
+ %install
10909
+ mkdir -p %{buildroot}%{_libdir}/${pkg} %{buildroot}%{_bindir}
10910
+ cp -a ${shell(bundleRoot)}/. %{buildroot}%{_libdir}/${pkg}/
10911
+ printf 'rpm\\n' > %{buildroot}%{_libdir}/${pkg}/Resources/app/.adea-linux-package
10912
+ cat > %{buildroot}%{_bindir}/${executable} <<'LAUNCHER'
10913
+ #!/bin/sh
10914
+ export ${formatEnvironment}=rpm
10915
+ exec %{_libdir}/${pkg}/${launcher} "$@"
10916
+ LAUNCHER
10917
+ chmod 0755 %{buildroot}%{_bindir}/${executable}
10918
+
10919
+ %files
10920
+ %{_libdir}/${pkg}
10921
+ %{_bindir}/${executable}
10922
+ `;
10923
+ const repoFile = `[${repoId}]
10924
+ name=${name} ${context.manifest.channel}
10925
+ baseurl=${repository}${context.manifest.channel}/$basearch/
10926
+ enabled=1
10927
+ gpgcheck=1
10928
+ repo_gpgcheck=1
10929
+ gpgkey=${keyUrl}
10930
+ `;
10931
+ return {
10932
+ status: "planned",
10933
+ catalogEligible: false,
10934
+ asset,
10935
+ files: [
10936
+ { path: `${pkg}.spec`, contents: spec },
10937
+ { path: `${repoId}.repo`, contents: repoFile },
10938
+ stageInput(context, asset)
10939
+ ],
10940
+ install: [
10941
+ `sudo curl -fsSLo /etc/yum.repos.d/${repoId}.repo ${shell(repository + repoId + ".repo")}`,
10942
+ `sudo dnf install ${pkg}`
10943
+ ].join(" && ")
10944
+ };
10945
+ }
10946
+ var yaml = (value) => JSON.stringify(value);
10947
+ var systemTalkDenied = /^(org\.freedesktop\.(Flatpak|DBus|systemd1)|org\.gtk\.GDBus)(\.|$)/;
10948
+ function flatpak(context, row) {
10949
+ keys2(row, "flatpak", [
10950
+ "applicationId",
10951
+ "artifact",
10952
+ "runtime",
10953
+ "runtimeVersion",
10954
+ "sdk",
10955
+ "bundleRoot",
10956
+ "launcher",
10957
+ "command",
10958
+ "formatEnvironment",
10959
+ "remote",
10960
+ "permissions"
10961
+ ]);
10962
+ const id = text3(row.applicationId, "Flatpak application id", reverseDns);
10963
+ const { asset, bundleRoot, launcher, formatEnvironment } = linuxPayload(context, row, "Flatpak");
10964
+ const runtime = text3(row.runtime, "Flatpak runtime", reverseDns);
10965
+ const sdk = text3(row.sdk, "Flatpak SDK", reverseDns);
10966
+ const runtimeVersion = text3(row.runtimeVersion, "Flatpak runtime version", /^[0-9][0-9.]*$/);
10967
+ const command = text3(row.command, "Flatpak command", /^[a-z0-9][a-z0-9._-]{0,63}$/);
10968
+ const remote = object(row.remote, "flatpak.remote");
10969
+ keys2(remote, "flatpak.remote", ["name", "url"]);
10970
+ const remoteName = text3(remote.name, "Flatpak remote name", /^[a-z0-9][a-z0-9_-]{0,63}$/);
10971
+ const remoteUrl = https(remote.url, "Flatpak remote URL", false).href;
10972
+ ensure(remoteUrl.endsWith(".flatpakrepo"), "Expected a .flatpakrepo remote URL");
10973
+ const permissions = object(row.permissions, "flatpak.permissions");
10974
+ keys2(permissions, "flatpak.permissions", ["network", "sockets", "devices", "sessionTalkNames"]);
10975
+ ensure(typeof permissions.network === "boolean", "Invalid Flatpak network permission");
10976
+ const list = (value, label, allowed) => {
10977
+ ensure(Array.isArray(value) && value.length <= 16, `Invalid Flatpak ${label}`);
10978
+ for (const entry of value)
10979
+ ensure(typeof entry === "string" && allowed(entry), `Unsafe Flatpak ${label}: ${String(entry)}`);
10980
+ ensure(new Set(value).size === value.length, `Duplicate Flatpak ${label}`);
10981
+ return value;
10982
+ };
10983
+ const sockets = list(permissions.sockets, "socket", (s) => s === "wayland" || s === "pulseaudio");
10984
+ const devices = list(permissions.devices, "device", (d) => d === "dri");
10985
+ const talk = list(permissions.sessionTalkNames, "session talk name", (n) => /^[A-Za-z_][\w-]*(\.[A-Za-z_][\w-]*)+$/.test(n) && !systemTalkDenied.test(n));
10986
+ const finishArgs = [
10987
+ ...permissions.network ? ["--share=network"] : [],
10988
+ "--share=ipc",
10989
+ ...sockets.map((s) => `--socket=${s}`),
10990
+ ...sockets.includes("wayland") ? ["--socket=fallback-x11"] : [],
10991
+ ...devices.map((d) => `--device=${d}`),
10992
+ ...talk.map((n) => `--talk-name=${n}`),
10993
+ `--env=${formatEnvironment}=flatpak`
10994
+ ];
10995
+ const manifest = `# Generated by @adea-ai/app-framework-release-tools from ${asset.name}.
10996
+ app-id: ${yaml(id)}
10997
+ runtime: ${yaml(runtime)}
10998
+ runtime-version: ${yaml(runtimeVersion)}
10999
+ sdk: ${yaml(sdk)}
11000
+ command: ${yaml(command)}
11001
+ finish-args:
11002
+ ${finishArgs.map((arg) => ` - ${yaml(arg)}`).join(`
11003
+ `)}
11004
+ modules:
11005
+ - name: ${yaml(id)}
11006
+ buildsystem: simple
11007
+ build-commands:
11008
+ - ${yaml(`mkdir -p /app/lib/${command} /app/bin`)}
11009
+ - ${yaml(`cp -a ${bundleRoot}/. /app/lib/${command}/`)}
11010
+ - ${yaml(`printf 'flatpak\\n' > /app/lib/${command}/Resources/app/.adea-linux-package`)}
11011
+ - ${yaml(`printf '#!/bin/sh\\nexport ${formatEnvironment}=flatpak\\nexec /app/lib/${command}/${launcher} "$@"\\n' > /app/bin/${command}`)}
11012
+ - ${yaml(`chmod 0755 /app/bin/${command}`)}
11013
+ sources:
11014
+ - type: archive
11015
+ url: ${yaml(asset.url)}
11016
+ sha256: ${yaml(asset.sha256)}
11017
+ strip-components: 0
11018
+ `;
11019
+ return {
11020
+ status: "planned",
11021
+ catalogEligible: false,
11022
+ asset,
11023
+ files: [
11024
+ { path: `${id}.yml`, contents: manifest },
11025
+ {
11026
+ path: `${id}.flatpakrepo.snippet`,
11027
+ contents: `[Flatpak Repo]
11028
+ Title=${context.common.name}
11029
+ Url=${new URL("./", remoteUrl).href}
11030
+ `
11031
+ }
11032
+ ],
11033
+ install: [
11034
+ `flatpak remote-add --user --if-not-exists ${remoteName} ${shell(remoteUrl)}`,
11035
+ `flatpak install --user ${remoteName} ${id}`
11036
+ ].join(" && ")
11037
+ };
11038
+ }
11039
+ var planners = { homebrew, winget, apt, pacman, rpm, flatpak };
11040
+ function parseCommon(policy) {
11041
+ keys2(policy, "policy", ["schema", "appId", "name", "description", "homepage", "license", "releaseBase", "channels"], ["downloads"]);
11042
+ ensure(policy.schema === "framework/package-channels/v1", "Unsupported package channel policy");
11043
+ return {
11044
+ appId: text3(policy.appId, "appId", /^(?=.{1,128}$)[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/),
11045
+ name: text3(policy.name, "product name"),
11046
+ description: text3(policy.description, "description"),
11047
+ homepage: https(policy.homepage, "homepage", true).href,
11048
+ license: text3(policy.license, "license", /^[A-Za-z0-9][A-Za-z0-9.+-]*( (AND|OR) [A-Za-z0-9][A-Za-z0-9.+-]*)*$/),
11049
+ releaseBase: https(policy.releaseBase, "release base", true)
11050
+ };
11051
+ }
11052
+ function downloads(context, value) {
11053
+ if (value === undefined)
11054
+ return [];
11055
+ ensure(Array.isArray(value) && value.length <= 32, "Invalid downloads");
11056
+ return value.map((entry) => {
11057
+ const row = object(entry, "download");
11058
+ keys2(row, "download", ["platform", "label", "artifact"]);
11059
+ const platform = text3(row.platform, "download platform", /^(macos|windows|linux)-(arm64|x64)$/);
11060
+ return {
11061
+ platform,
11062
+ label: text3(row.label, "download label"),
11063
+ ...exact2(context, row.artifact, "download", [
11064
+ ".dmg",
11065
+ "-Setup.exe",
11066
+ "-Setup.zip",
11067
+ ".deb",
11068
+ ".AppImage",
11069
+ ".rpm",
11070
+ "-Setup.tar.gz"
11071
+ ])
11072
+ };
11073
+ });
11074
+ }
11075
+ function planPackageChannels(input) {
11076
+ const policy = object(input.policy, "policy");
11077
+ const common = parseCommon(policy);
11078
+ const manifest = parsePackageChannelManifest(input.manifest);
11079
+ ensure(manifest.appId === null || manifest.appId === common.appId, "The manifest belongs to a different app");
11080
+ const configured = object(policy.channels, "policy.channels");
11081
+ keys2(configured, "policy.channels", [], packageChannelNames);
11082
+ const requested = input.channels ?? packageChannelNames.filter((n) => Object.hasOwn(configured, n));
11083
+ ensure(requested.length > 0, "No package channels requested");
11084
+ ensure(new Set(requested).size === requested.length, "Duplicate package channel");
11085
+ const context = { common, manifest, version: manifest.tag.slice(1) };
11086
+ const channels = {};
11087
+ for (const name of requested) {
11088
+ ensure(packageChannelNames.includes(name), `Unknown package channel ${String(name)}`);
11089
+ try {
11090
+ ensure(Object.hasOwn(configured, name), `The policy does not configure ${name}`);
11091
+ channels[name] = planners[name](context, object(configured[name], `policy.channels.${name}`));
11092
+ } catch (error) {
11093
+ channels[name] = { status: "failed", reason: error.message };
11094
+ }
11095
+ }
11096
+ return {
11097
+ schema: "framework/package-channel-plan/v1",
11098
+ appId: common.appId,
11099
+ tag: manifest.tag,
11100
+ version: context.version,
11101
+ channel: manifest.channel,
11102
+ sourceSha: manifest.sourceSha,
11103
+ downloads: downloads(context, policy.downloads),
11104
+ channels
11105
+ };
11106
+ }
10540
11107
  export {
10541
11108
  assertStandaloneWindowsPayload,
10542
11109
  buildLinuxFormats,
@@ -10559,7 +11126,10 @@ export {
10559
11126
  inspectDailyBatch,
10560
11127
  inspectDailyPreSigning,
10561
11128
  inspectStagedStep,
11129
+ packageChannelNames,
11130
+ parsePackageChannelManifest,
10562
11131
  planDailyReleaseMatrix,
11132
+ planPackageChannels,
10563
11133
  planQualificationRun2 as planQualificationRun,
10564
11134
  planReleaseAssets2 as planReleaseAssets,
10565
11135
  promoteDailyBatch,
@@ -1 +1 @@
1
- {"version":"0.9.0","commit":"8ab34499ea15c2233d6747f69d262fdd5c74b4ad"}
1
+ {"version":"0.10.0","commit":"15725353a83f706e8e7cb1340e7da4a7a5e4f0bd"}