@theholocron/cli 5.0.0-alpha.265 → 5.0.0-alpha.267

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,16 +540,18 @@ 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 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 --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 |
554
+ | `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 |
552
555
 
553
556
  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).
554
557
 
@@ -769,7 +772,7 @@ the local override exists to exempt.
769
772
  `package bump-versions`, `sync github`, `repo upgrade node`,
770
773
  `repo upgrade deps`, `new plugin`, `auth`, `notifications setup`,
771
774
  `notifications channel add`, `notifications link`,
772
- `notifications sync-roles`, `doctor notifications`, `doctor variables`
775
+ `notifications sync-roles`, `doctor notifications`, `doctor secrets`, `doctor variables`
773
776
  - `src/commands/doctor-checks/` and `src/commands/deep-checks/` — the shared row
774
777
  renderer and `declaredVsActual` helper, and `DEEP_CHECKS`, the registry every
775
778
  `doctor <capability>` is listed in
package/dist/cli.mjs CHANGED
@@ -214,7 +214,9 @@ const COMMAND_CONTEXTS = {
214
214
  "notifications link": "workspace",
215
215
  "notifications create-server": "workspace",
216
216
  "notifications sync-roles": "workspace",
217
+ "doctor all": "workspace",
217
218
  "doctor notifications": "workspace",
219
+ "doctor secrets": "workspace",
218
220
  "doctor variables": "workspace",
219
221
  probe: "workspace",
220
222
  deploy: "workspace",
@@ -1405,6 +1407,15 @@ const doctorEntry = {
1405
1407
  positionals: [],
1406
1408
  supportsDryRun: true
1407
1409
  };
1410
+ // src/commands/doctor/doctor-all.entry.ts
1411
+ const doctorAllEntry = {
1412
+ name: "doctor all",
1413
+ menuLabel: "doctor (everything)",
1414
+ description: "Run every deep check (doctor <capability>) and print one row each",
1415
+ positionals: [],
1416
+ supportsDryRun: false,
1417
+ spawnArgs: ["doctor", "--all"]
1418
+ };
1408
1419
  // src/commands/doctor-notifications/doctor-notifications.entry.ts
1409
1420
  const doctorNotificationsEntry = {
1410
1421
  name: "doctor notifications",
@@ -1419,6 +1430,13 @@ const doctorNotificationsEntry = {
1419
1430
  }],
1420
1431
  supportsDryRun: false
1421
1432
  };
1433
+ // src/commands/doctor-secrets/doctor-secrets.entry.ts
1434
+ const doctorSecretsEntry = {
1435
+ name: "doctor secrets",
1436
+ description: "Check the secrets the config says must exist against the ones the provider holds (read-only, names only)",
1437
+ positionals: [],
1438
+ supportsDryRun: false
1439
+ };
1422
1440
  // src/commands/doctor-variables/doctor-variables.entry.ts
1423
1441
  const doctorVariablesEntry = {
1424
1442
  name: "doctor variables",
@@ -1594,6 +1612,7 @@ const PUBLISH_OTP_OPTION = {
1594
1612
  const COMMAND_REGISTRY = [
1595
1613
  cloneEntry,
1596
1614
  doctorEntry,
1615
+ doctorAllEntry,
1597
1616
  probeEntry,
1598
1617
  {
1599
1618
  name: "repo setup",
@@ -1629,6 +1648,7 @@ const COMMAND_REGISTRY = [
1629
1648
  },
1630
1649
  notificationsChannelAddEntry,
1631
1650
  doctorNotificationsEntry,
1651
+ doctorSecretsEntry,
1632
1652
  doctorVariablesEntry,
1633
1653
  notificationsSetupEntry,
1634
1654
  notificationsCreateServerEntry,
@@ -1825,7 +1845,7 @@ function menuItems(entries, path = []) {
1825
1845
  const self = family.find((e) => e.name === full);
1826
1846
  const nested = family.filter((e) => e.name !== full);
1827
1847
  if (nested.length === 0 && self) items.push({
1828
- name: self.opensMenu ? `${word} ›` : word,
1848
+ name: self.menuLabel ?? (self.opensMenu ? `${word} ›` : word),
1829
1849
  value: full,
1830
1850
  description: self.description,
1831
1851
  haystack: haystackOf([self])
@@ -4391,6 +4411,16 @@ async function runNotificationsChannelAdd(input) {
4391
4411
  };
4392
4412
  }
4393
4413
  }
4414
+ // src/commands/notifications-channel-add/layout-secret-names.ts
4415
+ /**
4416
+ * The names of the secrets a layout fills: each channel's webhook secret (`webhook.secret`, else the name derived
4417
+ * from the channel) and each role's `secret`. In the order the layout declares them.
4418
+ */
4419
+ function layoutSecretNames(layout) {
4420
+ 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)));
4421
+ const fromRoles = (layout.roles ?? []).flatMap((role) => role.secret ? [role.secret] : []);
4422
+ return [...fromChannels, ...fromRoles];
4423
+ }
4394
4424
  const localRedirectUri = (port) => `http://localhost:${port}/callback`;
