@kubb/cli 5.0.0-alpha.33 → 5.0.0-alpha.35

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 (60) hide show
  1. package/dist/{agent-BXxgXjmf.cjs → agent-BLXyRIQn.cjs} +3 -3
  2. package/dist/{agent-BXxgXjmf.cjs.map → agent-BLXyRIQn.cjs.map} +1 -1
  3. package/dist/{agent-C5na5bbz.cjs → agent-CRQdwSar.cjs} +6 -6
  4. package/dist/{agent-C5na5bbz.cjs.map → agent-CRQdwSar.cjs.map} +1 -1
  5. package/dist/{agent-DmHfzo4T.js → agent-DeM_wyAN.js} +2 -2
  6. package/dist/{agent-DmHfzo4T.js.map → agent-DeM_wyAN.js.map} +1 -1
  7. package/dist/{generate-B9GfVi-d.js → generate-CNQWSc3E.js} +2 -2
  8. package/dist/{generate-B9GfVi-d.js.map → generate-CNQWSc3E.js.map} +1 -1
  9. package/dist/{generate-DO1tyM1F.cjs → generate-CWPwtauL.cjs} +173 -154
  10. package/dist/generate-CWPwtauL.cjs.map +1 -0
  11. package/dist/{generate-Cx5laPNU.js → generate-DctgMAfY.js} +169 -150
  12. package/dist/generate-DctgMAfY.js.map +1 -0
  13. package/dist/{generate-C6VkdDNS.cjs → generate-gdilbmRQ.cjs} +2 -2
  14. package/dist/{generate-C6VkdDNS.cjs.map → generate-gdilbmRQ.cjs.map} +1 -1
  15. package/dist/index.cjs +7 -7
  16. package/dist/index.js +6 -6
  17. package/dist/{init-ogkUFxTY.js → init-BI-1RkgG.js} +3 -3
  18. package/dist/{init-ogkUFxTY.js.map → init-BI-1RkgG.js.map} +1 -1
  19. package/dist/{init-BlriFVH6.cjs → init-cAbMOLut.cjs} +6 -6
  20. package/dist/init-cAbMOLut.cjs.map +1 -0
  21. package/dist/{init-Dlr3agDn.cjs → init-hVxzq-Kh.cjs} +3 -3
  22. package/dist/{init-Dlr3agDn.cjs.map → init-hVxzq-Kh.cjs.map} +1 -1
  23. package/dist/{init-Y1TNCdzh.js → init-hcm7zvPn.js} +2 -2
  24. package/dist/init-hcm7zvPn.js.map +1 -0
  25. package/dist/{mcp-jMZ56bqT.cjs → mcp-9yURBP26.cjs} +3 -3
  26. package/dist/{mcp-jMZ56bqT.cjs.map → mcp-9yURBP26.cjs.map} +1 -1
  27. package/dist/{mcp-s3qV65Np.js → mcp-Bdtcfk55.js} +2 -2
  28. package/dist/{mcp-s3qV65Np.js.map → mcp-Bdtcfk55.js.map} +1 -1
  29. package/dist/{mcp-1Jlsqqaz.cjs → mcp-DMOLm4FN.cjs} +3 -3
  30. package/dist/{mcp-1Jlsqqaz.cjs.map → mcp-DMOLm4FN.cjs.map} +1 -1
  31. package/dist/{package-BkTfqrtl.cjs → package-B9cAxfxL.cjs} +2 -2
  32. package/dist/package-B9cAxfxL.cjs.map +1 -0
  33. package/dist/package-CYS1_pd_.js +6 -0
  34. package/dist/package-CYS1_pd_.js.map +1 -0
  35. package/dist/{telemetry-YO-uwAbf.cjs → telemetry-D_Bi2E3I.cjs} +3 -3
  36. package/dist/{telemetry-YO-uwAbf.cjs.map → telemetry-D_Bi2E3I.cjs.map} +1 -1
  37. package/dist/{validate-Ctlfg8IA.js → validate--mbofqde.js} +2 -2
  38. package/dist/{validate-Ctlfg8IA.js.map → validate--mbofqde.js.map} +1 -1
  39. package/dist/{validate-B-LfVNlS.cjs → validate-DIKeUU8K.cjs} +3 -3
  40. package/dist/{validate-B-LfVNlS.cjs.map → validate-DIKeUU8K.cjs.map} +1 -1
  41. package/dist/{validate-BuMgxIlK.cjs → validate-b-ccrtPU.cjs} +3 -3
  42. package/dist/{validate-BuMgxIlK.cjs.map → validate-b-ccrtPU.cjs.map} +1 -1
  43. package/package.json +5 -5
  44. package/src/loggers/clackLogger.ts +24 -24
  45. package/src/loggers/fileSystemLogger.ts +10 -10
  46. package/src/loggers/githubActionsLogger.ts +22 -22
  47. package/src/loggers/plainLogger.ts +21 -21
  48. package/src/runners/generate.ts +53 -65
  49. package/src/runners/init.ts +1 -1
  50. package/src/utils/executeHooks.ts +11 -11
  51. package/src/utils/getConfig.ts +10 -0
  52. package/src/utils/getCosmiConfig.ts +2 -2
  53. package/src/utils/runHook.ts +9 -9
  54. package/dist/generate-Cx5laPNU.js.map +0 -1
  55. package/dist/generate-DO1tyM1F.cjs.map +0 -1
  56. package/dist/init-BlriFVH6.cjs.map +0 -1
  57. package/dist/init-Y1TNCdzh.js.map +0 -1
  58. package/dist/package-BkTfqrtl.cjs.map +0 -1
  59. package/dist/package-DR71mSab.js +0 -6
  60. package/dist/package-DR71mSab.js.map +0 -1
@@ -2,7 +2,7 @@ import "./chunk--u3MIqq1.js";
2
2
  import { n as toCause, r as toError } from "./errors-CjPmyZHy.js";
