@theholocron/cli 5.0.0-alpha.266 → 5.0.0-alpha.268

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/README.md CHANGED
@@ -188,13 +188,14 @@ A minimal config — for repos with a `package.json` and a GitHub remote
188
188
 
189
189
  Additional `repo` fields recognised by `holocron repo setup`:
190
190
 
191
- | Field | Type | Description |
192
- | ----------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
193
- | `repo.teams` | `Array<string \| { slug, permission }>` | GitHub teams granted repo access. String shorthand defaults to `push` (Write). `holocron repo setup` also writes `.github/CODEOWNERS` for teams with `push`/`maintain`/`admin`. |
194
- | `repo.topics` | `string[]` | GitHub topics set on the repository. |
195
- | `repo.protection` | `"balanced" \| "strict" \| "none"` | Branch-protection preset applied by `holocron repo setup`. For `"strict"`, the required status checks are derived from the task manifest — see below. |
196
- | `repo.properties` | `RepoProperties` | Org-level custom property values synced to the GitHub dashboard. |
197
- | `repo.variables` | `{ repo?, org?, prune? }` | GitHub Actions variables created and updated by `holocron repo setup`. Undeclared ones are left alone unless `prune` is on. |
191
+ | Field | Type | Description |
192
+ | ----------------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
193
+ | `repo.teams` | `Array<string \| { slug, permission }>` | GitHub teams granted repo access. String shorthand defaults to `push` (Write). `holocron repo setup` also writes `.github/CODEOWNERS` for teams with `push`/`maintain`/`admin`. |
194
+ | `repo.topics` | `string[]` | GitHub topics set on the repository. |
195
+ | `repo.protection` | `"balanced" \| "strict" \| "none"` | Branch-protection preset applied by `holocron repo setup`. For `"strict"`, the required status checks are derived from the task manifest — see below. |
196
+ | `repo.properties` | `RepoProperties` | Org-level custom property values synced to the GitHub dashboard. |
197
+ | `repo.variables` | `{ repo?, org?, prune? }` | GitHub Actions variables created and updated by `holocron repo setup`. Undeclared ones are left alone unless `prune` is on. |
198
+ | `repo.secrets` | `{ repo?, org?, environments? }` | Names of the secrets that must exist, checked (never written) by `holocron doctor secrets`. Names only. The notification layout's secrets and a Chromatic project token are expected without being listed. |
198
199
 
199
200
  ### Custom properties synced to GitHub
200
201
 
@@ -539,17 +540,19 @@ A `notifications` provider can declare a whole server in `holocron.config.ts`
539
540
  pinned messages, onboarding, the bot application) and the CLI applies and checks it. The
540
541
  commands and the config are provider-neutral; Discord is the first provider.
541
542
 
