@theholocron/cli 5.0.0-alpha.352 → 5.0.0-alpha.354
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 -1
- package/dist/cli.mjs +77 -14
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-DU91-XEp.d.mts → config-system-CTXxGw0f.d.mts} +25 -2
- package/dist/{config-system-iuxern-U.mjs → config-system-DKtlo5Pb.mjs} +64 -9
- package/dist/{index-CArtx6o0.d.mts → index-CmdMBl-M.d.mts} +16 -0
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +3 -3
- package/dist/plugin/capabilities.d.mts +1 -1
- package/dist/presets.d.mts +1 -3
- package/dist/presets.mjs +5 -8
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -194,6 +194,7 @@ the list is never read):
|
|
|
194
194
|
| --------------------------- | ---------------------------------------------------------------------------------- |
|
|
195
195
|
| `.holocron/notifications.*` | the `layout` option of the `providers.notifications` entry (which keeps `guildId`) |
|
|
196
196
|
| `.holocron/repo.*` | keys of `repo` (`defaultBranch` stays inline: Sentinel needs it first) |
|
|
197
|
+
| `.holocron/org.*` | provider options the config leaves out (`teamId`, `accountId`), see below |
|
|
197
198
|
|
|
198
199
|
The file's default export is the value (`.ts` keeps its comments; `.json` needs no `import`, for repos with no
|
|
199
200
|
`package.json`). If both exist for one area, `.ts` wins over `.json`. A missing directory changes nothing. Setting the
|
|
@@ -237,6 +238,18 @@ is no per-key precedence: the loader does not let an inline key win, it refuses
|
|
|
237
238
|
repo's `.holocron/repo.ts` holds `teams`, `topics`, `variables` and `secrets`, names and identifiers only, typed with
|
|
238
239
|
`satisfies RepoConfig` (a type-only import).
|
|
239
240
|
|
|
241
|
+
**The `org` area** (#1820). The organization's constants that are provider options and that CI does not need:
|
|
242
|
+
`.holocron/org.ts` is `{ cloudflare: { accountId }, vercel: { teamId }, checkly: { accountId } }` (typed with
|
|
243
|
+
`satisfies OrgConfig`). The loader fills each of these into every provider entry of that name that leaves the option
|
|
244
|
+
out, so the config can say `deployment: ["vercel", { domain }]` and `monitoring: "checkly"`. The same option set inline
|
|
245
|
+
and in the file is an error that names both (`vercel.teamId is set in providers.deployment and in
|
|
246
|
+
.holocron/org.ts`), with no merge and no precedence. A provider key or an option the area does not know is an error; a
|
|
247
|
+
provider the config does not use is ignored. A config reads only the `.holocron/` beside it, so an app with its own
|
|
248
|
+
`holocron.config.ts` (`apps/sentinel`) has its own `.holocron/org.ts`. Anything CI needs (`CLOUDFLARE_ACCOUNT_ID`,
|
|
249
|
+
`TURBO_TEAM`, `AXIOM_DATASET`) stays out: it lives in 1Password and syncs to a GitHub variable (`repo.variables.sync`),
|
|
250
|
+
and nothing else carries a copy. `.holocron/org.md` (the agent contract the CLI embeds) is not an area: only
|
|
251
|
+
`.ts`, `.js`, `.mjs`, `.cjs` and `.json` are read.
|
|
252
|
+
|
|
240
253
|
### repo options
|
|
241
254
|
|
|
242
255
|
Additional `repo` fields recognised by `holocron repo setup`:
|
|
@@ -633,7 +646,7 @@ Channels fed by the error tracker add `feeds: { errors: true }` and a layout `re
|
|
|
633
646
|
|
|
634
647
|
`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`.
|
|
635
648
|
|
|
636
|
-
A channel with `kind: "forum"` is a forum, with `tags` (each a `name`, an `emoji` and whether it is `moderated`); `setup` adds and corrects the tags but never removes one, and a text channel of the same name must be deleted first, since neither kind can become the other. A forum takes no `webhook` or `feeds`.
|
|
649
|
+
A channel with `kind: "forum"` is a forum, with `tags` (each a `name`, an `emoji` and whether it is `moderated`); `setup` adds and corrects the tags but never removes one, and a text channel of the same name must be deleted first, since neither kind can become the other. A forum takes no `webhook` or `feeds`. `defaultReaction` is the emoji Discord offers on every post (its Get Started step "Set a default reaction for posts"); Discord allows only one, so `starterReactions` lists more (`["👍", "👎", "❓"]` for approve, disapprove, question) that the bot adds to the first message of each post `specs sync` makes. Existing posts are left alone, a reaction the bot cannot add is skipped, and `doctor notifications` checks `defaultReaction`. Unicode emoji only.
|
|
637
650
|
|
|
638
651
|
`holocron specs sync [--channel <forum>] [--files <paths...>] [--pr <number>] [--refresh] [--refresh-origin] [--refresh-titles] [--withdraw] [--notify]` keeps one forum post per ADR and spec in step with the files: it makes the post (titled with the document's own title, tagged with the file's status), writes its address into the file as `discussion.url`, and turns a gatekeeper's retag into an edit of the file's `status:` line in the working tree for a pull request. `--files` syncs only those files and `--pr` names a pull request on their posts, for a pull request that is still open. `--refresh-origin` is a one-off repair: it rewrites the `PR:` line of existing posts to the one the current rule names (the optional `prLine` of `DiscussionPatch`, and of `DiscussionPost`), and nothing else in them. `--refresh-titles` is the same kind of one-off repair for the title: it renames each existing post whose title differs from the current rule's (the optional `title` of `DiscussionPatch`, and of `DiscussionPost`) and changes nothing else; a rate limit stops it cleanly, reports how many documents are left, and the next run continues. The id that opens a post is a link to the file on the default branch (`repo.defaultBranch`, else `HEAD`) once the file is there, and plain text while `--pr` names an open pull request; the normal sync rewrites a post's id line (and only that line) whenever it is not the one the rule gives and no `--pr` is given, which covers a file that moved and a post made while its pull request was open, so it needs no extra request when every post is right and `--refresh` is no longer needed for it. `--refresh` runs the `PR:`, title and id-link repairs in one pass (the id link is the optional `idLine` of `DiscussionPatch`, and of `DiscussionPost`, which changes only the message's first line); `--refresh-origin` and `--refresh-titles` still do only their own. `--withdraw` (with `--files`, on the base branch) tags the posts of a pull request closed unmerged `withdrawn` and closes them; `withdrawn` is a tag only, never a file `status:`, and the next sync puts the file's own status back. It cannot be combined with `--refresh`, `--refresh-origin` or `--refresh-titles`. `--dry-run` previews it. See the [`specs sync` page](https://docs.theholocron.dev/holocron/commands/specs-sync/).
|
|
639
652
|
|
package/dist/cli.mjs
CHANGED
|
@@ -421,19 +421,23 @@ async function deriveDefaults$1(found) {
|
|
|
421
421
|
// src/config/load-config/holocron-areas/holocron-areas.ts
|
|
422
422
|
/**
|
|
423
423
|
* The closed list of area files `loadConfig` reads from `.holocron/` (the directory is `.<config name>`, set by kyber):
|
|
424
|
-
* `.holocron/notifications.*` fills `providers.notifications`' `layout`,
|
|
424
|
+
* `.holocron/notifications.*` fills `providers.notifications`' `layout`, `.holocron/repo.*` fills keys of `repo`, and `.holocron/org.*` fills provider options (`teamId`, `accountId`) a config leaves out.
|
|
425
425
|
* A file not on this list is never read.
|
|
426
426
|
*/
|
|
427
|
-
const HOLOCRON_AREAS = [
|
|
427
|
+
const HOLOCRON_AREAS = [
|
|
428
|
+
"notifications",
|
|
429
|
+
"repo",
|
|
430
|
+
"org"
|
|
431
|
+
];
|
|
428
432
|
// src/config/load-config/place-notifications/place-notifications.ts
|
|
429
|
-
const isTuple = (entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && typeof entry[1] === "object" && entry[1] !== null && !Array.isArray(entry[1]);
|
|
430
|
-
const providerName = (entry) => isTuple(entry) ? entry[0] : entry;
|
|
433
|
+
const isTuple$1 = (entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && typeof entry[1] === "object" && entry[1] !== null && !Array.isArray(entry[1]);
|
|
434
|
+
const providerName = (entry) => isTuple$1(entry) ? entry[0] : entry;
|
|
431
435
|
/** Index of the entry the layout belongs to in a multi-provider list: the first `discord`. */
|
|
432
436
|
function findDiscord(entries) {
|
|
433
437
|
return entries.findIndex((entry) => providerName(entry) === "discord");
|
|
434
438
|
}
|
|
435
439
|
function withLayout(entry, layout) {
|
|
436
|
-
return isTuple(entry) ? [entry[0], {
|
|
440
|
+
return isTuple$1(entry) ? [entry[0], {
|
|
437
441
|
...entry[1],
|
|
438
442
|
layout
|
|
439
443
|
}] : [entry, { layout }];
|
|
@@ -449,14 +453,14 @@ function placeNotifications(raw, area) {
|
|
|
449
453
|
const hint = `Set it in one place: remove the inline \`layout\` or delete ${area.path}`;
|
|
450
454
|
let placed;
|
|
451
455
|
if (entry === void 0) throw new ConfigError(`${area.path} holds the notifications layout, but providers.notifications is not set. Add \`notifications: ["discord", { guildId }]\` to providers`);
|
|
452
|
-
else if (Array.isArray(entry) && !isTuple(entry)) {
|
|
456
|
+
else if (Array.isArray(entry) && !isTuple$1(entry)) {
|
|
453
457
|
const index = findDiscord(entry);
|
|
454
458
|
if (index === -1) throw new ConfigError(`${area.path} holds the notifications layout, but providers.notifications has no discord entry`);
|
|
455
459
|
const target = entry[index];
|
|
456
|
-
if (isTuple(target) && target[1].layout !== void 0) throw new ConfigError(`the notifications layout is set in providers.notifications and in ${area.path}. ${hint}`);
|
|
460
|
+
if (isTuple$1(target) && target[1].layout !== void 0) throw new ConfigError(`the notifications layout is set in providers.notifications and in ${area.path}. ${hint}`);
|
|
457
461
|
placed = entry.map((item, i) => i === index ? withLayout(item, area.value) : item);
|
|
458
462
|
} else {
|
|
459
|
-
if (isTuple(entry) && entry[1].layout !== void 0) throw new ConfigError(`the notifications layout is set in providers.notifications and in ${area.path}. ${hint}`);
|
|
463
|
+
if (isTuple$1(entry) && entry[1].layout !== void 0) throw new ConfigError(`the notifications layout is set in providers.notifications and in ${area.path}. ${hint}`);
|
|
460
464
|
placed = withLayout(entry, area.value);
|
|
461
465
|
}
|
|
462
466
|
return {
|
|
@@ -467,6 +471,56 @@ function placeNotifications(raw, area) {
|
|
|
467
471
|
}
|
|
468
472
|
};
|
|
469
473
|
}
|
|
474
|
+
// src/config/load-config/place-org/place-org.ts
|
|
475
|
+
/** The options each provider key of `.holocron/org.*` may hold. Checked against `OrgConfig` by the type. */
|
|
476
|
+
const ORG_OPTIONS = {
|
|
477
|
+
cloudflare: ["accountId"],
|
|
478
|
+
vercel: ["teamId"],
|
|
479
|
+
checkly: ["accountId"]
|
|
480
|
+
};
|
|
481
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
482
|
+
const isTuple = (entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && isObject(entry[1]);
|
|
483
|
+
/** Check the shape of the area file: a closed list of providers, each with a closed list of string options. */
|
|
484
|
+
function validate(area) {
|
|
485
|
+
if (!isObject(area.value)) throw new ConfigError(`${area.path} must export the org settings as an object`);
|
|
486
|
+
for (const [provider, options] of Object.entries(area.value)) {
|
|
487
|
+
const allowed = ORG_OPTIONS[provider];
|
|
488
|
+
if (allowed === void 0) throw new ConfigError(`${area.path} has an unknown provider "${provider}". Known: ${Object.keys(ORG_OPTIONS).join(", ")}`);
|
|
489
|
+
if (!isObject(options)) throw new ConfigError(`${area.path}: "${provider}" must be an object of options`);
|
|
490
|
+
for (const [option, value] of Object.entries(options)) {
|
|
491
|
+
if (!allowed.includes(option)) throw new ConfigError(`${area.path}: "${provider}.${option}" is not an org option. Known: ${allowed.join(", ")}`);
|
|
492
|
+
if (typeof value !== "string" || value === "") throw new ConfigError(`${area.path}: "${provider}.${option}" must be a non-empty string`);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return area.value;
|
|
496
|
+
}
|
|
497
|
+
/** Fill one entry when it names a provider the area holds; throws when the config already sets one of its options. */
|
|
498
|
+
function fill(entry, org, capability, path) {
|
|
499
|
+
const [provider, options] = isTuple(entry) ? entry : [entry, {}];
|
|
500
|
+
const values = org[provider];
|
|
501
|
+
if (values === void 0 || Object.keys(values).length === 0) return entry;
|
|
502
|
+
for (const option of Object.keys(values)) if (options[option] !== void 0) throw new ConfigError(`${provider}.${option} is set in providers.${capability} and in ${path}. Set it in one place: remove the inline option or the key from ${path}`);
|
|
503
|
+
return [provider, {
|
|
504
|
+
...options,
|
|
505
|
+
...values
|
|
506
|
+
}];
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Fill the provider options of `.holocron/org.*` into the providers the config uses. A provider entry (a name, a
|
|
510
|
+
* `[name, options]` tuple, or either inside a list) that names a provider the file holds gets each option it leaves
|
|
511
|
+
* out. An option set inline and in the file is a `ConfigError` naming both (no merge, no precedence); a provider the
|
|
512
|
+
* config does not use is ignored; a provider or option the file lists but `OrgConfig` does not know is an error.
|
|
513
|
+
*/
|
|
514
|
+
function placeOrg(raw, area) {
|
|
515
|
+
const org = validate(area);
|
|
516
|
+
if (raw.providers === void 0) return raw;
|
|
517
|
+
const providers = { ...raw.providers };
|
|
518
|
+
for (const [capability, entry] of Object.entries(raw.providers)) providers[capability] = Array.isArray(entry) && !isTuple(entry) ? entry.map((item) => fill(item, org, capability, area.path)) : fill(entry, org, capability, area.path);
|
|
519
|
+
return {
|
|
520
|
+
...raw,
|
|
521
|
+
providers
|
|
522
|
+
};
|
|
523
|
+
}
|
|
470
524
|
// src/config/load-config/place-repo/place-repo.ts
|
|
471
525
|
/**
|
|
472
526
|
* Add the keys of `.holocron/repo.*` to `repo`. The keys of the two sources must differ (`repo.defaultBranch` stays
|
|
@@ -489,13 +543,14 @@ function placeRepo(raw, area) {
|
|
|
489
543
|
// src/config/load-config/place-areas/place-areas.ts
|
|
490
544
|
/**
|
|
491
545
|
* Put the area files of `.holocron/` into the config as loaded, before `deriveDefaults` runs: `notifications` becomes
|
|
492
|
-
* the `layout` of the notifications provider and `repo` supplies keys of `repo
|
|
546
|
+
* the `layout` of the notifications provider and `repo` supplies keys of `repo` and `org` fills the provider options a config leaves out. A value set both inline and in a file
|
|
493
547
|
* is a `ConfigError` naming both (no merge, no precedence). With no area files the config is returned as it was.
|
|
494
548
|
*/
|
|
495
549
|
function placeAreas(areas, raw) {
|
|
496
550
|
let result = raw;
|
|
497
551
|
for (const area of areas) if (area.area === "notifications") result = placeNotifications(result, area);
|
|
498
552
|
else if (area.area === "repo") result = placeRepo(result, area);
|
|
553
|
+
else if (area.area === "org") result = placeOrg(result, area);
|
|
499
554
|
return result;
|
|
500
555
|
}
|
|
501
556
|
// src/config/config-system.ts
|
|
@@ -4896,7 +4951,8 @@ async function provisionChannel(deps, spec) {
|
|
|
4896
4951
|
...spec.topic ? { topic: spec.topic } : {},
|
|
4897
4952
|
...spec.access ? { access: spec.access } : {},
|
|
4898
4953
|
...spec.kind ? { kind: spec.kind } : {},
|
|
4899
|
-
...spec.tags ? { tags: spec.tags } : {}
|
|
4954
|
+
...spec.tags ? { tags: spec.tags } : {},
|
|
4955
|
+
...spec.defaultReaction ? { defaultReaction: spec.defaultReaction } : {}
|
|
4900
4956
|
});
|
|
4901
4957
|
const changed = channel.created || (channel.updated?.length ?? 0) > 0;
|
|
4902
4958
|
const verb = channel.created ? "created" : changed ? "updated" : "exists ";
|
|
@@ -6011,9 +6067,12 @@ function forumLayoutProblem(layout) {
|
|
|
6011
6067
|
const where = `channel \`${channel.name}\``;
|
|
6012
6068
|
if (channel.kind !== "forum") {
|
|
6013
6069
|
if (channel.tags) return `${where}: \`tags\` belong to a forum -- set \`kind: "forum"\` or remove them`;
|
|
6070
|
+
if (channel.defaultReaction || channel.starterReactions) return `${where}: reactions belong to a forum -- set \`kind: "forum"\` or remove them`;
|
|
6014
6071
|
continue;
|
|
6015
6072
|
}
|
|
6016
6073
|
if (channel.webhook || channel.feeds?.monitoring || channel.feeds?.errors) return `${where}: a forum takes no \`webhook\` or \`feeds\`; its conversations are posts`;
|
|
6074
|
+
if (channel.defaultReaction !== void 0 && channel.defaultReaction.trim() === "") return `${where}: \`defaultReaction\` is empty`;
|
|
6075
|
+
if ((channel.starterReactions ?? []).some((r) => r.trim() === "")) return `${where}: a starter reaction is empty`;
|
|
6017
6076
|
const seen = /* @__PURE__ */ new Set();
|
|
6018
6077
|
for (const tag of channel.tags ?? []) {
|
|
6019
6078
|
const name = tag.name.trim().toLowerCase();
|
|
@@ -6347,6 +6406,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
6347
6406
|
...effectiveAccess(category.access, channel.access) ? { access: effectiveAccess(category.access, channel.access) } : {},
|
|
6348
6407
|
...channel.kind ? { kind: channel.kind } : {},
|
|
6349
6408
|
...channel.tags ? { tags: channel.tags } : {},
|
|
6409
|
+
...channel.defaultReaction ? { defaultReaction: channel.defaultReaction } : {},
|
|
6350
6410
|
...webhook ? { webhook } : {},
|
|
6351
6411
|
...channel.feeds?.monitoring || channel.feeds?.errors ? { feeds: {
|
|
6352
6412
|
...channel.feeds.monitoring ? { monitoring: {
|
|
@@ -7548,10 +7608,13 @@ async function runDoctorNotifications(input) {
|
|
|
7548
7608
|
if (channel.topic && (match.topic ?? "") !== channel.topic) channelProblems.push(`#${shown(channel.name)}: topic is "${shown(match.topic ?? "")}" but the layout says "${shown(channel.topic)}"`);
|
|
7549
7609
|
const isForum = channel.kind === "forum";
|
|
7550
7610
|
if (isForum !== (match.kind === "forum")) channelProblems.push(`#${shown(channel.name)}: is ${isForum ? "a text channel, and the layout says forum" : "a forum, and the layout says text"}; delete it so \`setup\` can make it again`);
|
|
7551
|
-
else if (isForum)
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7611
|
+
else if (isForum) {
|
|
7612
|
+
if (channel.defaultReaction && (match.defaultReaction ?? "") !== channel.defaultReaction) channelProblems.push(`#${shown(channel.name)}: default reaction is ${match.defaultReaction ? `"${shown(match.defaultReaction)}"` : "not set"} but the layout says "${shown(channel.defaultReaction)}"`);
|
|
7613
|
+
for (const tag of channel.tags ?? []) {
|
|
7614
|
+
const have = match.tags?.find((t) => same(t.name, tag.name));
|
|
7615
|
+
if (!have) channelProblems.push(`#${shown(channel.name)}: tag "${shown(tag.name)}" is missing`);
|
|
7616
|
+
else if ((have.emoji ?? "") !== (tag.emoji ?? "") || (have.moderated ?? false) !== (tag.moderated ?? false)) channelProblems.push(`#${shown(channel.name)}: tag "${shown(tag.name)}" differs from the layout (emoji or moderated)`);
|
|
7617
|
+
}
|
|
7555
7618
|
}
|
|
7556
7619
|
}
|
|
7557
7620
|
add("channels", "channels in their category, with topics", channelProblems, declaredChannels.length === 0 ? "none declared" : `${declaredChannels.length} of ${declaredChannels.length} as declared`);
|