@kubb/cli 5.0.0-beta.14 → 5.0.0-beta.15

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 (42) hide show
  1. package/dist/{agent-SCGeyEIE.js → agent-BTvJ7IUq.js} +2 -2
  2. package/dist/{agent-SCGeyEIE.js.map → agent-BTvJ7IUq.js.map} +1 -1
  3. package/dist/{agent-Dn1Kfd_R.cjs → agent-vzaMEbPS.cjs} +2 -2
  4. package/dist/{agent-Dn1Kfd_R.cjs.map → agent-vzaMEbPS.cjs.map} +1 -1
  5. package/dist/{generate-CLYE3RWE.js → generate-BczcDWHS.js} +2 -2
  6. package/dist/{generate-CLYE3RWE.js.map → generate-BczcDWHS.js.map} +1 -1
  7. package/dist/{generate-z_83cgcO.cjs → generate-BkKnYYok.cjs} +2 -2
  8. package/dist/{generate-z_83cgcO.cjs.map → generate-BkKnYYok.cjs.map} +1 -1
  9. package/dist/index.cjs +6 -6
  10. package/dist/index.js +6 -6
  11. package/dist/{init-BvHHgquV.js → init-CGLK93Ny.js} +2 -2
  12. package/dist/{init-BvHHgquV.js.map → init-CGLK93Ny.js.map} +1 -1
  13. package/dist/{init-S-eLRaep.cjs → init-DH-tkhDa.cjs} +2 -2
  14. package/dist/{init-S-eLRaep.cjs.map → init-DH-tkhDa.cjs.map} +1 -1
  15. package/dist/{mcp-BkBwpF6r.cjs → mcp-BzuRPhN0.cjs} +2 -2
  16. package/dist/{mcp-BkBwpF6r.cjs.map → mcp-BzuRPhN0.cjs.map} +1 -1
  17. package/dist/{mcp-DEjoAmP2.js → mcp-CmSOtsiY.js} +2 -2
  18. package/dist/{mcp-DEjoAmP2.js.map → mcp-CmSOtsiY.js.map} +1 -1
  19. package/dist/package-B3fEVBWy.js +6 -0
  20. package/dist/package-B3fEVBWy.js.map +1 -0
  21. package/dist/{package-C7ZmbQd7.cjs → package-rMKbcyw1.cjs} +2 -2
  22. package/dist/package-rMKbcyw1.cjs.map +1 -0
  23. package/dist/{run-BNvaRFvz.js → run-BvsacB4B.js} +127 -72
  24. package/dist/run-BvsacB4B.js.map +1 -0
  25. package/dist/{run-DK-3QOOS.cjs → run-ftIEu5xK.cjs} +127 -72
  26. package/dist/run-ftIEu5xK.cjs.map +1 -0
  27. package/dist/{validate-C3hmnp-x.cjs → validate--WZ6E0gu.cjs} +2 -2
  28. package/dist/{validate-C3hmnp-x.cjs.map → validate--WZ6E0gu.cjs.map} +1 -1
  29. package/dist/{validate-qvniflGp.js → validate-D3p-TOu4.js} +2 -2
  30. package/dist/{validate-qvniflGp.js.map → validate-D3p-TOu4.js.map} +1 -1
  31. package/package.json +6 -6
  32. package/src/loggers/clackLogger.ts +45 -55
  33. package/src/loggers/githubActionsLogger.ts +64 -6
  34. package/src/loggers/plainLogger.ts +47 -11
  35. package/src/loggers/utils.ts +4 -1
  36. package/src/runners/generate/run.ts +20 -8
  37. package/src/runners/generate/utils.ts +2 -2
  38. package/dist/package-C7ZmbQd7.cjs.map +0 -1
  39. package/dist/package-D5eM8mZw.js +0 -6
  40. package/dist/package-D5eM8mZw.js.map +0 -1
  41. package/dist/run-BNvaRFvz.js.map +0 -1
  42. package/dist/run-DK-3QOOS.cjs.map +0 -1
@@ -2,7 +2,7 @@ import "./chunk-BvFE5Tac.js";
2
2
  import { n as toCause, r as toError } from "./errors-CINO1EIv.js";