542
- | Command | What it does |
543
- | -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
544
- | `holocron notifications setup` | Applies the layout; looks everything up by name first, so a re-run changes nothing that matches |
545
- | `holocron notifications channel add <name>` | Creates one channel (optionally with a webhook whose URL is stored as a secret) |
546
- | `holocron notifications create-server --name <n> --owner <id>` | Creates the server the layout describes, writes its id into the config, applies the layout, invites the owner, waits for them to join and hands the server over (`--resume` finishes an interrupted hand-over; `--force` allows a second server) |
547
- | `holocron notifications link` | Links your account on the provider to your GitHub account by signing in with the provider (OAuth, nothing secret kept) |
548
- | `holocron notifications sync-roles` | Makes who holds a role match a GitHub team, through the links file (`--keep` only adds; `--provider` picks one) |
549
- | `holocron doctor notifications [--built-only] [--deliver]` | Step by step: does the server match the layout, do the secrets exist, and does a person (not the bot) own it. A full run also leaves one `🧪 test:` post in the layout's `testChannel`; `--built-only` posts nothing; `--deliver` posts to every channel and removes each post |
550
- | `holocron doctor variables` | Do the Actions variables `repo.variables` declares exist, with those values (and, for the organization's, that visibility)? One row for the repository and one for the organization, each only when declared. Read-only. An undeclared variable counts only with `prune`; a scope that cannot be read (no provider, no org token) is a skip, not a failure |
551
- | `holocron doctor --all` | Runs every deep check (`doctor notifications`, `doctor variables`, ...) and prints one row each, then `N ok, N fail, N skipped` counted in checks. Exits 1 when any check failed. A check that cannot run (no provider, no token) is a skip with the reason. Read-only: notifications runs as `--built-only`, so it posts nothing |
552
- | `holocron probe [<provider> [<probe>]] [--dry-run] [--yes]` | Poke a live provider on purpose: list the probes, inspect something, or run a proof that cleans up after itself. Plugins offer the probes; nothing secret is printed; one that changes things asks first |
543
+ | Command | What it does |
544
+ | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
545
+ | `holocron notifications setup` | Applies the layout; looks everything up by name first, so a re-run changes nothing that matches |
546
+ | `holocron notifications channel add <name>` | Creates one channel (optionally with a webhook whose URL is stored as a secret) |
547
+ | `holocron notifications create-server --name <n> --owner <id>` | Creates the server the layout describes, writes its id into the config, applies the layout, invites the owner, waits for them to join and hands the server over (`--resume` finishes an interrupted hand-over; `--force` allows a second server) |
548
+ | `holocron notifications link` | Links your account on the provider to your GitHub account by signing in with the provider (OAuth, nothing secret kept) |
549
+ | `holocron notifications sync-roles` | Makes who holds a role match a GitHub team, through the links file (`--keep` only adds; `--provider` picks one) |
550
+ | `holocron doctor notifications [--built-only] [--deliver]` | Step by step: does the server match the layout, do the secrets exist, and does a person (not the bot) own it. A full run also leaves one `🧪 test:` post in the layout's `testChannel`; `--built-only` posts nothing; `--deliver` posts to every channel and removes each post |
551
+ | `holocron doctor variables` | Do the Actions variables `repo.variables` declares exist, with those values (and, for the organization's, that visibility)? One row for the repository and one for the organization, each only when declared. Read-only. An undeclared variable counts only with `prune`; a scope that cannot be read (no provider, no org token) is a skip, not a failure |
552
+ | `holocron doctor secrets` | Do the secrets the config says must exist (`repo.secrets`, plus the notification layout's webhook and role secrets and the Chromatic token) exist? One row for the repository, the organization and each environment, each only when something is expected there. Names only; an undeclared secret is never a problem. A scope that cannot be read is a skip |
553
+ | `holocron doctor tokens` | For every token a configured plugin lists (the GitHub plugin's nine), looked up as the plugin does (env var, then keyring) and verified with its `verifyToken`: set and accepted is ok, set and rejected fails, not set is a skip. No token is printed. What a token may do is not checked, because GitHub does not return a fine-grained token's permissions |
554
+ | `holocron doctor --all` | Runs every deep check (`doctor notifications`, `doctor variables`, ...) and prints one row each, then `N ok, N fail, N skipped` counted in checks. Exits 1 when any check failed. A check that cannot run (no provider, no token) is a skip with the reason. Read-only: notifications runs as `--built-only`, so it posts nothing |
555
+ | `holocron probe [<provider> [<probe>]] [--dry-run] [--yes]` | Poke a live provider on purpose: list the probes, inspect something, or run a proof that cleans up after itself. Plugins offer the probes; nothing secret is printed; one that changes things asks first |
553
556
 
554
557
  Channels fed by another service are declared with `feeds` on the channel: `{ name: "uptime", webhook: true, feeds: { monitoring: true } }` (the object form `{ name?, webhook?, avatar? }` overrides the alert channel's name, default `Message to #<channel>`, the dedicated webhook's name, default the provider's, and gives that webhook a picture, a file path or `https://` URL, or `{ url, image }` (the URL is tried first, the file in the repo is the fallback), else the provider's own icon (`Monitoring.icon`, a URL and an embedded `data:` image; Checkly provides one), else the layout's `webhookAvatar`, else the layout's `webhookAvatar`). `setup` gives the channel a dedicated webhook and hands its URL straight to the `monitoring` provider through `Monitoring.ensureAlertChannel({ name, format: "discord", url? })`, which finds an alert channel of that name or creates one and subscribes every check; the URL is never stored as a secret. It needs a `monitoring` provider that implements `ensureAlertChannel` (Checkly does). Two feeds may not share an alert channel name, and a feed's webhook may not share the channel's own webhook name (compared without regard to case).
555
558
 
@@ -770,7 +773,7 @@ the local override exists to exempt.
770
773
  `package bump-versions`, `sync github`, `repo upgrade node`,
771
774
  `repo upgrade deps`, `new plugin`, `auth`, `notifications setup`,
772
775
  `notifications channel add`, `notifications link`,
773
- `notifications sync-roles`, `doctor notifications`, `doctor variables`
776
+ `notifications sync-roles`, `doctor notifications`, `doctor secrets`, `doctor tokens`, `doctor variables`
774
777
  - `src/commands/doctor-checks/` and `src/commands/deep-checks/` — the shared row
775
778
  renderer and `declaredVsActual` helper, and `DEEP_CHECKS`, the registry every
776
779
  `doctor <capability>` is listed in
package/dist/cli.mjs CHANGED
@@ -126,13 +126,17 @@ function listStoredProviders() {
126
126
  * operation fails with a message naming the exact env var to set.
127
127
  */
128
128
  function createFeatureResolver(config) {
129
- return function resolveFeatureToken(input = {}) {
129
+ const resolveFeatureToken = (input = {}) => {
130
130
  const env = makeEnv(input.env);
131
131
  const keyring = input.keyring ?? getToken;
132
132
  const token = input.cliToken || env.get(config.envName) || keyring(config.keyringKey);
133
133
  if (!token) throw new AuthError(`no ${config.vendor ?? "GitHub"} token found for this operation. Pass --token <token>, set ${config.envName}, or run: holocron auth set ${config.keyringKey} <token>`);
134
134
  return token;
135
135
  };
136
+ return Object.assign(resolveFeatureToken, { token: {
137
+ envName: config.envName,
138
+ keyringKey: config.keyringKey
139
+ } });
136
140
  }
137
141
  // src/auth/token-args/token-args.ts
138
142
  var TokenParseError = class extends Error {
@@ -216,6 +220,8 @@ const COMMAND_CONTEXTS = {
216
220
  "notifications sync-roles": "workspace",
217
221
  "doctor all": "workspace",
218
222
  "doctor notifications": "workspace",
223
+ "doctor secrets": "workspace",
224
+ "doctor tokens": "workspace",
219
225
  "doctor variables": "workspace",
220
226
  probe: "workspace",
221
227
  deploy: "workspace",
@@ -1429,6 +1435,20 @@ const doctorNotificationsEntry = {
1429
1435
  }],
1430
1436
  supportsDryRun: false
1431
1437
  };
1438
+ // src/commands/doctor-secrets/doctor-secrets.entry.ts
1439
+ const doctorSecretsEntry = {
1440
+ name: "doctor secrets",
1441
+ description: "Check the secrets the config says must exist against the ones the provider holds (read-only, names only)",
1442
+ positionals: [],
1443
+ supportsDryRun: false
1444
+ };
1445
+ // src/commands/doctor-tokens/doctor-tokens.entry.ts
1446
+ const doctorTokensEntry = {
1447
+ name: "doctor tokens",
1448
+ description: "Check that each token a configured plugin takes is set and still accepted (read-only; no token is printed)",
1449
+ positionals: [],
1450
+ supportsDryRun: false
1451
+ };
1432
1452
  // src/commands/doctor-variables/doctor-variables.entry.ts
1433
1453
  const doctorVariablesEntry = {
1434
1454
  name: "doctor variables",
@@ -1640,6 +1660,8 @@ const COMMAND_REGISTRY = [
1640
1660
  },
1641
1661
  notificationsChannelAddEntry,
1642
1662
  doctorNotificationsEntry,
1663
+ doctorSecretsEntry,
1664
+ doctorTokensEntry,
1643
1665
  doctorVariablesEntry,
1644
1666
  notificationsSetupEntry,
1645
1667
  notificationsCreateServerEntry,
@@ -2769,6 +2791,7 @@ function assertPluginsResolvable(loader, command) {
2769
2791
  * don't export `verifyToken` can still store — with a warning — because
2770
2792
  * "no verify path" shouldn't block credential storage.
2771
2793
  */
2794
+ /** Loads a plugin package for its module-level exports (`verifyToken`, `tokens`), from the working directory first. */
2772
2795
  const defaultImporter = async (pkg) => {
2773
2796
  try {
2774
2797
  const resolved = createRequire(process.cwd() + "/").resolve(pkg);
@@ -4402,6 +4425,16 @@ async function runNotificationsChannelAdd(input) {
4402
4425
  };
4403
4426
  }
4404
4427
  }
4428
+ // src/commands/notifications-channel-add/layout-secret-names.ts
4429
+ /**
4430
+ * The names of the secrets a layout fills: each channel's webhook secret (`webhook.secret`, else the name derived
4431
+ * from the channel) and each role's `secret`. In the order the layout declares them.
4432
+ */
4433
+ function layoutSecretNames(layout) {
4434
+ const fromChannels = (layout.categories ?? []).flatMap((category) => (category.channels ?? []).filter((channel) => channel.webhook).map((channel) => channel.webhook !== true && channel.webhook && channel.webhook.secret ? channel.webhook.secret : defaultSecretName(channel.name)));
4435
+ const fromRoles = (layout.roles ?? []).flatMap((role) => role.secret ? [role.secret] : []);
4436
+ return [...fromChannels, ...fromRoles];
4437
+ }
4405
4438
  const localRedirectUri = (port) => `http://localhost:${port}/callback`;
4406
4439
  /**
4407
4440
  * The hosted service answers `GET <hostedUrl>/api/link` with `{ "service": "link" }`. Anything else (a 402 for
@@ -5379,7 +5412,7 @@ async function runDoctorNotifications(input) {
5379
5412
  }
5380
5413
  add("app-settings", APP_TITLE, appProblems, wantApp ? "1 of 1 as declared" : "none declared");
5381
5414
  }
5382
- const wanted = [...declaredChannels.filter(({ channel }) => channel.webhook).map(({ channel }) => channel.webhook !== true && channel.webhook && channel.webhook.secret ? channel.webhook.secret : defaultSecretName(channel.name)), ...(layout.roles ?? []).flatMap((r) => r.secret ? [r.secret] : [])];
5415
+ const wanted = layoutSecretNames(layout);
5383
5416
  if (wanted.length === 0) checks.push({
5384
5417
  id: "secrets",
5385
5418
  title: SECRETS_TITLE,
@@ -5523,6 +5556,269 @@ const doctorNotificationsCommand = {
5523
5556
  })).status === "fail") process.exitCode = 1;
5524
5557
  }
5525
5558
  };
5559
+ // src/commands/doctor-secrets/expected-secrets.ts
5560
+ /** Names that differ only in case are one secret to GitHub, so the first spelling wins. */
5561
+ const unique = (names) => {
5562
+ const seen = /* @__PURE__ */ new Map();
5563
+ for (const name of names) if (!seen.has(name.toUpperCase())) seen.set(name.toUpperCase(), name);
5564
+ return [...seen.values()];
5565
+ };
5566
+ /**
5567
+ * The secret a Chromatic project reads: `CHROMATIC_PROJECT_TOKEN` for `default` (or no name), otherwise
5568
+ * `CHROMATIC_PROJECT_TOKEN_<NAME>`.
5569
+ */
5570
+ const chromaticSecret = (tokenName) => !tokenName || tokenName === "default" ? "CHROMATIC_PROJECT_TOKEN" : `CHROMATIC_PROJECT_TOKEN_${tokenName.toUpperCase()}`;
5571
+ /**
5572
+ * The secrets the config says must exist: the names listed in `repo.secrets`, plus the ones it implies. A
5573
+ * notification layout fills a secret per webhook and per role (organization scope), and each project of a
5574
+ * `verification.visualRegression` task reads a Chromatic token (repository scope).
5575
+ */
5576
+ function expectedSecrets(config, layouts) {
5577
+ const declared = config.repo?.secrets;
5578
+ const chromatic = (config.tasks ?? []).flatMap((task) => typeof task === "object" && task.name === "verification.visualRegression" ? (task.with?.["chromatic-projects"] ?? []).map((project) => chromaticSecret(project.tokenName)) : []);
5579
+ return {
5580
+ repo: unique([...declared?.repo ?? [], ...chromatic]),
5581
+ org: unique([...declared?.org ?? [], ...layouts.flatMap(layoutSecretNames)]),
5582
+ environments: Object.fromEntries(Object.entries(declared?.environments ?? {}).map(([env, names]) => [env, unique(names)]))
5583
+ };
5584
+ }
5585
+ // src/commands/doctor-secrets/doctor-secrets.ts
5586
+ /**
5587
+ * `holocron doctor secrets` — do the secrets the config says must exist, exist?
5588
+ *
5589
+ * Read-only, names only: GitHub never returns a value. One row for the repository's secrets, one for the
5590
+ * organization's and one per environment, each only when the config expects something there (see
5591
+ * {@link expectedSecrets}). A secret that exists but is not expected is never a problem. A scope that cannot be
5592
+ * read because there is no provider, or no token for it, is a skip with the reason, not a failure.
5593
+ */
5594
+ async function runDoctorSecrets(input) {
5595
+ const print = input.print ?? ((line) => console.log(line));
5596
+ const logger = input.logger ?? getLogger();
5597
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
5598
+ await loader.load();
5599
+ assertPluginsResolvable(loader, "doctor secrets");
5600
+ const config = input.loaded.resolved;
5601
+ const expected = expectedSecrets(config, (loader.has("notifications") ? loader.get("notifications") : []).flatMap((p) => p.layout ? [p.layout] : []));
5602
+ const org = input.context.org ?? (input.context.repo ?? config.repo?.name ?? "").split("/")[0];
5603
+ const checks = [];
5604
+ if (expected.repo.length > 0) checks.push({
5605
+ id: "repo-secrets",
5606
+ title: "repository secrets exist",
5607
+ scope: { kind: "repo" },
5608
+ names: expected.repo
5609
+ });
5610
+ if (expected.org.length > 0) checks.push({
5611
+ id: "org-secrets",
5612
+ title: "organization secrets exist",
5613
+ scope: org ? {
5614
+ kind: "organization",
5615
+ name: org
5616
+ } : { problem: "no organization: set `org` in the config or run inside a repository" },
5617
+ names: expected.org
5618
+ });
5619
+ for (const [env, names] of Object.entries(expected.environments)) {
5620
+ if (names.length === 0) continue;
5621
+ checks.push({
5622
+ id: `env-secrets-${env}`,
5623
+ title: `${env} environment secrets exist`,
5624
+ scope: {
5625
+ kind: "environment",
5626
+ name: env
5627
+ },
5628
+ names
5629
+ });
5630
+ }
5631
+ const rows = [];
5632
+ if (checks.length === 0) rows.push({
5633
+ id: "secrets",
5634
+ title: "secrets",
5635
+ status: "ok",
5636
+ detail: "none declared",
5637
+ problems: []
5638
+ });
5639
+ else if (!loader.has("secrets")) {
5640
+ const why = whyMissing(loader, "secrets", "no `secrets` provider to check them with");
5641
+ for (const { id, title } of checks) rows.push({
5642
+ id,
5643
+ title,
5644
+ status: "skip",
5645
+ detail: why,
5646
+ problems: []
5647
+ });
5648
+ } else {
5649
+ const secrets = loader.get("secrets");
5650
+ for (const check of checks) rows.push(await checkScope(secrets, check));
5651
+ }
5652
+ printCheckRows(rows, print);
5653
+ const summary = summariseChecks(rows);
5654
+ printCheckSummary(summary, print);
5655
+ const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
5656
+ logger.info({
5657
+ ...summary,
5658
+ status
5659
+ }, "doctor secrets");
5660
+ return {
5661
+ status,
5662
+ rows,
5663
+ summary,
5664
+ ...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
5665
+ };
5666
+ }
5667
+ async function checkScope(secrets, check) {
5668
+ const { id, title, scope, names } = check;
5669
+ if ("problem" in scope) return {
5670
+ id,
5671
+ title,
5672
+ status: "fail",
5673
+ detail: "1 problem(s)",
5674
+ problems: [scope.problem]
5675
+ };
5676
+ try {
5677
+ const have = await secrets.listSecrets(scope);
5678
+ const spelled = new Map(names.map((name) => [name.toUpperCase(), name]));
5679
+ const problems = declaredVsActual(new Map(names.map((name) => [name, true])), new Map(have.map((name) => [spelled.get(name.toUpperCase()) ?? name, true])), {
5680
+ noun: "secret",
5681
+ flagExtra: false
5682
+ });
5683
+ return problems.length > 0 ? {
5684
+ id,
5685
+ title,
5686
+ status: "fail",
5687
+ detail: `${problems.length} problem(s)`,
5688
+ problems
5689
+ } : {
5690
+ id,
5691
+ title,
5692
+ status: "ok",
5693
+ detail: `${names.length} of ${names.length} exist`,
5694
+ problems: []
5695
+ };
5696
+ } catch (err) {
5697
+ if (err instanceof MissingTokenError) return {
5698
+ id,
5699
+ title,
5700
+ status: "skip",
5701
+ detail: err.message,
5702
+ problems: []
5703
+ };
5704
+ return {
5705
+ id,
5706
+ title,
5707
+ status: "fail",
5708
+ detail: errorMessage(err),
5709
+ problems: []
5710
+ };
5711
+ }
5712
+ }
5713
+ // src/commands/doctor-secrets/doctor-secrets.command.ts
5714
+ const doctorSecretsCommand = {
5715
+ command: "secrets",
5716
+ describe: "Check the secrets the config says must exist against the ones the provider holds (read-only, names only)",
5717
+ handler: async (argv) => {
5718
+ const tokens = tokenContext(argv.token);
5719
+ if (!tokens) return;
5720
+ const loaded = await loadConfig(argv.cwd);
5721
+ applyResolvedConfig(argv, loaded.resolved);
5722
+ if ((await runDoctorSecrets({
5723
+ loaded,
5724
+ context: {
5725
+ repoRoot: argv.cwd,
5726
+ ...tokens,
5727
+ org: resolveOrg(argv, loaded.resolved)
5728
+ }
5729
+ })).status === "fail") process.exitCode = 1;
5730
+ }
5731
+ };
5732
+ // src/commands/doctor-tokens/doctor-tokens.ts
5733
+ /**
5734
+ * `holocron doctor tokens` — is each token a configured plugin takes set, and still accepted?
5735
+ *
5736
+ * Read-only. For every token a configured plugin lists (its `tokens` export), the token is looked up the way the
5737
+ * plugin does it (the environment variable, then the OS keyring) and the plugin's `verifyToken` is asked whether it
5738
+ * is still accepted. A token is never printed. One that is not set is a skip, not a failure: whether it is needed
5739
+ * depends on what is run. One that is set and rejected (expired, revoked, malformed) fails.
5740
+ *
5741
+ * What a token may do is not checked: GitHub does not return a fine-grained token's permissions.
5742
+ */
5743
+ async function runDoctorTokens(input) {
5744
+ const print = input.print ?? ((line) => console.log(line));
5745
+ const logger = input.logger ?? getLogger();
5746
+ const importer = input.importer ?? defaultImporter;
5747
+ const env = makeEnv(input.env);
5748
+ const keyring = input.keyring ?? getToken;
5749
+ const rows = [];
5750
+ for (const pkg of configuredPackages(input)) {
5751
+ let module;
5752
+ try {
5753
+ module = await importer(pkg);
5754
+ } catch (err) {
5755
+ rows.push(row$1(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
5756
+ continue;
5757
+ }
5758
+ for (const token of module.tokens ?? []) rows.push(await checkToken(token, module, env.get(token.envName), keyring));
5759
+ }
5760
+ if (rows.length === 0) rows.push(row$1("tokens", "skip", "no configured plugin lists the tokens it takes"));
5761
+ printCheckRows(rows, print);
5762
+ const summary = summariseChecks(rows);
5763
+ printCheckSummary(summary, print);
5764
+ const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
5765
+ logger.info({
5766
+ ...summary,
5767
+ status
5768
+ }, "doctor tokens");
5769
+ return {
5770
+ status,
5771
+ rows,
5772
+ summary,
5773
+ ...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
5774
+ };
5775
+ }
5776
+ /** The package of every provider the config names, once each. */
5777
+ function configuredPackages(input) {
5778
+ const packages = Object.values(input.loaded.resolved.providers).flatMap((entry) => entry.cardinality === "single" ? [entry.tuple.packageName] : entry.tuples.map((t) => t.packageName));
5779
+ return [...new Set(packages)];
5780
+ }
5781
+ function row$1(id, status, detail) {
5782
+ return {
5783
+ id,
5784
+ title: id,
5785
+ status,
5786
+ detail,
5787
+ problems: []
5788
+ };
5789
+ }
5790
+ async function checkToken(token, module, fromEnv, keyring) {
5791
+ const { keyringKey, envName } = token;
5792
+ const value = fromEnv || keyring(keyringKey);
5793
+ if (!value) return row$1(keyringKey, "skip", `not set (${envName}, or \`holocron auth set ${keyringKey}\`)`);
5794
+ if (!module.verifyToken) return row$1(keyringKey, "skip", "set, but its plugin cannot verify it");
5795
+ const from = fromEnv ? envName : "keyring";
5796
+ try {
5797
+ const verified = await module.verifyToken(value);
5798
+ return verified.ok ? row$1(keyringKey, "ok", `${verified.subject} (${from})`) : row$1(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
5799
+ } catch (err) {
5800
+ return row$1(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
5801
+ }
5802
+ }
5803
+ // src/commands/doctor-tokens/doctor-tokens.command.ts
5804
+ const doctorTokensCommand = {
5805
+ command: "tokens",
5806
+ describe: "Check that each token a configured plugin takes is set and still accepted (read-only; no token is printed)",
5807
+ handler: async (argv) => {
5808
+ const tokens = tokenContext(argv.token);
5809
+ if (!tokens) return;
5810
+ const loaded = await loadConfig(argv.cwd);
5811
+ applyResolvedConfig(argv, loaded.resolved);
5812
+ if ((await runDoctorTokens({
5813
+ loaded,
5814
+ context: {
5815
+ repoRoot: argv.cwd,
5816
+ ...tokens,
5817
+ org: resolveOrg(argv, loaded.resolved)
5818
+ }
5819
+ })).status === "fail") process.exitCode = 1;
5820
+ }
5821
+ };
5526
5822
  // src/commands/doctor-variables/doctor-variables.ts
5527
5823
  /**
5528
5824
  * `holocron doctor variables` — do the Actions variables `repo.variables` declares exist, with those values?
@@ -5673,63 +5969,92 @@ function compareOrg(declared, have, prune) {
5673
5969
  * Every `doctor <capability>` deep check, in the order `doctor --all` runs them. Adding one is an entry here
5674
5970
  * plus its `COMMAND_CONTEXTS` and `COMMAND_REGISTRY` entries; `deep-checks.test.ts` fails without them.
5675
5971
  */
5676
- const DEEP_CHECKS = [{
5677
- name: "notifications",
5678
- capability: "notifications",
5679
- command: doctorNotificationsCommand,
5680
- async run(input) {
5681
- const report = await runDoctorNotifications({
5682
- ...input,
5683
- builtOnly: true
5684
- });
5685
- if (report.message) return {
5686
- status: "skip",
5687
- summary: {
5688
- ok: 0,
5689
- fail: 0,
5690
- skip: 1
5691
- },
5692
- reason: report.message
5693
- };
5694
- return {
5695
- status: report.status,
5696
- summary: {
5697
- ok: report.summary.pass,
5698
- fail: report.summary.fail,
5699
- skip: report.summary.skip
5700
- }
5701
- };
5702
- }
5703
- }, {
5704
- name: "variables",
5705
- capability: "source",
5706
- command: {
5707
- command: "variables",
5708
- describe: "Check the Actions variables the config declares against the ones the provider holds (read-only)",
5709
- handler: async (argv) => {
5710
- const tokens = tokenContext(argv.token);
5711
- if (!tokens) return;
5712
- const loaded = await loadConfig(argv.cwd);
5713
- applyResolvedConfig(argv, loaded.resolved);
5714
- if ((await runDoctorVariables({
5715
- loaded,
5716
- context: {
5717
- repoRoot: argv.cwd,
5718
- ...tokens,
5719
- org: resolveOrg(argv, loaded.resolved)
5972
+ const DEEP_CHECKS = [
5973
+ {
5974
+ name: "notifications",
5975
+ capability: "notifications",
5976
+ command: doctorNotificationsCommand,
5977
+ async run(input) {
5978
+ const report = await runDoctorNotifications({
5979
+ ...input,
5980
+ builtOnly: true
5981
+ });
5982
+ if (report.message) return {
5983
+ status: "skip",
5984
+ summary: {
5985
+ ok: 0,
5986
+ fail: 0,
5987
+ skip: 1
5988
+ },
5989
+ reason: report.message
5990
+ };
5991
+ return {
5992
+ status: report.status,
5993
+ summary: {
5994
+ ok: report.summary.pass,
5995
+ fail: report.summary.fail,
5996
+ skip: report.summary.skip
5720
5997
  }
5721
- })).status === "fail") process.exitCode = 1;
5998
+ };
5722
5999
  }
5723
6000
  },
5724
- async run(input) {
5725
- const report = await runDoctorVariables(input);
5726
- return {
5727
- status: report.status,
5728
- summary: report.summary,
5729
- ...report.reason ? { reason: report.reason } : {}
5730
- };
6001
+ {
6002
+ name: "secrets",
6003
+ capability: "secrets",
6004
+ command: doctorSecretsCommand,
6005
+ async run(input) {
6006
+ const report = await runDoctorSecrets(input);
6007
+ return {
6008
+ status: report.status,
6009
+ summary: report.summary,
6010
+ ...report.reason ? { reason: report.reason } : {}
6011
+ };
6012
+ }
6013
+ },
6014
+ {
6015
+ name: "tokens",
6016
+ capability: "source",
6017
+ command: doctorTokensCommand,
6018
+ async run(input) {
6019
+ const report = await runDoctorTokens(input);
6020
+ return {
6021
+ status: report.status,
6022
+ summary: report.summary,
6023
+ ...report.reason ? { reason: report.reason } : {}
6024
+ };
6025
+ }
6026
+ },
6027
+ {
6028
+ name: "variables",
6029
+ capability: "source",
6030
+ command: {
6031
+ command: "variables",
6032
+ describe: "Check the Actions variables the config declares against the ones the provider holds (read-only)",
6033
+ handler: async (argv) => {
6034
+ const tokens = tokenContext(argv.token);
6035
+ if (!tokens) return;
6036
+ const loaded = await loadConfig(argv.cwd);
6037
+ applyResolvedConfig(argv, loaded.resolved);
6038
+ if ((await runDoctorVariables({
6039
+ loaded,
6040
+ context: {
6041
+ repoRoot: argv.cwd,
6042
+ ...tokens,
6043
+ org: resolveOrg(argv, loaded.resolved)
6044
+ }
6045
+ })).status === "fail") process.exitCode = 1;
6046
+ }
6047
+ },
6048
+ async run(input) {
6049
+ const report = await runDoctorVariables(input);
6050
+ return {
6051
+ status: report.status,
6052
+ summary: report.summary,
6053
+ ...report.reason ? { reason: report.reason } : {}
6054
+ };
6055
+ }
5731
6056
  }
5732
- }];
6057
+ ];
5733
6058
  // src/commands/doctor-all/doctor-all.ts
5734
6059
  /**
5735
6060
  * `holocron doctor --all` — run every deep check and print one row for each.