@theholocron/cli 5.0.0-alpha.482 → 5.0.0-alpha.484

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.mjs CHANGED
@@ -109,6 +109,8 @@ const COMMAND_CONTEXTS = {
109
109
  "doctor project": "workspace",
110
110
  "doctor logs": "workspace",
111
111
  "doctor wiki": "workspace",
112
+ "doctor errors": "workspace",
113
+ "doctor workers": "workspace",
112
114
  "doctor github-app": "workspace",
113
115
  "move issues": "workspace",
114
116
  "apply properties": "workspace",
@@ -385,6 +387,14 @@ const doctorEnvironmentsEntry = {
385
387
  skipOptions: ["all", "repo"],
386
388
  supportsDryRun: false
387
389
  };
390
+ // src/commands/doctor-errors/doctor-errors.entry.ts
391
+ const doctorErrorsEntry = {
392
+ name: "doctor errors",
393
+ description: "Check the error tracker's organization, declared projects, keys and alert rules (read-only)",
394
+ positionals: [],
395
+ skipOptions: ["all", "repo"],
396
+ supportsDryRun: false
397
+ };
388
398
  // src/commands/doctor-github-app/doctor-github-app.entry.ts
389
399
  const doctorGitHubAppEntry = {
390
400
  name: "doctor github-app",
@@ -532,6 +542,14 @@ const doctorWikiEntry = {
532
542
  skipOptions: ["all", "repo"],
533
543
  supportsDryRun: false
534
544
  };
545
+ // src/commands/doctor-workers/doctor-workers.entry.ts
546
+ const doctorWorkersEntry = {
547
+ name: "doctor workers",
548
+ description: "Check the declared Workers and deployment projects: they exist, route and deploy healthily (read-only)",
549
+ positionals: [],
550
+ skipOptions: ["all", "repo"],
551
+ supportsDryRun: false
552
+ };
535
553
  // src/commands/github-app-create/github-app-create.entry.ts
536
554
  const githubAppCreateEntry = {
537
555
  name: "new github-app",
@@ -1348,6 +1366,8 @@ const registry = createCommandRegistry([
1348
1366
  doctorGitHubAppEntry,
1349
1367
  doctorLogsEntry,
1350
1368
  doctorWikiEntry,
1369
+ doctorErrorsEntry,
1370
+ doctorWorkersEntry,
1351
1371
  projectMoveEntry,
1352
1372
  repoPropertiesApplyEntry,
1353
1373
  migrateIssueEntry,
@@ -7435,7 +7455,7 @@ async function runDoctorDns(input) {
7435
7455
  });
7436
7456
  else if (!loader.has("dns")) {
7437
7457
  const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
7438
- for (const zone of zones) rows.push(row$19(zone, "skip", why));
7458
+ for (const zone of zones) rows.push(row$23(zone, "skip", why));
7439
7459
  for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
7440
7460
  } else {
7441
7461
  const dns = loader.get("dns");
@@ -7457,7 +7477,7 @@ async function runDoctorDns(input) {
7457
7477
  ...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
7458
7478
  };
7459
7479
  }
7460
- function row$19(zone, status, detail, problems = []) {
7480
+ function row$23(zone, status, detail, problems = []) {
7461
7481
  return {
7462
7482
  id: `dns-${zone}`,
7463
7483
  title: `${zone} records exist`,
@@ -7486,7 +7506,7 @@ async function checkDomain(dns, deploy, project, hostname) {
7486
7506
  return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
7487
7507
  }
7488
7508
  }
7489
- async function checkZone(dns, zone, wanted, rowOf = (...args) => row$19(zone, ...args)) {
7509
+ async function checkZone(dns, zone, wanted, rowOf = (...args) => row$23(zone, ...args)) {
7490
7510
  try {
7491
7511
  const have = await dns.listRecords(zone);
7492
7512
  const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
@@ -7596,6 +7616,130 @@ const doctorEnvironmentsCommand = {
7596
7616
  })).status === "fail") process.exitCode = 1;
7597
7617
  }
7598
7618
  };
7619
+ // src/commands/doctor-errors/declared-projects.ts
7620
+ /**
7621
+ * The error tracker projects the config declares: every project a notifications layout's `relay.errors.projects`
7622
+ * sends alerts from, in order, each once.
7623
+ */
7624
+ function declaredProjects$1(layouts) {
7625
+ return [...new Set(layouts.flatMap((layout) => layout.relay?.errors?.projects ?? []))];
7626
+ }
7627
+ // src/commands/doctor-errors/errors-rows.ts
7628
+ const row$22 = (id, title, status, detail, problems = []) => ({
7629
+ id,
7630
+ title,
7631
+ status,
7632
+ detail,
7633
+ problems
7634
+ });
7635
+ /**
7636
+ * The rows `holocron doctor errors` prints for one {@link ErrorsInspection}: the organization, then for each declared
7637
+ * project that it exists, has a client key and is watched by an enabled alert rule. Pure. A project missing, a project
7638
+ * with no key and a project no enabled rule watches fail; alert rules the token could not read are a skip. The Comlink
7639
+ * relay's integration and rule have their own rows in `doctor notifications`.
7640
+ */
7641
+ function errorsRows(found, providerName) {
7642
+ const orgSlug = found.org.slug;
7643
+ if (!found.org.exists) {
7644
+ const problem = `${providerName} has no organization named ${orgSlug}; check the \`org\` option of the \`errors\` provider`;
7645
+ const rows = [row$22("errors:org", "organization exists", "fail", `${orgSlug} not found`, [problem])];
7646
+ for (const project of found.projects) rows.push(row$22(`errors:project:${project.slug}`, `project ${project.slug} exists`, "skip", "not checked: no organization"));
7647
+ return rows;
7648
+ }
7649
+ const rows = [row$22("errors:org", "organization exists", "ok", `${orgSlug} (${found.org.name ?? orgSlug})`)];
7650
+ if (found.projects.length === 0) {
7651
+ rows.push(row$22("errors:projects", "declared projects", "skip", "none declared: no `relay.errors.projects` in a layout"));
7652
+ return rows;
7653
+ }
7654
+ for (const project of found.projects) {
7655
+ const slug = project.slug;
7656
+ if (!project.exists) {
7657
+ const problem = `no project ${slug} in ${found.org.slug}; create it in ${providerName}`;
7658
+ rows.push(row$22(`errors:project:${slug}`, `project ${slug} exists`, "fail", "not found", [problem]), row$22(`errors:dsn:${slug}`, `project ${slug} has a key`, "skip", "not checked: no project"), row$22(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "skip", "not checked: no project"));
7659
+ continue;
7660
+ }
7661
+ rows.push(row$22(`errors:project:${slug}`, `project ${slug} exists`, "ok", slug));
7662
+ rows.push(project.hasDsn ? row$22(`errors:dsn:${slug}`, `project ${slug} has a key`, "ok", "a client key (DSN) exists") : row$22(`errors:dsn:${slug}`, `project ${slug} has a key`, "fail", "no client key", [`${slug} has no client key, so an SDK has no DSN to send to; add one in ${providerName}`]));
7663
+ if (project.alertRules === void 0) rows.push(row$22(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "skip", found.alertsUnreadable ? `could not read the alert rules: ${found.alertsUnreadable}` : "not read"));
7664
+ else if (project.alertRules === 0) rows.push(row$22(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "fail", "no enabled rule", [`no enabled alert rule watches ${slug}, so its errors reach no one`]));
7665
+ else rows.push(row$22(`errors:alerts:${slug}`, `project ${slug} has an alert rule`, "ok", `${project.alertRules} enabled rule(s)`));
7666
+ }
7667
+ return rows;
7668
+ }
7669
+ // src/commands/doctor-errors/doctor-errors.ts
7670
+ /**
7671
+ * `holocron doctor errors` — does the error tracker the config declares have the organization, projects, keys and
7672
+ * alert rules it relies on?
7673
+ *
7674
+ * Read-only: it never creates a project or a rule, and prints names and counts only, never a DSN, a key or a token.
7675
+ * The rows (`errorsRows()`): the organization; for each project a notifications layout's `relay.errors.projects`
7676
+ * declares, that it exists, has a client key and is watched by an enabled alert rule. The Comlink relay's own
7677
+ * integration and rule are `doctor notifications`' rows and are not repeated. A project the provider says is missing
7678
+ * fails; anything that cannot be read (no token, no `org`, a token without the alert scope) is a skip with the reason.
7679
+ */
7680
+ const skip$1 = (detail) => ({
7681
+ id: "errors",
7682
+ title: "errors",
7683
+ status: "skip",
7684
+ detail,
7685
+ problems: []
7686
+ });
7687
+ async function runDoctorErrors(input) {
7688
+ const print = input.print ?? ((line) => console.log(line));
7689
+ const logger = input.logger ?? getLogger();
7690
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
7691
+ await loader.load();
7692
+ assertPluginsResolvable(loader, "doctor errors");
7693
+ let rows;
7694
+ if (!loader.has("errors")) {
7695
+ const failure = loader.loadFailures().find((f) => f.key === "errors");
7696
+ rows = [skip$1(failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `errors` provider is configured in holocron.config.ts")];
7697
+ } else {
7698
+ const errors = loader.get("errors");
7699
+ if (!errors.inspect) rows = [skip$1(`${errors.providerName} cannot read its organization`)];
7700
+ else {
7701
+ const layouts = (loader.has("notifications") ? loader.get("notifications") : []).flatMap((p) => p.layout ? [p.layout] : []);
7702
+ try {
7703
+ rows = errorsRows(await errors.inspect({ projects: declaredProjects$1(layouts) }), errors.providerName);
7704
+ } catch (err) {
7705
+ rows = [skip$1(missingTokenReason(err) ?? `could not read ${errors.providerName}: ${describeError(err)}`)];
7706
+ }
7707
+ }
7708
+ }
7709
+ printCheckRows(rows, print);
7710
+ const summary = summariseChecks(rows);
7711
+ printCheckSummary(summary, print);
7712
+ const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
7713
+ logger.info({
7714
+ ...summary,
7715
+ status
7716
+ }, "doctor errors");
7717
+ return {
7718
+ status,
7719
+ rows,
7720
+ summary,
7721
+ ...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
7722
+ };
7723
+ }
7724
+ // src/commands/doctor-errors/doctor-errors.command.ts
7725
+ const doctorErrorsCommand = {
7726
+ command: "errors",
7727
+ describe: "Check the error tracker's organization, declared projects, keys and alert rules (read-only)",
7728
+ handler: async (argv) => {
7729
+ const tokens = tokenContext(argv.token);
7730
+ if (!tokens) return;
7731
+ const loaded = await loadConfig(argv.cwd);
7732
+ applyResolvedConfig(argv, loaded.resolved);
7733
+ if ((await runDoctorErrors({
7734
+ loaded,
7735
+ context: {
7736
+ repoRoot: argv.cwd,
7737
+ ...tokens,
7738
+ org: resolveOrg(argv, loaded.resolved)
7739
+ }
7740
+ })).status === "fail") process.exitCode = 1;
7741
+ }
7742
+ };
7599
7743
  // src/commands/doctor-github-app/permission-gaps.ts
7600
7744
  const LEVELS$1 = [
7601
7745
  "read",
@@ -7621,7 +7765,7 @@ function installationSettingsUrl(account, id) {
7621
7765
  return `https://github.com/settings/installations/${id}`;
7622
7766
  }
7623
7767
  // src/commands/doctor-github-app/app-rows.ts
7624
- const row$18 = (name, what, problems, ok) => ({
7768
+ const row$21 = (name, what, problems, ok) => ({
7625
7769
  id: `${name}:${what}`,
7626
7770
  title: `${name}: ${what}`,
7627
7771
  status: problems.length > 0 ? "fail" : "ok",
@@ -7648,9 +7792,9 @@ function appRows(name, manifest, app, installations) {
7648
7792
  return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
7649
7793
  });
7650
7794
  return [
7651
- row$18(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
7652
- row$18(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
7653
- row$18(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
7795
+ row$21(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
7796
+ row$21(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
7797
+ row$21(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
7654
7798
  ];
7655
7799
  }
7656
7800
  // src/commands/doctor-github-app/parse-manifest.ts
@@ -7708,7 +7852,7 @@ async function runDoctorGitHubApp(input) {
7708
7852
  assertPluginsResolvable(loader, "doctor github-app");
7709
7853
  }
7710
7854
  const rows = [];
7711
- if (instances.length === 0) rows.push(row$17("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
7855
+ if (instances.length === 0) rows.push(row$20("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
7712
7856
  for (const instance of instances) rows.push(...await checkInstance(instance, loader, input));
7713
7857
  printCheckRows(rows, print);
7714
7858
  const summary = summariseChecks(rows);
@@ -7725,7 +7869,7 @@ async function runDoctorGitHubApp(input) {
7725
7869
  ...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
7726
7870
  };
7727
7871
  }
7728
- function row$17(name, what, status, detail) {
7872
+ function row$20(name, what, status, detail) {
7729
7873
  return {
7730
7874
  id: `${name}:${what}`,
7731
7875
  title: `${name}: ${what}`,
@@ -7766,19 +7910,19 @@ async function checkInstance(instance, loader, input) {
7766
7910
  try {
7767
7911
  manifest = parseManifest(readManifest(instance.manifest));
7768
7912
  } catch (err) {
7769
- return [row$17(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
7913
+ return [row$20(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
7770
7914
  }
7771
7915
  const read = await readCredentials(instance, loader);
7772
- if ("reason" in read) return [row$17(name, "reachable", "skip", read.reason)];
7916
+ if ("reason" in read) return [row$20(name, "reachable", "skip", read.reason)];
7773
7917
  const api = input.api ?? defaultApi;
7774
7918
  const secrets = [read.creds.privateKey];
7775
7919
  try {
7776
7920
  const app = await api.getApp(read.creds);
7777
7921
  const installations = await api.listAppInstallations(read.creds);
7778
7922
  const owner = app.owner ? `, owned by ${app.owner.login}` : "";
7779
- return [row$17(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
7923
+ return [row$20(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
7780
7924
  } catch (err) {
7781
- return [row$17(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
7925
+ return [row$20(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed$1(err, secrets)}`)];
7782
7926
  }
7783
7927
  }
7784
7928
  // src/commands/doctor-github-app/doctor-github-app.command.ts
@@ -7845,7 +7989,7 @@ function datasetTargets(config) {
7845
7989
  * dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
7846
7990
  * a dataset the token may not see (403), a name, a token or a response that cannot be read is a skip with the reason.
7847
7991
  */
7848
- const row$16 = (id, title, status, detail, problems = []) => ({
7992
+ const row$19 = (id, title, status, detail, problems = []) => ({
7849
7993
  id,
7850
7994
  title,
7851
7995
  status,
@@ -7862,7 +8006,7 @@ async function runDoctorLogs(input) {
7862
8006
  if (!loader.has("logs")) {
7863
8007
  const failure = loader.loadFailures().find((f) => f.key === "logs");
7864
8008
  const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
7865
- rows.push(row$16("logs", "logs", "skip", why));
8009
+ rows.push(row$19("logs", "logs", "skip", why));
7866
8010
  } else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
7867
8011
  printCheckRows(rows, print);
7868
8012
  const summary = summariseChecks(rows);
@@ -7886,38 +8030,38 @@ async function checkLogs(logs, targets) {
7886
8030
  for (const target of targets) {
7887
8031
  const id = `logs:dataset:${target.id}`;
7888
8032
  const title = `dataset for ${target.label}`;
7889
- if (!target.name) rows.push(row$16(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
7890
- else if (!token.usable) rows.push(row$16(id, title, "skip", `${target.name}: not checked, the token is not usable`));
7891
- else if (!logs.readDataset) rows.push(row$16(id, title, "skip", `${logs.providerName} cannot read a dataset`));
8033
+ if (!target.name) rows.push(row$19(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
8034
+ else if (!token.usable) rows.push(row$19(id, title, "skip", `${target.name}: not checked, the token is not usable`));
8035
+ else if (!logs.readDataset) rows.push(row$19(id, title, "skip", `${logs.providerName} cannot read a dataset`));
7892
8036
  else rows.push(...await checkDataset(logs, target, target.name, id, title));
7893
8037
  }
7894
8038
  const org = resolveValue$1(["AXIOM_ORG"], void 0, { prefix: PREFIX$1 });
7895
- rows.push(org ? row$16("logs:org", "organization", "ok", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$16("logs:org", "organization", "skip", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links need it`));
8039
+ rows.push(org ? row$19("logs:org", "organization", "ok", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$19("logs:org", "organization", "skip", `${PREFIX$1}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links need it`));
7896
8040
  return rows;
7897
8041
  }
7898
8042
  /** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
7899
8043
  async function checkToken$1(logs, dataset) {
7900
8044
  const title = "token is accepted";
7901
8045
  if (!logs.checkToken) return {
7902
- row: row$16("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
8046
+ row: row$19("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
7903
8047
  usable: true
7904
8048
  };
7905
8049
  try {
7906
8050
  const result = await logs.checkToken(dataset);
7907
8051
  if (result.ok) return {
7908
- row: row$16("logs:token", title, "ok", `${logs.providerName} accepts the token`),
8052
+ row: row$19("logs:token", title, "ok", `${logs.providerName} accepts the token`),
7909
8053
  usable: true
7910
8054
  };
7911
8055
  const reason = result.reason ?? `${logs.providerName} refused the token`;
7912
8056
  return {
7913
- row: row$16("logs:token", title, "fail", reason, [reason]),
8057
+ row: row$19("logs:token", title, "fail", reason, [reason]),
7914
8058
  usable: false
7915
8059
  };
7916
8060
  } catch (err) {
7917
8061
  const noToken = missingTokenReason(err);
7918
8062
  const detail = noToken ?? `could not check the token: ${describeError(err)}`;
7919
8063
  return {
7920
- row: row$16("logs:token", title, "skip", detail),
8064
+ row: row$19("logs:token", title, "skip", detail),
7921
8065
  usable: noToken === void 0
7922
8066
  };
7923
8067
  }
@@ -7927,17 +8071,17 @@ async function checkDataset(logs, target, name, id, title) {
7927
8071
  const found = await logs.readDataset(name);
7928
8072
  if (found.forbidden) {
7929
8073
  const why = `${name}: not visible to this token (${logs.providerName} refused the read; it may also not exist)`;
7930
- return [row$16(id, title, "skip", why)];
8074
+ return [row$19(id, title, "skip", why)];
7931
8075
  }
7932
8076
  if (!found.exists) {
7933
8077
  const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
7934
- return [row$16(id, title, "fail", `${name} does not exist`, [problem])];
8078
+ return [row$19(id, title, "fail", `${name} does not exist`, [problem])];
7935
8079
  }
7936
8080
  const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
7937
- return [row$16(id, title, "ok", `${name} exists`), row$16(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
8081
+ return [row$19(id, title, "ok", `${name} exists`), row$19(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
7938
8082
  } catch (err) {
7939
8083
  const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
7940
- return [row$16(id, title, "skip", detail)];
8084
+ return [row$19(id, title, "skip", detail)];
7941
8085
  }
7942
8086
  }
7943
8087
  // src/commands/doctor-logs/doctor-logs.command.ts
@@ -9239,7 +9383,7 @@ const CHANNEL_ID = "monitoring-alert-channel";
9239
9383
  const CHANNEL_TITLE = "monitoring alert channel posts through the feed webhook";
9240
9384
  const SUBSCRIPTIONS_ID = "monitoring-subscriptions";
9241
9385
  const SUBSCRIPTIONS_TITLE = "monitoring alert channel is subscribed to the checks routed to it";
9242
- const same$3 = (a, b) => a.toLowerCase() === b.toLowerCase();
9386
+ const same$5 = (a, b) => a.toLowerCase() === b.toLowerCase();
9243
9387
  const shown$5 = (s) => sanitizeDetail(s);
9244
9388
  const skipAll = (reason) => [
9245
9389
  skipRow$1(WEBHOOK_ID$1, WEBHOOK_TITLE$1, reason),
@@ -9267,14 +9411,14 @@ async function monitoringFeedChecks(input) {
9267
9411
  let channelSkip;
9268
9412
  for (const { channel, feed } of fed) {
9269
9413
  const names = monitoringFeed(channel.name, feed, monitoring);
9270
- const where = found.channels.find((c) => same$3(c.name, channel.name));
9414
+ const where = found.channels.find((c) => same$5(c.name, channel.name));
9271
9415
  const hookId = where?.webhookIds?.[names.webhook.toLowerCase()];
9272
- const named = where?.webhooks.some((w) => same$3(w, names.webhook)) ?? false;
9416
+ const named = where?.webhooks.some((w) => same$5(w, names.webhook)) ?? false;
9273
9417
  const label = `#${shown$5(channel.name)}`;
9274
9418
  if (!where) webhookProblems.push(`${label}: no channel to hold the feed webhook`);
9275
9419
  else if (where.webhooksError) webhookProblems.push(`${label}: could not list its webhooks (${shown$5(where.webhooksError)})`);
9276
9420
  else if (!named) webhookProblems.push(`${label}: no webhook named ${shown$5(names.webhook)}`);
9277
- else if (feedAvatarOf(layout, feed, monitoring).length > 0 && !where.webhookAvatars?.some((w) => same$3(w, names.webhook))) webhookProblems.push(`${label}: webhook ${shown$5(names.webhook)} has no picture`);
9421
+ else if (feedAvatarOf(layout, feed, monitoring).length > 0 && !where.webhookAvatars?.some((w) => same$5(w, names.webhook))) webhookProblems.push(`${label}: webhook ${shown$5(names.webhook)} has no picture`);
9278
9422
  if (channelSkip !== void 0) continue;
9279
9423
  if (!monitoring.inspectAlertChannel) {
9280
9424
  channelSkip = `the \`${monitoring.providerName}\` provider cannot read its alert channels`;
@@ -9978,7 +10122,7 @@ async function postDoctorReport(notifications, channel, report, name = "notifica
9978
10122
  const FORUM_TITLE = "pull request feed forum exists";
9979
10123
  const TAGS_TITLE = "pull request feed forum has the tags of every state";
9980
10124
  const BOT_TITLE = "bot can post in the pull request feed forum and manage its threads";
9981
- const same$2 = (a, b) => a.toLowerCase() === b.toLowerCase();
10125
+ const same$4 = (a, b) => a.toLowerCase() === b.toLowerCase();
9982
10126
  const shown$3 = (s) => sanitizeDetail(s);
9983
10127
  /**
9984
10128
  * The steps of `doctor notifications` for the pull-request feed (`feeds.prs`): the forum is there (in its category, as a
@@ -10006,7 +10150,7 @@ function prFeedChecks(input) {
10006
10150
  const botProblems = [];
10007
10151
  for (const { cat, channel } of fed) {
10008
10152
  const name = shown$3(channel.name);
10009
- const have = found.channels.find((c) => same$2(c.name, channel.name) && c.category !== void 0 && same$2(c.category, cat));
10153
+ const have = found.channels.find((c) => same$4(c.name, channel.name) && c.category !== void 0 && same$4(c.category, cat));
10010
10154
  if (!have) {
10011
10155
  forumProblems.push(`#${name}: missing from ${shown$3(cat)}`);
10012
10156
  continue;
@@ -10015,7 +10159,7 @@ function prFeedChecks(input) {
10015
10159
  forumProblems.push(`#${name}: is a text channel, not a forum; delete it so \`setup\` can make it again`);
10016
10160
  continue;
10017
10161
  }
10018
- for (const tag of PR_FEED_TAGS) if (!have.tags?.some((t) => same$2(t.name, tag))) tagProblems.push(`#${name}: tag "${tag}" is missing`);
10162
+ for (const tag of PR_FEED_TAGS) if (!have.tags?.some((t) => same$4(t.name, tag))) tagProblems.push(`#${name}: tag "${tag}" is missing`);
10019
10163
  if (have.botThreadsError) botProblems.push(`#${name}: could not read the bot's permissions (${shown$3(have.botThreadsError)})`);
10020
10164
  else if (have.botThreads) {
10021
10165
  if (!have.botThreads.post) botProblems.push(`#${name}: the bot cannot start posts or reply in it`);
@@ -10040,7 +10184,7 @@ const BINDINGS_ID = "relay-bindings";
10040
10184
  const BINDINGS_TITLE = "relay Worker has its webhook and signing secret bound";
10041
10185
  const WEBHOOK_ID = "relay-feed-webhook";
10042
10186
  const WEBHOOK_TITLE = "error feed webhook exists and has a picture";
10043
- const same$1 = (a, b) => a.toLowerCase() === b.toLowerCase();
10187
+ const same$3 = (a, b) => a.toLowerCase() === b.toLowerCase();
10044
10188
  const shown$2 = (s) => sanitizeDetail(s);
10045
10189
  /** One unsigned `POST` to the Worker, and what the answer says about it. Reads nothing from the response. */
10046
10190
  async function answers(url, doFetch) {
@@ -10087,7 +10231,7 @@ async function relayChecks(input) {
10087
10231
  else {
10088
10232
  const bound = new Set(state.bindingNames.map((n) => n.toUpperCase()));
10089
10233
  const wanted = [relayWebhookBinding(source), relaySecretBinding(source)];
10090
- rows.push(resultRow(WORKER_ID, WORKER_TITLE, state.routes.some((r) => same$1(r, route)) ? [] : [`${shown$2(script)} has no route ${shown$2(route)}`], `${shown$2(script)} serves ${shown$2(route)}`), resultRow(BINDINGS_ID, BINDINGS_TITLE, wanted.filter((n) => !bound.has(n)).map((n) => `${n}: not bound`), `${wanted.length} of ${wanted.length} bound`));
10234
+ rows.push(resultRow(WORKER_ID, WORKER_TITLE, state.routes.some((r) => same$3(r, route)) ? [] : [`${shown$2(script)} has no route ${shown$2(route)}`], `${shown$2(script)} serves ${shown$2(route)}`), resultRow(BINDINGS_ID, BINDINGS_TITLE, wanted.filter((n) => !bound.has(n)).map((n) => `${n}: not bound`), `${wanted.length} of ${wanted.length} bound`));
10091
10235
  }
10092
10236
  } catch (err) {
10093
10237
  const reason = missingTokenReason(err);
@@ -10102,13 +10246,13 @@ function webhookRow(input, source) {
10102
10246
  const channel = input.layout.categories.flatMap((cat) => cat.channels ?? []).find((c) => c.feeds?.errors);
10103
10247
  const feed = channel.feeds.errors;
10104
10248
  const name = errorsFeedWebhook(feed, { providerName: source });
10105
- const where = input.found.channels.find((c) => same$1(c.name, channel.name));
10249
+ const where = input.found.channels.find((c) => same$3(c.name, channel.name));
10106
10250
  const label = `#${shown$2(channel.name)}`;
10107
10251
  const problems = [];
10108
10252
  if (!where) problems.push(`${label}: no channel to hold the feed webhook`);
10109
10253
  else if (where.webhooksError) problems.push(`${label}: could not list its webhooks (${shown$2(where.webhooksError)})`);
10110
- else if (!where.webhooks.some((w) => same$1(w, name))) problems.push(`${label}: no webhook named ${shown$2(name)}`);
10111
- else if (feedAvatarOf(input.layout, feed).length > 0 && !where.webhookAvatars?.some((w) => same$1(w, name))) problems.push(`${label}: webhook ${shown$2(name)} has no picture`);
10254
+ else if (!where.webhooks.some((w) => same$3(w, name))) problems.push(`${label}: no webhook named ${shown$2(name)}`);
10255
+ else if (feedAvatarOf(input.layout, feed).length > 0 && !where.webhookAvatars?.some((w) => same$3(w, name))) problems.push(`${label}: webhook ${shown$2(name)} has no picture`);
10112
10256
  return resultRow(WEBHOOK_ID, WEBHOOK_TITLE, problems, `${label}: ${shown$2(name)}`);
10113
10257
  }
10114
10258
  // src/commands/sentry-relay-checks/sentry-relay-checks.ts
@@ -10175,7 +10319,7 @@ async function sentryRelayChecks(input) {
10175
10319
  * It is the end-to-end check for `setup notifications`, and stays useful after
10176
10320
  * as a drift check. The step numbers match the table in holocron#1098.
10177
10321
  */
10178
- const same = (a, b) => a.toLowerCase() === b.toLowerCase();
10322
+ const same$2 = (a, b) => a.toLowerCase() === b.toLowerCase();
10179
10323
  /** `everyone`, or the roles sorted and lower-cased, so order and case do not matter when comparing. */
10180
10324
  const accessKey = (v) => v === "everyone" ? "everyone" : JSON.stringify([...new Set(v.map((r) => r.toLowerCase()))].sort());
10181
10325
  /** The prompts of an onboarding in a form two of them can be compared in: the order of the channels and roles an answer gives, and case, do not matter. */
@@ -10314,10 +10458,10 @@ async function runDoctorNotifications(input) {
10314
10458
  channel
10315
10459
  })));
10316
10460
  const pick = (name, category) => {
10317
- const named = found.channels.filter((c) => same(c.name, name));
10461
+ const named = found.channels.filter((c) => same$2(c.name, name));
10318
10462
  return {
10319
10463
  named,
10320
- match: named.find((c) => c.category !== void 0 && same(c.category, category))
10464
+ match: named.find((c) => c.category !== void 0 && same$2(c.category, category))
10321
10465
  };
10322
10466
  };
10323
10467
  if (!found) {
@@ -10338,7 +10482,7 @@ async function runDoctorNotifications(input) {
10338
10482
  } else {
10339
10483
  const inspected = found;
10340
10484
  const categories = layout.categories ?? [];
10341
- add("categories", "categories exist", categories.filter((cat) => !inspected.categories.some((name) => same(name, cat.name))).map((cat) => `${shown(cat.name)}: missing`), categories.length === 0 ? "none declared" : `${categories.length} of ${categories.length} exist`);
10485
+ add("categories", "categories exist", categories.filter((cat) => !inspected.categories.some((name) => same$2(name, cat.name))).map((cat) => `${shown(cat.name)}: missing`), categories.length === 0 ? "none declared" : `${categories.length} of ${categories.length} exist`);
10342
10486
  const channelProblems = [];
10343
10487
  for (const { cat, channel } of declaredChannels) {
10344
10488
  const { named, match } = pick(channel.name, cat);
@@ -10357,7 +10501,7 @@ async function runDoctorNotifications(input) {
10357
10501
  else if (isForum) {
10358
10502
  if (channel.defaultReaction && (match.defaultReaction ?? "") !== channel.defaultReaction) channelProblems.push(`#${shown(channel.name)}: default reaction is ${match.defaultReaction ? `"${shown(match.defaultReaction)}"` : "not set"} but the layout says "${shown(channel.defaultReaction)}"`);
10359
10503
  for (const tag of channel.tags ?? []) {
10360
- const have = match.tags?.find((t) => same(t.name, tag.name));
10504
+ const have = match.tags?.find((t) => same$2(t.name, tag.name));
10361
10505
  if (!have) channelProblems.push(`#${shown(channel.name)}: tag "${shown(tag.name)}" is missing`);
10362
10506
  else if ((have.emoji ?? "") !== (tag.emoji ?? "") || (have.moderated ?? false) !== (tag.moderated ?? false)) channelProblems.push(`#${shown(channel.name)}: tag "${shown(tag.name)}" differs from the layout (emoji or moderated)`);
10363
10507
  }
@@ -10371,7 +10515,7 @@ async function runDoctorNotifications(input) {
10371
10515
  const { match } = pick(channel.name, cat);
10372
10516
  if (!match) webhookProblems.push(`#${shown(channel.name)}: no channel to hold the webhook`);
10373
10517
  else if (match.webhooksError) webhookProblems.push(`#${shown(channel.name)}: could not list its webhooks (${shown(match.webhooksError)})`);
10374
- else if (!match.webhooks.some((w) => same(w, name))) webhookProblems.push(`#${shown(channel.name)}: no webhook named ${shown(name)}`);
10518
+ else if (!match.webhooks.some((w) => same$2(w, name))) webhookProblems.push(`#${shown(channel.name)}: no webhook named ${shown(name)}`);
10375
10519
  }
10376
10520
  add("webhooks", "webhooks on their channels", webhookProblems, withWebhook.length === 0 ? "none declared" : `${withWebhook.length} of ${withWebhook.length} exist`);
10377
10521
  const wantAvatar = declaredChannels.filter(({ channel }) => channel.webhook && webhookAvatarOf(layout, channel.webhook).length > 0);
@@ -10381,14 +10525,14 @@ async function runDoctorNotifications(input) {
10381
10525
  const { match } = pick(channel.name, cat);
10382
10526
  if (!match) avatarProblems.push(`#${shown(channel.name)}: no channel to hold the webhook`);
10383
10527
  else if (match.webhooksError) avatarProblems.push(`#${shown(channel.name)}: could not list its webhooks (${shown(match.webhooksError)})`);
10384
- else if (match.webhookAvatars && !match.webhookAvatars.some((w) => same(w, name))) avatarProblems.push(`#${shown(channel.name)}: webhook ${shown(name)} has no avatar`);
10528
+ else if (match.webhookAvatars && !match.webhookAvatars.some((w) => same$2(w, name))) avatarProblems.push(`#${shown(channel.name)}: webhook ${shown(name)} has no avatar`);
10385
10529
  }
10386
10530
  add("webhook-appearance", AVATAR_TITLE, avatarProblems, wantAvatar.length === 0 ? "none declared" : `${wantAvatar.length} of ${wantAvatar.length} set`);
10387
10531
  const roles = layout.roles ?? [];
10388
10532
  const roleProblems = [];
10389
10533
  if (inspected.rolesError) roleProblems.push(`could not read the roles (${shown(inspected.rolesError)})`);
10390
10534
  for (const role of inspected.rolesError ? [] : roles) {
10391
- const named = inspected.roles.filter((r) => same(r.name, role.name));
10535
+ const named = inspected.roles.filter((r) => same$2(r.name, role.name));
10392
10536
  const actual = named[0];
10393
10537
  if (named.length > 1) roleProblems.push(`${shown(role.name)}: ${named.length} roles have this name; setup cannot tell which to manage`);
10394
10538
  else if (!actual) roleProblems.push(`${shown(role.name)}: missing`);
@@ -10397,7 +10541,7 @@ async function runDoctorNotifications(input) {
10397
10541
  add("roles", "roles exist and are mentionable", roleProblems, roles.length === 0 ? "none declared" : `${roles.length} of ${roles.length} as declared`);
10398
10542
  const appearance = [];
10399
10543
  if (!inspected.rolesError) for (const role of roles) {
10400
- const actual = inspected.roles.find((r) => same(r.name, role.name));
10544
+ const actual = inspected.roles.find((r) => same$2(r.name, role.name));
10401
10545
  if (!actual) {
10402
10546
  appearance.push(`${shown(role.name)}: not checked, the role is missing`);
10403
10547
  continue;
@@ -10451,9 +10595,9 @@ async function runDoctorNotifications(input) {
10451
10595
  for (const cat of categories) {
10452
10596
  if (cat.access) {
10453
10597
  accessDeclared++;
10454
- if (!inspected.categories.some((name) => same(name, cat.name))) accessProblems.push(`${shown(cat.name)}: not checked, the category is missing`);
10598
+ if (!inspected.categories.some((name) => same$2(name, cat.name))) accessProblems.push(`${shown(cat.name)}: not checked, the category is missing`);
10455
10599
  else {
10456
- const have = Object.entries(inspected.categoryAccess ?? {}).find(([n]) => same(n, cat.name))?.[1];
10600
+ const have = Object.entries(inspected.categoryAccess ?? {}).find(([n]) => same$2(n, cat.name))?.[1];
10457
10601
  compare(shown(cat.name), cat.access, have);
10458
10602
  }
10459
10603
  }
@@ -10491,7 +10635,7 @@ async function runDoctorNotifications(input) {
10491
10635
  const want = wantServer[field];
10492
10636
  if (want === void 0) continue;
10493
10637
  const actual = have[field];
10494
- if (!((field === "systemChannel" || field === "rulesChannel" || field === "updatesChannel") && typeof want === "string" && typeof actual === "string" ? same(want, actual) : want === actual)) serverProblems.push(`${field} is ${shown(String(actual ?? "not set"))} but the layout says ${shown(String(want))}`);
10638
+ if (!((field === "systemChannel" || field === "rulesChannel" || field === "updatesChannel") && typeof want === "string" && typeof actual === "string" ? same$2(want, actual) : want === actual)) serverProblems.push(`${field} is ${shown(String(actual ?? "not set"))} but the layout says ${shown(String(want))}`);
10495
10639
  }
10496
10640
  }
10497
10641
  }
@@ -10697,7 +10841,7 @@ async function runDoctorNotifications(input) {
10697
10841
  })));
10698
10842
  const testName = layout.testChannel;
10699
10843
  const mode = input.deliver ? "all" : !input.builtOnly && testName !== void 0 ? "test" : "none";
10700
- const targets = mode === "all" ? withHook : mode === "test" ? withHook.filter(({ channel }) => same(channel.name, testName)).slice(0, 1) : [];
10844
+ const targets = mode === "all" ? withHook : mode === "test" ? withHook.filter(({ channel }) => same$2(channel.name, testName)).slice(0, 1) : [];
10701
10845
  let deliveryNote;
10702
10846
  if (mode === "none") deliveryNote = !input.builtOnly && testName === void 0 ? "the delivery check needs a test channel: name one in the layout's `testChannel` (a channel with a webhook)" : "the delivery check posts test messages, so --built-only skips it; add --deliver to post to every channel";
10703
10847
  else if (targets.length === 0) checks.push({
@@ -11141,7 +11285,7 @@ const info = (id, title, noun, extras) => ({
11141
11285
  detail: `info: ${extras.length} ${noun} not in the template (never deleted)`,
11142
11286
  problems: extras
11143
11287
  });
11144
- const row$15 = (id, title, problems, ok) => ({
11288
+ const row$18 = (id, title, problems, ok) => ({
11145
11289
  id,
11146
11290
  title,
11147
11291
  status: problems.length > 0 ? "fail" : "ok",
@@ -11177,19 +11321,19 @@ function viewProblems(want, found) {
11177
11321
  function boardRows(boardName, template, state) {
11178
11322
  const id = `project:${boardName}`;
11179
11323
  const rows = [];
11180
- rows.push(row$15(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
11324
+ rows.push(row$18(`${id}:statuses`, `${boardName}: statuses`, listProblems("status", "statuses", template.statuses.map((s) => s.name), state.statuses), `${template.statuses.length} in order`));
11181
11325
  const extraStatuses = state.statuses.filter((s) => !template.statuses.some((t) => t.name === s));
11182
11326
  if (extraStatuses.length > 0) rows.push(info(`${id}:extra-statuses`, `${boardName}: extra statuses`, "status(es)", extraStatuses));
11183
- for (const want of template.fields) rows.push(row$15(`${id}:field:${want.name}`, `${boardName}: field ${want.name}`, fieldProblems(want, state.fields.find((f) => f.name === want.name)), want.options ? `${want.options.length} options in order` : want.type));
11327
+ for (const want of template.fields) rows.push(row$18(`${id}:field:${want.name}`, `${boardName}: field ${want.name}`, fieldProblems(want, state.fields.find((f) => f.name === want.name)), want.options ? `${want.options.length} options in order` : want.type));
11184
11328
  const extraFields = state.fields.filter((f) => !template.fields.some((t) => t.name === f.name));
11185
11329
  if (extraFields.length > 0) rows.push(info(`${id}:extra-fields`, `${boardName}: extra fields`, "field(s)", extraFields.map((f) => f.name)));
11186
- for (const want of template.views) rows.push(row$15(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
11330
+ for (const want of template.views) rows.push(row$18(`${id}:view:${want.name}`, `${boardName}: view ${want.name}`, viewProblems(want, state.views.find((v) => v.name === want.name)), `${want.layout}${want.filter ? `, ${want.filter}` : ""}`));
11187
11331
  const extraViews = state.views.filter((v) => !template.views.some((t) => t.name === v.name));
11188
11332
  if (extraViews.length > 0) rows.push(info(`${id}:extra-views`, `${boardName}: extra views`, "view(s)", extraViews.map((v) => v.name)));
11189
11333
  for (const name of template.rules ?? []) {
11190
11334
  const found = state.rules.find((r) => r.name === name);
11191
11335
  const problems = !found ? [`missing rule ${name}`] : found.enabled ? [] : [`rule ${name} is off`];
11192
- rows.push(row$15(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
11336
+ rows.push(row$18(`${id}:rule:${name}`, `${boardName}: rule ${name}`, problems, "on"));
11193
11337
  }
11194
11338
  return rows;
11195
11339
  }
@@ -11249,7 +11393,7 @@ function itemRows(boardName, items) {
11249
11393
  * never fail the run. A template file that does not read is a failure naming the file. `--post [channel]` shares the
11250
11394
  * failing rows through the `notifications` provider's bot, like `doctor notifications --post`.
11251
11395
  */
11252
- const row$14 = (id, title, status, detail, problems = []) => ({
11396
+ const row$17 = (id, title, status, detail, problems = []) => ({
11253
11397
  id,
11254
11398
  title,
11255
11399
  status,
@@ -11303,14 +11447,14 @@ async function checkBoards(input, loader) {
11303
11447
  loader,
11304
11448
  ...input.io ? { io: input.io } : {}
11305
11449
  });
11306
- if (!opened.ok) return [row$14("project", "project", opened.kind, opened.reason, opened.problems)];
11450
+ if (!opened.ok) return [row$17("project", "project", opened.kind, opened.reason, opened.problems)];
11307
11451
  const { projects, owner, boards, templates, templateProblems } = opened.context;
11308
11452
  const rows = templateProblems.map((problem) => {
11309
11453
  /* v8 ignore next -- split always returns at least one element; the fallback only satisfies noUncheckedIndexedAccess */
11310
11454
  const file = problem.split(": ")[0] ?? problem;
11311
- return row$14(`project:template:${file}`, `template file ${file}`, "fail", problem);
11455
+ return row$17(`project:template:${file}`, `template file ${file}`, "fail", problem);
11312
11456
  });
11313
- if (boards.length === 0) return [...rows, row$14("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
11457
+ if (boards.length === 0) return [...rows, row$17("project", "project", "skip", "no boards are declared in `providers.projects.boards`")];
11314
11458
  for (const declared of boards) {
11315
11459
  const template = templates[declared.template];
11316
11460
  const title = `${declared.name}: board exists and is open`;
@@ -11318,18 +11462,18 @@ async function checkBoards(input, loader) {
11318
11462
  const board = await projects.find(owner, declared.name);
11319
11463
  if (!board) {
11320
11464
  const closed = (await projects.list(owner)).some((b) => b.name === declared.name && b.closed);
11321
- rows.push(row$14(`project:${declared.name}`, title, "fail", closed ? "the board is closed" : "no open board has this name", [closed ? "reopen it, or run `holocron setup project` to make a new one" : "run `holocron setup project`"]));
11465
+ rows.push(row$17(`project:${declared.name}`, title, "fail", closed ? "the board is closed" : "no open board has this name", [closed ? "reopen it, or run `holocron setup project` to make a new one" : "run `holocron setup project`"]));
11322
11466
  continue;
11323
11467
  }
11324
- rows.push(row$14(`project:${declared.name}`, title, "ok", board.url));
11468
+ rows.push(row$17(`project:${declared.name}`, title, "ok", board.url));
11325
11469
  if (!template) {
11326
- rows.push(row$14(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
11470
+ rows.push(row$17(`project:${declared.name}:template`, `${declared.name}: template ${declared.template}`, "fail", "no built-in or file template has this name"));
11327
11471
  continue;
11328
11472
  }
11329
11473
  rows.push(...boardRows(declared.name, template, await projects.read(owner, board)));
11330
- rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$14(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
11474
+ rows.push(...projects.items ? itemRows(declared.name, await projects.items(owner, board, template)) : [row$17(`project:${declared.name}:items`, `${declared.name}: items`, "skip", "the provider cannot list a board's items")]);
11331
11475
  } catch (err) {
11332
- rows.push(row$14(`project:${declared.name}`, title, "fail", describeError(err)));
11476
+ rows.push(row$17(`project:${declared.name}`, title, "fail", describeError(err)));
11333
11477
  }
11334
11478
  }
11335
11479
  return rows;
@@ -12249,19 +12393,19 @@ async function runDoctorRepo(input) {
12249
12393
  const rows = [];
12250
12394
  if (!loader.has("source")) {
12251
12395
  const why = whyMissing(loader, "source", "no `source` provider to read the repository with");
12252
- for (const check of checks) rows.push(row$13(check, { skip: why }));
12396
+ for (const check of checks) rows.push(row$16(check, { skip: why }));
12253
12397
  } else {
12254
12398
  const source = loader.get("source");
12255
12399
  for (const check of checks) {
12256
12400
  if (typeof source[check.needs] !== "function") {
12257
- rows.push(row$13(check, { skip: `provider does not implement ${check.needs}` }));
12401
+ rows.push(row$16(check, { skip: `provider does not implement ${check.needs}` }));
12258
12402
  continue;
12259
12403
  }
12260
12404
  try {
12261
- rows.push(row$13(check, await check.run(source)));
12405
+ rows.push(row$16(check, await check.run(source)));
12262
12406
  } catch (err) {
12263
12407
  const noToken = missingTokenReason(err);
12264
- if (noToken !== void 0) rows.push(row$13(check, { skip: noToken }));
12408
+ if (noToken !== void 0) rows.push(row$16(check, { skip: noToken }));
12265
12409
  else rows.push({
12266
12410
  id: check.id,
12267
12411
  title: check.title,
@@ -12287,7 +12431,7 @@ async function runDoctorRepo(input) {
12287
12431
  ...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
12288
12432
  };
12289
12433
  }
12290
- function row$13(check, result) {
12434
+ function row$16(check, result) {
12291
12435
  const { id, title } = check;
12292
12436
  if ("skip" in result) return {
12293
12437
  id,
@@ -12810,7 +12954,7 @@ function providerGroup(providerName) {
12810
12954
  }
12811
12955
  // src/commands/doctor-secrets/credentials-rows.ts
12812
12956
  /** A row for the provider as a whole, or for one of its variables when `name` is given. */
12813
- function row$12(provider, status, detail, name) {
12957
+ function row$15(provider, status, detail, name) {
12814
12958
  return name === void 0 ? {
12815
12959
  id: provider,
12816
12960
  title: provider,
@@ -12835,10 +12979,10 @@ async function credentialsRows(input) {
12835
12979
  const { loader } = input;
12836
12980
  const { resolved } = input.loaded;
12837
12981
  if (!resolved.providers.credentials) return {
12838
- rows: input.asked ? [row$12("credentials", "skip", "no `credentials` provider is configured")] : [],
12982
+ rows: input.asked ? [row$15("credentials", "skip", "no `credentials` provider is configured")] : [],
12839
12983
  places: []
12840
12984
  };
12841
- const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$12(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
12985
+ const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$15(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
12842
12986
  const places = [];
12843
12987
  if (!loader.has("credentials")) return {
12844
12988
  rows,
@@ -12850,7 +12994,7 @@ async function credentialsRows(input) {
12850
12994
  const tuple = tuples.find((t) => t.provider === impl.providerName);
12851
12995
  const explicit = tuple && credentialsEnvironment(tuple, resolved);
12852
12996
  if (!explicit && !derivesEnvironment(impl.providerName)) {
12853
- rows.push(row$12(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
12997
+ rows.push(row$15(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set"));
12854
12998
  continue;
12855
12999
  }
12856
13000
  try {
@@ -12862,7 +13006,7 @@ async function credentialsRows(input) {
12862
13006
  rows.push(...checked.rows);
12863
13007
  places.push(...checked.places);
12864
13008
  } catch (err) {
12865
- rows.push(row$12(impl.providerName, "fail", errorMessage(err)));
13009
+ rows.push(row$15(impl.providerName, "fail", errorMessage(err)));
12866
13010
  }
12867
13011
  }
12868
13012
  return {
@@ -12878,17 +13022,17 @@ async function credentialsRows(input) {
12878
13022
  async function checkProvider(impl, candidates, expected, synced) {
12879
13023
  const provider = impl.providerName;
12880
13024
  if (!impl.inspect) return {
12881
- rows: [row$12(provider, "skip", "cannot list the variables without reading their values")],
13025
+ rows: [row$15(provider, "skip", "cannot list the variables without reading their values")],
12882
13026
  places: []
12883
13027
  };
12884
13028
  if (expected.length === 0) return {
12885
- rows: [row$12(provider, "skip", "no configured plugin lists the tokens it takes")],
13029
+ rows: [row$15(provider, "skip", "no configured plugin lists the tokens it takes")],
12886
13030
  places: []
12887
13031
  };
12888
13032
  const inspect = impl.inspect.bind(impl);
12889
13033
  try {
12890
13034
  const { found, missing } = await tryEnvironments(candidates, inspect);
12891
- const rows = missing.map((name) => row$12(provider, "fail", `${provider} has no Environment named "${name}"`));
13035
+ const rows = missing.map((name) => row$15(provider, "fail", `${provider} has no Environment named "${name}"`));
12892
13036
  const group = providerGroup(provider);
12893
13037
  const unreadPlaces = missing.map((name) => ({
12894
13038
  column: {
@@ -12911,9 +13055,9 @@ async function checkProvider(impl, candidates, expected, synced) {
12911
13055
  const have = (name) => found.some((f) => f.result.names.includes(name));
12912
13056
  let present = 0;
12913
13057
  for (const { name, optional } of expected) if (have(name)) present++;
12914
- else if (optional) rows.push(row$12(provider, "skip", `optional, not set in ${where}`, name));
12915
- else rows.push(row$12(provider, "fail", `missing from ${where}`, name));
12916
- if (present > 0) rows.push(row$12(provider, "ok", `${present} of ${expected.length} tokens present in ${where}`, "tokens"));
13058
+ else if (optional) rows.push(row$15(provider, "skip", `optional, not set in ${where}`, name));
13059
+ else rows.push(row$15(provider, "fail", `missing from ${where}`, name));
13060
+ if (present > 0) rows.push(row$15(provider, "ok", `${present} of ${expected.length} tokens present in ${where}`, "tokens"));
12917
13061
  const names = new Set(expected.map((e) => e.name));
12918
13062
  const places = [];
12919
13063
  const missingRequired = expected.filter((e) => !e.optional && !have(e.name)).map((e) => e.name);
@@ -12952,7 +13096,7 @@ async function checkProvider(impl, candidates, expected, synced) {
12952
13096
  };
12953
13097
  } catch (err) {
12954
13098
  return {
12955
- rows: [row$12(provider, "fail", errorMessage(err))],
13099
+ rows: [row$15(provider, "fail", errorMessage(err))],
12956
13100
  places: []
12957
13101
  };
12958
13102
  }
@@ -13826,7 +13970,7 @@ async function variableRows(loader, config, org) {
13826
13970
  if (!loader.has("source")) {
13827
13971
  const why = whyMissing(loader, "source", "no `source` provider to read them with");
13828
13972
  for (const check of checks) {
13829
- rows.push(row$11(check, { skip: why }));
13973
+ rows.push(row$14(check, { skip: why }));
13830
13974
  observations.push({
13831
13975
  scope: check.scope,
13832
13976
  unread: why
@@ -13836,7 +13980,7 @@ async function variableRows(loader, config, org) {
13836
13980
  const source = loader.get("source");
13837
13981
  for (const check of checks) try {
13838
13982
  const result = await check.run(source);
13839
- rows.push(row$11(check, result));
13983
+ rows.push(row$14(check, result));
13840
13984
  observations.push("skip" in result ? {
13841
13985
  scope: check.scope,
13842
13986
  unread: result.skip
@@ -13847,7 +13991,7 @@ async function variableRows(loader, config, org) {
13847
13991
  } catch (err) {
13848
13992
  const noToken = missingTokenReason(err);
13849
13993
  if (noToken !== void 0) {
13850
- rows.push(row$11(check, { skip: noToken }));
13994
+ rows.push(row$14(check, { skip: noToken }));
13851
13995
  observations.push({
13852
13996
  scope: check.scope,
13853
13997
  unread: noToken
@@ -13873,7 +14017,7 @@ async function variableRows(loader, config, org) {
13873
14017
  observations
13874
14018
  };
13875
14019
  }
13876
- function row$11(check, result) {
14020
+ function row$14(check, result) {
13877
14021
  const { id, title } = check;
13878
14022
  if ("skip" in result) return {
13879
14023
  id,
@@ -13963,7 +14107,7 @@ function describeExpiry(expiresAt, now) {
13963
14107
  *
13964
14108
  * What a token may do is not checked: GitHub does not return a fine-grained token's permissions.
13965
14109
  */
13966
- function row$10(id, status, detail) {
14110
+ function row$13(id, status, detail) {
13967
14111
  return {
13968
14112
  id: `verify:${id}`,
13969
14113
  title: `verify ${id}`,
@@ -13991,12 +14135,12 @@ async function verifyRows(input) {
13991
14135
  try {
13992
14136
  module = await importer(pkg);
13993
14137
  } catch (err) {
13994
- rows.push(row$10(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
14138
+ rows.push(row$13(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
13995
14139
  continue;
13996
14140
  }
13997
14141
  for (const token of module.tokens ?? []) rows.push(await checkToken(token, module, env, readToken, now()));
13998
14142
  }
13999
- if (rows.length === 0) rows.push(row$10("tokens", "skip", "no configured plugin lists the tokens it takes"));
14143
+ if (rows.length === 0) rows.push(row$13("tokens", "skip", "no configured plugin lists the tokens it takes"));
14000
14144
  return rows;
14001
14145
  }
14002
14146
  /**
@@ -14009,30 +14153,30 @@ async function loadCredentials(input) {
14009
14153
  try {
14010
14154
  await input.loader.load();
14011
14155
  } catch (err) {
14012
- return [row$10("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
14156
+ return [row$13("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
14013
14157
  }
14014
- return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$10(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
14158
+ return input.loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$13(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
14015
14159
  }
14016
14160
  async function checkToken(token, module, env, readToken, now) {
14017
14161
  const { keyringKey, envName, vendorEnvName } = token;
14018
14162
  const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
14019
14163
  const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
14020
14164
  const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
14021
- if (!value) return row$10(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
14165
+ if (!value) return row$13(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron new token ${keyringKey}\`)`);
14022
14166
  const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
14023
- if (!verify) return row$10(keyringKey, "skip", "set, but its plugin cannot verify it");
14167
+ if (!verify) return row$13(keyringKey, "skip", "set, but its plugin cannot verify it");
14024
14168
  const from = fromEnv ?? stored?.source ?? "keyring";
14025
14169
  try {
14026
14170
  const verified = await verify(value);
14027
- if (!verified.ok) return row$10(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
14171
+ if (!verified.ok) return row$13(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
14028
14172
  const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
14029
- if (!expiry) return row$10(keyringKey, "ok", `${verified.subject} (${from})`);
14173
+ if (!expiry) return row$13(keyringKey, "ok", `${verified.subject} (${from})`);
14030
14174
  return expiry.soon ? {
14031
- ...row$10(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
14175
+ ...row$13(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
14032
14176
  problems: [`${expiry.text}: renew it`]
14033
- } : row$10(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
14177
+ } : row$13(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
14034
14178
  } catch (err) {
14035
- return row$10(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
14179
+ return row$13(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
14036
14180
  }
14037
14181
  }
14038
14182
  // src/commands/doctor-secrets/doctor-secrets.ts
@@ -14759,7 +14903,7 @@ function summariseProbeRows(id, title, rows) {
14759
14903
  * provider with no `token` probe, no declared layer, or one that cannot be read is a skip with the reason.
14760
14904
  */
14761
14905
  const PROBE = "token";
14762
- const row$9 = (id, title, status, detail, problems = []) => ({
14906
+ const row$12 = (id, title, status, detail, problems = []) => ({
14763
14907
  id,
14764
14908
  title,
14765
14909
  status,
@@ -14784,12 +14928,12 @@ async function runDoctorTokens(input) {
14784
14928
  try {
14785
14929
  tokens = await providerTokens(provider);
14786
14930
  } catch (err) {
14787
- rows.push(row$9(`tokens:${provider}`, provider, "skip", `could not read its tokens: ${describeError(err)}`));
14931
+ rows.push(row$12(`tokens:${provider}`, provider, "skip", `could not read its tokens: ${describeError(err)}`));
14788
14932
  continue;
14789
14933
  }
14790
14934
  const expectations = tokenExpectations(tokens);
14791
- if (expectations.length === 0) rows.push(row$9(`tokens:${provider}`, provider, "skip", "info: declares no token layers, nothing to check"));
14792
- else if (!usableProbe(probes.get(provider))) rows.push(row$9(`tokens:${provider}`, provider, "skip", `info: has no \`${PROBE}\` probe loaded, so its tokens are not checked`));
14935
+ if (expectations.length === 0) rows.push(row$12(`tokens:${provider}`, provider, "skip", "info: declares no token layers, nothing to check"));
14936
+ else if (!usableProbe(probes.get(provider))) rows.push(row$12(`tokens:${provider}`, provider, "skip", `info: has no \`${PROBE}\` probe loaded, so its tokens are not checked`));
14793
14937
  else declared.push({
14794
14938
  provider,
14795
14939
  tokens,
@@ -14851,14 +14995,14 @@ async function checkLayer(c) {
14851
14995
  tokens
14852
14996
  });
14853
14997
  } catch (err) {
14854
- if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$9(id(e), title(e), "fail", "not held in this layer", [err.message]));
14855
- return c.wanted.map((e) => row$9(id(e), title(e), "skip", `could not read the Environment: ${describeError(err)}`));
14998
+ if (err instanceof HoldsNoTokenError) return c.wanted.map((e) => row$12(id(e), title(e), "fail", "not held in this layer", [err.message]));
14999
+ return c.wanted.map((e) => row$12(id(e), title(e), "skip", `could not read the Environment: ${describeError(err)}`));
14856
15000
  }
14857
15001
  const rows = [];
14858
15002
  for (const e of c.wanted) {
14859
15003
  const token = held.held.find((h) => h.envName === e.envName);
14860
15004
  if (!token) {
14861
- rows.push(row$9(id(e), title(e), "fail", `not held in ${held.environment}`, [`${e.envName} is declared for ${c.layer}`]));
15005
+ rows.push(row$12(id(e), title(e), "fail", `not held in ${held.environment}`, [`${e.envName} is declared for ${c.layer}`]));
14862
15006
  continue;
14863
15007
  }
14864
15008
  rows.push(summariseProbeRows(id(e), title(e), await probeToken(c, e, token.token, held.plain)));
@@ -14931,7 +15075,7 @@ const doctorTokensCommand = {
14931
15075
  }
14932
15076
  };
14933
15077
  // src/commands/doctor-wiki/wiki-rows.ts
14934
- const row$8 = (id, title, status, detail, problems = []) => ({
15078
+ const row$11 = (id, title, status, detail, problems = []) => ({
14935
15079
  id,
14936
15080
  title,
14937
15081
  status,
@@ -14947,11 +15091,11 @@ const names = (paths) => paths.length > LISTED ? `${paths.slice(0, LISTED).join(
14947
15091
  * skip, since a machine with no network says nothing about the site.
14948
15092
  */
14949
15093
  function siteRow(id, title, probe, notFoundHint) {
14950
- if (probe.status === void 0) return row$8(id, title, "skip", `${probe.url}: ${probe.error ?? "no answer"}`);
14951
- if (probe.status < 400) return row$8(id, title, "ok", `${probe.url} answers ${probe.status}`);
14952
- if (probe.status === 401 || probe.status === 403) return row$8(id, title, "ok", `${probe.url} answers ${probe.status} (access is restricted)`);
15094
+ if (probe.status === void 0) return row$11(id, title, "skip", `${probe.url}: ${probe.error ?? "no answer"}`);
15095
+ if (probe.status < 400) return row$11(id, title, "ok", `${probe.url} answers ${probe.status}`);
15096
+ if (probe.status === 401 || probe.status === 403) return row$11(id, title, "ok", `${probe.url} answers ${probe.status} (access is restricted)`);
14953
15097
  const problem = probe.status === 404 ? `${probe.url} answers 404; ${notFoundHint}` : `${probe.url} answers ${probe.status}, expected a page`;
14954
- return row$8(id, title, "fail", `${probe.url} answers ${probe.status}`, [problem]);
15098
+ return row$11(id, title, "fail", `${probe.url} answers ${probe.status}`, [problem]);
14955
15099
  }
14956
15100
  /**
14957
15101
  * The rows `holocron doctor wiki` prints for one {@link WikiInspection}: organization, docs instance, the site and its
@@ -14963,42 +15107,42 @@ function wikiRows(found, providerName) {
14963
15107
  const { declared, found: foundOrg } = found.organization;
14964
15108
  if (foundOrg === null) {
14965
15109
  const problem = `fern/fern.config.json has no organization; \`holocron setup\` writes it`;
14966
- rows.push(row$8("wiki:organization", "organization is set", "fail", problem, [problem]));
15110
+ rows.push(row$11("wiki:organization", "organization is set", "fail", problem, [problem]));
14967
15111
  } else if (foundOrg !== declared) {
14968
15112
  const problem = `fern/fern.config.json names ${foundOrg}, the config declares ${declared}; run \`holocron setup\``;
14969
- rows.push(row$8("wiki:organization", "organization is set", "fail", `${foundOrg}, declared ${declared}`, [problem]));
14970
- } else rows.push(row$8("wiki:organization", "organization is set", "ok", `${declared} in fern/fern.config.json`));
15113
+ rows.push(row$11("wiki:organization", "organization is set", "fail", `${foundOrg}, declared ${declared}`, [problem]));
15114
+ } else rows.push(row$11("wiki:organization", "organization is set", "ok", `${declared} in fern/fern.config.json`));
14971
15115
  const instance = found.instance;
14972
15116
  if (instance === null) {
14973
15117
  const problem = "fern/docs.yml does not exist; `holocron setup` writes it";
14974
- rows.push(row$8("wiki:instance", "docs site is declared", "fail", problem, [problem]));
15118
+ rows.push(row$11("wiki:instance", "docs site is declared", "fail", problem, [problem]));
14975
15119
  } else {
14976
15120
  const problems = [];
14977
15121
  if (instance.foundUrl !== instance.expectedUrl) problems.push(`instance url is ${instance.foundUrl ?? "not set"}, expected ${instance.expectedUrl}`);
14978
15122
  if (instance.expectedDomain !== void 0 && instance.foundDomain !== instance.expectedDomain) problems.push(`custom-domain is ${instance.foundDomain ?? "not set"}, expected ${instance.expectedDomain}`);
14979
- rows.push(problems.length > 0 ? row$8("wiki:instance", "docs site is declared", "fail", `${problems.length} problem(s)`, [...problems.map((p) => `fern/docs.yml: ${p}`)]) : row$8("wiki:instance", "docs site is declared", "ok", `${instance.expectedUrl} in fern/docs.yml`));
15123
+ rows.push(problems.length > 0 ? row$11("wiki:instance", "docs site is declared", "fail", `${problems.length} problem(s)`, [...problems.map((p) => `fern/docs.yml: ${p}`)]) : row$11("wiki:instance", "docs site is declared", "ok", `${instance.expectedUrl} in fern/docs.yml`));
14980
15124
  }
14981
15125
  const [site, domain] = found.site;
14982
15126
  if (site) rows.push(siteRow("wiki:site", "docs site answers", site, `the organization or its docs are not published; run the wiki workflow (\`fern generate --docs\`)`));
14983
15127
  if (domain) rows.push(siteRow("wiki:domain", "custom domain answers", domain, `check the ${providerName} dashboard for the domain and \`holocron doctor dns\` for its record`));
14984
- if (found.navigation === null) rows.push(row$8("wiki:navigation", "navigation pages exist", "skip", "no fern/docs.yml to read"));
15128
+ if (found.navigation === null) rows.push(row$11("wiki:navigation", "navigation pages exist", "skip", "no fern/docs.yml to read"));
14985
15129
  else if (found.navigation.missing.length > 0) {
14986
15130
  const problems = found.navigation.missing.map((p) => `${p} is listed in fern/docs.yml but is not on disk`);
14987
- rows.push(row$8("wiki:navigation", "navigation pages exist", "fail", `${found.navigation.missing.length} missing`, problems));
15131
+ rows.push(row$11("wiki:navigation", "navigation pages exist", "fail", `${found.navigation.missing.length} missing`, problems));
14988
15132
  } else {
14989
- rows.push(row$8("wiki:navigation", "navigation pages exist", "ok", `${found.navigation.listed} listed pages exist`));
14990
- if (found.navigation.unlisted.length > 0) rows.push(row$8("wiki:unlisted", "pages under docs/wiki are listed", "skip", `info: ${found.navigation.unlisted.length} not in the navigation (${names(found.navigation.unlisted)}); they are not published`));
15133
+ rows.push(row$11("wiki:navigation", "navigation pages exist", "ok", `${found.navigation.listed} listed pages exist`));
15134
+ if (found.navigation.unlisted.length > 0) rows.push(row$11("wiki:unlisted", "pages under docs/wiki are listed", "skip", `info: ${found.navigation.unlisted.length} not in the navigation (${names(found.navigation.unlisted)}); they are not published`));
14991
15135
  }
14992
15136
  const published = found.published;
14993
15137
  const listed = found.navigation?.listed;
14994
- if (!published) rows.push(row$8("wiki:published", "published pages", "skip", "the site's page index could not be asked"));
15138
+ if (!published) rows.push(row$11("wiki:published", "published pages", "skip", "the site's page index could not be asked"));
14995
15139
  else if (published.pages === void 0) {
14996
15140
  const why = published.status === void 0 ? published.error ?? "no answer" : `answered ${published.status}`;
14997
- rows.push(row$8("wiki:published", "published pages", "skip", `${published.url}: ${why}`));
15141
+ rows.push(row$11("wiki:published", "published pages", "skip", `${published.url}: ${why}`));
14998
15142
  } else if (listed !== void 0 && published.pages < listed) {
14999
15143
  const problem = `${published.url} lists ${published.pages} page(s), the navigation lists ${listed}; the last publish is behind (run the wiki workflow)`;
15000
- rows.push(row$8("wiki:published", "published pages", "fail", `${published.pages} of ${listed}`, [problem]));
15001
- } else rows.push(row$8("wiki:published", "published pages", "ok", listed === void 0 ? `${published.pages} page(s) in ${published.url}` : `${published.pages} page(s) published for ${listed} listed`));
15144
+ rows.push(row$11("wiki:published", "published pages", "fail", `${published.pages} of ${listed}`, [problem]));
15145
+ } else rows.push(row$11("wiki:published", "published pages", "ok", listed === void 0 ? `${published.pages} page(s) in ${published.url}` : `${published.pages} page(s) published for ${listed} listed`));
15002
15146
  return rows;
15003
15147
  }
15004
15148
  // src/commands/doctor-wiki/doctor-wiki.ts
@@ -15052,6 +15196,295 @@ async function runDoctorWiki(input) {
15052
15196
  ...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
15053
15197
  };
15054
15198
  }
15199
+ // src/commands/doctor-wiki/doctor-wiki.command.ts
15200
+ const doctorWikiCommand = {
15201
+ command: "wiki",
15202
+ describe: "Check the wiki's organization, docs site, domain and published pages (read-only)",
15203
+ handler: async (argv) => {
15204
+ const tokens = tokenContext(argv.token);
15205
+ if (!tokens) return;
15206
+ const loaded = await loadConfig(argv.cwd);
15207
+ applyResolvedConfig(argv, loaded.resolved);
15208
+ if ((await runDoctorWiki({
15209
+ loaded,
15210
+ context: {
15211
+ repoRoot: argv.cwd,
15212
+ ...tokens,
15213
+ org: resolveOrg(argv, loaded.resolved)
15214
+ }
15215
+ })).status === "fail") process.exitCode = 1;
15216
+ }
15217
+ };
15218
+ // src/commands/doctor-workers/read-failure.ts
15219
+ /**
15220
+ * The row for a read that threw: a skip when the token is missing or the provider refused it (401, 403: the token may
15221
+ * simply not reach this), a failure for anything else. The status is read off the error rather than with `instanceof`,
15222
+ * because the CLI and a plugin may each hold their own copy of the error class.
15223
+ */
15224
+ function readFailureRow(id, title, err) {
15225
+ const noToken = missingTokenReason(err);
15226
+ if (noToken !== void 0) return {
15227
+ id,
15228
+ title,
15229
+ status: "skip",
15230
+ detail: noToken,
15231
+ problems: []
15232
+ };
15233
+ const status = err?.status;
15234
+ if (status === 401 || status === 403) return {
15235
+ id,
15236
+ title,
15237
+ status: "skip",
15238
+ detail: `not readable with this token (${status})`,
15239
+ problems: []
15240
+ };
15241
+ const detail = describeError(err);
15242
+ return {
15243
+ id,
15244
+ title,
15245
+ status: "fail",
15246
+ detail,
15247
+ problems: [detail]
15248
+ };
15249
+ }
15250
+ // src/commands/doctor-workers/check-project.ts
15251
+ const row$10 = (id, title, status, detail, problems = []) => ({
15252
+ id,
15253
+ title,
15254
+ status,
15255
+ detail,
15256
+ problems
15257
+ });
15258
+ const same$1 = (a, b) => a.toLowerCase() === b.toLowerCase();
15259
+ /**
15260
+ * The rows for one declared deployment project: it exists, its custom domain (when one is declared) is attached, and
15261
+ * the newest production deployment is healthy. A step the provider cannot do, or a token that cannot read it, is a
15262
+ * skip; a project that is not there fails and the steps that need it are skipped.
15263
+ */
15264
+ async function checkProject(deploy, declared) {
15265
+ const project = declared.project;
15266
+ const ids = {
15267
+ exists: `deployment:${project}:exists`,
15268
+ domain: `deployment:${project}:domain`,
15269
+ deploy: `deployment:${project}:deployment`
15270
+ };
15271
+ const titles = {
15272
+ exists: `${project} project exists`,
15273
+ domain: `${project} has its custom domain`,
15274
+ deploy: `${project} latest deployment is healthy`
15275
+ };
15276
+ const rows = [];
15277
+ let exists = false;
15278
+ try {
15279
+ exists = (await deploy.listProjects()).some((p) => same$1(p.name, project) || p.id === project);
15280
+ rows.push(exists ? row$10(ids.exists, titles.exists, "ok", `${project} on ${deploy.providerName}`) : row$10(ids.exists, titles.exists, "fail", "not found", [`no project ${project} on ${deploy.providerName}; \`holocron setup\` makes it`]));
15281
+ } catch (err) {
15282
+ rows.push(readFailureRow(ids.exists, titles.exists, err));
15283
+ }
15284
+ const notChecked = (reason) => `not checked: ${reason}`;
15285
+ const gone = exists ? void 0 : "the project is not readable or not there";
15286
+ if (declared.hostname === void 0) {} else if (gone) rows.push(row$10(ids.domain, titles.domain, "skip", notChecked(gone)));
15287
+ else if (!deploy.listDomains) rows.push(row$10(ids.domain, titles.domain, "skip", `the \`${deploy.providerName}\` provider cannot list domains`));
15288
+ else try {
15289
+ const attached = await deploy.listDomains(project);
15290
+ rows.push(attached.some((d) => same$1(d, declared.hostname)) ? row$10(ids.domain, titles.domain, "ok", `${declared.hostname} attached`) : row$10(ids.domain, titles.domain, "fail", `${declared.hostname} not attached`, [`${declared.hostname} is not a domain of ${project}; \`holocron setup\` attaches it`]));
15291
+ } catch (err) {
15292
+ rows.push(readFailureRow(ids.domain, titles.domain, err));
15293
+ }
15294
+ if (gone) rows.push(row$10(ids.deploy, titles.deploy, "skip", notChecked(gone)));
15295
+ else if (!deploy.latestDeployment) rows.push(row$10(ids.deploy, titles.deploy, "skip", `the \`${deploy.providerName}\` provider cannot list deployments`));
15296
+ else try {
15297
+ const latest = await deploy.latestDeployment(project);
15298
+ if (!latest) rows.push(row$10(ids.deploy, titles.deploy, "skip", "no production deployment yet"));
15299
+ else if (latest.status === "ready") rows.push(row$10(ids.deploy, titles.deploy, "ok", latest.createdAt ? `ready, ${latest.createdAt}` : "ready"));
15300
+ else if (latest.status === "error") {
15301
+ const why = latest.errorMessage ? `: ${latest.errorMessage}` : "";
15302
+ rows.push(row$10(ids.deploy, titles.deploy, "fail", "the newest deployment errored", [`the newest production deployment of ${project} failed${why}`]));
15303
+ } else rows.push(row$10(ids.deploy, titles.deploy, "skip", `info: the newest deployment is ${latest.status}`));
15304
+ } catch (err) {
15305
+ rows.push(readFailureRow(ids.deploy, titles.deploy, err));
15306
+ }
15307
+ return rows;
15308
+ }
15309
+ // src/commands/doctor-workers/check-worker.ts
15310
+ const same = (a, b) => a.toLowerCase() === b.toLowerCase();
15311
+ const row$9 = (id, title, status, detail, problems = []) => ({
15312
+ id,
15313
+ title,
15314
+ status,
15315
+ detail,
15316
+ problems
15317
+ });
15318
+ /**
15319
+ * The rows for one declared Worker: its script is deployed and has the route for its host, it has the bindings it
15320
+ * needs (names only, a value is never read), and its newest deployment serves all traffic. A step the provider cannot
15321
+ * do is a skip, and a later step is skipped when the script is not there to read.
15322
+ */
15323
+ async function checkWorker(workers, worker) {
15324
+ const name = worker.label;
15325
+ const ids = {
15326
+ deployed: `workers:${name}:deployed`,
15327
+ bindings: `workers:${name}:bindings`,
15328
+ deploy: `workers:${name}:deployment`
15329
+ };
15330
+ const titles = {
15331
+ deployed: `${name} Worker is deployed and routed`,
15332
+ bindings: `${name} Worker has its bindings`,
15333
+ deploy: `${name} Worker's latest deployment is healthy`
15334
+ };
15335
+ const skipAll = (reason) => [
15336
+ row$9(ids.deployed, titles.deployed, "skip", reason),
15337
+ row$9(ids.bindings, titles.bindings, "skip", reason),
15338
+ row$9(ids.deploy, titles.deploy, "skip", reason)
15339
+ ];
15340
+ if (worker.script === void 0) return skipAll(`${workers.providerName} does not say how it names this Worker`);
15341
+ const script = worker.script;
15342
+ if (!workers.inspectScript) return skipAll(`the \`${workers.providerName}\` provider cannot read its Workers`);
15343
+ const rows = [];
15344
+ const route = `${worker.host}/*`;
15345
+ let exists = false;
15346
+ try {
15347
+ const state = await workers.inspectScript(script, worker.host);
15348
+ exists = state.exists;
15349
+ if (!state.exists) {
15350
+ const problem = `no Worker named ${script}; \`holocron setup\` deploys it`;
15351
+ rows.push(row$9(ids.deployed, titles.deployed, "fail", `${script} not deployed`, [problem]), row$9(ids.bindings, titles.bindings, "skip", `not checked: no Worker named ${script}`));
15352
+ } else {
15353
+ rows.push(state.routes.some((r) => same(r, route)) ? row$9(ids.deployed, titles.deployed, "ok", `${script} serves ${route}`) : row$9(ids.deployed, titles.deployed, "fail", `no route ${route}`, [`${script} has no route ${route}`]));
15354
+ if (worker.bindings.length === 0) rows.push(row$9(ids.bindings, titles.bindings, "ok", "none declared"));
15355
+ else {
15356
+ const bound = new Set(state.bindingNames.map((n) => n.toUpperCase()));
15357
+ const missing = worker.bindings.filter((n) => !bound.has(n.toUpperCase()));
15358
+ rows.push(missing.length === 0 ? row$9(ids.bindings, titles.bindings, "ok", `${worker.bindings.length} of ${worker.bindings.length} bound`) : row$9(ids.bindings, titles.bindings, "fail", `${missing.length} not bound`, missing.map((n) => `${n}: not bound`)));
15359
+ }
15360
+ }
15361
+ } catch (err) {
15362
+ const failure = readFailureRow(ids.deployed, titles.deployed, err);
15363
+ rows.push(failure, row$9(ids.bindings, titles.bindings, "skip", "not checked: could not read the Worker"));
15364
+ }
15365
+ if (!exists) rows.push(row$9(ids.deploy, titles.deploy, "skip", "not checked: the Worker is not readable or not there"));
15366
+ else if (!workers.latestDeployment) rows.push(row$9(ids.deploy, titles.deploy, "skip", `the \`${workers.providerName}\` provider cannot list deployments`));
15367
+ else try {
15368
+ const latest = await workers.latestDeployment(script);
15369
+ if (!latest) rows.push(row$9(ids.deploy, titles.deploy, "skip", `${script} has no recorded deployment`));
15370
+ else if (!latest.active) {
15371
+ const problem = `the newest deployment of ${script} does not serve all traffic`;
15372
+ rows.push(row$9(ids.deploy, titles.deploy, "fail", "not serving all traffic", [problem]));
15373
+ } else rows.push(row$9(ids.deploy, titles.deploy, "ok", latest.createdAt ? `deployed ${latest.createdAt}` : "serving all traffic"));
15374
+ } catch (err) {
15375
+ rows.push(readFailureRow(ids.deploy, titles.deploy, err));
15376
+ }
15377
+ return rows;
15378
+ }
15379
+ // src/commands/doctor-workers/declared-projects.ts
15380
+ /**
15381
+ * The deployment projects `holocron setup` makes: the preview project (and its domain) when the config carries a
15382
+ * preview configuration, otherwise one named like the repo, with the provider's own `domain` when it has one.
15383
+ */
15384
+ function declaredProjects(config, deploy) {
15385
+ const preview = previewConfigOf(config);
15386
+ if (preview) return [{
15387
+ project: preview.project,
15388
+ ...preview.domain ? { hostname: preview.domain } : {}
15389
+ }];
15390
+ return [{
15391
+ project: config.name,
15392
+ ...deploy.domain ? { hostname: deploy.domain } : {}
15393
+ }];
15394
+ }
15395
+ // src/commands/doctor-workers/declared-workers.ts
15396
+ /**
15397
+ * The Workers the config makes `holocron setup` deploy: the relay Worker of each notifications layout that feeds an
15398
+ * error tracker (`relay.host`, its `script` or the default name, and the two bindings the relay reads for the tracker,
15399
+ * when one is configured), and the reverse proxy of a wiki that has a custom domain behind one. A proxy Worker whose
15400
+ * provider does not say how it names it has `script: undefined`, which the check reports as a skip.
15401
+ */
15402
+ function declaredWorkers(input) {
15403
+ const declared = [];
15404
+ for (const layout of input.layouts) {
15405
+ const relay = layout.relay;
15406
+ if (!relay?.host || !wantsRelay(layout)) continue;
15407
+ declared.push({
15408
+ label: "relay",
15409
+ script: relay.script ?? "comlink",
15410
+ host: relay.host,
15411
+ bindings: input.errors ? [relayWebhookBinding(input.errors.providerName), relaySecretBinding(input.errors.providerName)] : []
15412
+ });
15413
+ }
15414
+ const proxied = input.wiki?.proxyConfig?.() ? input.wiki.dnsRecord?.() : null;
15415
+ if (proxied) {
15416
+ const host = proxied.record.name;
15417
+ declared.push({
15418
+ label: "wiki proxy",
15419
+ script: input.workers?.proxyScriptName?.(host),
15420
+ host,
15421
+ bindings: []
15422
+ });
15423
+ }
15424
+ return declared;
15425
+ }
15426
+ // src/commands/doctor-workers/doctor-workers.ts
15427
+ /**
15428
+ * `holocron doctor workers` — do the Workers and deployment projects the config declares exist, route and deploy?
15429
+ *
15430
+ * Read-only: it never deploys, routes or binds anything, and prints names, hostnames and times only, never a secret
15431
+ * value or a token. For each declared Worker (the relay Worker of a notifications layout, a wiki's reverse proxy):
15432
+ * the script is deployed with its route, has the bindings it needs (by name), and its newest deployment serves all
15433
+ * traffic. For each deployment project `setup` makes (the preview project, or one named like the repo): it exists, its
15434
+ * custom domain is attached, and the newest production deployment is ready. Only what the provider proves wrong
15435
+ * fails; a missing token, a 401 or 403, or a provider that cannot read it is a skip with the reason.
15436
+ */
15437
+ const row$8 = (id, title, status, detail) => ({
15438
+ id,
15439
+ title,
15440
+ status,
15441
+ detail,
15442
+ problems: []
15443
+ });
15444
+ /** Why a capability is not there: the plugin failed to load, or none is configured. */
15445
+ function whyNone(loader, key, fallback) {
15446
+ const failure = loader.loadFailures().find((f) => f.key === key);
15447
+ return failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : fallback;
15448
+ }
15449
+ async function runDoctorWorkers(input) {
15450
+ const print = input.print ?? ((line) => console.log(line));
15451
+ const logger = input.logger ?? getLogger();
15452
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
15453
+ await loader.load();
15454
+ assertPluginsResolvable(loader, "doctor workers");
15455
+ const rows = [];
15456
+ const workers = loader.has("workers") ? loader.get("workers") : void 0;
15457
+ const declared = declaredWorkers({
15458
+ layouts: (loader.has("notifications") ? loader.get("notifications") : []).flatMap((p) => p.layout ? [p.layout] : []),
15459
+ ...loader.has("errors") ? { errors: loader.get("errors") } : {},
15460
+ ...loader.has("wiki") ? { wiki: loader.get("wiki") } : {},
15461
+ ...workers ? { workers } : {}
15462
+ });
15463
+ if (declared.length === 0) rows.push(row$8("workers", "declared Workers", "ok", "none declared"));
15464
+ else if (!workers) {
15465
+ const why = whyNone(loader, "workers", "no `workers` provider is configured in holocron.config.ts");
15466
+ for (const worker of declared) rows.push(row$8(`workers:${worker.label}`, `${worker.label} Worker`, "skip", why));
15467
+ } else for (const worker of declared) rows.push(...await checkWorker(workers, worker));
15468
+ if (!loader.has("deployment")) rows.push(row$8("deployment", "deployment project", "skip", whyNone(loader, "deployment", "no `deployment` provider is configured in holocron.config.ts")));
15469
+ else {
15470
+ const deploy = loader.get("deployment");
15471
+ for (const project of declaredProjects(input.loaded.resolved, deploy)) rows.push(...await checkProject(deploy, project));
15472
+ }
15473
+ printCheckRows(rows, print);
15474
+ const summary = summariseChecks(rows);
15475
+ printCheckSummary(summary, print);
15476
+ const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
15477
+ logger.info({
15478
+ ...summary,
15479
+ status
15480
+ }, "doctor workers");
15481
+ return {
15482
+ status,
15483
+ rows,
15484
+ summary,
15485
+ ...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
15486
+ };
15487
+ }
15055
15488
  // src/commands/deep-checks/deep-checks.ts
15056
15489
  /**
15057
15490
  * Every `doctor <capability>` deep check, in the order `doctor --all` runs them. Adding one is an entry here
@@ -15231,15 +15664,41 @@ const DEEP_CHECKS = [
15231
15664
  {
15232
15665
  name: "wiki",
15233
15666
  capability: "wiki",
15667
+ command: doctorWikiCommand,
15668
+ async run(input) {
15669
+ const report = await runDoctorWiki(input);
15670
+ return {
15671
+ status: report.status,
15672
+ summary: report.summary,
15673
+ ...report.reason ? { reason: report.reason } : {}
15674
+ };
15675
+ }
15676
+ },
15677
+ {
15678
+ name: "errors",
15679
+ capability: "errors",
15680
+ command: doctorErrorsCommand,
15681
+ async run(input) {
15682
+ const report = await runDoctorErrors(input);
15683
+ return {
15684
+ status: report.status,
15685
+ summary: report.summary,
15686
+ ...report.reason ? { reason: report.reason } : {}
15687
+ };
15688
+ }
15689
+ },
15690
+ {
15691
+ name: "workers",
15692
+ capability: "workers",
15234
15693
  command: {
15235
- command: "wiki",
15236
- describe: "Check the wiki's organization, docs site, domain and published pages (read-only)",
15694
+ command: "workers",
15695
+ describe: "Check the declared Workers and deployment projects: they exist, route and deploy healthily (read-only)",
15237
15696
  handler: async (argv) => {
15238
15697
  const tokens = tokenContext(argv.token);
15239
15698
  if (!tokens) return;
15240
15699
  const loaded = await loadConfig(argv.cwd);
15241
15700
  applyResolvedConfig(argv, loaded.resolved);
15242
- if ((await runDoctorWiki({
15701
+ if ((await runDoctorWorkers({
15243
15702
  loaded,
15244
15703
  context: {
15245
15704
  repoRoot: argv.cwd,
@@ -15250,7 +15709,7 @@ const DEEP_CHECKS = [
15250
15709
  }
15251
15710
  },
15252
15711
  async run(input) {
15253
- const report = await runDoctorWiki(input);
15712
+ const report = await runDoctorWorkers(input);
15254
15713
  return {
15255
15714
  status: report.status,
15256
15715
  summary: report.summary,
@@ -22870,6 +23329,35 @@ const newCommand = {
22870
23329
  builder: (y) => y.command(newRepoCommand).command(pluginCreateCommand).command(notificationsChannelAddCommand).command(githubAppCreateCommand).command(projectCreateCommand).command(secretSetCommand).command(notificationsCreateServerCommand).command(ideasPromoteCommand).command(issueCreateCommand).command(authSetCommand).command(tunnelUpCommand).command(newDomainCommand).command(groupMenu("new")),
22871
23330
  handler: () => {}
22872
23331
  };
23332
+ // src/commands/open-requests/parse-open-layers/parse-open-layers.ts
23333
+ /**
23334
+ * The layers `open requests` can fill, in the order they are listed. `ci` and `test` are left out on purpose: the request
23335
+ * tool is a person at a machine, and neither layer is one it signs requests for.
23336
+ */
23337
+ const OPEN_LAYERS = [
23338
+ "local",
23339
+ "dev",
23340
+ "prod"
23341
+ ];
23342
+ /**
23343
+ * Turns the `--environment` values into the layers to load. Each value may itself be a comma-separated list, so
23344
+ * `--environment dev,local` and `--environment dev --environment local` mean the same. Duplicates are collapsed, spaces
23345
+ * around a name are ignored, and the result is in {@link OPEN_LAYERS} order whatever order was typed. With no value the
23346
+ * result is `dev` alone.
23347
+ *
23348
+ * @param values - The raw `--environment` values, or `undefined` when the flag was not given.
23349
+ * @throws {ConfigError} For a name that is not one of {@link OPEN_LAYERS}, or an empty one; the message lists the allowed ones.
23350
+ */
23351
+ function parseOpenLayers(values) {
23352
+ if (!values || values.length === 0) return ["dev"];
23353
+ const names = values.flatMap((value) => value.split(",").map((name) => name.trim()));
23354
+ const unknown = [...new Set(names.filter((name) => !OPEN_LAYERS.includes(name)))];
23355
+ if (unknown.length > 0) {
23356
+ const shown = unknown.map((name) => name === "" ? "(empty)" : JSON.stringify(name)).join(", ");
23357
+ throw new ConfigError$1(`--environment does not know ${shown}: use ${OPEN_LAYERS.join(", ")}, comma-separated or repeated`);
23358
+ }
23359
+ return OPEN_LAYERS.filter((layer) => names.includes(layer));
23360
+ }
22873
23361
  // src/commands/open-requests/read-entry-values/read-entry-values.ts
22874
23362
  /**
22875
23363
  * The values of the named entries of one vault Environment, read in memory. Only an Environment this repo uses is read:
@@ -23044,7 +23532,7 @@ async function runOpenRequests(input) {
23044
23532
  ...input.deps
23045
23533
  };
23046
23534
  const dryRun = Boolean(input.context.dryRun);
23047
- const environment = input.environment ?? "dev";
23535
+ const layers = parseOpenLayers(input.environments);
23048
23536
  const { repoRoot } = input.context;
23049
23537
  const rows = [];
23050
23538
  const say = (next) => {
@@ -23092,10 +23580,13 @@ async function runOpenRequests(input) {
23092
23580
  say(row$4(tool.providerName, "fail", describeError(err)));
23093
23581
  return finish();
23094
23582
  }
23095
- const names = [...new Set(plan.wants.map((w) => w.entry))].sort();
23583
+ const loaded = plan.wants.filter((want) => layers.includes(want.layer));
23584
+ const notLoaded = plan.wants.filter((want) => !layers.includes(want.layer));
23585
+ const names = [...new Set(loaded.map((want) => want.name))].sort();
23096
23586
  if (plan.unfilled.length > 0) say(row$4("unfilled", "skip", `${plan.unfilled.length} secret variable(s) refer to no entry, so nobody fills them`, plan.unfilled));
23587
+ say(row$4("layers", notLoaded.length > 0 ? "skip" : "ok", `loaded: ${layers.join(", ")}; not loaded: ${OPEN_LAYERS.filter((layer) => !layers.includes(layer)).join(", ") || "none"}`, notLoaded.map((want) => `${want.collection}: ${want.variable} is a ${want.layer} secret (${want.name}); start with --environment ${want.layer} to load it`)));
23097
23588
  if (dryRun) {
23098
- for (const want of plan.wants) say(row$4(want.variable, "ok", `would fill ${want.collection}'s ${want.variable} from ${want.entry} of ${environment}`));
23589
+ for (const want of loaded) say(row$4(want.variable, "ok", `would fill ${want.collection}'s ${want.variable} from ${want.entry} of ${want.layer} as ${want.name}`));
23099
23590
  if (names.length === 0) say(row$4("secrets", "ok", "nothing to fill: no variable refers to an entry"));
23100
23591
  else say(row$4("secrets", "ok", `would write ${names.length} value(s) to ${SECRETS_FILE} and link it from ${plan.targets.length} collection(s)`));
23101
23592
  say(row$4(plan.app, "ok", `would start ${plan.launch.command} in the foreground`));
@@ -23121,35 +23612,45 @@ async function runOpenRequests(input) {
23121
23612
  if (!await (input.confirm ?? ((message) => confirm({
23122
23613
  message,
23123
23614
  default: false
23124
- })))(names.length === 0 ? `Start ${plan.app} (nothing to fill)?` : `Read ${names.length} value(s) from ${environment} and start ${plan.app} with them?`)) {
23615
+ })))(names.length === 0 ? `Start ${plan.app} (nothing to fill)?` : `Read ${names.length} value(s) from ${layers.join(", ")} and start ${plan.app} with them?`)) {
23125
23616
  print(` ${style.skip("cancelled; nothing was read or written")}`);
23126
23617
  return finish("cancelled");
23127
23618
  }
23128
23619
  }
23129
- let values = /* @__PURE__ */ new Map();
23620
+ const values = /* @__PURE__ */ new Map();
23130
23621
  if (names.length > 0) {
23131
23622
  const vault = loader.has("vault") ? loader.get("vault") : void 0;
23132
23623
  if (!vault?.readEnvironmentEntries) {
23133
23624
  say(row$4("vault", "fail", vault ? `${vault.providerName} cannot read an Environment's entries` : "needs a `vault` provider in holocron.config.ts (1password)"));
23134
23625
  return finish();
23135
23626
  }
23136
- let read;
23137
- try {
23138
- read = await readEntryValues({
23139
- vault,
23140
- environment,
23141
- configured: ownerEnvironments(input.loaded.resolved).names,
23142
- repoRoot,
23143
- names
23144
- });
23145
- } catch (err) {
23146
- say(row$4(`vault ${environment}`, "fail", describeError(err)));
23147
- return finish();
23627
+ let failed = false;
23628
+ for (const layer of layers) {
23629
+ const wanted = loaded.filter((want) => want.layer === layer);
23630
+ if (wanted.length === 0) continue;
23631
+ let read;
23632
+ try {
23633
+ read = await readEntryValues({
23634
+ vault,
23635
+ environment: layer,
23636
+ configured: ownerEnvironments(input.loaded.resolved).names,
23637
+ repoRoot,
23638
+ names: [...new Set(wanted.map((want) => want.entry))].sort()
23639
+ });
23640
+ } catch (err) {
23641
+ say(row$4(`vault ${layer}`, "fail", describeError(err)));
23642
+ failed = true;
23643
+ continue;
23644
+ }
23645
+ for (const entry of read.missing) {
23646
+ say(row$4(`${layer} ${entry}`, "fail", `${read.environmentId} holds no value for ${entry}`));
23647
+ failed = true;
23648
+ }
23649
+ if (read.missing.length > 0) continue;
23650
+ for (const want of wanted) values.set(want.name, read.values.get(want.entry));
23651
+ say(row$4(`vault ${read.environmentId}`, "ok", `${wanted.length} value(s) read: ${[...new Set(wanted.map((want) => want.name))].join(", ")}`));
23148
23652
  }
23149
- for (const name of read.missing) say(row$4(name, "fail", `${read.environmentId} holds no value for ${name}`));
23150
- if (read.missing.length > 0) return finish();
23151
- values = read.values;
23152
- say(row$4(`vault ${read.environmentId}`, "ok", `${names.length} value(s) read: ${names.join(", ")}`));
23653
+ if (failed) return finish();
23153
23654
  }
23154
23655
  const secrets = resolve(repoRoot, SECRETS_FILE);
23155
23656
  const lock = resolve(repoRoot, LOCK_FILE);
@@ -23233,7 +23734,8 @@ const openRequestsCommand = {
23233
23734
  describe: "Open the request tool's workspace with its secrets filled in from the layer's vault Environment",
23234
23735
  builder: (y) => y.option("environment", {
23235
23736
  type: "string",
23236
- describe: "The layer (`local`, `dev`, `ci`, `prod`) or Environment to read the secrets from (default: `dev`)"
23737
+ array: true,
23738
+ describe: "The layers to read the secrets from: `local`, `dev` or `prod`, repeated or comma-separated (default: `dev` alone; `prod` only when named)"
23237
23739
  }).option("to", {
23238
23740
  type: "string",
23239
23741
  describe: "Open only for this tooling provider (needed when more than one can open its workspace)"
@@ -23254,7 +23756,7 @@ const openRequestsCommand = {
23254
23756
  ...tokens,
23255
23757
  org: resolveOrg(argv, loaded.resolved)
23256
23758
  },
23257
- ...argv.environment ? { environment: argv.environment } : {},
23759
+ ...argv.environment ? { environments: argv.environment } : {},
23258
23760
  ...argv.to ? { to: argv.to } : {},
23259
23761
  ...argv.yes ? { yes: true } : {}
23260
23762
  })).status === "fail") process.exitCode = 1;