@kubb/cli 5.0.0-beta.85 → 5.0.0-beta.87

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.
Files changed (34) hide show
  1. package/dist/{generate-C1bIl1nH.js → generate-DtoC8Sf-.js} +4 -4
  2. package/dist/{generate-C1bIl1nH.js.map → generate-DtoC8Sf-.js.map} +1 -1
  3. package/dist/{generate-Cgmty90l.cjs → generate-ObONedYm.cjs} +4 -4
  4. package/dist/{generate-Cgmty90l.cjs.map → generate-ObONedYm.cjs.map} +1 -1
  5. package/dist/index.cjs +6 -5
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.js +6 -5
  8. package/dist/index.js.map +1 -1
  9. package/dist/{init-DqgB69HY.cjs → init-BOHP90zY.cjs} +2 -2
  10. package/dist/{init-DqgB69HY.cjs.map → init-BOHP90zY.cjs.map} +1 -1
  11. package/dist/{init-EnhDxlBB.js → init-BwECoOjR.js} +2 -2
  12. package/dist/{init-EnhDxlBB.js.map → init-BwECoOjR.js.map} +1 -1
  13. package/dist/{mcp-5DDTiwIA.js → mcp-BoTFkZtH.js} +2 -2
  14. package/dist/{mcp-5DDTiwIA.js.map → mcp-BoTFkZtH.js.map} +1 -1
  15. package/dist/{mcp-DYmjmXQb.cjs → mcp-C0Mb-6vq.cjs} +2 -2
  16. package/dist/{mcp-DYmjmXQb.cjs.map → mcp-C0Mb-6vq.cjs.map} +1 -1
  17. package/dist/{package-B57sF1X0.cjs → package-BEeHRnqi.cjs} +2 -2
  18. package/dist/package-BEeHRnqi.cjs.map +1 -0
  19. package/dist/package-DMkl0ZXC.js +6 -0
  20. package/dist/package-DMkl0ZXC.js.map +1 -0
  21. package/dist/{run-CCsw-Y-v.js → run-B7KazRni.js} +76 -76
  22. package/dist/run-B7KazRni.js.map +1 -0
  23. package/dist/{run-DT9pRBLX.cjs → run-v1VbCRBI.cjs} +75 -75
  24. package/dist/run-v1VbCRBI.cjs.map +1 -0
  25. package/dist/{validate-CZFmahWd.js → validate-B57gAhne.js} +2 -2
  26. package/dist/{validate-CZFmahWd.js.map → validate-B57gAhne.js.map} +1 -1
  27. package/dist/{validate-BTVjxR4L.cjs → validate-CZRrk4fM.cjs} +2 -2
  28. package/dist/{validate-BTVjxR4L.cjs.map → validate-CZRrk4fM.cjs.map} +1 -1
  29. package/package.json +5 -5
  30. package/dist/package-B57sF1X0.cjs.map +0 -1
  31. package/dist/package-CQbxcw7I.js +0 -6
  32. package/dist/package-CQbxcw7I.js.map +0 -1
  33. package/dist/run-CCsw-Y-v.js.map +0 -1
  34. package/dist/run-DT9pRBLX.cjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-Bx3C2hgW.cjs");
2
2
  const require_Telemetry = require("./Telemetry-CwQYBgsg.cjs");
3
3
  const require_errors = require("./errors-gxFK0vrp.cjs");
4
- const require_package = require("./package-B57sF1X0.cjs");
4
+ const require_package = require("./package-BEeHRnqi.cjs");
5
5
  const require_tools = require("./tools-CeIABV0T.cjs");
6
6
  let node_util = require("node:util");
7
7
  require("node:crypto");
