@kubb/cli 5.0.0-alpha.52 → 5.0.0-alpha.54

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 (43) hide show
  1. package/dist/{agent-CyXvl4j6.cjs → agent-1X2z7Jvl.cjs} +2 -2
  2. package/dist/{agent-CyXvl4j6.cjs.map → agent-1X2z7Jvl.cjs.map} +1 -1
  3. package/dist/{agent-D_DzTqSx.js → agent-D047iKiB.js} +2 -2
  4. package/dist/{agent-D_DzTqSx.js.map → agent-D047iKiB.js.map} +1 -1
  5. package/dist/{generate-Cr4SXhUE.js → generate-7aYlBJaj.js} +2 -2
  6. package/dist/{generate-Cr4SXhUE.js.map → generate-7aYlBJaj.js.map} +1 -1
  7. package/dist/{generate-BEWAGgDc.cjs → generate-BU4u2JoK.cjs} +111 -80
  8. package/dist/generate-BU4u2JoK.cjs.map +1 -0
  9. package/dist/{generate-XfgAmKJO.cjs → generate-CcOGuRmF.cjs} +2 -2
  10. package/dist/{generate-XfgAmKJO.cjs.map → generate-CcOGuRmF.cjs.map} +1 -1
  11. package/dist/{generate-C5ZuMK47.js → generate-EiNGk7Ll.js} +111 -80
  12. package/dist/generate-EiNGk7Ll.js.map +1 -0
  13. package/dist/index.cjs +6 -6
  14. package/dist/index.js +6 -6
  15. package/dist/{init-Cfgb3-m1.cjs → init-B25Uve4i.cjs} +2 -2
  16. package/dist/{init-Cfgb3-m1.cjs.map → init-B25Uve4i.cjs.map} +1 -1
  17. package/dist/{init-DntPjNaL.js → init-Cm5Ujd24.js} +2 -2
  18. package/dist/{init-DntPjNaL.js.map → init-Cm5Ujd24.js.map} +1 -1
  19. package/dist/{mcp-xQpXtS4T.js → mcp-B_Sfvzbe.js} +2 -2
  20. package/dist/{mcp-xQpXtS4T.js.map → mcp-B_Sfvzbe.js.map} +1 -1
  21. package/dist/{mcp-DfElIp1N.cjs → mcp-CbaPiXK3.cjs} +2 -2
  22. package/dist/{mcp-DfElIp1N.cjs.map → mcp-CbaPiXK3.cjs.map} +1 -1
  23. package/dist/{package-TAugqkSc.cjs → package-BZydcekF.cjs} +2 -2
  24. package/dist/package-BZydcekF.cjs.map +1 -0
  25. package/dist/package-DbJYRz-L.js +6 -0
  26. package/dist/package-DbJYRz-L.js.map +1 -0
  27. package/dist/{validate-Q5FM7up3.js → validate-DWwX1glC.js} +2 -2
  28. package/dist/{validate-Q5FM7up3.js.map → validate-DWwX1glC.js.map} +1 -1
  29. package/dist/{validate-C6cbSTUd.cjs → validate-RRCLoIv_.cjs} +2 -2
  30. package/dist/{validate-C6cbSTUd.cjs.map → validate-RRCLoIv_.cjs.map} +1 -1
  31. package/package.json +5 -5
  32. package/src/loggers/clackLogger.ts +16 -16
  33. package/src/loggers/fileSystemLogger.ts +9 -9
  34. package/src/loggers/githubActionsLogger.ts +12 -12
  35. package/src/loggers/plainLogger.ts +9 -9
  36. package/src/runners/generate.ts +28 -27
  37. package/src/utils/executeHooks.ts +6 -6
  38. package/src/utils/runHook.ts +2 -2
  39. package/dist/generate-BEWAGgDc.cjs.map +0 -1
  40. package/dist/generate-C5ZuMK47.js.map +0 -1
  41. package/dist/package-D5-gtCQz.js +0 -6
  42. package/dist/package-D5-gtCQz.js.map +0 -1
  43. package/dist/package-TAugqkSc.cjs.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-Dis5nWR_.js";
4
4
  import { n as tokenize } from "./shell-DLzN4fRo.js";
5
- import { t as version } from "./package-D5-gtCQz.js";
5
+ import { t as version } from "./package-DbJYRz-L.js";
6
6
  import { a as SUMMARY_SEPARATOR, n as KUBB_NPM_PACKAGE_URL, o as WATCHER_IGNORED_PATHS } from "./constants-T_2rsi7T.js";