4395
4425
  /**
4396
4426
  * The hosted service answers `GET <hostedUrl>/api/link` with `{ "service": "link" }`. Anything else (a 402 for
@@ -5368,7 +5398,7 @@ async function runDoctorNotifications(input) {
5368
5398
  }
5369
5399
  add("app-settings", APP_TITLE, appProblems, wantApp ? "1 of 1 as declared" : "none declared");
5370
5400
  }
5371
- 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] : [])];
5401
+ const wanted = layoutSecretNames(layout);
5372
5402
  if (wanted.length === 0) checks.push({
5373
5403
  id: "secrets",
5374
5404
  title: SECRETS_TITLE,
@@ -5512,6 +5542,179 @@ const doctorNotificationsCommand = {
5512
5542
  })).status === "fail") process.exitCode = 1;
5513
5543
  }
5514
5544
  };
5545
+ // src/commands/doctor-secrets/expected-secrets.ts
5546
+ /** Names that differ only in case are one secret to GitHub, so the first spelling wins. */
5547
+ const unique = (names) => {
5548
+ const seen = /* @__PURE__ */ new Map();
5549
+ for (const name of names) if (!seen.has(name.toUpperCase())) seen.set(name.toUpperCase(), name);
5550
+ return [...seen.values()];
5551
+ };
5552
+ /**
5553
+ * The secret a Chromatic project reads: `CHROMATIC_PROJECT_TOKEN` for `default` (or no name), otherwise
5554
+ * `CHROMATIC_PROJECT_TOKEN_<NAME>`.
5555
+ */
5556
+ const chromaticSecret = (tokenName) => !tokenName || tokenName === "default" ? "CHROMATIC_PROJECT_TOKEN" : `CHROMATIC_PROJECT_TOKEN_${tokenName.toUpperCase()}`;
5557
+ /**
5558
+ * The secrets the config says must exist: the names listed in `repo.secrets`, plus the ones it implies. A
5559
+ * notification layout fills a secret per webhook and per role (organization scope), and each project of a
5560
+ * `verification.visualRegression` task reads a Chromatic token (repository scope).
5561
+ */
5562
+ function expectedSecrets(config, layouts) {
5563
+ const declared = config.repo?.secrets;
5564
+ const chromatic = (config.tasks ?? []).flatMap((task) => typeof task === "object" && task.name === "verification.visualRegression" ? (task.with?.["chromatic-projects"] ?? []).map((project) => chromaticSecret(project.tokenName)) : []);
5565
+ return {
5566
+ repo: unique([...declared?.repo ?? [], ...chromatic]),
5567
+ org: unique([...declared?.org ?? [], ...layouts.flatMap(layoutSecretNames)]),
5568
+ environments: Object.fromEntries(Object.entries(declared?.environments ?? {}).map(([env, names]) => [env, unique(names)]))
5569
+ };
5570
+ }
5571
+ // src/commands/doctor-secrets/doctor-secrets.ts
5572
+ /**
5573
+ * `holocron doctor secrets` — do the secrets the config says must exist, exist?
5574
+ *
5575
+ * Read-only, names only: GitHub never returns a value. One row for the repository's secrets, one for the
5576
+ * organization's and one per environment, each only when the config expects something there (see
5577
+ * {@link expectedSecrets}). A secret that exists but is not expected is never a problem. A scope that cannot be
5578
+ * read because there is no provider, or no token for it, is a skip with the reason, not a failure.
5579
+ */
5580
+ async function runDoctorSecrets(input) {
5581
+ const print = input.print ?? ((line) => console.log(line));
5582
+ const logger = input.logger ?? getLogger();
5583
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
5584
+ await loader.load();
5585
+ assertPluginsResolvable(loader, "doctor secrets");
5586
+ const config = input.loaded.resolved;
5587
+ const expected = expectedSecrets(config, (loader.has("notifications") ? loader.get("notifications") : []).flatMap((p) => p.layout ? [p.layout] : []));
5588
+ const org = input.context.org ?? (input.context.repo ?? config.repo?.name ?? "").split("/")[0];
5589
+ const checks = [];
5590
+ if (expected.repo.length > 0) checks.push({
5591
+ id: "repo-secrets",
5592
+ title: "repository secrets exist",
5593
+ scope: { kind: "repo" },
5594
+ names: expected.repo
5595
+ });
5596
+ if (expected.org.length > 0) checks.push({
5597
+ id: "org-secrets",
5598
+ title: "organization secrets exist",
5599
+ scope: org ? {
5600
+ kind: "organization",
5601
+ name: org
5602
+ } : { problem: "no organization: set `org` in the config or run inside a repository" },
5603
+ names: expected.org
5604
+ });
5605
+ for (const [env, names] of Object.entries(expected.environments)) {
5606
+ if (names.length === 0) continue;
5607
+ checks.push({
5608
+ id: `env-secrets-${env}`,
5609
+ title: `${env} environment secrets exist`,
5610
+ scope: {
5611
+ kind: "environment",
5612
+ name: env
5613
+ },
5614
+ names
5615
+ });
5616
+ }
5617
+ const rows = [];
5618
+ if (checks.length === 0) rows.push({
5619
+ id: "secrets",
5620
+ title: "secrets",
5621
+ status: "ok",
5622
+ detail: "none declared",
5623
+ problems: []
5624
+ });
5625
+ else if (!loader.has("secrets")) {
5626
+ const why = whyMissing(loader, "secrets", "no `secrets` provider to check them with");
5627
+ for (const { id, title } of checks) rows.push({
5628
+ id,
5629
+ title,
5630
+ status: "skip",
5631
+ detail: why,
5632
+ problems: []
5633
+ });
5634
+ } else {
5635
+ const secrets = loader.get("secrets");
5636
+ for (const check of checks) rows.push(await checkScope(secrets, check));
5637
+ }
5638
+ printCheckRows(rows, print);
5639
+ const summary = summariseChecks(rows);
5640
+ printCheckSummary(summary, print);
5641
+ const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
5642
+ logger.info({
5643
+ ...summary,
5644
+ status
5645
+ }, "doctor secrets");
5646
+ return {
5647
+ status,
5648
+ rows,
5649
+ summary,
5650
+ ...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
5651
+ };
5652
+ }
5653
+ async function checkScope(secrets, check) {
5654
+ const { id, title, scope, names } = check;
5655
+ if ("problem" in scope) return {
5656
+ id,
5657
+ title,
5658
+ status: "fail",
5659
+ detail: "1 problem(s)",
5660
+ problems: [scope.problem]
5661
+ };
5662
+ try {
5663
+ const have = await secrets.listSecrets(scope);
5664
+ const spelled = new Map(names.map((name) => [name.toUpperCase(), name]));
5665
+ const problems = declaredVsActual(new Map(names.map((name) => [name, true])), new Map(have.map((name) => [spelled.get(name.toUpperCase()) ?? name, true])), {
5666
+ noun: "secret",
5667
+ flagExtra: false
5668
+ });
5669
+ return problems.length > 0 ? {
5670
+ id,
5671
+ title,
5672
+ status: "fail",
5673
+ detail: `${problems.length} problem(s)`,
5674
+ problems
5675
+ } : {
5676
+ id,
5677
+ title,
5678
+ status: "ok",
5679
+ detail: `${names.length} of ${names.length} exist`,
5680
+ problems: []
5681
+ };
5682
+ } catch (err) {
5683
+ if (err instanceof MissingTokenError) return {
5684
+ id,
5685
+ title,
5686
+ status: "skip",
5687
+ detail: err.message,
5688
+ problems: []
5689
+ };
5690
+ return {
5691
+ id,
5692
+ title,
5693
+ status: "fail",
5694
+ detail: errorMessage(err),
5695
+ problems: []
5696
+ };
5697
+ }
5698
+ }
5699
+ // src/commands/doctor-secrets/doctor-secrets.command.ts
5700
+ const doctorSecretsCommand = {
5701
+ command: "secrets",
5702
+ describe: "Check the secrets the config says must exist against the ones the provider holds (read-only, names only)",
5703
+ handler: async (argv) => {
5704
+ const tokens = tokenContext(argv.token);
5705
+ if (!tokens) return;
5706
+ const loaded = await loadConfig(argv.cwd);
5707
+ applyResolvedConfig(argv, loaded.resolved);
5708
+ if ((await runDoctorSecrets({
5709
+ loaded,
5710
+ context: {
5711
+ repoRoot: argv.cwd,
5712
+ ...tokens,
5713
+ org: resolveOrg(argv, loaded.resolved)
5714
+ }
5715
+ })).status === "fail") process.exitCode = 1;
5716
+ }
5717
+ };
5515
5718
  // src/commands/doctor-variables/doctor-variables.ts
