@theholocron/cli 5.0.0-alpha.352 → 5.0.0-alpha.353
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 +13 -0
- package/dist/cli.mjs +64 -9
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-DU91-XEp.d.mts → config-system-CTQ_I-Vm.d.mts} +24 -1
- package/dist/{config-system-iuxern-U.mjs → config-system-DKtlo5Pb.mjs} +64 -9
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +3 -3
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/package.json +8 -8
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`:
|
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
|