@theholocron/cli 5.0.0-alpha.244 → 5.0.0-alpha.246

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/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { CARDINALITY, ElevationRequiredError, ProviderApiError, REQUIRED_CAPABILITIES, WebhookVerificationError, isMulti } from "./plugin/capabilities.mjs";
2
+ import { a as resolvePluginPackage, i as resolveEntry, n as ConfigError, r as resolveConfig, t as compose } from "./compose-Cao-W6Mu.mjs";
2
3
  import { AuthError, createResolveToken as createResolveToken$1, createRestClient } from "@theholocron/http-client";
3
4
  import { createEnvLookup, withEnvPrefix } from "@theholocron/env-utils";
4
5
  import { Entry, findCredentials } from "@napi-rs/keyring";
@@ -223,215 +224,6 @@ async function readWorkspacePackageJsons(repoRoot, workspacePackages) {
223
224
  return results;
224
225
  }
225
226
  //#endregion
226
- //#region src/config/config/config.ts
227
- var ConfigError = class extends Error {
228
- name = "ConfigError";
229
- };
230
- const PLUGIN_PREFIX = "@theholocron/holocron-plugin-";
231
- const COMMUNITY_PREFIX = "holocron-plugin-";
232
- /**
233
- * Resolve `"github"` → `"@theholocron/holocron-plugin-github"`.
234
- * Fully-qualified names (scoped or not) are honored verbatim, which
235
- * is how third-party plugins published outside the org work.
236
- */
237
- function resolvePluginPackage(provider) {
238
- if (!provider) throw new ConfigError("provider name is empty");
239
- if (provider.startsWith("@")) return provider;
240
- if (provider.startsWith(COMMUNITY_PREFIX)) return provider;
241
- if (provider.includes("/")) return provider;
242
- return PLUGIN_PREFIX + provider;
243
- }
244
- /** A bare `[provider, options]` tuple, with both elements present? */
245
- function isOptionsTuple(value) {
246
- if (!Array.isArray(value)) return false;
247
- if (value.length !== 2) return false;
248
- if (typeof value[0] !== "string") return false;
249
- const opt = value[1];
250
- return typeof opt === "object" && opt !== null && !Array.isArray(opt);
251
- }
252
- function normalizeEntry(entry) {
253
- if (typeof entry === "string") return {
254
- provider: entry,
255
- packageName: resolvePluginPackage(entry),
256
- options: {}
257
- };
258
- const [provider, options] = entry;
259
- return {
260
- provider,
261
- packageName: resolvePluginPackage(provider),
262
- options
263
- };
264
- }
265
- function resolveEntry(key, raw) {
266
- const cardinality = CARDINALITY[key];
267
- if (typeof raw === "string") {
268
- if (cardinality === "many") throw new ConfigError(`\`${key}\` accepts multiple providers; wrap a single one in an array: ["${raw}"]`);
269
- return {
270
- cardinality: "single",
271
- tuple: normalizeEntry(raw)
272
- };
273
- }
274
- if (!Array.isArray(raw)) throw new ConfigError(`\`${key}\` entry must be a string or array, got ${typeof raw}`);
275
- if (isOptionsTuple(raw)) {
276
- if (cardinality === "many") return {
277
- cardinality: "many",
278
- tuples: [normalizeEntry(raw)]
279
- };
280
- return {
281
- cardinality: "single",
282
- tuple: normalizeEntry(raw)
283
- };
284
- }
285
- if (cardinality === "single") throw new ConfigError(`\`${key}\` accepts exactly one provider; got a multi-provider list with ${raw.length} entries`);
286
- return {
287
- cardinality: "many",
288
- tuples: raw.map((entry, idx) => {
289
- if (typeof entry === "string") return normalizeEntry(entry);
290
- if (isOptionsTuple(entry)) return normalizeEntry(entry);
291
- throw new ConfigError(`\`${key}[${idx}]\` must be a provider string or [provider, options] tuple`);
292
- })
293
- };
294
- }
295
- function resolveConfig(raw) {
296
- if (!raw.name) throw new ConfigError("`name` is required");
297
- if (!raw.providers || typeof raw.providers !== "object") throw new ConfigError("`providers` block is required");
298
- const providers = {};
299
- for (const [key, entry] of Object.entries(raw.providers)) {
300
- if (entry === void 0) continue;
301
- providers[key] = resolveEntry(key, entry);
302
- }
303
- for (const required of REQUIRED_CAPABILITIES) if (!providers[required]) throw new ConfigError(`required capability \`${required}\` is missing from providers`);
304
- let docs;
305
- if (raw.docs !== void 0) {
306
- if (!raw.docs.build) throw new ConfigError("`docs.build` is required when `docs` is set");
307
- docs = raw.docs;
308
- }
309
- const homepage = raw.homepage ?? (docs?.domain ? `https://${docs.domain}/` : void 0);
310
- return {
311
- name: raw.name,
312
- description: raw.description,
313
- homepage,
314
- org: raw.org,
315
- domain: raw.domain,
316
- repo: raw.repo,
317
- tasks: raw.tasks,
318
- syncScripts: raw.syncScripts,
319
- holocronScript: raw.holocronScript,
320
- extraRequiredChecks: raw.extraRequiredChecks,
321
- hooks: raw.hooks,
322
- providers,
323
- apps: raw.apps ?? [],
324
- doctor: raw.doctor ?? {},
325
- agent: raw.agent,
326
- skills: raw.skills,
327
- docs,
328
- env: raw.env,
329
- log: raw.log,
330
- telemetry: raw.telemetry,
331
- eslint: raw.eslint
332
- };
333
- }
334
- //#endregion
335
- //#region src/config/compose/compose.ts
336
- function taskName(e) {
337
- return typeof e === "string" ? e : e.name;
338
- }
339
- /**
340
- * Merge any number of capability fragments into a single preset object that
341
- * spreads directly into `defineConfig()`.
342
- *
343
- * - Accepts individual capabilities or nested arrays (for bundle presets).
344
- * - Deduplicates by `id` — when the same ID appears more than once, the last
345
- * occurrence wins. This lets callers override bundle defaults by listing an
346
- * explicit capability after the bundle.
347
- * - Validates all `requires` at call time and throws `ConfigError` if any are
348
- * unmet, listing every missing dependency in a single message.
349
- *
350
- * @example
351
- * // docs-only site — no typecheck
352
- * const preset = compose(node(), docs());
353
- *
354
- * // library with docs
355
- * const preset = compose(node(), typecheck(), docs());
356
- *
357
- * // nextjs() is a bundle that returns Capability[]
358
- * const preset = compose(node(), nextjs());
359
- */
360
- function compose(...args) {
361
- const flat = args.flat();
362
- const byId = /* @__PURE__ */ new Map();
363
- for (const cap of flat) byId.set(cap.id, cap);
364
- const caps = [...byId.values()];
365
- const available = new Set(caps.map((c) => c.id));
366
- const errors = [];
367
- for (const cap of caps) for (const req of cap.requires ?? []) if (!available.has(req)) errors.push(`"${cap.id}" requires "${req}"`);
368
- if (errors.length > 0) throw new ConfigError(`compose(): unmet dependencies — ${errors.join(", ")}`);
369
- const taskMap = /* @__PURE__ */ new Map();
370
- for (const cap of caps) for (const entry of cap.tasks ?? []) taskMap.set(taskName(entry), entry);
371
- let providers = {};
372
- for (const cap of caps) if (cap.providers) providers = {
373
- ...providers,
374
- ...cap.providers
375
- };
376
- const checksSeen = /* @__PURE__ */ new Set();
377
- const extraRequiredChecks = [];
378
- for (const cap of caps) for (const check of cap.extraRequiredChecks ?? []) if (!checksSeen.has(check)) {
379
- checksSeen.add(check);
380
- extraRequiredChecks.push(check);
381
- }
382
- let repo = {};
383
- for (const cap of caps) {
384
- if (!cap.repo) continue;
385
- const { properties, topics, teams, variables, ...scalars } = cap.repo;
386
- repo = {
387
- ...repo,
388
- ...scalars
389
- };
390
- if (properties) repo.properties = {
391
- ...repo.properties,
392
- ...properties
393
- };
394
- if (variables) repo.variables = {
395
- ...repo.variables,
396
- ...variables,
397
- ...repo.variables?.repo || variables.repo ? { repo: {
398
- ...repo.variables?.repo,
399
- ...variables.repo
400
- } } : {},
401
- ...repo.variables?.org || variables.org ? { org: {
402
- ...repo.variables?.org,
403
- ...variables.org
404
- } } : {}
405
- };
406
- if (topics) {
407
- const merged = /* @__PURE__ */ new Set([...repo.topics ?? [], ...topics]);
408
- repo.topics = [...merged];
409
- }
410
- if (teams) {
411
- const teamMap = new Map((repo.teams ?? []).map((t) => [typeof t === "string" ? t : t.slug, t]));
412
- for (const t of teams) teamMap.set(typeof t === "string" ? t : t.slug, t);
413
- repo.teams = [...teamMap.values()];
414
- }
415
- }
416
- let org;
417
- let domain;
418
- let docs;
419
- for (const cap of caps) {
420
- if (cap.org !== void 0) org = cap.org;
421
- if (cap.domain !== void 0) domain = cap.domain;
422
- if (cap.docs !== void 0) docs = cap.docs;
423
- }
424
- return {
425
- tasks: [...taskMap.values()],
426
- providers,
427
- repo,
428
- extraRequiredChecks,
429
- ...org !== void 0 ? { org } : {},
430
- ...domain !== void 0 ? { domain } : {},
431
- ...docs !== void 0 ? { docs } : {}
432
- };
433
- }
434
- //#endregion
435
227
  //#region src/config/define-config/define-config.ts
436
228
  function defineConfig(config) {
437
229
  return config;
@@ -465,8 +257,9 @@ async function loadConfig(cwd) {
465
257
  walkUp: true
466
258
  });
467
259
  if (!found) throw new ConfigFileError$1(`no holocron.config.{ts,js,mjs,cjs,json} found in ${cwd}. Create one — see the README for the schema.`);
260
+ const withDefaults = await deriveDefaults(found);
468
261
  return {
469
- resolved: resolveConfig(await deriveDefaults(found)),
262
+ resolved: resolveConfig(withDefaults),
470
263
  filepath: found.filepath
471
264
  };
472
265
  }