@theholocron/cli 5.0.0-alpha.26 → 5.0.0-alpha.260
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 +321 -57
- package/dist/cli.mjs +14786 -8173
- 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-CdeSuXXV.d.mts +628 -0
- package/dist/index.d.mts +105 -577
- package/dist/index.mjs +174 -252
- package/dist/plugin/capabilities.d.mts +2 -794
- package/dist/plugin/capabilities.mjs +15 -3
- package/dist/presets.d.mts +211 -0
- package/dist/presets.mjs +401 -0
- package/package.json +25 -21
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { CARDINALITY, REQUIRED_CAPABILITIES } from "./plugin/capabilities.mjs";
|
|
2
|
+
// src/config/config/config.ts
|
|
3
|
+
var ConfigError = class extends Error {
|
|
4
|
+
name = "ConfigError";
|
|
5
|
+
};
|
|
6
|
+
const PLUGIN_PREFIX = "@theholocron/holocron-plugin-";
|
|
7
|
+
const COMMUNITY_PREFIX = "holocron-plugin-";
|
|
8
|
+
/**
|
|
9
|
+
* Resolve `"github"` → `"@theholocron/holocron-plugin-github"`.
|
|
10
|
+
* Fully-qualified names (scoped or not) are honored verbatim, which
|
|
11
|
+
* is how third-party plugins published outside the org work.
|
|
12
|
+
*/
|
|
13
|
+
function resolvePluginPackage(provider) {
|
|
14
|
+
if (!provider) throw new ConfigError("provider name is empty");
|
|
15
|
+
if (provider.startsWith("@")) return provider;
|
|
16
|
+
if (provider.startsWith(COMMUNITY_PREFIX)) return provider;
|
|
17
|
+
if (provider.includes("/")) return provider;
|
|
18
|
+
return PLUGIN_PREFIX + provider;
|
|
19
|
+
}
|
|
20
|
+
/** A bare `[provider, options]` tuple, with both elements present? */
|
|
21
|
+
function isOptionsTuple(value) {
|
|
22
|
+
if (!Array.isArray(value)) return false;
|
|
23
|
+
if (value.length !== 2) return false;
|
|
24
|
+
if (typeof value[0] !== "string") return false;
|
|
25
|
+
const opt = value[1];
|
|
26
|
+
return typeof opt === "object" && opt !== null && !Array.isArray(opt);
|
|
27
|
+
}
|
|
28
|
+
function normalizeEntry(entry) {
|
|
29
|
+
if (typeof entry === "string") return {
|
|
30
|
+
provider: entry,
|
|
31
|
+
packageName: resolvePluginPackage(entry),
|
|
32
|
+
options: {}
|
|
33
|
+
};
|
|
34
|
+
const [provider, options] = entry;
|
|
35
|
+
return {
|
|
36
|
+
provider,
|
|
37
|
+
packageName: resolvePluginPackage(provider),
|
|
38
|
+
options
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function resolveEntry(key, raw) {
|
|
42
|
+
const cardinality = CARDINALITY[key];
|
|
43
|
+
if (typeof raw === "string") {
|
|
44
|
+
if (cardinality === "many") throw new ConfigError(`\`${key}\` accepts multiple providers; wrap a single one in an array: ["${raw}"]`);
|
|
45
|
+
return {
|
|
46
|
+
cardinality: "single",
|
|
47
|
+
tuple: normalizeEntry(raw)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (!Array.isArray(raw)) throw new ConfigError(`\`${key}\` entry must be a string or array, got ${typeof raw}`);
|
|
51
|
+
if (isOptionsTuple(raw)) {
|
|
52
|
+
if (cardinality === "many") return {
|
|
53
|
+
cardinality: "many",
|
|
54
|
+
tuples: [normalizeEntry(raw)]
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
cardinality: "single",
|
|
58
|
+
tuple: normalizeEntry(raw)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (cardinality === "single") throw new ConfigError(`\`${key}\` accepts exactly one provider; got a multi-provider list with ${raw.length} entries`);
|
|
62
|
+
return {
|
|
63
|
+
cardinality: "many",
|
|
64
|
+
tuples: raw.map((entry, idx) => {
|
|
65
|
+
if (typeof entry === "string") return normalizeEntry(entry);
|
|
66
|
+
if (isOptionsTuple(entry)) return normalizeEntry(entry);
|
|
67
|
+
throw new ConfigError(`\`${key}[${idx}]\` must be a provider string or [provider, options] tuple`);
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function resolveConfig(raw) {
|
|
72
|
+
if (!raw.name) throw new ConfigError("`name` is required");
|
|
73
|
+
if (!raw.providers || typeof raw.providers !== "object") throw new ConfigError("`providers` block is required");
|
|
74
|
+
const providers = {};
|
|
75
|
+
for (const [key, entry] of Object.entries(raw.providers)) {
|
|
76
|
+
if (entry === void 0) continue;
|
|
77
|
+
providers[key] = resolveEntry(key, entry);
|
|
78
|
+
}
|
|
79
|
+
for (const required of REQUIRED_CAPABILITIES) if (!providers[required]) throw new ConfigError(`required capability \`${required}\` is missing from providers`);
|
|
80
|
+
let docs;
|
|
81
|
+
if (raw.docs !== void 0) {
|
|
82
|
+
if (!raw.docs.build) throw new ConfigError("`docs.build` is required when `docs` is set");
|
|
83
|
+
docs = raw.docs;
|
|
84
|
+
}
|
|
85
|
+
const homepage = raw.homepage ?? (docs?.domain ? `https://${docs.domain}/` : void 0);
|
|
86
|
+
return {
|
|
87
|
+
name: raw.name,
|
|
88
|
+
description: raw.description,
|
|
89
|
+
homepage,
|
|
90
|
+
org: raw.org,
|
|
91
|
+
domain: raw.domain,
|
|
92
|
+
repo: raw.repo,
|
|
93
|
+
tasks: raw.tasks,
|
|
94
|
+
syncScripts: raw.syncScripts,
|
|
95
|
+
holocronScript: raw.holocronScript,
|
|
96
|
+
extraRequiredChecks: raw.extraRequiredChecks,
|
|
97
|
+
hooks: raw.hooks,
|
|
98
|
+
providers,
|
|
99
|
+
apps: raw.apps ?? [],
|
|
100
|
+
doctor: raw.doctor ?? {},
|
|
101
|
+
agent: raw.agent,
|
|
102
|
+
skills: raw.skills,
|
|
103
|
+
docs,
|
|
104
|
+
env: raw.env,
|
|
105
|
+
log: raw.log,
|
|
106
|
+
telemetry: raw.telemetry,
|
|
107
|
+
eslint: raw.eslint
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// src/config/compose/compose.ts
|
|
111
|
+
function taskName(e) {
|
|
112
|
+
return typeof e === "string" ? e : e.name;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Merge any number of capability fragments into a single preset object that
|
|
116
|
+
* spreads directly into `defineConfig()`.
|
|
117
|
+
*
|
|
118
|
+
* - Accepts individual capabilities or nested arrays (for bundle presets).
|
|
119
|
+
* - Deduplicates by `id` — when the same ID appears more than once, the last
|
|
120
|
+
* occurrence wins. This lets callers override bundle defaults by listing an
|
|
121
|
+
* explicit capability after the bundle.
|
|
122
|
+
* - Validates all `requires` at call time and throws `ConfigError` if any are
|
|
123
|
+
* unmet, listing every missing dependency in a single message.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* // docs-only site — no typecheck
|
|
127
|
+
* const preset = compose(node(), docs());
|
|
128
|
+
*
|
|
129
|
+
* // library with docs
|
|
130
|
+
* const preset = compose(node(), typecheck(), docs());
|
|
131
|
+
*
|
|
132
|
+
* // nextjs() is a bundle that returns Capability[]
|
|
133
|
+
* const preset = compose(node(), nextjs());
|
|
134
|
+
*/
|
|
135
|
+
function compose(...args) {
|
|
136
|
+
const flat = args.flat();
|
|
137
|
+
const byId = /* @__PURE__ */ new Map();
|
|
138
|
+
for (const cap of flat) byId.set(cap.id, cap);
|
|
139
|
+
const caps = [...byId.values()];
|
|
140
|
+
const available = new Set(caps.map((c) => c.id));
|
|
141
|
+
const errors = [];
|
|
142
|
+
for (const cap of caps) for (const req of cap.requires ?? []) if (!available.has(req)) errors.push(`"${cap.id}" requires "${req}"`);
|
|
143
|
+
if (errors.length > 0) throw new ConfigError(`compose(): unmet dependencies — ${errors.join(", ")}`);
|
|
144
|
+
const taskMap = /* @__PURE__ */ new Map();
|
|
145
|
+
for (const cap of caps) for (const entry of cap.tasks ?? []) taskMap.set(taskName(entry), entry);
|
|
146
|
+
let providers = {};
|
|
147
|
+
for (const cap of caps) if (cap.providers) providers = {
|
|
148
|
+
...providers,
|
|
149
|
+
...cap.providers
|
|
150
|
+
};
|
|
151
|
+
const checksSeen = /* @__PURE__ */ new Set();
|
|
152
|
+
const extraRequiredChecks = [];
|
|
153
|
+
for (const cap of caps) for (const check of cap.extraRequiredChecks ?? []) if (!checksSeen.has(check)) {
|
|
154
|
+
checksSeen.add(check);
|
|
155
|
+
extraRequiredChecks.push(check);
|
|
156
|
+
}
|
|
157
|
+
let repo = {};
|
|
158
|
+
for (const cap of caps) {
|
|
159
|
+
if (!cap.repo) continue;
|
|
160
|
+
const { properties, topics, teams, variables, ...scalars } = cap.repo;
|
|
161
|
+
repo = {
|
|
162
|
+
...repo,
|
|
163
|
+
...scalars
|
|
164
|
+
};
|
|
165
|
+
if (properties) repo.properties = {
|
|
166
|
+
...repo.properties,
|
|
167
|
+
...properties
|
|
168
|
+
};
|
|
169
|
+
if (variables) repo.variables = {
|
|
170
|
+
...repo.variables,
|
|
171
|
+
...variables,
|
|
172
|
+
...repo.variables?.repo || variables.repo ? { repo: {
|
|
173
|
+
...repo.variables?.repo,
|
|
174
|
+
...variables.repo
|
|
175
|
+
} } : {},
|
|
176
|
+
...repo.variables?.org || variables.org ? { org: {
|
|
177
|
+
...repo.variables?.org,
|
|
178
|
+
...variables.org
|
|
179
|
+
} } : {}
|
|
180
|
+
};
|
|
181
|
+
if (topics) {
|
|
182
|
+
const merged = /* @__PURE__ */ new Set([...repo.topics ?? [], ...topics]);
|
|
183
|
+
repo.topics = [...merged];
|
|
184
|
+
}
|
|
185
|
+
if (teams) {
|
|
186
|
+
const teamMap = new Map((repo.teams ?? []).map((t) => [typeof t === "string" ? t : t.slug, t]));
|
|
187
|
+
for (const t of teams) teamMap.set(typeof t === "string" ? t : t.slug, t);
|
|
188
|
+
repo.teams = [...teamMap.values()];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
let org;
|
|
192
|
+
let domain;
|
|
193
|
+
let docs;
|
|
194
|
+
for (const cap of caps) {
|
|
195
|
+
if (cap.org !== void 0) org = cap.org;
|
|
196
|
+
if (cap.domain !== void 0) domain = cap.domain;
|
|
197
|
+
if (cap.docs !== void 0) docs = cap.docs;
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
tasks: [...taskMap.values()],
|
|
201
|
+
providers,
|
|
202
|
+
repo,
|
|
203
|
+
extraRequiredChecks,
|
|
204
|
+
...org !== void 0 ? { org } : {},
|
|
205
|
+
...domain !== void 0 ? { domain } : {},
|
|
206
|
+
...docs !== void 0 ? { docs } : {}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
export { resolvePluginPackage as a, resolveEntry as i, ConfigError as n, resolveConfig as r, compose as t };
|