@kubb/cli 5.0.0-beta.6 → 5.0.0-beta.7

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 (117) hide show
  1. package/README.md +177 -26
  2. package/dist/{agent-BJEvbSiP.js → agent-DN7o8nlE.js} +7 -7
  3. package/dist/agent-DN7o8nlE.js.map +1 -0
  4. package/dist/{agent-CXNO6dgj.cjs → agent-Fm9_8BBH.cjs} +5 -5
  5. package/dist/agent-Fm9_8BBH.cjs.map +1 -0
  6. package/dist/{chunk--u3MIqq1.js → chunk-BvFE5Tac.js} +1 -0
  7. package/dist/{constants-BPJBMT_6.js → constants-B2JTeRBb.js} +1 -4
  8. package/dist/{constants-BPJBMT_6.js.map → constants-B2JTeRBb.js.map} +1 -1
  9. package/dist/{constants-Rcaqzyd-.cjs → constants-BINTA5VZ.cjs} +1 -4
  10. package/dist/{constants-Rcaqzyd-.cjs.map → constants-BINTA5VZ.cjs.map} +1 -1
  11. package/dist/{define-Ctii4bel.js → define-m_fp-Aqm.js} +2 -2
  12. package/dist/{define-Ctii4bel.js.map → define-m_fp-Aqm.js.map} +1 -1
  13. package/dist/{errors-CjPmyZHy.js → errors-CINO1EIv.js} +2 -2
  14. package/dist/{errors-CjPmyZHy.js.map → errors-CINO1EIv.js.map} +1 -1
  15. package/dist/{generate-BmulGxIM.js → generate-BY-juRdH.js} +5 -5
  16. package/dist/{generate-BmulGxIM.js.map → generate-BY-juRdH.js.map} +1 -1
  17. package/dist/{generate-BB2Q7I9s.cjs → generate-Bod9YCbF.cjs} +3 -3
  18. package/dist/{generate-BB2Q7I9s.cjs.map → generate-Bod9YCbF.cjs.map} +1 -1
  19. package/dist/index.cjs +9 -9
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +11 -11
  23. package/dist/index.js.map +1 -1
  24. package/dist/{init-Dpg8e1HN.cjs → init-BIkZU6mB.cjs} +4 -4
  25. package/dist/{init-Dpg8e1HN.cjs.map → init-BIkZU6mB.cjs.map} +1 -1
  26. package/dist/{init-BTp9if7K.js → init-Cs3Fp6nN.js} +6 -6
  27. package/dist/{init-BTp9if7K.js.map → init-Cs3Fp6nN.js.map} +1 -1
  28. package/dist/{mcp-C9RoU-Dg.js → mcp-BSNulBcC.js} +6 -6
  29. package/dist/{mcp-C9RoU-Dg.js.map → mcp-BSNulBcC.js.map} +1 -1
  30. package/dist/{mcp-wpl6sYYR.cjs → mcp-DcSrFhhP.cjs} +4 -4
  31. package/dist/{mcp-wpl6sYYR.cjs.map → mcp-DcSrFhhP.cjs.map} +1 -1
  32. package/dist/package-D5wmvFl4.js +6 -0
  33. package/dist/package-D5wmvFl4.js.map +1 -0
  34. package/dist/{package-iheSdfas.cjs → package-DrUndPET.cjs} +2 -2
  35. package/dist/package-DrUndPET.cjs.map +1 -0
  36. package/dist/{generate-DAsdUw3z.js → run-BAJubgdA.js} +298 -315
  37. package/dist/run-BAJubgdA.js.map +1 -0
  38. package/dist/{agent-VXKxLCho.js → run-BzpYYOQs.js} +46 -43
  39. package/dist/run-BzpYYOQs.js.map +1 -0
  40. package/dist/{validate-k9s_hFah.js → run-CCZ24VKk.js} +25 -20
  41. package/dist/run-CCZ24VKk.js.map +1 -0
  42. package/dist/{init-DCqcEq86.js → run-CF97BWVa.js} +77 -68
  43. package/dist/run-CF97BWVa.js.map +1 -0
  44. package/dist/{validate-BU4fPTMc.cjs → run-CQbj3ley.cjs} +23 -18
  45. package/dist/run-CQbj3ley.cjs.map +1 -0
  46. package/dist/{generate-B_p5dl68.cjs → run-CqKd6JNc.cjs} +295 -312
  47. package/dist/run-CqKd6JNc.cjs.map +1 -0
  48. package/dist/{mcp-DNUw8nqb.js → run-D0hmRpHy.js} +23 -23
  49. package/dist/run-D0hmRpHy.js.map +1 -0
  50. package/dist/{agent-D9CKYh4K.cjs → run-DwdAwnLG.cjs} +44 -41
  51. package/dist/run-DwdAwnLG.cjs.map +1 -0
  52. package/dist/{mcp-D1llTaRM.cjs → run-Lr0Ctnu0.cjs} +21 -21
  53. package/dist/run-Lr0Ctnu0.cjs.map +1 -0
  54. package/dist/{init-CJ80lKSP.cjs → run-YsoCk5we.cjs} +75 -66
  55. package/dist/run-YsoCk5we.cjs.map +1 -0
  56. package/dist/{shell-DLzN4fRo.js → shell-CN6DNqeC.js} +2 -2
  57. package/dist/{shell-DLzN4fRo.js.map → shell-CN6DNqeC.js.map} +1 -1
  58. package/dist/{telemetry-BLX0NzRk.cjs → telemetry-B2iWkY5e.cjs} +5 -7
  59. package/dist/telemetry-B2iWkY5e.cjs.map +1 -0
  60. package/dist/{telemetry-juq4QBf7.js → telemetry-BkektVz6.js} +6 -8
  61. package/dist/telemetry-BkektVz6.js.map +1 -0
  62. package/dist/{validate-DIDBROB2.cjs → validate-Bfpf_UIh.cjs} +4 -4
  63. package/dist/{validate-DIDBROB2.cjs.map → validate-Bfpf_UIh.cjs.map} +1 -1
  64. package/dist/{validate-BfJoCxrC.js → validate-lbUkWQ5o.js} +6 -6
  65. package/dist/{validate-BfJoCxrC.js.map → validate-lbUkWQ5o.js.map} +1 -1
  66. package/package.json +7 -12
  67. package/src/commands/agent/start.ts +2 -2
  68. package/src/commands/generate.ts +2 -2
  69. package/src/commands/init.ts +2 -2
  70. package/src/commands/mcp.ts +2 -2
  71. package/src/commands/validate.ts +2 -2
  72. package/src/constants.ts +0 -4
  73. package/src/index.ts +5 -3
  74. package/src/loggers/clackLogger.ts +45 -43
  75. package/src/loggers/fileSystemLogger.ts +11 -1
  76. package/src/loggers/githubActionsLogger.ts +13 -25
  77. package/src/loggers/plainLogger.ts +12 -23
  78. package/src/loggers/types.ts +6 -0
  79. package/src/loggers/utils.ts +155 -9
  80. package/src/runners/agent/run.ts +113 -0
  81. package/src/runners/agent/utils.ts +98 -0
  82. package/src/runners/generate/run.ts +276 -0
  83. package/src/runners/generate/utils.ts +209 -0
  84. package/src/runners/{init.ts → init/run.ts} +70 -66
  85. package/src/{utils/packageManager.ts → runners/init/utils.ts} +10 -0
  86. package/src/runners/mcp/run.ts +55 -0
  87. package/src/runners/{validate.ts → validate/run.ts} +25 -20
  88. package/src/{utils/telemetry.ts → telemetry.ts} +12 -5
  89. package/dist/agent-BJEvbSiP.js.map +0 -1
  90. package/dist/agent-CXNO6dgj.cjs.map +0 -1
  91. package/dist/agent-D9CKYh4K.cjs.map +0 -1
  92. package/dist/agent-VXKxLCho.js.map +0 -1
  93. package/dist/generate-B_p5dl68.cjs.map +0 -1
  94. package/dist/generate-DAsdUw3z.js.map +0 -1
  95. package/dist/init-CJ80lKSP.cjs.map +0 -1
  96. package/dist/init-DCqcEq86.js.map +0 -1
  97. package/dist/mcp-D1llTaRM.cjs.map +0 -1
  98. package/dist/mcp-DNUw8nqb.js.map +0 -1
  99. package/dist/package-iheSdfas.cjs.map +0 -1
  100. package/dist/package-vLafMWCe.js +0 -6
  101. package/dist/package-vLafMWCe.js.map +0 -1
  102. package/dist/telemetry-BLX0NzRk.cjs.map +0 -1
  103. package/dist/telemetry-juq4QBf7.js.map +0 -1
  104. package/dist/validate-BU4fPTMc.cjs.map +0 -1
  105. package/dist/validate-k9s_hFah.js.map +0 -1
  106. package/src/runners/agent.ts +0 -155
  107. package/src/runners/generate.ts +0 -333
  108. package/src/runners/mcp.ts +0 -56
  109. package/src/types.ts +0 -11
  110. package/src/utils/Writables.ts +0 -17
  111. package/src/utils/executeHooks.ts +0 -45
  112. package/src/utils/flags.ts +0 -9
  113. package/src/utils/getConfig.ts +0 -10
  114. package/src/utils/getCosmiConfig.ts +0 -75
  115. package/src/utils/getSummary.ts +0 -68
  116. package/src/utils/runHook.ts +0 -91
  117. package/src/utils/watcher.ts +0 -19
