@theholocron/cli 2.0.0-alpha.6 → 2.0.0-alpha.61

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.d.mts CHANGED
@@ -1,26 +1,56 @@
1
- import { $ as StorageBranch, A as EnvironmentReviewer, B as ParseWebhookInput, C as DeploymentTarget, D as DnsRecordType, E as DnsRecord, F as LifecycleResult, G as RepoSettings, H as ProviderIdentity, I as LifecycleSlot, J as SecretScope, K as ResolvedCapability, L as NormalizedAuthUser, M as Issue, N as IssueSearchFilter, O as EnsureResult, P as Issues, Q as Storage, R as Notifications, S as DeploymentRecord, T as Dns, U as REQUIRED_CAPABILITIES, V as ProviderApiError, W as RepoRef, X as Source, Y as Secrets, Z as StatusCategory, _ as ConnectionStringOptions, a as AuthEventType, at as WebhookDashboardInfo, b as DeploymentProject, c as CARDINALITY, d as Cardinality, et as Tooling, f as CardinalityFor, g as CiRunStatus, h as CiRunFilter, i as AuthEvent, it as Vault, j as Environments, k as Environment, l as CapabilityImpls, m as CiRun, n as Auth, nt as TrackerDoctorReport, o as AuthIdentity, ot as WebhookVerificationError, p as Ci, q as Ruleset, r as AuthDescription, rt as TrackerUser, s as AuthUser, st as isMulti, t as Analytics, tt as ToolingDoctorReport, u as CapabilityKey, v as CreateAuthUserInput, w as DeploymentTrigger, x as DeploymentProjectSettings, y as Deployment, z as Observability } from "./index-jxPVFH7-.mjs";
1
+ import { Analytics, Auth, AuthDescription, AuthEvent, AuthEventType, AuthIdentity, AuthUser, CARDINALITY, CapabilityImpls, CapabilityKey, Cardinality, CardinalityFor, Ci, CiRun, CiRunFilter, CiRunStatus, ConnectionStringOptions, CreateAuthUserInput, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, Dns, DnsRecord, DnsRecordType, EnsureResult, Environment, EnvironmentReviewer, Environments, Issue, IssueSearchFilter, Issues, LabelDef, LifecycleResult, LifecycleSlot, NormalizedAuthUser, Notifications, Observability, ParseWebhookInput, ProviderApiError, ProviderIdentity, REQUIRED_CAPABILITIES, RepoRef, RepoSettings, ResolvedCapability, Ruleset, SecretScope, Secrets, Source, StatusCategory, Storage, StorageBranch, Tooling, ToolingDoctorReport, TrackerDoctorReport, TrackerUser, Vault, WebhookDashboardInfo, WebhookVerificationError, isMulti } from "./capabilities/index.mjs";
2
+ import { AuthError, RequestOptions, ResolveTokenConfig as ResolveTokenConfig$1, ResolveTokenInput, RestClient, RestClientConfig, createRestClient } from "@theholocron/http-client";
2
3
 
4
+ //#region src/auth-resolver.d.ts
5
+ type ResolveTokenConfig = Omit<ResolveTokenConfig$1, "getKeyringToken">;
6
+ /** Wraps `createResolveToken` from `@theholocron/http` and injects the
7
+ * system keyring so plugins stay at a one-liner call site. */
8
+ declare function createResolveToken(config: ResolveTokenConfig): (input?: import("@theholocron/http-client").ResolveTokenInput) => string;
9
+ //#endregion
3
10
  //#region src/config.d.ts
4
11
  type ProviderOptions = Record<string, unknown>;
12
+ /**
13
+ * The shape a capability config package's default export must satisfy.
14
+ * Config packages let teams share a pre-bundled provider + options across
15
+ * repos (Level 1 of the shareable-configs story, issue #75).
16
+ *
17
+ * @example
18
+ * // @acme/holocron-vault/index.ts
19
+ * import type { CapabilityConfigPackage } from '@theholocron/cli'
20
+ * export default {
21
+ * provider: '1password',
22
+ * options: { vault: 'acme-app' },
23
+ * } satisfies CapabilityConfigPackage
24
+ */
25
+ interface CapabilityConfigPackage {
26
+ provider: string;
27
+ options?: ProviderOptions;
28
+ }
5
29
  type SingleEntry = string | [provider: string, options: ProviderOptions];
