@autometa/config 0.1.27 → 1.0.0-rc.0
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 +34 -2
- package/dist/builder-types.d.ts +27 -0
- package/dist/config.d.ts +12 -0
- package/dist/environment-selector.d.ts +10 -0
- package/dist/index.cjs +809 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -117
- package/dist/index.js +760 -142
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +584 -0
- package/dist/types.d.ts +47 -0
- package/package.json +24 -22
- package/.eslintignore +0 -3
- package/.eslintrc.cjs +0 -4
- package/.turbo/turbo-coverage.log +0 -27
- package/.turbo/turbo-lint$colon$fix.log +0 -4
- package/.turbo/turbo-prettify.log +0 -5
- package/.turbo/turbo-test.log +0 -16
- package/CHANGELOG.md +0 -220
- package/dist/esm/index.js +0 -151
- package/dist/esm/index.js.map +0 -1
- package/dist/index.d.cts +0 -117
- package/tsup.config.ts +0 -14
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,809 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var errors = require('@autometa/errors');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var zod = require('zod');
|
|
6
|
+
|
|
7
|
+
// src/config.ts
|
|
8
|
+
|
|
9
|
+
// src/environment-selector.ts
|
|
10
|
+
var sanitize = (value) => {
|
|
11
|
+
if (value == null) {
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
14
|
+
const trimmed = value.trim();
|
|
15
|
+
return trimmed.length === 0 ? void 0 : trimmed;
|
|
16
|
+
};
|
|
17
|
+
var EnvironmentSelector = class {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.detectors = [];
|
|
20
|
+
this.fallback = "default";
|
|
21
|
+
}
|
|
22
|
+
byLiteral(name) {
|
|
23
|
+
this.detectors.push(() => sanitize(name));
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
byEnvironmentVariable(variable) {
|
|
27
|
+
this.detectors.push(() => sanitize(process.env[variable]));
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
byFactory(factory) {
|
|
31
|
+
this.detectors.push(() => sanitize(factory()));
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
defaultTo(name) {
|
|
35
|
+
const sanitized = sanitize(name);
|
|
36
|
+
if (!sanitized) {
|
|
37
|
+
throw new Error("Default environment name must be a non-empty string");
|
|
38
|
+
}
|
|
39
|
+
this.fallback = sanitized;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
resolve() {
|
|
43
|
+
for (const detector of this.detectors) {
|
|
44
|
+
const detected = detector();
|
|
45
|
+
if (detected) {
|
|
46
|
+
return detected;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return this.fallback;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var TimeUnitSchema = zod.z.enum(["ms", "s", "m", "h"]);
|
|
53
|
+
var TimeoutSchema = zod.z.union([
|
|
54
|
+
zod.z.number().nonnegative(),
|
|
55
|
+
zod.z.tuple([zod.z.number().nonnegative(), TimeUnitSchema]),
|
|
56
|
+
zod.z.object({
|
|
57
|
+
value: zod.z.number().nonnegative(),
|
|
58
|
+
unit: TimeUnitSchema.optional()
|
|
59
|
+
})
|
|
60
|
+
]).optional();
|
|
61
|
+
var RunnerSchema = zod.z.union([zod.z.literal("jest"), zod.z.literal("vitest"), zod.z.literal("playwright")]);
|
|
62
|
+
var TagFilterSchema = zod.z.string().refine(
|
|
63
|
+
(value) => value.startsWith("@") || value.startsWith("not @"),
|
|
64
|
+
"tag filter must start with `@` or `not @`"
|
|
65
|
+
).optional();
|
|
66
|
+
var TestSchema = zod.z.object({
|
|
67
|
+
timeout: TimeoutSchema,
|
|
68
|
+
tagFilter: TagFilterSchema,
|
|
69
|
+
groupLogging: zod.z.boolean().optional()
|
|
70
|
+
}).partial();
|
|
71
|
+
var ShimSchema = zod.z.object({
|
|
72
|
+
errorCause: zod.z.boolean().optional()
|
|
73
|
+
});
|
|
74
|
+
var PathSchema = zod.z.array(zod.z.string());
|
|
75
|
+
var RootSchema = zod.z.object({
|
|
76
|
+
features: PathSchema,
|
|
77
|
+
steps: PathSchema,
|
|
78
|
+
support: PathSchema.optional()
|
|
79
|
+
}).catchall(PathSchema);
|
|
80
|
+
var EventsSchema = zod.z.array(zod.z.string());
|
|
81
|
+
var LoggingSchema = zod.z.object({
|
|
82
|
+
http: zod.z.boolean().optional()
|
|
83
|
+
}).optional();
|
|
84
|
+
var ReporterSchema = zod.z.object({
|
|
85
|
+
hierarchical: zod.z.object({
|
|
86
|
+
bufferOutput: zod.z.boolean().optional()
|
|
87
|
+
}).optional()
|
|
88
|
+
}).optional();
|
|
89
|
+
var ModuleFormatSchema = zod.z.enum(["cjs", "esm"]);
|
|
90
|
+
var PartialRootSchema = RootSchema.partial();
|
|
91
|
+
var ModuleDeclarationSchema = zod.z.lazy(
|
|
92
|
+
() => zod.z.union([
|
|
93
|
+
zod.z.string(),
|
|
94
|
+
zod.z.object({
|
|
95
|
+
name: zod.z.string().min(1),
|
|
96
|
+
submodules: zod.z.array(ModuleDeclarationSchema).optional()
|
|
97
|
+
})
|
|
98
|
+
])
|
|
99
|
+
);
|
|
100
|
+
var ModulesConfigSchema = zod.z.object({
|
|
101
|
+
stepScoping: zod.z.enum(["global", "scoped"]).optional(),
|
|
102
|
+
relativeRoots: PartialRootSchema.optional(),
|
|
103
|
+
groups: zod.z.record(
|
|
104
|
+
zod.z.object({
|
|
105
|
+
root: zod.z.string(),
|
|
106
|
+
modules: zod.z.array(ModuleDeclarationSchema).nonempty()
|
|
107
|
+
})
|
|
108
|
+
).optional(),
|
|
109
|
+
explicit: zod.z.array(zod.z.string()).optional()
|
|
110
|
+
});
|
|
111
|
+
var SourceMapSchema = zod.z.union([
|
|
112
|
+
zod.z.literal(true),
|
|
113
|
+
zod.z.literal(false),
|
|
114
|
+
zod.z.literal("inline"),
|
|
115
|
+
zod.z.literal("external")
|
|
116
|
+
]);
|
|
117
|
+
var BuildHookSchema = zod.z.custom((value) => {
|
|
118
|
+
return typeof value === "function";
|
|
119
|
+
}, {
|
|
120
|
+
message: "build hooks must be functions"
|
|
121
|
+
});
|
|
122
|
+
var BuilderHooksSchema = zod.z.object({
|
|
123
|
+
before: zod.z.array(BuildHookSchema).optional(),
|
|
124
|
+
after: zod.z.array(BuildHookSchema).optional()
|
|
125
|
+
});
|
|
126
|
+
var BuilderConfigSchema = zod.z.object({
|
|
127
|
+
format: ModuleFormatSchema.optional(),
|
|
128
|
+
target: zod.z.union([zod.z.string(), zod.z.array(zod.z.string()).nonempty()]).optional(),
|
|
129
|
+
sourcemap: SourceMapSchema.optional(),
|
|
130
|
+
tsconfig: zod.z.string().optional(),
|
|
131
|
+
external: zod.z.array(zod.z.string()).optional(),
|
|
132
|
+
outDir: zod.z.string().optional(),
|
|
133
|
+
hooks: BuilderHooksSchema.optional()
|
|
134
|
+
});
|
|
135
|
+
var ExecutorConfigSchema = zod.z.object({
|
|
136
|
+
runner: RunnerSchema,
|
|
137
|
+
test: TestSchema.optional(),
|
|
138
|
+
roots: RootSchema,
|
|
139
|
+
modules: ModulesConfigSchema.optional(),
|
|
140
|
+
shim: ShimSchema.optional(),
|
|
141
|
+
events: EventsSchema.optional(),
|
|
142
|
+
builder: BuilderConfigSchema.optional(),
|
|
143
|
+
logging: LoggingSchema.optional(),
|
|
144
|
+
reporting: ReporterSchema.optional()
|
|
145
|
+
});
|
|
146
|
+
var PartialExecutorConfigSchema = zod.z.object({
|
|
147
|
+
runner: RunnerSchema.optional(),
|
|
148
|
+
test: TestSchema.optional(),
|
|
149
|
+
roots: PartialRootSchema.optional(),
|
|
150
|
+
modules: ModulesConfigSchema.optional(),
|
|
151
|
+
shim: ShimSchema.optional(),
|
|
152
|
+
events: EventsSchema.optional(),
|
|
153
|
+
builder: BuilderConfigSchema.optional(),
|
|
154
|
+
logging: LoggingSchema.optional(),
|
|
155
|
+
reporting: ReporterSchema.optional()
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// src/config.ts
|
|
159
|
+
var Config = class {
|
|
160
|
+
constructor(definition) {
|
|
161
|
+
this.definition = definition;
|
|
162
|
+
}
|
|
163
|
+
resolve(options = {}) {
|
|
164
|
+
const environment = this.resolveEnvironment(options);
|
|
165
|
+
const override = this.definition.environments[environment] ?? {};
|
|
166
|
+
const merged = mergeExecutorConfig(this.definition.default, override);
|
|
167
|
+
const validated = ExecutorConfigSchema.parse(merged);
|
|
168
|
+
const expanded = expandModules(validated, options.modules, options.groups);
|
|
169
|
+
return {
|
|
170
|
+
environment,
|
|
171
|
+
config: deepFreeze(expanded)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
current(options) {
|
|
175
|
+
return this.resolve(options).config;
|
|
176
|
+
}
|
|
177
|
+
get environment() {
|
|
178
|
+
return this.resolve().environment;
|
|
179
|
+
}
|
|
180
|
+
forEnvironment(environment) {
|
|
181
|
+
return this.resolve({ environment }).config;
|
|
182
|
+
}
|
|
183
|
+
resolveEnvironment(options) {
|
|
184
|
+
if (options.environment) {
|
|
185
|
+
return this.assertEnvironment(options.environment);
|
|
186
|
+
}
|
|
187
|
+
const detected = this.definition.selector.resolve();
|
|
188
|
+
return this.assertEnvironment(detected);
|
|
189
|
+
}
|
|
190
|
+
assertEnvironment(environment) {
|
|
191
|
+
if (environment === "default") {
|
|
192
|
+
return environment;
|
|
193
|
+
}
|
|
194
|
+
if (!this.definition.environments[environment]) {
|
|
195
|
+
const available = [
|
|
196
|
+
"default",
|
|
197
|
+
...Object.keys(this.definition.environments).filter(
|
|
198
|
+
(name) => name !== "default"
|
|
199
|
+
)
|
|
200
|
+
];
|
|
201
|
+
const options = available.length ? available.join(", ") : "(define environments to extend the default profile)";
|
|
202
|
+
throw new errors.AutomationError(
|
|
203
|
+
`Environment "${environment}" is not defined. Available environments: ${options}`
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
return environment;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
var defineConfig = (input) => {
|
|
210
|
+
const selector = new EnvironmentSelector();
|
|
211
|
+
selector.defaultTo("default");
|
|
212
|
+
if (input.environment) {
|
|
213
|
+
input.environment(selector);
|
|
214
|
+
}
|
|
215
|
+
const defaultConfig = deepFreeze(ExecutorConfigSchema.parse(input.default));
|
|
216
|
+
const environments = {};
|
|
217
|
+
for (const [name, rawOverride] of Object.entries(input.environments ?? {})) {
|
|
218
|
+
if (!name.trim()) {
|
|
219
|
+
throw new errors.AutomationError("Environment name must be a non-empty string");
|
|
220
|
+
}
|
|
221
|
+
const override = rawOverride ? PartialExecutorConfigSchema.parse(rawOverride) : {};
|
|
222
|
+
environments[name] = deepFreeze(override);
|
|
223
|
+
}
|
|
224
|
+
return new Config({
|
|
225
|
+
default: defaultConfig,
|
|
226
|
+
environments,
|
|
227
|
+
selector
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
var mergeExecutorConfig = (base, override) => {
|
|
231
|
+
const result = cloneConfig(base);
|
|
232
|
+
if (override.runner) {
|
|
233
|
+
result.runner = override.runner;
|
|
234
|
+
}
|
|
235
|
+
if (override.test !== void 0) {
|
|
236
|
+
result.test = mergeTest(result.test, override.test);
|
|
237
|
+
}
|
|
238
|
+
if (override.roots !== void 0) {
|
|
239
|
+
result.roots = mergeRoots(result.roots, override.roots);
|
|
240
|
+
}
|
|
241
|
+
if (override.modules !== void 0) {
|
|
242
|
+
result.modules = cloneModules(override.modules);
|
|
243
|
+
}
|
|
244
|
+
if (override.shim !== void 0) {
|
|
245
|
+
result.shim = mergeShim(result.shim, override.shim);
|
|
246
|
+
}
|
|
247
|
+
if (override.events !== void 0) {
|
|
248
|
+
result.events = cloneArray(override.events);
|
|
249
|
+
}
|
|
250
|
+
if (override.builder !== void 0) {
|
|
251
|
+
result.builder = mergeBuilder(result.builder, override.builder);
|
|
252
|
+
}
|
|
253
|
+
if (override.logging !== void 0) {
|
|
254
|
+
result.logging = mergeLogging(result.logging, override.logging);
|
|
255
|
+
}
|
|
256
|
+
if (override.reporting !== void 0) {
|
|
257
|
+
result.reporting = mergeReporting(result.reporting, override.reporting);
|
|
258
|
+
}
|
|
259
|
+
return result;
|
|
260
|
+
};
|
|
261
|
+
var expandModules = (config, moduleFilters, groupFilters) => {
|
|
262
|
+
const modulesConfig = config.modules;
|
|
263
|
+
if (!modulesConfig) {
|
|
264
|
+
return config;
|
|
265
|
+
}
|
|
266
|
+
const relativeRoots = modulesConfig.relativeRoots;
|
|
267
|
+
const hasRelativeRoots = !!relativeRoots && Object.keys(relativeRoots).length > 0;
|
|
268
|
+
if (!hasRelativeRoots) {
|
|
269
|
+
const hasFilters = (moduleFilters?.some((m) => m.trim().length > 0) ?? false) || (groupFilters?.some((g) => g.trim().length > 0) ?? false);
|
|
270
|
+
if (hasFilters) {
|
|
271
|
+
throw new errors.AutomationError(
|
|
272
|
+
'Module filters were provided, but "modules.relativeRoots" is not configured. Configure at least one relative root (e.g. { steps: ["steps/**/*.ts"] }) or remove -m/-g.'
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
return config;
|
|
276
|
+
}
|
|
277
|
+
const moduleEntries = collectModuleEntries(modulesConfig);
|
|
278
|
+
if (moduleEntries.length === 0) {
|
|
279
|
+
throw new errors.AutomationError(
|
|
280
|
+
'When "modules" is provided, at least one module must be declared via "groups" or "explicit".'
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
const selectedModules = selectModules(moduleEntries, moduleFilters, groupFilters);
|
|
284
|
+
const expandedByKey = {};
|
|
285
|
+
for (const [key, entries] of Object.entries(relativeRoots)) {
|
|
286
|
+
if (!entries || entries.length === 0) {
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
const expanded = [];
|
|
290
|
+
for (const moduleDir of selectedModules) {
|
|
291
|
+
for (const entry of entries) {
|
|
292
|
+
const joined = joinModuleEntry(moduleDir, entry);
|
|
293
|
+
if (joined) {
|
|
294
|
+
expanded.push(joined);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (expanded.length > 0) {
|
|
299
|
+
expandedByKey[key] = expanded;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (Object.keys(expandedByKey).length === 0) {
|
|
303
|
+
return config;
|
|
304
|
+
}
|
|
305
|
+
const roots = cloneRoots(config.roots);
|
|
306
|
+
for (const [key, expanded] of Object.entries(expandedByKey)) {
|
|
307
|
+
const existing = roots[key] ?? [];
|
|
308
|
+
roots[key] = [...expanded, ...existing];
|
|
309
|
+
}
|
|
310
|
+
return {
|
|
311
|
+
...config,
|
|
312
|
+
roots
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
var flattenModuleDeclarations = (declarations, prefix = "") => {
|
|
316
|
+
const flattened = [];
|
|
317
|
+
const walk = (items, currentPrefix) => {
|
|
318
|
+
for (const item of items) {
|
|
319
|
+
if (typeof item === "string") {
|
|
320
|
+
const name2 = normalizeSlashes(item.trim()).replace(/^\/+|\/+$/gu, "");
|
|
321
|
+
if (!name2) {
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
flattened.push(normalizeSlashes(path.posix.join(currentPrefix, name2)));
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
const name = normalizeSlashes(item.name.trim()).replace(/^\/+|\/+$/gu, "");
|
|
328
|
+
if (!name) {
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
const nextPrefix = normalizeSlashes(path.posix.join(currentPrefix, name));
|
|
332
|
+
flattened.push(nextPrefix);
|
|
333
|
+
if (item.submodules && item.submodules.length > 0) {
|
|
334
|
+
walk(item.submodules, nextPrefix);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
const cleanedPrefix = normalizeSlashes(prefix.trim()).replace(/\/+$/u, "");
|
|
339
|
+
walk(declarations, cleanedPrefix);
|
|
340
|
+
return Array.from(new Set(flattened));
|
|
341
|
+
};
|
|
342
|
+
var collectModuleEntries = (modulesConfig) => {
|
|
343
|
+
const entries = [];
|
|
344
|
+
const seen = /* @__PURE__ */ new Set();
|
|
345
|
+
for (const [groupId, group] of Object.entries(modulesConfig.groups ?? {})) {
|
|
346
|
+
const normalizedGroupId = groupId.trim();
|
|
347
|
+
if (!normalizedGroupId) {
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
const root = normalizeSlashes(group.root.trim()).replace(/\/+$/u, "");
|
|
351
|
+
if (!root) {
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
const modulePaths = flattenModuleDeclarations(group.modules);
|
|
355
|
+
for (const modulePath of modulePaths) {
|
|
356
|
+
const cleaned = normalizeSlashes(modulePath.trim()).replace(/^\/+|\/+$/gu, "");
|
|
357
|
+
if (!cleaned) {
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
const dir = normalizeSlashes(path.posix.join(root, cleaned));
|
|
361
|
+
const id = `${normalizedGroupId}/${cleaned}`;
|
|
362
|
+
const key = `${id}::${dir}`;
|
|
363
|
+
if (seen.has(key)) {
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
seen.add(key);
|
|
367
|
+
entries.push({ id, dir });
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
for (const explicit of modulesConfig.explicit ?? []) {
|
|
371
|
+
const normalized = normalizeSlashes(explicit.trim());
|
|
372
|
+
if (!normalized) {
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
const id = normalized;
|
|
376
|
+
const key = `${id}::${normalized}`;
|
|
377
|
+
if (seen.has(key)) {
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
seen.add(key);
|
|
381
|
+
entries.push({ id, dir: normalized });
|
|
382
|
+
}
|
|
383
|
+
return entries;
|
|
384
|
+
};
|
|
385
|
+
var selectModules = (moduleEntries, moduleFilters, groupFilters) => {
|
|
386
|
+
const options = moduleEntries.map((m) => ({
|
|
387
|
+
id: normalizeSlashes(m.id),
|
|
388
|
+
dir: normalizeSlashes(m.dir),
|
|
389
|
+
group: normalizeSlashes(m.id.split("/")[0] ?? "")
|
|
390
|
+
}));
|
|
391
|
+
const groupFilterSet = new Set(
|
|
392
|
+
(groupFilters ?? []).map((g) => normalizeSlashes(g.trim())).filter(Boolean)
|
|
393
|
+
);
|
|
394
|
+
const inGroupScope = (candidate) => {
|
|
395
|
+
if (groupFilterSet.size === 0) {
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
return groupFilterSet.has(candidate.group);
|
|
399
|
+
};
|
|
400
|
+
const scopedOptions = options.filter(inGroupScope);
|
|
401
|
+
if (groupFilterSet.size > 0 && scopedOptions.length === 0) {
|
|
402
|
+
throw new errors.AutomationError(
|
|
403
|
+
`No modules found for group filter(s): ${Array.from(groupFilterSet).join(", ")}. Available groups: ${Array.from(new Set(options.map((o) => o.group))).filter(Boolean).join(", ")}`
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
if (!moduleFilters || moduleFilters.length === 0) {
|
|
407
|
+
return scopedOptions.map((o) => o.dir);
|
|
408
|
+
}
|
|
409
|
+
const scopedGroups = new Set(scopedOptions.map((o) => o.group).filter(Boolean));
|
|
410
|
+
const selected = /* @__PURE__ */ new Set();
|
|
411
|
+
for (const rawFilter of moduleFilters) {
|
|
412
|
+
const filter = normalizeSlashes(rawFilter.trim());
|
|
413
|
+
if (!filter) {
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
const parsed = parseModuleSelector(filter, scopedGroups);
|
|
417
|
+
if (parsed) {
|
|
418
|
+
const wantedId = `${parsed.group}/${parsed.modulePath}`;
|
|
419
|
+
const exact = scopedOptions.filter((o) => o.id === wantedId);
|
|
420
|
+
if (exact.length === 0) {
|
|
421
|
+
throw new errors.AutomationError(
|
|
422
|
+
`Module "${rawFilter}" not found. Available modules: ${scopedOptions.map((o) => o.id).join(", ")}`
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
const match2 = exact[0];
|
|
426
|
+
if (match2) {
|
|
427
|
+
selected.add(match2.dir);
|
|
428
|
+
}
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
const pathSelector = filter.includes(":") ? filter.split(":").join("/") : filter;
|
|
432
|
+
const suffixMatches = scopedOptions.filter((o) => o.id.endsWith(`/${pathSelector}`));
|
|
433
|
+
if (suffixMatches.length === 0) {
|
|
434
|
+
throw new errors.AutomationError(
|
|
435
|
+
`Module "${rawFilter}" not found. Available modules: ${scopedOptions.map((o) => o.id).join(", ")}`
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
if (suffixMatches.length > 1) {
|
|
439
|
+
throw new errors.AutomationError(
|
|
440
|
+
`Module filter "${rawFilter}" is ambiguous. Candidates: ${suffixMatches.map((m) => m.id).join(", ")}. Use "<group>/<module>" or "<group>:<module>" to disambiguate.`
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
const match = suffixMatches[0];
|
|
444
|
+
if (match) {
|
|
445
|
+
selected.add(match.dir);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return scopedOptions.map((o) => o.dir).filter((dir) => selected.has(dir));
|
|
449
|
+
};
|
|
450
|
+
var parseModuleSelector = (selector, knownGroups) => {
|
|
451
|
+
if (!selector) {
|
|
452
|
+
return void 0;
|
|
453
|
+
}
|
|
454
|
+
if (selector.includes(":")) {
|
|
455
|
+
const parts = selector.split(":").map((p) => p.trim()).filter(Boolean);
|
|
456
|
+
if (parts.length >= 2) {
|
|
457
|
+
const group = parts[0];
|
|
458
|
+
if (!group) {
|
|
459
|
+
return void 0;
|
|
460
|
+
}
|
|
461
|
+
if (knownGroups.has(group)) {
|
|
462
|
+
const modulePath = normalizeSlashes(parts.slice(1).join("/")).replace(/^\/+|\/+$/gu, "");
|
|
463
|
+
if (modulePath) {
|
|
464
|
+
return { group, modulePath };
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
if (selector.includes("/")) {
|
|
470
|
+
const parts = selector.split("/").map((p) => p.trim()).filter(Boolean);
|
|
471
|
+
if (parts.length >= 2) {
|
|
472
|
+
const group = parts[0];
|
|
473
|
+
if (!group) {
|
|
474
|
+
return void 0;
|
|
475
|
+
}
|
|
476
|
+
if (knownGroups.has(group)) {
|
|
477
|
+
const modulePath = normalizeSlashes(parts.slice(1).join("/")).replace(/^\/+|\/+$/gu, "");
|
|
478
|
+
if (modulePath) {
|
|
479
|
+
return { group, modulePath };
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return void 0;
|
|
485
|
+
};
|
|
486
|
+
var joinModuleEntry = (moduleDir, entry) => {
|
|
487
|
+
const moduleTrimmed = normalizeSlashes(moduleDir.trim()).replace(/\/+$/u, "");
|
|
488
|
+
if (!moduleTrimmed) {
|
|
489
|
+
return void 0;
|
|
490
|
+
}
|
|
491
|
+
const entryTrimmed = normalizeSlashes(entry.trim());
|
|
492
|
+
if (!entryTrimmed) {
|
|
493
|
+
return void 0;
|
|
494
|
+
}
|
|
495
|
+
const negated = entryTrimmed.startsWith("!");
|
|
496
|
+
const raw = negated ? entryTrimmed.slice(1).trim() : entryTrimmed;
|
|
497
|
+
if (!raw || raw === ".") {
|
|
498
|
+
return negated ? `!${moduleTrimmed}` : moduleTrimmed;
|
|
499
|
+
}
|
|
500
|
+
if (raw.startsWith("/") || /^[A-Za-z]:\//u.test(raw)) {
|
|
501
|
+
return negated ? `!${raw}` : raw;
|
|
502
|
+
}
|
|
503
|
+
const joined = normalizeSlashes(path.posix.join(moduleTrimmed, raw));
|
|
504
|
+
return negated ? `!${joined}` : joined;
|
|
505
|
+
};
|
|
506
|
+
var normalizeSlashes = (value) => value.replace(/\\/gu, "/");
|
|
507
|
+
var mergeTest = (base, override) => {
|
|
508
|
+
if (override === void 0) {
|
|
509
|
+
return base ? cloneTest(base) : void 0;
|
|
510
|
+
}
|
|
511
|
+
const result = base ? cloneTest(base) : {};
|
|
512
|
+
if (override.timeout !== void 0) {
|
|
513
|
+
result.timeout = cloneTimeout(override.timeout);
|
|
514
|
+
}
|
|
515
|
+
if (override.tagFilter !== void 0) {
|
|
516
|
+
result.tagFilter = override.tagFilter;
|
|
517
|
+
}
|
|
518
|
+
if (override.groupLogging !== void 0) {
|
|
519
|
+
result.groupLogging = override.groupLogging;
|
|
520
|
+
}
|
|
521
|
+
return Object.keys(result).length === 0 ? void 0 : result;
|
|
522
|
+
};
|
|
523
|
+
var mergeShim = (base, override) => {
|
|
524
|
+
if (override === void 0) {
|
|
525
|
+
return base ? cloneShim(base) : void 0;
|
|
526
|
+
}
|
|
527
|
+
const result = base ? cloneShim(base) : {};
|
|
528
|
+
if (override.errorCause !== void 0) {
|
|
529
|
+
result.errorCause = override.errorCause;
|
|
530
|
+
}
|
|
531
|
+
return Object.keys(result).length === 0 ? void 0 : result;
|
|
532
|
+
};
|
|
533
|
+
var mergeLogging = (base, override) => {
|
|
534
|
+
if (override === void 0) {
|
|
535
|
+
return base ? cloneLogging(base) : void 0;
|
|
536
|
+
}
|
|
537
|
+
const result = base ? cloneLogging(base) : {};
|
|
538
|
+
if (override.http !== void 0) {
|
|
539
|
+
result.http = override.http;
|
|
540
|
+
}
|
|
541
|
+
return Object.keys(result).length === 0 ? void 0 : result;
|
|
542
|
+
};
|
|
543
|
+
var mergeReporting = (base, override) => {
|
|
544
|
+
if (override === void 0) {
|
|
545
|
+
return base ? cloneReporting(base) : void 0;
|
|
546
|
+
}
|
|
547
|
+
const result = base ? cloneReporting(base) : {};
|
|
548
|
+
if (override.hierarchical !== void 0) {
|
|
549
|
+
const hierarchicalOverride = override.hierarchical;
|
|
550
|
+
if (hierarchicalOverride) {
|
|
551
|
+
const hierarchical = result.hierarchical ? { ...result.hierarchical } : {};
|
|
552
|
+
if (hierarchicalOverride.bufferOutput !== void 0) {
|
|
553
|
+
hierarchical.bufferOutput = hierarchicalOverride.bufferOutput;
|
|
554
|
+
}
|
|
555
|
+
if (Object.keys(hierarchical).length > 0) {
|
|
556
|
+
result.hierarchical = hierarchical;
|
|
557
|
+
} else {
|
|
558
|
+
delete result.hierarchical;
|
|
559
|
+
}
|
|
560
|
+
} else {
|
|
561
|
+
delete result.hierarchical;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return Object.keys(result).length === 0 ? void 0 : result;
|
|
565
|
+
};
|
|
566
|
+
var mergeRoots = (base, override) => {
|
|
567
|
+
const result = cloneRoots(base);
|
|
568
|
+
if (!override) {
|
|
569
|
+
return result;
|
|
570
|
+
}
|
|
571
|
+
for (const [key, value] of Object.entries(override)) {
|
|
572
|
+
if (value === void 0) {
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
result[key] = cloneArray(value);
|
|
576
|
+
}
|
|
577
|
+
if (!result.features) {
|
|
578
|
+
throw new errors.AutomationError(
|
|
579
|
+
'Environment overrides removed required root "features"'
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
if (!result.steps) {
|
|
583
|
+
throw new errors.AutomationError(
|
|
584
|
+
'Environment overrides removed required root "steps"'
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
return result;
|
|
588
|
+
};
|
|
589
|
+
var mergeBuilder = (base, override) => {
|
|
590
|
+
if (override === void 0) {
|
|
591
|
+
return base ? cloneBuilder(base) : void 0;
|
|
592
|
+
}
|
|
593
|
+
const result = base ? cloneBuilder(base) : {};
|
|
594
|
+
if (override.format !== void 0) {
|
|
595
|
+
result.format = override.format;
|
|
596
|
+
}
|
|
597
|
+
if (override.target !== void 0) {
|
|
598
|
+
result.target = Array.isArray(override.target) ? [...override.target] : override.target;
|
|
599
|
+
}
|
|
600
|
+
if (override.sourcemap !== void 0) {
|
|
601
|
+
result.sourcemap = override.sourcemap;
|
|
602
|
+
}
|
|
603
|
+
if (override.tsconfig !== void 0) {
|
|
604
|
+
result.tsconfig = override.tsconfig;
|
|
605
|
+
}
|
|
606
|
+
if (override.external !== void 0) {
|
|
607
|
+
result.external = cloneArray(override.external);
|
|
608
|
+
}
|
|
609
|
+
if (override.outDir !== void 0) {
|
|
610
|
+
result.outDir = override.outDir;
|
|
611
|
+
}
|
|
612
|
+
if (override.hooks !== void 0) {
|
|
613
|
+
const clonedHooks = cloneBuilderHooks(override.hooks);
|
|
614
|
+
if (clonedHooks) {
|
|
615
|
+
result.hooks = clonedHooks;
|
|
616
|
+
} else {
|
|
617
|
+
delete result.hooks;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return Object.keys(result).length === 0 ? void 0 : result;
|
|
621
|
+
};
|
|
622
|
+
var cloneConfig = (config) => ({
|
|
623
|
+
runner: config.runner,
|
|
624
|
+
roots: cloneRoots(config.roots),
|
|
625
|
+
modules: config.modules ? cloneModules(config.modules) : void 0,
|
|
626
|
+
test: config.test ? cloneTest(config.test) : void 0,
|
|
627
|
+
shim: config.shim ? cloneShim(config.shim) : void 0,
|
|
628
|
+
events: cloneOptionalArray(config.events),
|
|
629
|
+
builder: config.builder ? cloneBuilder(config.builder) : void 0,
|
|
630
|
+
logging: config.logging ? cloneLogging(config.logging) : void 0,
|
|
631
|
+
reporting: config.reporting ? cloneReporting(config.reporting) : void 0
|
|
632
|
+
});
|
|
633
|
+
var cloneRoots = (roots) => {
|
|
634
|
+
const cloned = {};
|
|
635
|
+
for (const [key, value] of Object.entries(roots)) {
|
|
636
|
+
if (value) {
|
|
637
|
+
cloned[key] = cloneArray(value);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
return cloned;
|
|
641
|
+
};
|
|
642
|
+
var cloneRootRecord = (roots) => {
|
|
643
|
+
const cloned = {};
|
|
644
|
+
for (const [key, value] of Object.entries(roots)) {
|
|
645
|
+
if (!value) {
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
cloned[key] = cloneArray(value);
|
|
649
|
+
}
|
|
650
|
+
return cloned;
|
|
651
|
+
};
|
|
652
|
+
var cloneGroups = (groups) => {
|
|
653
|
+
const cloneModuleDeclaration = (value) => {
|
|
654
|
+
if (typeof value === "string") {
|
|
655
|
+
return value;
|
|
656
|
+
}
|
|
657
|
+
return {
|
|
658
|
+
name: value.name,
|
|
659
|
+
submodules: value.submodules ? value.submodules.map((child) => cloneModuleDeclaration(child)) : void 0
|
|
660
|
+
};
|
|
661
|
+
};
|
|
662
|
+
const cloned = {};
|
|
663
|
+
for (const [key, group] of Object.entries(groups)) {
|
|
664
|
+
cloned[key] = {
|
|
665
|
+
root: group.root,
|
|
666
|
+
modules: group.modules.map((m) => cloneModuleDeclaration(m))
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
return cloned;
|
|
670
|
+
};
|
|
671
|
+
var cloneModules = (modules) => {
|
|
672
|
+
const clone = {};
|
|
673
|
+
if (modules.relativeRoots) {
|
|
674
|
+
clone.relativeRoots = cloneRootRecord(modules.relativeRoots);
|
|
675
|
+
}
|
|
676
|
+
if (modules.groups) {
|
|
677
|
+
clone.groups = cloneGroups(modules.groups);
|
|
678
|
+
}
|
|
679
|
+
if (modules.explicit) {
|
|
680
|
+
clone.explicit = cloneArray(modules.explicit);
|
|
681
|
+
}
|
|
682
|
+
return clone;
|
|
683
|
+
};
|
|
684
|
+
var cloneTest = (test) => {
|
|
685
|
+
const clone = {};
|
|
686
|
+
if (test.timeout !== void 0) {
|
|
687
|
+
clone.timeout = cloneTimeout(test.timeout);
|
|
688
|
+
}
|
|
689
|
+
if (test.tagFilter !== void 0) {
|
|
690
|
+
clone.tagFilter = test.tagFilter;
|
|
691
|
+
}
|
|
692
|
+
if (test.groupLogging !== void 0) {
|
|
693
|
+
clone.groupLogging = test.groupLogging;
|
|
694
|
+
}
|
|
695
|
+
return clone;
|
|
696
|
+
};
|
|
697
|
+
var cloneShim = (shim) => {
|
|
698
|
+
const clone = {};
|
|
699
|
+
if (shim.errorCause !== void 0) {
|
|
700
|
+
clone.errorCause = shim.errorCause;
|
|
701
|
+
}
|
|
702
|
+
return clone;
|
|
703
|
+
};
|
|
704
|
+
var cloneLogging = (logging) => {
|
|
705
|
+
const clone = {};
|
|
706
|
+
if (logging.http !== void 0) {
|
|
707
|
+
clone.http = logging.http;
|
|
708
|
+
}
|
|
709
|
+
return clone;
|
|
710
|
+
};
|
|
711
|
+
var cloneReporting = (reporting) => {
|
|
712
|
+
const clone = {};
|
|
713
|
+
if (reporting.hierarchical) {
|
|
714
|
+
clone.hierarchical = { ...reporting.hierarchical };
|
|
715
|
+
}
|
|
716
|
+
return clone;
|
|
717
|
+
};
|
|
718
|
+
var cloneBuilder = (config) => {
|
|
719
|
+
const clone = {};
|
|
720
|
+
if (config.format !== void 0) {
|
|
721
|
+
clone.format = config.format;
|
|
722
|
+
}
|
|
723
|
+
if (config.target !== void 0) {
|
|
724
|
+
clone.target = Array.isArray(config.target) ? [...config.target] : config.target;
|
|
725
|
+
}
|
|
726
|
+
if (config.sourcemap !== void 0) {
|
|
727
|
+
clone.sourcemap = config.sourcemap;
|
|
728
|
+
}
|
|
729
|
+
if (config.tsconfig !== void 0) {
|
|
730
|
+
clone.tsconfig = config.tsconfig;
|
|
731
|
+
}
|
|
732
|
+
if (config.external !== void 0) {
|
|
733
|
+
clone.external = cloneArray(config.external);
|
|
734
|
+
}
|
|
735
|
+
if (config.outDir !== void 0) {
|
|
736
|
+
clone.outDir = config.outDir;
|
|
737
|
+
}
|
|
738
|
+
if (config.hooks) {
|
|
739
|
+
const clonedHooks = cloneBuilderHooks(config.hooks);
|
|
740
|
+
if (clonedHooks) {
|
|
741
|
+
clone.hooks = clonedHooks;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
return clone;
|
|
745
|
+
};
|
|
746
|
+
var cloneBuilderHooks = (hooks) => {
|
|
747
|
+
const clone = {};
|
|
748
|
+
if (hooks.before && hooks.before.length > 0) {
|
|
749
|
+
clone.before = [...hooks.before];
|
|
750
|
+
}
|
|
751
|
+
if (hooks.after && hooks.after.length > 0) {
|
|
752
|
+
clone.after = [...hooks.after];
|
|
753
|
+
}
|
|
754
|
+
return Object.keys(clone).length === 0 ? void 0 : clone;
|
|
755
|
+
};
|
|
756
|
+
var cloneTimeout = (timeout) => {
|
|
757
|
+
if (timeout === void 0) {
|
|
758
|
+
return void 0;
|
|
759
|
+
}
|
|
760
|
+
if (typeof timeout === "number") {
|
|
761
|
+
return timeout;
|
|
762
|
+
}
|
|
763
|
+
if (Array.isArray(timeout)) {
|
|
764
|
+
const [value, unit] = timeout;
|
|
765
|
+
return [value, unit];
|
|
766
|
+
}
|
|
767
|
+
return { ...timeout };
|
|
768
|
+
};
|
|
769
|
+
var cloneArray = (value) => [...value];
|
|
770
|
+
var cloneOptionalArray = (value) => {
|
|
771
|
+
if (value === void 0) {
|
|
772
|
+
return void 0;
|
|
773
|
+
}
|
|
774
|
+
return [...value];
|
|
775
|
+
};
|
|
776
|
+
var deepFreeze = (value) => {
|
|
777
|
+
if (value === null || typeof value !== "object") {
|
|
778
|
+
return value;
|
|
779
|
+
}
|
|
780
|
+
const propertyNames = Object.getOwnPropertyNames(value);
|
|
781
|
+
for (const name of propertyNames) {
|
|
782
|
+
const property = value[name];
|
|
783
|
+
if (property && typeof property === "object") {
|
|
784
|
+
deepFreeze(property);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
return Object.freeze(value);
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
exports.BuilderConfigSchema = BuilderConfigSchema;
|
|
791
|
+
exports.Config = Config;
|
|
792
|
+
exports.EnvironmentSelector = EnvironmentSelector;
|
|
793
|
+
exports.EventsSchema = EventsSchema;
|
|
794
|
+
exports.ExecutorConfigSchema = ExecutorConfigSchema;
|
|
795
|
+
exports.ModuleFormatSchema = ModuleFormatSchema;
|
|
796
|
+
exports.PartialExecutorConfigSchema = PartialExecutorConfigSchema;
|
|
797
|
+
exports.PartialRootSchema = PartialRootSchema;
|
|
798
|
+
exports.PathSchema = PathSchema;
|
|
799
|
+
exports.ReporterSchema = ReporterSchema;
|
|
800
|
+
exports.RootSchema = RootSchema;
|
|
801
|
+
exports.RunnerSchema = RunnerSchema;
|
|
802
|
+
exports.ShimSchema = ShimSchema;
|
|
803
|
+
exports.TagFilterSchema = TagFilterSchema;
|
|
804
|
+
exports.TestSchema = TestSchema;
|
|
805
|
+
exports.TimeUnitSchema = TimeUnitSchema;
|
|
806
|
+
exports.TimeoutSchema = TimeoutSchema;
|
|
807
|
+
exports.defineConfig = defineConfig;
|
|
808
|
+
//# sourceMappingURL=out.js.map
|
|
809
|
+
//# sourceMappingURL=index.cjs.map
|