@adea-ai/app-framework-release-tools 0.1.0 → 0.2.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/cli.js CHANGED
@@ -45,10 +45,10 @@ __export(exports_src, {
45
45
  });
46
46
 
47
47
  // src/cli.ts
48
- import { Effect as Effect25 } from "effect";
48
+ import { Effect as Effect26 } from "effect";
49
49
 
50
50
  // src/cli-commands.ts
51
- import { Effect as Effect24 } from "effect";
51
+ import { Effect as Effect25 } from "effect";
52
52
 
53
53
  // ../../src/cli/cli-runner.ts
54
54
  var MAX_ERROR_LENGTH = 400;
@@ -350,6 +350,149 @@ function errorCode(error) {
350
350
  return typeof code === "string" ? code : undefined;
351
351
  }
352
352
 
353
+ // ../../src/updates/feed/arch-package-policy.ts
354
+ var packageName = /^[a-z0-9][a-z0-9@+._-]{0,63}$/;
355
+ var executableName = /^[a-z][a-z0-9-]{0,63}$/;
356
+ var licenseToken = /^[A-Za-z0-9][A-Za-z0-9.+:-]{0,63}$/;
357
+ var category = /^[A-Za-z][A-Za-z0-9-]{0,31}$/;
358
+ var relative2 = /^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;
359
+ var optdependsEntry = /^[a-z0-9][a-z0-9@+._-]{0,63}(?:: [^<>\r\n]{1,128})?$/;
360
+ function assert(condition, message) {
361
+ if (!condition)
362
+ throw new Error(message);
363
+ }
364
+ function text(value, maximum) {
365
+ return typeof value === "string" && value.length > 0 && value.length <= maximum && !containsAsciiControl(value) && value.trim() === value;
366
+ }
367
+ function httpsUrl(value) {
368
+ if (typeof value !== "string" || value.length > 300)
369
+ return false;
370
+ let url;
371
+ try {
372
+ url = new URL(value);
373
+ } catch {
374
+ return false;
375
+ }
376
+ return url.protocol === "https:" && (url.href === value || url.pathname === "/" && url.href === `${value}/`) && !url.username && !url.password && !url.port && !url.search && !url.hash;
377
+ }
378
+ function sourceTemplate(value) {
379
+ if (typeof value !== "string" || !value.includes("{tag}"))
380
+ return false;
381
+ const rest = value.replaceAll("{tag}", "");
382
+ return !rest.includes("{") && !rest.includes("}") && httpsUrl(value.replaceAll("{tag}", "v1.0.0"));
383
+ }
384
+ function tokenList(value, options) {
385
+ assert(Array.isArray(value) && value.length >= options.minimum && value.length <= options.maximum && value.every((item) => typeof item === "string" && item.length <= 200 && options.pattern.test(item) && !containsAsciiControl(item)) && new Set(value).size === value.length, options.message);
386
+ return [...value];
387
+ }
388
+ function bundlePath(value, suffix) {
389
+ return typeof value === "string" && value.length <= 200 && relative2.test(value) && !value.split("/").some((part) => part === "." || part === "..") && (suffix === undefined || value.endsWith(suffix));
390
+ }
391
+ var policyKeys = new Set([
392
+ "pkgname",
393
+ "pkgdesc",
394
+ "maintainer",
395
+ "url",
396
+ "license",
397
+ "depends",
398
+ "optdepends",
399
+ "provides",
400
+ "conflicts",
401
+ "executable",
402
+ "setuid",
403
+ "desktop",
404
+ "icon",
405
+ "licenseSource",
406
+ "links",
407
+ "channel",
408
+ "repository"
409
+ ]);
410
+ function parseArchPackage(value) {
411
+ assert(isRecord(value) && Object.keys(value).every((key) => policyKeys.has(key)), "Invalid Arch package configuration");
412
+ const policy = value;
413
+ const desktop = policy.desktop;
414
+ const links = policy.links ?? [];
415
+ assert(typeof policy.pkgname === "string" && packageName.test(policy.pkgname) && policy.pkgname.endsWith("-bin"), "Arch package name must be a lowercase pkgname ending in -bin");
416
+ assert(text(policy.pkgdesc, 256), "Invalid Arch package description");
417
+ assert(text(policy.maintainer, 128) && /^[^<>\r\n]{1,64} <[^<>\r\n]{3,64}>$/.test(policy.maintainer), "Invalid Arch package maintainer");
418
+ assert(httpsUrl(policy.url), "Invalid Arch package URL");
419
+ assert(text(policy.executable, 64) && executableName.test(policy.executable), "Invalid Arch executable");
420
+ assert(policy.icon === undefined || bundlePath(policy.icon, ".svg"), "Invalid Arch package icon");
421
+ assert(policy.licenseSource === undefined || sourceTemplate(policy.licenseSource), "Invalid Arch license source");
422
+ assert(isRecord(desktop) && Object.keys(desktop).every((key) => ["name", "comment", "categories"].includes(key)) && text(desktop.name, 64) && (desktop.comment === undefined || text(desktop.comment, 128)) && "categories" in desktop, "Invalid Arch desktop entry");
423
+ assert(Array.isArray(links) && links.length <= 8 && links.every((link, index) => isRecord(link) && Object.keys(link).length === 2 && text(link.name, 64) && executableName.test(link.name) && link.name !== policy.executable && links.findIndex((item) => isRecord(item) && item.name === link.name) === index && bundlePath(link.target)), "Invalid Arch package links");
424
+ assert(policy.channel === undefined || policy.channel === "stable" || policy.channel === "daily", "Invalid Arch package channel");
425
+ const repository = policy.repository;
426
+ assert(repository === undefined || isRecord(repository) && Object.keys(repository).length === 3 && typeof repository.name === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(repository.name) && httpsUrl(repository.base) && repository.base.endsWith("/") && httpsUrl(repository.publicKey), "Invalid Arch package repository");
427
+ return {
428
+ pkgname: policy.pkgname,
429
+ pkgdesc: policy.pkgdesc,
430
+ maintainer: policy.maintainer,
431
+ url: policy.url,
432
+ license: tokenList(policy.license, {
433
+ maximum: 8,
434
+ minimum: 1,
435
+ pattern: licenseToken,
436
+ message: "Invalid Arch package license"
437
+ }),
438
+ depends: tokenList(policy.depends, {
439
+ maximum: 64,
440
+ minimum: 1,
441
+ pattern: packageName,
442
+ message: "Invalid Arch package dependencies"
443
+ }),
444
+ optdepends: tokenList(policy.optdepends ?? [], {
445
+ maximum: 32,
446
+ minimum: 0,
447
+ pattern: optdependsEntry,
448
+ message: "Invalid Arch optional dependencies"
449
+ }),
450
+ provides: tokenList(policy.provides ?? [], {
451
+ maximum: 16,
452
+ minimum: 0,
453
+ pattern: packageName,
454
+ message: "Invalid Arch package provides"
455
+ }),
456
+ conflicts: tokenList(policy.conflicts ?? [], {
457
+ maximum: 16,
458
+ minimum: 0,
459
+ pattern: packageName,
460
+ message: "Invalid Arch package conflicts"
461
+ }),
462
+ executable: policy.executable,
463
+ setuid: tokenList(policy.setuid ?? [], {
464
+ maximum: 8,
465
+ minimum: 0,
466
+ pattern: /^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+$/,
467
+ message: "Invalid Arch setuid executables"
468
+ }),
469
+ desktop: {
470
+ name: desktop.name,
471
+ ...desktop.comment === undefined ? {} : { comment: desktop.comment },
472
+ categories: tokenList(desktop.categories, {
473
+ maximum: 8,
474
+ minimum: 1,
475
+ pattern: category,
476
+ message: "Invalid Arch desktop categories"
477
+ })
478
+ },
479
+ ...policy.icon === undefined ? {} : { icon: policy.icon },
480
+ ...policy.licenseSource === undefined ? {} : { licenseSource: policy.licenseSource },
481
+ links: links.map((link) => ({
482
+ name: link.name,
483
+ target: link.target
484
+ })),
485
+ channel: policy.channel ?? "stable",
486
+ ...repository === undefined ? {} : {
487
+ repository: {
488
+ name: repository.name,
489
+ base: repository.base,
490
+ publicKey: repository.publicKey
491
+ }
492
+ }
493
+ };
494
+ }
495
+
353
496
  // ../../src/updates/feed/release-feed.ts
354
497
  var MAX_LEDGER_RELEASES = 500;
355
498
  var MAX_RELEASE_ASSETS = 256;
@@ -435,19 +578,19 @@ function parseReleaseLedger(value, app) {
435
578
  }
436
579
 
437
580
  // ../../src/updates/feed/release-config-contract.ts