3
3
  import { a as canUseTTY, i as executeIfOnline, o as isGitHubActions, r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-CBISr5w4.js";
4
4
  import { n as tokenize } from "./shell-DLzN4fRo.js";
5
- import { t as version } from "./package-DR71mSab.js";
5
+ import { t as version } from "./package-CYS1_pd_.js";
6
6
  import { a as WATCHER_IGNORED_PATHS, i as SUMMARY_SEPARATOR, t as KUBB_NPM_PACKAGE_URL } from "./constants-DJM9zCXm.js";
7
7
  import { styleText } from "node:util";
8
8
  import { EventEmitter } from "node:events";
@@ -12,7 +12,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
12
12
  import path, { dirname, relative, resolve } from "node:path";
13
13
  import process$1 from "node:process";
14
14
  import * as clack from "@clack/prompts";
15
- import { defineLogger, detectFormatter, detectLinter, formatters, getConfigs, isInputPath, linters, logLevel, safeBuild, setup } from "@kubb/core";
15
+ import { createKubb, defineLogger, detectFormatter, detectLinter, formatters, isInputPath, linters, logLevel } from "@kubb/core";
16
16
  import { NonZeroExitError, x } from "tinyexec";
17
17
  import { Writable } from "node:stream";
18
18
  import { cosmiconfig } from "cosmiconfig";
@@ -100,6 +100,18 @@ var AsyncEventEmitter = class {
100
100
  this.#emitter.off(eventName, handler);
101
101
  }
102
102
  /**
103
+ * Returns the number of listeners registered for `eventName`.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * emitter.on('build', handler)
108
+ * emitter.listenerCount('build') // 1
109
+ * ```
110
+ */
111
+ listenerCount(eventName) {
112
+ return this.#emitter.listenerCount(eventName);
113
+ }
114
+ /**
103
115
  * Removes all listeners from every event channel.
104
116
  *
105
117
  * @example
@@ -367,11 +379,11 @@ async function runHook({ id, command, args, commandWithArgs, context, stream = f
367
379
  });
368
380
  if (stream && sink?.onLine) for await (const line of proc) sink.onLine(line);
369
381
  const result = await proc;
370
- await context.emit("debug", {
382
+ await context.emit("kubb:debug", {
371
383
  date: /* @__PURE__ */ new Date(),
372
384
  logs: [result.stdout.trimEnd()]
373
385
  });
