@theholocron/cli 5.0.0-alpha.271 → 5.0.0-alpha.272
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 +9 -9
- package/dist/cli.mjs +86 -6
- package/dist/cli.mjs.map +1 -1
- package/dist/{compose-CDyegVKe.mjs → compose-8k8KP396.mjs} +21 -1
- package/dist/{index-CL7nYbMl.d.mts → index-DSzAZQdK.d.mts} +18 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -188,14 +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.
|
|
198
|
-
| `repo.secrets` | `{ repo?, org?, environments? }`
|
|
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?, sync? }` | 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. `sync: [{ environment, keys?, scope? }]` declares the vault environments `secrets sync` fills from; the doctor expects their keys (every key the `vault` provider lists when `keys` is omitted, names only) at the `scope` (`repo`, `env=<name>`, `org=<name>`). |
|
|
199
199
|
|
|
200
200
|
### Custom properties synced to GitHub
|
|
201
201
|
|
|
@@ -561,7 +561,7 @@ Channels fed by the error tracker add `feeds: { errors: true }` and a layout `re
|
|
|
561
561
|
|
|
562
562
|
`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.
|
|
563
563
|
|
|
564
|
-
`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`.
|
|
564
|
+
`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`, which also covers the keys of the vault environments declared in `repo.secrets.sync`.
|
|
565
565
|
|
|
566
566
|
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.
|
|
567
567
|
|
package/dist/cli.mjs
CHANGED
|
@@ -5640,13 +5640,14 @@ const doctorNotificationsCommand = {
|
|
|
5640
5640
|
})).status === "fail") process.exitCode = 1;
|
|
5641
5641
|
}
|
|
5642
5642
|
};
|
|
5643
|
-
// src/commands/doctor-secrets/
|
|
5643
|
+
// src/commands/doctor-secrets/unique-names.ts
|
|
5644
5644
|
/** Names that differ only in case are one secret to GitHub, so the first spelling wins. */
|
|
5645
|
-
const
|
|
5645
|
+
const uniqueNames = (names) => {
|
|
5646
5646
|
const seen = /* @__PURE__ */ new Map();
|
|
5647
5647
|
for (const name of names) if (!seen.has(name.toUpperCase())) seen.set(name.toUpperCase(), name);
|
|
5648
5648
|
return [...seen.values()];
|
|
5649
5649
|
};
|
|
5650
|
+
// src/commands/doctor-secrets/expected-secrets.ts
|
|
5650
5651
|
/**
|
|
5651
5652
|
* The secret a Chromatic project reads: `CHROMATIC_PROJECT_TOKEN` for `default` (or no name), otherwise
|
|
5652
5653
|
* `CHROMATIC_PROJECT_TOKEN_<NAME>`.
|
|
@@ -5661,9 +5662,69 @@ function expectedSecrets(config, layouts) {
|
|
|
5661
5662
|
const declared = config.repo?.secrets;
|
|
5662
5663
|
const chromatic = (config.tasks ?? []).flatMap((task) => typeof task === "object" && task.name === "verification.visualRegression" ? (task.with?.["chromatic-projects"] ?? []).map((project) => chromaticSecret(project.tokenName)) : []);
|
|
5663
5664
|
return {
|
|
5664
|
-
repo:
|
|
5665
|
-
org:
|
|
5666
|
-
environments: Object.fromEntries(Object.entries(declared?.environments ?? {}).map(([env, names]) => [env,
|
|
5665
|
+
repo: uniqueNames([...declared?.repo ?? [], ...chromatic]),
|
|
5666
|
+
org: uniqueNames([...declared?.org ?? [], ...layouts.flatMap(layoutSecretNames)]),
|
|
5667
|
+
environments: Object.fromEntries(Object.entries(declared?.environments ?? {}).map(([env, names]) => [env, uniqueNames(names)]))
|
|
5668
|
+
};
|
|
5669
|
+
}
|
|
5670
|
+
// src/commands/doctor-secrets/synced-secrets.ts
|
|
5671
|
+
/**
|
|
5672
|
+
* The secrets `holocron secrets sync` fills from a vault, as `repo.secrets.sync` declares them: which names land at
|
|
5673
|
+
* which scope. An entry that lists `keys` needs no vault. One that does not asks the vault which keys the environment
|
|
5674
|
+
* holds, and only the names are kept: the values the provider returns are dropped at once and never logged or printed.
|
|
5675
|
+
* An entry that cannot be resolved (no vault, no token, an environment the vault cannot list) is a skipped row with
|
|
5676
|
+
* the reason, and an unreadable `scope` is a failed one.
|
|
5677
|
+
*
|
|
5678
|
+
* @param entries - `repo.secrets.sync`.
|
|
5679
|
+
* @param vault - The `vault` provider, or why there is none.
|
|
5680
|
+
*/
|
|
5681
|
+
async function syncedSecrets(entries, vault) {
|
|
5682
|
+
const scopes = [];
|
|
5683
|
+
const rows = [];
|
|
5684
|
+
for (const entry of entries) {
|
|
5685
|
+
const id = `sync-${entry.environment}`;
|
|
5686
|
+
const title = `${entry.environment} vault environment is synced`;
|
|
5687
|
+
let scope;
|
|
5688
|
+
try {
|
|
5689
|
+
scope = parseScope(entry.scope ?? "repo");
|
|
5690
|
+
} catch (err) {
|
|
5691
|
+
rows.push({
|
|
5692
|
+
id,
|
|
5693
|
+
title,
|
|
5694
|
+
status: "fail",
|
|
5695
|
+
detail: "1 problem(s)",
|
|
5696
|
+
problems: [describeProviderError(err)]
|
|
5697
|
+
});
|
|
5698
|
+
continue;
|
|
5699
|
+
}
|
|
5700
|
+
if (entry.keys) {
|
|
5701
|
+
scopes.push({
|
|
5702
|
+
scope,
|
|
5703
|
+
names: entry.keys
|
|
5704
|
+
});
|
|
5705
|
+
continue;
|
|
5706
|
+
}
|
|
5707
|
+
const skip = (detail) => rows.push({
|
|
5708
|
+
id,
|
|
5709
|
+
title,
|
|
5710
|
+
status: "skip",
|
|
5711
|
+
detail,
|
|
5712
|
+
problems: []
|
|
5713
|
+
});
|
|
5714
|
+
if ("why" in vault) skip(vault.why);
|
|
5715
|
+
else if (!vault.readEnvironment) skip(`vault provider (${vault.providerName}) cannot list an environment's keys`);
|
|
5716
|
+
else try {
|
|
5717
|
+
scopes.push({
|
|
5718
|
+
scope,
|
|
5719
|
+
names: Object.keys(await vault.readEnvironment(entry.environment))
|
|
5720
|
+
});
|
|
5721
|
+
} catch (err) {
|
|
5722
|
+
skip(err instanceof MissingTokenError ? err.message : `could not read vault environment ${entry.environment}: ${describeProviderError(err)}`);
|
|
5723
|
+
}
|
|
5724
|
+
}
|
|
5725
|
+
return {
|
|
5726
|
+
scopes,
|
|
5727
|
+
rows
|
|
5667
5728
|
};
|
|
5668
5729
|
}
|
|
5669
5730
|
// src/commands/doctor-secrets/doctor-secrets.ts
|
|
@@ -5684,6 +5745,12 @@ async function runDoctorSecrets(input) {
|
|
|
5684
5745
|
const config = input.loaded.resolved;
|
|
5685
5746
|
const expected = expectedSecrets(config, (loader.has("notifications") ? loader.get("notifications") : []).flatMap((p) => p.layout ? [p.layout] : []));
|
|
5686
5747
|
const org = input.context.org ?? (input.context.repo ?? config.repo?.name ?? "").split("/")[0];
|
|
5748
|
+
const synced = await syncedSecrets(config.repo?.secrets?.sync ?? [], loader.has("vault") ? loader.get("vault") : { why: whyMissing(loader, "vault", "no `vault` provider to list the environment's keys with") });
|
|
5749
|
+
const foreignOrgs = /* @__PURE__ */ new Map();
|
|
5750
|
+
for (const { scope, names } of synced.scopes) if (scope.kind === "repo") expected.repo = uniqueNames([...expected.repo, ...names]);
|
|
5751
|
+
else if (scope.kind === "environment") expected.environments[scope.name] = uniqueNames([...expected.environments[scope.name] ?? [], ...names]);
|
|
5752
|
+
else if (scope.name === org) expected.org = uniqueNames([...expected.org, ...names]);
|
|
5753
|
+
else foreignOrgs.set(scope.name, uniqueNames([...foreignOrgs.get(scope.name) ?? [], ...names]));
|
|
5687
5754
|
const checks = [];
|
|
5688
5755
|
if (expected.repo.length > 0) checks.push({
|
|
5689
5756
|
id: "repo-secrets",
|
|
@@ -5712,8 +5779,20 @@ async function runDoctorSecrets(input) {
|
|
|
5712
5779
|
names
|
|
5713
5780
|
});
|
|
5714
5781
|
}
|
|
5782
|
+
for (const [name, names] of foreignOrgs) {
|
|
5783
|
+
if (names.length === 0) continue;
|
|
5784
|
+
checks.push({
|
|
5785
|
+
id: `org-secrets-${name}`,
|
|
5786
|
+
title: `${name} organization secrets exist`,
|
|
5787
|
+
scope: {
|
|
5788
|
+
kind: "organization",
|
|
5789
|
+
name
|
|
5790
|
+
},
|
|
5791
|
+
names
|
|
5792
|
+
});
|
|
5793
|
+
}
|
|
5715
5794
|
const rows = [];
|
|
5716
|
-
if (checks.length === 0) rows.push({
|
|
5795
|
+
if (checks.length === 0 && synced.rows.length === 0) rows.push({
|
|
5717
5796
|
id: "secrets",
|
|
5718
5797
|
title: "secrets",
|
|
5719
5798
|
status: "ok",
|
|
@@ -5733,6 +5812,7 @@ async function runDoctorSecrets(input) {
|
|
|
5733
5812
|
const secrets = loader.get("secrets");
|
|
5734
5813
|
for (const check of checks) rows.push(await checkScope(secrets, check));
|
|
5735
5814
|
}
|
|
5815
|
+
rows.push(...synced.rows);
|
|
5736
5816
|
printCheckRows(rows, print);
|
|
5737
5817
|
const summary = summariseChecks(rows);
|
|
5738
5818
|
printCheckSummary(summary, print);
|