3
3
  import { a as canUseTTY, i as executeIfOnline, o as isGitHubActions, r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-BkektVz6.js";
4
4
  import { n as tokenize } from "./shell-CN6DNqeC.js";
5
- import { t as version } from "./package-D5eM8mZw.js";
5
+ import { t as version } from "./package-B3fEVBWy.js";
6
6
  import { a as WATCHER_IGNORED_PATHS, i as SUMMARY_SEPARATOR, t as KUBB_NPM_PACKAGE_URL } from "./constants-B2JTeRBb.js";
7
7
  import { styleText } from "node:util";
8
8
  import { EventEmitter } from "node:events";
@@ -14,7 +14,6 @@ import path, { dirname, relative, resolve } from "node:path";
14
14
  import process$1 from "node:process";
15
15
  import * as clack from "@clack/prompts";
16
16
  import { createKubb, defineLogger, isInputPath, logLevel } from "@kubb/core";
17
- import { Writable } from "node:stream";
18
17
  import { cosmiconfig } from "cosmiconfig";
19
18
  import { createJiti } from "jiti";
20
19
  import { NonZeroExitError, x } from "tinyexec";
@@ -488,21 +487,6 @@ async function detectLinter() {
488
487
  //#endregion
489
488
  //#region src/loggers/clackLogger.ts
490
489
  /**
491
- * Node.js `Writable` stream that forwards each chunk to a clack `taskLog` message.
492
- * Used to pipe hook subprocess output into the clack task log UI.
493
- */
494
- var ClackWritable = class extends Writable {
495
- taskLog;
496
- constructor(taskLog, opts) {
497
- super(opts);
498
- this.taskLog = taskLog;
499
- }
500
- _write(chunk, _encoding, callback) {
501
- this.taskLog.message(`${styleText("dim", chunk.toString())}`);
502
- callback();
503
- }
504
- };
505
- /**
506
490
  * TTY logger with beautiful UI and progress indicators for local development.
507
491
  */
508
492
  const clackLogger = defineLogger({
@@ -518,7 +502,8 @@ const clackLogger = defineLogger({
518
502
  hrStart: process$1.hrtime(),
519
503
  spinner: clack.spinner(),
520
504
  isSpinning: false,
521
- activeProgress: /* @__PURE__ */ new Map()
505
+ activeProgress: /* @__PURE__ */ new Map(),
506
+ activeHookLogs: /* @__PURE__ */ new Map()
522
507
  };
523
508
  function reset() {
524
509
  for (const [_key, active] of state.activeProgress) {
@@ -534,6 +519,7 @@ const clackLogger = defineLogger({
534
519
  state.spinner = clack.spinner();
535
520
  state.isSpinning = false;
536
521
  state.activeProgress.clear();
522
+ state.activeHookLogs.clear();
537
523
  }
538
524
  function showProgressStep() {
539
525
  if (logLevel$8 <= logLevel.silent) return;
@@ -635,8 +621,10 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
635
621
  context.on("kubb:generation:start", ({ config }) => {
636
622
  reset();
637
623
  state.totalPlugins = config.plugins?.length ?? 0;
624
+ if (logLevel$8 <= logLevel.silent) return;
638
625
  const text = getMessage(["Generation started", config.name ? `for ${styleText("dim", config.name)}` : void 0].filter(Boolean).join(" "));
639
626
  clack.intro(text);
627
+ startSpinner(getMessage("Setting up plugins"));
640
628
  });
641
629
  context.on("kubb:plugin:start", ({ plugin }) => {
642
630
  if (logLevel$8 <= logLevel.silent) return;
@@ -704,38 +692,44 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
704
692
  showProgressStep();
705
693
  });
706
694
  context.on("kubb:generation:end", ({ config }) => {
695
+ stopSpinner();
707
696
  const text = getMessage(config.name ? `Generation completed for ${styleText("dim", config.name)}` : "Generation completed");
708
697
  clack.outro(text);
709
698
  });
710
699
  context.on("kubb:format:start", () => {
711
700
  if (logLevel$8 <= logLevel.silent) return;
712
- const text = getMessage("Format started");
713
- clack.intro(text);
714
- });
715
- context.on("kubb:format:end", () => {
716
- if (logLevel$8 <= logLevel.silent) return;
717
- const text = getMessage("Format completed");
718
- clack.outro(text);
701
+ clack.log.step(getMessage("Formatting"));
719
702
  });
720
703
  context.on("kubb:lint:start", () => {
721
704
  if (logLevel$8 <= logLevel.silent) return;
722
- const text = getMessage("Lint started");
723
- clack.intro(text);
705
+ clack.log.step(getMessage("Linting"));
724
706
  });
725
- context.on("kubb:lint:end", () => {
707
+ context.on("kubb:hooks:start", () => {
726
708
  if (logLevel$8 <= logLevel.silent) return;
727
- const text = getMessage("Lint completed");
728
- clack.outro(text);
709
+ clack.log.step(getMessage("Running hooks"));
729
710
  });
730
- context.on("kubb:hook:start", ({ command, args }) => {
731
- if (logLevel$8 <= logLevel.silent) return;
732
- const text = getMessage(`Hook ${styleText("dim", formatCommandWithArgs(command, args))} started`);
733
- clack.intro(text);
711
+ context.on("kubb:hook:start", ({ id, command, args }) => {
712
+ if (logLevel$8 <= logLevel.silent || !id) return;
713
+ stopSpinner();
714
+ const title = getMessage(`Running ${styleText("dim", formatCommandWithArgs(command, args))}`);
715
+ const taskLog = clack.taskLog({ title });
716
+ state.activeHookLogs.set(id, {
717
+ taskLog,
718
+ hrStart: process$1.hrtime()
719
+ });
734
720
  });
735
- context.on("kubb:hook:end", ({ command, args }) => {
736
- if (logLevel$8 <= logLevel.silent) return;
737
- const text = getMessage(`Hook ${styleText("dim", formatCommandWithArgs(command, args))} successfully executed`);
738
- clack.outro(text);
721
+ context.on("kubb:hook:end", ({ id, command, args, success, error }) => {
722
+ if (logLevel$8 <= logLevel.silent || !id) return;
723
+ const active = state.activeHookLogs.get(id);
724
+ if (!active) return;
725
+ state.activeHookLogs.delete(id);
726
+ const commandWithArgs = formatCommandWithArgs(command, args);
727
+ const duration = formatMsWithColor(getElapsedMs(active.hrStart));
728
+ if (success) active.taskLog.success(getMessage(`${styleText("dim", commandWithArgs)} completed in ${duration}`));
729
+ else {
730
+ const reason = error?.message ? ` (${error.message})` : "";
731
+ active.taskLog.error(getMessage(`${styleText("dim", commandWithArgs)} failed${reason}`), { showLog: true });
732
+ }
739
733
  });
740
734
  context.on("kubb:generation:summary", ({ config, pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
741
735
  const summary = getSummary({
@@ -766,18 +760,19 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
766
760
  context.on("kubb:lifecycle:end", () => {
767
761
  reset();
768
762
  });
769
- return (commandWithArgs) => {
763
+ return (_commandWithArgs, hookId) => {
770
764
  if (logLevel$8 <= logLevel.silent) return {
771
765
  onStdout: (s) => console.log(s),
772
766
  onStderr: (s) => console.error(s)
773
767
  };
774
- const logger = clack.taskLog({ title: getMessage(["Executing hook", logLevel$8 >= logLevel.info ? styleText("dim", commandWithArgs) : void 0].filter(Boolean).join(" ")) });
775
- const writable = new ClackWritable(logger);
768
+ const active = state.activeHookLogs.get(hookId);
769
+ if (!active) return;
770
+ const { taskLog } = active;
776
771
  return {
777
772
  stream: true,
778
- onLine: (line) => writable.write(line),
779
- onStdout: (s) => logger.message(s),
780
- onStderr: (s) => logger.error(s)
773
+ onLine: (line) => taskLog.message(styleText("dim", line)),
774
+ onStdout: (s) => taskLog.message(s),
775
+ onStderr: (s) => taskLog.message(styleText("red", s))
781
776
  };
782
777
  };
783
778
  }
@@ -905,17 +900,21 @@ const githubActionsLogger = defineLogger({
905
900
  failedPlugins: 0,
906
901
  totalFiles: 0,
907
902
  processedFiles: 0,
908
- hrStart: process.hrtime(),
909
- currentConfigs: []
903
+ hrStart: process$1.hrtime(),
904
+ currentConfigs: [],
905
+ hookStarts: /* @__PURE__ */ new Map(),
906
+ openGroupDepth: 0
910
907
  };
911
908
  function reset() {
909
+ closeAllGroups();
912
910
  state.totalPlugins = 0;
913
911
  state.completedPlugins = 0;
914
912
  state.failedPlugins = 0;
915
913
  state.totalFiles = 0;
916
914
  state.processedFiles = 0;
917
- state.hrStart = process.hrtime();
915
+ state.hrStart = process$1.hrtime();
918
916
  state.currentConfigs = [];
917
+ state.hookStarts.clear();
919
918
  }
920
919
  function showProgressStep() {
921
920
  if (logLevel$7 <= logLevel.silent) return;
@@ -927,9 +926,17 @@ const githubActionsLogger = defineLogger({
927
926
  }
928
927
  function openGroup(name) {
929
928
  console.log(`::group::${name}`);
929
+ state.openGroupDepth++;
930
930
  }
931
931
  function closeGroup(_name) {
932
932
  console.log("::endgroup::");
933
+ if (state.openGroupDepth > 0) state.openGroupDepth--;
934
+ }
935
+ function closeAllGroups() {
936
+ while (state.openGroupDepth > 0) {
937
+ console.log("::endgroup::");
938
+ state.openGroupDepth--;
939
+ }
933
940
  }
934
941
  context.on("kubb:info", ({ message, info = "" }) => {
935
942
  if (logLevel$7 <= logLevel.silent) return;
@@ -960,6 +967,7 @@ const githubActionsLogger = defineLogger({
960
967
  });
961
968
  context.on("kubb:error", ({ error }) => {
962
969
  const caused = toCause(error);
970
+ closeAllGroups();
963
971
  if (logLevel$7 <= logLevel.silent) return;
964
972
  const message = error.message || String(error);
965
973
  console.error(`::error::${message}`);
@@ -977,6 +985,9 @@ const githubActionsLogger = defineLogger({
977
985
  console.log(styleText("yellow", `Kubb ${version} 🧩`));
978
986
  reset();
979
987
  });
988
+ context.on("kubb:version:new", ({ currentVersion, latestVersion }) => {
989
+ console.log(`::notice::Update available for Kubb: v${currentVersion} → v${latestVersion}. Run \`npm install -g @kubb/cli\` to update.`);
990
+ });
980
991
  context.on("kubb:config:start", () => {
981
992
  if (logLevel$7 <= logLevel.silent) return;
982
993
  const text = getMessage("Configuration started");
@@ -1061,18 +1072,35 @@ const githubActionsLogger = defineLogger({
1061
1072
  console.log(text);
1062
1073
  if (state.currentConfigs.length === 1) closeGroup("Linting");
1063
1074
  });
1064
- context.on("kubb:hook:start", ({ command, args }) => {
1075
+ context.on("kubb:hooks:start", () => {
1076
+ if (logLevel$7 <= logLevel.silent) return;
1077
+ if (state.currentConfigs.length === 1) openGroup("Hooks");
1078
+ console.log(getMessage("Hooks started"));
1079
+ });
1080
+ context.on("kubb:hooks:end", () => {
1065
1081
  if (logLevel$7 <= logLevel.silent) return;
1082
+ console.log(getMessage("Hooks completed"));
1083
+ if (state.currentConfigs.length === 1) closeGroup("Hooks");
1084
+ });
1085
+ context.on("kubb:hook:start", ({ id, command, args }) => {
1086
+ if (logLevel$7 <= logLevel.silent) return;
1087
+ if (id) state.hookStarts.set(id, process$1.hrtime());
1066
1088
  const commandWithArgs = formatCommandWithArgs(command, args);
1067
1089
  const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} started`);
1068
1090
  if (state.currentConfigs.length === 1) openGroup(`Hook ${commandWithArgs}`);
1069
1091
  console.log(text);
1070
1092
  });
1071
- context.on("kubb:hook:end", ({ command, args }) => {
1093
+ context.on("kubb:hook:end", ({ id, command, args, success, error }) => {
1072
1094
  if (logLevel$7 <= logLevel.silent) return;
1095
+ const hrStart = id ? state.hookStarts.get(id) : void 0;
1096
+ if (id) state.hookStarts.delete(id);
1097
+ const durationStr = hrStart ? ` in ${formatMsWithColor(getElapsedMs(hrStart))}` : "";
1073
1098
  const commandWithArgs = formatCommandWithArgs(command, args);
1074
- const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} completed`);
1075
- console.log(text);
1099
+ if (success) console.log(getMessage(`${styleText("green", "✓")} Hook ${styleText("dim", commandWithArgs)} completed${durationStr}`));
1100
+ else {
1101
+ const reason = error?.message ? ` (${error.message})` : "";
1102
+ console.log(`::error::Hook ${commandWithArgs} failed${durationStr}${reason}`);
1103
+ }
1076
1104
  if (state.currentConfigs.length === 1) closeGroup(`Hook ${commandWithArgs}`);
1077
1105
  });
1078
1106
  context.on("kubb:generation:summary", ({ config, status, hrStart, failedPlugins }) => {
@@ -1086,7 +1114,7 @@ const githubActionsLogger = defineLogger({
1086
1114
  context.on("kubb:lifecycle:end", () => {
1087
1115
  reset();
1088
1116
  });
1089
- return (_commandWithArgs) => ({
1117
+ return (_commandWithArgs, _hookId) => ({
1090
1118
  onStdout: logLevel$7 > logLevel.silent ? (s) => console.log(s) : void 0,
1091
1119
  onStderr: logLevel$7 > logLevel.silent ? (s) => console.error(`::error::${s}`) : void 0
1092
1120
  });
@@ -1101,6 +1129,7 @@ const plainLogger = defineLogger({
1101
1129
  name: "plain",
1102
1130
  install(context, options) {
1103
1131
  const logLevel$6 = options?.logLevel ?? logLevel.info;
1132
+ const hookStarts = /* @__PURE__ */ new Map();
1104
1133
  function getMessage(message) {
1105
1134
  return formatMessage(message, logLevel$6);
1106
1135
  }
@@ -1145,8 +1174,12 @@ const plainLogger = defineLogger({
1145
1174
  }
1146
1175
  }
1147
1176
  });
1148
- context.on("kubb:lifecycle:start", () => {
1149
- console.log("Kubb CLI 🧩");
1177
+ context.on("kubb:lifecycle:start", ({ version }) => {
1178
+ console.log(`Kubb CLI v${version}`);
1179
+ });
1180
+ context.on("kubb:version:new", ({ currentVersion, latestVersion }) => {
1181
+ if (logLevel$6 <= logLevel.silent) return;
1182
+ console.log(getMessage(`Update available: v${currentVersion} → v${latestVersion}. Run \`npm install -g @kubb/cli\` to update.`));
1150
1183
  });
1151
1184
  context.on("kubb:config:start", () => {
1152
1185
  if (logLevel$6 <= logLevel.silent) return;
@@ -1212,15 +1245,31 @@ const plainLogger = defineLogger({
1212
1245
  const text = getMessage("Lint completed");
1213
1246
  console.log(text);
1214
1247
  });
1215
- context.on("kubb:hook:start", ({ command, args }) => {
1248
+ context.on("kubb:hooks:start", () => {
1216
1249
  if (logLevel$6 <= logLevel.silent) return;
1217
- const text = getMessage(`Hook ${formatCommandWithArgs(command, args)} started`);
1218
- console.log(text);
1250
+ console.log(getMessage("Hooks started"));
1219
1251
  });
1220
- context.on("kubb:hook:end", ({ command, args }) => {
1252
+ context.on("kubb:hooks:end", () => {
1221
1253
  if (logLevel$6 <= logLevel.silent) return;
1222
- const text = getMessage(`Hook ${formatCommandWithArgs(command, args)} completed`);
1223
- console.log(text);
1254
+ console.log(getMessage("Hooks completed"));
1255
+ });
1256
+ context.on("kubb:hook:start", ({ id, command, args }) => {
1257
+ if (logLevel$6 <= logLevel.silent) return;
1258
+ if (id) hookStarts.set(id, process$1.hrtime());
1259
+ const commandWithArgs = formatCommandWithArgs(command, args);
1260
+ console.log(getMessage(`Hook ${commandWithArgs} started`));
1261
+ });
1262
+ context.on("kubb:hook:end", ({ id, command, args, success, error }) => {
1263
+ if (logLevel$6 <= logLevel.silent) return;
1264
+ const hrStart = id ? hookStarts.get(id) : void 0;
1265
+ if (id) hookStarts.delete(id);
1266
+ const durationStr = hrStart ? ` in ${formatMs(getElapsedMs(hrStart))}` : "";
1267
+ const commandWithArgs = formatCommandWithArgs(command, args);
1268
+ if (success) console.log(getMessage(`✓ Hook ${commandWithArgs} completed${durationStr}`));
1269
+ else {
1270
+ const reason = error?.message ? ` (${error.message})` : "";
1271
+ console.log(getMessage(`✗ Hook ${commandWithArgs} failed${durationStr}${reason}`));
1272
+ }
1224
1273
  });
1225
1274
  context.on("kubb:generation:summary", ({ config, pluginTimings, status, hrStart, failedPlugins, filesCreated }) => {
1226
1275
  const summary = getSummary({
@@ -1235,7 +1284,7 @@ const plainLogger = defineLogger({
1235
1284
  console.log(summary.join("\n"));
1236
1285
  console.log(SUMMARY_SEPARATOR);
1237
1286
  });
1238
- return (_commandWithArgs) => ({
1287
+ return (_commandWithArgs, _hookId) => ({
1239
1288
  onStdout: logLevel$6 > logLevel.silent ? (s) => console.log(s) : void 0,
1240
1289
  onStderr: logLevel$6 > logLevel.silent ? (s) => console.error(s) : void 0
1241
1290
  });
@@ -1422,7 +1471,7 @@ async function executeHooks({ configHooks, hooks, makeSink }) {
1422
1471
  command: cmd,
1423
1472
  args
1424
1473
  });
1425
- const { stream = false, onLine, onStdout, onStderr } = makeSink?.(commandWithArgs) ?? {};
1474
+ const { stream = false, onLine, onStdout, onStderr } = makeSink?.(commandWithArgs, hookId) ?? {};
1426
1475
  await runHook({
1427
1476
  id: hookId,
1428
1477
  command: cmd,
@@ -1520,7 +1569,7 @@ function waitForHookEnd(hooks, hookId, onSuccess, fallbackErrorMessage) {
1520
1569
  hooks.on("kubb:hook:end", handler);
1521
1570
  });
1522
1571
  }
1523
- async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefix, noToolMessage, configName, outputPath, logLevel: logLevel$1, hooks, onStart, onEnd }) {
1572
+ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefix, noToolMessage, configName, outputPath, logLevel: logLevel$1, hooks, makeSink, onStart, onEnd }) {
1524
1573
  await onStart();
1525
1574
  let resolvedTool = toolValue;
1526
1575
  if (resolvedTool === "auto") {
@@ -1542,20 +1591,26 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1542
1591
  ].filter(Boolean).join(" ");
1543
1592
  try {
1544
1593
  const hookArgs = toolConfig.args(outputPath);
1594
+ const commandWithArgs = [toolConfig.command, ...hookArgs].join(" ");
1545
1595
  const hookEndPromise = waitForHookEnd(hooks, hookId, () => hooks.emit("kubb:success", { message: successMessage }), toolConfig.errorMessage);
1546
1596
  await hooks.emit("kubb:hook:start", {
1547
1597
  id: hookId,
1548
1598
  command: toolConfig.command,
1549
1599
  args: hookArgs
1550
1600
  });
1601
+ const { stream = false, onLine, onStdout, onStderr } = makeSink?.(commandWithArgs, hookId) ?? {};
1551
1602
  runHook({
1552
1603
  id: hookId,
1553
1604
  command: toolConfig.command,
1554
1605
  args: hookArgs,
1555
- commandWithArgs: [toolConfig.command, ...hookArgs].join(" "),
1606
+ commandWithArgs,
1556
1607
  context: hooks,
1557
- stream: false,
1558
- sink: {}
1608
+ stream,
1609
+ sink: {
1610
+ onLine,
1611
+ onStdout,
1612
+ onStderr
1613
+ }
1559
1614
  }).catch(() => {});
1560
1615
  await hookEndPromise;
1561
1616
  } catch (caughtError) {
@@ -1580,12 +1635,12 @@ async function generate(options) {
1580
1635
  ...options.config.output
1581
1636
  };
1582
1637
  const kubb = createKubb(config, { hooks });
1583
- await kubb.setup();
1584
1638
  await hooks.emit("kubb:generation:start", { config });
1585
1639
  await hooks.emit("kubb:info", {
1586
1640
  message: config.name ? `Setup generation ${styleText("bold", config.name)}` : "Setup generation",
1587
1641
  info: inputPath
1588
1642
  });
1643
+ await kubb.setup();
1589
1644
  await hooks.emit("kubb:info", {
1590
1645
  message: config.name ? `Build generation ${styleText("bold", config.name)}` : "Build generation",
1591
1646
  info: inputPath
@@ -1655,7 +1710,8 @@ async function generate(options) {
1655
1710
  configName: config.name,
1656
1711
  outputPath,
1657
1712
  logLevel: logLevel$2,
1658
- hooks
1713
+ hooks,
1714
+ makeSink
1659
1715
  });
1660
1716
  if (config.hooks) {
1661
1717
  await hooks.emit("kubb:hooks:start");
@@ -1696,14 +1752,15 @@ async function run({ input, configPath, logLevel: logLevelKey, watch }) {
1696
1752
  const logLevel$3 = logLevel[logLevelKey] ?? logLevel.info;
1697
1753
  const hooks = new AsyncEventEmitter();
1698
1754
  const makeSink = await setupLogger(hooks, { logLevel: logLevel$3 });
1755
+ await hooks.emit("kubb:lifecycle:start", { version });
1699
1756
  await checkForUpdate(hooks);
1700
1757
  try {
1758
+ await hooks.emit("kubb:config:start");
1701
1759
  const { configs, configPath: resolvedConfigPath } = await getConfigs({
1702
1760
  configPath,
1703
1761
  input
1704
1762
  });
1705
1763
  const relativeConfigPath = path.relative(process$1.cwd(), resolvedConfigPath);
1706
- await hooks.emit("kubb:config:start");
1707
1764
  await hooks.emit("kubb:info", {
1708
1765
  message: "Config loaded",
1709
1766
  info: relativeConfigPath
@@ -1713,10 +1770,8 @@ async function run({ input, configPath, logLevel: logLevelKey, watch }) {
1713
1770
  info: relativeConfigPath
1714
1771
  });
1715
1772
  await hooks.emit("kubb:config:end", { configs });
1716
- await hooks.emit("kubb:lifecycle:start", { version });
1717
1773
  let anyFailed = false;
1718
1774
  for (const config of configs) if (isInputPath(config) && watch) await startWatcher([input || config.input.path], async (paths) => {
1719
- hooks.removeAll();
1720
1775
  await generate({
1721
1776
  input,
1722
1777
  config,
@@ -1751,4 +1806,4 @@ async function run({ input, configPath, logLevel: logLevelKey, watch }) {
1751
1806
  //#endregion
1752
1807
  export { run };
1753
1808
 
1754
- //# sourceMappingURL=run-BNvaRFvz.js.map
1809
+ //# sourceMappingURL=run-BvsacB4B.js.map