374
- await context.emit("hook:end", {
386
+ await context.emit("kubb:hook:end", {
375
387
  command,
376
388
  args,
377
389
  id,
@@ -380,33 +392,33 @@ async function runHook({ id, command, args, commandWithArgs, context, stream = f
380
392
  });
381
393
  } catch (err) {
382
394
  if (!(err instanceof NonZeroExitError)) {
383
- await context.emit("hook:end", {
395
+ await context.emit("kubb:hook:end", {
384
396
  command,
385
397
  args,
386
398
  id,
387
399
  success: false,
388
400
  error: toError(err)
389
401
  });
390
- await context.emit("error", toError(err));
402
+ await context.emit("kubb:error", toError(err));
391
403
  return;
392
404
  }
393
405
  const stderr = err.output?.stderr ?? "";
394
406
  const stdout = err.output?.stdout ?? "";
395
- await context.emit("debug", {
407
+ await context.emit("kubb:debug", {
396
408
  date: /* @__PURE__ */ new Date(),
397
409
  logs: [stdout, stderr].filter(Boolean)
398
410
  });
399
411
  if (stderr) sink?.onStderr?.(stderr);
400
412
  if (stdout) sink?.onStdout?.(stdout);
401
413
  const errorMessage = /* @__PURE__ */ new Error(`Hook execute failed: ${commandWithArgs}`);
402
- await context.emit("hook:end", {
414
+ await context.emit("kubb:hook:end", {
403
415
  command,
404
416
  args,
405
417
  id,
406
418
  success: false,
407
419
  error: errorMessage
408
420
  });
409
- await context.emit("error", errorMessage);
421
+ await context.emit("kubb:error", errorMessage);
410
422
  }
411
423
  }
412
424
  //#endregion
@@ -474,7 +486,7 @@ const clackLogger = defineLogger({
474
486
  state.spinner.stop(text);
475
487
  state.isSpinning = false;
476
488
  }
477
- context.on("info", (message, info = "") => {
489
+ context.on("kubb:info", (message, info = "") => {
478
490
  if (logLevel$8 <= logLevel.silent) return;
479
491
  const text = getMessage([
480
492
  styleText("blue", "ℹ"),
@@ -484,7 +496,7 @@ const clackLogger = defineLogger({
484
496
  if (state.isSpinning) state.spinner.message(text);
485
497
  else clack.log.info(text);
486
498
  });
487
- context.on("success", (message, info = "") => {
499
+ context.on("kubb:success", (message, info = "") => {
488
500
  if (logLevel$8 <= logLevel.silent) return;
489
501
  const text = getMessage([
490
502
  styleText("blue", "✓"),
@@ -494,7 +506,7 @@ const clackLogger = defineLogger({
494
506
  if (state.isSpinning) stopSpinner(text);
495
507
  else clack.log.success(text);
496
508
  });
497
- context.on("warn", (message, info) => {
509
+ context.on("kubb:warn", (message, info) => {
498
510
  if (logLevel$8 < logLevel.warn) return;
499
511
  const text = getMessage([
500
512
  styleText("yellow", "⚠"),
@@ -503,7 +515,7 @@ const clackLogger = defineLogger({
503
515
  ].filter(Boolean).join(" "));
504
516
  clack.log.warn(text);
505
517
  });
506
- context.on("error", (error) => {
518
+ context.on("kubb:error", (error) => {
507
519
  const caused = toCause(error);
508
520
  const text = [styleText("red", "✗"), error.message].join(" ");
509
521
  if (state.isSpinning) stopSpinner(getMessage(text));
@@ -518,7 +530,7 @@ const clackLogger = defineLogger({
518
530
  }
519
531
  }
520
532
  });
521
- context.on("version:new", (version, latestVersion) => {
533
+ context.on("kubb:version:new", (version, latestVersion) => {
522
534
  if (logLevel$8 <= logLevel.silent) return;
523
535
  try {
524
536
  clack.box(`\`v${version}\` → \`v${latestVersion}\`
@@ -535,7 +547,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
535
547
  console.log("Run `npm install -g @kubb/cli` to update");
536
548
  }
537
549
  });
538
- context.on("lifecycle:start", async (version) => {
550
+ context.on("kubb:lifecycle:start", async (version) => {
539
551
  console.log(`\n${getIntro({
540
552
  title: "The ultimate toolkit for working with APIs",
541
553
  description: "Ready to start",
@@ -544,24 +556,24 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
544
556
  })}\n`);
545
557
  reset();
546
558
  });
547
- context.on("config:start", () => {
559
+ context.on("kubb:config:start", () => {
548
560
  if (logLevel$8 <= logLevel.silent) return;
549
561
  const text = getMessage("Configuration started");
550
562
  clack.intro(text);
551
563
  startSpinner(getMessage("Configuration loading"));
552
564
  });
553
- context.on("config:end", (_configs) => {
565
+ context.on("kubb:config:end", (_configs) => {
554
566
  if (logLevel$8 <= logLevel.silent) return;
555
567
  const text = getMessage("Configuration completed");
556
568
  clack.outro(text);
557
569
  });
558
- context.on("generation:start", (config) => {
570
+ context.on("kubb:generation:start", (config) => {
559
571
  reset();
560
572
  state.totalPlugins = config.plugins?.length ?? 0;
561
573
  const text = getMessage(["Generation started", config.name ? `for ${styleText("dim", config.name)}` : void 0].filter(Boolean).join(" "));
562
574
  clack.intro(text);
563
575
  });
564
- context.on("plugin:start", (plugin) => {
576
+ context.on("kubb:plugin:start", (plugin) => {
565
577
  if (logLevel$8 <= logLevel.silent) return;
566
578
  stopSpinner();
567
579
  const progressBar = clack.progress({
@@ -579,7 +591,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
579
591
  interval
580
592
  });
581
593
  });
582
- context.on("plugin:end", (plugin, { duration, success }) => {
594
+ context.on("kubb:plugin:end", (plugin, { duration, success }) => {
583
595
  stopSpinner();
584
596
  const active = state.activeProgress.get(plugin.name);
585
597
  if (!active || logLevel$8 === logLevel.silent) return;
@@ -592,7 +604,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
592
604
  state.activeProgress.delete(plugin.name);
593
605
  showProgressStep();
594
606
  });
595
- context.on("files:processing:start", (files) => {
607
+ context.on("kubb:files:processing:start", (files) => {
596
608
  if (logLevel$8 <= logLevel.silent) return;
597
609
  stopSpinner();
598
610
  state.totalFiles = files.length;
@@ -603,11 +615,11 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
603
615
  max: files.length,
604
616
  size: 30
605
617
  });
606
- context.emit("info", text);
618
+ context.emit("kubb:info", text);
607
619
  progressBar.start(getMessage(text));
608
620
  state.activeProgress.set("files", { progressBar });
609
621
  });
610
- context.on("file:processing:update", ({ file, config }) => {
622
+ context.on("kubb:file:processing:update", ({ file, config }) => {
611
623
  if (logLevel$8 <= logLevel.silent) return;
612
624
  stopSpinner();
613
625
  state.processedFiles++;
@@ -616,7 +628,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
616
628
  if (!active) return;
617
629
  active.progressBar.advance(void 0, text);
618
630
  });
619
- context.on("files:processing:end", () => {
631
+ context.on("kubb:files:processing:end", () => {
620
632
  if (logLevel$8 <= logLevel.silent) return;
621
633
  stopSpinner();
622
634
  const text = getMessage("Files written successfully");
@@ -626,31 +638,31 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
626
638
  state.activeProgress.delete("files");
627
639
  showProgressStep();
628
640
  });
629
- context.on("generation:end", (config) => {
641
+ context.on("kubb:generation:end", (config) => {
630
642
  const text = getMessage(config.name ? `Generation completed for ${styleText("dim", config.name)}` : "Generation completed");
631
643
  clack.outro(text);
632
644
  });
633
- context.on("format:start", () => {
645
+ context.on("kubb:format:start", () => {
634
646
  if (logLevel$8 <= logLevel.silent) return;
635
647
  const text = getMessage("Format started");
636
648
  clack.intro(text);
637
649
  });
638
- context.on("format:end", () => {
650
+ context.on("kubb:format:end", () => {
639
651
  if (logLevel$8 <= logLevel.silent) return;
640
652
  const text = getMessage("Format completed");
641
653
  clack.outro(text);
642
654
  });
643
- context.on("lint:start", () => {
655
+ context.on("kubb:lint:start", () => {
644
656
  if (logLevel$8 <= logLevel.silent) return;
645
657
  const text = getMessage("Lint started");
646
658
  clack.intro(text);
647
659
  });
648
- context.on("lint:end", () => {
660
+ context.on("kubb:lint:end", () => {
649
661
  if (logLevel$8 <= logLevel.silent) return;
650
662
  const text = getMessage("Lint completed");
651
663
  clack.outro(text);
652
664
  });
653
- context.on("hook:start", async ({ id, command, args }) => {
665
+ context.on("kubb:hook:start", async ({ id, command, args }) => {
654
666
  const commandWithArgs = formatCommandWithArgs(command, args);
655
667
  const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} started`);
656
668
  if (!id) return;
@@ -685,12 +697,12 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
685
697
  }
686
698
  });
687
699
  });
688
- context.on("hook:end", ({ command, args }) => {
700
+ context.on("kubb:hook:end", ({ command, args }) => {
689
701
  if (logLevel$8 <= logLevel.silent) return;
690
702
  const text = getMessage(`Hook ${styleText("dim", formatCommandWithArgs(command, args))} successfully executed`);
691
703
  clack.outro(text);
692
704
  });
693
- context.on("generation:summary", (config, { pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
705
+ context.on("kubb:generation:summary", (config, { pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
694
706
  const summary = getSummary({
695
707
  failedPlugins,
696
708
  filesCreated,
@@ -716,7 +728,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
716
728
  console.log(summary.join("\n"));
717
729
  }
718
730
  });
719
- context.on("lifecycle:end", () => {
731
+ context.on("kubb:lifecycle:end", () => {
720
732
  reset();
721
733
  });
722
734
  }
@@ -760,60 +772,60 @@ const fileSystemLogger = defineLogger({
760
772
  for (const [fileName, logs] of Object.entries(files)) await write(fileName, logs.join("\n\n"));
761
773
  return Object.keys(files);
762
774
  }
763
- context.on("info", (message, info) => {
775
+ context.on("kubb:info", (message, info) => {
764
776
  state.cachedLogs.add({
765
777
  date: /* @__PURE__ */ new Date(),
766
778
  logs: [`ℹ ${message} ${info}`]
767
779
  });
768
780
  });
769
- context.on("success", (message, info) => {
781
+ context.on("kubb:success", (message, info) => {
770
782
  state.cachedLogs.add({
771
783
  date: /* @__PURE__ */ new Date(),
772
784
  logs: [`✓ ${message} ${info}`]
773
785
  });
774
786
  });
775
- context.on("warn", (message, info) => {
787
+ context.on("kubb:warn", (message, info) => {
776
788
  state.cachedLogs.add({
777
789
  date: /* @__PURE__ */ new Date(),
778
790
  logs: [`⚠ ${message} ${info}`]
779
791
  });
780
792
  });
781
- context.on("error", (error) => {
793
+ context.on("kubb:error", (error) => {
782
794
  state.cachedLogs.add({
783
795
  date: /* @__PURE__ */ new Date(),
784
796
  logs: [`✗ ${error.message}`, error.stack || "unknown stack"]
785
797
  });
786
798
  });
787
- context.on("debug", (message) => {
799
+ context.on("kubb:debug", (message) => {
788
800
  state.cachedLogs.add({
789
801
  date: /* @__PURE__ */ new Date(),
790
802
  logs: message.logs
791
803
  });
792
804
  });
793
- context.on("plugin:start", (plugin) => {
805
+ context.on("kubb:plugin:start", (plugin) => {
794
806
  state.cachedLogs.add({
795
807
  date: /* @__PURE__ */ new Date(),
796
808
  logs: [`Generating ${plugin.name}`]
797
809
  });
798
810
  });
799
- context.on("plugin:end", (plugin, { duration, success }) => {
811
+ context.on("kubb:plugin:end", (plugin, { duration, success }) => {
800
812
  const durationStr = formatMs(duration);
801
813
  state.cachedLogs.add({
802
814
  date: /* @__PURE__ */ new Date(),
803
815
  logs: [success ? `${plugin.name} completed in ${durationStr}` : `${plugin.name} failed in ${durationStr}`]
804
816
  });
805
817
  });
806
- context.on("files:processing:start", (files) => {
818
+ context.on("kubb:files:processing:start", (files) => {
807
819
  state.cachedLogs.add({
808
820
  date: /* @__PURE__ */ new Date(),
809
821
  logs: [`Start ${files.length} writing:`, ...files.map((file) => file.path)]
810
822
  });
811
823
  });
812
- context.on("generation:end", async (config) => {
824
+ context.on("kubb:generation:end", async (config) => {
813
825
  const writtenFilePaths = await writeLogs(config.name);
814
826
  if (writtenFilePaths.length > 0) {
815
827
  const files = writtenFilePaths.map((f) => relative(process$1.cwd(), f));
816
- await context.emit("info", "Debug files written to:", files.join(", "));
828
+ await context.emit("kubb:info", "Debug files written to:", files.join(", "));
817
829
  }
818
830
  reset();
819
831
  });
@@ -867,7 +879,7 @@ const githubActionsLogger = defineLogger({
867
879
  function closeGroup(_name) {
868
880
  console.log("::endgroup::");
869
881
  }
870
- context.on("info", (message, info = "") => {
882
+ context.on("kubb:info", (message, info = "") => {
871
883
  if (logLevel$7 <= logLevel.silent) return;
872
884
  const text = getMessage([
873
885
  styleText("blue", "ℹ"),
@@ -876,7 +888,7 @@ const githubActionsLogger = defineLogger({
876
888
  ].join(" "));
877
889
  console.log(text);
878
890
  });
879
- context.on("success", (message, info = "") => {
891
+ context.on("kubb:success", (message, info = "") => {
880
892
  if (logLevel$7 <= logLevel.silent) return;
881
893
  const text = getMessage([
882
894
  styleText("blue", "✓"),
@@ -885,7 +897,7 @@ const githubActionsLogger = defineLogger({
885
897
  ].filter(Boolean).join(" "));
886
898
  console.log(text);
887
899
  });
888
- context.on("warn", (message, info = "") => {
900
+ context.on("kubb:warn", (message, info = "") => {
889
901
  if (logLevel$7 <= logLevel.silent) return;
890
902
  const text = getMessage([
891
903
  styleText("yellow", "⚠"),
@@ -894,7 +906,7 @@ const githubActionsLogger = defineLogger({
894
906
  ].filter(Boolean).join(" "));
895
907
  console.warn(`::warning::${text}`);
896
908
  });
897
- context.on("error", (error) => {
909
+ context.on("kubb:error", (error) => {
898
910
  const caused = toCause(error);
899
911
  if (logLevel$7 <= logLevel.silent) return;
900
912
  const message = error.message || String(error);
@@ -909,37 +921,37 @@ const githubActionsLogger = defineLogger({
909
921
  }
910
922
  }
911
923
  });
912
- context.on("lifecycle:start", (version) => {
924
+ context.on("kubb:lifecycle:start", (version) => {
913
925
  console.log(styleText("yellow", `Kubb ${version} 🧩`));
914
926
  reset();
915
927
  });
916
- context.on("config:start", () => {
928
+ context.on("kubb:config:start", () => {
917
929
  if (logLevel$7 <= logLevel.silent) return;
918
930
  const text = getMessage("Configuration started");
919
931
  openGroup("Configuration");
920
932
  console.log(text);
921
933
  });
922
- context.on("config:end", (configs) => {
934
+ context.on("kubb:config:end", (configs) => {
923
935
  state.currentConfigs = configs;
924
936
  if (logLevel$7 <= logLevel.silent) return;
925
937
  const text = getMessage("Configuration completed");
926
938
  console.log(text);
927
939
  closeGroup("Configuration");
928
940
  });
929
- context.on("generation:start", (config) => {
941
+ context.on("kubb:generation:start", (config) => {
930
942
  reset();
931
943
  state.totalPlugins = config.plugins?.length ?? 0;
932
944
  const text = config.name ? `Generation for ${styleText("bold", config.name)}` : "Generation";
933
945
  if (state.currentConfigs.length > 1) openGroup(text);
934
946
  if (state.currentConfigs.length === 1) console.log(getMessage(text));
935
947
  });
936
- context.on("plugin:start", (plugin) => {
948
+ context.on("kubb:plugin:start", (plugin) => {
937
949
  if (logLevel$7 <= logLevel.silent) return;
938
950
  const text = getMessage(`Generating ${styleText("bold", plugin.name)}`);
939
951
  if (state.currentConfigs.length === 1) openGroup(`Plugin: ${plugin.name}`);
940
952
  console.log(text);
941
953
  });
942
- context.on("plugin:end", (plugin, { duration, success }) => {
954
+ context.on("kubb:plugin:end", (plugin, { duration, success }) => {
943
955
  if (logLevel$7 <= logLevel.silent) return;
944
956
  if (success) state.completedPlugins++;
945
957
  else state.failedPlugins++;
@@ -950,7 +962,7 @@ const githubActionsLogger = defineLogger({
950
962
  if (state.currentConfigs.length === 1) closeGroup(`Plugin: ${plugin.name}`);
951
963
  showProgressStep();
952
964
  });
953
- context.on("files:processing:start", (files) => {
965
+ context.on("kubb:files:processing:start", (files) => {
954
966
  if (logLevel$7 <= logLevel.silent) return;
955
967
  state.totalFiles = files.length;
956
968
  state.processedFiles = 0;
@@ -958,46 +970,46 @@ const githubActionsLogger = defineLogger({
958
970
  const text = getMessage(`Writing ${files.length} files`);
959
971
  console.log(text);
960
972
  });
961
- context.on("files:processing:end", () => {
973
+ context.on("kubb:files:processing:end", () => {
962
974
  if (logLevel$7 <= logLevel.silent) return;
963
975
  const text = getMessage("Files written successfully");
964
976
  console.log(text);
965
977
  if (state.currentConfigs.length === 1) closeGroup("File Generation");
966
978
  showProgressStep();
967
979
  });
968
- context.on("file:processing:update", () => {
980
+ context.on("kubb:file:processing:update", () => {
969
981
  if (logLevel$7 <= logLevel.silent) return;
970
982
  state.processedFiles++;
971
983
  });
972
- context.on("generation:end", (config) => {
984
+ context.on("kubb:generation:end", (config) => {
973
985
  const text = getMessage(config.name ? `${styleText("blue", "✓")} Generation completed for ${styleText("dim", config.name)}` : `${styleText("blue", "✓")} Generation completed`);
974
986
  console.log(text);
975
987
  });
976
- context.on("format:start", () => {
988
+ context.on("kubb:format:start", () => {
977
989
  if (logLevel$7 <= logLevel.silent) return;
978
990
  const text = getMessage("Format started");
979
991
  if (state.currentConfigs.length === 1) openGroup("Formatting");
980
992
  console.log(text);
981
993
  });
982
- context.on("format:end", () => {
994
+ context.on("kubb:format:end", () => {
983
995
  if (logLevel$7 <= logLevel.silent) return;
984
996
  const text = getMessage("Format completed");
985
997
  console.log(text);
986
998
  if (state.currentConfigs.length === 1) closeGroup("Formatting");
987
999
  });
988
- context.on("lint:start", () => {
1000
+ context.on("kubb:lint:start", () => {
989
1001
  if (logLevel$7 <= logLevel.silent) return;
990
1002
  const text = getMessage("Lint started");
991
1003
  if (state.currentConfigs.length === 1) openGroup("Linting");
992
1004
  console.log(text);
993
1005
  });
994
- context.on("lint:end", () => {
1006
+ context.on("kubb:lint:end", () => {
995
1007
  if (logLevel$7 <= logLevel.silent) return;
996
1008
  const text = getMessage("Lint completed");
997
1009
  console.log(text);
998
1010
  if (state.currentConfigs.length === 1) closeGroup("Linting");
999
1011
  });
1000
- context.on("hook:start", async ({ id, command, args }) => {
1012
+ context.on("kubb:hook:start", async ({ id, command, args }) => {
1001
1013
  const commandWithArgs = formatCommandWithArgs(command, args);
1002
1014
  const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} started`);
1003
1015
  if (logLevel$7 > logLevel.silent) {
@@ -1017,14 +1029,14 @@ const githubActionsLogger = defineLogger({
1017
1029
  }
1018
1030
  });
1019
1031
  });
1020
- context.on("hook:end", ({ command, args }) => {
1032
+ context.on("kubb:hook:end", ({ command, args }) => {
1021
1033
  if (logLevel$7 <= logLevel.silent) return;
1022
1034
  const commandWithArgs = formatCommandWithArgs(command, args);
1023
1035
  const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} completed`);
1024
1036
  console.log(text);
1025
1037
  if (state.currentConfigs.length === 1) closeGroup(`Hook ${commandWithArgs}`);
1026
1038
  });
1027
- context.on("generation:summary", (config, { status, hrStart, failedPlugins }) => {
1039
+ context.on("kubb:generation:summary", (config, { status, hrStart, failedPlugins }) => {
1028
1040
  const pluginsCount = config.plugins?.length ?? 0;
1029
1041
  const successCount = pluginsCount - failedPlugins.size;
1030
1042
  const duration = formatHrtime(hrStart);
@@ -1032,7 +1044,7 @@ const githubActionsLogger = defineLogger({
1032
1044
  console.log(status === "success" ? `Kubb Summary: ${styleText("blue", "✓")} ${`${successCount} successful`}, ${pluginsCount} total, ${styleText("green", duration)}` : `Kubb Summary: ${styleText("blue", "✓")} ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total, ${styleText("green", duration)}`);
1033
1045
  if (state.currentConfigs.length > 1) closeGroup(config.name ? `Generation for ${styleText("bold", config.name)}` : "Generation");
1034
1046
  });
1035
- context.on("lifecycle:end", () => {
1047
+ context.on("kubb:lifecycle:end", () => {
1036
1048
  reset();
1037
1049
  });
1038
1050
  }
@@ -1050,7 +1062,7 @@ const plainLogger = defineLogger({
1050
1062
  function getMessage(message) {
1051
1063
  return formatMessage(message, logLevel$6);
1052
1064
  }
1053
- context.on("info", (message, info) => {
1065
+ context.on("kubb:info", (message, info) => {
1054
1066
  if (logLevel$6 <= logLevel.silent) return;
1055
1067
  const text = getMessage([
1056
1068
  "ℹ",
@@ -1059,7 +1071,7 @@ const plainLogger = defineLogger({
1059
1071
  ].join(" "));
1060
1072
  console.log(text);
1061
1073
  });
1062
- context.on("success", (message, info = "") => {
1074
+ context.on("kubb:success", (message, info = "") => {
1063
1075
  if (logLevel$6 <= logLevel.silent) return;
1064
1076
  const text = getMessage([
1065
1077
  "✓",
@@ -1068,7 +1080,7 @@ const plainLogger = defineLogger({
1068
1080
  ].filter(Boolean).join(" "));
1069
1081
  console.log(text);
1070
1082
  });
1071
- context.on("warn", (message, info) => {
1083
+ context.on("kubb:warn", (message, info) => {
1072
1084
  if (logLevel$6 < logLevel.warn) return;
1073
1085
  const text = getMessage([
1074
1086
  "⚠",
@@ -1077,7 +1089,7 @@ const plainLogger = defineLogger({
1077
1089
  ].filter(Boolean).join(" "));
1078
1090
  console.log(text);
1079
1091
  });
1080
- context.on("error", (error) => {
1092
+ context.on("kubb:error", (error) => {
1081
1093
  const caused = toCause(error);
1082
1094
  const text = getMessage(["✗", error.message].join(" "));
1083
1095
  console.log(text);
@@ -1091,74 +1103,74 @@ const plainLogger = defineLogger({
1091
1103
  }
1092
1104
  }
1093
1105
  });
1094
- context.on("lifecycle:start", () => {
1106
+ context.on("kubb:lifecycle:start", () => {
1095
1107
  console.log("Kubb CLI 🧩");
1096
1108
  });
1097
- context.on("config:start", () => {
1109
+ context.on("kubb:config:start", () => {
1098
1110
  if (logLevel$6 <= logLevel.silent) return;
1099
1111
  const text = getMessage("Configuration started");
1100
1112
  console.log(text);
1101
1113
  });
1102
- context.on("config:end", () => {
1114
+ context.on("kubb:config:end", () => {
1103
1115
  if (logLevel$6 <= logLevel.silent) return;
1104
1116
  const text = getMessage("Configuration completed");
1105
1117
  console.log(text);
1106
1118
  });
1107
- context.on("generation:start", () => {
1119
+ context.on("kubb:generation:start", () => {
1108
1120
  const text = getMessage("Generation started");
1109
1121
  console.log(text);
1110
1122
  });
1111
- context.on("plugin:start", (plugin) => {
1123
+ context.on("kubb:plugin:start", (plugin) => {
1112
1124
  if (logLevel$6 <= logLevel.silent) return;
1113
1125
  const text = getMessage(`Generating ${plugin.name}`);
1114
1126
  console.log(text);
1115
1127
  });
1116
- context.on("plugin:end", (plugin, { duration, success }) => {
1128
+ context.on("kubb:plugin:end", (plugin, { duration, success }) => {
1117
1129
  if (logLevel$6 <= logLevel.silent) return;
1118
1130
  const durationStr = formatMs(duration);
1119
1131
  const text = getMessage(success ? `${plugin.name} completed in ${durationStr}` : `${plugin.name} failed in ${durationStr}`);
1120
1132
  console.log(text);
1121
1133
  });
1122
- context.on("files:processing:start", (files) => {
1134
+ context.on("kubb:files:processing:start", (files) => {
1123
1135
  if (logLevel$6 <= logLevel.silent) return;
1124
1136
  const text = getMessage(`Writing ${files.length} files`);
1125
1137
  console.log(text);
1126
1138
  });
1127
- context.on("file:processing:update", ({ file, config }) => {
1139
+ context.on("kubb:file:processing:update", ({ file, config }) => {
1128
1140
  if (logLevel$6 <= logLevel.silent) return;
1129
1141
  const text = getMessage(`Writing ${relative(config.root, file.path)}`);
1130
1142
  console.log(text);
1131
1143
  });
1132
- context.on("files:processing:end", () => {
1144
+ context.on("kubb:files:processing:end", () => {
1133
1145
  if (logLevel$6 <= logLevel.silent) return;
1134
1146
  const text = getMessage("Files written successfully");
1135
1147
  console.log(text);
1136
1148
  });
1137
- context.on("generation:end", (config) => {
1149
+ context.on("kubb:generation:end", (config) => {
1138
1150
  const text = getMessage(config.name ? `Generation completed for ${config.name}` : "Generation completed");
1139
1151
  console.log(text);
1140
1152
  });
1141
- context.on("format:start", () => {
1153
+ context.on("kubb:format:start", () => {
1142
1154
  if (logLevel$6 <= logLevel.silent) return;
1143
1155
  const text = getMessage("Format started");
1144
1156
  console.log(text);
1145
1157
  });
1146
- context.on("format:end", () => {
1158
+ context.on("kubb:format:end", () => {
1147
1159
  if (logLevel$6 <= logLevel.silent) return;
1148
1160
  const text = getMessage("Format completed");
1149
1161
  console.log(text);
1150
1162
  });
1151
- context.on("lint:start", () => {
1163
+ context.on("kubb:lint:start", () => {
1152
1164
  if (logLevel$6 <= logLevel.silent) return;
1153
1165
  const text = getMessage("Lint started");
1154
1166
  console.log(text);
1155
1167
  });
1156
- context.on("lint:end", () => {
1168
+ context.on("kubb:lint:end", () => {
1157
1169
  if (logLevel$6 <= logLevel.silent) return;
1158
1170
  const text = getMessage("Lint completed");
1159
1171
  console.log(text);
1160
1172
  });
1161
- context.on("hook:start", async ({ id, command, args }) => {
1173
+ context.on("kubb:hook:start", async ({ id, command, args }) => {
1162
1174
  const commandWithArgs = formatCommandWithArgs(command, args);
1163
1175
  const text = getMessage(`Hook ${commandWithArgs} started`);
1164
1176
  if (logLevel$6 > logLevel.silent) console.log(text);
@@ -1175,12 +1187,12 @@ const plainLogger = defineLogger({
1175
1187
  }
1176
1188
  });
1177
1189
  });
1178
- context.on("hook:end", ({ command, args }) => {
1190
+ context.on("kubb:hook:end", ({ command, args }) => {
1179
1191
  if (logLevel$6 <= logLevel.silent) return;
1180
1192
  const text = getMessage(`Hook ${formatCommandWithArgs(command, args)} completed`);
1181
1193
  console.log(text);
1182
1194
  });
1183
- context.on("generation:summary", (config, { pluginTimings, status, hrStart, failedPlugins, filesCreated }) => {
1195
+ context.on("kubb:generation:summary", (config, { pluginTimings, status, hrStart, failedPlugins, filesCreated }) => {
1184
1196
  const summary = getSummary({
1185
1197
  failedPlugins,
1186
1198
  filesCreated,
@@ -1253,8 +1265,8 @@ async function setupLogger(context, { logLevel: logLevel$5 }) {
1253
1265
  }
1254
1266
  //#endregion
1255
1267
  //#region src/utils/executeHooks.ts
1256
- async function executeHooks({ hooks, events }) {
1257
- const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done].filter(Boolean);
1268
+ async function executeHooks({ configHooks, hooks }) {
1269
+ const commands = Array.isArray(configHooks.done) ? configHooks.done : [configHooks.done].filter(Boolean);
1258
1270
  for (const command of commands) {
1259
1271
  const [cmd, ...args] = tokenize(command);
1260
1272
  if (!cmd) continue;
@@ -1262,16 +1274,16 @@ async function executeHooks({ hooks, events }) {
1262
1274
  const hookEndPromise = new Promise((resolve, reject) => {
1263
1275
  const handler = ({ id, success, error }) => {
1264
1276
  if (id !== hookId) return;
1265
- events.off("hook:end", handler);
1277
+ hooks.off("kubb:hook:end", handler);
1266
1278
  if (!success) {
1267
1279
  reject(error ?? /* @__PURE__ */ new Error(`Hook failed: ${command}`));
1268
1280
  return;
1269
1281
  }
1270
- events.emit("success", `${styleText("dim", command)} successfully executed`).then(resolve).catch(reject);
1282
+ hooks.emit("kubb:success", `${styleText("dim", command)} successfully executed`).then(resolve).catch(reject);
1271
1283
  };
1272
- events.on("hook:end", handler);
1284
+ hooks.on("kubb:hook:end", handler);
1273
1285
  });
1274
- await events.emit("hook:start", {
1286
+ await hooks.emit("kubb:hook:start", {
1275
1287
  id: hookId,
1276
1288
  command: cmd,
1277
1289
  args
@@ -1280,6 +1292,15 @@ async function executeHooks({ hooks, events }) {
1280
1292
  }
1281
1293
  }
1282
1294
  //#endregion
1295
+ //#region src/utils/getConfig.ts
1296
+ async function getConfigs(config, args) {
1297
+ const resolved = await (typeof config === "function" ? config(args) : config);
1298
+ return (Array.isArray(resolved) ? resolved : [resolved]).map((item) => ({
1299
+ ...item,
1300
+ plugins: item.plugins ?? []
1301
+ }));
1302
+ }
1303
+ //#endregion
1283
1304
  //#region src/utils/getCosmiConfig.ts
1284
1305
  const jiti = createJiti(import.meta.url, {
1285
1306
  jsx: {
@@ -1356,15 +1377,15 @@ async function startWatcher(path, cb) {
1356
1377
  }
1357
1378
  //#endregion
1358
1379
  //#region src/runners/generate.ts
1359
- async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefix, noToolMessage, configName, outputPath, logLevel: logLevel$1, events, onStart, onEnd }) {
1380
+ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefix, noToolMessage, configName, outputPath, logLevel: logLevel$1, hooks, onStart, onEnd }) {
1360
1381
  await onStart();
1361
1382
  let resolvedTool = toolValue;
1362
1383
  if (resolvedTool === "auto") {
1363
1384
  const detected = await detect();
1364
- if (!detected) await events.emit("warn", noToolMessage);
1385
+ if (!detected) await hooks.emit("kubb:warn", noToolMessage);
1365
1386
  else {
1366
1387
  resolvedTool = detected;
1367
- await events.emit("info", `Auto-detected ${toolLabel}: ${styleText("dim", resolvedTool)}`);
1388
+ await hooks.emit("kubb:info", `Auto-detected ${toolLabel}: ${styleText("dim", resolvedTool)}`);
1368
1389
  }
1369
1390
  }
1370
1391
  let toolError;
@@ -1375,20 +1396,20 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1375
1396
  const hookEndPromise = new Promise((resolve, reject) => {
1376
1397
  const handler = ({ id, success, error }) => {
1377
1398
  if (id !== hookId) return;
1378
- events.off("hook:end", handler);
1399
+ hooks.off("kubb:hook:end", handler);
1379
1400
  if (!success) {
1380
1401
  reject(error ?? /* @__PURE__ */ new Error(`${toolConfig.errorMessage}`));
1381
1402
  return;
1382
1403
  }
1383
- events.emit("success", [
1404
+ hooks.emit("kubb:success", [
1384
1405
  `${successPrefix} with ${styleText("dim", resolvedTool)}`,
1385
1406
  logLevel$1 >= logLevel.info ? `on ${styleText("dim", outputPath)}` : void 0,
1386
1407
  "successfully"
1387
1408
  ].filter(Boolean).join(" ")).then(resolve).catch(reject);
1388
1409
  };
1389
- events.on("hook:end", handler);
1410
+ hooks.on("kubb:hook:end", handler);
1390
1411
  });
1391
- await events.emit("hook:start", {
1412
+ await hooks.emit("kubb:hook:start", {
1392
1413
  id: hookId,
1393
1414
  command: toolConfig.command,
1394
1415
  args: toolConfig.args(outputPath)
@@ -1397,7 +1418,7 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1397
1418
  } catch (caughtError) {
1398
1419
  const err = new Error(toolConfig.errorMessage);
1399
1420
  err.cause = caughtError;
1400
- await events.emit("error", err);
1421
+ await hooks.emit("kubb:error", err);
1401
1422
  toolError = err;
1402
1423
  }
1403
1424
  }
@@ -1405,34 +1426,32 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1405
1426
  if (toolError) throw toolError;
1406
1427
  }
1407
1428
  async function generate(options) {
1408
- const { input, events, logLevel: logLevel$2 } = options;
1429
+ const { input, hooks, logLevel: logLevel$2 } = options;
1409
1430
  const hrStart = process$1.hrtime();
1410
1431
  const inputPath = input ?? ("path" in options.config.input ? options.config.input.path : void 0);
1411
- const setupResult = await setup({
1412
- config: {
1413
- ...options.config,
1414
- input: inputPath ? {
1415
- ...options.config.input,
1416
- path: inputPath
1417
- } : options.config.input,
1418
- ...options.config.output
1419
- },
1420
- events
1421
- });
1422
- const { sources, config, driver } = setupResult;
1423
- await events.emit("generation:start", config);
1424
- await events.emit("info", config.name ? `Setup generation ${styleText("bold", config.name)}` : "Setup generation", inputPath);
1425
- await events.emit("info", config.name ? `Build generation ${styleText("bold", config.name)}` : "Build generation", inputPath);
1426
- const { files, failedPlugins, pluginTimings, error } = await safeBuild({
1432
+ const config = {
1433
+ ...options.config,
1434
+ input: inputPath ? {
1435
+ ...options.config.input,
1436
+ path: inputPath
1437
+ } : options.config.input,
1438
+ ...options.config.output
1439
+ };
1440
+ const kubb = createKubb({
1427
1441
  config,
1428
- events
1429
- }, setupResult);
1430
- await events.emit("info", "Load summary");
1442
+ hooks
1443
+ });
1444
+ await kubb.setup();
1445
+ await hooks.emit("kubb:generation:start", config);
1446
+ await hooks.emit("kubb:info", config.name ? `Setup generation ${styleText("bold", config.name)}` : "Setup generation", inputPath);
1447
+ await hooks.emit("kubb:info", config.name ? `Build generation ${styleText("bold", config.name)}` : "Build generation", inputPath);
1448
+ const { files, failedPlugins, pluginTimings, error, driver } = await kubb.safeBuild();
1449
+ await hooks.emit("kubb:info", "Load summary");
1431
1450
  if (failedPlugins.size > 0 || error) {
1432
1451
  const allErrors = [error, ...Array.from(failedPlugins).filter((it) => it.error).map((it) => it.error)].filter(Boolean);
1433
- for (const err of allErrors) await events.emit("error", err);
1434
- await events.emit("generation:end", config, files, sources);
1435
- await events.emit("generation:summary", config, {
1452
+ for (const err of allErrors) await hooks.emit("kubb:error", err);
1453
+ await hooks.emit("kubb:generation:end", config, files, kubb.sources);
1454
+ await hooks.emit("kubb:generation:summary", config, {
1436
1455
  failedPlugins,
1437
1456
  filesCreated: files.length,
1438
1457
  status: "failed",
@@ -1452,8 +1471,8 @@ async function generate(options) {
1452
1471
  }));
1453
1472
  process$1.exit(1);
1454
1473
  }
1455
- await events.emit("success", "Generation successfully", inputPath);
1456
- await events.emit("generation:end", config, files, sources);
1474
+ await hooks.emit("kubb:success", "Generation successfully", inputPath);
1475
+ await hooks.emit("kubb:generation:end", config, files, kubb.sources);
1457
1476
  const outputPath = path.resolve(config.root, config.output.path);
1458
1477
  if (config.output.format) await runToolPass({
1459
1478
  toolValue: config.output.format,
@@ -1465,9 +1484,9 @@ async function generate(options) {
1465
1484
  configName: config.name,
1466
1485
  outputPath,
1467
1486
  logLevel: logLevel$2,
1468
- events,
1469
- onStart: () => events.emit("format:start"),
1470
- onEnd: () => events.emit("format:end")
1487
+ hooks,
1488
+ onStart: () => hooks.emit("kubb:format:start"),
1489
+ onEnd: () => hooks.emit("kubb:format:end")
1471
1490
  });
1472
1491
  if (config.output.lint) await runToolPass({
1473
1492
  toolValue: config.output.lint,
@@ -1479,19 +1498,19 @@ async function generate(options) {
1479
1498
  configName: config.name,
1480
1499
  outputPath,
1481
1500
  logLevel: logLevel$2,
1482
- events,
1483
- onStart: () => events.emit("lint:start"),
1484
- onEnd: () => events.emit("lint:end")
1501
+ hooks,
1502
+ onStart: () => hooks.emit("kubb:lint:start"),
1503
+ onEnd: () => hooks.emit("kubb:lint:end")
1485
1504
  });
1486
1505
  if (config.hooks) {
1487
- await events.emit("hooks:start");
1506
+ await hooks.emit("kubb:hooks:start");
1488
1507
  await executeHooks({
1489
- hooks: config.hooks,
1490
- events
1508
+ configHooks: config.hooks,
1509
+ hooks
1491
1510
  });
1492
- await events.emit("hooks:end");
1511
+ await hooks.emit("kubb:hooks:end");
1493
1512
  }
1494
- await events.emit("generation:summary", config, {
1513
+ await hooks.emit("kubb:generation:summary", config, {
1495
1514
  failedPlugins,
1496
1515
  filesCreated: files.length,
1497
1516
  status: "success",
@@ -1512,29 +1531,29 @@ async function generate(options) {
1512
1531
  }
1513
1532
  async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, watch }) {
1514
1533
  const logLevel$3 = logLevel[logLevelKey] ?? logLevel.info;
1515
- const events = new AsyncEventEmitter();
1516
- await setupLogger(events, { logLevel: logLevel$3 });
1534
+ const hooks = new AsyncEventEmitter();
1535
+ await setupLogger(hooks, { logLevel: logLevel$3 });
1517
1536
  await executeIfOnline(async () => {
1518
1537
  try {
1519
1538
  const latestVersion = (await (await fetch(KUBB_NPM_PACKAGE_URL)).json()).version;
1520
- if (latestVersion && version < latestVersion) await events.emit("version:new", version, latestVersion);
1539
+ if (latestVersion && version < latestVersion) await hooks.emit("kubb:version:new", version, latestVersion);
1521
1540
  } catch {}
1522
1541
  });
1523
1542
  try {
1524
1543
  const result = await getCosmiConfig("kubb", configPath);
1525
1544
  const configs = await getConfigs(result.config, { input });
1526
- await events.emit("config:start");
1527
- await events.emit("info", "Config loaded", path.relative(process$1.cwd(), result.filepath));
1528
- await events.emit("success", "Config loaded successfully", path.relative(process$1.cwd(), result.filepath));
1529
- await events.emit("config:end", configs);
1530
- await events.emit("lifecycle:start", version);
1545
+ await hooks.emit("kubb:config:start");
1546
+ await hooks.emit("kubb:info", "Config loaded", path.relative(process$1.cwd(), result.filepath));
1547
+ await hooks.emit("kubb:success", "Config loaded successfully", path.relative(process$1.cwd(), result.filepath));
1548
+ await hooks.emit("kubb:config:end", configs);
1549
+ await hooks.emit("kubb:lifecycle:start", version);
1531
1550
  for (const config of configs) if (isInputPath(config) && watch) await startWatcher([input || config.input.path], async (paths) => {
1532
- events.removeAll();
1551
+ hooks.removeAll();
1533
1552
  await generate({
1534
1553
  input,
1535
1554
  config,
1536
1555
  logLevel: logLevel$3,
1537
- events
1556
+ hooks
1538
1557
  });
1539
1558
  clack.log.step(styleText("yellow", `Watching for changes in ${paths.join(" and ")}`));
1540
1559
  });
@@ -1542,15 +1561,15 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
1542
1561
  input,
1543
1562
  config,
1544
1563
  logLevel: logLevel$3,
1545
- events
1564
+ hooks
1546
1565
  });
1547
- await events.emit("lifecycle:end");
1566
+ await hooks.emit("kubb:lifecycle:end");
1548
1567
  } catch (error) {
1549
- await events.emit("error", toError(error));
1568
+ await hooks.emit("kubb:error", toError(error));
1550
1569
  process$1.exit(1);
1551
1570
  }
1552
1571
  }
1553
1572
  //#endregion
1554
1573
  export { runGenerateCommand };
1555
1574
 
1556
- //# sourceMappingURL=generate-Cx5laPNU.js.map
1575
+ //# sourceMappingURL=generate-DctgMAfY.js.map