6
30
  type MultiEntry = Array<string | [provider: string, options: ProviderOptions]>;
7
31
  type RawProviderEntry = SingleEntry | MultiEntry;
8
32
  type RawProvidersConfig = Partial<Record<CapabilityKey, RawProviderEntry>>;
9
- interface RepoPolicyConfig {
33
+ type RepoProtection = "balanced" | "strict" | "none";
34
+ interface RepoProperties {
35
+ lifecycle?: "active" | "experimental" | "deprecated";
36
+ open_source?: boolean;
37
+ runtime_environment?: "node" | "browser" | "universal" | "none";
38
+ uses_external_packages?: boolean;
39
+ }
40
+ interface RepoConfig {
41
+ /** "owner/name" — the GitHub repository coordinate. Derived from the git remote when absent. */
42
+ name?: string;
10
43
  /**
11
- * "balanced" squash-only merges, delete-branch-on-merge, issues/discussions/projects
12
- * enabled, auto-merge enabled, web sign-off required, always suggest updating, no wiki;
13
- * plus a ruleset that blocks force-push + deletion and requires a pull request (0 reviews).
14
- *
15
- * "strict" — everything in "balanced" plus required status checks from `requiredChecks`.
16
- *
17
- * "none" — skips repo settings + ruleset entirely.
18
- *
19
- * @default "balanced"
44
+ * Branch protection preset applied by `holocron setup`. When omitted,
45
+ * no protection is applied and no `branch_protection_level` property is set.
20
46
  */
21
- preset?: "balanced" | "strict" | "none";
22
- /** CI check context names required on the default branch (used by "strict"). */
47
+ protection?: RepoProtection;
48
+ /** CI check context names required on the default branch (only used when `protection` is "strict"). */
23
49
  requiredChecks?: string[];
50
+ /** GitHub topics set on the repository. */
51
+ topics?: string[];
52
+ /** GitHub custom properties synced to the org dashboard. */
53
+ properties?: RepoProperties;
24
54
  }
25
55
  interface AppConfig {
26
56
  name: string;
@@ -31,35 +61,35 @@ interface DoctorConfig {
31
61
  checks?: string[];
32
62
  }
33
63
  interface HolocronConfig {
34
- project: {
64
+ /** Project name. Derived from package.json when absent. */
65
+ name?: string;
66
+ description?: string;
67
+ /**
68
+ * Repository identity and metadata. When set, `PluginLoader` injects
69
+ * `repo.name` into every plugin's `RuntimeContext.repo` so plugins that
70
+ * need a repo (github, etc.) don't require `--repo` on every invocation.
71
+ * `--repo` on the command line still overrides.
72
+ */
73
+ repo?: RepoConfig;
74
+ /**
75
+ * CI workflow names to install as thin wrappers during `holocron setup`.
76
+ * Each name maps to a reusable workflow in `theholocron/.github`.
77
+ * Use the object form to pass `with:` inputs to the reusable workflow.
78
+ *
79
+ * Supported values: "lint" | "test" | "typecheck" | "codeql" | "review" |
80
+ * "release" | "stale" | "greetings" | "dependencies" | "bookkeeping-pr" | "audit"
81
+ *
82
+ * `holocron setup` writes `.github/workflows/<name>.yml` for each entry,
83
+ * calling the corresponding `ci-<name>.yml@main` reusable workflow.
84
+ * Files are overwritten on each run — they are generated artifacts.
85
+ *
86
+ * @example
87
+ * ["lint", { "name": "release", "with": { "run-build": false } }]
88
+ */
89
+ workflows?: Array<string | {
35
90
  name: string;
36
- description?: string;
37
- /**
38
- * Repo coord — `"owner/name"`. When set, `PluginLoader` injects
39
- * it into every plugin's `RuntimeContext.repo` so plugins that
40
- * need a repo (github, etc.) don't require `--repo` on every
41
- * invocation. `--repo` on the command line still overrides.
42
- */
43
- repo?: string;
44
- /**
45
- * Repo-level policy applied by `holocron setup`. Defines merge
46
- * strategy, branch protection rulesets, and security defaults.
47
- * Requires `source` capability to be configured.
48
- */
49
- repoPolicy?: RepoPolicyConfig;
50
- /**
51
- * CI workflow names to install as thin wrappers during `holocron setup`.
52
- * Each name maps to a reusable workflow in `theholocron/.github`.
53
- *
54
- * Supported values: "lint" | "test" | "typecheck" | "codeql" | "review" |
55
- * "release" | "stale" | "greetings" | "dependencies" | "bookkeeping-pr" | "audit"
56
- *
57
- * `holocron setup` writes `.github/workflows/<name>.yml` for each entry,
58
- * calling the corresponding `ci-<name>.yml@main` reusable workflow.
59
- * Files are overwritten on each run — they are generated artifacts.
60
- */
61
- workflows?: string[];
62
- };
91
+ with?: Record<string, unknown>;
92
+ }>;
63
93
  providers: RawProvidersConfig;
64
94
  apps?: AppConfig[];
65
95
  doctor?: DoctorConfig;
@@ -79,7 +109,13 @@ type ResolvedProviderEntry = {
79
109
  };
80
110
  type ResolvedProvidersConfig = Partial<Record<CapabilityKey, ResolvedProviderEntry>>;
81
111
  interface ResolvedHolocronConfig {
82
- project: HolocronConfig["project"];
112
+ name: string;
113
+ description?: string;
114
+ repo?: RepoConfig;
115
+ workflows?: Array<string | {
116
+ name: string;
117
+ with?: Record<string, unknown>;
118
+ }>;
83
119
  providers: ResolvedProvidersConfig;
84
120
  apps: AppConfig[];
85
121
  doctor: DoctorConfig;
@@ -96,6 +132,9 @@ declare function resolvePluginPackage(provider: string): string;
96
132
  declare function resolveEntry(key: CapabilityKey, raw: RawProviderEntry): ResolvedProviderEntry;
97
133
  declare function resolveConfig(raw: HolocronConfig): ResolvedHolocronConfig;
98
134
  //#endregion
135
+ //#region src/define-config.d.ts
136
+ declare function defineConfig(config: HolocronConfig): HolocronConfig;
137
+ //#endregion
99
138
  //#region src/keyring.d.ts
100
139
  /**
101
140
  * Keyring-backed bootstrap credential store.
@@ -140,4 +179,20 @@ declare function deleteToken(provider: string): boolean;
140
179
  */
141
180
  declare function listStoredProviders(): string[];
142
181
  //#endregion
143
- export { Analytics, AppConfig, Auth, AuthDescription, AuthEvent, AuthEventType, AuthIdentity, AuthUser, CARDINALITY, CapabilityImpls, CapabilityKey, Cardinality, CardinalityFor, Ci, CiRun, CiRunFilter, CiRunStatus, ConfigError, ConnectionStringOptions, CreateAuthUserInput, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, Dns, DnsRecord, DnsRecordType, DoctorConfig, EnsureResult, Environment, EnvironmentReviewer, Environments, HolocronConfig, Issue, IssueSearchFilter, Issues, LifecycleResult, LifecycleSlot, MultiEntry, NormalizedAuthUser, Notifications, Observability, ParseWebhookInput, ProviderApiError, ProviderIdentity, ProviderOptions, REQUIRED_CAPABILITIES, RawProviderEntry, RawProvidersConfig, RepoPolicyConfig, RepoRef, RepoSettings, ResolvedCapability, ResolvedHolocronConfig, ResolvedProviderEntry, ResolvedProvidersConfig, ResolvedTuple, Ruleset, SecretScope, Secrets, SingleEntry, Source, StatusCategory, Storage, StorageBranch, Tooling, ToolingDoctorReport, TrackerDoctorReport, TrackerUser, Vault, WebhookDashboardInfo, WebhookVerificationError, deleteToken, getToken, isMulti, listStoredProviders, resolveConfig, resolveEntry, resolvePluginPackage, setToken };
182
+ //#region src/load-config.d.ts
183
+ declare class ConfigFileError extends Error {
184
+ name: string;
185
+ }
186
+ interface LoadedConfig {
187
+ resolved: ResolvedHolocronConfig;
188
+ /** Absolute path to the file the config was read from. */
189
+ filepath: string;
190
+ }
191
+ /**
192
+ * Read + parse + resolve `holocron.config.*` from the given directory.
193
+ * Search order: json → js → ts. Throws `ConfigFileError` if nothing
194
+ * found, or `ConfigError` if the config is malformed / invalid.
195
+ */
196
+ declare function loadConfig(cwd: string): Promise<LoadedConfig>;
197
+ //#endregion
198
+ export { Analytics, AppConfig, Auth, AuthDescription, AuthError, AuthEvent, AuthEventType, AuthIdentity, AuthUser, CARDINALITY, CapabilityConfigPackage, CapabilityImpls, CapabilityKey, Cardinality, CardinalityFor, Ci, CiRun, CiRunFilter, CiRunStatus, ConfigError, ConfigFileError, ConnectionStringOptions, CreateAuthUserInput, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, Dns, DnsRecord, DnsRecordType, DoctorConfig, EnsureResult, Environment, EnvironmentReviewer, Environments, HolocronConfig, Issue, IssueSearchFilter, Issues, LabelDef, LifecycleResult, LifecycleSlot, LoadedConfig, MultiEntry, NormalizedAuthUser, Notifications, Observability, ParseWebhookInput, ProviderApiError, ProviderIdentity, ProviderOptions, REQUIRED_CAPABILITIES, RawProviderEntry, RawProvidersConfig, RepoConfig, RepoProperties, RepoProtection, RepoRef, RepoSettings, type RequestOptions, ResolveTokenConfig, type ResolveTokenInput, ResolvedCapability, ResolvedHolocronConfig, ResolvedProviderEntry, ResolvedProvidersConfig, ResolvedTuple, type RestClient, type RestClientConfig, Ruleset, SecretScope, Secrets, SingleEntry, Source, StatusCategory, Storage, StorageBranch, Tooling, ToolingDoctorReport, TrackerDoctorReport, TrackerUser, Vault, WebhookDashboardInfo, WebhookVerificationError, createResolveToken, createRestClient, defineConfig, deleteToken, getToken, isMulti, listStoredProviders, loadConfig, resolveConfig, resolveEntry, resolvePluginPackage, setToken };
package/dist/index.mjs CHANGED
@@ -1,3 +1,326 @@
1
- import { a as isMulti, i as WebhookVerificationError, n as ProviderApiError, r as REQUIRED_CAPABILITIES, t as CARDINALITY } from "./capabilities-DapaKOlX.mjs";
2
- import { a as ConfigError, c as resolvePluginPackage, i as setToken, n as getToken, o as resolveConfig, r as listStoredProviders, s as resolveEntry, t as deleteToken } from "./keyring-DwNEmrBc.mjs";
3
- export { CARDINALITY, ConfigError, ProviderApiError, REQUIRED_CAPABILITIES, WebhookVerificationError, deleteToken, getToken, isMulti, listStoredProviders, resolveConfig, resolveEntry, resolvePluginPackage, setToken };
1
+ import { CARDINALITY, ProviderApiError, REQUIRED_CAPABILITIES, WebhookVerificationError, isMulti } from "./capabilities/index.mjs";
2
+ import { AuthError, createResolveToken as createResolveToken$1, createRestClient } from "@theholocron/http-client";
3
+ import { Entry, findCredentials } from "@napi-rs/keyring";
4
+ import { execFile } from "node:child_process";
5
+ import { readFile, stat } from "node:fs/promises";
6
+ import { basename, dirname, join } from "node:path";
7
+ import { pathToFileURL } from "node:url";
8
+ import { promisify } from "node:util";
9
+ //#region src/keyring.ts
10
+ /**
11
+ * Keyring-backed bootstrap credential store.
12
+ *
13
+ * Every holocron plugin's bootstrap token (the one it needs before it
14
+ * can talk to its vendor's API) can be stored in the OS keyring under
15
+ * a single reverse-DNS service scope. Managed via `holocron auth`
16
+ * subcommands; consulted at position 4 in every plugin's auth
17
+ * precedence chain (after --token / HOLOCRON_<X>_TOKEN / <native>_TOKEN).
18
+ *
19
+ * See `.notes/tech-auth-bootstrap.spec.md` for the design rationale.
20
+ *
21
+ * Failure model: keyring access is best-effort. Platforms without a
22
+ * supported credential store (some Linux CI images, sandboxed
23
+ * environments) will throw from the underlying library. Every export
24
+ * here catches and returns a null/empty result rather than propagating
25
+ * — the plugin's precedence chain then falls through to
26
+ * env-var-only paths, which is exactly how CI is meant to work.
27
+ */
28
+ const SERVICE = "com.theholocron.cli";
29
+ /**
30
+ * Store or overwrite a bootstrap token for a provider. Returns true on
31
+ * success, false when the underlying keyring is unsupported or errored.
32
+ */
33
+ function setToken(provider, token) {
34
+ try {
35
+ new Entry(SERVICE, provider).setPassword(token);
36
+ return true;
37
+ } catch {
38
+ return false;
39
+ }
40
+ }
41
+ /**
42
+ * Read the bootstrap token for a provider. Returns `null` for both
43
+ * "not stored" and "keyring unavailable" — callers can treat them the
44
+ * same way (fall through to env-var precedence).
45
+ */
46
+ function getToken(provider) {
47
+ try {
48
+ return new Entry(SERVICE, provider).getPassword();
49
+ } catch {
50
+ return null;
51
+ }
52
+ }
53
+ /**
54
+ * Delete a stored token. Returns true when a token was removed, false
55
+ * when there was nothing to delete or the keyring is unavailable.
56
+ * Distinguishing the two cases isn't worth the surface area — the
57
+ * command output makes the situation clear either way.
58
+ */
59
+ function deleteToken(provider) {
60
+ try {
61
+ return new Entry(SERVICE, provider).deletePassword();
62
+ } catch {
63
+ return false;
64
+ }
65
+ }
66
+ /**
67
+ * List provider slugs with a stored token in this service scope.
68
+ * Uses the library's `findCredentials(service)` — supported on all
69
+ * platforms the underlying credential store supports.
70
+ */
71
+ function listStoredProviders() {
72
+ try {
73
+ return findCredentials(SERVICE).map((c) => c.account);
74
+ } catch {
75
+ return [];
76
+ }
77
+ }
78
+ //#endregion
79
+ //#region src/auth-resolver.ts
80
+ /** Wraps `createResolveToken` from `@theholocron/http` and injects the
81
+ * system keyring so plugins stay at a one-liner call site. */
82
+ function createResolveToken(config) {
83
+ return createResolveToken$1({
84
+ ...config,
85
+ getKeyringToken: getToken
86
+ });
87
+ }
88
+ //#endregion
89
+ //#region src/config.ts
90
+ /**
91
+ * `holocron.config.json` schema, parser, and provider resolution.
92
+ *
93
+ * ESLint-style entry forms:
94
+ *
95
+ * "source": "github" ← single, short
96
+ * "deployment": ["vercel", { team: "rando" }] ← single, with options
97
+ * "notifications": ["slack", "discord"] ← multi, short
98
+ * "notifications": [
99
+ * ["slack", { channel: "#ops" }],
100
+ * ["discord", { webhook: "env:HOOK" }]
101
+ * ] ← multi, with options
102
+ *
103
+ * Discriminator: an array entry is a `[provider, options]` tuple when
104
+ * the length is 2 AND element[1] is a non-array, non-null object.
105
+ * Otherwise it's a multi-provider list (string[] or tuple[]).
106
+ *
107
+ * Validation rules:
108
+ * - `vault` is REQUIRED (every project has secrets somewhere)
109
+ * - Entries for `'many'` capabilities are normalized to an array of
110
+ * normalized tuples; entries for `'single'` capabilities are
111
+ * normalized to one tuple
112
+ * - Tokens / secret values never appear in config — providers read
113
+ * them from env (or pull from `vault` at runtime)
114
+ */
115
+ var ConfigError = class extends Error {
116
+ name = "ConfigError";
117
+ };
118
+ const PLUGIN_PREFIX = "@theholocron/holocron-plugin-";
119
+ const COMMUNITY_PREFIX = "holocron-plugin-";
120
+ /**
121
+ * Resolve `"github"` → `"@theholocron/holocron-plugin-github"`.
122
+ * Fully-qualified names (scoped or not) are honored verbatim, which
123
+ * is how third-party plugins published outside the org work.
124
+ */
125
+ function resolvePluginPackage(provider) {
126
+ if (!provider) throw new ConfigError("provider name is empty");
127
+ if (provider.startsWith("@")) return provider;
128
+ if (provider.startsWith(COMMUNITY_PREFIX)) return provider;
129
+ if (provider.includes("/")) return provider;
130
+ return PLUGIN_PREFIX + provider;
131
+ }
132
+ /** A bare `[provider, options]` tuple, with both elements present? */
133
+ function isOptionsTuple(value) {
134
+ if (!Array.isArray(value)) return false;
135
+ if (value.length !== 2) return false;
136
+ if (typeof value[0] !== "string") return false;
137
+ const opt = value[1];
138
+ return typeof opt === "object" && opt !== null && !Array.isArray(opt);
139
+ }
140
+ function normalizeEntry(entry) {
141
+ if (typeof entry === "string") return {
142
+ provider: entry,
143
+ packageName: resolvePluginPackage(entry),
144
+ options: {}
145
+ };
146
+ const [provider, options] = entry;
147
+ return {
148
+ provider,
149
+ packageName: resolvePluginPackage(provider),
150
+ options
151
+ };
152
+ }
153
+ function resolveEntry(key, raw) {
154
+ const cardinality = CARDINALITY[key];
155
+ if (typeof raw === "string") {
156
+ if (cardinality === "many") throw new ConfigError(`\`${key}\` accepts multiple providers; wrap a single one in an array: ["${raw}"]`);
157
+ return {
158
+ cardinality: "single",
159
+ tuple: normalizeEntry(raw)
160
+ };
161
+ }
162
+ if (!Array.isArray(raw)) throw new ConfigError(`\`${key}\` entry must be a string or array, got ${typeof raw}`);
163
+ if (isOptionsTuple(raw)) {
164
+ if (cardinality === "many") return {
165
+ cardinality: "many",
166
+ tuples: [normalizeEntry(raw)]
167
+ };
168
+ return {
169
+ cardinality: "single",
170
+ tuple: normalizeEntry(raw)
171
+ };
172
+ }
173
+ if (cardinality === "single") throw new ConfigError(`\`${key}\` accepts exactly one provider; got a multi-provider list with ${raw.length} entries`);
174
+ return {
175
+ cardinality: "many",
176
+ tuples: raw.map((entry, idx) => {
177
+ if (typeof entry === "string") return normalizeEntry(entry);
178
+ if (isOptionsTuple(entry)) return normalizeEntry(entry);
179
+ throw new ConfigError(`\`${key}[${idx}]\` must be a provider string or [provider, options] tuple`);
180
+ })
181
+ };
182
+ }
183
+ function resolveConfig(raw) {
184
+ if (!raw.name) throw new ConfigError("`name` is required");
185
+ if (!raw.providers || typeof raw.providers !== "object") throw new ConfigError("`providers` block is required");
186
+ const providers = {};
187
+ for (const [key, entry] of Object.entries(raw.providers)) {
188
+ if (entry === void 0) continue;
189
+ providers[key] = resolveEntry(key, entry);
190
+ }
191
+ for (const required of REQUIRED_CAPABILITIES) if (!providers[required]) throw new ConfigError(`required capability \`${required}\` is missing from providers`);
192
+ return {
193
+ name: raw.name,
194
+ description: raw.description,
195
+ repo: raw.repo,
196
+ workflows: raw.workflows,
197
+ providers,
198
+ apps: raw.apps ?? [],
199
+ doctor: raw.doctor ?? {}
200
+ };
201
+ }
202
+ //#endregion
203
+ //#region src/define-config.ts
204
+ function defineConfig(config) {
205
+ return config;
206
+ }
207
+ //#endregion
208
+ //#region src/load-config.ts
209
+ /**
210
+ * `holocron.config.{json,js,ts}` file loader.
211
+ *
212
+ * Search order: json → js → ts. JSON is parsed directly; JS is loaded
213
+ * via native dynamic import; TS is loaded via `tsImport` from tsx (a
214
+ * runtime dep) so operators can write typed configs with `defineConfig`
215
+ * without needing a separate build step.
216
+ *
217
+ * All three forms are validated through the same `resolveConfig` path.
218
+ * Implements the lookup-order contract from issue #75 / #81.
219
+ */
220
+ const execFileAsync = promisify(execFile);
221
+ const CANDIDATE_FILENAMES = [
222
+ "holocron.config.json",
223
+ "holocron.config.js",
224
+ "holocron.config.ts"
225
+ ];
226
+ var ConfigFileError = class extends Error {
227
+ name = "ConfigFileError";
228
+ };
229
+ /**
230
+ * Read + parse + resolve `holocron.config.*` from the given directory.
231
+ * Search order: json → js → ts. Throws `ConfigFileError` if nothing
232
+ * found, or `ConfigError` if the config is malformed / invalid.
233
+ */
234
+ async function loadConfig(cwd) {
235
+ for (const filename of CANDIDATE_FILENAMES) {
236
+ const fullPath = join(cwd, filename);
237
+ if (await fileExists(fullPath)) {
238
+ if (filename.endsWith(".json")) return {
239
+ resolved: await loadJson(fullPath),
240
+ filepath: fullPath
241
+ };
242
+ if (filename.endsWith(".ts")) return {
243
+ resolved: await loadTs(fullPath),
244
+ filepath: fullPath
245
+ };
246
+ return {
247
+ resolved: await loadJs(fullPath),
248
+ filepath: fullPath
249
+ };
250
+ }
251
+ }
252
+ throw new ConfigFileError(`no holocron.config.{json,js,ts} found in ${cwd}. Create one — see the README for the schema.`);
253
+ }
254
+ async function loadJson(filepath) {
255
+ const raw = await readFile(filepath, "utf8");
256
+ let parsed;
257
+ try {
258
+ parsed = JSON.parse(raw);
259
+ } catch (err) {
260
+ throw new ConfigError(`${filepath} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
261
+ }
262
+ return resolveConfig(await deriveDefaults(dirname(filepath), parsed));
263
+ }
264
+ async function loadJs(filepath) {
265
+ const mod = await import(pathToFileURL(filepath).href);
266
+ return resolveConfig(await deriveDefaults(dirname(filepath), extractRaw(filepath, mod)));
267
+ }
268
+ async function loadTs(filepath) {
269
+ const { tsImport } = await import("tsx/esm/api");
270
+ const mod = await tsImport(pathToFileURL(filepath).href, import.meta.url);
271
+ return resolveConfig(await deriveDefaults(dirname(filepath), extractRaw(filepath, mod)));
272
+ }
273
+ function extractRaw(filepath, mod) {
274
+ const outer = mod.default;
275
+ const raw = outer?.__esModule === true ? outer.default : outer;
276
+ if (raw === void 0 || raw === null) throw new ConfigFileError(`${filepath} must have a default export (use \`export default defineConfig({…})\`)`);
277
+ return raw;
278
+ }
279
+ async function deriveDefaults(configDir, raw) {
280
+ const result = { ...raw };
281
+ if (!result.name) result.name = await readPackageJsonName(configDir) ?? basename(configDir);
282
+ if (result.repo && !result.repo.name) {
283
+ const repoName = await readGitRemote(configDir);
284
+ if (repoName) result.repo = {
285
+ ...result.repo,
286
+ name: repoName
287
+ };
288
+ }
289
+ return result;
290
+ }
291
+ async function readPackageJsonName(dir) {
292
+ try {
293
+ const content = await readFile(join(dir, "package.json"), "utf8");
294
+ const pkg = JSON.parse(content);
295
+ return typeof pkg.name === "string" ? pkg.name.replace(/^@[^/]+\//, "") : void 0;
296
+ } catch {
297
+ return;
298
+ }
299
+ }
300
+ async function readGitRemote(dir) {
301
+ try {
302
+ const { stdout } = await execFileAsync("git", [
303
+ "remote",
304
+ "get-url",
305
+ "origin"
306
+ ], { cwd: dir });
307
+ return parseGitRemoteUrl(stdout.trim());
308
+ } catch {
309
+ return;
310
+ }
311
+ }
312
+ function parseGitRemoteUrl(url) {
313
+ const httpsMatch = url.match(/github\.com\/([^/]+\/[^/]+?)(?:\.git)?$/);
314
+ if (httpsMatch) return httpsMatch[1];
315
+ const sshMatch = url.match(/github\.com:([^/]+\/[^/]+?)(?:\.git)?$/);
316
+ if (sshMatch) return sshMatch[1];
317
+ }
318
+ async function fileExists(path) {
319
+ try {
320
+ return (await stat(path)).isFile();
321
+ } catch {
322
+ return false;
323
+ }
324
+ }
325
+ //#endregion
326
+ export { AuthError, CARDINALITY, ConfigError, ConfigFileError, ProviderApiError, REQUIRED_CAPABILITIES, WebhookVerificationError, createResolveToken, createRestClient, defineConfig, deleteToken, getToken, isMulti, listStoredProviders, loadConfig, resolveConfig, resolveEntry, resolvePluginPackage, setToken };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/cli",
3
- "version": "2.0.0-alpha.6",
3
+ "version": "2.0.0-alpha.61",
4
4
  "description": "The Holocron CLI — a pluggable, capability-based orchestrator for spinning up and operating software projects.",
5
5
  "homepage": "https://github.com/theholocron/holocron/tree/main/packages/cli#readme",
6
6
  "bugs": "https://github.com/theholocron/holocron/issues",
@@ -34,20 +34,26 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@napi-rs/keyring": "^1.3.0",
37
- "yargs": "^18.0.0",
38
- "@theholocron/cli-utils": "0.0.0"
37
+ "@theholocron/github-client": "^0.11.3",
38
+ "@theholocron/http-client": "^0.11.3",
39
+ "tsx": "^4.22.4",
40
+ "yargs": "^18.0.0"
39
41
  },
40
42
  "devDependencies": {
41
- "@theholocron/eslint-config": "^4.1.0",
42
- "@theholocron/tsconfig": "^4.1.0",
43
- "@tsconfig/node-lts": "^24.0.0",
43
+ "@theholocron/eslint-config": "^7.3.0",
44
+ "@theholocron/tsconfig": "^7.3.0",
45
+ "@theholocron/vitest-config": "^7.3.0",
46
+ "@types/node": "^26",
44
47
  "@types/yargs": "^17.0.35",
45
- "@vitest/coverage-v8": "^3.2.6",
46
- "eslint": "^9.36.0",
47
- "globals": "^16.5.0",
48
+ "@vitest/coverage-v8": "^4.1.10",
49
+ "@vitest/eslint-plugin": "^1.6.23",
50
+ "eslint": "^10.7.0",
51
+ "eslint-plugin-n": "^18.2.2",
52
+ "globals": "^17.7.0",
48
53
  "tsdown": "^0.22.3",
49
54
  "typescript": "^5.9.3",
50
- "vitest": "^3.2.6"
55
+ "vitest": "^4.1.10",
56
+ "@theholocron/cli-utils": "0.0.0"
51
57
  },
52
58
  "publishConfig": {
53
59
  "access": "public"
@@ -1,47 +0,0 @@
1
- //#region src/capabilities/index.ts
2
- const CARDINALITY = {
3
- source: "single",
4
- ci: "single",
5
- secrets: "single",
6
- environments: "single",
7
- issues: "single",
8
- deployment: "single",
9
- storage: "single",
10
- auth: "single",
11
- vault: "single",
12
- dns: "single",
13
- tooling: "many",
14
- notifications: "many",
15
- analytics: "many",
16
- observability: "many"
17
- };
18
- /**
19
- * No capabilities are strictly required — repos without secrets (e.g. org
20
- * community health repos) legitimately omit vault. Plugins validate their
21
- * own requirements at call time.
22
- */
23
- const REQUIRED_CAPABILITIES = [];
24
- /**
25
- * Surfaced from every capability call that hits a vendor API. Wraps
26
- * the underlying error with `status` (HTTP) and `details` so
27
- * orchestrators (`holocron setup`, `doctor`) can soft-skip rather
28
- * than abort.
29
- */
30
- var ProviderApiError = class extends Error {
31
- status;
32
- details;
33
- name = "ProviderApiError";
34
- constructor(message, status, details) {
35
- super(message);
36
- this.status = status;
37
- this.details = details;
38
- }
39
- };
40
- var WebhookVerificationError = class extends Error {
41
- name = "WebhookVerificationError";
42
- };
43
- function isMulti(key) {
44
- return CARDINALITY[key] === "many";
45
- }
46
- //#endregion
47
- export { isMulti as a, WebhookVerificationError as i, ProviderApiError as n, REQUIRED_CAPABILITIES as r, CARDINALITY as t };
package/dist/cli.d.mts DELETED
@@ -1 +0,0 @@
1
- export { };