@theholocron/cli 5.0.0-alpha.347 → 5.0.0-alpha.349
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 +54 -1
- package/dist/cli.mjs +110 -28
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-CZ0F8Uq7.mjs → config-system-5rdWyUAw.mjs} +107 -25
- package/dist/{config-system-uaeB3g1g.d.mts → config-system-C6MsRNbo.d.mts} +3 -3
- package/dist/{index-XBpiD6Sx.d.mts → index-CArtx6o0.d.mts} +1 -1
- package/dist/index.d.mts +15 -2
- package/dist/index.mjs +2 -2
- package/dist/plugin/capabilities.d.mts +1 -1
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -184,6 +184,59 @@ in at load time:
|
|
|
184
184
|
A minimal config — for repos with a `package.json` and a GitHub remote
|
|
185
185
|
— only needs `providers`:
|
|
186
186
|
|
|
187
|
+
### The `.holocron/` directory
|
|
188
|
+
|
|
189
|
+
A big declaration can live in a file next to the config instead of inline, so `holocron.config.ts` stays a short index
|
|
190
|
+
of choices. `.holocron/<area>.{ts,js,mjs,cjs,json}` is read by name, and the areas are a closed list (a file not on
|
|
191
|
+
the list is never read):
|
|
192
|
+
|
|
193
|
+
| File | Where it lands |
|
|
194
|
+
| --------------------------- | ---------------------------------------------------------------------------------- |
|
|
195
|
+
| `.holocron/notifications.*` | the `layout` option of the `providers.notifications` entry (which keeps `guildId`) |
|
|
196
|
+
| `.holocron/repo.*` | keys of `repo` (`defaultBranch` stays inline: Sentinel needs it first) |
|
|
197
|
+
|
|
198
|
+
The file's default export is the value (`.ts` keeps its comments; `.json` needs no `import`, for repos with no
|
|
199
|
+
`package.json`). If both exist for one area, `.ts` wins over `.json`. A missing directory changes nothing. Setting the
|
|
200
|
+
same thing inline and in a file is an error that names both (`the notifications layout is set in providers.notifications
|
|
201
|
+
and in .holocron/notifications.ts`, `repo.topics is set in the config and in .holocron/repo.json`): there is no merge and
|
|
202
|
+
no precedence. An area file may `import` a sibling in `.holocron/`. Never put a secret in the directory: it is public in
|
|
203
|
+
a public repo.
|
|
204
|
+
|
|
205
|
+
To type the layout, import the type and use `satisfies` (there is no `defineLayout()` helper; the type-only import keeps
|
|
206
|
+
runtime code out of a file Sentinel evaluates from the default branch):
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
import type { NotificationsLayout } from "@theholocron/cli";
|
|
210
|
+
|
|
211
|
+
export default {
|
|
212
|
+
// comments stay
|
|
213
|
+
testChannel: "holonet",
|
|
214
|
+
} satisfies NotificationsLayout;
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
This repo's own Discord layout lives in `.holocron/notifications.ts`; `holocron.config.ts` keeps only `guildId`.
|
|
218
|
+
|
|
219
|
+
`RULES.md` and the webhook avatar live in `.holocron/` too (`.holocron/pinned/rules.md`, `.holocron/media/webhook-avatar.png`),
|
|
220
|
+
but they are not areas: the layout names them with an explicit repo-relative path (`pinned: [{ channel, file }]`,
|
|
221
|
+
`webhookAvatar`). `.holocron/projects/<name>.json` is the project-board template folder (SPEC-0020), read by its own
|
|
222
|
+
default and not placed into the config.
|
|
223
|
+
|
|
224
|
+
**Sentinel** reads the directory too, so its PR config check, property sync and role sync see the same merged config as
|
|
225
|
+
the CLI. It lists `.holocron/` at the config's ref and fetches the whole tree (any depth, so an area may import a
|
|
226
|
+
sibling), within caps: 50 files, 100 KB per file, 512 KB in all. Past a cap, or on an area file that does not load,
|
|
227
|
+
the check reports a load error. Only what the config or an area file imports is evaluated. The design and the decisions
|
|
228
|
+
are in `docs/wiki/specifications/tech-holocron-directory.spec.md` (SPEC-0069).
|
|
229
|
+
|
|
230
|
+
**Keys that never move out of `holocron.config.ts`.** `repo.defaultBranch`, because the config is the one file read
|
|
231
|
+
before the directory, and the default branch is what says which branch holds `.holocron/` and the config. Every other
|
|
232
|
+
top-level key (`name`, `org`, `domain`, `providers`, `tasks`) also stays, but only because the closed list of areas has
|
|
233
|
+
no entry for it: Sentinel's `validateConfig()` reads none of them before it fetches `.holocron/` (it needs the config
|
|
234
|
+
file's path and the `ref`, nothing from inside it). Keys that a preset spreads into `repo` (`protection`, `properties`,
|
|
235
|
+
which `syncPropertiesFromConfig()` reads) stay inline too, since a key set both inline and in the file is an error. There
|
|
236
|
+
is no per-key precedence: the loader does not let an inline key win, it refuses the duplicate and names both places. This
|
|
237
|
+
repo's `.holocron/repo.ts` holds `teams`, `topics`, `variables` and `secrets`, names and identifiers only, typed with
|
|
238
|
+
`satisfies RepoConfig` (a type-only import).
|
|
239
|
+
|
|
187
240
|
### repo options
|
|
188
241
|
|
|
189
242
|
Additional `repo` fields recognised by `holocron repo setup`:
|
|
@@ -582,7 +635,7 @@ A channel with `kind: "forum"` is a forum, with `tags` (each a `name`, an `emoji
|
|
|
582
635
|
|
|
583
636
|
`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/).
|
|
584
637
|
|
|
585
|
-
Pinned messages are declared under the provider's `layout` as `pinned: [{ channel, content }]` or `pinned: [{ channel, file }]` (`channel` is a channel in the layout, `content` up to 2000 characters, `file` a text file in the repository, such as
|
|
638
|
+
Pinned messages are declared under the provider's `layout` as `pinned: [{ channel, content }]` or `pinned: [{ channel, file }]` (`channel` is a channel in the layout, `content` up to 2000 characters, `file` a text file in the repository, such as `.holocron/pinned/rules.md`, whose contents are the message and win over a hand edit; `doctor notifications` reports the drift); the layout is the whole set of messages the bot has pinned in those channels.
|
|
586
639
|
|
|
587
640
|
Config shape added for role sync and sign-in (all under the provider's `layout`):
|
|
588
641
|
|
package/dist/cli.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { NonInteractiveError, commandFailureMessage, createProgress, createRetry
|
|
|
11
11
|
import { LOG_LEVELS } from "@theholocron/observability/core";
|
|
12
12
|
import yargs from "yargs";
|
|
13
13
|
import { hideBin } from "yargs/helpers";
|
|
14
|
-
import { ConfigError, createConfigSystem, lastWins, mergeByKey, shallowMerge, union } from "@theholocron/kyber/config";
|
|
14
|
+
import { ConfigError, ConfigError as ConfigError$1, createConfigSystem, lastWins, mergeByKey, shallowMerge, union } from "@theholocron/kyber/config";
|
|
15
15
|
import { LoaderError, assertPluginsResolvable, createPluginSystem, isModuleNotFound, resolvePluginPackage } from "@theholocron/kyber/plugins";
|
|
16
16
|
import { KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, RESERVED_SCRIPT_NAMES, SUITES, TASKS, aggregateChecks, checkPackageScripts, createAlexignore, createAlexrc, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, frozenReusablePaths, generateThinCallerContent, hostedReusableWorkflows, isDeprecated, isTask, legacyCaller, legacyCallerFile, legacyGate, legacyWorkflowKey, localize, mergeScripts, readWorkspacePackages, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, workflowFile, workflowKey, workflowKeys, workspacePackages } from "@theholocron/astromech";
|
|
17
17
|
import { loadTasksConfig } from "@theholocron/astromech/config";
|
|
@@ -121,7 +121,7 @@ const COMMUNITY_PREFIX = "holocron-plugin-";
|
|
|
121
121
|
* is how third-party plugins published outside the org work.
|
|
122
122
|
*/
|
|
123
123
|
function resolvePluginPackage$1(provider) {
|
|
124
|
-
if (!provider) throw new ConfigError("provider name is empty");
|
|
124
|
+
if (!provider) throw new ConfigError$1("provider name is empty");
|
|
125
125
|
return resolvePluginPackage(provider, PLUGIN_PREFIX, COMMUNITY_PREFIX);
|
|
126
126
|
}
|
|
127
127
|
/** A bare `[provider, options]` tuple, with both elements present? */
|
|
@@ -149,13 +149,13 @@ function normalizeEntry(entry) {
|
|
|
149
149
|
function resolveEntry(key, raw) {
|
|
150
150
|
const cardinality = CARDINALITY[key];
|
|
151
151
|
if (typeof raw === "string") {
|
|
152
|
-
if (cardinality === "many") throw new ConfigError(`\`${key}\` accepts multiple providers; wrap a single one in an array: ["${raw}"]`);
|
|
152
|
+
if (cardinality === "many") throw new ConfigError$1(`\`${key}\` accepts multiple providers; wrap a single one in an array: ["${raw}"]`);
|
|
153
153
|
return {
|
|
154
154
|
cardinality: "single",
|
|
155
155
|
tuple: normalizeEntry(raw)
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
|
-
if (!Array.isArray(raw)) throw new ConfigError(`\`${key}\` entry must be a string or array, got ${typeof raw}`);
|
|
158
|
+
if (!Array.isArray(raw)) throw new ConfigError$1(`\`${key}\` entry must be a string or array, got ${typeof raw}`);
|
|
159
159
|
if (isOptionsTuple(raw)) {
|
|
160
160
|
if (cardinality === "many") return {
|
|
161
161
|
cardinality: "many",
|
|
@@ -166,13 +166,13 @@ function resolveEntry(key, raw) {
|
|
|
166
166
|
tuple: normalizeEntry(raw)
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
if (cardinality === "single") throw new ConfigError(`\`${key}\` accepts exactly one provider; got a multi-provider list with ${raw.length} entries`);
|
|
169
|
+
if (cardinality === "single") throw new ConfigError$1(`\`${key}\` accepts exactly one provider; got a multi-provider list with ${raw.length} entries`);
|
|
170
170
|
return {
|
|
171
171
|
cardinality: "many",
|
|
172
172
|
tuples: raw.map((entry, idx) => {
|
|
173
173
|
if (typeof entry === "string") return normalizeEntry(entry);
|
|
174
174
|
if (isOptionsTuple(entry)) return normalizeEntry(entry);
|
|
175
|
-
throw new ConfigError(`\`${key}[${idx}]\` must be a provider string or [provider, options] tuple`);
|
|
175
|
+
throw new ConfigError$1(`\`${key}[${idx}]\` must be a provider string or [provider, options] tuple`);
|
|
176
176
|
})
|
|
177
177
|
};
|
|
178
178
|
}
|
|
@@ -181,19 +181,19 @@ const HOSTNAME = /^[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0
|
|
|
181
181
|
/** Throws a {@link ConfigError} naming the first thing wrong with the `dev` block. */
|
|
182
182
|
function validateDev(dev) {
|
|
183
183
|
const nonEmpty = (value) => typeof value === "string" && value.trim() !== "";
|
|
184
|
-
if (dev.environment !== void 0 && !nonEmpty(dev.environment)) throw new ConfigError("`dev.environment` must be the name of a vault environment, got an empty value");
|
|
184
|
+
if (dev.environment !== void 0 && !nonEmpty(dev.environment)) throw new ConfigError$1("`dev.environment` must be the name of a vault environment, got an empty value");
|
|
185
185
|
if (dev.tunnel !== void 0) {
|
|
186
|
-
if (!nonEmpty(dev.tunnel.name)) throw new ConfigError("`dev.tunnel.name` must be a name, got an empty value");
|
|
187
|
-
if (typeof dev.tunnel.hostname !== "string" || !HOSTNAME.test(dev.tunnel.hostname)) throw new ConfigError(`\`dev.tunnel.hostname\` must be a hostname such as sentinel-dev.example.dev (no scheme or path), got ${JSON.stringify(dev.tunnel.hostname)}`);
|
|
186
|
+
if (!nonEmpty(dev.tunnel.name)) throw new ConfigError$1("`dev.tunnel.name` must be a name, got an empty value");
|
|
187
|
+
if (typeof dev.tunnel.hostname !== "string" || !HOSTNAME.test(dev.tunnel.hostname)) throw new ConfigError$1(`\`dev.tunnel.hostname\` must be a hostname such as sentinel-dev.example.dev (no scheme or path), got ${JSON.stringify(dev.tunnel.hostname)}`);
|
|
188
188
|
}
|
|
189
|
-
if (dev.port !== void 0 && !(Number.isInteger(dev.port) && dev.port >= 1 && dev.port <= 65535)) throw new ConfigError(`\`dev.port\` must be a port from 1 to 65535, got ${JSON.stringify(dev.port)}`);
|
|
190
|
-
if (dev.command !== void 0 && !(Array.isArray(dev.command) && dev.command.length > 0 && dev.command.every(nonEmpty))) throw new ConfigError("`dev.command` must be the program and its arguments, e.g. [\"pnpm\", \"run\", \"serve\"]");
|
|
189
|
+
if (dev.port !== void 0 && !(Number.isInteger(dev.port) && dev.port >= 1 && dev.port <= 65535)) throw new ConfigError$1(`\`dev.port\` must be a port from 1 to 65535, got ${JSON.stringify(dev.port)}`);
|
|
190
|
+
if (dev.command !== void 0 && !(Array.isArray(dev.command) && dev.command.length > 0 && dev.command.every(nonEmpty))) throw new ConfigError$1("`dev.command` must be the program and its arguments, e.g. [\"pnpm\", \"run\", \"serve\"]");
|
|
191
191
|
if (dev.serve !== void 0) {
|
|
192
192
|
const { serve } = dev;
|
|
193
|
-
if (!nonEmpty(serve.handler)) throw new ConfigError("`dev.serve.handler` must be the path of the module that exports the handler");
|
|
194
|
-
if (serve.export !== void 0 && !nonEmpty(serve.export)) throw new ConfigError("`dev.serve.export` must be the name of the handler's export, got an empty value");
|
|
195
|
-
if (serve.required !== void 0 && !(Array.isArray(serve.required) && serve.required.every(nonEmpty))) throw new ConfigError("`dev.serve.required` must be a list of variable names");
|
|
196
|
-
if (serve.logging !== void 0 && !(nonEmpty(serve.logging.tokenVar) && nonEmpty(serve.logging.datasetVar))) throw new ConfigError("`dev.serve.logging` needs a `tokenVar` and a `datasetVar`, both variable names");
|
|
193
|
+
if (!nonEmpty(serve.handler)) throw new ConfigError$1("`dev.serve.handler` must be the path of the module that exports the handler");
|
|
194
|
+
if (serve.export !== void 0 && !nonEmpty(serve.export)) throw new ConfigError$1("`dev.serve.export` must be the name of the handler's export, got an empty value");
|
|
195
|
+
if (serve.required !== void 0 && !(Array.isArray(serve.required) && serve.required.every(nonEmpty))) throw new ConfigError$1("`dev.serve.required` must be a list of variable names");
|
|
196
|
+
if (serve.logging !== void 0 && !(nonEmpty(serve.logging.tokenVar) && nonEmpty(serve.logging.datasetVar))) throw new ConfigError$1("`dev.serve.logging` needs a `tokenVar` and a `datasetVar`, both variable names");
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
/** The values `repoValidation.docsCoverage` accepts. */
|
|
@@ -213,31 +213,31 @@ function credentialsEnvironment(tuple, config) {
|
|
|
213
213
|
}
|
|
214
214
|
/** Validates a raw `holocron.config` and resolves its provider entries; throws `ConfigError` when `name` or `providers` is missing or an entry is malformed. */
|
|
215
215
|
function resolveConfig(raw) {
|
|
216
|
-
if (!raw.name) throw new ConfigError("`name` is required");
|
|
217
|
-
if (!raw.providers || typeof raw.providers !== "object") throw new ConfigError("`providers` block is required");
|
|
216
|
+
if (!raw.name) throw new ConfigError$1("`name` is required");
|
|
217
|
+
if (!raw.providers || typeof raw.providers !== "object") throw new ConfigError$1("`providers` block is required");
|
|
218
218
|
const providers = {};
|
|
219
219
|
for (const [key, entry] of Object.entries(raw.providers)) {
|
|
220
220
|
if (entry === void 0) continue;
|
|
221
221
|
providers[key] = resolveEntry(key, entry);
|
|
222
222
|
}
|
|
223
|
-
for (const required of REQUIRED_CAPABILITIES) if (!providers[required]) throw new ConfigError(`required capability \`${required}\` is missing from providers`);
|
|
223
|
+
for (const required of REQUIRED_CAPABILITIES) if (!providers[required]) throw new ConfigError$1(`required capability \`${required}\` is missing from providers`);
|
|
224
224
|
let docs;
|
|
225
225
|
if (raw.docs !== void 0) {
|
|
226
|
-
if (!raw.docs.build) throw new ConfigError("`docs.build` is required when `docs` is set");
|
|
226
|
+
if (!raw.docs.build) throw new ConfigError$1("`docs.build` is required when `docs` is set");
|
|
227
227
|
docs = raw.docs;
|
|
228
228
|
}
|
|
229
229
|
const docsCoverage = raw.repoValidation?.docsCoverage;
|
|
230
|
-
if (docsCoverage !== void 0 && !DOCS_COVERAGE_MODES.includes(docsCoverage)) throw new ConfigError(`\`repoValidation.docsCoverage\` must be one of ${DOCS_COVERAGE_MODES.map((m) => `"${m}"`).join(", ")}, got ${JSON.stringify(docsCoverage)}`);
|
|
230
|
+
if (docsCoverage !== void 0 && !DOCS_COVERAGE_MODES.includes(docsCoverage)) throw new ConfigError$1(`\`repoValidation.docsCoverage\` must be one of ${DOCS_COVERAGE_MODES.map((m) => `"${m}"`).join(", ")}, got ${JSON.stringify(docsCoverage)}`);
|
|
231
231
|
if (raw.credentials !== void 0) {
|
|
232
232
|
const environment = raw.credentials.environment;
|
|
233
|
-
if (typeof environment !== "string" || environment.trim() === "") throw new ConfigError("`credentials.environment` must be the name of an environment, got an empty value");
|
|
233
|
+
if (typeof environment !== "string" || environment.trim() === "") throw new ConfigError$1("`credentials.environment` must be the name of an environment, got an empty value");
|
|
234
234
|
}
|
|
235
235
|
if (raw.dev !== void 0) validateDev(raw.dev);
|
|
236
236
|
const credentialsEntry = providers.credentials;
|
|
237
237
|
if (credentialsEntry?.cardinality === "many") for (const tuple of credentialsEntry.tuples) {
|
|
238
238
|
const own = tuple.options.environment;
|
|
239
|
-
if (own !== void 0 && (typeof own !== "string" || own.trim() === "")) throw new ConfigError(`the \`environment\` option of the \`${tuple.provider}\` credentials provider must be the name of an environment, got an empty value`);
|
|
240
|
-
if (credentialsEnvironment(tuple, raw) === void 0) throw new ConfigError(`the \`${tuple.provider}\` credentials provider has no environment to read: give it an \`environment\` option or set \`credentials.environment\``);
|
|
239
|
+
if (own !== void 0 && (typeof own !== "string" || own.trim() === "")) throw new ConfigError$1(`the \`environment\` option of the \`${tuple.provider}\` credentials provider must be the name of an environment, got an empty value`);
|
|
240
|
+
if (credentialsEnvironment(tuple, raw) === void 0) throw new ConfigError$1(`the \`${tuple.provider}\` credentials provider has no environment to read: give it an \`environment\` option or set \`credentials.environment\``);
|
|
241
241
|
}
|
|
242
242
|
const homepage = raw.homepage ?? (docs?.domain ? `https://${docs.domain}/` : void 0);
|
|
243
243
|
return {
|
|
@@ -387,6 +387,86 @@ async function deriveDefaults$1(found) {
|
|
|
387
387
|
if (manifest.extraRequiredChecks) result.extraRequiredChecks = [...result.extraRequiredChecks ?? [], ...manifest.extraRequiredChecks];
|
|
388
388
|
return result;
|
|
389
389
|
}
|
|
390
|
+
// src/config/load-config/holocron-areas/holocron-areas.ts
|
|
391
|
+
/**
|
|
392
|
+
* The closed list of area files `loadConfig` reads from `.holocron/` (the directory is `.<config name>`, set by kyber):
|
|
393
|
+
* `.holocron/notifications.*` fills `providers.notifications`' `layout`, and `.holocron/repo.*` fills keys of `repo`.
|
|
394
|
+
* A file not on this list is never read.
|
|
395
|
+
*/
|
|
396
|
+
const HOLOCRON_AREAS = ["notifications", "repo"];
|
|
397
|
+
// src/config/load-config/place-notifications/place-notifications.ts
|
|
398
|
+
const isTuple = (entry) => Array.isArray(entry) && entry.length === 2 && typeof entry[0] === "string" && typeof entry[1] === "object" && entry[1] !== null && !Array.isArray(entry[1]);
|
|
399
|
+
const providerName = (entry) => isTuple(entry) ? entry[0] : entry;
|
|
400
|
+
/** Index of the entry the layout belongs to in a multi-provider list: the first `discord`. */
|
|
401
|
+
function findDiscord(entries) {
|
|
402
|
+
return entries.findIndex((entry) => providerName(entry) === "discord");
|
|
403
|
+
}
|
|
404
|
+
function withLayout(entry, layout) {
|
|
405
|
+
return isTuple(entry) ? [entry[0], {
|
|
406
|
+
...entry[1],
|
|
407
|
+
layout
|
|
408
|
+
}] : [entry, { layout }];
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Set `layout` on the notifications provider from `.holocron/notifications.*`. The entry may be a name (`"discord"`),
|
|
412
|
+
* a `[name, options]` tuple, or a list (the first `discord` entry gets it). Throws `ConfigError` when the provider is
|
|
413
|
+
* not set or already has an inline `layout`.
|
|
414
|
+
*/
|
|
415
|
+
function placeNotifications(raw, area) {
|
|
416
|
+
if (typeof area.value !== "object" || area.value === null || Array.isArray(area.value)) throw new ConfigError(`${area.path} must export the notifications layout as an object`);
|
|
417
|
+
const entry = raw.providers?.notifications;
|
|
418
|
+
const hint = `Set it in one place: remove the inline \`layout\` or delete ${area.path}`;
|
|
419
|
+
let placed;
|
|
420
|
+
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`);
|
|
421
|
+
else if (Array.isArray(entry) && !isTuple(entry)) {
|
|
422
|
+
const index = findDiscord(entry);
|
|
423
|
+
if (index === -1) throw new ConfigError(`${area.path} holds the notifications layout, but providers.notifications has no discord entry`);
|
|
424
|
+
const target = entry[index];
|
|
425
|
+
if (isTuple(target) && target[1].layout !== void 0) throw new ConfigError(`the notifications layout is set in providers.notifications and in ${area.path}. ${hint}`);
|
|
426
|
+
placed = entry.map((item, i) => i === index ? withLayout(item, area.value) : item);
|
|
427
|
+
} else {
|
|
428
|
+
if (isTuple(entry) && entry[1].layout !== void 0) throw new ConfigError(`the notifications layout is set in providers.notifications and in ${area.path}. ${hint}`);
|
|
429
|
+
placed = withLayout(entry, area.value);
|
|
430
|
+
}
|
|
431
|
+
return {
|
|
432
|
+
...raw,
|
|
433
|
+
providers: {
|
|
434
|
+
...raw.providers,
|
|
435
|
+
notifications: placed
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
// src/config/load-config/place-repo/place-repo.ts
|
|
440
|
+
/**
|
|
441
|
+
* Add the keys of `.holocron/repo.*` to `repo`. The keys of the two sources must differ (`repo.defaultBranch` stays
|
|
442
|
+
* inline so Sentinel can find the branch to read): a key set both inline and in the file is a `ConfigError` naming
|
|
443
|
+
* both.
|
|
444
|
+
*/
|
|
445
|
+
function placeRepo(raw, area) {
|
|
446
|
+
if (typeof area.value !== "object" || area.value === null || Array.isArray(area.value)) throw new ConfigError(`${area.path} must export the repo settings as an object`);
|
|
447
|
+
const fromFile = area.value;
|
|
448
|
+
const inline = raw.repo ?? {};
|
|
449
|
+
for (const key of Object.keys(fromFile)) if (inline[key] !== void 0) throw new ConfigError(`repo.${key} is set in the config and in ${area.path}. Set it in one place: remove the inline value or the key from ${area.path}`);
|
|
450
|
+
return {
|
|
451
|
+
...raw,
|
|
452
|
+
repo: {
|
|
453
|
+
...inline,
|
|
454
|
+
...fromFile
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
// src/config/load-config/place-areas/place-areas.ts
|
|
459
|
+
/**
|
|
460
|
+
* Put the area files of `.holocron/` into the config as loaded, before `deriveDefaults` runs: `notifications` becomes
|
|
461
|
+
* the `layout` of the notifications provider and `repo` supplies keys of `repo`. A value set both inline and in a file
|
|
462
|
+
* is a `ConfigError` naming both (no merge, no precedence). With no area files the config is returned as it was.
|
|
463
|
+
*/
|
|
464
|
+
function placeAreas(areas, raw) {
|
|
465
|
+
let result = raw;
|
|
466
|
+
for (const area of areas) if (area.area === "notifications") result = placeNotifications(result, area);
|
|
467
|
+
else if (area.area === "repo") result = placeRepo(result, area);
|
|
468
|
+
return result;
|
|
469
|
+
}
|
|
390
470
|
// src/config/config-system.ts
|
|
391
471
|
/**
|
|
392
472
|
* Holocron's config system: `defineConfig`, `loadConfig` and `compose`, all built from one
|
|
@@ -394,7 +474,7 @@ async function deriveDefaults$1(found) {
|
|
|
394
474
|
*
|
|
395
475
|
* File discovery, the walk up to `.git`, module loading (typed configs via `tsx`) and the derive-then-resolve flow come
|
|
396
476
|
* from `@theholocron/kyber/config`. The holocron-specific parts are `deriveDefaults` (name, `repo.name`, the task
|
|
397
|
-
* manifest), `resolveConfig` and `mergeStrategies`.
|
|
477
|
+
* manifest), `placeAreas` (the `.holocron/` area files, placed before `deriveDefaults`), `resolveConfig` and `mergeStrategies`.
|
|
398
478
|
*
|
|
399
479
|
* The three functions live together because each is only a method of the one system object; splitting them back into
|
|
400
480
|
* one file apiece would just be pass-through wrappers (an exception to the one-function-per-file rule).
|
|
@@ -404,6 +484,8 @@ async function deriveDefaults$1(found) {
|
|
|
404
484
|
*/
|
|
405
485
|
const system$1 = createConfigSystem({
|
|
406
486
|
name: "holocron",
|
|
487
|
+
areas: HOLOCRON_AREAS,
|
|
488
|
+
place: placeAreas,
|
|
407
489
|
derive: deriveDefaults$1,
|
|
408
490
|
resolve: resolveConfig,
|
|
409
491
|
merge: mergeStrategies
|
|
@@ -16537,17 +16619,17 @@ const projectMoveCommand = {
|
|
|
16537
16619
|
*/
|
|
16538
16620
|
async function openProjects(input, command) {
|
|
16539
16621
|
const entry = input.loaded.resolved.providers.projects;
|
|
16540
|
-
if (entry?.cardinality !== "single") throw new ConfigError(`${command}: needs a \`projects\` provider in holocron.config.ts, e.g. providers: { projects: "github" }`);
|
|
16622
|
+
if (entry?.cardinality !== "single") throw new ConfigError$1(`${command}: needs a \`projects\` provider in holocron.config.ts, e.g. providers: { projects: "github" }`);
|
|
16541
16623
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
16542
16624
|
await withSpinner("Loading plugins…", () => loader.load());
|
|
16543
16625
|
assertPluginsResolvable$1(loader, command);
|
|
16544
16626
|
if (!loader.has("projects")) {
|
|
16545
16627
|
const failure = loader.loadFailures().find((f) => f.key === "projects");
|
|
16546
|
-
throw new ConfigError(`${command}: the \`projects\` provider is not available${failure ? ` (\`${failure.provider}\` failed to load: ${describeError(failure.error)})` : ""}`);
|
|
16628
|
+
throw new ConfigError$1(`${command}: the \`projects\` provider is not available${failure ? ` (\`${failure.provider}\` failed to load: ${describeError(failure.error)})` : ""}`);
|
|
16547
16629
|
}
|
|
16548
16630
|
const resolved = resolveProjectOptions(entry.tuple.options, input.owner ?? input.context.org ?? "");
|
|
16549
|
-
if (!resolved.ok) throw new ConfigError(`${command}: providers.projects is wrong: ${resolved.problems.join("; ")}`);
|
|
16550
|
-
if (resolved.options.owner === "") throw new ConfigError(`${command}: needs an owner: set \`org\` in holocron.config.ts, the provider's \`org\` option, or pass --org`);
|
|
16631
|
+
if (!resolved.ok) throw new ConfigError$1(`${command}: providers.projects is wrong: ${resolved.problems.join("; ")}`);
|
|
16632
|
+
if (resolved.options.owner === "") throw new ConfigError$1(`${command}: needs an owner: set \`org\` in holocron.config.ts, the provider's \`org\` option, or pass --org`);
|
|
16551
16633
|
return {
|
|
16552
16634
|
projects: loader.get("projects"),
|
|
16553
16635
|
options: resolved.options
|