438
- function assert(condition, message) {
581
+ function assert2(condition, message) {
439
582
  if (!condition)
440
583
  throw new Error(message);
441
584
  }
442
585
  function parseOfflinePolicy(value) {
443
- assert(typeof value === "object" && value !== null && !Array.isArray(value), "Invalid offline policy");
586
+ assert2(typeof value === "object" && value !== null && !Array.isArray(value), "Invalid offline policy");
444
587
  const policy = value;
445
- assert(typeof policy.marker === "string" && policy.marker.trim().length > 0 && policy.marker.length <= 256 && !containsAsciiControl(policy.marker), "Invalid offline marker");
588
+ assert2(typeof policy.marker === "string" && policy.marker.trim().length > 0 && policy.marker.length <= 256 && !containsAsciiControl(policy.marker), "Invalid offline marker");
446
589
  if (policy.kind === "standalone") {
447
- assert(Object.keys(policy).length === 2, "Invalid standalone offline policy");
590
+ assert2(Object.keys(policy).length === 2, "Invalid standalone offline policy");
448
591
  return { kind: "standalone", marker: policy.marker };
449
592
  }
450
- assert(policy.kind === "local-bootstrap" && Object.keys(policy).length === 3 && typeof policy.path === "string" && policy.path.length <= 256 && /^\/(?:[A-Za-z0-9_~-]+\/)*[A-Za-z0-9_~-]+$/.test(policy.path) && !policy.path.startsWith("/__framework/"), "Invalid bootstrap offline policy");
593
+ assert2(policy.kind === "local-bootstrap" && Object.keys(policy).length === 3 && typeof policy.path === "string" && policy.path.length <= 256 && /^\/(?:[A-Za-z0-9_~-]+\/)*[A-Za-z0-9_~-]+$/.test(policy.path) && !policy.path.startsWith("/__framework/"), "Invalid bootstrap offline policy");
451
594
  return { kind: "local-bootstrap", marker: policy.marker, path: policy.path };
452
595
  }
453
596
  var strings = (value) => Array.isArray(value) && value.length > 0 && value.every((item) => typeof item === "string" && item.length <= 200 && /^[A-Za-z0-9][A-Za-z0-9._{}-]*$/.test(item) && !item.replaceAll("{tag}", "").includes("{") && !item.replaceAll("{tag}", "").includes("}")) && new Set(value).size === value.length;
@@ -542,6 +685,7 @@ function parseReleaseConfig(config) {
542
685
  if (!/^[a-z0-9-]+$/.test(platform) || !strings(assets))
543
686
  throw new Error("Invalid release platform configuration");
544
687
  const platformSnapshot = Object.fromEntries(Object.entries(platforms).map(([platform, assets]) => [platform, [...assets]]));
688
+ const archPackage = config.archPackage === undefined ? undefined : parseArchPackage(config.archPackage);
545
689
  const commandArtifacts = parseCommandArtifacts(config.commandArtifacts, Object.keys(platforms));
546
690
  const appIds = [config.appId, ...commandArtifacts.map((artifact) => artifact.appId)];
547
691
  if (new Set(appIds).size !== appIds.length)
@@ -586,6 +730,7 @@ function parseReleaseConfig(config) {
586
730
  sidecars,
587
731
  releaseWorkflows,
588
732
  feed,
733
+ archPackage,
589
734
  commandArtifacts,
590
735
  requirements
591
736
  };
@@ -1123,7 +1268,7 @@ function normalizePromotionRelease(value) {
1123
1268
  }
1124
1269
 
1125
1270
  // ../../src/release/release-qualification.ts
1126
- function assert2(condition, message) {
1271
+ function assert3(condition, message) {
1127
1272
  if (!condition)
1128
1273
  throw new Error(message);
1129
1274
  }
@@ -1131,19 +1276,19 @@ function expectedAssets(requirements) {
1131
1276
  if (Object.hasOwn(requirements, "offlinePolicy"))
1132
1277
  parseOfflinePolicy(requirements.offlinePolicy);
1133
1278
  const platforms = Object.entries(requirements.platforms);
1134
- assert2(platforms.length > 0, "Missing platforms");
1279
+ assert3(platforms.length > 0, "Missing platforms");
1135
1280
  const names = [
1136
1281
  ...platforms.flatMap(([platform, artifacts]) => {
1137
- assert2(/^[a-z0-9-]+$/.test(platform) && artifacts.length > 0, "Invalid platform requirements");
1282
+ assert3(/^[a-z0-9-]+$/.test(platform) && artifacts.length > 0, "Invalid platform requirements");
1138
1283
  return artifacts;
1139
1284
  }),
1140
1285
  ...Object.entries(requirements.commandArtifacts ?? {}).flatMap(([kind, byPlatform]) => {
1141
- assert2(/^[a-z][a-z0-9-]{0,31}$/.test(kind) && Object.keys(byPlatform).length === platforms.length && platforms.every(([platform]) => typeof byPlatform[platform] === "string"), "Invalid command artifact requirements");
1286
+ assert3(/^[a-z][a-z0-9-]{0,31}$/.test(kind) && Object.keys(byPlatform).length === platforms.length && platforms.every(([platform]) => typeof byPlatform[platform] === "string"), "Invalid command artifact requirements");
1142
1287
  return Object.values(byPlatform);
1143
1288
  }),
1144
1289
  ...requirements.releaseAssets
1145
1290
  ];
1146
- assert2(names.length > 0 && names.every((name) => /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(name)) && new Set(names).size === names.length, "Invalid or duplicate asset requirements");
1291
+ assert3(names.length > 0 && names.every((name) => /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(name)) && new Set(names).size === names.length, "Invalid or duplicate asset requirements");
1147
1292
  return names;
1148
1293
  }
1149
1294
  function matches(saved, uploaded) {
@@ -1151,74 +1296,74 @@ function matches(saved, uploaded) {
1151
1296
  }
1152
1297
  function uniqueAsset(assets, name) {
1153
1298
  const found = assets.filter((asset) => asset.name === name);
1154
- assert2(found.length === 1, `Missing or duplicate asset: ${name}`);
1299
+ assert3(found.length === 1, `Missing or duplicate asset: ${name}`);
1155
1300
  return found[0];
1156
1301
  }
1157
1302
  function checkRenderer(value, offlinePolicy) {
1158
1303
  const port = Number(value?.origin?.split(":").at(-1));
1159
1304
  const common = value && port >= 1024 && port <= 65535 && /^http:\/\/127\.0\.0\.1:[1-9]\d{3,4}$/.test(value.origin) && value.samples === 2 && value.guardInstalled === true && value.offlineObserved === true && value.unexpectedActivity === false && Number.isFinite(value.elapsedMs) && value.elapsedMs >= 3000 && value.visible === true && ["interactive", "complete"].includes(value.readyState) && Number.isFinite(value.width) && value.width >= 100 && Number.isFinite(value.height) && value.height >= 100 && Number.isSafeInteger(value.interactiveElements) && value.interactiveElements >= 1 && Number.isSafeInteger(value.textLength) && value.textLength >= 1;
1160
1305
  if (!offlinePolicy) {
1161
- assert2(common && value.method === "native-dom-raf-v1" && value.bootstrapDenied === true, "Incomplete native renderer evidence");
1306
+ assert3(common && value.method === "native-dom-raf-v1" && value.bootstrapDenied === true, "Incomplete native renderer evidence");
1162
1307
  return;
1163
1308
  }
1164
- assert2(value && value.offlinePolicy, "Incomplete native renderer evidence");
1309
+ assert3(value && value.offlinePolicy, "Incomplete native renderer evidence");
1165
1310
  const policy = parseOfflinePolicy(offlinePolicy), observed = parseOfflinePolicy(value.offlinePolicy);
1166
- assert2(common && value.method === "native-dom-raf-v2" && value.markerObserved === true && value.browserNetworkRestricted === true && observed.kind === policy.kind && observed.marker === policy.marker && (policy.kind === "standalone" ? value.bootstrapDenied === false : observed.kind === "local-bootstrap" && observed.path === policy.path && value.bootstrapDenied === true), "Incomplete native renderer evidence");
1311
+ assert3(common && value.method === "native-dom-raf-v2" && value.markerObserved === true && value.browserNetworkRestricted === true && observed.kind === policy.kind && observed.marker === policy.marker && (policy.kind === "standalone" ? value.bootstrapDenied === false : observed.kind === "local-bootstrap" && observed.path === policy.path && value.bootstrapDenied === true), "Incomplete native renderer evidence");
1167
1312
  }
1168
1313
  function validateInstallerReceipt(identity, entry, platform, names, assets, offlinePolicy) {
1169
1314
  assertIdentity(identity, platform);
1170
- assert2(Array.isArray(names) && new Set(names).size === names.length, "Invalid installer receipt context");
1171
- assert2(entry && entry.platform === platform && entry.schema === 2 && entry.installed === true && entry.launched === true && entry.rendererReady === true && ["tag", "sourceSha", "workflowSha", "runId", "runAttempt"].every((key) => entry[key] === identity[key]), "Installer identity mismatch");
1315
+ assert3(Array.isArray(names) && new Set(names).size === names.length, "Invalid installer receipt context");
1316
+ assert3(entry && entry.platform === platform && entry.schema === 2 && entry.installed === true && entry.launched === true && entry.rendererReady === true && ["tag", "sourceSha", "workflowSha", "runId", "runAttempt"].every((key) => entry[key] === identity[key]), "Installer identity mismatch");
1172
1317
  checkRenderer(entry.rendererEvidence, offlinePolicy);
1173
- assert2(Array.isArray(entry.assets) && names.length > 0 && entry.assets.length === names.length, "Incorrect installer asset count");
1318
+ assert3(Array.isArray(entry.assets) && names.length > 0 && entry.assets.length === names.length, "Incorrect installer asset count");
1174
1319
  for (const name of names)
1175
- assert2(matches(uniqueAsset(entry.assets, name), uniqueAsset(assets, name)), `Installer asset mismatch: ${name}`);
1320
+ assert3(matches(uniqueAsset(entry.assets, name), uniqueAsset(assets, name)), `Installer asset mismatch: ${name}`);
1176
1321
  return true;
1177
1322
  }
1178
1323
  function assertIdentity(identity, platform) {
1179
- assert2(/^v\d+\.\d+\.\d+$/.test(identity.tag) && isGitSha(identity.sourceSha) && isGitSha(identity.workflowSha) && /^[1-9]\d{0,19}$/.test(identity.runId) && Number.isSafeInteger(identity.runAttempt) && identity.runAttempt > 0 && /^[a-z0-9-]+$/.test(platform), "Invalid receipt context");
1324
+ assert3(/^v\d+\.\d+\.\d+$/.test(identity.tag) && isGitSha(identity.sourceSha) && isGitSha(identity.workflowSha) && /^[1-9]\d{0,19}$/.test(identity.runId) && Number.isSafeInteger(identity.runAttempt) && identity.runAttempt > 0 && /^[a-z0-9-]+$/.test(platform), "Invalid receipt context");
1180
1325
  }
1181
1326
  function validateCommandReceipt(identity, entry, kind, platform, name, assets) {
1182
1327
  assertIdentity(identity, platform);
1183
- assert2(entry && entry.schema === 1 && entry.kind === kind && entry.platform === platform && entry.installed === true && entry.versionMatched === true && entry.probesPassed === true && entry.serviceStarted === true && entry.serviceStopped === (platform === "windows-x64" ? "process-tree" : "sigterm") && Object.keys(entry).length === 14 && ["tag", "sourceSha", "workflowSha", "runId", "runAttempt"].every((key) => entry[key] === identity[key]), "Command artifact receipt mismatch");
1184
- assert2(matches(entry.asset, uniqueAsset(assets, name)), `Command artifact asset mismatch: ${name}`);
1328
+ assert3(entry && entry.schema === 1 && entry.kind === kind && entry.platform === platform && entry.installed === true && entry.versionMatched === true && entry.probesPassed === true && entry.serviceStarted === true && entry.serviceStopped === (platform === "windows-x64" ? "process-tree" : "sigterm") && Object.keys(entry).length === 14 && ["tag", "sourceSha", "workflowSha", "runId", "runAttempt"].every((key) => entry[key] === identity[key]), "Command artifact receipt mismatch");
1329
+ assert3(matches(entry.asset, uniqueAsset(assets, name)), `Command artifact asset mismatch: ${name}`);
1185
1330
  return true;
1186
1331
  }
1187
1332
  function validateCommandReceipts(identity, receipts, requirements, assets) {
1188
1333
  const required = Object.entries(requirements.commandArtifacts ?? {}).flatMap(([kind, byPlatform]) => Object.entries(byPlatform).map(([platform, name]) => ({ kind, platform, name })));
1189
1334
  if (!required.length) {
1190
- assert2(receipts === undefined, "Unexpected command artifact receipts");
1335
+ assert3(receipts === undefined, "Unexpected command artifact receipts");
1191
1336
  return;
1192
1337
  }
1193
- assert2(Array.isArray(receipts) && receipts.length === required.length, "Missing or duplicate command artifact receipts");
1338
+ assert3(Array.isArray(receipts) && receipts.length === required.length, "Missing or duplicate command artifact receipts");
1194
1339
  for (const { kind, platform, name } of required) {
1195
1340
  const entries = receipts.filter((entry) => entry?.kind === kind && entry.platform === platform);
1196
- assert2(entries.length === 1, `Missing or duplicate command artifact receipt: ${kind}`);
1341
+ assert3(entries.length === 1, `Missing or duplicate command artifact receipt: ${kind}`);
1197
1342
  validateCommandReceipt(identity, entries[0], kind, platform, name, assets);
1198
1343
  }
1199
1344
  }
1200
1345
  function validateReleaseQualification(release, receipt, sourceSha, requirements) {
1201
1346
  const required = expectedAssets(requirements);
1202
1347
  const platforms = Object.keys(requirements.platforms);
1203
- assert2(release.draft === false && receipt.schema === 2 && receipt.tag === release.tag_name && receipt.sourceSha === sourceSha && isGitSha(sourceSha) && isGitSha(receipt.workflowSha) && /^[1-9]\d*$/.test(receipt.runId) && Number.isSafeInteger(receipt.runAttempt) && receipt.runAttempt > 0, "Qualification identity mismatch");
1204
- assert2(receipt.platforms.length === platforms.length && receipt.installerTests.length === platforms.length && receipt.installerReceipts.length === platforms.length && platforms.every((platform) => receipt.platforms.filter((x) => x === platform).length === 1 && receipt.installerTests.filter((x) => x === platform).length === 1), "Missing or duplicate platform tests");
1348
+ assert3(release.draft === false && receipt.schema === 2 && receipt.tag === release.tag_name && receipt.sourceSha === sourceSha && isGitSha(sourceSha) && isGitSha(receipt.workflowSha) && /^[1-9]\d*$/.test(receipt.runId) && Number.isSafeInteger(receipt.runAttempt) && receipt.runAttempt > 0, "Qualification identity mismatch");
1349
+ assert3(receipt.platforms.length === platforms.length && receipt.installerTests.length === platforms.length && receipt.installerReceipts.length === platforms.length && platforms.every((platform) => receipt.platforms.filter((x) => x === platform).length === 1 && receipt.installerTests.filter((x) => x === platform).length === 1), "Missing or duplicate platform tests");
1205
1350
  for (const platform of platforms) {
1206
1351
  const entries = receipt.installerReceipts.filter((entry) => entry.platform === platform);
1207
- assert2(entries.length === 1, `Missing or duplicate installer receipt: ${platform}`);
1352
+ assert3(entries.length === 1, `Missing or duplicate installer receipt: ${platform}`);
1208
1353
  validateInstallerReceipt(receipt, entries[0], platform, requirements.platforms[platform], release.assets, requirements.offlinePolicy);
1209
1354
  }
1210
1355
  validateCommandReceipts(receipt, receipt.commandReceipts, requirements, release.assets);
1211
- assert2(receipt.assets.length === required.length, "Incorrect qualification asset count");
1356
+ assert3(receipt.assets.length === required.length, "Incorrect qualification asset count");
1212
1357
  for (const name of required)
1213
- assert2(matches(uniqueAsset(receipt.assets, name), uniqueAsset(release.assets, name)), `Qualification asset mismatch: ${name}`);
1358
+ assert3(matches(uniqueAsset(receipt.assets, name), uniqueAsset(release.assets, name)), `Qualification asset mismatch: ${name}`);
1214
1359
  return true;
1215
1360
  }
1216
1361
  function validateQualificationRun(run, jobs, receipt, repository, requirements, assetsWorkflow) {
1217
1362
  expectedAssets(requirements);
1218
- assert2(String(run.id) === receipt.runId && run.run_attempt === receipt.runAttempt && run.conclusion === "success" && run.path === assetsWorkflow && run.repository.full_name === repository && run.head_sha === receipt.workflowSha && ["release", "workflow_dispatch"].includes(run.event), "Qualification run identity mismatch");
1363
+ assert3(String(run.id) === receipt.runId && run.run_attempt === receipt.runAttempt && run.conclusion === "success" && run.path === assetsWorkflow && run.repository.full_name === repository && run.head_sha === receipt.workflowSha && ["release", "workflow_dispatch"].includes(run.event), "Qualification run identity mismatch");
1219
1364
  for (const platform of Object.keys(requirements.platforms)) {
1220
1365
  const platformJobs = jobs.filter((job) => new RegExp(`^(?:[A-Za-z0-9_-]+ / )?Installer / ${platform}$`).test(job.name));
1221
- assert2(platformJobs.length === 1 && platformJobs[0].conclusion === "success", `Missing successful installer job: ${platform}`);
1366
+ assert3(platformJobs.length === 1 && platformJobs[0].conclusion === "success", `Missing successful installer job: ${platform}`);
1222
1367
  }
1223
1368
  return true;
1224
1369
  }
@@ -1881,7 +2026,7 @@ import { join as join3, resolve } from "path";
1881
2026
  // ../../src/installer/command-artifact.ts
1882
2027
  import { lstat as lstat2, mkdir as mkdir2, mkdtemp as mkdtemp2, readFile as readFile3, readdir as readdir4, rm as rm2 } from "fs/promises";
1883
2028
  import { tmpdir } from "os";
1884
- import { basename, join as join2, relative as relative2, sep } from "path";
2029
+ import { basename, join as join2, relative as relative3, sep } from "path";
1885
2030
  import { c as create, t as list, x as extract } from "tar";
1886
2031
 
1887
2032
  // ../../src/installer/archive-entry.ts
@@ -1996,7 +2141,7 @@ async function collect(root, directory, entries) {
1996
2141
  for (const child of children) {
1997
2142
  const path = join2(directory, child.name);
1998
2143
  const info = await lstat2(path);
1999
- const name = relative2(root, path).split(sep).join("/");
2144
+ const name = relative3(root, path).split(sep).join("/");
2000
2145
  if (info.isDirectory()) {
2001
2146
  entries.push(name);
2002
2147
  await collect(root, path, entries);
@@ -2778,7 +2923,7 @@ function readPackageFile(bytes, path) {
2778
2923
  }
2779
2924
 
2780
2925
  // src/framework-package-publish.ts
2781
- var packageName = "@adea-ai/app-framework";
2926
+ var packageName2 = "@adea-ai/app-framework";
2782
2927
  var registryUrl = "https://registry.npmjs.org/";
2783
2928
  var VISIBILITY_SLEEPS = 32;
2784
2929
  var FIRST_VISIBILITY_DELAY_MS = 5000;
@@ -2848,12 +2993,12 @@ function publishProgram(options) {
2848
2993
  const manifest = yield* step(async () => JSON.parse(await fs.readFile("package.json", "utf8")));
2849
2994
  const version = provenance.releasedVersion;
2850
2995
  const archive = resolve4(options.archive);
2851
- if (provenance.repository !== "adea-ai/app-framework" || manifest.name !== packageName || manifest.version !== version || basename2(archive) !== `adea-ai-app-framework-${version}.tgz`)
2996
+ if (provenance.repository !== "adea-ai/app-framework" || manifest.name !== packageName2 || manifest.version !== version || basename2(archive) !== `adea-ai-app-framework-${version}.tgz`)
2852
2997
  return yield* refused("source-mismatch");
2853
2998
  const { bytes, integrity } = yield* archiveIntegrity(fs, archive);
2854
2999
  const packed = yield* step(async () => readPackageFile(bytes, "package/package.json"));
2855
3000
  const source = yield* step(async () => readPackageFile(bytes, "package/dist/framework-source.json"));
2856
- if (packed.name !== packageName || packed.version !== version || source.version !== version || source.commit !== sha)
3001
+ if (packed.name !== packageName2 || packed.version !== version || source.version !== version || source.commit !== sha)
2857
3002
  return yield* refused("not-from-checkout");
2858
3003
  const existing = yield* step(() => registry(version));
2859
3004
  if (existing !== null) {
@@ -4319,7 +4464,7 @@ import { Effect as Effect22 } from "effect";
4319
4464
  // ../../src/installer/installer-archive-members.ts
4320
4465
  import { createHash as createHash10 } from "crypto";
4321
4466
  import { lstat as lstat6, open as open5 } from "fs/promises";
4322
- import { isAbsolute as isAbsolute3, relative as relative3, sep as sep2 } from "path";
4467
+ import { isAbsolute as isAbsolute3, relative as relative4, sep as sep2 } from "path";
4323
4468
 
4324
4469
  // ../../src/installer/native-executable.ts
4325
4470
  async function assertNativeExecutable(file, size, platform, what) {
@@ -4342,7 +4487,7 @@ async function assertNativeExecutable(file, size, platform, what) {
4342
4487
  // ../../src/installer/installer-archive-members.ts
4343
4488
  var EMBEDDED_ARCHIVE_MARKER = Buffer.from("ELECTROBUN_ARCHIVE_V1");
4344
4489
  function isWithin(root, path) {
4345
- const rel = relative3(root, path);
4490
+ const rel = relative4(root, path);
4346
4491
  return rel !== "" && rel !== ".." && !rel.startsWith(".." + sep2) && !isAbsolute3(rel);
4347
4492
  }
4348
4493
  function normalizeArchiveMember(name) {
@@ -4957,7 +5102,7 @@ import { delimiter, dirname as dirname12, join as join27 } from "path";
4957
5102
  // ../../src/installer/installer-ci-bootstrap.ts
4958
5103
  import { randomBytes } from "crypto";
4959
5104
  import { lstat as lstat9, mkdir as mkdir5, mkdtemp as mkdtemp5, realpath as realpath2, rm as rm5, writeFile as writeFile4 } from "fs/promises";
4960
- import { dirname as dirname4, isAbsolute as isAbsolute4, join as join14, relative as relative4, sep as sep3 } from "path";
5105
+ import { dirname as dirname4, isAbsolute as isAbsolute4, join as join14, relative as relative5, sep as sep3 } from "path";
4961
5106
  import { fileURLToPath } from "url";
4962
5107
  var bootstrapModules = [
4963
5108
  "app/value-guards.js",
@@ -4969,6 +5114,7 @@ var bootstrapModules = [
4969
5114
  "installer/hosted-runner.js",
4970
5115
  "release/release-qualification.js",
4971
5116
  "updates/feed/release-config-contract.js",
5117
+ "updates/feed/arch-package-policy.js",
4972
5118
  "updates/feed/release-feed.js",
4973
5119
  "native/app-bundle.js",
4974
5120
  "desktop/string-policy.js",
@@ -5013,7 +5159,7 @@ async function preflightInstallerRuntime(options) {
5013
5159
  if (!isHostedRunner(env) || !temp || !isAbsolute4(runtime))
5014
5160
  throw new Error("Runtime preflight requires a disposable hosted runner");
5015
5161
  const tempRoot = await realpath2(temp), bootstrapRoot = await realpath2(bootstrap.directory);
5016
- const relativeBootstrap = relative4(tempRoot, bootstrapRoot);
5162
+ const relativeBootstrap = relative5(tempRoot, bootstrapRoot);
5017
5163
  if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep3) || isAbsolute4(relativeBootstrap) || /\s/.test(bootstrapRoot) || bootstrap.worker !== join14(bootstrapRoot, "installer/installer-ci-worker.js") || bootstrap.preflight !== join14(bootstrapRoot, "installer/installer-ci-preflight.js") || bootstrap.bunOptions !== `--preload=${bootstrap.worker}`)
5018
5164
  throw new Error("Invalid installer bootstrap location");
5019
5165
  await runInstallerPreflight({
@@ -7890,32 +8036,432 @@ var provideLivePorts = (program) => program.pipe(Effect23.provideService(Release
7890
8036
  codesign: codesignRun
7891
8037
  }));
7892
8038
 
8039
+ // src/library/arch-publish.ts
8040
+ import { createHash as createHash16 } from "crypto";
8041
+ import { join as join32 } from "path";
8042
+ import { tmpdir as tmpdir5 } from "os";
8043
+ import { Effect as Effect24 } from "effect";
8044
+
8045
+ // ../../src/release/arch-package.ts
8046
+ function archPkgver(tag) {
8047
+ if (!/^v\d+\.\d+\.\d+$/.test(tag))
8048
+ throw new Error("Invalid Arch package release tag");
8049
+ return tag.slice(1);
8050
+ }
8051
+ function archBundle(appName) {
8052
+ assertPortableAppName(appName);
8053
+ return appName.replaceAll(" ", "");
8054
+ }
8055
+ function shell(value) {
8056
+ if (/[\r\n]/.test(value))
8057
+ throw new Error("Arch package value spans lines");
8058
+ return `'${value.replaceAll("'", "'\\''")}'`;
8059
+ }
8060
+ function array(name, values) {
8061
+ if (!values.length)
8062
+ return "";
8063
+ const lines = values.map((value) => ` ${shell(value)}`).join(`
8064
+ `);
8065
+ return `${name}=(
8066
+ ${lines}
8067
+ )`;
8068
+ }
8069
+ function desktopEntry(input, bundle) {
8070
+ const { policy } = input;
8071
+ return [
8072
+ "[Desktop Entry]",
8073
+ "Type=Application",
8074
+ `Name=${policy.desktop.name}`,
8075
+ ...policy.desktop.comment ? [`Comment=${policy.desktop.comment}`] : [],
8076
+ `Exec=/opt/${policy.pkgname}/bin/launcher %U`,
8077
+ `Icon=${policy.executable}`,
8078
+ "Terminal=false",
8079
+ `StartupWMClass=${bundle}`,
8080
+ `Categories=${policy.desktop.categories.map((value) => `${value};`).join("")}`,
8081
+ ""
8082
+ ].join(`
8083
+ `);
8084
+ }
8085
+ function packageBody(input, bundle) {
8086
+ const { policy } = input;
8087
+ const lines = [
8088
+ "package() {",
8089
+ ` install -d "$pkgdir/opt/${policy.pkgname}"`,
8090
+ ` cp -a --no-preserve=ownership "$srcdir/${bundle}/." "$pkgdir/opt/${policy.pkgname}/"`,
8091
+ ` chmod -R u=rwX,go=rX "$pkgdir/opt/${policy.pkgname}"`,
8092
+ ...policy.setuid.map((path) => ` chmod 4755 "$pkgdir/opt/${policy.pkgname}/${path}"`),
8093
+ "",
8094
+ ' install -d "$pkgdir/usr/bin"',
8095
+ ` ln -s "/opt/${policy.pkgname}/bin/launcher" "$pkgdir/usr/bin/${policy.executable}"`,
8096
+ ...policy.links.map((link) => ` ln -s "/opt/${policy.pkgname}/${link.target}" "$pkgdir/usr/bin/${link.name}"`),
8097
+ "",
8098
+ ` install -Dm644 /dev/stdin "$pkgdir/usr/share/applications/${policy.pkgname}.desktop" <<'EOF'`,
8099
+ desktopEntry(input, bundle).trimEnd(),
8100
+ "EOF"
8101
+ ];
8102
+ if (policy.icon)
8103
+ lines.push("", ` install -Dm644 "$srcdir/${bundle}/${policy.icon}" \\`, ` "$pkgdir/usr/share/icons/hicolor/scalable/apps/${policy.executable}.svg"`);
8104
+ if (input.license)
8105
+ lines.push("", ` install -Dm644 "$srcdir/LICENSE" "$pkgdir/usr/share/licenses/${policy.pkgname}/LICENSE"`);
8106
+ lines.push("}", "");
8107
+ return lines.join(`
8108
+ `);
8109
+ }
8110
+ function sources(input) {
8111
+ const entries = [
8112
+ ...input.license ? [`LICENSE::${input.license.url}`] : [],
8113
+ `${input.assetName}::${input.assetUrl}`
8114
+ ];
8115
+ const sums = [...input.license ? [input.license.sha256] : [], input.assetSha256];
8116
+ return { entries, sums };
8117
+ }
8118
+ function renderArchPackage(input) {
8119
+ const { policy } = input;
8120
+ const pkgver = archPkgver(input.tag);
8121
+ if (!Number.isSafeInteger(input.pkgrel) || input.pkgrel < 1 || input.pkgrel > 999)
8122
+ throw new Error("Invalid Arch package release");
8123
+ const bundle = archBundle(input.appName);
8124
+ const { entries, sums } = sources(input);
8125
+ const metadata = [
8126
+ `pkgname=${policy.pkgname}`,
8127
+ `pkgver=${pkgver}`,
8128
+ `pkgrel=${input.pkgrel}`,
8129
+ `pkgdesc=${shell(policy.pkgdesc)}`,
8130
+ "arch=('x86_64')",
8131
+ `url=${shell(policy.url)}`,
8132
+ array("license", policy.license),
8133
+ array("depends", policy.depends),
8134
+ array("optdepends", policy.optdepends),
8135
+ array("provides", policy.provides),
8136
+ array("conflicts", policy.conflicts),
8137
+ "options=('!strip' '!debug')",
8138
+ array("source", entries),
8139
+ array("sha256sums", sums)
8140
+ ].filter(Boolean).join(`
8141
+ `);
8142
+ const pkgbuild = `${[`# Maintainer: ${policy.maintainer}`, metadata, packageBody(input, bundle).trimEnd()].join(`
8143
+
8144
+ `)}
8145
+ `;
8146
+ const srcinfo = [
8147
+ `pkgbase = ${policy.pkgname}`,
8148
+ ` pkgdesc = ${policy.pkgdesc}`,
8149
+ ` pkgver = ${pkgver}`,
8150
+ ` pkgrel = ${input.pkgrel}`,
8151
+ ` url = ${policy.url}`,
8152
+ "\tarch = x86_64",
8153
+ ...policy.license.map((value) => ` license = ${value}`),
8154
+ ...policy.depends.map((value) => ` depends = ${value}`),
8155
+ ...policy.optdepends.map((value) => ` optdepends = ${value}`),
8156
+ ...policy.provides.map((value) => ` provides = ${value}`),
8157
+ ...policy.conflicts.map((value) => ` conflicts = ${value}`),
8158
+ "\toptions = !strip",
8159
+ "\toptions = !debug",
8160
+ ...entries.map((value) => ` source = ${value}`),
8161
+ ...sums.map((value) => ` sha256sums = ${value}`),
8162
+ "",
8163
+ `pkgname = ${policy.pkgname}`,
8164
+ ""
8165
+ ].join(`
8166
+ `);
8167
+ return { pkgver, bundle, files: { PKGBUILD: pkgbuild, ".SRCINFO": srcinfo } };
8168
+ }
8169
+ function renderPacmanRepository(policy) {
8170
+ const { repository } = policy;
8171
+ if (!repository)
8172
+ return {};
8173
+ const stanza = [
8174
+ `[${repository.name}]`,
8175
+ "SigLevel = Required DatabaseOptional",
8176
+ `Server = ${repository.base}$arch`,
8177
+ ""
8178
+ ].join(`
8179
+ `);
8180
+ const bootstrap = `#!/bin/sh
8181
+ # Install ${policy.desktop.name} from the ${repository.name} pacman repository.
8182
+ #
8183
+ # curl -fsSL ${repository.base}install.sh | sudo sh
8184
+ # curl -fsSL ${repository.base}install.sh | sudo sh -s -- <package>...
8185
+ set -eu
8186
+
8187
+ repo=${shell(repository.name)}
8188
+ package=${shell(policy.pkgname)}
8189
+ server=${shell(repository.base)}
8190
+ key_url=${shell(repository.publicKey)}
8191
+
8192
+ if [ "$(id -u)" -ne 0 ]; then
8193
+ echo "Run this script as root, for example: curl -fsSL ${repository.base}install.sh | sudo sh" >&2
8194
+ exit 1
8195
+ fi
8196
+ for tool in curl pacman-key pacman grep; do
8197
+ command -v "$tool" >/dev/null || { echo "Missing $tool" >&2; exit 1; }
8198
+ done
8199
+ # A fresh container or a minimal install may have no local keyring; lsign needs one.
8200
+ [ -s /etc/pacman.d/gnupg/pubring.gpg ] || pacman-key --init >/dev/null
8201
+ tmp=$(mktemp)
8202
+ trap 'rm -f "$tmp"' EXIT
8203
+ curl -fsSL "$key_url" -o "$tmp"
8204
+ pacman-key --add "$tmp" >/dev/null
8205
+ # The key's own fingerprint, so the script trusts exactly the key it just imported.
8206
+ fingerprint=$(gpg --batch --show-keys --with-colons "$tmp" 2>/dev/null |
8207
+ awk -F: '/^fpr:/{print $10; exit}')
8208
+ [ -n "$fingerprint" ] || { echo "Could not read the signing key at $key_url" >&2; exit 1; }
8209
+ # Trust the key locally. It is the only key this repository's packages are signed with.
8210
+ pacman-key --lsign-key "$fingerprint" >/dev/null
8211
+ if ! grep -q "^\\[$repo\\]" /etc/pacman.conf; then
8212
+ printf '\\n[%s]\\nSigLevel = Required DatabaseOptional\\nServer = %s$arch\\n' "$repo" "$server" >> /etc/pacman.conf
8213
+ fi
8214
+ pacman -Sy --noconfirm >/dev/null
8215
+ if [ "$#" -eq 0 ]; then set -- "$package"; fi
8216
+ exec pacman -S --needed --noconfirm "$@"
8217
+ `;
8218
+ return { "install.sh": bootstrap, "pacman.conf": stanza };
8219
+ }
8220
+
8221
+ // src/library/arch-publish.ts
8222
+ var AUR_HOST_KEY = "aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN";
8223
+ var MAX_LICENSE_BYTES = 1024 * 1024;
8224
+ var feedBytes = (feed, path, maximum) => Effect24.gen(function* () {
8225
+ const { fetch: fetch2 } = yield* ReleaseFetch;
8226
+ const scope = feedUrl(feed);
8227
+ const response = yield* step(() => fetchReleaseLocation(`${scope}${path}`, scope, fetch2, AbortSignal.timeout(30000)));
8228
+ if (response.status === 404) {
8229
+ yield* step(async () => discardStream(response.body));
8230
+ return null;
8231
+ }
8232
+ return yield* step(() => readReleaseBytes(response, maximum));
8233
+ });
8234
+ var feedJson = (feed, path, maximum) => Effect24.gen(function* () {
8235
+ const bytes = yield* feedBytes(feed, path, maximum);
8236
+ if (!bytes)
8237
+ return null;
8238
+ return yield* step(async () => {
8239
+ try {
8240
+ return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
8241
+ } catch {
8242
+ throw new Error("Invalid release feed response");
8243
+ }
8244
+ });
8245
+ });
8246
+ var readChannelTag = (feed, channel) => Effect24.gen(function* () {
8247
+ const parsed = yield* feedJson(feed, `channels/${channel}.json`, 262144);
8248
+ if (parsed === null)
8249
+ return null;
8250
+ return yield* step(async () => parseFeedRelease(parsed).tag);
8251
+ });
8252
+ var readLicense = (url) => Effect24.gen(function* () {
8253
+ const { fetch: fetch2 } = yield* ReleaseFetch;
8254
+ const response = yield* step(() => fetch2(url, { redirect: "follow", signal: AbortSignal.timeout(30000) }));
8255
+ if (response.status !== 200 || !response.body) {
8256
+ yield* step(async () => discardStream(response.body));
8257
+ return yield* fail("Release license is unavailable");
8258
+ }
8259
+ const bytes = yield* step(() => readReleaseBytes(response, MAX_LICENSE_BYTES));
8260
+ const sha256 = yield* step(async () => createHash16("sha256").update(bytes).digest("hex"));
8261
+ return { url, sha256 };
8262
+ });
8263
+ var git2 = (args) => Effect24.gen(function* () {
8264
+ const { run } = yield* ReleaseGit;
8265
+ return yield* Effect24.tryPromise({
8266
+ try: () => run(args),
8267
+ catch: (error) => {
8268
+ const stderr = String(error.stderr ?? "").trim().split(`
8269
+ `).slice(-3).join(" ");
8270
+ return new ReleaseFailure({
8271
+ reason: "git-failed",
8272
+ message: `git ${args.find((value) => !value.startsWith("-")) ?? ""} failed${stderr ? `: ${stderr}` : ""}`,
8273
+ original: error
8274
+ });
8275
+ }
8276
+ });
8277
+ });
8278
+ var gitExit = (args) => Effect24.gen(function* () {
8279
+ const { run } = yield* ReleaseGit;
8280
+ return yield* Effect24.promise(() => run(args).then(() => 0, (error) => Number(error.code ?? 1) || 1));
8281
+ });
8282
+ var verifyArchRelease = (options) => Effect24.gen(function* () {
8283
+ const parsed = parseReleaseConfig(options.config);
8284
+ const { config } = options;
8285
+ const repository = typeof config.repository === "string" && isRepositorySlug(config.repository) ? config.repository : null;
8286
+ if (!repository)
8287
+ return yield* fail("release-config.json has no repository to verify the signed descriptor");
8288
+ const ledger = yield* readFeedLedgerEffect(options.feed);
8289
+ const entry = ledger.releases.find((item) => item.tag === options.tag);
8290
+ if (!entry || entry.kind !== options.channel)
8291
+ return yield* fail(`Release ${options.tag} is not a ${options.channel} release in the ledger`);
8292
+ const archive = parsed.requirements(options.tag).platforms["linux-x64"]?.[1];
8293
+ if (!archive)
8294
+ return yield* fail("Arch packaging requires the linux-x64 desktop archive to be configured");
8295
+ const descriptorPolicy = discoveryPolicies(config, options.tag).find((candidate) => candidate.channel === options.channel && candidate.platform === "linux-x64" && candidate.payload === archive);
8296
+ if (!descriptorPolicy)
8297
+ return yield* fail("Release has no signed Linux descriptor");
8298
+ const listed = options.release.assets.find((item) => item.name === descriptorPolicy.name);
8299
+ if (!listed)
8300
+ return yield* fail(`Missing signed descriptor: ${descriptorPolicy.name}`);
8301
+ const bytes = yield* feedBytes(options.feed, `${options.tag}/${descriptorPolicy.name}`, 65536);
8302
+ if (!bytes || bytes.length !== listed.size || createHash16("sha256").update(bytes).digest("hex") !== listed.sha256)
8303
+ return yield* fail(`Signed descriptor differs from its release: ${descriptorPolicy.name}`);
8304
+ const json = yield* step(async () => {
8305
+ try {
8306
+ return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
8307
+ } catch {
8308
+ throw new Error("Signed descriptor is not JSON");
8309
+ }
8310
+ });
8311
+ const verified = verifyReleaseDescriptor(json, {
8312
+ appId: descriptorPolicy.appId,
8313
+ repository,
8314
+ channel: descriptorPolicy.channel,
8315
+ platform: descriptorPolicy.os,
8316
+ arch: descriptorPolicy.arch,
8317
+ feed: feedUrl(options.feed),
8318
+ keys: releaseVerificationKeys(config)
8319
+ });
8320
+ if (!verified.ok)
8321
+ return yield* fail("Untrusted signed descriptor");
8322
+ const descriptor = verified.descriptor;
8323
+ if (descriptor.tag !== options.tag || descriptor.sourceSha !== entry.sourceSha)
8324
+ return yield* fail("Signed descriptor names another release");
8325
+ const payload = options.release.assets.find((item) => item.name === descriptorPolicy.payload);
8326
+ if (!payload)
8327
+ return yield* fail("Signed descriptor names a missing archive");
8328
+ if (descriptor.asset.name !== payload.name || descriptor.asset.size !== payload.size || descriptor.asset.sha256 !== payload.sha256)
8329
+ return yield* fail("Signed descriptor does not bind the published archive");
8330
+ return descriptor.asset;
8331
+ });
8332
+ var publishArchPackageEffect = (options) => Effect24.gen(function* () {
8333
+ const { archPackage: policy, feed } = parseReleaseConfig(options.config);
8334
+ if (!policy)
8335
+ return { status: "not-configured" };
8336
+ if (!/^v\d+\.\d+\.\d+$/.test(options.tag))
8337
+ return yield* fail("Invalid Arch package release tag");
8338
+ const release = yield* readFeedReleaseEffect(feed, options.tag);
8339
+ if (!release)
8340
+ return yield* fail(`Release ${options.tag} is not published on the feed`);
8341
+ const channelTag = yield* readChannelTag(feed, policy.channel);
8342
+ if (channelTag !== options.tag)
8343
+ return {
8344
+ status: "not-current",
8345
+ channel: policy.channel,
8346
+ channelTag
8347
+ };
8348
+ const asset = yield* verifyArchRelease({
8349
+ config: options.config,
8350
+ feed,
8351
+ tag: options.tag,
8352
+ release,
8353
+ channel: policy.channel
8354
+ });
8355
+ const license = policy.licenseSource ? yield* readLicense(policy.licenseSource.replaceAll("{tag}", options.tag)) : undefined;
8356
+ const pkgrel = options.pkgrel ?? 1;
8357
+ const rendered = renderArchPackage({
8358
+ appName: options.appName,
8359
+ tag: options.tag,
8360
+ pkgrel,
8361
+ policy,
8362
+ assetName: asset.name,
8363
+ assetUrl: asset.url,
8364
+ assetSha256: asset.sha256,
8365
+ ...license ? { license } : {}
8366
+ });
8367
+ const files = rendered.files;
8368
+ const repositoryFiles = renderPacmanRepository(policy);
8369
+ const fs = yield* ReleaseFs;
8370
+ if (options.printDirectory) {
8371
+ const directory = options.printDirectory;
8372
+ yield* step(() => fs.mkdir(directory, { recursive: true }));
8373
+ for (const [name, contents] of Object.entries({ ...files, ...repositoryFiles }))
8374
+ yield* step(() => fs.writeFile(join32(directory, name), contents, { mode: 420 }));
8375
+ }
8376
+ const base = { pkgname: policy.pkgname, pkgver: rendered.pkgver, pkgrel };
8377
+ if (options.dryRun)
8378
+ return { status: "dry-run", ...base, files: { ...files, ...repositoryFiles } };
8379
+ const { env } = yield* ReleaseConfig;
8380
+ const encodedKey = env.AUR_SSH_PRIVATE_KEY_B64;
8381
+ if (!encodedKey)
8382
+ return yield* fail("AUR_SSH_PRIVATE_KEY_B64 is not set");
8383
+ const key = Buffer.from(encodedKey, "base64").toString("utf8");
8384
+ if (!key.includes("PRIVATE KEY"))
8385
+ return yield* fail("AUR_SSH_PRIVATE_KEY_B64 is not a private key");
8386
+ return yield* Effect24.gen(function* () {
8387
+ const work = yield* step(() => fs.mkdtemp(join32(tmpdir5(), "arch-package-")));
8388
+ yield* Effect24.addFinalizer(() => Effect24.promise(() => fs.rm(work, { recursive: true, force: true }).then(() => {
8389
+ return;
8390
+ }, () => {
8391
+ return;
8392
+ })));
8393
+ const keyFile = join32(work, "aur_id_ed25519");
8394
+ const knownHosts = join32(work, "aur_known_hosts");
8395
+ yield* step(() => fs.mkdir(work, { recursive: true, mode: 448 }));
8396
+ yield* step(() => fs.writeFile(keyFile, key.endsWith(`
8397
+ `) ? key : `${key}
8398
+ `, { mode: 384 }));
8399
+ yield* step(() => fs.writeFile(knownHosts, `${AUR_HOST_KEY}
8400
+ `, { mode: 420 }));
8401
+ const ssh = `ssh -i "${keyFile}" -o IdentitiesOnly=yes -o UserKnownHostsFile="${knownHosts}" -o StrictHostKeyChecking=yes`;
8402
+ const checkout = join32(work, policy.pkgname);
8403
+ yield* git2([
8404
+ "-c",
8405
+ `core.sshCommand=${ssh}`,
8406
+ "-c",
8407
+ "init.defaultBranch=master",
8408
+ "clone",
8409
+ "--depth",
8410
+ "1",
8411
+ `ssh://aur@aur.archlinux.org/${policy.pkgname}.git`,
8412
+ checkout
8413
+ ]);
8414
+ for (const [name, contents] of Object.entries(files))
8415
+ yield* step(() => fs.writeFile(join32(checkout, name), contents, { mode: 420 }));
8416
+ yield* git2(["-C", checkout, "add", "--", ...Object.keys(files)]);
8417
+ const staged = yield* gitExit(["-C", checkout, "diff", "--cached", "--quiet"]);
8418
+ if (staged === 0)
8419
+ return { status: "unchanged", ...base };
8420
+ if (staged !== 1)
8421
+ return yield* fail("Comparing the AUR package failed");
8422
+ const host = new URL(policy.url).hostname;
8423
+ yield* git2([
8424
+ "-C",
8425
+ checkout,
8426
+ "-c",
8427
+ `user.name=${options.appName} Release`,
8428
+ "-c",
8429
+ `user.email=release@${host}`,
8430
+ "commit",
8431
+ "-m",
8432
+ `${policy.pkgname}: update to ${rendered.pkgver}-${pkgrel}`
8433
+ ]);
8434
+ yield* git2(["-C", checkout, "-c", `core.sshCommand=${ssh}`, "push", "origin", "HEAD:master"]);
8435
+ return { status: "published", ...base };
8436
+ }).pipe(Effect24.scoped);
8437
+ });
8438
+
7893
8439
  // src/cli-commands.ts
7894
- var print = (value) => Effect24.gen(function* () {
8440
+ var print = (value) => Effect25.gen(function* () {
7895
8441
  const { stdout } = yield* ReleaseOutput;
7896
8442
  stdout(JSON.stringify(value) + `
7897
8443
  `);
7898
8444
  });
7899
- var say = (line) => Effect24.gen(function* () {
8445
+ var say = (line) => Effect25.gen(function* () {
7900
8446
  const { stdout } = yield* ReleaseOutput;
7901
8447
  stdout(line + `
7902
8448
  `);
7903
8449
  });
7904
8450
  var invalid = (message = "Invalid workflow invocation") => refuse("usage", message);
7905
8451
  var localFlag = (args) => args[0] === "--local" ? [true, args.slice(1)] : [false, args];
7906
- var hostPlatform = Effect24.gen(function* () {
8452
+ var hostPlatform = Effect25.gen(function* () {
7907
8453
  const { platform, arch } = yield* ReleaseConfig;
7908
8454
  return yield* step(async () => hostReleasePlatform(platform, arch));
7909
8455
  });
7910
- var withPlanGitHub = (env, effect) => Effect24.gen(function* () {
8456
+ var withPlanGitHub = (env, effect) => Effect25.gen(function* () {
7911
8457
  const github = yield* ReleaseGitHub;
7912
- return yield* effect.pipe(Effect24.provideService(ReleaseGitHub, {
8458
+ return yield* effect.pipe(Effect25.provideService(ReleaseGitHub, {
7913
8459
  run: github.withEnvironment ? github.withEnvironment(releasePlanGitHubEnvironment(env)) : github.run
7914
8460
  }));
7915
8461
  });
7916
8462
  var publish = (argv) => {
7917
8463
  const [local, args] = localFlag(argv);
7918
- return runCommand("Unable to publish release artifacts; check the trusted workflow or local checkout, receipts, signing configuration and staged bytes.", Effect24.gen(function* () {
8464
+ return runCommand("Unable to publish release artifacts; check the trusted workflow or local checkout, receipts, signing configuration and staged bytes.", Effect25.gen(function* () {
7919
8465
  const [directory, configPath, out, ...extra] = args;
7920
8466
  if (!directory || !configPath || extra.length || !out !== !local)
7921
8467
  return yield* invalid();
@@ -7928,7 +8474,7 @@ var publish = (argv) => {
7928
8474
  const clock = yield* ReleaseClock;
7929
8475
  const platform = yield* hostPlatform;
7930
8476
  const { repository } = yield* localTagProvenanceEffect({ config, tag, sourceSha });
7931
- const plan = yield* Effect24.uninterruptible(stageLocalReleaseEffect({
8477
+ const plan = yield* Effect25.uninterruptible(stageLocalReleaseEffect({
7932
8478
  config,
7933
8479
  directory,
7934
8480
  out,
@@ -7946,7 +8492,7 @@ var publish = (argv) => {
7946
8492
  };
7947
8493
  var cut = (argv) => {
7948
8494
  const [local, args] = localFlag(argv);
7949
- return runCommand((error) => `Unable to cut the release: ${redactedErrorMessage(error)}. Check the trusted workflow or local checkout and release configuration.`, Effect24.gen(function* () {
8495
+ return runCommand((error) => `Unable to cut the release: ${redactedErrorMessage(error)}. Check the trusted workflow or local checkout and release configuration.`, Effect25.gen(function* () {
7950
8496
  const [kind, path, sourceSha, ...extra] = args;
7951
8497
  if (kind !== "daily" || !path || extra.length || !sourceSha !== !local)
7952
8498
  return yield* invalid();
@@ -7956,7 +8502,7 @@ var cut = (argv) => {
7956
8502
  const { env } = yield* ReleaseConfig;
7957
8503
  if (local) {
7958
8504
  const platform = yield* hostPlatform;
7959
- const result = yield* Effect24.uninterruptible(runLocalReleaseCutEffect({ kind, config, sourceSha, platform }));
8505
+ const result = yield* Effect25.uninterruptible(runLocalReleaseCutEffect({ kind, config, sourceSha, platform }));
7960
8506
  return yield* print(result);
7961
8507
  }
7962
8508
  const result = yield* releaseCutCommand({
@@ -7970,7 +8516,7 @@ var cut = (argv) => {
7970
8516
  };
7971
8517
  var promote = (argv) => {
7972
8518
  const [local, args] = localFlag(argv);
7973
- return runCommand("Unable to promote the release; check the trusted workflow or feed and release configuration.", Effect24.gen(function* () {
8519
+ return runCommand("Unable to promote the release; check the trusted workflow or feed and release configuration.", Effect25.gen(function* () {
7974
8520
  const [path, out, ...extra] = args;
7975
8521
  const { env } = yield* ReleaseConfig;
7976
8522
  const held = env.STABLE_PROMOTION_HELD;
@@ -7980,7 +8526,7 @@ var promote = (argv) => {
7980
8526
  if (local) {
7981
8527
  const clock = yield* ReleaseClock;
7982
8528
  const repository = yield* originRepositoryEffect;
7983
- const result = yield* Effect24.uninterruptible(runLocalPromotionEffect({
8529
+ const result = yield* Effect25.uninterruptible(runLocalPromotionEffect({
7984
8530
  config,
7985
8531
  out,
7986
8532
  now: clock.now(),
@@ -7993,7 +8539,7 @@ var promote = (argv) => {
7993
8539
  yield* print(yield* promotionCommand({ env, config }));
7994
8540
  }), { requireGitHubActions: !local });
7995
8541
  };
7996
- var finalize = (argv) => runCommand((error) => `Release finalization failed: ${redactedErrorMessage(error)}`, Effect24.gen(function* () {
8542
+ var finalize = (argv) => runCommand((error) => `Release finalization failed: ${redactedErrorMessage(error)}`, Effect25.gen(function* () {
7997
8543
  const { env } = yield* ReleaseConfig;
7998
8544
  if (argv[0] === "--local") {
7999
8545
  const [configPath, tag, ...extra] = argv.slice(1);
@@ -8014,7 +8560,7 @@ var finalize = (argv) => runCommand((error) => `Release finalization failed: ${r
8014
8560
  yield* finalizeReleasePleaseDraftEffect({ env, config, ...identity });
8015
8561
  yield* say("Qualified draft published as a prerelease");
8016
8562
  }));
8017
- var planAssets = (args) => runCommand("Unable to plan release assets; check release provenance and the trusted workflow.", Effect24.gen(function* () {
8563
+ var planAssets = (args) => runCommand("Unable to plan release assets; check release provenance and the trusted workflow.", Effect25.gen(function* () {
8018
8564
  const [tag, path, ...extra] = args;
8019
8565
  if (!tag || !path || extra.length)
8020
8566
  return yield* invalid("Expected release tag and configuration file");
@@ -8022,7 +8568,7 @@ var planAssets = (args) => runCommand("Unable to plan release assets; check rele
8022
8568
  const { env } = yield* ReleaseConfig;
8023
8569
  yield* print(yield* planReleaseAssetsEffect({ env, config, tag }));
8024
8570
  }));
8025
- var sign2 = (args) => runCommand("Unable to sign release artifact; check the identity, archive and signing key.", Effect24.gen(function* () {
8571
+ var sign2 = (args) => runCommand("Unable to sign release artifact; check the identity, archive and signing key.", Effect25.gen(function* () {
8026
8572
  const [identityPath, artifactPath, feed, ...extra] = args;
8027
8573
  const { env } = yield* ReleaseConfig;
8028
8574
  if (!identityPath || !artifactPath || !feed || extra.length || !env.ADEA_RELEASE_SIGNING_KEY)
@@ -8033,7 +8579,7 @@ var sign2 = (args) => runCommand("Unable to sign release artifact; check the ide
8033
8579
  }));
8034
8580
  var signDescriptors = (argv) => {
8035
8581
  const [local, args] = localFlag(argv);
8036
- return runCommand("Unable to stage signed descriptors; check the trusted release, installer receipts and signing configuration.", Effect24.gen(function* () {
8582
+ return runCommand("Unable to stage signed descriptors; check the trusted release, installer receipts and signing configuration.", Effect25.gen(function* () {
8037
8583
  const [directory, configPath, ...extra] = args;
8038
8584
  const { env } = yield* ReleaseConfig;
8039
8585
  const {
@@ -8066,7 +8612,7 @@ var signDescriptors = (argv) => {
8066
8612
  }));
8067
8613
  }));
8068
8614
  };
8069
- var releaseStep = (argv) => runCommand((error) => `Release step failed: ${error.message}`, Effect24.gen(function* () {
8615
+ var releaseStep = (argv) => runCommand((error) => `Release step failed: ${error.message}`, Effect25.gen(function* () {
8070
8616
  const args = [...argv];
8071
8617
  const flag = args.indexOf("--artifacts");
8072
8618
  const artifacts = flag === -1 ? undefined : args.splice(flag, 2)[1];
@@ -8118,9 +8664,9 @@ var releaseStep = (argv) => runCommand((error) => `Release step failed: ${error.
8118
8664
  return yield* invalid(`Unknown release step ${String(name)}`);
8119
8665
  }
8120
8666
  }));
8121
- var verifyMacosSigning = (args) => Effect24.gen(function* () {
8667
+ var verifyMacosSigning = (args) => Effect25.gen(function* () {
8122
8668
  let problems = 0;
8123
- const code = yield* runCommand("Unable to check the app signing; run it on macOS with codesign.", Effect24.gen(function* () {
8669
+ const code = yield* runCommand("Unable to check the app signing; run it on macOS with codesign.", Effect25.gen(function* () {
8124
8670
  const [app, flag, ...extra] = args;
8125
8671
  if (!app || extra.length || ![undefined, "--hardened"].includes(flag))
8126
8672
  return yield* invalid("usage");
@@ -8133,19 +8679,55 @@ var verifyMacosSigning = (args) => Effect24.gen(function* () {
8133
8679
  }));
8134
8680
  return code || (problems ? 1 : 0);
8135
8681
  });
8136
- var publishFramework = (args) => runCommand((error) => error.message, Effect24.gen(function* () {
8682
+ var publishFramework = (args) => runCommand((error) => error.message, Effect25.gen(function* () {
8137
8683
  const [archive, flag, ...extra] = args;
8138
8684
  if (!archive || extra.length || flag !== undefined && flag !== "--dry-run")
8139
8685
  return yield* invalid("Expected one framework package archive and an optional --dry-run");
8140
8686
  const { env } = yield* ReleaseConfig;
8141
8687
  yield* print(yield* step(() => publishFrameworkPackage({ env, archive, dryRun: flag === "--dry-run" })));
8142
8688
  }));
8689
+ var publishArch = (argv) => runCommand((error) => `Unable to publish the Arch package: ${redactedErrorMessage(error)}`, Effect25.gen(function* () {
8690
+ const args = [...argv];
8691
+ const printIndex = args.indexOf("--print");
8692
+ const printDirectory = printIndex === -1 ? undefined : args[printIndex + 1];
8693
+ if (printIndex !== -1 && !printDirectory)
8694
+ return yield* invalid("Expected a directory after --print");
8695
+ if (printIndex !== -1)
8696
+ args.splice(printIndex, 2);
8697
+ const pkgrelIndex = args.indexOf("--pkgrel");
8698
+ const pkgrelText = pkgrelIndex === -1 ? undefined : args[pkgrelIndex + 1];
8699
+ if (pkgrelIndex !== -1 && !pkgrelText)
8700
+ return yield* invalid("Expected a number after --pkgrel");
8701
+ if (pkgrelIndex !== -1)
8702
+ args.splice(pkgrelIndex, 2);
8703
+ if (pkgrelText !== undefined && !/^[1-9]\d{0,2}$/.test(pkgrelText))
8704
+ return yield* invalid("--pkgrel must be an integer between 1 and 999");
8705
+ const dryIndex = args.indexOf("--dry-run");
8706
+ const dryRun = dryIndex !== -1;
8707
+ if (dryRun)
8708
+ args.splice(dryIndex, 1);
8709
+ const [configPath, tag, ...extra] = args;
8710
+ if (!configPath || !tag || extra.length)
8711
+ return yield* invalid("Expected <release-config.json> <tag>");
8712
+ const config = yield* readReleaseConfig(configPath);
8713
+ if (typeof config !== "object" || config === null || Array.isArray(config) || typeof config.appName !== "string")
8714
+ return yield* invalid("release-config.json names no app");
8715
+ yield* print(yield* publishArchPackageEffect({
8716
+ config,
8717
+ appName: config.appName,
8718
+ tag,
8719
+ ...pkgrelText === undefined ? {} : { pkgrel: Number(pkgrelText) },
8720
+ ...dryRun ? { dryRun } : {},
8721
+ ...printDirectory ? { printDirectory } : {}
8722
+ }));
8723
+ }));
8143
8724
  var commands = {
8144
8725
  cut,
8145
8726
  finalize,
8146
8727
  "plan-assets": planAssets,
8147
8728
  promote,
8148
8729
  publish,
8730
+ "publish-arch": publishArch,
8149
8731
  "publish-framework-package": publishFramework,
8150
8732
  sign: sign2,
8151
8733
  "sign-descriptors": signDescriptors,
@@ -8157,7 +8739,7 @@ var releaseCli = (argv) => {
8157
8739
  const command = name === undefined ? undefined : commands[name];
8158
8740
  if (command)
8159
8741
  return command(args);
8160
- return Effect24.gen(function* () {
8742
+ return Effect25.gen(function* () {
8161
8743
  const { stderr } = yield* ReleaseOutput;
8162
8744
  stderr(`Usage: adea-release <${Object.keys(commands).join("|")}> [arguments]; unknown command ${String(name)}
8163
8745
  `);
@@ -8166,4 +8748,4 @@ var releaseCli = (argv) => {
8166
8748
  };
8167
8749
 
8168
8750
  // src/cli.ts
8169
- process.exitCode = await Effect25.runPromise(provideLivePorts(releaseCli(process.argv.slice(2))));
8751
+ process.exitCode = await Effect26.runPromise(provideLivePorts(releaseCli(process.argv.slice(2))));