@@ -1,9 +1,9 @@
1
- import "./chunk--u3MIqq1.js";
2
- import { n as toCause, r as toError } from "./errors-CjPmyZHy.js";
3
- import { a as canUseTTY, i as executeIfOnline, o as isGitHubActions, r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-juq4QBf7.js";
4
- import { n as tokenize } from "./shell-DLzN4fRo.js";
5
- import { t as version } from "./package-vLafMWCe.js";
6
- import { a as WATCHER_IGNORED_PATHS, i as SUMMARY_SEPARATOR, t as KUBB_NPM_PACKAGE_URL } from "./constants-BPJBMT_6.js";
1
+ import "./chunk-BvFE5Tac.js";
2
+ import { n as toCause, r as toError } from "./errors-CINO1EIv.js";
3
+ import { a as canUseTTY, i as executeIfOnline, o as isGitHubActions, r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-BkektVz6.js";
4
+ import { n as tokenize } from "./shell-CN6DNqeC.js";
5
+ import { t as version } from "./package-D5wmvFl4.js";
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";
9
9
  import { createHash } from "node:crypto";
@@ -14,10 +14,10 @@ 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 { NonZeroExitError, x } from "tinyexec";
18
17
  import { Writable } from "node:stream";
19
18
  import { cosmiconfig } from "cosmiconfig";
20
19
  import { createJiti } from "jiti";
20
+ import { NonZeroExitError, x } from "tinyexec";
21
21
  //#region ../../internals/utils/src/asyncEventEmitter.ts
22
22
  /**
23
23
  * Typed `EventEmitter` that awaits all async listeners before resolving.
@@ -486,100 +486,11 @@ async function detectLinter() {
486
486
  return null;
487
487
  }
488
488
  //#endregion
489
- //#region src/utils/getSummary.ts
490
- function getSummary({ failedPlugins, filesCreated, status, hrStart, config, pluginTimings }) {
491
- const duration = formatHrtime(hrStart);
492
- const pluginsCount = config.plugins?.length ?? 0;
493
- const successCount = pluginsCount - failedPlugins.size;
494
- const meta = {
495
- plugins: status === "success" ? `${styleText("green", `${successCount} successful`)}, ${pluginsCount} total` : `${styleText("green", `${successCount} successful`)}, ${styleText("red", `${failedPlugins.size} failed`)}, ${pluginsCount} total`,
496
- pluginsFailed: status === "failed" ? [...failedPlugins].map(({ plugin }) => randomCliColor(plugin.name)).join(", ") : void 0,
497
- filesCreated,
498
- time: styleText("green", duration),
499
- output: path.resolve(config.root, config.output.path)
500
- };
501
- const labels = {
502
- plugins: "Plugins:",
503
- failed: "Failed:",
504
- generated: "Generated:",
505
- pluginTimings: "Plugin Timings:",
506
- output: "Output:"
507
- };
508
- const maxLength = Math.max(0, ...[...Object.values(labels), ...pluginTimings ? Array.from(pluginTimings.keys()) : []].map((s) => s.length));
509
- const summaryLines = [];
510
- summaryLines.push(`${labels.plugins.padEnd(maxLength + 2)} ${meta.plugins}`);
511
- if (meta.pluginsFailed) summaryLines.push(`${labels.failed.padEnd(maxLength + 2)} ${meta.pluginsFailed}`);
512
- summaryLines.push(`${labels.generated.padEnd(maxLength + 2)} ${meta.filesCreated} files in ${meta.time}`);
513
- if (pluginTimings && pluginTimings.size > 0) {
514
- const sortedTimings = Array.from(pluginTimings.entries()).sort((a, b) => b[1] - a[1]);
515
- summaryLines.push(`${labels.pluginTimings}`);
516
- sortedTimings.forEach(([name, time]) => {
517
- const timeStr = time >= 1e3 ? `${(time / 1e3).toFixed(2)}s` : `${Math.round(time)}ms`;
518
- const barLength = Math.min(Math.ceil(time / 100), 10);
519
- const bar = styleText("dim", "█".repeat(barLength));
520
- summaryLines.push(`${styleText("dim", "•")} ${name.padEnd(maxLength + 1)}${bar} ${timeStr}`);
521
- });
522
- }
523
- summaryLines.push(`${labels.output.padEnd(maxLength + 2)} ${meta.output}`);
524
- return summaryLines;
525
- }
526
- //#endregion
527
- //#region src/utils/runHook.ts
489
+ //#region src/loggers/clackLogger.ts
528
490
  /**
529
- * Executes a hook command, emits debug and completion events, and forwards output to an optional sink.
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.
530
493
  */
531
- async function runHook({ id, command, args, commandWithArgs, context, stream = false, sink }) {
532
- try {
533
- const proc = x(command, [...args ?? []], {
534
- nodeOptions: { detached: process.platform !== "win32" },
535
- throwOnError: true
536
- });
537
- if (stream && sink?.onLine) for await (const line of proc) sink.onLine(line);
538
- const result = await proc;
539
- await context.emit("kubb:debug", {
540
- date: /* @__PURE__ */ new Date(),
541
- logs: [result.stdout.trimEnd()]
542
- });
543
- await context.emit("kubb:hook:end", {
544
- command,
545
- args,
546
- id,
547
- success: true,
548
- error: null
549
- });
550
- } catch (err) {
551
- if (!(err instanceof NonZeroExitError)) {
552
- await context.emit("kubb:hook:end", {
553
- command,
554
- args,
555
- id,
556
- success: false,
557
- error: toError(err)
558
- });
559
- await context.emit("kubb:error", { error: toError(err) });
560
- return;
561
- }
562
- const stderr = err.output?.stderr ?? "";
563
- const stdout = err.output?.stdout ?? "";
564
- await context.emit("kubb:debug", {
565
- date: /* @__PURE__ */ new Date(),
566
- logs: [stdout, stderr].filter(Boolean)
567
- });
568
- if (stderr) sink?.onStderr?.(stderr);
569
- if (stdout) sink?.onStdout?.(stdout);
570
- const errorMessage = /* @__PURE__ */ new Error(`Hook execute failed: ${commandWithArgs}`);
571
- await context.emit("kubb:hook:end", {
572
- command,
573
- args,
574
- id,
575
- success: false,
576
- error: errorMessage
577
- });
578
- await context.emit("kubb:error", { error: errorMessage });
579
- }
580
- }
581
- //#endregion
582
- //#region src/utils/Writables.ts
583
494
  var ClackWritable = class extends Writable {
584
495
  taskLog;
585
496
  constructor(taskLog, opts) {
@@ -591,8 +502,6 @@ var ClackWritable = class extends Writable {
591
502
  callback();
592
503
  }
593
504
  };
594
- //#endregion
595
- //#region src/loggers/clackLogger.ts
596
505
  /**
597
506
  * TTY logger with beautiful UI and progress indicators for local development.
598
507
  */
@@ -818,40 +727,10 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
818
727
  const text = getMessage("Lint completed");
819
728
  clack.outro(text);
820
729
  });
821
- context.on("kubb:hook:start", async ({ id, command, args }) => {
822
- const commandWithArgs = formatCommandWithArgs(command, args);
823
- const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} started`);
824
- if (!id) return;
825
- if (logLevel$8 <= logLevel.silent) {
826
- await runHook({
827
- id,
828
- command,
829
- args,
830
- commandWithArgs,
831
- context,
832
- sink: {
833
- onStderr: (s) => console.error(s),
834
- onStdout: (s) => console.log(s)
835
- }
836
- });
837
- return;
838
- }
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`);
839
733
  clack.intro(text);
840
- const logger = clack.taskLog({ title: getMessage(["Executing hook", logLevel$8 >= logLevel.info ? styleText("dim", commandWithArgs) : void 0].filter(Boolean).join(" ")) });
841
- const writable = new ClackWritable(logger);
842
- await runHook({
843
- id,
844
- command,
845
- args,
846
- commandWithArgs,
847
- context,
848
- stream: true,
849
- sink: {
850
- onLine: (line) => writable.write(line),
851
- onStderr: (s) => logger.error(s),
852
- onStdout: (s) => logger.message(s)
853
- }
854
- });
855
734
  });
