@theholocron/cli 5.0.0-alpha.354 → 5.0.0-alpha.355
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 +5 -2
- package/dist/cli.mjs +33 -5
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-DKtlo5Pb.mjs → config-system-u8-jh7xW.mjs} +34 -6
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +2 -2
- package/dist/presets.mjs +1 -1
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -244,8 +244,11 @@ repo's `.holocron/repo.ts` holds `teams`, `topics`, `variables` and `secrets`, n
|
|
|
244
244
|
out, so the config can say `deployment: ["vercel", { domain }]` and `monitoring: "checkly"`. The same option set inline
|
|
245
245
|
and in the file is an error that names both (`vercel.teamId is set in providers.deployment and in
|
|
246
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.
|
|
248
|
-
|
|
247
|
+
provider the config does not use is ignored. The org area is shared: a config in a subdirectory (`apps/sentinel`)
|
|
248
|
+
also reads the repository root's `.holocron/org.ts` (the nearest ancestor with a `.git`), and its own
|
|
249
|
+
`.holocron/org.ts` wins for a key set in both, option by option; that is not an error, so an identifier written in the
|
|
250
|
+
root file needs no copy in the app. The other areas (`repo`, `notifications`) describe the repository and are not
|
|
251
|
+
shared. Anything CI needs (`CLOUDFLARE_ACCOUNT_ID`,
|
|
249
252
|
`TURBO_TEAM`, `AXIOM_DATASET`) stays out: it lives in 1Password and syncs to a GitHub variable (`repo.variables.sync`),
|
|
250
253
|
and nothing else carries a copy. `.holocron/org.md` (the agent contract the CLI embeds) is not an area: only
|
|
251
254
|
`.ts`, `.js`, `.mjs`, `.cjs` and `.json` are read.
|
package/dist/cli.mjs
CHANGED
|
@@ -429,6 +429,12 @@ const HOLOCRON_AREAS = [
|
|
|
429
429
|
"repo",
|
|
430
430
|
"org"
|
|
431
431
|
];
|
|
432
|
+
/**
|
|
433
|
+
* The areas a config in a subdirectory also reads from the repository root's `.holocron/` (SPEC-0069): only `org`,
|
|
434
|
+
* because its values are the organization's and every config needs them. `repo` and `notifications` describe the
|
|
435
|
+
* repository itself, so an app's config does not take them from the root.
|
|
436
|
+
*/
|
|
437
|
+
const SHARED_AREAS = ["org"];
|
|
432
438
|
// src/config/load-config/place-notifications/place-notifications.ts
|
|
433
439
|
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
440
|
const providerName = (entry) => isTuple$1(entry) ? entry[0] : entry;
|
|
@@ -494,15 +500,34 @@ function validate(area) {
|
|
|
494
500
|
}
|
|
495
501
|
return area.value;
|
|
496
502
|
}
|
|
503
|
+
/**
|
|
504
|
+
* The org options of an area and, when the repository root has the same area, the root's under them: an option set in
|
|
505
|
+
* both takes the config's own value, option by option (the root's other options stay). Each file is checked on its own.
|
|
506
|
+
*/
|
|
507
|
+
function merge(area) {
|
|
508
|
+
const merged = {};
|
|
509
|
+
for (const layer of area.root ? [area.root, area] : [area]) for (const [provider, options] of Object.entries(validate(layer))) {
|
|
510
|
+
const sourced = merged[provider] ??= {};
|
|
511
|
+
for (const [option, value] of Object.entries(options)) sourced[option] = {
|
|
512
|
+
value,
|
|
513
|
+
path: layer.path
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
return merged;
|
|
517
|
+
}
|
|
497
518
|
/** 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
|
|
519
|
+
function fill(entry, org, capability) {
|
|
499
520
|
const [provider, options] = isTuple(entry) ? entry : [entry, {}];
|
|
500
521
|
const values = org[provider];
|
|
501
522
|
if (values === void 0 || Object.keys(values).length === 0) return entry;
|
|
502
|
-
|
|
523
|
+
const filled = {};
|
|
524
|
+
for (const [option, { value, path }] of Object.entries(values)) {
|
|
525
|
+
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}`);
|
|
526
|
+
filled[option] = value;
|
|
527
|
+
}
|
|
503
528
|
return [provider, {
|
|
504
529
|
...options,
|
|
505
|
-
...
|
|
530
|
+
...filled
|
|
506
531
|
}];
|
|
507
532
|
}
|
|
508
533
|
/**
|
|
@@ -510,12 +535,14 @@ function fill(entry, org, capability, path) {
|
|
|
510
535
|
* `[name, options]` tuple, or either inside a list) that names a provider the file holds gets each option it leaves
|
|
511
536
|
* out. An option set inline and in the file is a `ConfigError` naming both (no merge, no precedence); a provider the
|
|
512
537
|
* config does not use is ignored; a provider or option the file lists but `OrgConfig` does not know is an error.
|
|
538
|
+
* When the area also came from the repository root (`area.root`, a config in a subdirectory), the two files combine
|
|
539
|
+
* option by option and the config's own file wins; that is not an error.
|
|
513
540
|
*/
|
|
514
541
|
function placeOrg(raw, area) {
|
|
515
|
-
const org =
|
|
542
|
+
const org = merge(area);
|
|
516
543
|
if (raw.providers === void 0) return raw;
|
|
517
544
|
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
|
|
545
|
+
for (const [capability, entry] of Object.entries(raw.providers)) providers[capability] = Array.isArray(entry) && !isTuple(entry) ? entry.map((item) => fill(item, org, capability)) : fill(entry, org, capability);
|
|
519
546
|
return {
|
|
520
547
|
...raw,
|
|
521
548
|
providers
|
|
@@ -571,6 +598,7 @@ function placeAreas(areas, raw) {
|
|
|
571
598
|
const system$1 = createConfigSystem({
|
|
572
599
|
name: "holocron",
|
|
573
600
|
areas: HOLOCRON_AREAS,
|
|
601
|
+
shared: SHARED_AREAS,
|
|
574
602
|
place: placeAreas,
|
|
575
603
|
derive: deriveDefaults$1,
|
|
576
604
|
resolve: resolveConfig,
|