@@ -206,7 +206,7 @@ function createSerialRunner({ run, onError }) {
206
206
  * export const myLogger = defineLogger({
207
207
  * name: 'my-logger',
208
208
  * install(context) {
209
- * context.on('kubb:info', ({ message }) => console.log('ℹ', message))
209
+ * context.hook('kubb:info', ({ message }) => console.log('ℹ', message))
210
210
  * },
211
211
  * })
212
212
  * ```
@@ -258,8 +258,8 @@ const clackLogger = defineLogger({
258
258
  function getMessage(message) {
259
259
  return formatMessage(message, logLevel);
260
260
  }
261
- function onStep(event, message) {
262
- context.on(event, () => {
261
+ function onStep(hook, message) {
262
+ context.hook(hook, () => {
263
263
  if (logLevel <= _kubb_core.logLevel.silent) return;
264
264
  _clack_prompts.log.step(getMessage(message));
265
265
  });
@@ -269,7 +269,7 @@ const clackLogger = defineLogger({
269
269
  state.spinner.stop(text);
270
270
  state.isSpinning = false;
271
271
  }
272
- context.on("kubb:info", ({ message, info = "" }) => {
272
+ context.hook("kubb:info", ({ message, info = "" }) => {
273
273
  if (logLevel <= _kubb_core.logLevel.silent) return;
274
274
  const text = getMessage([
275
275
  (0, node_util.styleText)("blue", "ℹ"),
@@ -282,7 +282,7 @@ const clackLogger = defineLogger({
282
282
  }
283
283
  _clack_prompts.log.info(text);
284
284
  });
285
- context.on("kubb:success", ({ message, info = "" }) => {
285
+ context.hook("kubb:success", ({ message, info = "" }) => {
286
286
  if (logLevel <= _kubb_core.logLevel.silent) return;
287
287
  const text = getMessage([
288
288
  (0, node_util.styleText)("blue", "✓"),
@@ -295,7 +295,7 @@ const clackLogger = defineLogger({
295
295
  }
296
296
  _clack_prompts.log.success(text);
297
297
  });
298
- context.on("kubb:warn", ({ message, info }) => {
298
+ context.hook("kubb:warn", ({ message, info }) => {
299
299
  if (logLevel < _kubb_core.logLevel.warn) return;
300
300
  const text = getMessage([
301
301
  (0, node_util.styleText)("yellow", "⚠"),
@@ -304,7 +304,7 @@ const clackLogger = defineLogger({
304
304
  ].filter(Boolean).join(" "));
305
305
  _clack_prompts.log.warn(text);
306
306
  });
307
- context.on("kubb:error", ({ error }) => {
307
+ context.hook("kubb:error", ({ error }) => {
308
308
  const text = [(0, node_util.styleText)("red", "✗"), error.message].join(" ");
309
309
  if (state.isSpinning) {
310
310
  stopSpinner(getMessage(text));
@@ -320,7 +320,7 @@ const clackLogger = defineLogger({
320
320
  }
321
321
  }
322
322
  });
323
- context.on("kubb:diagnostic", ({ diagnostic }) => {
323
+ context.hook("kubb:diagnostic", ({ diagnostic }) => {
324
324
  if (logLevel <= _kubb_core.logLevel.silent && diagnostic.severity !== "error") return;
325
325
  stopSpinner();
326
326
  stopActiveProgress();
@@ -342,7 +342,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
342
342
  secondarySymbol: ""
343
343
  });
344
344
  });
345
- context.on("kubb:lifecycle:start", async ({ version }) => {
345
+ context.hook("kubb:lifecycle:start", async ({ version }) => {
346
346
  console.log(`\n${getIntro({
347
347
  title: "The meta framework for code generation",
348
348
  description: "Ready to start",
@@ -351,14 +351,14 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
351
351
  })}\n`);
352
352
  reset();
353
353
  });
354
- context.on("kubb:generation:start", ({ config }) => {
354
+ context.hook("kubb:generation:start", ({ config }) => {
355
355
  reset();
356
356
  state.totalPlugins = config.plugins?.length ?? 0;
357
357
  if (logLevel <= _kubb_core.logLevel.silent) return;
358
358
  const text = getMessage(["Generation started", config.name ? `for ${(0, node_util.styleText)("dim", config.name)}` : void 0].filter(Boolean).join(" "));
359
359
  _clack_prompts.intro(text);
360
360
  });
361
- context.on("kubb:plugin:start", ({ plugin }) => {
361
+ context.hook("kubb:plugin:start", ({ plugin }) => {
362
362
  if (logLevel <= _kubb_core.logLevel.silent) return;
363
363
  stopSpinner();
364
364
  state.runningPlugins.add(plugin.name);
@@ -376,7 +376,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
376
376
  progressBar.advance(state.completedPlugins + state.failedPlugins, pluginProgressText());
377
377
  state.activeProgress.set("plugins", { progressBar });
378
378
  });
379
- context.on("kubb:plugin:end", ({ plugin, success }) => {
379
+ context.hook("kubb:plugin:end", ({ plugin, success }) => {
380
380
  stopSpinner();
381
381
  const active = state.activeProgress.get("plugins");
382
382
  if (!active || logLevel === _kubb_core.logLevel.silent) return;
@@ -389,7 +389,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
389
389
  showProgressStep();
390
390
  }
391
391
  });
392
- context.on("kubb:files:processing:start", ({ files }) => {
392
+ context.hook("kubb:files:processing:start", ({ files }) => {
393
393
  if (logLevel <= _kubb_core.logLevel.silent) return;
394
394
  stopSpinner();
395
395
  state.totalFiles = files.length;
@@ -400,11 +400,11 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
400
400
  max: files.length,
401
401
  size: 30
402
402
  });
403
- context.emit("kubb:info", { message: text });
403
+ context.callHook("kubb:info", { message: text });
404
404
  progressBar.start(getMessage(text));
405
405
  state.activeProgress.set("files", { progressBar });
406
406
  });
407
- context.on("kubb:files:processing:update", ({ files }) => {
407
+ context.hook("kubb:files:processing:update", ({ files }) => {
408
408
  if (logLevel <= _kubb_core.logLevel.silent) return;
409
409
  stopSpinner();
410
410
  const active = state.activeProgress.get("files");
@@ -413,7 +413,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
413
413
  if (active) active.progressBar.advance(void 0, `Writing ${(0, node_path.relative)(config.root, file.path)}`);
414
414
  }
415
415
  });
416
- context.on("kubb:files:processing:end", () => {
416
+ context.hook("kubb:files:processing:end", () => {
417
417
  if (logLevel <= _kubb_core.logLevel.silent) return;
418
418
  stopSpinner();
419
419
  const text = getMessage("Files written successfully");
@@ -423,7 +423,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
423
423
  state.activeProgress.delete("files");
424
424
  showProgressStep();
425
425
  });
426
- context.on("kubb:generation:end", ({ config }) => {
426
+ context.hook("kubb:generation:end", ({ config }) => {
427
427
  stopSpinner();
428
428
  const text = getMessage(config.name ? `Generation completed for ${(0, node_util.styleText)("dim", config.name)}` : "Generation completed");
429
429
  _clack_prompts.outro(text);
@@ -431,7 +431,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
431
431
  onStep("kubb:format:start", "Formatting");
432
432
  onStep("kubb:lint:start", "Linting");
433
433
  onStep("kubb:hooks:start", "Running hooks");
434
- context.on("kubb:hook:start", ({ id, command, args }) => {
434
+ context.hook("kubb:hook:start", ({ id, command, args }) => {
435
435
  if (logLevel <= _kubb_core.logLevel.silent || !id) return;
436
436
  stopSpinner();
437
437
  const title = getMessage(`Running ${(0, node_util.styleText)("dim", formatCommandWithArgs(command, args))}`);
@@ -441,10 +441,10 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
441
441
  hrStart: node_process.default.hrtime()
442
442
  });
443
443
  });
444
- if (logLevel > _kubb_core.logLevel.silent) context.on("kubb:hook:line", ({ id, line }) => {
444
+ if (logLevel > _kubb_core.logLevel.silent) context.hook("kubb:hook:line", ({ id, line }) => {
445
445
  state.activeHookLogs.get(id)?.taskLog.message((0, node_util.styleText)("dim", line));
446
446
  });
447
- context.on("kubb:hook:end", ({ id, command, args, success, error, stdout, stderr }) => {
447
+ context.hook("kubb:hook:end", ({ id, command, args, success, error, stdout, stderr }) => {
448
448
  if (!id) return;
449
449
  if (logLevel <= _kubb_core.logLevel.silent) {
450
450
  if (!success) {
@@ -464,7 +464,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
464
464
  active.taskLog.error(getMessage(`${(0, node_util.styleText)("dim", commandWithArgs)} failed${reason}`), { showLog: true });
465
465
  }
466
466
  });
467
- context.on("kubb:lifecycle:end", () => {
467
+ context.hook("kubb:lifecycle:end", () => {
468
468
  reset();
469
469
  });
470
470
  }
@@ -482,13 +482,13 @@ const plainLogger = defineLogger({
482
482
  function getMessage(message) {
483
483
  return formatMessage(message, logLevel);
484
484
  }
485
- function onStep(event, message) {
486
- context.on(event, () => {
485
+ function onStep(hook, message) {
486
+ context.hook(hook, () => {
487
487
  if (logLevel <= _kubb_core.logLevel.silent) return;
488
488
  console.log(getMessage(message));
489
489
  });
490
490
  }
491
- context.on("kubb:info", ({ message, info }) => {
491
+ context.hook("kubb:info", ({ message, info }) => {
492
492
  if (logLevel <= _kubb_core.logLevel.silent) return;
493
493
  const text = getMessage([
494
494
  "ℹ",
@@ -497,7 +497,7 @@ const plainLogger = defineLogger({
497
497
  ].join(" "));
498
498
  console.log(text);
499
499
  });
500
- context.on("kubb:success", ({ message, info = "" }) => {
500
+ context.hook("kubb:success", ({ message, info = "" }) => {
501
501
  if (logLevel <= _kubb_core.logLevel.silent) return;
502
502
  const text = getMessage([
503
503
  "✓",
@@ -506,7 +506,7 @@ const plainLogger = defineLogger({
506
506
  ].filter(Boolean).join(" "));
507
507
  console.log(text);
508
508
  });
509
- context.on("kubb:warn", ({ message, info }) => {
509
+ context.hook("kubb:warn", ({ message, info }) => {
510
510
  if (logLevel < _kubb_core.logLevel.warn) return;
511
511
  const text = getMessage([
512
512
  "⚠",
@@ -515,7 +515,7 @@ const plainLogger = defineLogger({
515
515
  ].filter(Boolean).join(" "));
516
516
  console.log(text);
517
517
  });
518
- context.on("kubb:error", ({ error }) => {
518
+ context.hook("kubb:error", ({ error }) => {
519
519
  const text = getMessage(["✗", error.message].join(" "));
520
520
  console.log(text);
521
521
  const frames = logLevel >= _kubb_core.logLevel.verbose ? formatErrorFrames(error) : null;
@@ -527,43 +527,43 @@ const plainLogger = defineLogger({
527
527
  }
528
528
  }
529
529
  });
530
- context.on("kubb:diagnostic", ({ diagnostic }) => {
530
+ context.hook("kubb:diagnostic", ({ diagnostic }) => {
531
531
  if (logLevel <= _kubb_core.logLevel.silent && diagnostic.severity !== "error") return;
532
532
  console.log(getMessage(_kubb_core.Diagnostics.formatLines(diagnostic).join("\n")));
533
533
  });
534
- context.on("kubb:lifecycle:start", ({ version }) => {
534
+ context.hook("kubb:lifecycle:start", ({ version }) => {
535
535
  console.log(`Kubb CLI v${version}`);
536
536
  });
537
- context.on("kubb:generation:start", () => {
537
+ context.hook("kubb:generation:start", () => {
538
538
  const text = getMessage("Generation started");
539
539
  console.log(text);
540
540
  });
541
- context.on("kubb:plugin:start", ({ plugin }) => {
541
+ context.hook("kubb:plugin:start", ({ plugin }) => {
542
542
  if (logLevel <= _kubb_core.logLevel.silent) return;
543
543
  const text = getMessage(`Generating ${plugin.name}`);
544
544
  console.log(text);
545
545
  });
546
- context.on("kubb:plugin:end", ({ plugin, duration, success }) => {
546
+ context.hook("kubb:plugin:end", ({ plugin, duration, success }) => {
547
547
  if (logLevel <= _kubb_core.logLevel.silent) return;
548
548
  const durationStr = formatMs(duration);
549
549
  const text = getMessage(success ? `${plugin.name} completed in ${durationStr}` : `${plugin.name} failed in ${durationStr}`);
550
550
  console.log(text);
551
551
  });
552
- context.on("kubb:files:processing:start", ({ files }) => {
552
+ context.hook("kubb:files:processing:start", ({ files }) => {
553
553
  if (logLevel <= _kubb_core.logLevel.silent) return;
554
554
  const text = getMessage(`Writing ${files.length} files`);
555
555
  console.log(text);
556
556
  });
557
- context.on("kubb:files:processing:update", ({ files }) => {
557
+ context.hook("kubb:files:processing:update", ({ files }) => {
558
558
  if (logLevel <= _kubb_core.logLevel.silent) return;
559
559
  for (const { file, config } of files) console.log(getMessage(`Writing ${(0, node_path.relative)(config.root, file.path)}`));
560
560
  });
561
- context.on("kubb:files:processing:end", () => {
561
+ context.hook("kubb:files:processing:end", () => {
562
562
  if (logLevel <= _kubb_core.logLevel.silent) return;
563
563
  const text = getMessage("Files written successfully");
564
564
  console.log(text);
565
565
  });
566
- context.on("kubb:generation:end", ({ config }) => {
566
+ context.hook("kubb:generation:end", ({ config }) => {
567
567
  const text = getMessage(config.name ? `Generation completed for ${config.name}` : "Generation completed");
568
568
  console.log(text);
569
569
  });
@@ -573,13 +573,13 @@ const plainLogger = defineLogger({
573
573
  onStep("kubb:lint:end", "Lint completed");
574
574
  onStep("kubb:hooks:start", "Hooks started");
575
575
  onStep("kubb:hooks:end", "Hooks completed");
576
- context.on("kubb:hook:start", ({ id, command, args }) => {
576
+ context.hook("kubb:hook:start", ({ id, command, args }) => {
577
577
  if (logLevel <= _kubb_core.logLevel.silent) return;
578
578
  if (id) hookTimer.start(id);
579
579
  const commandWithArgs = formatCommandWithArgs(command, args);
580
580
  console.log(getMessage(`Hook ${commandWithArgs} started`));
581
581
  });
582
- context.on("kubb:hook:end", ({ id, command, args, success, error, stdout, stderr }) => {
582
+ context.hook("kubb:hook:end", ({ id, command, args, success, error, stdout, stderr }) => {
583
583
  if (logLevel <= _kubb_core.logLevel.silent) return;
584
584
  const ms = id ? hookTimer.end(id) : void 0;
585
585
  const durationStr = ms !== void 0 ? ` in ${formatMs(ms)}` : "";
@@ -699,11 +699,11 @@ function formatCommandWithArgs(command, args) {
699
699
  return args?.length ? `${command} ${args.join(" ")}` : command;
700
700
  }
701
701
  /**
702
- * Bridges a {@link Reporter} onto the run's event emitter: calls `report` with each config's
702
+ * Bridges a {@link Reporter} onto the run's hook emitter: calls `report` with each config's
703
703
  * {@link GenerationResult} on `kubb:generation:end`. The reporter never touches the emitter.
704
704
  */
705
705
  function installReporter(context, reporter, ctx) {
706
- context.on("kubb:generation:end", async ({ config, diagnostics = [], filesCreated = 0, status = "success", hrStart = node_process.default.hrtime() }) => {
706
+ context.hook("kubb:generation:end", async ({ config, diagnostics = [], filesCreated = 0, status = "success", hrStart = node_process.default.hrtime() }) => {
707
707
  await reporter.report({
708
708
  config,
709
709
  diagnostics,
@@ -712,7 +712,7 @@ function installReporter(context, reporter, ctx) {
712
712
  hrStart
713
713
  }, ctx);
714
714
  });
715
- if (reporter.drain) context.on("kubb:lifecycle:end", () => reporter.drain?.(ctx));
715
+ if (reporter.drain) context.hook("kubb:lifecycle:end", () => reporter.drain?.(ctx));
716
716
  }
717
717
  /**
718
718
  * Installs the live logger (the TUI view) and the given reporters (the output). The reporters are
@@ -845,7 +845,7 @@ async function getConfigs({ configPath, input, watch, logLevel }) {
845
845
  let hookSequence = 0;
846
846
  /**
847
847
  * Returns a process-unique id that correlates a hook's `kubb:hook:start` and `kubb:hook:end`
848
- * events, which loggers use to key their per-hook state.
848
+ * emissions, which loggers use to key their per-hook state.
849
849
  */
850
850
  function createHookId() {
851
851
  hookSequence += 1;
@@ -894,7 +894,7 @@ async function executeHooks({ configHooks, hooks }) {
894
894
  if (!cmd) continue;
895
895
  const hookId = createHookId();
896
896
  const commandWithArgs = [cmd, ...args].join(" ");
897
- await hooks.emit("kubb:hook:start", {
897
+ await hooks.callHook("kubb:hook:start", {
898
898
  id: hookId,
899
899
  command: cmd,
900
900
  args
@@ -917,7 +917,7 @@ async function executeHooks({ configHooks, hooks }) {
917
917
  */
918
918
  async function runHook({ id, command, args, commandWithArgs, hooks }) {
919
919
  const emitEnd = async (result) => {
920
- await hooks.emit("kubb:hook:end", {
920
+ await hooks.callHook("kubb:hook:end", {
921
921
  command,
922
922
  args,
923
923
  id,
@@ -931,12 +931,12 @@ async function runHook({ id, command, args, commandWithArgs, hooks }) {
931
931
  nodeOptions: { detached: node_process.default.platform !== "win32" },
932
932
  throwOnError: true
933
933
  });
934
- if (stream) for await (const line of proc) await hooks.emit("kubb:hook:line", {
934
+ if (stream) for await (const line of proc) await hooks.callHook("kubb:hook:line", {
935
935
  id,
936
936
  line
937
937
  });
938
938
  await proc;
939
- await hooks.emit("kubb:success", { message: `${(0, node_util.styleText)("dim", commandWithArgs)} successfully executed` });
939
+ await hooks.callHook("kubb:success", { message: `${(0, node_util.styleText)("dim", commandWithArgs)} successfully executed` });
940
940
  return emitEnd({
941
941
  success: true,
942
942
  error: null
@@ -1004,10 +1004,10 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1004
1004
  let resolvedTool = toolValue;
1005
1005
  if (resolvedTool === "auto") {
1006
1006
  const detected = await detect();
1007
- if (!detected) await hooks.emit("kubb:warn", { message: noToolMessage });
1007
+ if (!detected) await hooks.callHook("kubb:warn", { message: noToolMessage });
1008
1008
  else {
1009
1009
  resolvedTool = detected;
1010
- await hooks.emit("kubb:info", { message: `Auto-detected ${toolLabel}: ${(0, node_util.styleText)("dim", resolvedTool)}` });
1010
+ await hooks.callHook("kubb:info", { message: `Auto-detected ${toolLabel}: ${(0, node_util.styleText)("dim", resolvedTool)}` });
1011
1011
  }
1012
1012
  }
1013
1013
  let toolError = null;
@@ -1022,7 +1022,7 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1022
1022
  const hookId = createHookId();
1023
1023
  const hookArgs = toolConfig.args(outputPath);
1024
1024
  const commandWithArgs = [toolConfig.command, ...hookArgs].join(" ");
1025
- await hooks.emit("kubb:hook:start", {
1025
+ await hooks.callHook("kubb:hook:start", {
1026
1026
  id: hookId,
1027
1027
  command: toolConfig.command,
1028
1028
  args: hookArgs
@@ -1034,7 +1034,7 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1034
1034
  commandWithArgs,
1035
1035
  hooks
1036
1036
  });
1037
- if (result.success) await hooks.emit("kubb:success", { message: successMessage });
1037
+ if (result.success) await hooks.callHook("kubb:success", { message: successMessage });
1038
1038
  else toolError = result.error ?? new Error(toolConfig.errorMessage);
1039
1039
  } catch (caughtError) {
1040
1040
  toolError = require_errors.toError(caughtError);
@@ -1055,18 +1055,18 @@ async function generate(options) {
1055
1055
  } : options.config.input
1056
1056
  };
1057
1057
  const kubb = (0, _kubb_core.createKubb)(config, { hooks });
1058
- await hooks.emit("kubb:generation:start", { config });
1059
- await hooks.emit("kubb:info", {
1058
+ await hooks.callHook("kubb:generation:start", { config });
1059
+ await hooks.callHook("kubb:info", {
1060
1060
  message: config.name ? `Setup generation ${(0, node_util.styleText)("bold", config.name)}` : "Setup generation",
1061
1061
  info: inputPath
1062
1062
  });
1063
1063
  await kubb.setup();
1064
- await hooks.emit("kubb:info", {
1064
+ await hooks.callHook("kubb:info", {
1065
1065
  message: config.name ? `Build generation ${(0, node_util.styleText)("bold", config.name)}` : "Build generation",
1066
1066
  info: inputPath
1067
1067
  });
1068
1068
  const { files, diagnostics, driver } = await kubb.safeBuild();
1069
- await hooks.emit("kubb:info", { message: "Load summary" });
1069
+ await hooks.callHook("kubb:info", { message: "Load summary" });
1070
1070
  const telemetryPlugins = Array.from(driver.plugins.values(), (p) => ({
1071
1071
  name: p.name,
1072
1072
  options: p.options
@@ -1082,11 +1082,11 @@ async function generate(options) {
1082
1082
  for (const diagnostic of diagnostics) {
1083
1083
  if (!_kubb_core.Diagnostics.isProblem(diagnostic)) continue;
1084
1084
  const unknown = _kubb_core.Diagnostics.narrow(diagnostic, _kubb_core.Diagnostics.code.unknown);
1085
- if (unknown) await hooks.emit("kubb:error", { error: unknown.cause ?? new Error(unknown.message) });
1085
+ if (unknown) await hooks.callHook("kubb:error", { error: unknown.cause ?? new Error(unknown.message) });
1086
1086
  else await _kubb_core.Diagnostics.emit(hooks, diagnostic);
1087
1087
  }
1088
1088
  if (_kubb_core.Diagnostics.hasError(diagnostics)) {
1089
- await hooks.emit("kubb:generation:end", {
1089
+ await hooks.callHook("kubb:generation:end", {
1090
1090
  config,
1091
1091
  storage: kubb.storage,
1092
1092
  diagnostics,
@@ -1116,8 +1116,8 @@ async function generate(options) {
1116
1116
  toolLabel: "formatter",
1117
1117
  successPrefix: "Formatting",
1118
1118
  noToolMessage: "No formatter found (oxfmt, biome, or prettier). Skipping formatting.",
1119
- onStart: () => hooks.emit("kubb:format:start"),
1120
- onEnd: () => hooks.emit("kubb:format:end"),
1119
+ onStart: () => hooks.callHook("kubb:format:start"),
1120
+ onEnd: () => hooks.callHook("kubb:format:end"),
1121
1121
  outputPath,
1122
1122
  logLevel,
1123
1123
  hooks
@@ -1136,8 +1136,8 @@ async function generate(options) {
1136
1136
  toolLabel: "linter",
1137
1137
  successPrefix: "Linting",
1138
1138
  noToolMessage: "No linter found (oxlint, biome, or eslint). Skipping linting.",
1139
- onStart: () => hooks.emit("kubb:lint:start"),
1140
- onEnd: () => hooks.emit("kubb:lint:end"),
1139
+ onStart: () => hooks.callHook("kubb:lint:start"),
1140
+ onEnd: () => hooks.callHook("kubb:lint:end"),
1141
1141
  outputPath,
1142
1142
  logLevel,
1143
1143
  hooks
@@ -1145,7 +1145,7 @@ async function generate(options) {
1145
1145
  if (error) await reportOutputFailure(_kubb_core.Diagnostics.code.lintFailed, "linter", error);
1146
1146
  }
1147
1147
  if (config.hooks) {
1148
- await hooks.emit("kubb:hooks:start");
1148
+ await hooks.callHook("kubb:hooks:start");
1149
1149
  const hookResults = await executeHooks({
1150
1150
  configHooks: config.hooks,
1151
1151
  hooks
@@ -1154,15 +1154,15 @@ async function generate(options) {
1154
1154
  if (result.success) continue;
1155
1155
  await reportOutputFailure(_kubb_core.Diagnostics.code.hookFailed, "Post-generate hook", result.error ?? /* @__PURE__ */ new Error("Post-generate hook failed"));
1156
1156
  }
1157
- await hooks.emit("kubb:hooks:end");
1157
+ await hooks.callHook("kubb:hooks:end");
1158
1158
  }
1159
1159
  const finalDiagnostics = [...diagnostics, ...outputDiagnostics];
1160
1160
  const failed = _kubb_core.Diagnostics.hasError(outputDiagnostics);
1161
- if (!failed) await hooks.emit("kubb:success", {
1161
+ if (!failed) await hooks.callHook("kubb:success", {
1162
1162
  message: "Generation succeeded",
1163
1163
  info: inputPath
1164
1164
  });
1165
- await hooks.emit("kubb:generation:end", {
1165
+ await hooks.callHook("kubb:generation:end", {
1166
1166
  config,
1167
1167
  storage: kubb.storage,
1168
1168
  diagnostics: finalDiagnostics,
@@ -1203,7 +1203,7 @@ async function checkForUpdate(hooks) {
1203
1203
  */
1204
1204
  async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters }) {
1205
1205
  const logLevel = _kubb_core.logLevel[logLevelKey] ?? _kubb_core.logLevel.info;
1206
- const hooks = new _kubb_core.AsyncEventEmitter();
1206
+ const hooks = new _kubb_core.Hookable();
1207
1207
  let configs;
1208
1208
  let resolvedConfigPath;
1209
1209
  try {
@@ -1220,7 +1220,7 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
1220
1220
  logLevel,
1221
1221
  reporters: [_kubb_core.cliReporter]
1222
1222
  });
1223
- await hooks.emit("kubb:error", { error: require_errors.toError(error) });
1223
+ await hooks.callHook("kubb:error", { error: require_errors.toError(error) });
1224
1224
  node_process.default.exit(1);
1225
1225
  }
1226
1226
  const requestedNames = cliReporters?.length ? cliReporters : ["cli"];
@@ -1228,15 +1228,15 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
1228
1228
  logLevel,
1229
1229
  reporters: selectReporters(configs[0]?.reporters ?? [], requestedNames)
1230
1230
  });
1231
- await hooks.emit("kubb:lifecycle:start", { version: require_package.version });
1231
+ await hooks.callHook("kubb:lifecycle:start", { version: require_package.version });
1232
1232
  await checkForUpdate(hooks);
1233
1233
  try {
1234
1234
  const relativeConfigPath = node_path.default.relative(node_process.default.cwd(), resolvedConfigPath);
1235
- await hooks.emit("kubb:info", {
1235
+ await hooks.callHook("kubb:info", {
1236
1236
  message: "Config loaded",
1237
1237
  info: relativeConfigPath
1238
1238
  });
1239
- await hooks.emit("kubb:success", {
1239
+ await hooks.callHook("kubb:success", {
1240
1240
  message: "Config loaded successfully",
1241
1241
  info: relativeConfigPath
1242
1242
  });
@@ -1255,7 +1255,7 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
1255
1255
  try {
1256
1256
  await build(watchedPaths);
1257
1257
  } catch (buildError) {
1258
- await hooks.emit("kubb:error", { error: require_errors.toError(buildError) });
1258
+ await hooks.callHook("kubb:error", { error: require_errors.toError(buildError) });
1259
1259
  }
1260
1260
  await startWatcher(watchedPaths, build, {
1261
1261
  info: (msg) => _clack_prompts.log.info(msg),
@@ -1269,17 +1269,17 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
1269
1269
  hooks
1270
1270
  })) anyFailed = true;
1271
1271
  } catch (configError) {
1272
- await hooks.emit("kubb:error", { error: require_errors.toError(configError) });
1272
+ await hooks.callHook("kubb:error", { error: require_errors.toError(configError) });
1273
1273
  anyFailed = true;
1274
1274
  }
1275
- await hooks.emit("kubb:lifecycle:end");
1275
+ await hooks.callHook("kubb:lifecycle:end");
1276
1276
  if (anyFailed) node_process.default.exit(1);
1277
1277
  } catch (error) {
1278
- await hooks.emit("kubb:error", { error: require_errors.toError(error) });
1278
+ await hooks.callHook("kubb:error", { error: require_errors.toError(error) });
1279
1279
  node_process.default.exit(1);
1280
1280
  }
1281
1281
  }
1282
1282
  //#endregion
1283
1283
  exports.run = run;
1284
1284
 
1285
- //# sourceMappingURL=run-DT9pRBLX.cjs.map
1285
+ //# sourceMappingURL=run-v1VbCRBI.cjs.map