@kubb/cli 5.0.0-beta.85 → 5.0.0-beta.86
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/{generate-C1bIl1nH.js → generate-BO6xVUEL.js} +2 -2
- package/dist/{generate-C1bIl1nH.js.map → generate-BO6xVUEL.js.map} +1 -1
- package/dist/{generate-Cgmty90l.cjs → generate-BW9yIfgS.cjs} +2 -2
- package/dist/{generate-Cgmty90l.cjs.map → generate-BW9yIfgS.cjs.map} +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.js +5 -5
- package/dist/{init-DqgB69HY.cjs → init-Cx4n_O5X.cjs} +2 -2
- package/dist/{init-DqgB69HY.cjs.map → init-Cx4n_O5X.cjs.map} +1 -1
- package/dist/{init-EnhDxlBB.js → init-_NdYuc6u.js} +2 -2
- package/dist/{init-EnhDxlBB.js.map → init-_NdYuc6u.js.map} +1 -1
- package/dist/{mcp-5DDTiwIA.js → mcp-BuhCkjE_.js} +2 -2
- package/dist/{mcp-5DDTiwIA.js.map → mcp-BuhCkjE_.js.map} +1 -1
- package/dist/{mcp-DYmjmXQb.cjs → mcp-DJd2cm9I.cjs} +2 -2
- package/dist/{mcp-DYmjmXQb.cjs.map → mcp-DJd2cm9I.cjs.map} +1 -1
- package/dist/{package-B57sF1X0.cjs → package-Bar6zPkT.cjs} +2 -2
- package/dist/package-Bar6zPkT.cjs.map +1 -0
- package/dist/package-D24TC3pS.js +6 -0
- package/dist/package-D24TC3pS.js.map +1 -0
- package/dist/{run-CCsw-Y-v.js → run-BxMfDivH.js} +76 -76
- package/dist/run-BxMfDivH.js.map +1 -0
- package/dist/{run-DT9pRBLX.cjs → run-lAxAF-4t.cjs} +75 -75
- package/dist/run-lAxAF-4t.cjs.map +1 -0
- package/dist/{validate-BTVjxR4L.cjs → validate-D0doE06k.cjs} +2 -2
- package/dist/{validate-BTVjxR4L.cjs.map → validate-D0doE06k.cjs.map} +1 -1
- package/dist/{validate-CZFmahWd.js → validate-DZXin3M6.js} +2 -2
- package/dist/{validate-CZFmahWd.js.map → validate-DZXin3M6.js.map} +1 -1
- package/package.json +6 -6
- package/dist/package-B57sF1X0.cjs.map +0 -1
- package/dist/package-CQbxcw7I.js +0 -6
- package/dist/package-CQbxcw7I.js.map +0 -1
- package/dist/run-CCsw-Y-v.js.map +0 -1
- package/dist/run-DT9pRBLX.cjs.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
2
|
import { a as WATCHER_IGNORED_PATHS, i as UPDATE_CHECK_TIMEOUT_MS, n as KUBB_NPM_PACKAGE_URL, o as canUseTTY, t as Telemetry } from "./Telemetry-Cuzoes9Y.js";
|
|
3
3
|
import { n as toCause, r as toError } from "./errors-Dc_d7BfX.js";
|
|
4
|
-
import { t as version } from "./package-
|
|
4
|
+
import { t as version } from "./package-D24TC3pS.js";
|
|
5
5
|
import { i as linters, n as detectTool, r as formatters } from "./tools-B23ltmWP.js";
|
|
6
6
|
import { styleText } from "node:util";
|
|
7
7
|
import process$1 from "node:process";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import path, { basename, dirname, relative, resolve } from "node:path";
|
|
10
10
|
import * as clack from "@clack/prompts";
|
|
11
|
-
import {
|
|
11
|
+
import { Diagnostics, Hookable, cliReporter, createKubb, logLevel } from "@kubb/core";
|
|
12
12
|
import { createJiti } from "jiti";
|
|
13
13
|
import { NonZeroExitError, x } from "tinyexec";
|
|
14
14
|
import { loadConfig } from "unconfig";
|
|
@@ -202,7 +202,7 @@ function createSerialRunner({ run, onError }) {
|
|
|
202
202
|
* export const myLogger = defineLogger({
|
|
203
203
|
* name: 'my-logger',
|
|
204
204
|
* install(context) {
|
|
205
|
-
* context.
|
|
205
|
+
* context.hook('kubb:info', ({ message }) => console.log('ℹ', message))
|
|
206
206
|
* },
|
|
207
207
|
* })
|
|
208
208
|
* ```
|
|
@@ -254,8 +254,8 @@ const clackLogger = defineLogger({
|
|
|
254
254
|
function getMessage(message) {
|
|
255
255
|
return formatMessage(message, logLevel$5);
|
|
256
256
|
}
|
|
257
|
-
function onStep(
|
|
258
|
-
context.
|
|
257
|
+
function onStep(hook, message) {
|
|
258
|
+
context.hook(hook, () => {
|
|
259
259
|
if (logLevel$5 <= logLevel.silent) return;
|
|
260
260
|
clack.log.step(getMessage(message));
|
|
261
261
|
});
|
|
@@ -265,7 +265,7 @@ const clackLogger = defineLogger({
|
|
|
265
265
|
state.spinner.stop(text);
|
|
266
266
|
state.isSpinning = false;
|
|
267
267
|
}
|
|
268
|
-
context.
|
|
268
|
+
context.hook("kubb:info", ({ message, info = "" }) => {
|
|
269
269
|
if (logLevel$5 <= logLevel.silent) return;
|
|
270
270
|
const text = getMessage([
|
|
271
271
|
styleText("blue", "ℹ"),
|
|
@@ -278,7 +278,7 @@ const clackLogger = defineLogger({
|
|
|
278
278
|
}
|
|
279
279
|
clack.log.info(text);
|
|
280
280
|
});
|
|
281
|
-
context.
|
|
281
|
+
context.hook("kubb:success", ({ message, info = "" }) => {
|
|
282
282
|
if (logLevel$5 <= logLevel.silent) return;
|
|
283
283
|
const text = getMessage([
|
|
284
284
|
styleText("blue", "✓"),
|
|
@@ -291,7 +291,7 @@ const clackLogger = defineLogger({
|
|
|
291
291
|
}
|
|
292
292
|
clack.log.success(text);
|
|
293
293
|
});
|
|
294
|
-
context.
|
|
294
|
+
context.hook("kubb:warn", ({ message, info }) => {
|
|
295
295
|
if (logLevel$5 < logLevel.warn) return;
|
|
296
296
|
const text = getMessage([
|
|
297
297
|
styleText("yellow", "⚠"),
|
|
@@ -300,7 +300,7 @@ const clackLogger = defineLogger({
|
|
|
300
300
|
].filter(Boolean).join(" "));
|
|
301
301
|
clack.log.warn(text);
|
|
302
302
|
});
|
|
303
|
-
context.
|
|
303
|
+
context.hook("kubb:error", ({ error }) => {
|
|
304
304
|
const text = [styleText("red", "✗"), error.message].join(" ");
|
|
305
305
|
if (state.isSpinning) {
|
|
306
306
|
stopSpinner(getMessage(text));
|
|
@@ -316,7 +316,7 @@ const clackLogger = defineLogger({
|
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
});
|
|
319
|
-
context.
|
|
319
|
+
context.hook("kubb:diagnostic", ({ diagnostic }) => {
|
|
320
320
|
if (logLevel$5 <= logLevel.silent && diagnostic.severity !== "error") return;
|
|
321
321
|
stopSpinner();
|
|
322
322
|
stopActiveProgress();
|
|
@@ -338,7 +338,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
338
338
|
secondarySymbol: ""
|
|
339
339
|
});
|
|
340
340
|
});
|
|
341
|
-
context.
|
|
341
|
+
context.hook("kubb:lifecycle:start", async ({ version }) => {
|
|
342
342
|
console.log(`\n${getIntro({
|
|
343
343
|
title: "The meta framework for code generation",
|
|
344
344
|
description: "Ready to start",
|
|
@@ -347,14 +347,14 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
347
347
|
})}\n`);
|
|
348
348
|
reset();
|
|
349
349
|
});
|
|
350
|
-
context.
|
|
350
|
+
context.hook("kubb:generation:start", ({ config }) => {
|
|
351
351
|
reset();
|
|
352
352
|
state.totalPlugins = config.plugins?.length ?? 0;
|
|
353
353
|
if (logLevel$5 <= logLevel.silent) return;
|
|
354
354
|
const text = getMessage(["Generation started", config.name ? `for ${styleText("dim", config.name)}` : void 0].filter(Boolean).join(" "));
|
|
355
355
|
clack.intro(text);
|
|
356
356
|
});
|
|
357
|
-
context.
|
|
357
|
+
context.hook("kubb:plugin:start", ({ plugin }) => {
|
|
358
358
|
if (logLevel$5 <= logLevel.silent) return;
|
|
359
359
|
stopSpinner();
|
|
360
360
|
state.runningPlugins.add(plugin.name);
|
|
@@ -372,7 +372,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
372
372
|
progressBar.advance(state.completedPlugins + state.failedPlugins, pluginProgressText());
|
|
373
373
|
state.activeProgress.set("plugins", { progressBar });
|
|
374
374
|
});
|
|
375
|
-
context.
|
|
375
|
+
context.hook("kubb:plugin:end", ({ plugin, success }) => {
|
|
376
376
|
stopSpinner();
|
|
377
377
|
const active = state.activeProgress.get("plugins");
|
|
378
378
|
if (!active || logLevel$5 === logLevel.silent) return;
|
|
@@ -385,7 +385,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
385
385
|
showProgressStep();
|
|
386
386
|
}
|
|
387
387
|
});
|
|
388
|
-
context.
|
|
388
|
+
context.hook("kubb:files:processing:start", ({ files }) => {
|
|
389
389
|
if (logLevel$5 <= logLevel.silent) return;
|
|
390
390
|
stopSpinner();
|
|
391
391
|
state.totalFiles = files.length;
|
|
@@ -396,11 +396,11 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
396
396
|
max: files.length,
|
|
397
397
|
size: 30
|
|
398
398
|
});
|
|
399
|
-
context.
|
|
399
|
+
context.callHook("kubb:info", { message: text });
|
|
400
400
|
progressBar.start(getMessage(text));
|
|
401
401
|
state.activeProgress.set("files", { progressBar });
|
|
402
402
|
});
|
|
403
|
-
context.
|
|
403
|
+
context.hook("kubb:files:processing:update", ({ files }) => {
|
|
404
404
|
if (logLevel$5 <= logLevel.silent) return;
|
|
405
405
|
stopSpinner();
|
|
406
406
|
const active = state.activeProgress.get("files");
|
|
@@ -409,7 +409,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
409
409
|
if (active) active.progressBar.advance(void 0, `Writing ${relative(config.root, file.path)}`);
|
|
410
410
|
}
|
|
411
411
|
});
|
|
412
|
-
context.
|
|
412
|
+
context.hook("kubb:files:processing:end", () => {
|
|
413
413
|
if (logLevel$5 <= logLevel.silent) return;
|
|
414
414
|
stopSpinner();
|
|
415
415
|
const text = getMessage("Files written successfully");
|
|
@@ -419,7 +419,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
419
419
|
state.activeProgress.delete("files");
|
|
420
420
|
showProgressStep();
|
|
421
421
|
});
|
|
422
|
-
context.
|
|
422
|
+
context.hook("kubb:generation:end", ({ config }) => {
|
|
423
423
|
stopSpinner();
|
|
424
424
|
const text = getMessage(config.name ? `Generation completed for ${styleText("dim", config.name)}` : "Generation completed");
|
|
425
425
|
clack.outro(text);
|
|
@@ -427,7 +427,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
427
427
|
onStep("kubb:format:start", "Formatting");
|
|
428
428
|
onStep("kubb:lint:start", "Linting");
|
|
429
429
|
onStep("kubb:hooks:start", "Running hooks");
|
|
430
|
-
context.
|
|
430
|
+
context.hook("kubb:hook:start", ({ id, command, args }) => {
|
|
431
431
|
if (logLevel$5 <= logLevel.silent || !id) return;
|
|
432
432
|
stopSpinner();
|
|
433
433
|
const title = getMessage(`Running ${styleText("dim", formatCommandWithArgs(command, args))}`);
|
|
@@ -437,10 +437,10 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
437
437
|
hrStart: process$1.hrtime()
|
|
438
438
|
});
|
|
439
439
|
});
|
|
440
|
-
if (logLevel$5 > logLevel.silent) context.
|
|
440
|
+
if (logLevel$5 > logLevel.silent) context.hook("kubb:hook:line", ({ id, line }) => {
|
|
441
441
|
state.activeHookLogs.get(id)?.taskLog.message(styleText("dim", line));
|
|
442
442
|
});
|
|
443
|
-
context.
|
|
443
|
+
context.hook("kubb:hook:end", ({ id, command, args, success, error, stdout, stderr }) => {
|
|
444
444
|
if (!id) return;
|
|
445
445
|
if (logLevel$5 <= logLevel.silent) {
|
|
446
446
|
if (!success) {
|
|
@@ -460,7 +460,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
460
460
|
active.taskLog.error(getMessage(`${styleText("dim", commandWithArgs)} failed${reason}`), { showLog: true });
|
|
461
461
|
}
|
|
462
462
|
});
|
|
463
|
-
context.
|
|
463
|
+
context.hook("kubb:lifecycle:end", () => {
|
|
464
464
|
reset();
|
|
465
465
|
});
|
|
466
466
|
}
|
|
@@ -478,13 +478,13 @@ const plainLogger = defineLogger({
|
|
|
478
478
|
function getMessage(message) {
|
|
479
479
|
return formatMessage(message, logLevel$4);
|
|
480
480
|
}
|
|
481
|
-
function onStep(
|
|
482
|
-
context.
|
|
481
|
+
function onStep(hook, message) {
|
|
482
|
+
context.hook(hook, () => {
|
|
483
483
|
if (logLevel$4 <= logLevel.silent) return;
|
|
484
484
|
console.log(getMessage(message));
|
|
485
485
|
});
|
|
486
486
|
}
|
|
487
|
-
context.
|
|
487
|
+
context.hook("kubb:info", ({ message, info }) => {
|
|
488
488
|
if (logLevel$4 <= logLevel.silent) return;
|
|
489
489
|
const text = getMessage([
|
|
490
490
|
"ℹ",
|
|
@@ -493,7 +493,7 @@ const plainLogger = defineLogger({
|
|
|
493
493
|
].join(" "));
|
|
494
494
|
console.log(text);
|
|
495
495
|
});
|
|
496
|
-
context.
|
|
496
|
+
context.hook("kubb:success", ({ message, info = "" }) => {
|
|
497
497
|
if (logLevel$4 <= logLevel.silent) return;
|
|
498
498
|
const text = getMessage([
|
|
499
499
|
"✓",
|
|
@@ -502,7 +502,7 @@ const plainLogger = defineLogger({
|
|
|
502
502
|
].filter(Boolean).join(" "));
|
|
503
503
|
console.log(text);
|
|
504
504
|
});
|
|
505
|
-
context.
|
|
505
|
+
context.hook("kubb:warn", ({ message, info }) => {
|
|
506
506
|
if (logLevel$4 < logLevel.warn) return;
|
|
507
507
|
const text = getMessage([
|
|
508
508
|
"⚠",
|
|
@@ -511,7 +511,7 @@ const plainLogger = defineLogger({
|
|
|
511
511
|
].filter(Boolean).join(" "));
|
|
512
512
|
console.log(text);
|
|
513
513
|
});
|
|
514
|
-
context.
|
|
514
|
+
context.hook("kubb:error", ({ error }) => {
|
|
515
515
|
const text = getMessage(["✗", error.message].join(" "));
|
|
516
516
|
console.log(text);
|
|
517
517
|
const frames = logLevel$4 >= logLevel.verbose ? formatErrorFrames(error) : null;
|
|
@@ -523,43 +523,43 @@ const plainLogger = defineLogger({
|
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
});
|
|
526
|
-
context.
|
|
526
|
+
context.hook("kubb:diagnostic", ({ diagnostic }) => {
|
|
527
527
|
if (logLevel$4 <= logLevel.silent && diagnostic.severity !== "error") return;
|
|
528
528
|
console.log(getMessage(Diagnostics.formatLines(diagnostic).join("\n")));
|
|
529
529
|
});
|
|
530
|
-
context.
|
|
530
|
+
context.hook("kubb:lifecycle:start", ({ version }) => {
|
|
531
531
|
console.log(`Kubb CLI v${version}`);
|
|
532
532
|
});
|
|
533
|
-
context.
|
|
533
|
+
context.hook("kubb:generation:start", () => {
|
|
534
534
|
const text = getMessage("Generation started");
|
|
535
535
|
console.log(text);
|
|
536
536
|
});
|
|
537
|
-
context.
|
|
537
|
+
context.hook("kubb:plugin:start", ({ plugin }) => {
|
|
538
538
|
if (logLevel$4 <= logLevel.silent) return;
|
|
539
539
|
const text = getMessage(`Generating ${plugin.name}`);
|
|
540
540
|
console.log(text);
|
|
541
541
|
});
|
|
542
|
-
context.
|
|
542
|
+
context.hook("kubb:plugin:end", ({ plugin, duration, success }) => {
|
|
543
543
|
if (logLevel$4 <= logLevel.silent) return;
|
|
544
544
|
const durationStr = formatMs(duration);
|
|
545
545
|
const text = getMessage(success ? `${plugin.name} completed in ${durationStr}` : `${plugin.name} failed in ${durationStr}`);
|
|
546
546
|
console.log(text);
|
|
547
547
|
});
|
|
548
|
-
context.
|
|
548
|
+
context.hook("kubb:files:processing:start", ({ files }) => {
|
|
549
549
|
if (logLevel$4 <= logLevel.silent) return;
|
|
550
550
|
const text = getMessage(`Writing ${files.length} files`);
|
|
551
551
|
console.log(text);
|
|
552
552
|
});
|
|
553
|
-
context.
|
|
553
|
+
context.hook("kubb:files:processing:update", ({ files }) => {
|
|
554
554
|
if (logLevel$4 <= logLevel.silent) return;
|
|
555
555
|
for (const { file, config } of files) console.log(getMessage(`Writing ${relative(config.root, file.path)}`));
|
|
556
556
|
});
|
|
557
|
-
context.
|
|
557
|
+
context.hook("kubb:files:processing:end", () => {
|
|
558
558
|
if (logLevel$4 <= logLevel.silent) return;
|
|
559
559
|
const text = getMessage("Files written successfully");
|
|
560
560
|
console.log(text);
|
|
561
561
|
});
|
|
562
|
-
context.
|
|
562
|
+
context.hook("kubb:generation:end", ({ config }) => {
|
|
563
563
|
const text = getMessage(config.name ? `Generation completed for ${config.name}` : "Generation completed");
|
|
564
564
|
console.log(text);
|
|
565
565
|
});
|
|
@@ -569,13 +569,13 @@ const plainLogger = defineLogger({
|
|
|
569
569
|
onStep("kubb:lint:end", "Lint completed");
|
|
570
570
|
onStep("kubb:hooks:start", "Hooks started");
|
|
571
571
|
onStep("kubb:hooks:end", "Hooks completed");
|
|
572
|
-
context.
|
|
572
|
+
context.hook("kubb:hook:start", ({ id, command, args }) => {
|
|
573
573
|
if (logLevel$4 <= logLevel.silent) return;
|
|
574
574
|
if (id) hookTimer.start(id);
|
|
575
575
|
const commandWithArgs = formatCommandWithArgs(command, args);
|
|
576
576
|
console.log(getMessage(`Hook ${commandWithArgs} started`));
|
|
577
577
|
});
|
|
578
|
-
context.
|
|
578
|
+
context.hook("kubb:hook:end", ({ id, command, args, success, error, stdout, stderr }) => {
|
|
579
579
|
if (logLevel$4 <= logLevel.silent) return;
|
|
580
580
|
const ms = id ? hookTimer.end(id) : void 0;
|
|
581
581
|
const durationStr = ms !== void 0 ? ` in ${formatMs(ms)}` : "";
|
|
@@ -695,11 +695,11 @@ function formatCommandWithArgs(command, args) {
|
|
|
695
695
|
return args?.length ? `${command} ${args.join(" ")}` : command;
|
|
696
696
|
}
|
|
697
697
|
/**
|
|
698
|
-
* Bridges a {@link Reporter} onto the run's
|
|
698
|
+
* Bridges a {@link Reporter} onto the run's hook emitter: calls `report` with each config's
|
|
699
699
|
* {@link GenerationResult} on `kubb:generation:end`. The reporter never touches the emitter.
|
|
700
700
|
*/
|
|
701
701
|
function installReporter(context, reporter, ctx) {
|
|
702
|
-
context.
|
|
702
|
+
context.hook("kubb:generation:end", async ({ config, diagnostics = [], filesCreated = 0, status = "success", hrStart = process$1.hrtime() }) => {
|
|
703
703
|
await reporter.report({
|
|
704
704
|
config,
|
|
705
705
|
diagnostics,
|
|
@@ -708,7 +708,7 @@ function installReporter(context, reporter, ctx) {
|
|
|
708
708
|
hrStart
|
|
709
709
|
}, ctx);
|
|
710
710
|
});
|
|
711
|
-
if (reporter.drain) context.
|
|
711
|
+
if (reporter.drain) context.hook("kubb:lifecycle:end", () => reporter.drain?.(ctx));
|
|
712
712
|
}
|
|
713
713
|
/**
|
|
714
714
|
* Installs the live logger (the TUI view) and the given reporters (the output). The reporters are
|
|
@@ -841,7 +841,7 @@ async function getConfigs({ configPath, input, watch, logLevel }) {
|
|
|
841
841
|
let hookSequence = 0;
|
|
842
842
|
/**
|
|
843
843
|
* Returns a process-unique id that correlates a hook's `kubb:hook:start` and `kubb:hook:end`
|
|
844
|
-
*
|
|
844
|
+
* emissions, which loggers use to key their per-hook state.
|
|
845
845
|
*/
|
|
846
846
|
function createHookId() {
|
|
847
847
|
hookSequence += 1;
|
|
@@ -890,7 +890,7 @@ async function executeHooks({ configHooks, hooks }) {
|
|
|
890
890
|
if (!cmd) continue;
|
|
891
891
|
const hookId = createHookId();
|
|
892
892
|
const commandWithArgs = [cmd, ...args].join(" ");
|
|
893
|
-
await hooks.
|
|
893
|
+
await hooks.callHook("kubb:hook:start", {
|
|
894
894
|
id: hookId,
|
|
895
895
|
command: cmd,
|
|
896
896
|
args
|
|
@@ -913,7 +913,7 @@ async function executeHooks({ configHooks, hooks }) {
|
|
|
913
913
|
*/
|
|
914
914
|
async function runHook({ id, command, args, commandWithArgs, hooks }) {
|
|
915
915
|
const emitEnd = async (result) => {
|
|
916
|
-
await hooks.
|
|
916
|
+
await hooks.callHook("kubb:hook:end", {
|
|
917
917
|
command,
|
|
918
918
|
args,
|
|
919
919
|
id,
|
|
@@ -927,12 +927,12 @@ async function runHook({ id, command, args, commandWithArgs, hooks }) {
|
|
|
927
927
|
nodeOptions: { detached: process$1.platform !== "win32" },
|
|
928
928
|
throwOnError: true
|
|
929
929
|
});
|
|
930
|
-
if (stream) for await (const line of proc) await hooks.
|
|
930
|
+
if (stream) for await (const line of proc) await hooks.callHook("kubb:hook:line", {
|
|
931
931
|
id,
|
|
932
932
|
line
|
|
933
933
|
});
|
|
934
934
|
await proc;
|
|
935
|
-
await hooks.
|
|
935
|
+
await hooks.callHook("kubb:success", { message: `${styleText("dim", commandWithArgs)} successfully executed` });
|
|
936
936
|
return emitEnd({
|
|
937
937
|
success: true,
|
|
938
938
|
error: null
|
|
@@ -1000,10 +1000,10 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
|
|
|
1000
1000
|
let resolvedTool = toolValue;
|
|
1001
1001
|
if (resolvedTool === "auto") {
|
|
1002
1002
|
const detected = await detect();
|
|
1003
|
-
if (!detected) await hooks.
|
|
1003
|
+
if (!detected) await hooks.callHook("kubb:warn", { message: noToolMessage });
|
|
1004
1004
|
else {
|
|
1005
1005
|
resolvedTool = detected;
|
|
1006
|
-
await hooks.
|
|
1006
|
+
await hooks.callHook("kubb:info", { message: `Auto-detected ${toolLabel}: ${styleText("dim", resolvedTool)}` });
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
1009
1009
|
let toolError = null;
|
|
@@ -1018,7 +1018,7 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
|
|
|
1018
1018
|
const hookId = createHookId();
|
|
1019
1019
|
const hookArgs = toolConfig.args(outputPath);
|
|
1020
1020
|
const commandWithArgs = [toolConfig.command, ...hookArgs].join(" ");
|
|
1021
|
-
await hooks.
|
|
1021
|
+
await hooks.callHook("kubb:hook:start", {
|
|
1022
1022
|
id: hookId,
|
|
1023
1023
|
command: toolConfig.command,
|
|
1024
1024
|
args: hookArgs
|
|
@@ -1030,7 +1030,7 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
|
|
|
1030
1030
|
commandWithArgs,
|
|
1031
1031
|
hooks
|
|
1032
1032
|
});
|
|
1033
|
-
if (result.success) await hooks.
|
|
1033
|
+
if (result.success) await hooks.callHook("kubb:success", { message: successMessage });
|
|
1034
1034
|
else toolError = result.error ?? new Error(toolConfig.errorMessage);
|
|
1035
1035
|
} catch (caughtError) {
|
|
1036
1036
|
toolError = toError(caughtError);
|
|
@@ -1051,18 +1051,18 @@ async function generate(options) {
|
|
|
1051
1051
|
} : options.config.input
|
|
1052
1052
|
};
|
|
1053
1053
|
const kubb = createKubb(config, { hooks });
|
|
1054
|
-
await hooks.
|
|
1055
|
-
await hooks.
|
|
1054
|
+
await hooks.callHook("kubb:generation:start", { config });
|
|
1055
|
+
await hooks.callHook("kubb:info", {
|
|
1056
1056
|
message: config.name ? `Setup generation ${styleText("bold", config.name)}` : "Setup generation",
|
|
1057
1057
|
info: inputPath
|
|
1058
1058
|
});
|
|
1059
1059
|
await kubb.setup();
|
|
1060
|
-
await hooks.
|
|
1060
|
+
await hooks.callHook("kubb:info", {
|
|
1061
1061
|
message: config.name ? `Build generation ${styleText("bold", config.name)}` : "Build generation",
|
|
1062
1062
|
info: inputPath
|
|
1063
1063
|
});
|
|
1064
1064
|
const { files, diagnostics, driver } = await kubb.safeBuild();
|
|
1065
|
-
await hooks.
|
|
1065
|
+
await hooks.callHook("kubb:info", { message: "Load summary" });
|
|
1066
1066
|
const telemetryPlugins = Array.from(driver.plugins.values(), (p) => ({
|
|
1067
1067
|
name: p.name,
|
|
1068
1068
|
options: p.options
|
|
@@ -1078,11 +1078,11 @@ async function generate(options) {
|
|
|
1078
1078
|
for (const diagnostic of diagnostics) {
|
|
1079
1079
|
if (!Diagnostics.isProblem(diagnostic)) continue;
|
|
1080
1080
|
const unknown = Diagnostics.narrow(diagnostic, Diagnostics.code.unknown);
|
|
1081
|
-
if (unknown) await hooks.
|
|
1081
|
+
if (unknown) await hooks.callHook("kubb:error", { error: unknown.cause ?? new Error(unknown.message) });
|
|
1082
1082
|
else await Diagnostics.emit(hooks, diagnostic);
|
|
1083
1083
|
}
|
|
1084
1084
|
if (Diagnostics.hasError(diagnostics)) {
|
|
1085
|
-
await hooks.
|
|
1085
|
+
await hooks.callHook("kubb:generation:end", {
|
|
1086
1086
|
config,
|
|
1087
1087
|
storage: kubb.storage,
|
|
1088
1088
|
diagnostics,
|
|
@@ -1112,8 +1112,8 @@ async function generate(options) {
|
|
|
1112
1112
|
toolLabel: "formatter",
|
|
1113
1113
|
successPrefix: "Formatting",
|
|
1114
1114
|
noToolMessage: "No formatter found (oxfmt, biome, or prettier). Skipping formatting.",
|
|
1115
|
-
onStart: () => hooks.
|
|
1116
|
-
onEnd: () => hooks.
|
|
1115
|
+
onStart: () => hooks.callHook("kubb:format:start"),
|
|
1116
|
+
onEnd: () => hooks.callHook("kubb:format:end"),
|
|
1117
1117
|
outputPath,
|
|
1118
1118
|
logLevel,
|
|
1119
1119
|
hooks
|
|
@@ -1132,8 +1132,8 @@ async function generate(options) {
|
|
|
1132
1132
|
toolLabel: "linter",
|
|
1133
1133
|
successPrefix: "Linting",
|
|
1134
1134
|
noToolMessage: "No linter found (oxlint, biome, or eslint). Skipping linting.",
|
|
1135
|
-
onStart: () => hooks.
|
|
1136
|
-
onEnd: () => hooks.
|
|
1135
|
+
onStart: () => hooks.callHook("kubb:lint:start"),
|
|
1136
|
+
onEnd: () => hooks.callHook("kubb:lint:end"),
|
|
1137
1137
|
outputPath,
|
|
1138
1138
|
logLevel,
|
|
1139
1139
|
hooks
|
|
@@ -1141,7 +1141,7 @@ async function generate(options) {
|
|
|
1141
1141
|
if (error) await reportOutputFailure(Diagnostics.code.lintFailed, "linter", error);
|
|
1142
1142
|
}
|
|
1143
1143
|
if (config.hooks) {
|
|
1144
|
-
await hooks.
|
|
1144
|
+
await hooks.callHook("kubb:hooks:start");
|
|
1145
1145
|
const hookResults = await executeHooks({
|
|
1146
1146
|
configHooks: config.hooks,
|
|
1147
1147
|
hooks
|
|
@@ -1150,15 +1150,15 @@ async function generate(options) {
|
|
|
1150
1150
|
if (result.success) continue;
|
|
1151
1151
|
await reportOutputFailure(Diagnostics.code.hookFailed, "Post-generate hook", result.error ?? /* @__PURE__ */ new Error("Post-generate hook failed"));
|
|
1152
1152
|
}
|
|
1153
|
-
await hooks.
|
|
1153
|
+
await hooks.callHook("kubb:hooks:end");
|
|
1154
1154
|
}
|
|
1155
1155
|
const finalDiagnostics = [...diagnostics, ...outputDiagnostics];
|
|
1156
1156
|
const failed = Diagnostics.hasError(outputDiagnostics);
|
|
1157
|
-
if (!failed) await hooks.
|
|
1157
|
+
if (!failed) await hooks.callHook("kubb:success", {
|
|
1158
1158
|
message: "Generation succeeded",
|
|
1159
1159
|
info: inputPath
|
|
1160
1160
|
});
|
|
1161
|
-
await hooks.
|
|
1161
|
+
await hooks.callHook("kubb:generation:end", {
|
|
1162
1162
|
config,
|
|
1163
1163
|
storage: kubb.storage,
|
|
1164
1164
|
diagnostics: finalDiagnostics,
|
|
@@ -1199,7 +1199,7 @@ async function checkForUpdate(hooks) {
|
|
|
1199
1199
|
*/
|
|
1200
1200
|
async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters }) {
|
|
1201
1201
|
const logLevel$2 = logLevel[logLevelKey] ?? logLevel.info;
|
|
1202
|
-
const hooks = new
|
|
1202
|
+
const hooks = new Hookable();
|
|
1203
1203
|
let configs;
|
|
1204
1204
|
let resolvedConfigPath;
|
|
1205
1205
|
try {
|
|
@@ -1216,7 +1216,7 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
|
|
|
1216
1216
|
logLevel: logLevel$2,
|
|
1217
1217
|
reporters: [cliReporter]
|
|
1218
1218
|
});
|
|
1219
|
-
await hooks.
|
|
1219
|
+
await hooks.callHook("kubb:error", { error: toError(error) });
|
|
1220
1220
|
process$1.exit(1);
|
|
1221
1221
|
}
|
|
1222
1222
|
const requestedNames = cliReporters?.length ? cliReporters : ["cli"];
|
|
@@ -1224,15 +1224,15 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
|
|
|
1224
1224
|
logLevel: logLevel$2,
|
|
1225
1225
|
reporters: selectReporters(configs[0]?.reporters ?? [], requestedNames)
|
|
1226
1226
|
});
|
|
1227
|
-
await hooks.
|
|
1227
|
+
await hooks.callHook("kubb:lifecycle:start", { version });
|
|
1228
1228
|
await checkForUpdate(hooks);
|
|
1229
1229
|
try {
|
|
1230
1230
|
const relativeConfigPath = path.relative(process$1.cwd(), resolvedConfigPath);
|
|
1231
|
-
await hooks.
|
|
1231
|
+
await hooks.callHook("kubb:info", {
|
|
1232
1232
|
message: "Config loaded",
|
|
1233
1233
|
info: relativeConfigPath
|
|
1234
1234
|
});
|
|
1235
|
-
await hooks.
|
|
1235
|
+
await hooks.callHook("kubb:success", {
|
|
1236
1236
|
message: "Config loaded successfully",
|
|
1237
1237
|
info: relativeConfigPath
|
|
1238
1238
|
});
|
|
@@ -1251,7 +1251,7 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
|
|
|
1251
1251
|
try {
|
|
1252
1252
|
await build(watchedPaths);
|
|
1253
1253
|
} catch (buildError) {
|
|
1254
|
-
await hooks.
|
|
1254
|
+
await hooks.callHook("kubb:error", { error: toError(buildError) });
|
|
1255
1255
|
}
|
|
1256
1256
|
await startWatcher(watchedPaths, build, {
|
|
1257
1257
|
info: (msg) => clack.log.info(msg),
|
|
@@ -1265,17 +1265,17 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
|
|
|
1265
1265
|
hooks
|
|
1266
1266
|
})) anyFailed = true;
|
|
1267
1267
|
} catch (configError) {
|
|
1268
|
-
await hooks.
|
|
1268
|
+
await hooks.callHook("kubb:error", { error: toError(configError) });
|
|
1269
1269
|
anyFailed = true;
|
|
1270
1270
|
}
|
|
1271
|
-
await hooks.
|
|
1271
|
+
await hooks.callHook("kubb:lifecycle:end");
|
|
1272
1272
|
if (anyFailed) process$1.exit(1);
|
|
1273
1273
|
} catch (error) {
|
|
1274
|
-
await hooks.
|
|
1274
|
+
await hooks.callHook("kubb:error", { error: toError(error) });
|
|
1275
1275
|
process$1.exit(1);
|
|
1276
1276
|
}
|
|
1277
1277
|
}
|
|
1278
1278
|
//#endregion
|
|
1279
1279
|
export { run };
|
|
1280
1280
|
|
|
1281
|
-
//# sourceMappingURL=run-
|
|
1281
|
+
//# sourceMappingURL=run-BxMfDivH.js.map
|