7
7
  import { styleText } from "node:util";
8
8
  import { EventEmitter } from "node:events";
@@ -541,7 +541,7 @@ async function runHook({ id, command, args, commandWithArgs, context, stream = f
541
541
  success: false,
542
542
  error: toError(err)
543
543
  });
544
- await context.emit("kubb:error", toError(err));
544
+ await context.emit("kubb:error", { error: toError(err) });
545
545
  return;
546
546
  }
547
547
  const stderr = err.output?.stderr ?? "";
@@ -560,7 +560,7 @@ async function runHook({ id, command, args, commandWithArgs, context, stream = f
560
560
  success: false,
561
561
  error: errorMessage
562
562
  });
563
- await context.emit("kubb:error", errorMessage);
563
+ await context.emit("kubb:error", { error: errorMessage });
564
564
  }
565
565
  }
566
566
  //#endregion
@@ -628,7 +628,7 @@ const clackLogger = defineLogger({
628
628
  state.spinner.stop(text);
629
629
  state.isSpinning = false;
630
630
  }
631
- context.on("kubb:info", (message, info = "") => {
631
+ context.on("kubb:info", ({ message, info = "" }) => {
632
632
  if (logLevel$8 <= logLevel.silent) return;
633
633
  const text = getMessage([
634
634
  styleText("blue", "ℹ"),
@@ -638,7 +638,7 @@ const clackLogger = defineLogger({
638
638
  if (state.isSpinning) state.spinner.message(text);
639
639
  else clack.log.info(text);
640
640
  });
641
- context.on("kubb:success", (message, info = "") => {
641
+ context.on("kubb:success", ({ message, info = "" }) => {
642
642
  if (logLevel$8 <= logLevel.silent) return;
643
643
  const text = getMessage([
644
644
  styleText("blue", "✓"),
@@ -648,7 +648,7 @@ const clackLogger = defineLogger({
648
648
  if (state.isSpinning) stopSpinner(text);
649
649
  else clack.log.success(text);
650
650
  });
651
- context.on("kubb:warn", (message, info) => {
651
+ context.on("kubb:warn", ({ message, info }) => {
652
652
  if (logLevel$8 < logLevel.warn) return;
653
653
  const text = getMessage([
654
654
  styleText("yellow", "⚠"),
@@ -657,7 +657,7 @@ const clackLogger = defineLogger({
657
657
  ].filter(Boolean).join(" "));
658
658
  clack.log.warn(text);
659
659
  });
660
- context.on("kubb:error", (error) => {
660
+ context.on("kubb:error", ({ error }) => {
661
661
  const caused = toCause(error);
662
662
  const text = [styleText("red", "✗"), error.message].join(" ");
663
663
  if (state.isSpinning) stopSpinner(getMessage(text));
@@ -672,10 +672,10 @@ const clackLogger = defineLogger({
672
672
  }
673
673
  }
674
674
  });
675
- context.on("kubb:version:new", (version, latestVersion) => {
675
+ context.on("kubb:version:new", ({ currentVersion, latestVersion }) => {
676
676
  if (logLevel$8 <= logLevel.silent) return;
677
677
  try {
678
- clack.box(`\`v${version}\` → \`v${latestVersion}\`
678
+ clack.box(`\`v${currentVersion}\` → \`v${latestVersion}\`
679
679
  Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
680
680
  width: "auto",
681
681
  formatBorder: (s) => styleText("yellow", s),
@@ -685,11 +685,11 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
685
685
  titleAlign: "center"
686
686
  });
687
687
  } catch {
688
- console.log(`Update available for Kubb: v${version} → v${latestVersion}`);
688
+ console.log(`Update available for Kubb: v${currentVersion} → v${latestVersion}`);
689
689
  console.log("Run `npm install -g @kubb/cli` to update");
690
690
  }
691
691
  });
692
- context.on("kubb:lifecycle:start", async (version) => {
692
+ context.on("kubb:lifecycle:start", async ({ version }) => {
693
693
  console.log(`\n${getIntro({
694
694
  title: "The ultimate toolkit for working with APIs",
695
695
  description: "Ready to start",
@@ -704,18 +704,18 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
704
704
  clack.intro(text);
705
705
  startSpinner(getMessage("Configuration loading"));
706
706
  });
707
- context.on("kubb:config:end", (_configs) => {
707
+ context.on("kubb:config:end", () => {
708
708
  if (logLevel$8 <= logLevel.silent) return;
709
709
  const text = getMessage("Configuration completed");
710
710
  clack.outro(text);
711
711
  });
712
- context.on("kubb:generation:start", (config) => {
712
+ context.on("kubb:generation:start", ({ config }) => {
713
713
  reset();
714
714
  state.totalPlugins = config.plugins?.length ?? 0;
715
715
  const text = getMessage(["Generation started", config.name ? `for ${styleText("dim", config.name)}` : void 0].filter(Boolean).join(" "));
716
716
  clack.intro(text);
717
717
  });
718
- context.on("kubb:plugin:start", (plugin) => {
718
+ context.on("kubb:plugin:start", ({ plugin }) => {
719
719
  if (logLevel$8 <= logLevel.silent) return;
720
720
  stopSpinner();
721
721
  const progressBar = clack.progress({
@@ -733,7 +733,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
733
733
  interval
734
734
  });
735
735
  });
736
- context.on("kubb:plugin:end", (plugin, { duration, success }) => {
736
+ context.on("kubb:plugin:end", ({ plugin, duration, success }) => {
737
737
  stopSpinner();
738
738
  const active = state.activeProgress.get(plugin.name);
739
739
  if (!active || logLevel$8 === logLevel.silent) return;
@@ -746,7 +746,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
746
746
  state.activeProgress.delete(plugin.name);
747
747
  showProgressStep();
748
748
  });
749
- context.on("kubb:files:processing:start", (files) => {
749
+ context.on("kubb:files:processing:start", ({ files }) => {
750
750
  if (logLevel$8 <= logLevel.silent) return;
751
751
  stopSpinner();
752
752
  state.totalFiles = files.length;
@@ -757,7 +757,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
757
757
  max: files.length,
758
758
  size: 30
759
759
  });
760
- context.emit("kubb:info", text);
760
+ context.emit("kubb:info", { message: text });
761
761
  progressBar.start(getMessage(text));
762
762
  state.activeProgress.set("files", { progressBar });
763
763
  });
@@ -780,7 +780,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
780
780
  state.activeProgress.delete("files");
781
781
  showProgressStep();
782
782
  });
783
- context.on("kubb:generation:end", (config) => {
783
+ context.on("kubb:generation:end", ({ config }) => {
784
784
  const text = getMessage(config.name ? `Generation completed for ${styleText("dim", config.name)}` : "Generation completed");
785
785
  clack.outro(text);
786
786
  });
@@ -844,7 +844,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
844
844
  const text = getMessage(`Hook ${styleText("dim", formatCommandWithArgs(command, args))} successfully executed`);
845
845
  clack.outro(text);
846
846
  });
847
- context.on("kubb:generation:summary", (config, { pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
847
+ context.on("kubb:generation:summary", ({ config, pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
848
848
  const summary = getSummary({
849
849
  failedPlugins,
850
850
  filesCreated,
@@ -914,25 +914,25 @@ const fileSystemLogger = defineLogger({
914
914
  for (const [fileName, logs] of Object.entries(files)) await write(fileName, logs.join("\n\n"));
915
915
  return Object.keys(files);
916
916
  }
917
- context.on("kubb:info", (message, info) => {
917
+ context.on("kubb:info", ({ message, info }) => {
918
918
  state.cachedLogs.add({
919
919
  date: /* @__PURE__ */ new Date(),
920
920
  logs: [`ℹ ${message} ${info}`]
921
921
  });
922
922
  });
923
- context.on("kubb:success", (message, info) => {
923
+ context.on("kubb:success", ({ message, info }) => {
924
924
  state.cachedLogs.add({
925
925
  date: /* @__PURE__ */ new Date(),
926
926
  logs: [`✓ ${message} ${info}`]
927
927
  });
928
928
  });
929
- context.on("kubb:warn", (message, info) => {
929
+ context.on("kubb:warn", ({ message, info }) => {
930
930
  state.cachedLogs.add({
931
931
  date: /* @__PURE__ */ new Date(),
932
932
  logs: [`⚠ ${message} ${info}`]
933
933
  });
934
934
  });
935
- context.on("kubb:error", (error) => {
935
+ context.on("kubb:error", ({ error }) => {
936
936
  state.cachedLogs.add({
937
937
  date: /* @__PURE__ */ new Date(),
938
938
  logs: [`✗ ${error.message}`, error.stack || "unknown stack"]
@@ -944,30 +944,33 @@ const fileSystemLogger = defineLogger({
944
944
  logs: message.logs
945
945
  });
946
946
  });
947
- context.on("kubb:plugin:start", (plugin) => {
947
+ context.on("kubb:plugin:start", ({ plugin }) => {
948
948
  state.cachedLogs.add({
949
949
  date: /* @__PURE__ */ new Date(),
950
950
  logs: [`Generating ${plugin.name}`]
951
951
  });
952
952
  });
953
- context.on("kubb:plugin:end", (plugin, { duration, success }) => {
953
+ context.on("kubb:plugin:end", ({ plugin, duration, success }) => {
954
954
  const durationStr = formatMs(duration);
955
955
  state.cachedLogs.add({
956
956
  date: /* @__PURE__ */ new Date(),
957
957
  logs: [success ? `${plugin.name} completed in ${durationStr}` : `${plugin.name} failed in ${durationStr}`]
958
958
  });
959
959
  });
960
- context.on("kubb:files:processing:start", (files) => {
960
+ context.on("kubb:files:processing:start", ({ files }) => {
961
961
  state.cachedLogs.add({
962
962
  date: /* @__PURE__ */ new Date(),
963
963
  logs: [`Start ${files.length} writing:`, ...files.map((file) => file.path)]
964
964
  });
965
965
  });
966
- context.on("kubb:generation:end", async (config) => {
966
+ context.on("kubb:generation:end", async ({ config }) => {
967
967
  const writtenFilePaths = await writeLogs(config.name);
968
968
  if (writtenFilePaths.length > 0) {
969
969
  const files = writtenFilePaths.map((f) => relative(process$1.cwd(), f));
970
- await context.emit("kubb:info", "Debug files written to:", files.join(", "));
970
+ await context.emit("kubb:info", {
971
+ message: "Debug files written to:",
972
+ info: files.join(", ")
973
+ });
971
974
  }
972
975
  reset();
973
976
  });
@@ -1021,7 +1024,7 @@ const githubActionsLogger = defineLogger({
1021
1024
  function closeGroup(_name) {
1022
1025
  console.log("::endgroup::");
1023
1026
  }
1024
- context.on("kubb:info", (message, info = "") => {
1027
+ context.on("kubb:info", ({ message, info = "" }) => {
1025
1028
  if (logLevel$7 <= logLevel.silent) return;
1026
1029
  const text = getMessage([
1027
1030
  styleText("blue", "ℹ"),
@@ -1030,7 +1033,7 @@ const githubActionsLogger = defineLogger({
1030
1033
  ].join(" "));
1031
1034
  console.log(text);
1032
1035
  });
1033
- context.on("kubb:success", (message, info = "") => {
1036
+ context.on("kubb:success", ({ message, info = "" }) => {
1034
1037
  if (logLevel$7 <= logLevel.silent) return;
1035
1038
  const text = getMessage([
1036
1039
  styleText("blue", "✓"),
@@ -1039,7 +1042,7 @@ const githubActionsLogger = defineLogger({
1039
1042
  ].filter(Boolean).join(" "));
1040
1043
  console.log(text);
1041
1044
  });
1042
- context.on("kubb:warn", (message, info = "") => {
1045
+ context.on("kubb:warn", ({ message, info = "" }) => {
1043
1046
  if (logLevel$7 <= logLevel.silent) return;
1044
1047
  const text = getMessage([
1045
1048
  styleText("yellow", "⚠"),
@@ -1048,7 +1051,7 @@ const githubActionsLogger = defineLogger({
1048
1051
  ].filter(Boolean).join(" "));
1049
1052
  console.warn(`::warning::${text}`);
1050
1053
  });
1051
- context.on("kubb:error", (error) => {
1054
+ context.on("kubb:error", ({ error }) => {
1052
1055
  const caused = toCause(error);
1053
1056
  if (logLevel$7 <= logLevel.silent) return;
1054
1057
  const message = error.message || String(error);
@@ -1063,7 +1066,7 @@ const githubActionsLogger = defineLogger({
1063
1066
  }
1064
1067
  }
1065
1068
  });
1066
- context.on("kubb:lifecycle:start", (version) => {
1069
+ context.on("kubb:lifecycle:start", ({ version }) => {
1067
1070
  console.log(styleText("yellow", `Kubb ${version} 🧩`));
1068
1071
  reset();
1069
1072
  });
@@ -1073,27 +1076,27 @@ const githubActionsLogger = defineLogger({
1073
1076
  openGroup("Configuration");
1074
1077
  console.log(text);
1075
1078
  });
1076
- context.on("kubb:config:end", (configs) => {
1079
+ context.on("kubb:config:end", ({ configs }) => {
1077
1080
  state.currentConfigs = configs;
1078
1081
  if (logLevel$7 <= logLevel.silent) return;
1079
1082
  const text = getMessage("Configuration completed");
1080
1083
  console.log(text);
1081
1084
  closeGroup("Configuration");
1082
1085
  });
1083
- context.on("kubb:generation:start", (config) => {
1086
+ context.on("kubb:generation:start", ({ config }) => {
1084
1087
  reset();
1085
1088
  state.totalPlugins = config.plugins?.length ?? 0;
1086
1089
  const text = config.name ? `Generation for ${styleText("bold", config.name)}` : "Generation";
1087
1090
  if (state.currentConfigs.length > 1) openGroup(text);
1088
1091
  if (state.currentConfigs.length === 1) console.log(getMessage(text));
1089
1092
  });
1090
- context.on("kubb:plugin:start", (plugin) => {
1093
+ context.on("kubb:plugin:start", ({ plugin }) => {
1091
1094
  if (logLevel$7 <= logLevel.silent) return;
1092
1095
  const text = getMessage(`Generating ${styleText("bold", plugin.name)}`);
1093
1096
  if (state.currentConfigs.length === 1) openGroup(`Plugin: ${plugin.name}`);
1094
1097
  console.log(text);
1095
1098
  });
1096
- context.on("kubb:plugin:end", (plugin, { duration, success }) => {
1099
+ context.on("kubb:plugin:end", ({ plugin, duration, success }) => {
1097
1100
  if (logLevel$7 <= logLevel.silent) return;
1098
1101
  if (success) state.completedPlugins++;
1099
1102
  else state.failedPlugins++;
@@ -1104,7 +1107,7 @@ const githubActionsLogger = defineLogger({
1104
1107
  if (state.currentConfigs.length === 1) closeGroup(`Plugin: ${plugin.name}`);
1105
1108
  showProgressStep();
1106
1109
  });
1107
- context.on("kubb:files:processing:start", (files) => {
1110
+ context.on("kubb:files:processing:start", ({ files }) => {
1108
1111
  if (logLevel$7 <= logLevel.silent) return;
1109
1112
  state.totalFiles = files.length;
1110
1113
  state.processedFiles = 0;
@@ -1123,7 +1126,7 @@ const githubActionsLogger = defineLogger({
1123
1126
  if (logLevel$7 <= logLevel.silent) return;
1124
1127
  state.processedFiles++;
1125
1128
  });
1126
- context.on("kubb:generation:end", (config) => {
1129
+ context.on("kubb:generation:end", ({ config }) => {
1127
1130
  const text = getMessage(config.name ? `${styleText("blue", "✓")} Generation completed for ${styleText("dim", config.name)}` : `${styleText("blue", "✓")} Generation completed`);
1128
1131
  console.log(text);
1129
1132
  });
@@ -1178,7 +1181,7 @@ const githubActionsLogger = defineLogger({
1178
1181
  console.log(text);
1179
1182
  if (state.currentConfigs.length === 1) closeGroup(`Hook ${commandWithArgs}`);
1180
1183
  });
1181
- context.on("kubb:generation:summary", (config, { status, hrStart, failedPlugins }) => {
1184
+ context.on("kubb:generation:summary", ({ config, status, hrStart, failedPlugins }) => {
1182
1185
  const pluginsCount = config.plugins?.length ?? 0;
1183
1186
  const successCount = pluginsCount - failedPlugins.size;
1184
1187
  const duration = formatHrtime(hrStart);
@@ -1204,7 +1207,7 @@ const plainLogger = defineLogger({
1204
1207
  function getMessage(message) {
1205
1208
  return formatMessage(message, logLevel$6);
1206
1209
  }
1207
- context.on("kubb:info", (message, info) => {
1210
+ context.on("kubb:info", ({ message, info }) => {
1208
1211
  if (logLevel$6 <= logLevel.silent) return;
1209
1212
  const text = getMessage([
1210
1213
  "ℹ",
@@ -1213,7 +1216,7 @@ const plainLogger = defineLogger({
1213
1216
  ].join(" "));
1214
1217
  console.log(text);
1215
1218
  });
1216
- context.on("kubb:success", (message, info = "") => {
1219
+ context.on("kubb:success", ({ message, info = "" }) => {
1217
1220
  if (logLevel$6 <= logLevel.silent) return;
1218
1221
  const text = getMessage([
1219
1222
  "✓",
@@ -1222,7 +1225,7 @@ const plainLogger = defineLogger({
1222
1225
  ].filter(Boolean).join(" "));
1223
1226
  console.log(text);
1224
1227
  });
1225
- context.on("kubb:warn", (message, info) => {
1228
+ context.on("kubb:warn", ({ message, info }) => {
1226
1229
  if (logLevel$6 < logLevel.warn) return;
1227
1230
  const text = getMessage([
1228
1231
  "⚠",
@@ -1231,7 +1234,7 @@ const plainLogger = defineLogger({
1231
1234
  ].filter(Boolean).join(" "));
1232
1235
  console.log(text);
1233
1236
  });
1234
- context.on("kubb:error", (error) => {
1237
+ context.on("kubb:error", ({ error }) => {
1235
1238
  const caused = toCause(error);
1236
1239
  const text = getMessage(["✗", error.message].join(" "));
1237
1240
  console.log(text);
@@ -1262,18 +1265,18 @@ const plainLogger = defineLogger({
1262
1265
  const text = getMessage("Generation started");
1263
1266
  console.log(text);
1264
1267
  });
1265
- context.on("kubb:plugin:start", (plugin) => {
1268
+ context.on("kubb:plugin:start", ({ plugin }) => {
1266
1269
  if (logLevel$6 <= logLevel.silent) return;
1267
1270
  const text = getMessage(`Generating ${plugin.name}`);
1268
1271
  console.log(text);
1269
1272
  });
1270
- context.on("kubb:plugin:end", (plugin, { duration, success }) => {
1273
+ context.on("kubb:plugin:end", ({ plugin, duration, success }) => {
1271
1274
  if (logLevel$6 <= logLevel.silent) return;
1272
1275
  const durationStr = formatMs(duration);
1273
1276
  const text = getMessage(success ? `${plugin.name} completed in ${durationStr}` : `${plugin.name} failed in ${durationStr}`);
1274
1277
  console.log(text);
1275
1278
  });
1276
- context.on("kubb:files:processing:start", (files) => {
1279
+ context.on("kubb:files:processing:start", ({ files }) => {
1277
1280
  if (logLevel$6 <= logLevel.silent) return;
1278
1281
  const text = getMessage(`Writing ${files.length} files`);
1279
1282
  console.log(text);
@@ -1288,7 +1291,7 @@ const plainLogger = defineLogger({
1288
1291
  const text = getMessage("Files written successfully");
1289
1292
  console.log(text);
1290
1293
  });
1291
- context.on("kubb:generation:end", (config) => {
1294
+ context.on("kubb:generation:end", ({ config }) => {
1292
1295
  const text = getMessage(config.name ? `Generation completed for ${config.name}` : "Generation completed");
1293
1296
  console.log(text);
1294
1297
  });
@@ -1334,7 +1337,7 @@ const plainLogger = defineLogger({
1334
1337
  const text = getMessage(`Hook ${formatCommandWithArgs(command, args)} completed`);
1335
1338
  console.log(text);
1336
1339
  });
1337
- context.on("kubb:generation:summary", (config, { pluginTimings, status, hrStart, failedPlugins, filesCreated }) => {
1340
+ context.on("kubb:generation:summary", ({ config, pluginTimings, status, hrStart, failedPlugins, filesCreated }) => {
1338
1341
  const summary = getSummary({
1339
1342
  failedPlugins,
1340
1343
  filesCreated,
@@ -1414,14 +1417,14 @@ async function executeHooks({ configHooks, hooks }) {
1414
1417
  if (!cmd) continue;
1415
1418
  const hookId = createHash("sha256").update(command).digest("hex");
1416
1419
  const hookEndPromise = new Promise((resolve, reject) => {
1417
- const handler = ({ id, success, error }) => {
1418
- if (id !== hookId) return;
1420
+ const handler = (ctx) => {
1421
+ if (ctx.id !== hookId) return;
1419
1422
  hooks.off("kubb:hook:end", handler);
1420
- if (!success) {
1421
- reject(error ?? /* @__PURE__ */ new Error(`Hook failed: ${command}`));
1423
+ if (!ctx.success) {
1424
+ reject(ctx.error ?? /* @__PURE__ */ new Error(`Hook failed: ${command}`));
1422
1425
  return;
1423
1426
  }
1424
- hooks.emit("kubb:success", `${styleText("dim", command)} successfully executed`).then(resolve).catch(reject);
1427
+ hooks.emit("kubb:success", { message: `${styleText("dim", command)} successfully executed` }).then(resolve).catch(reject);
1425
1428
  };
1426
1429
  hooks.on("kubb:hook:end", handler);
1427
1430
  });
@@ -1524,10 +1527,10 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1524
1527
  let resolvedTool = toolValue;
1525
1528
  if (resolvedTool === "auto") {
1526
1529
  const detected = await detect();
1527
- if (!detected) await hooks.emit("kubb:warn", noToolMessage);
1530
+ if (!detected) await hooks.emit("kubb:warn", { message: noToolMessage });
1528
1531
  else {
1529
1532
  resolvedTool = detected;
1530
- await hooks.emit("kubb:info", `Auto-detected ${toolLabel}: ${styleText("dim", resolvedTool)}`);
1533
+ await hooks.emit("kubb:info", { message: `Auto-detected ${toolLabel}: ${styleText("dim", resolvedTool)}` });
1531
1534
  }
1532
1535
  }
1533
1536
  let toolError;
@@ -1536,18 +1539,18 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1536
1539
  try {
1537
1540
  const hookId = createHash("sha256").update([configName, resolvedTool].filter(Boolean).join("-")).digest("hex");
1538
1541
  const hookEndPromise = new Promise((resolve, reject) => {
1539
- const handler = ({ id, success, error }) => {
1540
- if (id !== hookId) return;
1542
+ const handler = (ctx) => {
1543
+ if (ctx.id !== hookId) return;
1541
1544
  hooks.off("kubb:hook:end", handler);
1542
- if (!success) {
1543
- reject(error ?? /* @__PURE__ */ new Error(`${toolConfig.errorMessage}`));
1545
+ if (!ctx.success) {
1546
+ reject(ctx.error ?? /* @__PURE__ */ new Error(`${toolConfig.errorMessage}`));
1544
1547
  return;
1545
1548
  }
1546
- hooks.emit("kubb:success", [
1549
+ hooks.emit("kubb:success", { message: [
1547
1550
  `${successPrefix} with ${styleText("dim", resolvedTool)}`,
1548
1551
  logLevel$1 >= logLevel.info ? `on ${styleText("dim", outputPath)}` : void 0,
1549
1552
  "successfully"
1550
- ].filter(Boolean).join(" ")).then(resolve).catch(reject);
1553
+ ].filter(Boolean).join(" ") }).then(resolve).catch(reject);
1551
1554
  };
1552
1555
  hooks.on("kubb:hook:end", handler);
1553
1556
  });
@@ -1559,7 +1562,7 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1559
1562
  await hookEndPromise;
1560
1563
  } catch (caughtError) {
1561
1564
  const err = toError(caughtError);
1562
- await hooks.emit("kubb:error", err);
1565
+ await hooks.emit("kubb:error", { error: err });
1563
1566
  toolError = err;
1564
1567
  }
1565
1568
  }
@@ -1580,16 +1583,27 @@ async function generate(options) {
1580
1583
  };
1581
1584
  const kubb = createKubb(config, { hooks });
1582
1585
  await kubb.setup();
1583
- await hooks.emit("kubb:generation:start", config);
1584
- await hooks.emit("kubb:info", config.name ? `Setup generation ${styleText("bold", config.name)}` : "Setup generation", inputPath);
1585
- await hooks.emit("kubb:info", config.name ? `Build generation ${styleText("bold", config.name)}` : "Build generation", inputPath);
1586
+ await hooks.emit("kubb:generation:start", { config });
1587
+ await hooks.emit("kubb:info", {
1588
+ message: config.name ? `Setup generation ${styleText("bold", config.name)}` : "Setup generation",
1589
+ info: inputPath
1590
+ });
1591
+ await hooks.emit("kubb:info", {
1592
+ message: config.name ? `Build generation ${styleText("bold", config.name)}` : "Build generation",
1593
+ info: inputPath
1594
+ });
1586
1595
  const { files, failedPlugins, pluginTimings, error, driver } = await kubb.safeBuild();
1587
- await hooks.emit("kubb:info", "Load summary");
1596
+ await hooks.emit("kubb:info", { message: "Load summary" });
1588
1597
  if (failedPlugins.size > 0 || error) {
1589
1598
  const allErrors = [error, ...Array.from(failedPlugins).filter((it) => it.error).map((it) => it.error)].filter(Boolean);
1590
- for (const err of allErrors) await hooks.emit("kubb:error", err);
1591
- await hooks.emit("kubb:generation:end", config, files, kubb.sources);
1592
- await hooks.emit("kubb:generation:summary", config, {
1599
+ for (const err of allErrors) await hooks.emit("kubb:error", { error: err });
1600
+ await hooks.emit("kubb:generation:end", {
1601
+ config,
1602
+ files,
1603
+ sources: kubb.sources
1604
+ });
1605
+ await hooks.emit("kubb:generation:summary", {
1606
+ config,
1593
1607
  failedPlugins,
1594
1608
  filesCreated: files.length,
1595
1609
  status: "failed",
@@ -1609,8 +1623,15 @@ async function generate(options) {
1609
1623
  }));
1610
1624
  process$1.exit(1);
1611
1625
  }
1612
- await hooks.emit("kubb:success", "Generation successfully", inputPath);
1613
- await hooks.emit("kubb:generation:end", config, files, kubb.sources);
1626
+ await hooks.emit("kubb:success", {
1627
+ message: "Generation successfully",
1628
+ info: inputPath
1629
+ });
1630
+ await hooks.emit("kubb:generation:end", {
1631
+ config,
1632
+ files,
1633
+ sources: kubb.sources
1634
+ });
1614
1635
  const outputPath = path.resolve(config.root, config.output.path);
1615
1636
  if (config.output.format) await runToolPass({
1616
1637
  toolValue: config.output.format,
@@ -1648,7 +1669,8 @@ async function generate(options) {
1648
1669
  });
1649
1670
  await hooks.emit("kubb:hooks:end");
1650
1671
  }
1651
- await hooks.emit("kubb:generation:summary", config, {
1672
+ await hooks.emit("kubb:generation:summary", {
1673
+ config,
1652
1674
  failedPlugins,
1653
1675
  filesCreated: files.length,
1654
1676
  status: "success",
@@ -1674,17 +1696,26 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
1674
1696
  await executeIfOnline(async () => {
1675
1697
  try {
1676
1698
  const latestVersion = (await (await fetch(KUBB_NPM_PACKAGE_URL)).json()).version;
1677
- if (latestVersion && version < latestVersion) await hooks.emit("kubb:version:new", version, latestVersion);
1699
+ if (latestVersion && version < latestVersion) await hooks.emit("kubb:version:new", {
1700
+ currentVersion: version,
1701
+ latestVersion
1702
+ });
1678
1703
  } catch {}
1679
1704
  });
1680
1705
  try {
1681
1706
  const result = await getCosmiConfig("kubb", configPath);
1682
1707
  const configs = await getConfigs(result.config, { input });
1683
1708
  await hooks.emit("kubb:config:start");
1684
- await hooks.emit("kubb:info", "Config loaded", path.relative(process$1.cwd(), result.filepath));
1685
- await hooks.emit("kubb:success", "Config loaded successfully", path.relative(process$1.cwd(), result.filepath));
1686
- await hooks.emit("kubb:config:end", configs);
1687
- await hooks.emit("kubb:lifecycle:start", version);
1709
+ await hooks.emit("kubb:info", {
1710
+ message: "Config loaded",
1711
+ info: path.relative(process$1.cwd(), result.filepath)
1712
+ });
1713
+ await hooks.emit("kubb:success", {
1714
+ message: "Config loaded successfully",
1715
+ info: path.relative(process$1.cwd(), result.filepath)
1716
+ });
1717
+ await hooks.emit("kubb:config:end", { configs });
1718
+ await hooks.emit("kubb:lifecycle:start", { version });
1688
1719
  for (const config of configs) if (isInputPath(config) && watch) await startWatcher([input || config.input.path], async (paths) => {
1689
1720
  hooks.removeAll();
1690
1721
  await generate({
@@ -1703,11 +1734,11 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
1703
1734
  });
1704
1735
  await hooks.emit("kubb:lifecycle:end");
1705
1736
  } catch (error) {
1706
- await hooks.emit("kubb:error", toError(error));
1737
+ await hooks.emit("kubb:error", { error: toError(error) });
1707
1738
  process$1.exit(1);
1708
1739
  }
1709
1740
  }
1710
1741
  //#endregion
1711
1742
  export { runGenerateCommand };
1712
1743
 
1713
- //# sourceMappingURL=generate-C5ZuMK47.js.map
1744
+ //# sourceMappingURL=generate-EiNGk7Ll.js.map