@theholocron/cli 5.0.0-alpha.245 → 5.0.0-alpha.247
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/cli.mjs +238 -469
- package/dist/cli.mjs.map +1 -1
- package/dist/compose-DFW8ftHT.mjs +209 -0
- package/dist/index-BD9zG_5Z.d.mts +1632 -0
- package/dist/index-BK5cc9WI.d.mts +626 -0
- package/dist/index.d.mts +21 -673
- package/dist/index.mjs +10 -224
- package/dist/plugin/capabilities.d.mts +1 -1635
- package/dist/plugin/capabilities.mjs +1 -2
- package/dist/presets.d.mts +211 -0
- package/dist/presets.mjs +401 -0
- package/package.json +6 -6
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-DFW8ftHT.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";
|
|
@@ -8,7 +9,7 @@ import { loadTasksConfig } from "@theholocron/astromech/config";
|
|
|
8
9
|
import { ConfigFileError, ConfigFileError as ConfigFileError$1, loadConfigFile } from "@theholocron/datapad";
|
|
9
10
|
import { readGitRemote } from "@theholocron/git-utils";
|
|
10
11
|
import { lookup } from "node:dns/promises";
|
|
11
|
-
|
|
12
|
+
// src/env/env.ts
|
|
12
13
|
/** Singleton env for simple global lookups throughout the CLI. */
|
|
13
14
|
const env = createEnvLookup();
|
|
14
15
|
withEnvPrefix(env, "HOLOCRON");
|
|
@@ -19,8 +20,7 @@ withEnvPrefix(env, "HOLOCRON");
|
|
|
19
20
|
function makeEnv(source) {
|
|
20
21
|
return createEnvLookup(source);
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
//#region src/auth/keyring/keyring.ts
|
|
23
|
+
// src/auth/keyring/keyring.ts
|
|
24
24
|
/**
|
|
25
25
|
* Keyring-backed bootstrap credential store.
|
|
26
26
|
*
|
|
@@ -89,8 +89,7 @@ function listStoredProviders() {
|
|
|
89
89
|
return [];
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
//#region src/auth/auth-resolver/auth-resolver.ts
|
|
92
|
+
// src/auth/auth-resolver/auth-resolver.ts
|
|
94
93
|
/** Wraps `createResolveToken` from `@theholocron/http` and injects the
|
|
95
94
|
* system keyring so plugins stay at a one-liner call site. */
|
|
96
95
|
function createResolveToken(config) {
|
|
@@ -115,8 +114,7 @@ function createFeatureResolver(config) {
|
|
|
115
114
|
return token;
|
|
116
115
|
};
|
|
117
116
|
}
|
|
118
|
-
|
|
119
|
-
//#region src/commands/setup/derived-properties/derived-properties.ts
|
|
117
|
+
// src/commands/setup/derived-properties/derived-properties.ts
|
|
120
118
|
/**
|
|
121
119
|
* Repo archetype, in priority order:
|
|
122
120
|
* 1. `*-template` repo name → `template` (independent of package shape).
|
|
@@ -222,222 +220,11 @@ async function readWorkspacePackageJsons(repoRoot, workspacePackages) {
|
|
|
222
220
|
}
|
|
223
221
|
return results;
|
|
224
222
|
}
|
|
225
|
-
|
|
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
|
-
//#region src/config/define-config/define-config.ts
|
|
223
|
+
// src/config/define-config/define-config.ts
|
|
436
224
|
function defineConfig(config) {
|
|
437
225
|
return config;
|
|
438
226
|
}
|
|
439
|
-
|
|
440
|
-
//#region src/config/load-config/load-config.ts
|
|
227
|
+
// src/config/load-config/load-config.ts
|
|
441
228
|
/**
|
|
442
229
|
* `holocron.config.{ts,js,mjs,cjs,json}` loader.
|
|
443
230
|
*
|
|
@@ -465,8 +252,9 @@ async function loadConfig(cwd) {
|
|
|
465
252
|
walkUp: true
|
|
466
253
|
});
|
|
467
254
|
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.`);
|
|
255
|
+
const withDefaults = await deriveDefaults(found);
|
|
468
256
|
return {
|
|
469
|
-
resolved: resolveConfig(
|
|
257
|
+
resolved: resolveConfig(withDefaults),
|
|
470
258
|
filepath: found.filepath
|
|
471
259
|
};
|
|
472
260
|
}
|
|
@@ -493,8 +281,7 @@ async function readPackageJsonName(dir) {
|
|
|
493
281
|
const name = (await readPackageJson(dir))?.name;
|
|
494
282
|
return name === void 0 ? void 0 : name.replace(/^@[^/]+\//, "");
|
|
495
283
|
}
|
|
496
|
-
|
|
497
|
-
//#region src/plugin/connection-probe/connection-probe.ts
|
|
284
|
+
// src/plugin/connection-probe/connection-probe.ts
|
|
498
285
|
const TLS_CODES = /* @__PURE__ */ new Set([
|
|
499
286
|
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
500
287
|
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
@@ -631,5 +418,4 @@ function connectionProbe(input) {
|
|
|
631
418
|
}
|
|
632
419
|
};
|
|
633
420
|
}
|
|
634
|
-
//#endregion
|
|
635
421
|
export { AuthError, CARDINALITY, ConfigError, ConfigFileError, ElevationRequiredError, ProviderApiError, REQUIRED_CAPABILITIES, WebhookVerificationError, compose, connectionProbe, createFeatureResolver, createResolveToken, createRestClient, defineConfig, deleteToken, deriveCapabilities, deriveCompliance, deriveProfile, deriveStack, describeNetworkError, getToken, isMulti, listStoredProviders, loadConfig, missingCapabilities, readWorkspacePackageJsons, resolveConfig, resolveEntry, resolvePluginPackage, setToken };
|