plantr 2.0.0 → 2.1.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/dist/index.d.ts +23 -20
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +761 -262
- package/dist/src/cli.d.ts +13 -3
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/create-seeder-instance.d.ts +55 -78
- package/dist/src/create-seeder-instance.d.ts.map +1 -0
- package/dist/src/define-seeder.d.ts +4 -3
- package/dist/src/define-seeder.d.ts.map +1 -0
- package/dist/src/dependency-resolver.d.ts +2 -1
- package/dist/src/dependency-resolver.d.ts.map +1 -0
- package/dist/src/formatting.d.ts +27 -13
- package/dist/src/formatting.d.ts.map +1 -0
- package/dist/src/lazy-faker.d.ts +12 -0
- package/dist/src/lazy-faker.d.ts.map +1 -0
- package/dist/src/run-seeders.d.ts +39 -22
- package/dist/src/run-seeders.d.ts.map +1 -0
- package/dist/src/seeding-state.d.ts +15 -4
- package/dist/src/seeding-state.d.ts.map +1 -0
- package/dist/src/step.d.ts +79 -22
- package/dist/src/step.d.ts.map +1 -0
- package/dist/src/types.d.ts +117 -34
- package/dist/src/types.d.ts.map +1 -0
- package/dist/state.d.ts +2 -1
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +10 -2
- package/index.ts +56 -23
- package/package.json +2 -1
- package/readme.md +89 -48
- package/src/cli.ts +154 -21
- package/src/create-seeder-instance.ts +225 -110
- package/src/define-seeder.ts +14 -7
- package/src/dependency-resolver.ts +17 -28
- package/src/formatting.ts +121 -36
- package/src/lazy-faker.ts +46 -0
- package/src/run-seeders.ts +336 -115
- package/src/seeding-state.ts +27 -5
- package/src/step.ts +208 -64
- package/src/types.ts +169 -37
- package/state.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// index.ts
|
|
2
2
|
import { expect as expect2 } from "bun:test";
|
|
3
|
-
import { faker as faker2 } from "@faker-js/faker";
|
|
4
3
|
|
|
5
4
|
// src/create-seeder-instance.ts
|
|
6
5
|
import { expect } from "bun:test";
|
|
7
|
-
import {
|
|
6
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
8
7
|
|
|
9
8
|
// src/cli.ts
|
|
10
9
|
import { parseArgs } from "node:util";
|
|
@@ -12,7 +11,7 @@ import { parseArgs } from "node:util";
|
|
|
12
11
|
// src/dependency-resolver.ts
|
|
13
12
|
class CircularDependencyError extends Error {
|
|
14
13
|
constructor(cycle) {
|
|
15
|
-
super(`Circular dependency detected in seeders: ${cycle.join(" -> ")} -> ${cycle[0]}`);
|
|
14
|
+
super(`Circular dependency detected in seeders: ${cycle.join(" -> ")} -> ${cycle[0] ?? ""}`);
|
|
16
15
|
this.name = "CircularDependencyError";
|
|
17
16
|
}
|
|
18
17
|
}
|
|
@@ -44,13 +43,6 @@ function resolveDependencyOrder(seeders, only) {
|
|
|
44
43
|
throw new DuplicateSeederError(seeder.name);
|
|
45
44
|
seederMap.set(seeder.name, seeder);
|
|
46
45
|
}
|
|
47
|
-
for (const seeder of seeders) {
|
|
48
|
-
for (const dep of seeder.dependsOn) {
|
|
49
|
-
if (!seederMap.has(dep)) {
|
|
50
|
-
throw new MissingDependencyError(seeder.name, dep);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
46
|
const inDegree = new Map;
|
|
55
47
|
const dependents = new Map;
|
|
56
48
|
for (const seeder of seeders) {
|
|
@@ -58,12 +50,14 @@ function resolveDependencyOrder(seeders, only) {
|
|
|
58
50
|
dependents.set(seeder.name, []);
|
|
59
51
|
}
|
|
60
52
|
for (const seeder of seeders) {
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
const uniqueDeps = new Set(seeder.dependsOn);
|
|
54
|
+
inDegree.set(seeder.name, uniqueDeps.size);
|
|
55
|
+
for (const dep of uniqueDeps) {
|
|
63
56
|
const deps = dependents.get(dep);
|
|
64
|
-
if (deps) {
|
|
65
|
-
|
|
57
|
+
if (!deps) {
|
|
58
|
+
throw new MissingDependencyError(seeder.name, dep);
|
|
66
59
|
}
|
|
60
|
+
deps.push(seeder.name);
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
63
|
const queue = [];
|
|
@@ -73,10 +67,13 @@ function resolveDependencyOrder(seeders, only) {
|
|
|
73
67
|
}
|
|
74
68
|
}
|
|
75
69
|
const result = [];
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
let head = 0;
|
|
71
|
+
while (head < queue.length) {
|
|
72
|
+
const current = queue[head++];
|
|
78
73
|
result.push(current);
|
|
79
|
-
const deps = dependents.get(current)
|
|
74
|
+
const deps = dependents.get(current);
|
|
75
|
+
if (!deps)
|
|
76
|
+
continue;
|
|
80
77
|
for (const dependent of deps) {
|
|
81
78
|
const newDegree = (inDegree.get(dependent) ?? 0) - 1;
|
|
82
79
|
inDegree.set(dependent, newDegree);
|
|
@@ -86,7 +83,8 @@ function resolveDependencyOrder(seeders, only) {
|
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
85
|
if (result.length !== seeders.length) {
|
|
89
|
-
const
|
|
86
|
+
const resolved = new Set(result);
|
|
87
|
+
const remaining = seeders.filter((s) => !resolved.has(s.name));
|
|
90
88
|
const cycle = findCycle(remaining, seederMap);
|
|
91
89
|
throw new CircularDependencyError(cycle);
|
|
92
90
|
}
|
|
@@ -155,7 +153,16 @@ var colors = {
|
|
|
155
153
|
white: "\x1B[37m",
|
|
156
154
|
gray: "\x1B[90m"
|
|
157
155
|
};
|
|
156
|
+
function supportsColor() {
|
|
157
|
+
if (process.env.NO_COLOR !== undefined && process.env.NO_COLOR !== "")
|
|
158
|
+
return false;
|
|
159
|
+
if (process.env.FORCE_COLOR !== undefined && process.env.FORCE_COLOR !== "0")
|
|
160
|
+
return true;
|
|
161
|
+
return Boolean(process.stdout.isTTY);
|
|
162
|
+
}
|
|
158
163
|
function colorize(text, color, style) {
|
|
164
|
+
if (!supportsColor())
|
|
165
|
+
return text;
|
|
159
166
|
let result = "";
|
|
160
167
|
if (style === "bold")
|
|
161
168
|
result += colors.bold;
|
|
@@ -166,7 +173,7 @@ function colorize(text, color, style) {
|
|
|
166
173
|
}
|
|
167
174
|
function formatDuration(ms) {
|
|
168
175
|
if (ms < 1000)
|
|
169
|
-
return `${ms}ms`;
|
|
176
|
+
return `${Math.round(ms)}ms`;
|
|
170
177
|
if (ms < 60000)
|
|
171
178
|
return `${(ms / 1000).toFixed(1)}s`;
|
|
172
179
|
return `${(ms / 60000).toFixed(1)}m`;
|
|
@@ -181,7 +188,12 @@ function printResultsTable(results) {
|
|
|
181
188
|
const durationHeader = "Duration";
|
|
182
189
|
const maxNameLen = Math.max(nameHeader.length, ...results.map((r) => r.name.length));
|
|
183
190
|
const maxStatusLen = Math.max(statusHeader.length, 10);
|
|
184
|
-
const maxDurationLen = Math.max(durationHeader.length, ...results.map((r) =>
|
|
191
|
+
const maxDurationLen = Math.max(durationHeader.length, ...results.map((r) => {
|
|
192
|
+
if (r.status === "completed" || r.status === "failed") {
|
|
193
|
+
return formatDuration(r.durationMs).length;
|
|
194
|
+
}
|
|
195
|
+
return 1;
|
|
196
|
+
}));
|
|
185
197
|
const topBorder = `┌${"─".repeat(maxNameLen + 2)}┬${"─".repeat(maxStatusLen + 2)}┬${"─".repeat(maxDurationLen + 2)}┐`;
|
|
186
198
|
const divider = `├${"─".repeat(maxNameLen + 2)}┼${"─".repeat(maxStatusLen + 2)}┼${"─".repeat(maxDurationLen + 2)}┤`;
|
|
187
199
|
const bottomBorder = `└${"─".repeat(maxNameLen + 2)}┴${"─".repeat(maxStatusLen + 2)}┴${"─".repeat(maxDurationLen + 2)}┘`;
|
|
@@ -192,28 +204,27 @@ function printResultsTable(results) {
|
|
|
192
204
|
for (const result of results) {
|
|
193
205
|
let statusDisplay;
|
|
194
206
|
let statusColor;
|
|
207
|
+
let duration = "-";
|
|
195
208
|
switch (result.status) {
|
|
196
209
|
case "completed":
|
|
197
210
|
statusDisplay = "✓ Done";
|
|
198
211
|
statusColor = "green";
|
|
212
|
+
duration = formatDuration(result.durationMs);
|
|
199
213
|
break;
|
|
200
214
|
case "failed":
|
|
201
215
|
statusDisplay = "✗ Failed";
|
|
202
216
|
statusColor = "red";
|
|
217
|
+
duration = formatDuration(result.durationMs);
|
|
203
218
|
break;
|
|
204
219
|
case "skipped":
|
|
205
220
|
statusDisplay = "⊘ Skipped";
|
|
206
221
|
statusColor = "yellow";
|
|
207
222
|
break;
|
|
208
|
-
case "
|
|
209
|
-
statusDisplay = "⟳ Running";
|
|
210
|
-
statusColor = "yellow";
|
|
211
|
-
break;
|
|
212
|
-
default:
|
|
223
|
+
case "pending":
|
|
213
224
|
statusDisplay = "○ Pending";
|
|
214
225
|
statusColor = "gray";
|
|
226
|
+
break;
|
|
215
227
|
}
|
|
216
|
-
const duration = result.durationMs !== undefined ? formatDuration(result.durationMs) : "-";
|
|
217
228
|
console.log(`│ ${result.name.padEnd(maxNameLen)} │ ${colorize(statusDisplay.padEnd(maxStatusLen), statusColor)} │ ${colorize(duration.padEnd(maxDurationLen), "dim")} │`);
|
|
218
229
|
}
|
|
219
230
|
console.log(bottomBorder);
|
|
@@ -225,19 +236,16 @@ function printErrors(results) {
|
|
|
225
236
|
for (const result of failed) {
|
|
226
237
|
const where = result.failedStep ? ` in step "${result.failedStep}"` : "";
|
|
227
238
|
console.log(colorize(`❌ Seeder "${result.name}" failed${where}:`, "red"));
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
for (const line of details.split(`
|
|
239
|
+
const details = Bun.inspect(result.error, { colors: supportsColor() });
|
|
240
|
+
for (const line of details.split(`
|
|
231
241
|
`))
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (cached.length > 0) {
|
|
236
|
-
console.log(colorize(` ${cached.length} earlier step(s) came from the cache: ${cached.join(", ")}. If they are stale, run this seeder fresh (CLI: --only ${result.name} --fresh).`, "yellow"));
|
|
242
|
+
console.log(` ${line}`);
|
|
243
|
+
if (result.cachedSteps.length > 0) {
|
|
244
|
+
console.log(colorize(` ${result.cachedSteps.length} earlier step(s) came from the cache: ${result.cachedSteps.join(", ")}. If they are stale, run this seeder fresh (CLI: --only ${result.name} --fresh).`, "yellow"));
|
|
237
245
|
}
|
|
238
246
|
if (process.env.GITHUB_ACTIONS === "true") {
|
|
239
247
|
const title = `Seeder ${result.name} failed${where}`.replace(/[:,]/g, " ");
|
|
240
|
-
console.log(`::error title=${escapeAnnotation(title)}::${escapeAnnotation(result.error
|
|
248
|
+
console.log(`::error title=${escapeAnnotation(title)}::${escapeAnnotation(result.error.message || "failed")}`);
|
|
241
249
|
}
|
|
242
250
|
console.log("");
|
|
243
251
|
}
|
|
@@ -260,10 +268,25 @@ function printSeederComplete(durationMs, success) {
|
|
|
260
268
|
}
|
|
261
269
|
console.log("");
|
|
262
270
|
}
|
|
263
|
-
function
|
|
271
|
+
function printConcurrentComplete(seederName, durationMs, success) {
|
|
272
|
+
const tag = colorize(`[${seederName}]`, "cyan", "bold");
|
|
273
|
+
if (success) {
|
|
274
|
+
console.log(` ${tag} ${colorize(`✓ Completed in ${formatDuration(durationMs)}`, "green")}`);
|
|
275
|
+
} else {
|
|
276
|
+
console.log(` ${tag} ${colorize(`✗ Failed after ${formatDuration(durationMs)}`, "red")}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function printConcurrentSkipped(seederName, failedDeps) {
|
|
280
|
+
const tag = colorize(`[${seederName}]`, "cyan", "bold");
|
|
281
|
+
console.log(` ${tag} ${colorize(`⊘ Skipped (depends on failed: ${failedDeps.join(", ")})`, "yellow")}`);
|
|
282
|
+
}
|
|
283
|
+
function printStartBanner(options) {
|
|
284
|
+
const name = options?.name ?? "Seeders";
|
|
285
|
+
const countText = options?.count !== undefined ? ` ${colorize(`(${options.count} ${options.count === 1 ? "seeder" : "seeders"}${options.concurrency && options.concurrency > 1 ? `, concurrency: ${options.concurrency === Number.POSITIVE_INFINITY ? "∞" : options.concurrency}` : ""})`, "dim")}` : "";
|
|
286
|
+
const target = options?.target;
|
|
264
287
|
const targetText = target ? ` ${colorize(`→ ${target.label}`, "dim")}${target.local ? "" : ` ${colorize("(remote, allowed)", "yellow")}`}` : "";
|
|
265
288
|
console.log(`
|
|
266
|
-
${colorize(
|
|
289
|
+
${colorize(`\uD83C\uDF31 Running ${name}`, "cyan", "bold")}${countText}${targetText}
|
|
267
290
|
`);
|
|
268
291
|
}
|
|
269
292
|
function printSeederSkipped(failedDeps) {
|
|
@@ -271,11 +294,36 @@ function printSeederSkipped(failedDeps) {
|
|
|
271
294
|
console.log(colorize(` ⊘ Skipped (depends on failed: ${failedDeps.join(", ")})`, "yellow"));
|
|
272
295
|
console.log("");
|
|
273
296
|
}
|
|
274
|
-
function printSummary(results) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
297
|
+
function printSummary(results, totalDurationMs, concurrency = 1) {
|
|
298
|
+
let completed = 0;
|
|
299
|
+
let failed = 0;
|
|
300
|
+
let skipped = 0;
|
|
301
|
+
let pending = 0;
|
|
302
|
+
let cachedCount = 0;
|
|
303
|
+
let totalWorkMs = 0;
|
|
304
|
+
for (const r of results) {
|
|
305
|
+
switch (r.status) {
|
|
306
|
+
case "completed":
|
|
307
|
+
completed++;
|
|
308
|
+
cachedCount += r.cachedSteps.length;
|
|
309
|
+
totalWorkMs += r.durationMs;
|
|
310
|
+
break;
|
|
311
|
+
case "failed":
|
|
312
|
+
failed++;
|
|
313
|
+
cachedCount += r.cachedSteps.length;
|
|
314
|
+
totalWorkMs += r.durationMs;
|
|
315
|
+
break;
|
|
316
|
+
case "skipped":
|
|
317
|
+
skipped++;
|
|
318
|
+
break;
|
|
319
|
+
case "pending":
|
|
320
|
+
pending++;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
const durationSuffix = totalDurationMs !== undefined ? ` in ${formatDuration(totalDurationMs)}` : "";
|
|
325
|
+
const speedupSuffix = concurrency > 1 && totalDurationMs !== undefined && totalDurationMs > 0 && totalWorkMs > totalDurationMs * 1.1 ? ` ${colorize(`(${formatDuration(totalWorkMs)} work, ${(totalWorkMs / totalDurationMs).toFixed(1)}× faster)`, "dim")}` : "";
|
|
326
|
+
const cacheSuffix = cachedCount > 0 ? ` ${colorize(`(${cachedCount} cached ${cachedCount === 1 ? "step" : "steps"})`, "cyan")}` : "";
|
|
279
327
|
if (failed > 0 || skipped > 0) {
|
|
280
328
|
const parts = [`${completed} completed`];
|
|
281
329
|
if (failed > 0)
|
|
@@ -284,13 +332,353 @@ function printSummary(results) {
|
|
|
284
332
|
parts.push(`${skipped} skipped`);
|
|
285
333
|
if (pending > 0)
|
|
286
334
|
parts.push(`${pending} pending`);
|
|
287
|
-
console.log(colorize(`Seeding failed: ${parts.join(", ")}`, "red"));
|
|
335
|
+
console.log(colorize(`Seeding failed: ${parts.join(", ")}${durationSuffix}`, "red"));
|
|
288
336
|
} else {
|
|
289
|
-
console.log(`${colorize("✓ Seeding complete:", "green")} ${completed} seeders executed successfully
|
|
337
|
+
console.log(`${colorize("✓ Seeding complete:", "green")} ${completed} ${completed === 1 ? "seeder" : "seeders"} executed successfully${durationSuffix}${speedupSuffix}${cacheSuffix}
|
|
290
338
|
`);
|
|
291
339
|
}
|
|
292
340
|
}
|
|
293
341
|
|
|
342
|
+
// src/seeding-state.ts
|
|
343
|
+
var key = Symbol.for("plantr.seedingActive");
|
|
344
|
+
var countKey = Symbol.for("plantr.seedingCount");
|
|
345
|
+
var state = globalThis;
|
|
346
|
+
function isSeedingActive() {
|
|
347
|
+
return state[key] === true;
|
|
348
|
+
}
|
|
349
|
+
function enterSeeding() {
|
|
350
|
+
const next = (state[countKey] ?? 0) + 1;
|
|
351
|
+
state[countKey] = next;
|
|
352
|
+
state[key] = true;
|
|
353
|
+
}
|
|
354
|
+
function exitSeeding() {
|
|
355
|
+
const next = Math.max(0, (state[countKey] ?? 0) - 1);
|
|
356
|
+
state[countKey] = next;
|
|
357
|
+
state[key] = next > 0;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// src/run-seeders.ts
|
|
361
|
+
class SeedTargetError extends Error {
|
|
362
|
+
constructor(label) {
|
|
363
|
+
super(`Refusing to seed ${label}: it is not a local database. Pass allowRemote (CLI: --allow-remote) to seed it on purpose.`);
|
|
364
|
+
this.name = "SeedTargetError";
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
var isLocalHost = (hostPort) => {
|
|
368
|
+
if (hostPort.startsWith("/"))
|
|
369
|
+
return true;
|
|
370
|
+
const lower = hostPort.toLowerCase();
|
|
371
|
+
const bracketed = /^\[([^\]]*)\]/.exec(lower);
|
|
372
|
+
const host = bracketed ? bracketed[1] ?? "" : lower.replace(/:\d+$/, "");
|
|
373
|
+
return host === "::1" || host === "0.0.0.0" || host === "host.docker.internal" || host.endsWith(".localhost") || /^127\./.test(host) || !/[.:]/.test(host);
|
|
374
|
+
};
|
|
375
|
+
function describeTarget(target) {
|
|
376
|
+
if (/^file:/i.test(target))
|
|
377
|
+
return { label: target.replace(/[?#].*$/, ""), local: true };
|
|
378
|
+
const scheme = /^[a-z][\w+.-]*:\/\//i.exec(target);
|
|
379
|
+
if (!scheme)
|
|
380
|
+
return { label: "a target that is not a URL", local: false };
|
|
381
|
+
const rest = target.slice(scheme[0].length);
|
|
382
|
+
const queryStart = rest.search(/[?#]/);
|
|
383
|
+
const beforeQuery = queryStart === -1 ? rest : rest.slice(0, queryStart);
|
|
384
|
+
const query = queryStart === -1 ? "" : rest.slice(queryStart);
|
|
385
|
+
const authorityAndPath = beforeQuery.slice(beforeQuery.lastIndexOf("@") + 1);
|
|
386
|
+
const [authority = "", path = ""] = authorityAndPath.split(/(?=[/;])/, 2);
|
|
387
|
+
let hosts = authority.split(",").filter(Boolean);
|
|
388
|
+
const hostParam = /[?&;]host=([^&;#]*)/i.exec(`${query}${path.startsWith(";") ? path : ""}`)?.[1];
|
|
389
|
+
if (hostParam) {
|
|
390
|
+
try {
|
|
391
|
+
hosts = decodeURIComponent(hostParam).split(",").filter(Boolean);
|
|
392
|
+
} catch {
|
|
393
|
+
return { label: "a target with an invalid host parameter", local: false };
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
const label = `${hosts.join(",") || "local socket"}${path.startsWith("/") ? path : ""}`;
|
|
397
|
+
return { label, local: hosts.every(isLocalHost) };
|
|
398
|
+
}
|
|
399
|
+
async function runSeedersCore(seeders, config, options = {}) {
|
|
400
|
+
const {
|
|
401
|
+
printResults = true,
|
|
402
|
+
verbose = true,
|
|
403
|
+
continueOnFailure = false,
|
|
404
|
+
only,
|
|
405
|
+
fresh = false,
|
|
406
|
+
allowRemote = false,
|
|
407
|
+
concurrency = 1
|
|
408
|
+
} = options;
|
|
409
|
+
if (Number.isNaN(concurrency) || concurrency < 1 || Number.isFinite(concurrency) && !Number.isInteger(concurrency)) {
|
|
410
|
+
throw new RangeError(`Invalid concurrency (${String(concurrency)}): expected a positive integer or Infinity`);
|
|
411
|
+
}
|
|
412
|
+
const orderedNames = resolveDependencyOrder(seeders, only);
|
|
413
|
+
const seederMap = new Map;
|
|
414
|
+
for (const seeder of seeders) {
|
|
415
|
+
seederMap.set(seeder.name, seeder);
|
|
416
|
+
}
|
|
417
|
+
const freshSet = Array.isArray(fresh) ? new Set(fresh) : undefined;
|
|
418
|
+
if (freshSet) {
|
|
419
|
+
for (const name of freshSet) {
|
|
420
|
+
if (!seederMap.has(name))
|
|
421
|
+
throw new UnknownSeederError(name, [...seederMap.keys()]);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
const targetUrl = config.target?.();
|
|
425
|
+
const target = targetUrl ? describeTarget(targetUrl) : undefined;
|
|
426
|
+
if (target && !target.local && !allowRemote) {
|
|
427
|
+
throw new SeedTargetError(target.label);
|
|
428
|
+
}
|
|
429
|
+
const isFresh = (name) => fresh === true || (freshSet?.has(name) ?? false);
|
|
430
|
+
const results = orderedNames.map((name) => ({
|
|
431
|
+
name,
|
|
432
|
+
status: "pending"
|
|
433
|
+
}));
|
|
434
|
+
const resultIndex = new Map;
|
|
435
|
+
for (let i = 0;i < orderedNames.length; i++) {
|
|
436
|
+
resultIndex.set(orderedNames[i], i);
|
|
437
|
+
}
|
|
438
|
+
const outputs = {};
|
|
439
|
+
const failedSeeders = new Set;
|
|
440
|
+
const concurrent = concurrency > 1;
|
|
441
|
+
enterSeeding();
|
|
442
|
+
try {
|
|
443
|
+
if (verbose) {
|
|
444
|
+
printStartBanner({
|
|
445
|
+
name: config.bannerName,
|
|
446
|
+
count: orderedNames.length,
|
|
447
|
+
target,
|
|
448
|
+
concurrency
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
const runStartTime = performance.now();
|
|
452
|
+
if (config.onBeforeAll) {
|
|
453
|
+
await config.onBeforeAll();
|
|
454
|
+
}
|
|
455
|
+
let ctx;
|
|
456
|
+
try {
|
|
457
|
+
if (config.preloadCache) {
|
|
458
|
+
await config.preloadCache();
|
|
459
|
+
}
|
|
460
|
+
ctx = await config.context();
|
|
461
|
+
const activeCtx = ctx;
|
|
462
|
+
const executeSeeder = async (name) => {
|
|
463
|
+
const idx = resultIndex.get(name);
|
|
464
|
+
const seeder = seederMap.get(name);
|
|
465
|
+
if (idx === undefined || !seeder)
|
|
466
|
+
return true;
|
|
467
|
+
const scopeHandle = config.createSeederScope ? config.createSeederScope({ name, fresh: isFresh(name), concurrent }) : {
|
|
468
|
+
record: config.beforeSeeder?.(name, { fresh: isFresh(name) }),
|
|
469
|
+
run: (fn) => fn()
|
|
470
|
+
};
|
|
471
|
+
const deps = {};
|
|
472
|
+
for (const depName of seeder.dependsOn) {
|
|
473
|
+
deps[depName] = outputs[depName];
|
|
474
|
+
}
|
|
475
|
+
const startTime = performance.now();
|
|
476
|
+
try {
|
|
477
|
+
const output = await scopeHandle.run(async () => seeder.run(activeCtx, deps));
|
|
478
|
+
const durationMs = Math.round(performance.now() - startTime);
|
|
479
|
+
outputs[name] = output;
|
|
480
|
+
results[idx] = {
|
|
481
|
+
name,
|
|
482
|
+
status: "completed",
|
|
483
|
+
durationMs,
|
|
484
|
+
output,
|
|
485
|
+
cachedSteps: scopeHandle.record?.cachedSteps ?? []
|
|
486
|
+
};
|
|
487
|
+
if (verbose) {
|
|
488
|
+
if (concurrent) {
|
|
489
|
+
printConcurrentComplete(name, durationMs, true);
|
|
490
|
+
} else {
|
|
491
|
+
printSeederComplete(durationMs, true);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return true;
|
|
495
|
+
} catch (error) {
|
|
496
|
+
const durationMs = Math.round(performance.now() - startTime);
|
|
497
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
498
|
+
const failedStep = scopeHandle.record?.failed && scopeHandle.record.failed.error === error ? scopeHandle.record.failed.step : undefined;
|
|
499
|
+
results[idx] = {
|
|
500
|
+
name,
|
|
501
|
+
status: "failed",
|
|
502
|
+
durationMs,
|
|
503
|
+
error: err,
|
|
504
|
+
...failedStep !== undefined ? { failedStep } : {},
|
|
505
|
+
cachedSteps: scopeHandle.record?.cachedSteps ?? []
|
|
506
|
+
};
|
|
507
|
+
failedSeeders.add(name);
|
|
508
|
+
if (verbose) {
|
|
509
|
+
if (concurrent) {
|
|
510
|
+
printConcurrentComplete(name, durationMs, false);
|
|
511
|
+
} else {
|
|
512
|
+
printSeederComplete(durationMs, false);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
if (!concurrent) {
|
|
519
|
+
for (let i = 0;i < orderedNames.length; i++) {
|
|
520
|
+
const name = orderedNames[i];
|
|
521
|
+
if (!name)
|
|
522
|
+
continue;
|
|
523
|
+
const seeder = seederMap.get(name);
|
|
524
|
+
if (!seeder)
|
|
525
|
+
continue;
|
|
526
|
+
if (continueOnFailure) {
|
|
527
|
+
const failedDeps = seeder.dependsOn.filter((dep) => failedSeeders.has(dep));
|
|
528
|
+
if (failedDeps.length > 0) {
|
|
529
|
+
results[i] = { name, status: "skipped", failedDeps };
|
|
530
|
+
failedSeeders.add(name);
|
|
531
|
+
if (verbose) {
|
|
532
|
+
printSeederHeader(name, i, orderedNames.length, seeder.description);
|
|
533
|
+
printSeederSkipped(failedDeps);
|
|
534
|
+
}
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
if (verbose) {
|
|
539
|
+
printSeederHeader(name, i, orderedNames.length, seeder.description);
|
|
540
|
+
}
|
|
541
|
+
const ok = await executeSeeder(name);
|
|
542
|
+
if (!ok && !continueOnFailure) {
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
} else if (orderedNames.length > 0) {
|
|
547
|
+
const remainingDeps = new Map;
|
|
548
|
+
const dependents = new Map;
|
|
549
|
+
for (const name of orderedNames) {
|
|
550
|
+
remainingDeps.set(name, 0);
|
|
551
|
+
dependents.set(name, []);
|
|
552
|
+
}
|
|
553
|
+
for (const name of orderedNames) {
|
|
554
|
+
const seeder = seederMap.get(name);
|
|
555
|
+
if (!seeder)
|
|
556
|
+
continue;
|
|
557
|
+
const uniqueDeps = new Set(seeder.dependsOn);
|
|
558
|
+
remainingDeps.set(name, uniqueDeps.size);
|
|
559
|
+
for (const dep of uniqueDeps) {
|
|
560
|
+
dependents.get(dep)?.push(name);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
const criticalHeight = new Map;
|
|
564
|
+
for (let i = orderedNames.length - 1;i >= 0; i--) {
|
|
565
|
+
const name = orderedNames[i];
|
|
566
|
+
let maxHeight = 0;
|
|
567
|
+
for (const dependent of dependents.get(name) ?? []) {
|
|
568
|
+
const h = (criticalHeight.get(dependent) ?? 0) + 1;
|
|
569
|
+
if (h > maxHeight)
|
|
570
|
+
maxHeight = h;
|
|
571
|
+
}
|
|
572
|
+
criticalHeight.set(name, maxHeight);
|
|
573
|
+
}
|
|
574
|
+
const ready = [];
|
|
575
|
+
for (const name of orderedNames) {
|
|
576
|
+
if (remainingDeps.get(name) === 0) {
|
|
577
|
+
ready.push(name);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
const popHighestPriority = () => {
|
|
581
|
+
let bestIdx = 0;
|
|
582
|
+
let bestHeight = criticalHeight.get(ready[0]) ?? 0;
|
|
583
|
+
let bestOrder = resultIndex.get(ready[0]) ?? 0;
|
|
584
|
+
for (let i = 1;i < ready.length; i++) {
|
|
585
|
+
const candidate = ready[i];
|
|
586
|
+
const h = criticalHeight.get(candidate) ?? 0;
|
|
587
|
+
const order = resultIndex.get(candidate) ?? 0;
|
|
588
|
+
if (h > bestHeight || h === bestHeight && order < bestOrder) {
|
|
589
|
+
bestIdx = i;
|
|
590
|
+
bestHeight = h;
|
|
591
|
+
bestOrder = order;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return ready.splice(bestIdx, 1)[0];
|
|
595
|
+
};
|
|
596
|
+
await new Promise((resolve) => {
|
|
597
|
+
let inFlight = 0;
|
|
598
|
+
let stopped = false;
|
|
599
|
+
const markSettled = (settledName) => {
|
|
600
|
+
const deps = dependents.get(settledName);
|
|
601
|
+
if (!deps)
|
|
602
|
+
return;
|
|
603
|
+
for (const dependent of deps) {
|
|
604
|
+
const next = (remainingDeps.get(dependent) ?? 1) - 1;
|
|
605
|
+
remainingDeps.set(dependent, next);
|
|
606
|
+
if (next !== 0 || stopped)
|
|
607
|
+
continue;
|
|
608
|
+
const seeder = seederMap.get(dependent);
|
|
609
|
+
if (!seeder)
|
|
610
|
+
continue;
|
|
611
|
+
const failedDeps = seeder.dependsOn.filter((d) => failedSeeders.has(d));
|
|
612
|
+
if (failedDeps.length > 0) {
|
|
613
|
+
const idx = resultIndex.get(dependent);
|
|
614
|
+
if (idx !== undefined) {
|
|
615
|
+
results[idx] = { name: dependent, status: "skipped", failedDeps };
|
|
616
|
+
}
|
|
617
|
+
failedSeeders.add(dependent);
|
|
618
|
+
if (verbose) {
|
|
619
|
+
printConcurrentSkipped(dependent, failedDeps);
|
|
620
|
+
}
|
|
621
|
+
markSettled(dependent);
|
|
622
|
+
} else {
|
|
623
|
+
ready.push(dependent);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
const schedule = () => {
|
|
628
|
+
while (!stopped && inFlight < concurrency && ready.length > 0) {
|
|
629
|
+
const name = popHighestPriority();
|
|
630
|
+
inFlight++;
|
|
631
|
+
executeSeeder(name).then((ok) => {
|
|
632
|
+
inFlight--;
|
|
633
|
+
if (!ok && !continueOnFailure) {
|
|
634
|
+
stopped = true;
|
|
635
|
+
} else {
|
|
636
|
+
markSettled(name);
|
|
637
|
+
}
|
|
638
|
+
schedule();
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
if (inFlight === 0 && (stopped || ready.length === 0)) {
|
|
642
|
+
resolve();
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
schedule();
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
if (printResults) {
|
|
649
|
+
printResultsTable(results);
|
|
650
|
+
printErrors(results);
|
|
651
|
+
printSummary(results, performance.now() - runStartTime, concurrency);
|
|
652
|
+
}
|
|
653
|
+
} finally {
|
|
654
|
+
try {
|
|
655
|
+
if (config.flushCache) {
|
|
656
|
+
await config.flushCache();
|
|
657
|
+
}
|
|
658
|
+
} finally {
|
|
659
|
+
if (config.onAfterAll) {
|
|
660
|
+
await config.onAfterAll(ctx);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
} finally {
|
|
665
|
+
exitSeeding();
|
|
666
|
+
}
|
|
667
|
+
const hasFailure = results.some((r) => r.status === "failed");
|
|
668
|
+
if (hasFailure) {
|
|
669
|
+
return {
|
|
670
|
+
success: false,
|
|
671
|
+
results,
|
|
672
|
+
outputs
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
return {
|
|
676
|
+
success: true,
|
|
677
|
+
results,
|
|
678
|
+
outputs
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
|
|
294
682
|
// src/cli.ts
|
|
295
683
|
var USAGE_ERRORS = new Set([
|
|
296
684
|
"CircularDependencyError",
|
|
@@ -299,7 +687,19 @@ var USAGE_ERRORS = new Set([
|
|
|
299
687
|
"UnknownSeederError",
|
|
300
688
|
"SeedTargetError"
|
|
301
689
|
]);
|
|
302
|
-
|
|
690
|
+
function formatSeedersList(seeders) {
|
|
691
|
+
if (seeders.length === 0)
|
|
692
|
+
return "No seeders registered.";
|
|
693
|
+
const maxLen = Math.max(...seeders.map((s) => s.name.length));
|
|
694
|
+
const lines = seeders.map((s) => {
|
|
695
|
+
const desc = s.description ? ` ${colorize(s.description, "dim")}` : "";
|
|
696
|
+
return ` ${s.name.padEnd(maxLen)}${desc}`;
|
|
697
|
+
});
|
|
698
|
+
return `${colorize(`Registered seeders (${seeders.length}):`, "white", "bold")}
|
|
699
|
+
${lines.join(`
|
|
700
|
+
`)}`;
|
|
701
|
+
}
|
|
702
|
+
var helpText = (seeders) => `
|
|
303
703
|
${colorize("Usage:", "cyan", "bold")} bun run seed [seeder...] [options]
|
|
304
704
|
|
|
305
705
|
${colorize("Arguments:", "white", "bold")}
|
|
@@ -309,54 +709,128 @@ ${colorize("Options:", "white", "bold")}
|
|
|
309
709
|
--only a,b Same as naming the seeders
|
|
310
710
|
--fresh Ignore and overwrite cached steps of the named seeders
|
|
311
711
|
(of every seeder when none are named)
|
|
712
|
+
--concurrency, -c <n> Run up to <n> independent seeders in parallel (default: 1)
|
|
312
713
|
--continue-on-failure Keep running seeders that do not depend on a failed one
|
|
313
714
|
--allow-remote Seed a database that is not local
|
|
715
|
+
--quiet, -q Suppress progress and step output (keep results table)
|
|
314
716
|
--dry-run Show execution order without running seeders
|
|
717
|
+
--list, -l List registered seeders in dependency order and exit
|
|
315
718
|
--help, -h Show this help message
|
|
316
719
|
|
|
317
|
-
${
|
|
720
|
+
${formatSeedersList(seeders)}
|
|
318
721
|
`;
|
|
319
|
-
async function runCli(seeders, runSeeders, {
|
|
722
|
+
async function runCli(seeders, runSeeders, {
|
|
723
|
+
argv,
|
|
724
|
+
target,
|
|
725
|
+
defaultConcurrency
|
|
726
|
+
}) {
|
|
320
727
|
let parsed;
|
|
321
728
|
try {
|
|
322
729
|
parsed = parse(argv);
|
|
323
730
|
} catch (error) {
|
|
324
731
|
console.error(colorize(error instanceof Error ? error.message : String(error), "red"));
|
|
325
|
-
console.log(helpText(seeders
|
|
732
|
+
console.log(helpText(seeders));
|
|
326
733
|
return 1;
|
|
327
734
|
}
|
|
328
735
|
const { values, positionals } = parsed;
|
|
329
736
|
if (values.help) {
|
|
330
|
-
console.log(helpText(seeders
|
|
737
|
+
console.log(helpText(seeders));
|
|
331
738
|
return 0;
|
|
332
739
|
}
|
|
740
|
+
let concurrency;
|
|
741
|
+
if (values.concurrency !== undefined) {
|
|
742
|
+
const parsedConcurrency = values.concurrency.toLowerCase() === "infinity" ? Number.POSITIVE_INFINITY : Number(values.concurrency);
|
|
743
|
+
if (Number.isNaN(parsedConcurrency) || parsedConcurrency < 1 || Number.isFinite(parsedConcurrency) && !Number.isInteger(parsedConcurrency)) {
|
|
744
|
+
console.error(colorize(`Invalid --concurrency value "${values.concurrency}": expected a positive integer`, "red"));
|
|
745
|
+
return 1;
|
|
746
|
+
}
|
|
747
|
+
concurrency = parsedConcurrency;
|
|
748
|
+
}
|
|
333
749
|
const names = [...positionals, ...(values.only ?? []).flatMap((value) => value.split(","))].map((value) => value.trim()).filter(Boolean);
|
|
334
750
|
const only = names.length > 0 ? names : undefined;
|
|
335
751
|
try {
|
|
336
|
-
|
|
752
|
+
if (values.list) {
|
|
753
|
+
const order = resolveDependencyOrder(seeders, only);
|
|
754
|
+
const seederMap = new Map(seeders.map((s) => [s.name, s]));
|
|
755
|
+
console.log(`
|
|
756
|
+
${colorize("\uD83C\uDF31 Seeders", "cyan", "bold")} ${colorize(`(${order.length})`, "dim")}
|
|
757
|
+
`);
|
|
758
|
+
const maxLen = Math.max(0, ...order.map((n) => n.length));
|
|
759
|
+
for (const seederName of order) {
|
|
760
|
+
const seeder = seederMap.get(seederName);
|
|
761
|
+
const desc = seeder?.description ? ` ${colorize(seeder.description, "dim")}` : "";
|
|
762
|
+
const deps = seeder?.dependsOn ?? [];
|
|
763
|
+
const depsStr = deps.length > 0 ? ` ${colorize(`[depends on: ${deps.join(", ")}]`, "dim")}` : "";
|
|
764
|
+
console.log(` ${seederName.padEnd(maxLen)}${desc}${depsStr}`);
|
|
765
|
+
}
|
|
766
|
+
console.log("");
|
|
767
|
+
return 0;
|
|
768
|
+
}
|
|
337
769
|
if (values["dry-run"]) {
|
|
770
|
+
const order = resolveDependencyOrder(seeders, only);
|
|
771
|
+
const seederMap = new Map(seeders.map((s) => [s.name, s]));
|
|
772
|
+
const targetUrl = target?.();
|
|
773
|
+
const targetDesc = targetUrl ? describeTarget(targetUrl) : undefined;
|
|
774
|
+
const targetText = targetDesc ? ` ${colorize(`→ ${targetDesc.label}`, "dim")}${targetDesc.local ? "" : ` ${colorize("(remote)", "yellow")}`}` : "";
|
|
775
|
+
const freshSet = values.fresh ? only ? new Set(only) : true : false;
|
|
776
|
+
const effectiveConcurrency = concurrency ?? defaultConcurrency ?? 1;
|
|
777
|
+
const concurrencyText = effectiveConcurrency > 1 ? `, concurrency: ${effectiveConcurrency === Number.POSITIVE_INFINITY ? "∞" : effectiveConcurrency}` : "";
|
|
338
778
|
console.log(`
|
|
339
|
-
${colorize("\uD83C\uDF31 Dry Run", "cyan", "bold")} ${colorize(`(${order.length} seeders)`, "dim")}
|
|
779
|
+
${colorize("\uD83C\uDF31 Dry Run", "cyan", "bold")} ${colorize(`(${order.length} ${order.length === 1 ? "seeder" : "seeders"}${concurrencyText})`, "dim")}${targetText}
|
|
340
780
|
`);
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const deps =
|
|
781
|
+
const printItem = (seederName, num, indent) => {
|
|
782
|
+
const seeder = seederMap.get(seederName);
|
|
783
|
+
const deps = seeder?.dependsOn ?? [];
|
|
344
784
|
const depsStr = deps.length > 0 ? ` ${colorize(`(depends on: ${deps.join(", ")})`, "dim")}` : "";
|
|
345
|
-
|
|
346
|
-
|
|
785
|
+
const freshStr = freshSet === true || freshSet instanceof Set && freshSet.has(seederName) ? ` ${colorize("(fresh)", "yellow")}` : "";
|
|
786
|
+
console.log(`${indent}${num}. ${seederName}${depsStr}${freshStr}`);
|
|
787
|
+
if (seeder?.description) {
|
|
788
|
+
console.log(`${indent} ${colorize(seeder.description, "dim")}`);
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
if (effectiveConcurrency > 1 && order.length > 0) {
|
|
792
|
+
const waveOf = new Map;
|
|
793
|
+
const waves = [];
|
|
794
|
+
for (const seederName of order) {
|
|
795
|
+
const deps = seederMap.get(seederName)?.dependsOn ?? [];
|
|
796
|
+
let wave = 0;
|
|
797
|
+
for (const dep of deps) {
|
|
798
|
+
wave = Math.max(wave, (waveOf.get(dep) ?? 0) + 1);
|
|
799
|
+
}
|
|
800
|
+
waveOf.set(seederName, wave);
|
|
801
|
+
let bucket = waves[wave];
|
|
802
|
+
if (!bucket) {
|
|
803
|
+
bucket = [];
|
|
804
|
+
waves[wave] = bucket;
|
|
805
|
+
}
|
|
806
|
+
bucket.push(seederName);
|
|
807
|
+
}
|
|
808
|
+
console.log(colorize(`Execution plan (${waves.length} ${waves.length === 1 ? "wave" : "waves"}):`, "white", "bold"));
|
|
809
|
+
let index = 1;
|
|
810
|
+
waves.forEach((waveSeeders, waveIdx) => {
|
|
811
|
+
const parallelTag = waveSeeders.length > 1 ? ` ${colorize("(parallel)", "cyan")}` : "";
|
|
812
|
+
console.log(` ${colorize(`Wave ${waveIdx + 1}`, "white", "bold")}${parallelTag}`);
|
|
813
|
+
for (const seederName of waveSeeders) {
|
|
814
|
+
printItem(seederName, index++, " ");
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
} else {
|
|
818
|
+
console.log(colorize("Execution order:", "white", "bold"));
|
|
819
|
+
order.forEach((seederName, i) => {
|
|
820
|
+
printItem(seederName, i + 1, " ");
|
|
821
|
+
});
|
|
822
|
+
}
|
|
347
823
|
console.log("");
|
|
348
824
|
return 0;
|
|
349
825
|
}
|
|
350
|
-
console.log(`
|
|
351
|
-
${colorize(`\uD83C\uDF31 Running ${name}`, "cyan", "bold")} ${colorize(`(${order.length} seeders)`, "dim")}
|
|
352
|
-
`);
|
|
353
826
|
const { success } = await runSeeders(seeders, {
|
|
354
827
|
printResults: true,
|
|
355
|
-
verbose:
|
|
828
|
+
verbose: !values.quiet,
|
|
356
829
|
only,
|
|
357
830
|
fresh: values.fresh ? only ?? true : false,
|
|
358
831
|
continueOnFailure: values["continue-on-failure"],
|
|
359
|
-
allowRemote: values["allow-remote"]
|
|
832
|
+
allowRemote: values["allow-remote"],
|
|
833
|
+
concurrency
|
|
360
834
|
});
|
|
361
835
|
return success ? 0 : 1;
|
|
362
836
|
} catch (error) {
|
|
@@ -372,6 +846,9 @@ function parse(argv) {
|
|
|
372
846
|
strict: true,
|
|
373
847
|
options: {
|
|
374
848
|
help: { type: "boolean", short: "h" },
|
|
849
|
+
list: { type: "boolean", short: "l" },
|
|
850
|
+
quiet: { type: "boolean", short: "q" },
|
|
851
|
+
concurrency: { type: "string", short: "c" },
|
|
375
852
|
"dry-run": { type: "boolean" },
|
|
376
853
|
only: { type: "string", multiple: true },
|
|
377
854
|
fresh: { type: "boolean" },
|
|
@@ -384,7 +861,9 @@ function parse(argv) {
|
|
|
384
861
|
// src/define-seeder.ts
|
|
385
862
|
function createDefineSeeder() {
|
|
386
863
|
return function defineSeeder(config) {
|
|
387
|
-
const dependsOnNames =
|
|
864
|
+
const dependsOnNames = [
|
|
865
|
+
...new Set((config.dependsOn ?? []).map((seeder) => seeder.name))
|
|
866
|
+
];
|
|
388
867
|
return {
|
|
389
868
|
name: config.name,
|
|
390
869
|
description: config.description,
|
|
@@ -394,263 +873,283 @@ function createDefineSeeder() {
|
|
|
394
873
|
};
|
|
395
874
|
}
|
|
396
875
|
|
|
397
|
-
// src/
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
876
|
+
// src/lazy-faker.ts
|
|
877
|
+
import { createRequire } from "node:module";
|
|
878
|
+
var loadedFaker;
|
|
879
|
+
function getDefaultFaker() {
|
|
880
|
+
if (!loadedFaker) {
|
|
881
|
+
const req = createRequire(import.meta.url);
|
|
882
|
+
const mod = req("@faker-js/faker/locale/en");
|
|
883
|
+
loadedFaker = mod.faker;
|
|
402
884
|
}
|
|
885
|
+
return loadedFaker;
|
|
403
886
|
}
|
|
404
|
-
var
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
if (hostParam)
|
|
427
|
-
hosts = decodeURIComponent(hostParam).split(",").filter(Boolean);
|
|
428
|
-
const label = `${hosts.join(",") || "local socket"}${path.startsWith("/") ? path : ""}`;
|
|
429
|
-
return { label, local: hosts.every(isLocalHost) };
|
|
430
|
-
}
|
|
431
|
-
async function runSeedersCore(seeders, config, options = {}) {
|
|
432
|
-
const {
|
|
433
|
-
printResults = true,
|
|
434
|
-
verbose = true,
|
|
435
|
-
continueOnFailure = false,
|
|
436
|
-
only,
|
|
437
|
-
fresh = false,
|
|
438
|
-
allowRemote = false
|
|
439
|
-
} = options;
|
|
440
|
-
const orderedNames = resolveDependencyOrder(seeders, only);
|
|
441
|
-
const seederMap = new Map;
|
|
442
|
-
for (const seeder of seeders) {
|
|
443
|
-
seederMap.set(seeder.name, seeder);
|
|
444
|
-
}
|
|
445
|
-
if (Array.isArray(fresh)) {
|
|
446
|
-
for (const name of fresh) {
|
|
447
|
-
if (!seederMap.has(name))
|
|
448
|
-
throw new UnknownSeederError(name, [...seederMap.keys()]);
|
|
449
|
-
}
|
|
887
|
+
var lazyFaker = new Proxy({}, {
|
|
888
|
+
get(_target, prop) {
|
|
889
|
+
const instance = getDefaultFaker();
|
|
890
|
+
const value = Reflect.get(instance, prop, instance);
|
|
891
|
+
return typeof value === "function" && prop !== "constructor" ? value.bind(instance) : value;
|
|
892
|
+
},
|
|
893
|
+
set(_target, prop, value) {
|
|
894
|
+
const instance = getDefaultFaker();
|
|
895
|
+
return Reflect.set(instance, prop, value, instance);
|
|
896
|
+
},
|
|
897
|
+
has(_target, prop) {
|
|
898
|
+
return Reflect.has(getDefaultFaker(), prop);
|
|
899
|
+
},
|
|
900
|
+
ownKeys() {
|
|
901
|
+
return Reflect.ownKeys(getDefaultFaker());
|
|
902
|
+
},
|
|
903
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
904
|
+
const desc = Reflect.getOwnPropertyDescriptor(getDefaultFaker(), prop);
|
|
905
|
+
return desc ? { ...desc, configurable: true } : undefined;
|
|
906
|
+
},
|
|
907
|
+
getPrototypeOf() {
|
|
908
|
+
return Reflect.getPrototypeOf(getDefaultFaker());
|
|
450
909
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
// src/step.ts
|
|
913
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
914
|
+
var isCacheEntry = (stored) => typeof stored === "object" && stored !== null && stored.__plantr === 1;
|
|
915
|
+
var slugify = (description) => description.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
916
|
+
function canonicalStringify(value) {
|
|
917
|
+
if (value === null || typeof value !== "object") {
|
|
918
|
+
return JSON.stringify(value);
|
|
455
919
|
}
|
|
456
|
-
if (
|
|
457
|
-
|
|
920
|
+
if (Array.isArray(value)) {
|
|
921
|
+
return `[${value.map((item) => item === undefined ? "null" : canonicalStringify(item)).join(",")}]`;
|
|
458
922
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
status: "pending"
|
|
462
|
-
}));
|
|
463
|
-
const outputs = {};
|
|
464
|
-
const failedSeeders = new Set;
|
|
465
|
-
if (config.onBeforeAll) {
|
|
466
|
-
await config.onBeforeAll();
|
|
923
|
+
if (typeof value.toJSON === "function") {
|
|
924
|
+
return canonicalStringify(value.toJSON());
|
|
467
925
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
const seeder = seederMap.get(name);
|
|
476
|
-
if (!seeder)
|
|
477
|
-
continue;
|
|
478
|
-
if (continueOnFailure) {
|
|
479
|
-
const hasFailedDep = seeder.dependsOn.some((dep) => failedSeeders.has(dep));
|
|
480
|
-
if (hasFailedDep) {
|
|
481
|
-
result.status = "skipped";
|
|
482
|
-
failedSeeders.add(name);
|
|
483
|
-
if (verbose) {
|
|
484
|
-
printSeederHeader(name, i, orderedNames.length, seeder.description);
|
|
485
|
-
printSeederSkipped(seeder.dependsOn.filter((d) => failedSeeders.has(d)));
|
|
486
|
-
}
|
|
487
|
-
continue;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
if (verbose) {
|
|
491
|
-
printSeederHeader(name, i, orderedNames.length, seeder.description);
|
|
492
|
-
}
|
|
493
|
-
result.status = "running";
|
|
494
|
-
const record = config.beforeSeeder?.(name, {
|
|
495
|
-
fresh: fresh === true || Array.isArray(fresh) && fresh.includes(name)
|
|
496
|
-
});
|
|
497
|
-
const deps = {};
|
|
498
|
-
for (const depName of seeder.dependsOn) {
|
|
499
|
-
deps[depName] = outputs[depName];
|
|
500
|
-
}
|
|
501
|
-
const startTime = Date.now();
|
|
502
|
-
try {
|
|
503
|
-
const output = await seeder.run(ctx, deps);
|
|
504
|
-
outputs[name] = output;
|
|
505
|
-
result.status = "completed";
|
|
506
|
-
result.durationMs = Date.now() - startTime;
|
|
507
|
-
result.output = output;
|
|
508
|
-
if (record)
|
|
509
|
-
result.cachedSteps = record.cachedSteps;
|
|
510
|
-
if (verbose) {
|
|
511
|
-
printSeederComplete(result.durationMs, true);
|
|
512
|
-
}
|
|
513
|
-
} catch (error) {
|
|
514
|
-
result.status = "failed";
|
|
515
|
-
result.durationMs = Date.now() - startTime;
|
|
516
|
-
result.error = error instanceof Error ? error : new Error(String(error));
|
|
517
|
-
if (record) {
|
|
518
|
-
result.cachedSteps = record.cachedSteps;
|
|
519
|
-
if (record.failed && record.failed.error === error)
|
|
520
|
-
result.failedStep = record.failed.step;
|
|
521
|
-
}
|
|
522
|
-
failedSeeders.add(name);
|
|
523
|
-
if (verbose) {
|
|
524
|
-
printSeederComplete(result.durationMs, false);
|
|
525
|
-
}
|
|
526
|
-
if (!continueOnFailure) {
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
if (printResults) {
|
|
532
|
-
printResultsTable(results);
|
|
533
|
-
printErrors(results);
|
|
534
|
-
printSummary(results);
|
|
535
|
-
}
|
|
536
|
-
} finally {
|
|
537
|
-
if (config.onAfterAll) {
|
|
538
|
-
await config.onAfterAll();
|
|
926
|
+
const obj = value;
|
|
927
|
+
const keys = Object.keys(obj).sort();
|
|
928
|
+
const parts = [];
|
|
929
|
+
for (const key of keys) {
|
|
930
|
+
const entryValue = obj[key];
|
|
931
|
+
if (entryValue !== undefined) {
|
|
932
|
+
parts.push(`${JSON.stringify(key)}:${canonicalStringify(entryValue)}`);
|
|
539
933
|
}
|
|
540
934
|
}
|
|
541
|
-
|
|
542
|
-
return { results, success: failed === 0 };
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
// src/seeding-state.ts
|
|
546
|
-
var key = Symbol.for("plantr.seedingActive");
|
|
547
|
-
var state = globalThis;
|
|
548
|
-
function isSeedingActive() {
|
|
549
|
-
return state[key] === true;
|
|
935
|
+
return `{${parts.join(",")}}`;
|
|
550
936
|
}
|
|
551
|
-
function setSeedingActive(active) {
|
|
552
|
-
state[key] = active;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
// src/step.ts
|
|
556
|
-
var isCacheEntry = (stored) => typeof stored === "object" && stored !== null && stored.__plantr === 1;
|
|
557
937
|
function createStepRunner(config) {
|
|
558
938
|
const { cache, log = true } = config ?? {};
|
|
559
|
-
|
|
560
|
-
let
|
|
561
|
-
|
|
939
|
+
const scopeStorage = new AsyncLocalStorage;
|
|
940
|
+
let fallbackScope = {
|
|
941
|
+
seederName: config?.seederName ?? "",
|
|
942
|
+
fresh: false,
|
|
943
|
+
record: { cachedSteps: [] }
|
|
944
|
+
};
|
|
562
945
|
const usedKeys = new Set;
|
|
946
|
+
const pendingWrites = new Map;
|
|
947
|
+
let preloaded;
|
|
948
|
+
let warnedNoCache = false;
|
|
563
949
|
const setSeederName = (name, options) => {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
950
|
+
const record = { cachedSteps: [] };
|
|
951
|
+
fallbackScope = {
|
|
952
|
+
seederName: name,
|
|
953
|
+
fresh: options?.fresh ?? false,
|
|
954
|
+
record
|
|
955
|
+
};
|
|
567
956
|
return record;
|
|
568
957
|
};
|
|
958
|
+
const createScope = (options) => ({
|
|
959
|
+
seederName: options.seederName,
|
|
960
|
+
fresh: options.fresh ?? false,
|
|
961
|
+
record: { cachedSteps: [] },
|
|
962
|
+
prefix: options.prefix
|
|
963
|
+
});
|
|
964
|
+
const runWithScope = (scope, fn) => scopeStorage.run(scope, fn);
|
|
965
|
+
const preload = async () => {
|
|
966
|
+
if (!cache?.getAll)
|
|
967
|
+
return;
|
|
968
|
+
const entries = await cache.getAll();
|
|
969
|
+
preloaded = entries instanceof Map ? new Map(entries) : new Map(Object.entries(entries));
|
|
970
|
+
};
|
|
971
|
+
const flush = async () => {
|
|
972
|
+
if (!cache?.setMany || pendingWrites.size === 0)
|
|
973
|
+
return;
|
|
974
|
+
const entries = [...pendingWrites.entries()].map(([key, value]) => ({
|
|
975
|
+
key,
|
|
976
|
+
value
|
|
977
|
+
}));
|
|
978
|
+
pendingWrites.clear();
|
|
979
|
+
await cache.setMany(entries);
|
|
980
|
+
};
|
|
569
981
|
const print = (line) => {
|
|
570
982
|
if (log)
|
|
571
983
|
console.log(line);
|
|
572
984
|
};
|
|
985
|
+
const formatPrefix = (scope) => scope.prefix ? ` ${colorize(`[${scope.prefix}]`, "cyan")} ` : " ";
|
|
573
986
|
const step = async (description, fn, options) => {
|
|
574
|
-
const
|
|
575
|
-
const
|
|
576
|
-
const
|
|
577
|
-
const
|
|
987
|
+
const scope = scopeStorage.getStore() ?? fallbackScope;
|
|
988
|
+
const useCache = options?.useCache === true;
|
|
989
|
+
const startTime = performance.now();
|
|
990
|
+
const prefix = formatPrefix(scope);
|
|
578
991
|
try {
|
|
579
992
|
let result;
|
|
580
993
|
let wasCached = false;
|
|
581
994
|
if (useCache && cache) {
|
|
995
|
+
const rawKey = options.key !== undefined ? options.key : slugify(description);
|
|
996
|
+
const cacheKey = scope.seederName ? `${scope.seederName}:${rawKey}` : rawKey;
|
|
582
997
|
if (usedKeys.has(cacheKey)) {
|
|
583
|
-
throw new Error(`Step "${description}" uses cache key "${cacheKey}", which another cached step in this run already used. Give each cached step a unique description.`);
|
|
998
|
+
throw new Error(`Step "${description}" uses cache key "${cacheKey}", which another cached step in this run already used. Give each cached step a unique description or explicit key.`);
|
|
584
999
|
}
|
|
585
1000
|
usedKeys.add(cacheKey);
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
const version = options?.version === undefined ? undefined : JSON.stringify(options.version);
|
|
589
|
-
const stored = fresh ? undefined : await cache.get(cacheKey);
|
|
1001
|
+
const version = options.version === undefined ? undefined : canonicalStringify(options.version);
|
|
1002
|
+
const stored = scope.fresh ? undefined : preloaded !== undefined ? preloaded.get(cacheKey) : await cache.get(cacheKey);
|
|
590
1003
|
if (isCacheEntry(stored) && stored.version === version) {
|
|
591
1004
|
result = stored.value;
|
|
592
1005
|
wasCached = true;
|
|
593
|
-
} else if (stored !== undefined && !isCacheEntry(stored) && version === undefined) {
|
|
1006
|
+
} else if (stored !== undefined && stored !== null && !isCacheEntry(stored) && version === undefined) {
|
|
594
1007
|
result = stored;
|
|
595
1008
|
wasCached = true;
|
|
596
1009
|
} else {
|
|
597
1010
|
result = await fn();
|
|
598
1011
|
const entry = version === undefined ? { __plantr: 1, value: result } : { __plantr: 1, version, value: result };
|
|
599
|
-
|
|
1012
|
+
preloaded?.set(cacheKey, entry);
|
|
1013
|
+
if (cache.setMany) {
|
|
1014
|
+
pendingWrites.set(cacheKey, entry);
|
|
1015
|
+
} else {
|
|
1016
|
+
await cache.set(cacheKey, entry);
|
|
1017
|
+
}
|
|
600
1018
|
}
|
|
601
1019
|
} else if (useCache && !cache) {
|
|
602
|
-
|
|
1020
|
+
if (!warnedNoCache) {
|
|
1021
|
+
warnedNoCache = true;
|
|
1022
|
+
print(`${prefix}${colorize("⚠ Cache not configured, running without cache", "yellow")}`);
|
|
1023
|
+
}
|
|
603
1024
|
result = await fn();
|
|
604
1025
|
} else {
|
|
605
1026
|
result = await fn();
|
|
606
1027
|
}
|
|
607
1028
|
if (wasCached)
|
|
608
|
-
record.cachedSteps.push(description);
|
|
609
|
-
const suffix = wasCached ? ` ${colorize("(cached)", "cyan")}` : ` ${colorize(formatDuration(
|
|
610
|
-
print(
|
|
1029
|
+
scope.record.cachedSteps.push(description);
|
|
1030
|
+
const suffix = wasCached ? ` ${colorize("(cached)", "cyan")}` : ` ${colorize(formatDuration(performance.now() - startTime), "dim")}`;
|
|
1031
|
+
print(`${prefix}${colorize("✓", "green")} ${description}${suffix}`);
|
|
611
1032
|
return result;
|
|
612
1033
|
} catch (error) {
|
|
613
|
-
record.failed
|
|
614
|
-
|
|
1034
|
+
if (!scope.record.failed || scope.record.failed.error !== error) {
|
|
1035
|
+
scope.record.failed = { step: description, error };
|
|
1036
|
+
}
|
|
1037
|
+
print(`${prefix}${colorize("✗", "red")} ${description}`);
|
|
615
1038
|
if (error instanceof Error) {
|
|
616
|
-
print(
|
|
1039
|
+
print(`${prefix} ${colorize(error.message, "dim")}`);
|
|
617
1040
|
}
|
|
618
1041
|
throw error;
|
|
619
1042
|
}
|
|
620
1043
|
};
|
|
621
|
-
return { step, setSeederName };
|
|
1044
|
+
return { step, setSeederName, createScope, runWithScope, preload, flush };
|
|
622
1045
|
}
|
|
623
1046
|
|
|
624
1047
|
// src/create-seeder-instance.ts
|
|
1048
|
+
function cloneFaker(baseFaker) {
|
|
1049
|
+
const Ctor = baseFaker.constructor;
|
|
1050
|
+
if (typeof Ctor === "function" && "rawDefinitions" in baseFaker && baseFaker.rawDefinitions) {
|
|
1051
|
+
return new Ctor({ locale: baseFaker.rawDefinitions });
|
|
1052
|
+
}
|
|
1053
|
+
return baseFaker;
|
|
1054
|
+
}
|
|
625
1055
|
function createSeederInstance(config) {
|
|
626
1056
|
const defineSeeder = createDefineSeeder();
|
|
627
|
-
const
|
|
628
|
-
|
|
629
|
-
|
|
1057
|
+
const customFaker = config?.faker && config.faker !== lazyFaker ? config.faker : undefined;
|
|
1058
|
+
const resolveBaseFaker = () => customFaker ?? getDefaultFaker();
|
|
1059
|
+
const fakerSeed = config?.fakerSeed;
|
|
1060
|
+
const defaultConcurrency = config?.concurrency;
|
|
1061
|
+
const runInternal = async (seeders, options, bannerName) => {
|
|
1062
|
+
const stepRunner = createStepRunner({
|
|
1063
|
+
cache: config?.cache,
|
|
630
1064
|
log: options?.verbose ?? true
|
|
631
1065
|
});
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
1066
|
+
const fakerStorage = new AsyncLocalStorage2;
|
|
1067
|
+
const resolveActiveFaker = () => {
|
|
1068
|
+
const slot = fakerStorage.getStore();
|
|
1069
|
+
if (!slot)
|
|
1070
|
+
return resolveBaseFaker();
|
|
1071
|
+
if (slot.instance)
|
|
1072
|
+
return slot.instance;
|
|
1073
|
+
const base = resolveBaseFaker();
|
|
1074
|
+
if (!slot.isolated) {
|
|
1075
|
+
slot.instance = base;
|
|
1076
|
+
return base;
|
|
1077
|
+
}
|
|
1078
|
+
const cloned = cloneFaker(base);
|
|
1079
|
+
if (fakerSeed !== undefined) {
|
|
1080
|
+
cloned.seed(fakerSeed + hashName(slot.name));
|
|
1081
|
+
}
|
|
1082
|
+
slot.instance = cloned;
|
|
1083
|
+
return cloned;
|
|
1084
|
+
};
|
|
1085
|
+
const scopedFaker = new Proxy({}, {
|
|
1086
|
+
get(_target, prop) {
|
|
1087
|
+
const active = resolveActiveFaker();
|
|
1088
|
+
const value = Reflect.get(active, prop, active);
|
|
1089
|
+
return typeof value === "function" && prop !== "constructor" ? value.bind(active) : value;
|
|
1090
|
+
},
|
|
1091
|
+
set(_target, prop, value) {
|
|
1092
|
+
const active = resolveActiveFaker();
|
|
1093
|
+
return Reflect.set(active, prop, value, active);
|
|
1094
|
+
},
|
|
1095
|
+
has(_target, prop) {
|
|
1096
|
+
return Reflect.has(resolveActiveFaker(), prop);
|
|
1097
|
+
},
|
|
1098
|
+
ownKeys() {
|
|
1099
|
+
return Reflect.ownKeys(resolveActiveFaker());
|
|
1100
|
+
},
|
|
1101
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
1102
|
+
const desc = Reflect.getOwnPropertyDescriptor(resolveActiveFaker(), prop);
|
|
1103
|
+
return desc ? { ...desc, configurable: true } : undefined;
|
|
1104
|
+
},
|
|
1105
|
+
getPrototypeOf() {
|
|
1106
|
+
return Reflect.getPrototypeOf(resolveActiveFaker());
|
|
1107
|
+
}
|
|
1108
|
+
});
|
|
1109
|
+
const mergedOptions = defaultConcurrency !== undefined && options?.concurrency === undefined ? { ...options, concurrency: defaultConcurrency } : options ?? {};
|
|
1110
|
+
return runSeedersCore(seeders, {
|
|
1111
|
+
context: async () => {
|
|
1112
|
+
const base = {
|
|
1113
|
+
faker: scopedFaker,
|
|
1114
|
+
step: stepRunner.step,
|
|
1115
|
+
expect
|
|
1116
|
+
};
|
|
1117
|
+
if (!config?.context)
|
|
1118
|
+
return base;
|
|
1119
|
+
const extra = await config.context(base);
|
|
1120
|
+
return extra === base ? base : { ...base, ...extra };
|
|
1121
|
+
},
|
|
1122
|
+
preloadCache: config?.cache?.getAll ? () => stepRunner.preload() : undefined,
|
|
1123
|
+
flushCache: config?.cache?.setMany ? () => stepRunner.flush() : undefined,
|
|
1124
|
+
createSeederScope: ({ name, fresh, concurrent }) => {
|
|
1125
|
+
const stepScope = stepRunner.createScope({
|
|
1126
|
+
seederName: name,
|
|
1127
|
+
fresh,
|
|
1128
|
+
prefix: concurrent ? name : undefined
|
|
1129
|
+
});
|
|
1130
|
+
const slot = {
|
|
1131
|
+
name,
|
|
1132
|
+
isolated: fakerSeed !== undefined || concurrent
|
|
1133
|
+
};
|
|
1134
|
+
return {
|
|
1135
|
+
record: stepScope.record,
|
|
1136
|
+
run: (fn) => stepRunner.runWithScope(stepScope, () => fakerStorage.run(slot, fn))
|
|
1137
|
+
};
|
|
1138
|
+
},
|
|
1139
|
+
bannerName,
|
|
1140
|
+
target: config?.target,
|
|
1141
|
+
onBeforeAll: config?.onBeforeAll,
|
|
1142
|
+
onAfterAll: config?.onAfterAll
|
|
1143
|
+
}, mergedOptions);
|
|
649
1144
|
};
|
|
1145
|
+
const runSeeders = (seeders, options) => runInternal(seeders, options);
|
|
650
1146
|
const runSeedersCli = async (seeders, options) => {
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
|
|
1147
|
+
const bannerName = options?.name ?? "Seeders";
|
|
1148
|
+
const code = await runCli(seeders, (s, opts) => runInternal(s, opts, bannerName), {
|
|
1149
|
+
name: bannerName,
|
|
1150
|
+
argv: options?.argv ?? process.argv.slice(2),
|
|
1151
|
+
target: config?.target,
|
|
1152
|
+
defaultConcurrency
|
|
654
1153
|
});
|
|
655
1154
|
process.exit(code);
|
|
656
1155
|
};
|
|
@@ -681,7 +1180,7 @@ export {
|
|
|
681
1180
|
createStepRunner,
|
|
682
1181
|
describeTarget,
|
|
683
1182
|
expect2 as expect,
|
|
684
|
-
|
|
1183
|
+
lazyFaker as faker,
|
|
685
1184
|
formatDuration,
|
|
686
1185
|
isSeedingActive,
|
|
687
1186
|
resolveDependencyOrder,
|