856
735
  context.on("kubb:hook:end", ({ command, args }) => {
857
736
  if (logLevel$8 <= logLevel.silent) return;
@@ -887,13 +766,28 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
887
766
  context.on("kubb:lifecycle:end", () => {
888
767
  reset();
889
768
  });
769
+ return (commandWithArgs) => {
770
+ if (logLevel$8 <= logLevel.silent) return {
771
+ onStdout: (s) => console.log(s),
772
+ onStderr: (s) => console.error(s)
773
+ };
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);
776
+ return {
777
+ stream: true,
778
+ onLine: (line) => writable.write(line),
779
+ onStdout: (s) => logger.message(s),
780
+ onStderr: (s) => logger.error(s)
781
+ };
782
+ };
890
783
  }
891
784
  });
892
785
  //#endregion
893
786
  //#region src/loggers/fileSystemLogger.ts
894
787
  /**
895
788
  * FileSystem logger that captures debug events and writes them to `.kubb` directory files.
896
- * Note: Logs write on `lifecycle:end` or process exit. Cached logs may be lost if the process crashes before these events.
789
+ *
790
+ * @note Logs are written on `kubb:lifecycle:end` or process exit. Cached logs may be lost if the process crashes before either event.
897
791
  */
898
792
  const fileSystemLogger = defineLogger({
899
793
  name: "filesystem",
@@ -1164,25 +1058,12 @@ const githubActionsLogger = defineLogger({
1164
1058
  console.log(text);
1165
1059
  if (state.currentConfigs.length === 1) closeGroup("Linting");
1166
1060
  });
1167
- context.on("kubb:hook:start", async ({ id, command, args }) => {
1061
+ context.on("kubb:hook:start", ({ command, args }) => {
1062
+ if (logLevel$7 <= logLevel.silent) return;
1168
1063
  const commandWithArgs = formatCommandWithArgs(command, args);
1169
1064
  const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} started`);
1170
- if (logLevel$7 > logLevel.silent) {
1171
- if (state.currentConfigs.length === 1) openGroup(`Hook ${commandWithArgs}`);
1172
- console.log(text);
1173
- }
1174
- if (!id) return;
1175
- await runHook({
1176
- id,
1177
- command,
1178
- args,
1179
- commandWithArgs,
1180
- context,
1181
- sink: {
1182
- onStdout: logLevel$7 > logLevel.silent ? (s) => console.log(s) : void 0,
1183
- onStderr: logLevel$7 > logLevel.silent ? (s) => console.error(`::error::${s}`) : void 0
1184
- }
1185
- });
1065
+ if (state.currentConfigs.length === 1) openGroup(`Hook ${commandWithArgs}`);
1066
+ console.log(text);
1186
1067
  });
1187
1068
  context.on("kubb:hook:end", ({ command, args }) => {
1188
1069
  if (logLevel$7 <= logLevel.silent) return;
@@ -1202,6 +1083,10 @@ const githubActionsLogger = defineLogger({
1202
1083
  context.on("kubb:lifecycle:end", () => {
1203
1084
  reset();
1204
1085
  });
1086
+ return (_commandWithArgs) => ({
1087
+ onStdout: logLevel$7 > logLevel.silent ? (s) => console.log(s) : void 0,
1088
+ onStderr: logLevel$7 > logLevel.silent ? (s) => console.error(`::error::${s}`) : void 0
1089
+ });
1205
1090
  }
1206
1091
  });
1207
1092
  //#endregion
@@ -1324,22 +1209,10 @@ const plainLogger = defineLogger({
1324
1209
  const text = getMessage("Lint completed");
1325
1210
  console.log(text);
1326
1211
  });
1327
- context.on("kubb:hook:start", async ({ id, command, args }) => {
1328
- const commandWithArgs = formatCommandWithArgs(command, args);
1329
- const text = getMessage(`Hook ${commandWithArgs} started`);
1330
- if (logLevel$6 > logLevel.silent) console.log(text);
1331
- if (!id) return;
1332
- await runHook({
1333
- id,
1334
- command,
1335
- args,
1336
- commandWithArgs,
1337
- context,
1338
- sink: {
1339
- onStdout: logLevel$6 > logLevel.silent ? (s) => console.log(s) : void 0,
1340
- onStderr: logLevel$6 > logLevel.silent ? (s) => console.error(s) : void 0
1341
- }
1342
- });
1212
+ context.on("kubb:hook:start", ({ command, args }) => {
1213
+ if (logLevel$6 <= logLevel.silent) return;
1214
+ const text = getMessage(`Hook ${formatCommandWithArgs(command, args)} started`);
1215
+ console.log(text);
1343
1216
  });
1344
1217
  context.on("kubb:hook:end", ({ command, args }) => {
1345
1218
  if (logLevel$6 <= logLevel.silent) return;
@@ -1359,6 +1232,10 @@ const plainLogger = defineLogger({
1359
1232
  console.log(summary.join("\n"));
1360
1233
  console.log(SUMMARY_SEPARATOR);
1361
1234
  });
1235
+ return (_commandWithArgs) => ({
1236
+ onStdout: logLevel$6 > logLevel.silent ? (s) => console.log(s) : void 0,
1237
+ onStderr: logLevel$6 > logLevel.silent ? (s) => console.error(s) : void 0
1238
+ });
1362
1239
  }
1363
1240
  });
1364
1241
  //#endregion
@@ -1413,49 +1290,52 @@ async function setupLogger(context, { logLevel: logLevel$5 }) {
1413
1290
  const type = detectLogger();
1414
1291
  const logger = logMapper[type];
1415
1292
  if (!logger) throw new Error(`Unknown adapter type: ${type}`);
1416
- const cleanup = await logger.install(context, { logLevel: logLevel$5 });
1293
+ const makeSink = await logger.install(context, { logLevel: logLevel$5 });
1417
1294
  if (logLevel$5 >= logLevel.debug) await fileSystemLogger.install(context, { logLevel: logLevel$5 });
1418
- return cleanup;
1295
+ return typeof makeSink === "function" ? makeSink : void 0;
1419
1296
  }
1420
- //#endregion
1421
- //#region src/utils/executeHooks.ts
1422
- async function executeHooks({ configHooks, hooks }) {
1423
- const commands = Array.isArray(configHooks.done) ? configHooks.done : [configHooks.done].filter(Boolean);
1424
- for (const command of commands) {
1425
- const [cmd, ...args] = tokenize(command);
1426
- if (!cmd) continue;
1427
- const hookId = createHash("sha256").update(command).digest("hex");
1428
- const hookEndPromise = new Promise((resolve, reject) => {
1429
- const handler = (ctx) => {
1430
- if (ctx.id !== hookId) return;
1431
- hooks.off("kubb:hook:end", handler);
1432
- if (!ctx.success) {
1433
- reject(ctx.error ?? /* @__PURE__ */ new Error(`Hook failed: ${command}`));
1434
- return;
1435
- }
1436
- hooks.emit("kubb:success", { message: `${styleText("dim", command)} successfully executed` }).then(resolve).catch(reject);
1437
- };
1438
- hooks.on("kubb:hook:end", handler);
1439
- });
1440
- await hooks.emit("kubb:hook:start", {
1441
- id: hookId,
1442
- command: cmd,
1443
- args
1297
+ /**
1298
+ * Builds the generation summary lines rendered in the end-of-run box.
1299
+ * Returns an array of styled strings, one per summary row.
1300
+ */
1301
+ function getSummary({ failedPlugins, filesCreated, status, hrStart, config, pluginTimings }) {
1302
+ const duration = formatHrtime(hrStart);
1303
+ const pluginsCount = config.plugins?.length ?? 0;
1304
+ const successCount = pluginsCount - failedPlugins.size;
1305
+ const meta = {
1306
+ plugins: status === "success" ? `${styleText("green", `${successCount} successful`)}, ${pluginsCount} total` : `${styleText("green", `${successCount} successful`)}, ${styleText("red", `${failedPlugins.size} failed`)}, ${pluginsCount} total`,
1307
+ pluginsFailed: status === "failed" ? [...failedPlugins].map(({ plugin }) => randomCliColor(plugin.name)).join(", ") : void 0,
1308
+ filesCreated,
1309
+ time: styleText("green", duration),
1310
+ output: path.resolve(config.root, config.output.path)
1311
+ };
1312
+ const labels = {
1313
+ plugins: "Plugins:",
1314
+ failed: "Failed:",
1315
+ generated: "Generated:",
1316
+ pluginTimings: "Plugin Timings:",
1317
+ output: "Output:"
1318
+ };
1319
+ const maxLength = Math.max(0, ...[...Object.values(labels), ...pluginTimings ? Array.from(pluginTimings.keys()) : []].map((s) => s.length));
1320
+ const summaryLines = [];
1321
+ summaryLines.push(`${labels.plugins.padEnd(maxLength + 2)} ${meta.plugins}`);
1322
+ if (meta.pluginsFailed) summaryLines.push(`${labels.failed.padEnd(maxLength + 2)} ${meta.pluginsFailed}`);
1323
+ summaryLines.push(`${labels.generated.padEnd(maxLength + 2)} ${meta.filesCreated} files in ${meta.time}`);
1324
+ if (pluginTimings && pluginTimings.size > 0) {
1325
+ const sortedTimings = Array.from(pluginTimings.entries()).sort((a, b) => b[1] - a[1]);
1326
+ summaryLines.push(`${labels.pluginTimings}`);
1327
+ sortedTimings.forEach(([name, time]) => {
1328
+ const timeStr = time >= 1e3 ? `${(time / 1e3).toFixed(2)}s` : `${Math.round(time)}ms`;
1329
+ const barLength = Math.min(Math.ceil(time / 100), 10);
1330
+ const bar = styleText("dim", "█".repeat(barLength));
1331
+ summaryLines.push(`${styleText("dim", "•")} ${name.padEnd(maxLength + 1)}${bar} ${timeStr}`);
1444
1332
  });
1445
- await hookEndPromise;
1446
1333
  }
1334
+ summaryLines.push(`${labels.output.padEnd(maxLength + 2)} ${meta.output}`);
1335
+ return summaryLines;
1447
1336
  }
1448
1337
  //#endregion
1449
- //#region src/utils/getConfig.ts
1450
- async function getConfigs(config, args) {
1451
- const resolved = await (typeof config === "function" ? config(args) : config);
1452
- return (Array.isArray(resolved) ? resolved : [resolved]).map((item) => ({
1453
- ...item,
1454
- plugins: item.plugins ?? []
1455
- }));
1456
- }
1457
- //#endregion
1458
- //#region src/utils/getCosmiConfig.ts
1338
+ //#region src/runners/generate/utils.ts
1459
1339
  const jiti = createJiti(import.meta.url, {
1460
1340
  jsx: {
1461
1341
  runtime: "automatic",
@@ -1463,73 +1343,180 @@ const jiti = createJiti(import.meta.url, {
1463
1343
  },
1464
1344
  moduleCache: false
1465
1345
  });
1466
- const tsLoader = async (configFile) => {
1467
- return jiti.import(configFile, { default: true });
1468
- };
1469
- async function getCosmiConfig(moduleName, config) {
1470
- let result;
1471
- const searchPlaces = [
1472
- "package.json",
1473
- `.${moduleName}rc`,
1474
- `.${moduleName}rc.json`,
1475
- `.${moduleName}rc.yaml`,
1476
- `.${moduleName}rc.yml`,
1477
- `.${moduleName}rc.ts`,
1478
- `.${moduleName}rc.mts`,
1479
- `.${moduleName}rc.cts`,
1480
- `.${moduleName}rc.js`,
1481
- `.${moduleName}rc.mjs`,
1482
- `.${moduleName}rc.cjs`,
1483
- `${moduleName}.config.ts`,
1484
- `${moduleName}.config.mts`,
1485
- `${moduleName}.config.cts`,
1486
- `${moduleName}.config.js`,
1487
- `${moduleName}.config.mjs`,
1488
- `${moduleName}.config.cjs`
1489
- ];
1490
- const explorer = cosmiconfig(moduleName, {
1346
+ const tsLoader = (configFile) => jiti.import(configFile, { default: true });
1347
+ const MODULE_NAME = "kubb";
1348
+ const BASE_SEARCH_PLACES = [
1349
+ "package.json",
1350
+ `.${MODULE_NAME}rc`,
1351
+ `.${MODULE_NAME}rc.json`,
1352
+ `.${MODULE_NAME}rc.yaml`,
1353
+ `.${MODULE_NAME}rc.yml`,
1354
+ `.${MODULE_NAME}rc.ts`,
1355
+ `.${MODULE_NAME}rc.mts`,
1356
+ `.${MODULE_NAME}rc.cts`,
1357
+ `.${MODULE_NAME}rc.js`,
1358
+ `.${MODULE_NAME}rc.mjs`,
1359
+ `.${MODULE_NAME}rc.cjs`,
1360
+ `${MODULE_NAME}.config.ts`,
1361
+ `${MODULE_NAME}.config.mts`,
1362
+ `${MODULE_NAME}.config.cts`,
1363
+ `${MODULE_NAME}.config.js`,
1364
+ `${MODULE_NAME}.config.mjs`,
1365
+ `${MODULE_NAME}.config.cjs`
1366
+ ];
1367
+ const SEARCH_PLACES = [
1368
+ "",
1369
+ ".config/",
1370
+ "configs/"
1371
+ ].flatMap((prefix) => BASE_SEARCH_PLACES.map((p) => `${prefix}${p}`));
1372
+ async function getCosmiConfig(configFile) {
1373
+ const explorer = cosmiconfig(MODULE_NAME, {
1491
1374
  cache: false,
1492
- searchPlaces: [
1493
- ...searchPlaces.map((searchPlace) => {
1494
- return `.config/${searchPlace}`;
1495
- }),
1496
- ...searchPlaces.map((searchPlace) => {
1497
- return `configs/${searchPlace}`;
1498
- }),
1499
- ...searchPlaces
1500
- ],
1375
+ searchPlaces: SEARCH_PLACES,
1501
1376
  loaders: {
1502
1377
  ".ts": tsLoader,
1503
1378
  ".mts": tsLoader,
1504
1379
  ".cts": tsLoader
1505
1380
  }
1506
1381
  });
1382
+ let result;
1507
1383
  try {
1508
- result = config ? await explorer.load(config) : await explorer.search();
1384
+ result = configFile ? await explorer.load(configFile) : await explorer.search();
1509
1385
  } catch (error) {
1510
1386
  throw new Error("Config failed loading", { cause: error });
1511
1387
  }
1512
- if (result?.isEmpty || !result || !result.config) throw new Error("Config not defined, create a kubb.config.js or pass through your config with the option --config");
1388
+ if (!result?.config || result.isEmpty) throw new Error("Config not defined, create a kubb.config.js or pass through your config with the option --config");
1513
1389
  return result;
1514
1390
  }
1515
- //#endregion
1516
- //#region src/utils/watcher.ts
1517
- async function startWatcher(path, cb) {
1391
+ /**
1392
+ * Discovers the Kubb config via cosmiconfig and resolves it into a normalized array of configs.
1393
+ * Every config in the result is guaranteed to have a `plugins` array.
1394
+ */
1395
+ async function getConfigs({ configPath, input }) {
1396
+ const result = await getCosmiConfig(configPath);
1397
+ const resolved = await (typeof result.config === "function" ? result.config({ input }) : result.config);
1398
+ const userConfigs = Array.isArray(resolved) ? resolved : [resolved];
1399
+ return {
1400
+ configPath: result.filepath,
1401
+ configs: userConfigs.map((item) => ({
1402
+ ...item,
1403
+ plugins: item.plugins ?? []
1404
+ }))
1405
+ };
1406
+ }
1407
+ /**
1408
+ * Runs the `done` hooks defined in a Kubb config in sequence.
1409
+ */
1410
+ async function executeHooks({ configHooks, hooks, makeSink }) {
1411
+ const commands = Array.isArray(configHooks.done) ? configHooks.done : [configHooks.done].filter(Boolean);
1412
+ for (const command of commands) {
1413
+ const [cmd, ...args] = tokenize(command);
1414
+ if (!cmd) continue;
1415
+ const hookId = createHash("sha256").update(command).digest("hex");
1416
+ const commandWithArgs = [cmd, ...args].join(" ");
1417
+ await hooks.emit("kubb:hook:start", {
1418
+ id: hookId,
1419
+ command: cmd,
1420
+ args
1421
+ });
1422
+ const { stream = false, onLine, onStdout, onStderr } = makeSink?.(commandWithArgs) ?? {};
1423
+ await runHook({
1424
+ id: hookId,
1425
+ command: cmd,
1426
+ args,
1427
+ commandWithArgs,
1428
+ context: hooks,
1429
+ stream,
1430
+ sink: {
1431
+ onLine,
1432
+ onStdout,
1433
+ onStderr
1434
+ }
1435
+ });
1436
+ }
1437
+ }
1438
+ async function runHook({ id, command, args, commandWithArgs, context, stream = false, sink }) {
1439
+ const emitEnd = (success, error) => context.emit("kubb:hook:end", {
1440
+ command,
1441
+ args,
1442
+ id,
1443
+ success,
1444
+ error
1445
+ });
1446
+ try {
1447
+ const proc = x(command, [...args ?? []], {
1448
+ nodeOptions: { detached: process.platform !== "win32" },
1449
+ throwOnError: true
1450
+ });
1451
+ if (stream && sink?.onLine) for await (const line of proc) sink.onLine(line);
1452
+ const result = await proc;
1453
+ await context.emit("kubb:debug", {
1454
+ date: /* @__PURE__ */ new Date(),
1455
+ logs: [result.stdout.trimEnd()]
1456
+ });
1457
+ await context.emit("kubb:success", { message: `${styleText("dim", commandWithArgs)} successfully executed` });
1458
+ await emitEnd(true, null);
1459
+ } catch (err) {
1460
+ if (!(err instanceof NonZeroExitError)) {
1461
+ const error = toError(err);
1462
+ await emitEnd(false, error);
1463
+ await context.emit("kubb:error", { error });
1464
+ return;
1465
+ }
1466
+ const stderr = err.output?.stderr ?? "";
1467
+ const stdout = err.output?.stdout ?? "";
1468
+ await context.emit("kubb:debug", {
1469
+ date: /* @__PURE__ */ new Date(),
1470
+ logs: [stdout, stderr].filter(Boolean)
1471
+ });
1472
+ if (stderr) sink?.onStderr?.(stderr);
1473
+ if (stdout) sink?.onStdout?.(stdout);
1474
+ const error = /* @__PURE__ */ new Error(`Hook execute failed: ${commandWithArgs}`);
1475
+ await emitEnd(false, error);
1476
+ await context.emit("kubb:error", { error });
1477
+ }
1478
+ }
1479
+ /**
1480
+ * Starts a file watcher on the given paths and calls `cb` on any change.
1481
+ * Ignores `.git` and `node_modules` directories.
1482
+ */
1483
+ async function startWatcher(path, cb, log = {
1484
+ info: console.log,
1485
+ error: console.log
1486
+ }) {
1518
1487
  const { watch } = await import("chokidar");
1519
1488
  watch(path, {
1520
1489
  ignorePermissionErrors: true,
1521
1490
  ignored: WATCHER_IGNORED_PATHS
1522
1491
  }).on("all", async (type, file) => {
1523
- console.log(styleText("yellow", styleText("bold", `Change detected: ${type} ${file}`)));
1492
+ log.info(styleText("yellow", styleText("bold", `Change detected: ${type} ${file}`)));
1524
1493
  try {
1525
1494
  await cb(path);
1526
1495
  } catch (_e) {
1527
- console.log(styleText("red", "Watcher failed"));
1496
+ log.error(styleText("red", "Watcher failed"));
1528
1497
  }
1529
1498
  });
1530
1499
  }
1531
1500
  //#endregion
1532
- //#region src/runners/generate.ts
1501
+ //#region src/runners/generate/run.ts
1502
+ /**
1503
+ * Registers a one-shot `kubb:hook:end` listener for `hookId` BEFORE the caller emits `kubb:hook:start`,
1504
+ * avoiding the race where a synchronous emitter fires end before the listener is attached.
1505
+ */
1506
+ function waitForHookEnd(hooks, hookId, onSuccess, fallbackErrorMessage) {
1507
+ return new Promise((resolve, reject) => {
1508
+ const handler = (ctx) => {
1509
+ if (ctx.id !== hookId) return;
1510
+ hooks.off("kubb:hook:end", handler);
1511
+ if (!ctx.success) {
1512
+ reject(ctx.error ?? new Error(fallbackErrorMessage));
1513
+ return;
1514
+ }
1515
+ onSuccess().then(resolve).catch(reject);
1516
+ };
1517
+ hooks.on("kubb:hook:end", handler);
1518
+ });
1519
+ }
1533
1520
  async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefix, noToolMessage, configName, outputPath, logLevel: logLevel$1, hooks, onStart, onEnd }) {
1534
1521
  await onStart();
1535
1522
  let resolvedTool = toolValue;
@@ -1544,24 +1531,14 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1544
1531
  let toolError;
1545
1532
  if (resolvedTool && resolvedTool !== "auto" && resolvedTool in toolMap) {
1546
1533
  const toolConfig = toolMap[resolvedTool];
1534
+ const hookId = createHash("sha256").update([configName, resolvedTool].filter(Boolean).join("-")).digest("hex");
1535
+ const successMessage = [
1536
+ `${successPrefix} with ${styleText("dim", resolvedTool)}`,
1537
+ logLevel$1 >= logLevel.info ? `on ${styleText("dim", outputPath)}` : void 0,
1538
+ "successfully"
1539
+ ].filter(Boolean).join(" ");
1547
1540
  try {
1548
- const hookId = createHash("sha256").update([configName, resolvedTool].filter(Boolean).join("-")).digest("hex");
1549
- const hookEndPromise = new Promise((resolve, reject) => {
1550
- const handler = (ctx) => {
1551
- if (ctx.id !== hookId) return;
1552
- hooks.off("kubb:hook:end", handler);
1553
- if (!ctx.success) {
1554
- reject(ctx.error ?? /* @__PURE__ */ new Error(`${toolConfig.errorMessage}`));
1555
- return;
1556
- }
1557
- hooks.emit("kubb:success", { message: [
1558
- `${successPrefix} with ${styleText("dim", resolvedTool)}`,
1559
- logLevel$1 >= logLevel.info ? `on ${styleText("dim", outputPath)}` : void 0,
1560
- "successfully"
1561
- ].filter(Boolean).join(" ") }).then(resolve).catch(reject);
1562
- };
1563
- hooks.on("kubb:hook:end", handler);
1564
- });
1541
+ const hookEndPromise = waitForHookEnd(hooks, hookId, () => hooks.emit("kubb:success", { message: successMessage }), toolConfig.errorMessage);
1565
1542
  await hooks.emit("kubb:hook:start", {
1566
1543
  id: hookId,
1567
1544
  command: toolConfig.command,
@@ -1578,7 +1555,7 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1578
1555
  if (toolError) throw toolError;
1579
1556
  }
1580
1557
  async function generate(options) {
1581
- const { input, hooks, logLevel: logLevel$2 } = options;
1558
+ const { input, hooks, logLevel: logLevel$2, makeSink } = options;
1582
1559
  const hrStart = process$1.hrtime();
1583
1560
  const inputPath = input ?? (options.config.input && "path" in options.config.input ? options.config.input.path : void 0);
1584
1561
  const config = {
@@ -1602,8 +1579,20 @@ async function generate(options) {
1602
1579
  });
1603
1580
  const { files, failedPlugins, pluginTimings, error, driver } = await kubb.safeBuild();
1604
1581
  await hooks.emit("kubb:info", { message: "Load summary" });
1582
+ const telemetryPlugins = Array.from(driver.plugins.values(), (p) => ({
1583
+ name: p.name,
1584
+ options: p.options
1585
+ }));
1586
+ const reportTelemetry = (status) => sendTelemetry(buildTelemetryEvent({
1587
+ command: "generate",
1588
+ kubbVersion: version,
1589
+ plugins: telemetryPlugins,
1590
+ hrStart,
1591
+ filesCreated: files.length,
1592
+ status
1593
+ }));
1605
1594
  if (failedPlugins.size > 0 || error) {
1606
- const allErrors = [error, ...Array.from(failedPlugins).filter((it) => it.error).map((it) => it.error)].filter(Boolean);
1595
+ const allErrors = [error, ...Array.from(failedPlugins, (it) => it.error)].filter(Boolean);
1607
1596
  for (const err of allErrors) await hooks.emit("kubb:error", { error: err });
1608
1597
  await hooks.emit("kubb:generation:end", {
1609
1598
  config,
@@ -1618,21 +1607,11 @@ async function generate(options) {
1618
1607
  hrStart,
1619
1608
  pluginTimings: logLevel$2 >= logLevel.verbose ? pluginTimings : void 0
1620
1609
  });
1621
- await sendTelemetry(buildTelemetryEvent({
1622
- command: "generate",
1623
- kubbVersion: version,
1624
- plugins: Array.from(driver.plugins.values(), (p) => ({
1625
- name: p.name,
1626
- options: p.options
1627
- })),
1628
- hrStart,
1629
- filesCreated: files.length,
1630
- status: "failed"
1631
- }));
1610
+ await reportTelemetry("failed");
1632
1611
  process$1.exit(1);
1633
1612
  }
1634
1613
  await hooks.emit("kubb:success", {
1635
- message: "Generation successfully",
1614
+ message: "Generation succeeded",
1636
1615
  info: inputPath
1637
1616
  });
1638
1617
  await hooks.emit("kubb:generation:end", {
@@ -1641,39 +1620,38 @@ async function generate(options) {
1641
1620
  sources: kubb.sources
1642
1621
  });
1643
1622
  const outputPath = path.resolve(config.root, config.output.path);
1644
- if (config.output.format) await runToolPass({
1623
+ const toolPasses = [config.output.format && {
1645
1624
  toolValue: config.output.format,
1646
1625
  detect: detectFormatter,
1647
1626
  toolMap: formatters,
1648
1627
  toolLabel: "formatter",
1649
1628
  successPrefix: "Formatting",
1650
1629
  noToolMessage: "No formatter found (oxfmt, biome, or prettier). Skipping formatting.",
1651
- configName: config.name,
1652
- outputPath,
1653
- logLevel: logLevel$2,
1654
- hooks,
1655
1630
  onStart: () => hooks.emit("kubb:format:start"),
1656
1631
  onEnd: () => hooks.emit("kubb:format:end")
1657
- });
1658
- if (config.output.lint) await runToolPass({
1632
+ }, config.output.lint && {
1659
1633
  toolValue: config.output.lint,
1660
1634
  detect: detectLinter,
1661
1635
  toolMap: linters,
1662
1636
  toolLabel: "linter",
1663
1637
  successPrefix: "Linting",
1664
1638
  noToolMessage: "No linter found (oxlint, biome, or eslint). Skipping linting.",
1639
+ onStart: () => hooks.emit("kubb:lint:start"),
1640
+ onEnd: () => hooks.emit("kubb:lint:end")
1641
+ }].filter(Boolean);
1642
+ for (const pass of toolPasses) await runToolPass({
1643
+ ...pass,
1665
1644
  configName: config.name,
1666
1645
  outputPath,
1667
1646
  logLevel: logLevel$2,
1668
- hooks,
1669
- onStart: () => hooks.emit("kubb:lint:start"),
1670
- onEnd: () => hooks.emit("kubb:lint:end")
1647
+ hooks
1671
1648
  });
1672
1649
  if (config.hooks) {
1673
1650
  await hooks.emit("kubb:hooks:start");
1674
1651
  await executeHooks({
1675
1652
  configHooks: config.hooks,
1676
- hooks
1653
+ hooks,
1654
+ makeSink
1677
1655
  });
1678
1656
  await hooks.emit("kubb:hooks:end");
1679
1657
  }
@@ -1685,42 +1663,42 @@ async function generate(options) {
1685
1663
  hrStart,
1686
1664
  pluginTimings
1687
1665
  });
1688
- await sendTelemetry(buildTelemetryEvent({
1689
- command: "generate",
1690
- kubbVersion: version,
1691
- plugins: Array.from(driver.plugins.values(), (p) => ({
1692
- name: p.name,
1693
- options: p.options
1694
- })),
1695
- hrStart,
1696
- filesCreated: files.length,
1697
- status: "success"
1698
- }));
1666
+ await reportTelemetry("success");
1699
1667
  }
1700
- async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, watch }) {
1701
- const logLevel$3 = logLevel[logLevelKey] ?? logLevel.info;
1702
- const hooks = new AsyncEventEmitter();
1703
- await setupLogger(hooks, { logLevel: logLevel$3 });
1668
+ async function checkForUpdate(hooks) {
1704
1669
  await executeIfOnline(async () => {
1705
1670
  try {
1706
- const latestVersion = (await (await fetch(KUBB_NPM_PACKAGE_URL)).json()).version;
1707
- if (latestVersion && version < latestVersion) await hooks.emit("kubb:version:new", {
1671
+ const data = await (await fetch(KUBB_NPM_PACKAGE_URL)).json();
1672
+ if (data.version && version < data.version) await hooks.emit("kubb:version:new", {
1708
1673
  currentVersion: version,
1709
- latestVersion
1674
+ latestVersion: data.version
1710
1675
  });
1711
1676
  } catch {}
1712
1677
  });
1678
+ }
1679
+ /**
1680
+ * Runs the full Kubb generation lifecycle for the given CLI options.
1681
+ * Sets up the logger, checks for a newer version, loads configs, and calls `generate` for each config entry.
1682
+ */
1683
+ async function run({ input, configPath, logLevel: logLevelKey, watch }) {
1684
+ const logLevel$3 = logLevel[logLevelKey] ?? logLevel.info;
1685
+ const hooks = new AsyncEventEmitter();
1686
+ const makeSink = await setupLogger(hooks, { logLevel: logLevel$3 });
1687
+ await checkForUpdate(hooks);
1713
1688
  try {
1714
- const result = await getCosmiConfig("kubb", configPath);
1715
- const configs = await getConfigs(result.config, { input });
1689
+ const { configs, configPath: resolvedConfigPath } = await getConfigs({
1690
+ configPath,
1691
+ input
1692
+ });
1693
+ const relativeConfigPath = path.relative(process$1.cwd(), resolvedConfigPath);
1716
1694
  await hooks.emit("kubb:config:start");
1717
1695
  await hooks.emit("kubb:info", {
1718
1696
  message: "Config loaded",
1719
- info: path.relative(process$1.cwd(), result.filepath)
1697
+ info: relativeConfigPath
1720
1698
  });
1721
1699
  await hooks.emit("kubb:success", {
1722
1700
  message: "Config loaded successfully",
1723
- info: path.relative(process$1.cwd(), result.filepath)
1701
+ info: relativeConfigPath
1724
1702
  });
1725
1703
  await hooks.emit("kubb:config:end", { configs });
1726
1704
  await hooks.emit("kubb:lifecycle:start", { version });
@@ -1730,15 +1708,20 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
1730
1708
  input,
1731
1709
  config,
1732
1710
  logLevel: logLevel$3,
1733
- hooks
1711
+ hooks,
1712
+ makeSink
1734
1713
  });
1735
1714
  clack.log.step(styleText("yellow", `Watching for changes in ${paths.join(" and ")}`));
1715
+ }, {
1716
+ info: (msg) => clack.log.info(msg),
1717
+ error: (msg) => clack.log.error(msg)
1736
1718
  });
1737
1719
  else await generate({
1738
1720
  input,
1739
1721
  config,
1740
1722
  logLevel: logLevel$3,
1741
- hooks
1723
+ hooks,
1724
+ makeSink
1742
1725
  });
1743
1726
  await hooks.emit("kubb:lifecycle:end");
1744
1727
  } catch (error) {
@@ -1747,6 +1730,6 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
1747
1730
  }
1748
1731
  }
1749
1732
  //#endregion
1750
- export { runGenerateCommand };
1733
+ export { run };
1751
1734
 
1752
- //# sourceMappingURL=generate-DAsdUw3z.js.map
1735
+ //# sourceMappingURL=run-BAJubgdA.js.map