@theholocron/cli 5.0.0-alpha.263 → 5.0.0-alpha.265
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 +14 -11
- package/dist/cli.mjs +403 -23
- package/dist/cli.mjs.map +1 -1
- package/dist/{index-BGZ_6iES.d.mts → index-CwxYoWzS.d.mts} +24 -1
- package/dist/{index-D0d--U7u.d.mts → index-DyTxSSgq.d.mts} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/plugin/capabilities.d.mts +2 -2
- package/dist/plugin/capabilities.mjs +9 -1
- package/dist/presets.d.mts +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -539,15 +539,16 @@ A `notifications` provider can declare a whole server in `holocron.config.ts`
|
|
|
539
539
|
pinned messages, onboarding, the bot application) and the CLI applies and checks it. The
|
|
540
540
|
commands and the config are provider-neutral; Discord is the first provider.
|
|
541
541
|
|
|
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
|
|
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 |
|
|
551
552
|
|
|
552
553
|
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).
|
|
553
554
|
|
|
@@ -555,6 +556,8 @@ Channels fed by the error tracker add `feeds: { errors: true }` and a layout `re
|
|
|
555
556
|
|
|
556
557
|
`holocron secrets sync <env> --worker <script>` also sets every key of the vault environment on a deployed Worker as a secret, through the optional `Workers.setSecret(script, name, value)` (write-only; the Cloudflare plugin implements it). The Worker must already exist. Sync only adds and updates: it never removes a binding, because a Worker also holds secrets that are not in the vault (for Comlink, the `COMLINK_<SOURCE>_WEBHOOK` that `notifications setup` sets), so a key deleted from the vault must be deleted from the Worker separately. Keys are written one at a time and each is reported; if one fails, the exit code is 1 and re-running finishes the rest, since every write is idempotent.
|
|
557
558
|
|
|
559
|
+
`holocron secrets list [--scope repo|environment|organization] [--env <name>] [--json]` prints the names (never the values; GitHub does not return them) of the secrets at each scope, sorted, under a heading per scope. With no `--scope` it lists the repository, plus the organization (`--org`, `HOLOCRON_ORG` or the config's `org`) and the `--env` environment when they are known; `--scope` lists one. A scope that cannot be listed is reported under its heading and the rest are still listed; the exit code is 1 if any failed. `--json` prints `[{ scope, names, error? }]`. It is read-only, so `--dry-run` does not apply. Comparing the names with what the config expects is `doctor secrets`.
|
|
560
|
+
|
|
558
561
|
Pinned messages are declared under the provider's `layout` as `pinned: [{ channel, content }]` (`channel` is a channel in the layout, `content` up to 2000 characters); the layout is the whole set of messages the bot has pinned in those channels.
|
|
559
562
|
|
|
560
563
|
Config shape added for role sync and sign-in (all under the provider's `layout`):
|
|
@@ -762,11 +765,11 @@ the local override exists to exempt.
|
|
|
762
765
|
`astromech.reusableTemplates()` to `theholocron/.github` (a pure sync target —
|
|
763
766
|
never hand-edit its `.github/workflows/*`).
|
|
764
767
|
- `src/commands/` — `repo setup`, `repo sync`, `doctor`, `deploy`,
|
|
765
|
-
`monitoring check`, `secrets set`, `secrets sync`, `package publish`,
|
|
768
|
+
`monitoring check`, `secrets list`, `secrets set`, `secrets sync`, `package publish`,
|
|
766
769
|
`package bump-versions`, `sync github`, `repo upgrade node`,
|
|
767
770
|
`repo upgrade deps`, `new plugin`, `auth`, `notifications setup`,
|
|
768
771
|
`notifications channel add`, `notifications link`,
|
|
769
|
-
`notifications sync-roles`, `doctor notifications`
|
|
772
|
+
`notifications sync-roles`, `doctor notifications`, `doctor variables`
|
|
770
773
|
- `src/commands/doctor-checks/` and `src/commands/deep-checks/` — the shared row
|
|
771
774
|
renderer and `declaredVsActual` helper, and `DEEP_CHECKS`, the registry every
|
|
772
775
|
`doctor <capability>` is listed in
|
package/dist/cli.mjs
CHANGED
|
@@ -206,6 +206,7 @@ const COMMAND_CONTEXTS = {
|
|
|
206
206
|
"repo sync readme": "repo-aware",
|
|
207
207
|
doctor: "workspace",
|
|
208
208
|
"repo setup": "workspace",
|
|
209
|
+
"secrets list": "workspace",
|
|
209
210
|
"secrets set": "workspace",
|
|
210
211
|
"secrets sync": "workspace",
|
|
211
212
|
"notifications channel add": "workspace",
|
|
@@ -214,6 +215,7 @@ const COMMAND_CONTEXTS = {
|
|
|
214
215
|
"notifications create-server": "workspace",
|
|
215
216
|
"notifications sync-roles": "workspace",
|
|
216
217
|
"doctor notifications": "workspace",
|
|
218
|
+
"doctor variables": "workspace",
|
|
217
219
|
probe: "workspace",
|
|
218
220
|
deploy: "workspace",
|
|
219
221
|
"deploy cleanup-preview": "workspace",
|
|
@@ -1417,6 +1419,13 @@ const doctorNotificationsEntry = {
|
|
|
1417
1419
|
}],
|
|
1418
1420
|
supportsDryRun: false
|
|
1419
1421
|
};
|
|
1422
|
+
// src/commands/doctor-variables/doctor-variables.entry.ts
|
|
1423
|
+
const doctorVariablesEntry = {
|
|
1424
|
+
name: "doctor variables",
|
|
1425
|
+
description: "Check the Actions variables the config declares against the ones the provider holds (read-only)",
|
|
1426
|
+
positionals: [],
|
|
1427
|
+
supportsDryRun: false
|
|
1428
|
+
};
|
|
1420
1429
|
// src/commands/monitoring-check/monitoring-check.entry.ts
|
|
1421
1430
|
const monitoringCheckEntry = {
|
|
1422
1431
|
name: "monitoring check",
|
|
@@ -1602,6 +1611,12 @@ const COMMAND_REGISTRY = [
|
|
|
1602
1611
|
}],
|
|
1603
1612
|
supportsDryRun: true
|
|
1604
1613
|
},
|
|
1614
|
+
{
|
|
1615
|
+
name: "secrets list",
|
|
1616
|
+
description: "List the names of the secrets at each scope (never the values)",
|
|
1617
|
+
positionals: [],
|
|
1618
|
+
supportsDryRun: false
|
|
1619
|
+
},
|
|
1605
1620
|
{
|
|
1606
1621
|
name: "secrets sync",
|
|
1607
1622
|
description: "Read a vault environment + fan KEY=VALUEs out to secrets + deployment env vars",
|
|
@@ -1614,6 +1629,7 @@ const COMMAND_REGISTRY = [
|
|
|
1614
1629
|
},
|
|
1615
1630
|
notificationsChannelAddEntry,
|
|
1616
1631
|
doctorNotificationsEntry,
|
|
1632
|
+
doctorVariablesEntry,
|
|
1617
1633
|
notificationsSetupEntry,
|
|
1618
1634
|
notificationsCreateServerEntry,
|
|
1619
1635
|
notificationsLinkEntry,
|
|
@@ -2171,6 +2187,14 @@ var ElevationRequiredError = class extends Error {
|
|
|
2171
2187
|
this.elevation = elevation;
|
|
2172
2188
|
}
|
|
2173
2189
|
};
|
|
2190
|
+
/**
|
|
2191
|
+
* A provider cannot do a read because it has no token for it. A check that meets this skips with the message instead
|
|
2192
|
+
* of failing: the token is missing, not wrong.
|
|
2193
|
+
*/
|
|
2194
|
+
var MissingTokenError = class extends Error {
|
|
2195
|
+
/** Lets a caller tell this error from any other by name, across package copies. */
|
|
2196
|
+
name = "MissingTokenError";
|
|
2197
|
+
};
|
|
2174
2198
|
// src/config/config/config.ts
|
|
2175
2199
|
var ConfigError = class extends Error {
|
|
2176
2200
|
name = "ConfigError";
|
|
@@ -3882,6 +3906,29 @@ function logReason(err) {
|
|
|
3882
3906
|
const root = err instanceof Error && err.cause !== void 0 ? err.cause : err;
|
|
3883
3907
|
return errorMessage(root);
|
|
3884
3908
|
}
|
|
3909
|
+
// src/commands/doctor-checks/declared-vs-actual.ts
|
|
3910
|
+
/**
|
|
3911
|
+
* Compares what the config declares with what exists, both as maps by key, and returns one problem line per
|
|
3912
|
+
* difference: a declared key that is missing, a key found but not declared, a key whose values disagree.
|
|
3913
|
+
* An empty list means they match. A deep check is then a list of these comparisons, not a renderer of its own.
|
|
3914
|
+
*/
|
|
3915
|
+
function declaredVsActual(declared, actual, options) {
|
|
3916
|
+
const equal = options.equal ?? ((a, b) => a === b);
|
|
3917
|
+
const show = options.show ?? ((value) => String(value));
|
|
3918
|
+
const problems = [];
|
|
3919
|
+
for (const [key, want] of declared) {
|
|
3920
|
+
if (!actual.has(key)) {
|
|
3921
|
+
problems.push(`missing ${options.noun} ${key}`);
|
|
3922
|
+
continue;
|
|
3923
|
+
}
|
|
3924
|
+
const found = actual.get(key);
|
|
3925
|
+
if (!equal(want, found)) problems.push(`${options.noun} ${key}: declared ${show(want)}, found ${show(found)}`);
|
|
3926
|
+
}
|
|
3927
|
+
if (options.flagExtra !== false) {
|
|
3928
|
+
for (const key of actual.keys()) if (!declared.has(key)) problems.push(`unexpected ${options.noun} ${key}`);
|
|
3929
|
+
}
|
|
3930
|
+
return problems;
|
|
3931
|
+
}
|
|
3885
3932
|
// src/commands/doctor-checks/print-check-rows.ts
|
|
3886
3933
|
/** One row per step, titles padded to the widest, each problem on its own indented line. */
|
|
3887
3934
|
function printCheckRows(rows, print) {
|
|
@@ -3897,6 +3944,15 @@ function printCheckSummary(summary, print) {
|
|
|
3897
3944
|
print("");
|
|
3898
3945
|
print(style.header(`${summary.ok} ok, ${summary.fail} fail, ${summary.skip} skipped`));
|
|
3899
3946
|
}
|
|
3947
|
+
// src/commands/doctor-checks/summarise-checks.ts
|
|
3948
|
+
/** How many rows ended each way. */
|
|
3949
|
+
function summariseChecks(rows) {
|
|
3950
|
+
return {
|
|
3951
|
+
ok: rows.filter((r) => r.status === "ok").length,
|
|
3952
|
+
fail: rows.filter((r) => r.status === "fail").length,
|
|
3953
|
+
skip: rows.filter((r) => r.status === "skip").length
|
|
3954
|
+
};
|
|
3955
|
+
}
|
|
3900
3956
|
// src/commands/notifications-channel-add/avatar.ts
|
|
3901
3957
|
/**
|
|
3902
3958
|
* Read a webhook avatar named in a layout: a file path (from the directory the CLI runs in) or an
|
|
@@ -5432,6 +5488,175 @@ async function runDoctorNotifications(input) {
|
|
|
5432
5488
|
}, print);
|
|
5433
5489
|
return finish();
|
|
5434
5490
|
}
|
|
5491
|
+
// src/commands/doctor-notifications/doctor-notifications.command.ts
|
|
5492
|
+
const doctorNotificationsCommand = {
|
|
5493
|
+
command: "notifications",
|
|
5494
|
+
describe: "Check the layout against the server and the secrets store, step by step (a full run leaves one test post in the test channel; --built-only posts nothing unless --deliver)",
|
|
5495
|
+
builder: doctorNotificationsArgs,
|
|
5496
|
+
handler: async (argv) => {
|
|
5497
|
+
const tokens = tokenContext(argv.token);
|
|
5498
|
+
if (!tokens) return;
|
|
5499
|
+
const loaded = await loadConfig(argv.cwd);
|
|
5500
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
5501
|
+
if ((await runDoctorNotifications({
|
|
5502
|
+
loaded,
|
|
5503
|
+
context: {
|
|
5504
|
+
repoRoot: argv.cwd,
|
|
5505
|
+
...tokens,
|
|
5506
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
5507
|
+
},
|
|
5508
|
+
...argv.scope ? { scope: parseScope(argv.scope) } : {},
|
|
5509
|
+
...argv.provider ? { provider: argv.provider } : {},
|
|
5510
|
+
...argv.builtOnly ? { builtOnly: true } : {},
|
|
5511
|
+
...argv.deliver ? { deliver: true } : {}
|
|
5512
|
+
})).status === "fail") process.exitCode = 1;
|
|
5513
|
+
}
|
|
5514
|
+
};
|
|
5515
|
+
// src/commands/doctor-variables/doctor-variables.ts
|
|
5516
|
+
/**
|
|
5517
|
+
* `holocron doctor variables` — do the Actions variables `repo.variables` declares exist, with those values?
|
|
5518
|
+
*
|
|
5519
|
+
* Read-only. One row for the repository's variables and one for the organization's, each only when the config
|
|
5520
|
+
* declares that scope. A variable that exists but is not declared is a problem only with `repo.variables.prune`,
|
|
5521
|
+
* since without it `repo setup` leaves it alone. A scope that cannot be read because there is no provider, the
|
|
5522
|
+
* provider cannot list variables, or the token is missing is a skip with the reason, not a failure.
|
|
5523
|
+
*/
|
|
5524
|
+
const REPO_TITLE = "repository variables match";
|
|
5525
|
+
const ORG_TITLE = "organization variables match";
|
|
5526
|
+
async function runDoctorVariables(input) {
|
|
5527
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
5528
|
+
const logger = input.logger ?? getLogger();
|
|
5529
|
+
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
5530
|
+
await loader.load();
|
|
5531
|
+
assertPluginsResolvable(loader, "doctor variables");
|
|
5532
|
+
const config = input.loaded.resolved;
|
|
5533
|
+
const variables = config.repo?.variables;
|
|
5534
|
+
const prune = variables?.prune === true;
|
|
5535
|
+
const declares = (scope) => scope !== void 0 && (Object.keys(scope).length > 0 || prune);
|
|
5536
|
+
const checks = [];
|
|
5537
|
+
if (declares(variables?.repo)) checks.push({
|
|
5538
|
+
id: "repo-variables",
|
|
5539
|
+
title: REPO_TITLE,
|
|
5540
|
+
async run(source) {
|
|
5541
|
+
if (!source.listVariables) return { skip: "provider does not implement listVariables" };
|
|
5542
|
+
const declared = variables.repo;
|
|
5543
|
+
return {
|
|
5544
|
+
problems: compareRepo(declared, await source.listVariables(), prune),
|
|
5545
|
+
checked: Object.keys(declared).length
|
|
5546
|
+
};
|
|
5547
|
+
}
|
|
5548
|
+
});
|
|
5549
|
+
if (declares(variables?.org)) checks.push({
|
|
5550
|
+
id: "org-variables",
|
|
5551
|
+
title: ORG_TITLE,
|
|
5552
|
+
async run(source) {
|
|
5553
|
+
if (!source.listOrgVariables) return { skip: "provider does not implement listOrgVariables" };
|
|
5554
|
+
const org = input.context.org ?? (input.context.repo ?? config.repo?.name ?? "").split("/")[0];
|
|
5555
|
+
if (!org) return {
|
|
5556
|
+
problems: ["no organization: set `org` in the config or run inside a repository"],
|
|
5557
|
+
checked: 0
|
|
5558
|
+
};
|
|
5559
|
+
const declared = variables.org;
|
|
5560
|
+
return {
|
|
5561
|
+
problems: compareOrg(declared, await source.listOrgVariables(org), prune),
|
|
5562
|
+
checked: Object.keys(declared).length
|
|
5563
|
+
};
|
|
5564
|
+
}
|
|
5565
|
+
});
|
|
5566
|
+
const rows = [];
|
|
5567
|
+
if (checks.length === 0) rows.push({
|
|
5568
|
+
id: "variables",
|
|
5569
|
+
title: "variables",
|
|
5570
|
+
status: "ok",
|
|
5571
|
+
detail: "none declared",
|
|
5572
|
+
problems: []
|
|
5573
|
+
});
|
|
5574
|
+
else if (!loader.has("source")) {
|
|
5575
|
+
const why = whyMissing(loader, "source", "no `source` provider to read them with");
|
|
5576
|
+
for (const check of checks) rows.push(row(check, { skip: why }));
|
|
5577
|
+
} else {
|
|
5578
|
+
const source = loader.get("source");
|
|
5579
|
+
for (const check of checks) try {
|
|
5580
|
+
rows.push(row(check, await check.run(source)));
|
|
5581
|
+
} catch (err) {
|
|
5582
|
+
if (err instanceof MissingTokenError) rows.push(row(check, { skip: err.message }));
|
|
5583
|
+
else rows.push({
|
|
5584
|
+
id: check.id,
|
|
5585
|
+
title: check.title,
|
|
5586
|
+
status: "fail",
|
|
5587
|
+
detail: errorMessage(err),
|
|
5588
|
+
problems: []
|
|
5589
|
+
});
|
|
5590
|
+
}
|
|
5591
|
+
}
|
|
5592
|
+
printCheckRows(rows, print);
|
|
5593
|
+
const summary = summariseChecks(rows);
|
|
5594
|
+
printCheckSummary(summary, print);
|
|
5595
|
+
const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
|
|
5596
|
+
logger.info({
|
|
5597
|
+
...summary,
|
|
5598
|
+
status
|
|
5599
|
+
}, "doctor variables");
|
|
5600
|
+
return {
|
|
5601
|
+
status,
|
|
5602
|
+
rows,
|
|
5603
|
+
summary,
|
|
5604
|
+
...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
|
|
5605
|
+
};
|
|
5606
|
+
}
|
|
5607
|
+
function row(check, result) {
|
|
5608
|
+
const { id, title } = check;
|
|
5609
|
+
if ("skip" in result) return {
|
|
5610
|
+
id,
|
|
5611
|
+
title,
|
|
5612
|
+
status: "skip",
|
|
5613
|
+
detail: result.skip,
|
|
5614
|
+
problems: []
|
|
5615
|
+
};
|
|
5616
|
+
if (result.problems.length > 0) return {
|
|
5617
|
+
id,
|
|
5618
|
+
title,
|
|
5619
|
+
status: "fail",
|
|
5620
|
+
detail: `${result.problems.length} problem(s)`,
|
|
5621
|
+
problems: result.problems
|
|
5622
|
+
};
|
|
5623
|
+
return {
|
|
5624
|
+
id,
|
|
5625
|
+
title,
|
|
5626
|
+
status: "ok",
|
|
5627
|
+
detail: `${result.checked} of ${result.checked} match`,
|
|
5628
|
+
problems: []
|
|
5629
|
+
};
|
|
5630
|
+
}
|
|
5631
|
+
/** Re-keys what GitHub holds by the spelling the config declares, since GitHub treats names as case-insensitive. */
|
|
5632
|
+
function bySpelling(declared, have) {
|
|
5633
|
+
const spelled = new Map(declared.map((name) => [name.toUpperCase(), name]));
|
|
5634
|
+
return new Map(Object.entries(have).map(([name, value]) => [spelled.get(name.toUpperCase()) ?? name, value]));
|
|
5635
|
+
}
|
|
5636
|
+
function compareRepo(declared, have, prune) {
|
|
5637
|
+
return declaredVsActual(new Map(Object.entries(declared)), bySpelling(Object.keys(declared), have), {
|
|
5638
|
+
noun: "variable",
|
|
5639
|
+
flagExtra: prune,
|
|
5640
|
+
show: (value) => JSON.stringify(value)
|
|
5641
|
+
});
|
|
5642
|
+
}
|
|
5643
|
+
function compareOrg(declared, have, prune) {
|
|
5644
|
+
const wanted = new Map(Object.entries(declared).map(([name, v]) => [name, typeof v === "string" ? {
|
|
5645
|
+
value: v,
|
|
5646
|
+
visibility: "all"
|
|
5647
|
+
} : {
|
|
5648
|
+
value: v.value,
|
|
5649
|
+
visibility: v.visibility ?? "all"
|
|
5650
|
+
}]));
|
|
5651
|
+
const found = bySpelling(Object.keys(declared), have);
|
|
5652
|
+
for (const [name, v] of found) if (!wanted.has(name) && v.visibility === "selected") found.delete(name);
|
|
5653
|
+
return declaredVsActual(wanted, found, {
|
|
5654
|
+
noun: "organization variable",
|
|
5655
|
+
flagExtra: prune,
|
|
5656
|
+
equal: (a, b) => a.value === b.value && a.visibility === b.visibility,
|
|
5657
|
+
show: (v) => `${JSON.stringify(v.value)} (${v.visibility})`
|
|
5658
|
+
});
|
|
5659
|
+
}
|
|
5435
5660
|
// src/commands/deep-checks/deep-checks.ts
|
|
5436
5661
|
/**
|
|
5437
5662
|
* Every `doctor <capability>` deep check, in the order `doctor --all` runs them. Adding one is an entry here
|
|
@@ -5440,39 +5665,46 @@ async function runDoctorNotifications(input) {
|
|
|
5440
5665
|
const DEEP_CHECKS = [{
|
|
5441
5666
|
name: "notifications",
|
|
5442
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",
|
|
5443
5684
|
command: {
|
|
5444
|
-
command: "
|
|
5445
|
-
describe: "Check the
|
|
5446
|
-
builder: doctorNotificationsArgs,
|
|
5685
|
+
command: "variables",
|
|
5686
|
+
describe: "Check the Actions variables the config declares against the ones the provider holds (read-only)",
|
|
5447
5687
|
handler: async (argv) => {
|
|
5448
5688
|
const tokens = tokenContext(argv.token);
|
|
5449
5689
|
if (!tokens) return;
|
|
5450
5690
|
const loaded = await loadConfig(argv.cwd);
|
|
5451
5691
|
applyResolvedConfig(argv, loaded.resolved);
|
|
5452
|
-
if ((await
|
|
5692
|
+
if ((await runDoctorVariables({
|
|
5453
5693
|
loaded,
|
|
5454
5694
|
context: {
|
|
5455
5695
|
repoRoot: argv.cwd,
|
|
5456
5696
|
...tokens,
|
|
5457
5697
|
org: resolveOrg(argv, loaded.resolved)
|
|
5458
|
-
}
|
|
5459
|
-
...argv.scope ? { scope: parseScope(argv.scope) } : {},
|
|
5460
|
-
...argv.provider ? { provider: argv.provider } : {},
|
|
5461
|
-
...argv.builtOnly ? { builtOnly: true } : {},
|
|
5462
|
-
...argv.deliver ? { deliver: true } : {}
|
|
5698
|
+
}
|
|
5463
5699
|
})).status === "fail") process.exitCode = 1;
|
|
5464
5700
|
}
|
|
5465
5701
|
},
|
|
5466
5702
|
async run(input) {
|
|
5467
|
-
const report = await
|
|
5703
|
+
const report = await runDoctorVariables(input);
|
|
5468
5704
|
return {
|
|
5469
5705
|
status: report.status,
|
|
5470
|
-
summary:
|
|
5471
|
-
|
|
5472
|
-
fail: report.summary.fail,
|
|
5473
|
-
skip: report.summary.skip
|
|
5474
|
-
},
|
|
5475
|
-
...report.message ? { reason: report.message } : {}
|
|
5706
|
+
summary: report.summary,
|
|
5707
|
+
...report.reason ? { reason: report.reason } : {}
|
|
5476
5708
|
};
|
|
5477
5709
|
}
|
|
5478
5710
|
}];
|
|
@@ -15188,9 +15420,9 @@ async function runSecretSet(input) {
|
|
|
15188
15420
|
if (!loader.has("secrets")) throw new Error("`secrets` capability is not configured — add a `secrets` provider to holocron.config.json");
|
|
15189
15421
|
const value = await resolveValue(input);
|
|
15190
15422
|
if (!value) throw new Error(`no value for secret \`${input.name}\` — pass it positionally, via --from-stdin, --from-env <NAME>, or set $${input.name} in the environment`);
|
|
15191
|
-
print(`Holocron secret set — ${input.name} (${describeScope(scope)})${dryRun ? " (dry-run)" : ""}`);
|
|
15423
|
+
print(`Holocron secret set — ${input.name} (${describeScope$1(scope)})${dryRun ? " (dry-run)" : ""}`);
|
|
15192
15424
|
if (dryRun) {
|
|
15193
|
-
const message = `would: secrets.setSecret(${describeScope(scope)}, ${input.name}, <${value.length} chars>)`;
|
|
15425
|
+
const message = `would: secrets.setSecret(${describeScope$1(scope)}, ${input.name}, <${value.length} chars>)`;
|
|
15194
15426
|
print(` … ${message}`);
|
|
15195
15427
|
return {
|
|
15196
15428
|
status: "dry-run",
|
|
@@ -15205,7 +15437,7 @@ async function runSecretSet(input) {
|
|
|
15205
15437
|
print(` ✓ set ${input.name} via ${secrets.providerName}`);
|
|
15206
15438
|
logger.info({
|
|
15207
15439
|
key: input.name,
|
|
15208
|
-
scope: describeScope(scope),
|
|
15440
|
+
scope: describeScope$1(scope),
|
|
15209
15441
|
provider: secrets.providerName,
|
|
15210
15442
|
status: "ok"
|
|
15211
15443
|
}, `secret set: ${input.name}`);
|
|
@@ -15219,7 +15451,7 @@ async function runSecretSet(input) {
|
|
|
15219
15451
|
print(` ✗ ${message}`);
|
|
15220
15452
|
logger.warn({
|
|
15221
15453
|
key: input.name,
|
|
15222
|
-
scope: describeScope(scope),
|
|
15454
|
+
scope: describeScope$1(scope),
|
|
15223
15455
|
reason: message
|
|
15224
15456
|
}, `secret set: ${input.name}`);
|
|
15225
15457
|
return {
|
|
@@ -15244,7 +15476,7 @@ async function defaultReadStdin() {
|
|
|
15244
15476
|
process.stdin.on("error", reject);
|
|
15245
15477
|
});
|
|
15246
15478
|
}
|
|
15247
|
-
function describeScope(scope) {
|
|
15479
|
+
function describeScope$1(scope) {
|
|
15248
15480
|
if (scope.kind === "repo") return "scope=repo";
|
|
15249
15481
|
if (scope.kind === "environment") return `scope=environment:${scope.name}`;
|
|
15250
15482
|
return `scope=organization:${scope.name}`;
|
|
@@ -15297,6 +15529,154 @@ const secretSetCommand = {
|
|
|
15297
15529
|
})).status === "fail") process.exitCode = 1;
|
|
15298
15530
|
}
|
|
15299
15531
|
};
|
|
15532
|
+
// src/commands/secrets-list/secrets-list.ts
|
|
15533
|
+
/**
|
|
15534
|
+
* `holocron secrets list` — which secrets exist, by name, at each scope.
|
|
15535
|
+
*
|
|
15536
|
+
* Read-only: GitHub never returns a value, so only names are printed. A scope
|
|
15537
|
+
* that cannot be listed (a token without the scope, a missing environment) is
|
|
15538
|
+
* reported under its heading and counted, and the other scopes are still
|
|
15539
|
+
* listed; the command exits non-zero when any failed.
|
|
15540
|
+
*/
|
|
15541
|
+
async function runSecretsList(input) {
|
|
15542
|
+
const print = input.print ?? ((line) => console.log(line));
|
|
15543
|
+
const logger = input.logger ?? getLogger();
|
|
15544
|
+
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
15545
|
+
await loader.load();
|
|
15546
|
+
assertPluginsResolvable(loader, "secrets list");
|
|
15547
|
+
if (!loader.has("secrets")) throw new Error("`secrets` capability is not configured — add a `secrets` provider to holocron.config.json");
|
|
15548
|
+
const secrets = loader.get("secrets");
|
|
15549
|
+
const groups = [];
|
|
15550
|
+
for (const scope of input.scopes) {
|
|
15551
|
+
const label = describeScope(scope);
|
|
15552
|
+
try {
|
|
15553
|
+
const names = [...await secrets.listSecrets(scope)].sort();
|
|
15554
|
+
groups.push({
|
|
15555
|
+
scope,
|
|
15556
|
+
label,
|
|
15557
|
+
names
|
|
15558
|
+
});
|
|
15559
|
+
logger.info({
|
|
15560
|
+
scope: label,
|
|
15561
|
+
count: names.length,
|
|
15562
|
+
provider: secrets.providerName
|
|
15563
|
+
}, `secrets list: ${label}`);
|
|
15564
|
+
} catch (err) {
|
|
15565
|
+
const error = errorMessage(err);
|
|
15566
|
+
groups.push({
|
|
15567
|
+
scope,
|
|
15568
|
+
label,
|
|
15569
|
+
names: [],
|
|
15570
|
+
error
|
|
15571
|
+
});
|
|
15572
|
+
logger.warn({
|
|
15573
|
+
scope: label,
|
|
15574
|
+
reason: error
|
|
15575
|
+
}, `secrets list: ${label}`);
|
|
15576
|
+
}
|
|
15577
|
+
}
|
|
15578
|
+
const report = {
|
|
15579
|
+
groups,
|
|
15580
|
+
failed: groups.filter((g) => g.error !== void 0).length
|
|
15581
|
+
};
|
|
15582
|
+
if (input.json) print(JSON.stringify(groups.map(({ label: _label, ...group }) => group), null, 2));
|
|
15583
|
+
else printGroups(groups, print);
|
|
15584
|
+
return report;
|
|
15585
|
+
}
|
|
15586
|
+
function printGroups(groups, print) {
|
|
15587
|
+
for (const [index, group] of groups.entries()) {
|
|
15588
|
+
if (index > 0) print("");
|
|
15589
|
+
print(group.label);
|
|
15590
|
+
if (group.error !== void 0) print(` ✗ ${group.error}`);
|
|
15591
|
+
else if (group.names.length === 0) print(" (none)");
|
|
15592
|
+
else for (const name of group.names) print(` ${name}`);
|
|
15593
|
+
}
|
|
15594
|
+
}
|
|
15595
|
+
function describeScope(scope) {
|
|
15596
|
+
if (scope.kind === "repo") return "repo";
|
|
15597
|
+
return `${scope.kind} ${scope.name}`;
|
|
15598
|
+
}
|
|
15599
|
+
// src/commands/secrets-list/secrets-list-scopes.ts
|
|
15600
|
+
/**
|
|
15601
|
+
* Turns `--scope`, `--env` and the resolved organization into the scopes to list.
|
|
15602
|
+
* With no `--scope` it lists the repository, then the organization and the
|
|
15603
|
+
* environment when one was named. Naming a scope whose name is missing throws.
|
|
15604
|
+
*/
|
|
15605
|
+
function secretsListScopes(input) {
|
|
15606
|
+
const { scope, env, org } = input;
|
|
15607
|
+
if (scope === "repo") return [{ kind: "repo" }];
|
|
15608
|
+
if (scope === "environment") {
|
|
15609
|
+
if (!env) throw new Error("`--scope environment` needs `--env <name>`");
|
|
15610
|
+
return [{
|
|
15611
|
+
kind: "environment",
|
|
15612
|
+
name: env
|
|
15613
|
+
}];
|
|
15614
|
+
}
|
|
15615
|
+
if (scope === "organization") {
|
|
15616
|
+
if (!org) throw new Error("`--scope organization` needs `--org <name>` or `org` in holocron.config.ts");
|
|
15617
|
+
return [{
|
|
15618
|
+
kind: "organization",
|
|
15619
|
+
name: org
|
|
15620
|
+
}];
|
|
15621
|
+
}
|
|
15622
|
+
return [
|
|
15623
|
+
{ kind: "repo" },
|
|
15624
|
+
...org ? [{
|
|
15625
|
+
kind: "organization",
|
|
15626
|
+
name: org
|
|
15627
|
+
}] : [],
|
|
15628
|
+
...env ? [{
|
|
15629
|
+
kind: "environment",
|
|
15630
|
+
name: env
|
|
15631
|
+
}] : []
|
|
15632
|
+
];
|
|
15633
|
+
}
|
|
15634
|
+
// src/commands/secrets-list/secrets-list.args.ts
|
|
15635
|
+
const secretsListArgs = (y) => y.option("scope", {
|
|
15636
|
+
type: "string",
|
|
15637
|
+
choices: [
|
|
15638
|
+
"repo",
|
|
15639
|
+
"environment",
|
|
15640
|
+
"organization"
|
|
15641
|
+
],
|
|
15642
|
+
describe: "List one scope. Omitted: the repository, plus the organization and the --env environment."
|
|
15643
|
+
}).option("env", {
|
|
15644
|
+
type: "string",
|
|
15645
|
+
describe: "The environment to list (adds it to the default scopes; required with --scope environment)."
|
|
15646
|
+
}).option("json", {
|
|
15647
|
+
type: "boolean",
|
|
15648
|
+
default: false,
|
|
15649
|
+
describe: "Print one JSON document: [{ scope, names, error? }]"
|
|
15650
|
+
});
|
|
15651
|
+
// src/commands/secrets-list/secrets-list.command.ts
|
|
15652
|
+
const secretsListCommand = {
|
|
15653
|
+
command: "list",
|
|
15654
|
+
describe: "List the names of the secrets at each scope (never the values)",
|
|
15655
|
+
builder: secretsListArgs,
|
|
15656
|
+
handler: async (argv) => {
|
|
15657
|
+
const tokens = tokenContext(argv.token);
|
|
15658
|
+
if (!tokens) return;
|
|
15659
|
+
const loaded = await loadConfig(argv.cwd);
|
|
15660
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
15661
|
+
const org = resolveOrg(argv, loaded.resolved);
|
|
15662
|
+
const scopes = secretsListScopes({
|
|
15663
|
+
...argv.scope ? { scope: argv.scope } : {},
|
|
15664
|
+
...argv.env ? { env: argv.env } : {},
|
|
15665
|
+
...org ? { org } : {}
|
|
15666
|
+
});
|
|
15667
|
+
if ((await runSecretsList({
|
|
15668
|
+
loaded,
|
|
15669
|
+
context: {
|
|
15670
|
+
repoRoot: argv.cwd,
|
|
15671
|
+
dryRun: false,
|
|
15672
|
+
...tokens,
|
|
15673
|
+
org
|
|
15674
|
+
},
|
|
15675
|
+
scopes,
|
|
15676
|
+
json: argv.json
|
|
15677
|
+
})).failed > 0) process.exitCode = 1;
|
|
15678
|
+
}
|
|
15679
|
+
};
|
|
15300
15680
|
// src/commands/secrets-sync/secrets-sync.ts
|
|
15301
15681
|
/**
|
|
15302
15682
|
* `holocron secrets sync` — vault → destinations.
|
|
@@ -15563,8 +15943,8 @@ const secretsSyncCommand = {
|
|
|
15563
15943
|
// src/commands/secrets/secrets.command.ts
|
|
15564
15944
|
const secretsCommand = {
|
|
15565
15945
|
command: "secrets",
|
|
15566
|
-
describe: "
|
|
15567
|
-
builder: (y) => y.command(secretSetCommand).command(secretsSyncCommand).command(groupMenu("secrets")),
|
|
15946
|
+
describe: "List and set secrets, and sync vault environments",
|
|
15947
|
+
builder: (y) => y.command(secretSetCommand).command(secretsListCommand).command(secretsSyncCommand).command(groupMenu("secrets")),
|
|
15568
15948
|
handler: () => {}
|
|
15569
15949
|
};
|
|
15570
15950
|
// src/commands/skills/skills.args.ts
|