5516
5719
  /**
5517
5720
  * `holocron doctor variables` — do the Actions variables `repo.variables` declares exist, with those values?
@@ -5662,55 +5865,161 @@ function compareOrg(declared, have, prune) {
5662
5865
  * Every `doctor <capability>` deep check, in the order `doctor --all` runs them. Adding one is an entry here
5663
5866
  * plus its `COMMAND_CONTEXTS` and `COMMAND_REGISTRY` entries; `deep-checks.test.ts` fails without them.
5664
5867
  */
5665
- const DEEP_CHECKS = [{
5666
- name: "notifications",
5667
- capability: "notifications",
5668
- command: doctorNotificationsCommand,
5669
- async run(input) {
5670
- const report = await runDoctorNotifications(input);
5671
- return {
5672
- status: report.status,
5673
- summary: {
5674
- ok: report.summary.pass,
5675
- fail: report.summary.fail,
5676
- skip: report.summary.skip
5677
- },
5678
- ...report.message ? { reason: report.message } : {}
5679
- };
5680
- }
5681
- }, {
5682
- name: "variables",
5683
- capability: "source",
5684
- command: {
5685
- command: "variables",
5686
- describe: "Check the Actions variables the config declares against the ones the provider holds (read-only)",
5687
- handler: async (argv) => {
5688
- const tokens = tokenContext(argv.token);
5689
- if (!tokens) return;
5690
- const loaded = await loadConfig(argv.cwd);
5691
- applyResolvedConfig(argv, loaded.resolved);
5692
- if ((await runDoctorVariables({
5693
- loaded,
5694
- context: {
5695
- repoRoot: argv.cwd,
5696
- ...tokens,
5697
- org: resolveOrg(argv, loaded.resolved)
5868
+ const DEEP_CHECKS = [
5869
+ {
5870
+ name: "notifications",
5871
+ capability: "notifications",
5872
+ command: doctorNotificationsCommand,
5873
+ async run(input) {
5874
+ const report = await runDoctorNotifications({
5875
+ ...input,
5876
+ builtOnly: true
5877
+ });
5878
+ if (report.message) return {
5879
+ status: "skip",
5880
+ summary: {
5881
+ ok: 0,
5882
+ fail: 0,
5883
+ skip: 1
5884
+ },
5885
+ reason: report.message
5886
+ };
5887
+ return {
5888
+ status: report.status,
5889
+ summary: {
5890
+ ok: report.summary.pass,
5891
+ fail: report.summary.fail,
5892
+ skip: report.summary.skip
5698
5893
  }
5699
- })).status === "fail") process.exitCode = 1;
5894
+ };
5895
+ }
5896
+ },
5897
+ {
5898
+ name: "secrets",
5899
+ capability: "secrets",
5900
+ command: doctorSecretsCommand,
5901
+ async run(input) {
5902
+ const report = await runDoctorSecrets(input);
5903
+ return {
5904
+ status: report.status,
5905
+ summary: report.summary,
5906
+ ...report.reason ? { reason: report.reason } : {}
5907
+ };
5700
5908
  }
5701
5909
  },
5702
- async run(input) {
5703
- const report = await runDoctorVariables(input);
5910
+ {
5911
+ name: "variables",
5912
+ capability: "source",
5913
+ command: {
5914
+ command: "variables",
5915
+ describe: "Check the Actions variables the config declares against the ones the provider holds (read-only)",
5916
+ handler: async (argv) => {
5917
+ const tokens = tokenContext(argv.token);
5918
+ if (!tokens) return;
5919
+ const loaded = await loadConfig(argv.cwd);
5920
+ applyResolvedConfig(argv, loaded.resolved);
5921
+ if ((await runDoctorVariables({
5922
+ loaded,
5923
+ context: {
5924
+ repoRoot: argv.cwd,
5925
+ ...tokens,
5926
+ org: resolveOrg(argv, loaded.resolved)
5927
+ }
5928
+ })).status === "fail") process.exitCode = 1;
5929
+ }
5930
+ },
5931
+ async run(input) {
5932
+ const report = await runDoctorVariables(input);
5933
+ return {
5934
+ status: report.status,
5935
+ summary: report.summary,
5936
+ ...report.reason ? { reason: report.reason } : {}
5937
+ };
5938
+ }
5939
+ }
5940
+ ];
5941
+ // src/commands/doctor-all/doctor-all.ts
5942
+ /**
5943
+ * `holocron doctor --all` — run every deep check and print one row for each.
5944
+ *
5945
+ * A check's own steps are not printed (they are what `holocron doctor <name>` is for); a failing row says so.
5946
+ * A check that cannot run because a provider or token is missing is a skip with the reason. Any other error
5947
+ * fails that check alone, and the rest still run. The run fails when any check failed.
5948
+ */
5949
+ async function runDoctorAll(input) {
5950
+ const print = input.print ?? ((line) => console.log(line));
5951
+ const logger = input.logger ?? getLogger();
5952
+ const checks = input.checks ?? DEEP_CHECKS;
5953
+ const rows = [];
5954
+ for (const check of checks) rows.push(toRow(check, await outcomeOf(check, input)));
5955
+ printCheckRows(rows, print);
5956
+ const summary = summariseChecks(rows);
5957
+ printCheckSummary(summary, print);
5958
+ const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
5959
+ logger.info({
5960
+ ...summary,
5961
+ status,
5962
+ checks: rows.map((r) => `${r.id}:${r.status}`)
5963
+ }, "doctor --all");
5964
+ return {
5965
+ status,
5966
+ rows,
5967
+ summary
5968
+ };
5969
+ }
5970
+ /** Runs one check silently. A missing token is a skip; any other error is that check's failure. */
5971
+ async function outcomeOf(check, input) {
5972
+ try {
5973
+ return await check.run({
5974
+ loaded: input.loaded,
5975
+ context: input.context,
5976
+ print: () => {},
5977
+ ...input.logger ? { logger: input.logger } : {}
5978
+ });
5979
+ } catch (err) {
5980
+ if (err instanceof WorkspaceContextError) throw err;
5981
+ if (err instanceof MissingTokenError) return {
5982
+ status: "skip",
5983
+ summary: {
5984
+ ok: 0,
5985
+ fail: 0,
5986
+ skip: 1
5987
+ },
5988
+ reason: err.message
5989
+ };
5704
5990
  return {
5705
- status: report.status,
5706
- summary: report.summary,
5707
- ...report.reason ? { reason: report.reason } : {}
5991
+ status: "fail",
5992
+ summary: {
5993
+ ok: 0,
5994
+ fail: 1,
5995
+ skip: 0
5996
+ },
5997
+ reason: errorMessage(err)
5708
5998
  };
5709
5999
  }
5710
- }];
6000
+ }
6001
+ function toRow(check, outcome) {
6002
+ const { ok, fail, skip } = outcome.summary;
6003
+ const counts = [
6004
+ `${ok} ok`,
6005
+ ...fail > 0 ? [`${fail} failed`] : [],
6006
+ ...skip > 0 ? [`${skip} skipped`] : []
6007
+ ].join(", ");
6008
+ return {
6009
+ id: check.name,
6010
+ title: check.name,
6011
+ status: outcome.status,
6012
+ detail: outcome.status === "ok" ? counts : outcome.reason ?? counts,
6013
+ problems: outcome.status === "fail" ? [`run \`holocron doctor ${check.name}\` for the steps`] : []
6014
+ };
6015
+ }
5711
6016
  // src/commands/doctor/doctor.args.ts
5712
6017
  const doctorArgs = (y) => {
5713
- const withRepo = y.option("repo", {
6018
+ const withRepo = y.option("all", {
6019
+ type: "boolean",
6020
+ default: false,
6021
+ describe: "Run every deep check (doctor <capability>) and print one row each, instead of the smoke check"
6022
+ }).option("repo", {
5714
6023
  type: "string",
5715
6024
  describe: "Repo coords (\"owner/name\"). Defaults to plugin-specific resolution."
5716
6025
  });
@@ -5921,6 +6230,18 @@ const doctorCommand = {
5921
6230
  if (!tokens) return;
5922
6231
  const loaded = await loadConfig(argv.cwd);
5923
6232
  applyResolvedConfig(argv, loaded.resolved);
6233
+ if (argv.all) {
6234
+ if ((await runDoctorAll({
6235
+ loaded,
6236
+ context: {
6237
+ repoRoot: argv.cwd,
6238
+ ...argv.repo ? { repo: argv.repo } : {},
6239
+ ...tokens,
6240
+ org: resolveOrg(argv, loaded.resolved)
6241
+ }
6242
+ })).status === "fail") process.exitCode = 1;
6243
+ return;
6244
+ }
5924
6245
  if ((await runDoctor({
5925
6246
  loaded,
5926
6247
  context: {