@kubb/cli 4.28.1 → 4.29.1

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 (64) hide show
  1. package/dist/{agent-DrV6PuuK.js → agent-BzD6f3mV.js} +4 -5
  2. package/dist/{agent-DrV6PuuK.js.map → agent-BzD6f3mV.js.map} +1 -1
  3. package/dist/{agent-BHBMSAC7.cjs → agent-NAhMf2ot.cjs} +4 -5
  4. package/dist/{agent-BHBMSAC7.cjs.map → agent-NAhMf2ot.cjs.map} +1 -1
  5. package/dist/{chunk-C1_xRkKa.cjs → chunk-CNbaEX1y.cjs} +1 -1
  6. package/dist/{chunk-jHaXqnEa.js → chunk-DKWOrOAv.js} +1 -1
  7. package/dist/{generate-CQudcsre.js → generate-CGEE6Etf.js} +192 -185
  8. package/dist/generate-CGEE6Etf.js.map +1 -0
  9. package/dist/{generate-B8XICi_S.cjs → generate-b2shdOTg.cjs} +191 -188
  10. package/dist/generate-b2shdOTg.cjs.map +1 -0
  11. package/dist/index.cjs +9 -8
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +8 -8
  15. package/dist/{init-Byzguonv.js → init-CPrROO67.js} +22 -23
  16. package/dist/init-CPrROO67.js.map +1 -0
  17. package/dist/{init-CRG4HVMq.cjs → init-CaoLbJ4R.cjs} +22 -24
  18. package/dist/init-CaoLbJ4R.cjs.map +1 -0
  19. package/dist/{mcp-DGyip5BX.cjs → mcp-97TXkJVX.cjs} +5 -7
  20. package/dist/mcp-97TXkJVX.cjs.map +1 -0
  21. package/dist/{mcp-C-e4yatL.js → mcp-Jboea6xH.js} +5 -6
  22. package/dist/mcp-Jboea6xH.js.map +1 -0
  23. package/dist/package-1sFkRYXi.js +6 -0
  24. package/dist/package-1sFkRYXi.js.map +1 -0
  25. package/dist/{package-DIc1GFdF.cjs → package-DPA0iPrU.cjs} +2 -2
  26. package/dist/package-DPA0iPrU.cjs.map +1 -0
  27. package/dist/{start-jaV7_Xss.js → start-CYuU23PX.js} +27 -24
  28. package/dist/start-CYuU23PX.js.map +1 -0
  29. package/dist/{start-DqKYNdp1.cjs → start-lrn1-P52.cjs} +27 -25
  30. package/dist/start-lrn1-P52.cjs.map +1 -0
  31. package/dist/{validate-Cvb5aOEb.cjs → validate-BgYhe_55.cjs} +3 -4
  32. package/dist/{validate-Cvb5aOEb.cjs.map → validate-BgYhe_55.cjs.map} +1 -1
  33. package/dist/{validate-YI4YkVTl.js → validate-DOeZKiGx.js} +3 -4
  34. package/dist/{validate-YI4YkVTl.js.map → validate-DOeZKiGx.js.map} +1 -1
  35. package/package.json +12 -21
  36. package/src/commands/agent/start.ts +17 -16
  37. package/src/commands/generate.ts +14 -7
  38. package/src/commands/init.ts +14 -14
  39. package/src/commands/mcp.ts +2 -2
  40. package/src/loggers/clackLogger.ts +49 -40
  41. package/src/loggers/githubActionsLogger.ts +36 -32
  42. package/src/loggers/plainLogger.ts +9 -9
  43. package/src/runners/generate.ts +9 -7
  44. package/src/utils/Writables.ts +2 -2
  45. package/src/utils/executeHooks.ts +4 -5
  46. package/src/utils/formatMsWithColor.ts +4 -4
  47. package/src/utils/getIntro.ts +52 -6
  48. package/src/utils/getSummary.ts +6 -6
  49. package/src/utils/packageManager.ts +3 -9
  50. package/src/utils/randomColor.ts +5 -6
  51. package/src/utils/watcher.ts +3 -3
  52. package/dist/generate-B8XICi_S.cjs.map +0 -1
  53. package/dist/generate-CQudcsre.js.map +0 -1
  54. package/dist/index.d.cts +0 -6
  55. package/dist/init-Byzguonv.js.map +0 -1
  56. package/dist/init-CRG4HVMq.cjs.map +0 -1
  57. package/dist/mcp-C-e4yatL.js.map +0 -1
  58. package/dist/mcp-DGyip5BX.cjs.map +0 -1
  59. package/dist/package-DIc1GFdF.cjs.map +0 -1
  60. package/dist/package-G_AvcVgZ.js +0 -6
  61. package/dist/package-G_AvcVgZ.js.map +0 -1
  62. package/dist/start-DqKYNdp1.cjs.map +0 -1
  63. package/dist/start-jaV7_Xss.js.map +0 -1
  64. package/src/utils/ansiColors.ts +0 -23
@@ -1,22 +1,17 @@
1
- import { t as __name } from "./chunk-jHaXqnEa.js";
2
- import { t as version } from "./package-G_AvcVgZ.js";
1
+ import { t as __name } from "./chunk-DKWOrOAv.js";
2
+ import { t as version } from "./package-1sFkRYXi.js";
3
3
  import { defineCommand, showUsage } from "citty";
4
4
  import path, { relative, resolve } from "node:path";
5
5
  import * as process$2 from "node:process";
6
6
  import process$1 from "node:process";
7
+ import { styleText } from "node:util";
7
8
  import * as clack from "@clack/prompts";
8
- import { execa } from "execa";
9
- import pc from "picocolors";
10
9
  import { LogLevel, PromiseManager, defineLogger, isInputPath, safeBuild, setup } from "@kubb/core";
11
- import { AsyncEventEmitter, detectFormatter, detectLinter, executeIfOnline, formatHrtime, formatMs, formatters, getConfigs, linters } from "@kubb/core/utils";
12
- import getLatestVersion from "latest-version";
13
- import { lt } from "semver";
14
- import gradientString from "gradient-string";
15
- import seedrandom from "seedrandom";
10
+ import { AsyncEventEmitter, detectFormatter, detectLinter, executeIfOnline, formatHrtime, formatMs, formatters, getConfigs, linters, tokenize } from "@kubb/core/utils";
11
+ import { x } from "tinyexec";
12
+ import { createHash } from "node:crypto";
16
13
  import { Writable } from "node:stream";
17
14
  import { write } from "@kubb/core/fs";
18
- import { createHash } from "node:crypto";
19
- import { parseArgsStringToArgv } from "string-argv";
20
15
  import { cosmiconfig } from "cosmiconfig";
21
16
  import { createJiti } from "jiti";
22
17
 
@@ -29,13 +24,13 @@ import { createJiti } from "jiti";
29
24
  */
30
25
  function formatMsWithColor(ms) {
31
26
  const formatted = formatMs(ms);
32
- if (ms <= 500) return pc.green(formatted);
33
- if (ms <= 1e3) return pc.yellow(formatted);
34
- return pc.red(formatted);
27
+ if (ms <= 500) return styleText("green", formatted);
28
+ if (ms <= 1e3) return styleText("yellow", formatted);
29
+ return styleText("red", formatted);
35
30
  }
36
31
 
37
32
  //#endregion
38
- //#region src/utils/ansiColors.ts
33
+ //#region src/utils/getIntro.ts
39
34
  /**
40
35
  * ANSI True Color (24-bit) utilities for terminal output
41
36
  * Supports hex color codes without external dependencies like chalk
@@ -55,9 +50,27 @@ function hex(color) {
55
50
  const safeB = Number.isNaN(b) ? 255 : b;
56
51
  return (text) => `\x1b[38;2;${safeR};${safeG};${safeB}m${text}\x1b[0m`;
57
52
  }
58
-
59
- //#endregion
60
- //#region src/utils/getIntro.ts
53
+ function hexToRgb(color) {
54
+ const c = color.replace("#", "");
55
+ return {
56
+ r: Number.parseInt(c.slice(0, 2), 16),
57
+ g: Number.parseInt(c.slice(2, 4), 16),
58
+ b: Number.parseInt(c.slice(4, 6), 16)
59
+ };
60
+ }
61
+ function gradient(colors) {
62
+ return (text) => {
63
+ const chars = [...text];
64
+ return chars.map((char, i) => {
65
+ const t = chars.length <= 1 ? 0 : i / (chars.length - 1);
66
+ const seg = Math.min(Math.floor(t * (colors.length - 1)), colors.length - 2);
67
+ const lt = t * (colors.length - 1) - seg;
68
+ const from = hexToRgb(colors[seg]);
69
+ const to = hexToRgb(colors[seg + 1]);
70
+ return `\x1b[38;2;${Math.round(from.r + (to.r - from.r) * lt)};${Math.round(from.g + (to.g - from.g) * lt)};${Math.round(from.b + (to.b - from.b) * lt)}m${char}\x1b[0m`;
71
+ }).join("");
72
+ };
73
+ }
61
74
  const colors = {
62
75
  lid: hex("#F55A17"),
63
76
  woodTop: hex("#F5A217"),
@@ -72,19 +85,19 @@ const colors = {
72
85
  * @param version - The version string to display
73
86
  * @returns Formatted mascot face string
74
87
  */
75
- function getIntro({ title, description, version: version$1, areEyesOpen }) {
76
- const kubbVersion = gradientString([
88
+ function getIntro({ title, description, version, areEyesOpen }) {
89
+ const kubbVersion = gradient([
77
90
  "#F58517",
78
91
  "#F5A217",
79
92
  "#F55A17"
80
- ])(`KUBB v${version$1}`);
93
+ ])(`KUBB v${version}`);
81
94
  const eyeTop = areEyesOpen ? colors.eye("█▀█") : colors.eye("───");
82
95
  const eyeBottom = areEyesOpen ? colors.eye("▀▀▀") : colors.eye("───");
83
96
  return `
84
97
  ${colors.lid("▄▄▄▄▄▄▄▄▄▄▄▄▄")}
85
98
  ${colors.woodTop("█ ")}${colors.highlight("▄▄")}${colors.woodTop(" ")}${colors.highlight("▄▄")}${colors.woodTop(" █")} ${kubbVersion}
86
- ${colors.woodMid("█ ")}${eyeTop}${colors.woodMid(" ")}${eyeTop}${colors.woodMid(" █")} ${pc.gray(title)}
87
- ${colors.woodMid("█ ")}${eyeBottom}${colors.woodMid(" ")}${colors.blush("◡")}${colors.woodMid(" ")}${eyeBottom}${colors.woodMid(" █")} ${pc.yellow("➜")} ${pc.white(description)}
99
+ ${colors.woodMid("█ ")}${eyeTop}${colors.woodMid(" ")}${eyeTop}${colors.woodMid(" █")} ${styleText("gray", title)}
100
+ ${colors.woodMid("█ ")}${eyeBottom}${colors.woodMid(" ")}${colors.blush("◡")}${colors.woodMid(" ")}${eyeBottom}${colors.woodMid(" █")} ${styleText("yellow", "➜")} ${styleText("white", description)}
88
101
  ${colors.woodBase("▀▀▀▀▀▀▀▀▀▀▀▀▀")}
89
102
  `;
90
103
  }
@@ -105,13 +118,11 @@ function randomColor(text) {
105
118
  "cyan",
106
119
  "gray"
107
120
  ];
108
- const random = seedrandom(text);
109
- return defaultColors.at(Math.floor(random() * defaultColors.length)) || "white";
121
+ return defaultColors[createHash("sha256").update(text).digest().readUInt32BE(0) % defaultColors.length] ?? "white";
110
122
  }
111
123
  function randomCliColor(text) {
112
124
  if (!text) return "";
113
- const fn = pc[randomColor(text)];
114
- return fn ? fn(text) : text;
125
+ return styleText(randomColor(text), text);
115
126
  }
116
127
 
117
128
  //#endregion
@@ -121,10 +132,10 @@ function getSummary({ failedPlugins, filesCreated, status, hrStart, config, plug
121
132
  const pluginsCount = config.plugins?.length || 0;
122
133
  const successCount = pluginsCount - failedPlugins.size;
123
134
  const meta = {
124
- plugins: status === "success" ? `${pc.green(`${successCount} successful`)}, ${pluginsCount} total` : `${pc.green(`${successCount} successful`)}, ${pc.red(`${failedPlugins.size} failed`)}, ${pluginsCount} total`,
135
+ plugins: status === "success" ? `${styleText("green", `${successCount} successful`)}, ${pluginsCount} total` : `${styleText("green", `${successCount} successful`)}, ${styleText("red", `${failedPlugins.size} failed`)}, ${pluginsCount} total`,
125
136
  pluginsFailed: status === "failed" ? [...failedPlugins]?.map(({ plugin }) => randomCliColor(plugin.name))?.join(", ") : void 0,
126
137
  filesCreated,
127
- time: pc.green(duration),
138
+ time: styleText("green", duration),
128
139
  output: path.isAbsolute(config.root) ? path.resolve(config.root, config.output.path) : config.root
129
140
  };
130
141
  const labels = {
@@ -148,8 +159,8 @@ function getSummary({ failedPlugins, filesCreated, status, hrStart, config, plug
148
159
  sortedTimings.forEach(([name, time]) => {
149
160
  const timeStr = time >= 1e3 ? `${(time / 1e3).toFixed(2)}s` : `${Math.round(time)}ms`;
150
161
  const barLength = Math.min(Math.ceil(time / TIME_SCALE_DIVISOR), MAX_BAR_LENGTH);
151
- const bar = pc.dim("█".repeat(barLength));
152
- summaryLines.push(`${pc.dim("•")} ${name.padEnd(maxLength + 1)}${bar} ${timeStr}`);
162
+ const bar = styleText("dim", "█".repeat(barLength));
163
+ summaryLines.push(`${styleText("dim", "•")} ${name.padEnd(maxLength + 1)}${bar} ${timeStr}`);
153
164
  });
154
165
  }
155
166
  }
@@ -166,7 +177,7 @@ var ClackWritable = class extends Writable {
166
177
  this.taskLog = taskLog;
167
178
  }
168
179
  _write(chunk, _encoding, callback) {
169
- this.taskLog.message(`${pc.dim(chunk?.toString())}`);
180
+ this.taskLog.message(`${styleText("dim", chunk?.toString())}`);
170
181
  callback();
171
182
  }
172
183
  };
@@ -212,25 +223,22 @@ const clackLogger = defineLogger({
212
223
  const parts = [];
213
224
  const duration = formatHrtime(state.hrStart);
214
225
  if (state.totalPlugins > 0) {
215
- const pluginStr = state.failedPlugins > 0 ? `Plugins ${pc.green(state.completedPlugins.toString())}/${state.totalPlugins} ${pc.red(`(${state.failedPlugins} failed)`)}` : `Plugins ${pc.green(state.completedPlugins.toString())}/${state.totalPlugins}`;
226
+ const pluginStr = state.failedPlugins > 0 ? `Plugins ${styleText("green", state.completedPlugins.toString())}/${state.totalPlugins} ${styleText("red", `(${state.failedPlugins} failed)`)}` : `Plugins ${styleText("green", state.completedPlugins.toString())}/${state.totalPlugins}`;
216
227
  parts.push(pluginStr);
217
228
  }
218
- if (state.totalFiles > 0) parts.push(`Files ${pc.green(state.processedFiles.toString())}/${state.totalFiles}`);
229
+ if (state.totalFiles > 0) parts.push(`Files ${styleText("green", state.processedFiles.toString())}/${state.totalFiles}`);
219
230
  if (parts.length > 0) {
220
- parts.push(`${pc.green(duration)} elapsed`);
221
- clack.log.step(getMessage(parts.join(pc.dim(" | "))));
231
+ parts.push(`${styleText("green", duration)} elapsed`);
232
+ clack.log.step(getMessage(parts.join(styleText("dim", " | "))));
222
233
  }
223
234
  }
224
235
  function getMessage(message) {
225
- if (logLevel >= LogLevel.verbose) {
226
- const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
227
- hour12: false,
228
- hour: "2-digit",
229
- minute: "2-digit",
230
- second: "2-digit"
231
- });
232
- return [pc.dim(`[${timestamp}]`), message].join(" ");
233
- }
236
+ if (logLevel >= LogLevel.verbose) return [styleText("dim", `[${(/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
237
+ hour12: false,
238
+ hour: "2-digit",
239
+ minute: "2-digit",
240
+ second: "2-digit"
241
+ })}]`), message].join(" ");
234
242
  return message;
235
243
  }
236
244
  function startSpinner(text) {
@@ -244,9 +252,9 @@ const clackLogger = defineLogger({
244
252
  context.on("info", (message, info = "") => {
245
253
  if (logLevel <= LogLevel.silent) return;
246
254
  const text = getMessage([
247
- pc.blue("ℹ"),
255
+ styleText("blue", "ℹ"),
248
256
  message,
249
- pc.dim(info)
257
+ styleText("dim", info)
250
258
  ].join(" "));
251
259
  if (state.isSpinning) state.spinner.message(text);
252
260
  else clack.log.info(text);
@@ -254,9 +262,9 @@ const clackLogger = defineLogger({
254
262
  context.on("success", (message, info = "") => {
255
263
  if (logLevel <= LogLevel.silent) return;
256
264
  const text = getMessage([
257
- pc.blue("✓"),
265
+ styleText("blue", "✓"),
258
266
  message,
259
- logLevel >= LogLevel.info ? pc.dim(info) : void 0
267
+ logLevel >= LogLevel.info ? styleText("dim", info) : void 0
260
268
  ].filter(Boolean).join(" "));
261
269
  if (state.isSpinning) stopSpinner(text);
262
270
  else clack.log.success(text);
@@ -264,44 +272,44 @@ const clackLogger = defineLogger({
264
272
  context.on("warn", (message, info) => {
265
273
  if (logLevel < LogLevel.warn) return;
266
274
  const text = getMessage([
267
- pc.yellow("⚠"),
275
+ styleText("yellow", "⚠"),
268
276
  message,
269
- logLevel >= LogLevel.info ? pc.dim(info) : void 0
277
+ logLevel >= LogLevel.info && info ? styleText("dim", info) : void 0
270
278
  ].filter(Boolean).join(" "));
271
279
  clack.log.warn(text);
272
280
  });
273
281
  context.on("error", (error) => {
274
282
  const caused = error.cause;
275
- const text = [pc.red("✗"), error.message].join(" ");
283
+ const text = [styleText("red", "✗"), error.message].join(" ");
276
284
  if (state.isSpinning) stopSpinner(getMessage(text));
277
285
  else clack.log.error(getMessage(text));
278
286
  if (logLevel >= LogLevel.debug && error.stack) {
279
287
  const frames = error.stack.split("\n").slice(1, 4);
280
- for (const frame of frames) clack.log.message(getMessage(pc.dim(frame.trim())));
288
+ for (const frame of frames) clack.log.message(getMessage(styleText("dim", frame.trim())));
281
289
  if (caused?.stack) {
282
- clack.log.message(pc.dim(`└─ caused by ${caused.message}`));
283
- const frames$1 = caused.stack.split("\n").slice(1, 4);
284
- for (const frame of frames$1) clack.log.message(getMessage(` ${pc.dim(frame.trim())}`));
290
+ clack.log.message(styleText("dim", `└─ caused by ${caused.message}`));
291
+ const frames = caused.stack.split("\n").slice(1, 4);
292
+ for (const frame of frames) clack.log.message(getMessage(` ${styleText("dim", frame.trim())}`));
285
293
  }
286
294
  }
287
295
  });
288
- context.on("version:new", (version$1, latestVersion) => {
296
+ context.on("version:new", (version, latestVersion) => {
289
297
  if (logLevel <= LogLevel.silent) return;
290
- clack.box(`\`v${version$1}\` → \`v${latestVersion}\`
298
+ clack.box(`\`v${version}\` → \`v${latestVersion}\`
291
299
  Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
292
300
  width: "auto",
293
- formatBorder: pc.yellow,
301
+ formatBorder: (s) => styleText("yellow", s),
294
302
  rounded: true,
295
303
  withGuide: false,
296
304
  contentAlign: "center",
297
305
  titleAlign: "center"
298
306
  });
299
307
  });
300
- context.on("lifecycle:start", async (version$1) => {
308
+ context.on("lifecycle:start", async (version) => {
301
309
  console.log(`\n${getIntro({
302
310
  title: "The ultimate toolkit for working with APIs",
303
311
  description: "Ready to start",
304
- version: version$1,
312
+ version,
305
313
  areEyesOpen: true
306
314
  })}\n`);
307
315
  reset();
@@ -319,7 +327,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
319
327
  });
320
328
  context.on("generation:start", (config) => {
321
329
  state.totalPlugins = config.plugins?.length || 0;
322
- const text = getMessage(["Generation started", config.name ? `for ${pc.dim(config.name)}` : void 0].filter(Boolean).join(" "));
330
+ const text = getMessage(["Generation started", config.name ? `for ${styleText("dim", config.name)}` : void 0].filter(Boolean).join(" "));
323
331
  clack.intro(text);
324
332
  reset();
325
333
  });
@@ -331,7 +339,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
331
339
  max: 100,
332
340
  size: 30
333
341
  });
334
- const text = getMessage(`Generating ${pc.bold(plugin.name)}`);
342
+ const text = getMessage(`Generating ${styleText("bold", plugin.name)}`);
335
343
  progressBar.start(text);
336
344
  const interval = setInterval(() => {
337
345
  progressBar.advance();
@@ -349,7 +357,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
349
357
  if (success) state.completedPlugins++;
350
358
  else state.failedPlugins++;
351
359
  const durationStr = formatMsWithColor(duration);
352
- const text = getMessage(success ? `${pc.bold(plugin.name)} completed in ${durationStr}` : `${pc.bold(plugin.name)} failed in ${pc.red(formatMs(duration))}`);
360
+ const text = getMessage(success ? `${styleText("bold", plugin.name)} completed in ${durationStr}` : `${styleText("bold", plugin.name)} failed in ${styleText("red", formatMs(duration))}`);
353
361
  active.progressBar.stop(text);
354
362
  state.activeProgress.delete(plugin.name);
355
363
  showProgressStep();
@@ -389,7 +397,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
389
397
  showProgressStep();
390
398
  });
391
399
  context.on("generation:end", (config) => {
392
- const text = getMessage(config.name ? `Generation completed for ${pc.dim(config.name)}` : "Generation completed");
400
+ const text = getMessage(config.name ? `Generation completed for ${styleText("dim", config.name)}` : "Generation completed");
393
401
  clack.outro(text);
394
402
  });
395
403
  context.on("format:start", () => {
@@ -412,22 +420,22 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
412
420
  const text = getMessage("Lint completed");
413
421
  clack.outro(text);
414
422
  });
415
- context.on("hook:start", async ({ id, command: command$1, args }) => {
416
- const commandWithArgs = args?.length ? `${command$1} ${args.join(" ")}` : command$1;
417
- const text = getMessage(`Hook ${pc.dim(commandWithArgs)} started`);
423
+ context.on("hook:start", async ({ id, command, args }) => {
424
+ const commandWithArgs = args?.length ? `${command} ${args.join(" ")}` : command;
425
+ const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} started`);
418
426
  if (!id) return;
419
427
  if (logLevel <= LogLevel.silent) {
420
428
  try {
421
- const result = await execa(command$1, args, {
422
- detached: true,
423
- stripFinalNewline: true
429
+ const result = await x(command, [...args ?? []], {
430
+ nodeOptions: { detached: true },
431
+ throwOnError: true
424
432
  });
425
433
  await context.emit("debug", {
426
434
  date: /* @__PURE__ */ new Date(),
427
- logs: [result.stdout]
435
+ logs: [result.stdout.trimEnd()]
428
436
  });
429
437
  await context.emit("hook:end", {
430
- command: command$1,
438
+ command,
431
439
  args,
432
440
  id,
433
441
  success: true,
@@ -435,8 +443,8 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
435
443
  });
436
444
  } catch (err) {
437
445
  const error = err;
438
- const stderr = typeof error.stderr === "string" ? error.stderr : String(error.stderr);
439
- const stdout = typeof error.stdout === "string" ? error.stdout : String(error.stdout);
446
+ const stderr = error.output?.stderr ?? "";
447
+ const stdout = error.output?.stdout ?? "";
440
448
  await context.emit("debug", {
441
449
  date: /* @__PURE__ */ new Date(),
442
450
  logs: [stdout, stderr].filter(Boolean)
@@ -445,7 +453,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
445
453
  if (stdout) console.log(stdout);
446
454
  const errorMessage = /* @__PURE__ */ new Error(`Hook execute failed: ${commandWithArgs}`);
447
455
  await context.emit("hook:end", {
448
- command: command$1,
456
+ command,
449
457
  args,
450
458
  id,
451
459
  success: false,
@@ -456,20 +464,21 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
456
464
  return;
457
465
  }
458
466
  clack.intro(text);
459
- const logger = clack.taskLog({ title: getMessage(["Executing hook", logLevel >= LogLevel.info ? pc.dim(commandWithArgs) : void 0].filter(Boolean).join(" ")) });
467
+ const logger = clack.taskLog({ title: getMessage(["Executing hook", logLevel >= LogLevel.info ? styleText("dim", commandWithArgs) : void 0].filter(Boolean).join(" ")) });
460
468
  const writable = new ClackWritable(logger);
461
469
  try {
462
- const result = await execa(command$1, args, {
463
- detached: true,
464
- stdout: ["pipe", writable],
465
- stripFinalNewline: true
470
+ const proc = x(command, [...args ?? []], {
471
+ nodeOptions: { detached: true },
472
+ throwOnError: true
466
473
  });
474
+ for await (const line of proc) writable.write(line);
475
+ const result = await proc;
467
476
  await context.emit("debug", {
468
477
  date: /* @__PURE__ */ new Date(),
469
- logs: [result.stdout]
478
+ logs: [result.stdout.trimEnd()]
470
479
  });
471
480
  await context.emit("hook:end", {
472
- command: command$1,
481
+ command,
473
482
  args,
474
483
  id,
475
484
  success: true,
@@ -477,8 +486,8 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
477
486
  });
478
487
  } catch (err) {
479
488
  const error = err;
480
- const stderr = typeof error.stderr === "string" ? error.stderr : String(error.stderr);
481
- const stdout = typeof error.stdout === "string" ? error.stdout : String(error.stdout);
489
+ const stderr = error.output?.stderr ?? "";
490
+ const stdout = error.output?.stdout ?? "";
482
491
  await context.emit("debug", {
483
492
  date: /* @__PURE__ */ new Date(),
484
493
  logs: [stdout, stderr].filter(Boolean)
@@ -487,7 +496,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
487
496
  if (stdout) logger.message(stdout);
488
497
  const errorMessage = /* @__PURE__ */ new Error(`Hook execute failed: ${commandWithArgs}`);
489
498
  await context.emit("hook:end", {
490
- command: command$1,
499
+ command,
491
500
  args,
492
501
  id,
493
502
  success: false,
@@ -496,10 +505,9 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
496
505
  await context.emit("error", errorMessage);
497
506
  }
498
507
  });
499
- context.on("hook:end", ({ command: command$1, args }) => {
508
+ context.on("hook:end", ({ command, args }) => {
500
509
  if (logLevel <= LogLevel.silent) return;
501
- const commandWithArgs = args?.length ? `${command$1} ${args.join(" ")}` : command$1;
502
- const text = getMessage(`Hook ${pc.dim(commandWithArgs)} successfully executed`);
510
+ const text = getMessage(`Hook ${styleText("dim", args?.length ? `${command} ${args.join(" ")}` : command)} successfully executed`);
503
511
  clack.outro(text);
504
512
  });
505
513
  context.on("generation:summary", (config, { pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
@@ -517,7 +525,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
517
525
  if (status === "success") {
518
526
  clack.box(summary.join("\n"), getMessage(title), {
519
527
  width: "auto",
520
- formatBorder: pc.green,
528
+ formatBorder: (s) => styleText("green", s),
521
529
  rounded: true,
522
530
  withGuide: false,
523
531
  contentAlign: "left",
@@ -527,7 +535,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
527
535
  }
528
536
  clack.box(summary.join("\n"), getMessage(title), {
529
537
  width: "auto",
530
- formatBorder: pc.red,
538
+ formatBorder: (s) => styleText("red", s),
531
539
  rounded: true,
532
540
  withGuide: false,
533
541
  contentAlign: "left",
@@ -709,25 +717,22 @@ const githubActionsLogger = defineLogger({
709
717
  const parts = [];
710
718
  const duration = formatHrtime(state.hrStart);
711
719
  if (state.totalPlugins > 0) {
712
- const pluginStr = state.failedPlugins > 0 ? `Plugins ${pc.green(state.completedPlugins.toString())}/${state.totalPlugins} ${pc.red(`(${state.failedPlugins} failed)`)}` : `Plugins ${pc.green(state.completedPlugins.toString())}/${state.totalPlugins}`;
720
+ const pluginStr = state.failedPlugins > 0 ? `Plugins ${styleText("green", state.completedPlugins.toString())}/${state.totalPlugins} ${styleText("red", `(${state.failedPlugins} failed)`)}` : `Plugins ${styleText("green", state.completedPlugins.toString())}/${state.totalPlugins}`;
713
721
  parts.push(pluginStr);
714
722
  }
715
- if (state.totalFiles > 0) parts.push(`Files ${pc.green(state.processedFiles.toString())}/${state.totalFiles}`);
723
+ if (state.totalFiles > 0) parts.push(`Files ${styleText("green", state.processedFiles.toString())}/${state.totalFiles}`);
716
724
  if (parts.length > 0) {
717
- parts.push(`${pc.green(duration)} elapsed`);
718
- console.log(getMessage(parts.join(pc.dim(" | "))));
725
+ parts.push(`${styleText("green", duration)} elapsed`);
726
+ console.log(getMessage(parts.join(styleText("dim", " | "))));
719
727
  }
720
728
  }
721
729
  function getMessage(message) {
722
- if (logLevel >= LogLevel.verbose) {
723
- const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
724
- hour12: false,
725
- hour: "2-digit",
726
- minute: "2-digit",
727
- second: "2-digit"
728
- });
729
- return [pc.dim(`[${timestamp}]`), message].join(" ");
730
- }
730
+ if (logLevel >= LogLevel.verbose) return [styleText("dim", `[${(/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
731
+ hour12: false,
732
+ hour: "2-digit",
733
+ minute: "2-digit",
734
+ second: "2-digit"
735
+ })}]`), message].join(" ");
731
736
  return message;
732
737
  }
733
738
  function openGroup(name) {
@@ -739,27 +744,27 @@ const githubActionsLogger = defineLogger({
739
744
  context.on("info", (message, info = "") => {
740
745
  if (logLevel <= LogLevel.silent) return;
741
746
  const text = getMessage([
742
- pc.blue("ℹ"),
747
+ styleText("blue", "ℹ"),
743
748
  message,
744
- pc.dim(info)
749
+ styleText("dim", info)
745
750
  ].join(" "));
746
751
  console.log(text);
747
752
  });
748
753
  context.on("success", (message, info = "") => {
749
754
  if (logLevel <= LogLevel.silent) return;
750
755
  const text = getMessage([
751
- pc.blue("✓"),
756
+ styleText("blue", "✓"),
752
757
  message,
753
- logLevel >= LogLevel.info ? pc.dim(info) : void 0
758
+ logLevel >= LogLevel.info ? styleText("dim", info) : void 0
754
759
  ].filter(Boolean).join(" "));
755
760
  console.log(text);
756
761
  });
757
762
  context.on("warn", (message, info = "") => {
758
763
  if (logLevel <= LogLevel.silent) return;
759
764
  const text = getMessage([
760
- pc.yellow("⚠"),
765
+ styleText("yellow", "⚠"),
761
766
  message,
762
- logLevel >= LogLevel.info ? pc.dim(info) : void 0
767
+ logLevel >= LogLevel.info ? styleText("dim", info) : void 0
763
768
  ].filter(Boolean).join(" "));
764
769
  console.warn(`::warning::${text}`);
765
770
  });
@@ -770,16 +775,16 @@ const githubActionsLogger = defineLogger({
770
775
  console.error(`::error::${message}`);
771
776
  if (logLevel >= LogLevel.debug && error.stack) {
772
777
  const frames = error.stack.split("\n").slice(1, 4);
773
- for (const frame of frames) console.log(getMessage(pc.dim(frame.trim())));
778
+ for (const frame of frames) console.log(getMessage(styleText("dim", frame.trim())));
774
779
  if (caused?.stack) {
775
- console.log(pc.dim(`└─ caused by ${caused.message}`));
776
- const frames$1 = caused.stack.split("\n").slice(1, 4);
777
- for (const frame of frames$1) console.log(getMessage(` ${pc.dim(frame.trim())}`));
780
+ console.log(styleText("dim", `└─ caused by ${caused.message}`));
781
+ const frames = caused.stack.split("\n").slice(1, 4);
782
+ for (const frame of frames) console.log(getMessage(` ${styleText("dim", frame.trim())}`));
778
783
  }
779
784
  }
780
785
  });
781
- context.on("lifecycle:start", (version$1) => {
782
- console.log(pc.yellow(`Kubb ${version$1} 🧩`));
786
+ context.on("lifecycle:start", (version) => {
787
+ console.log(styleText("yellow", `Kubb ${version} 🧩`));
783
788
  reset();
784
789
  });
785
790
  context.on("config:start", () => {
@@ -797,14 +802,14 @@ const githubActionsLogger = defineLogger({
797
802
  });
798
803
  context.on("generation:start", (config) => {
799
804
  state.totalPlugins = config.plugins?.length || 0;
800
- const text = config.name ? `Generation for ${pc.bold(config.name)}` : "Generation";
805
+ const text = config.name ? `Generation for ${styleText("bold", config.name)}` : "Generation";
801
806
  if (state.currentConfigs.length > 1) openGroup(text);
802
807
  if (state.currentConfigs.length === 1) console.log(getMessage(text));
803
808
  reset();
804
809
  });
805
810
  context.on("plugin:start", (plugin) => {
806
811
  if (logLevel <= LogLevel.silent) return;
807
- const text = getMessage(`Generating ${pc.bold(plugin.name)}`);
812
+ const text = getMessage(`Generating ${styleText("bold", plugin.name)}`);
808
813
  if (state.currentConfigs.length === 1) openGroup(`Plugin: ${plugin.name}`);
809
814
  console.log(text);
810
815
  });
@@ -813,7 +818,7 @@ const githubActionsLogger = defineLogger({
813
818
  if (success) state.completedPlugins++;
814
819
  else state.failedPlugins++;
815
820
  const durationStr = formatMsWithColor(duration);
816
- const text = getMessage(success ? `${pc.bold(plugin.name)} completed in ${durationStr}` : `${pc.bold(plugin.name)} failed in ${pc.red(formatMs(duration))}`);
821
+ const text = getMessage(success ? `${styleText("bold", plugin.name)} completed in ${durationStr}` : `${styleText("bold", plugin.name)} failed in ${styleText("red", formatMs(duration))}`);
817
822
  console.log(text);
818
823
  if (state.currentConfigs.length > 1) console.log(" ");
819
824
  if (state.currentConfigs.length === 1) closeGroup(`Plugin: ${plugin.name}`);
@@ -842,7 +847,7 @@ const githubActionsLogger = defineLogger({
842
847
  showProgressStep();
843
848
  });
844
849
  context.on("generation:end", (config) => {
845
- const text = getMessage(config.name ? `${pc.blue("✓")} Generation completed for ${pc.dim(config.name)}` : `${pc.blue("✓")} Generation completed`);
850
+ const text = getMessage(config.name ? `${styleText("blue", "✓")} Generation completed for ${styleText("dim", config.name)}` : `${styleText("blue", "✓")} Generation completed`);
846
851
  console.log(text);
847
852
  });
848
853
  context.on("format:start", () => {
@@ -869,26 +874,26 @@ const githubActionsLogger = defineLogger({
869
874
  console.log(text);
870
875
  if (state.currentConfigs.length === 1) closeGroup("Linting");
871
876
  });
872
- context.on("hook:start", async ({ id, command: command$1, args }) => {
873
- const commandWithArgs = args?.length ? `${command$1} ${args.join(" ")}` : command$1;
874
- const text = getMessage(`Hook ${pc.dim(commandWithArgs)} started`);
877
+ context.on("hook:start", async ({ id, command, args }) => {
878
+ const commandWithArgs = args?.length ? `${command} ${args.join(" ")}` : command;
879
+ const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} started`);
875
880
  if (logLevel > LogLevel.silent) {
876
881
  if (state.currentConfigs.length === 1) openGroup(`Hook ${commandWithArgs}`);
877
882
  console.log(text);
878
883
  }
879
884
  if (!id) return;
880
885
  try {
881
- const result = await execa(command$1, args, {
882
- detached: true,
883
- stripFinalNewline: true
886
+ const result = await x(command, [...args ?? []], {
887
+ nodeOptions: { detached: true },
888
+ throwOnError: true
884
889
  });
885
890
  await context.emit("debug", {
886
891
  date: /* @__PURE__ */ new Date(),
887
- logs: [result.stdout]
892
+ logs: [result.stdout.trimEnd()]
888
893
  });
889
- if (logLevel > LogLevel.silent) console.log(result.stdout);
894
+ if (logLevel > LogLevel.silent) console.log(result.stdout.trimEnd());
890
895
  await context.emit("hook:end", {
891
- command: command$1,
896
+ command,
892
897
  args,
893
898
  id,
894
899
  success: true,
@@ -896,8 +901,8 @@ const githubActionsLogger = defineLogger({
896
901
  });
897
902
  } catch (err) {
898
903
  const error = err;
899
- const stderr = typeof error.stderr === "string" ? error.stderr : String(error.stderr);
900
- const stdout = typeof error.stdout === "string" ? error.stdout : String(error.stdout);
904
+ const stderr = error.output?.stderr ?? "";
905
+ const stdout = error.output?.stdout ?? "";
901
906
  await context.emit("debug", {
902
907
  date: /* @__PURE__ */ new Date(),
903
908
  logs: [stdout, stderr].filter(Boolean)
@@ -906,7 +911,7 @@ const githubActionsLogger = defineLogger({
906
911
  if (stdout) console.log(stdout);
907
912
  const errorMessage = /* @__PURE__ */ new Error(`Hook execute failed: ${commandWithArgs}`);
908
913
  await context.emit("hook:end", {
909
- command: command$1,
914
+ command,
910
915
  args,
911
916
  id,
912
917
  success: false,
@@ -915,10 +920,10 @@ const githubActionsLogger = defineLogger({
915
920
  await context.emit("error", errorMessage);
916
921
  }
917
922
  });
918
- context.on("hook:end", ({ command: command$1, args }) => {
923
+ context.on("hook:end", ({ command, args }) => {
919
924
  if (logLevel <= LogLevel.silent) return;
920
- const commandWithArgs = args?.length ? `${command$1} ${args.join(" ")}` : command$1;
921
- const text = getMessage(`Hook ${pc.dim(commandWithArgs)} completed`);
925
+ const commandWithArgs = args?.length ? `${command} ${args.join(" ")}` : command;
926
+ const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} completed`);
922
927
  console.log(text);
923
928
  if (state.currentConfigs.length === 1) closeGroup(`Hook ${commandWithArgs}`);
924
929
  });
@@ -927,8 +932,8 @@ const githubActionsLogger = defineLogger({
927
932
  const successCount = pluginsCount - failedPlugins.size;
928
933
  const duration = formatHrtime(hrStart);
929
934
  if (state.currentConfigs.length > 1) console.log(" ");
930
- console.log(status === "success" ? `Kubb Summary: ${pc.blue("✓")} ${`${successCount} successful`}, ${pluginsCount} total, ${pc.green(duration)}` : `Kubb Summary: ${pc.blue("✓")} ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total, ${pc.green(duration)}`);
931
- if (state.currentConfigs.length > 1) closeGroup(config.name ? `Generation for ${pc.bold(config.name)}` : "Generation");
935
+ console.log(status === "success" ? `Kubb Summary: ${styleText("blue", "✓")} ${`${successCount} successful`}, ${pluginsCount} total, ${styleText("green", duration)}` : `Kubb Summary: ${styleText("blue", "✓")} ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total, ${styleText("green", duration)}`);
936
+ if (state.currentConfigs.length > 1) closeGroup(config.name ? `Generation for ${styleText("bold", config.name)}` : "Generation");
932
937
  });
933
938
  }
934
939
  });
@@ -988,8 +993,8 @@ const plainLogger = defineLogger({
988
993
  for (const frame of frames) console.log(getMessage(frame.trim()));
989
994
  if (caused?.stack) {
990
995
  console.log(`└─ caused by ${caused.message}`);
991
- const frames$1 = caused.stack.split("\n").slice(1, 4);
992
- for (const frame of frames$1) console.log(getMessage(` ${frame.trim()}`));
996
+ const frames = caused.stack.split("\n").slice(1, 4);
997
+ for (const frame of frames) console.log(getMessage(` ${frame.trim()}`));
993
998
  }
994
999
  }
995
1000
  });
@@ -1060,23 +1065,23 @@ const plainLogger = defineLogger({
1060
1065
  const text = getMessage("Lint completed");
1061
1066
  console.log(text);
1062
1067
  });
1063
- context.on("hook:start", async ({ id, command: command$1, args }) => {
1064
- const commandWithArgs = args?.length ? `${command$1} ${args.join(" ")}` : command$1;
1068
+ context.on("hook:start", async ({ id, command, args }) => {
1069
+ const commandWithArgs = args?.length ? `${command} ${args.join(" ")}` : command;
1065
1070
  const text = getMessage(`Hook ${commandWithArgs} started`);
1066
1071
  if (logLevel > LogLevel.silent) console.log(text);
1067
1072
  if (!id) return;
1068
1073
  try {
1069
- const result = await execa(command$1, args, {
1070
- detached: true,
1071
- stripFinalNewline: true
1074
+ const result = await x(command, [...args ?? []], {
1075
+ nodeOptions: { detached: true },
1076
+ throwOnError: true
1072
1077
  });
1073
1078
  await context.emit("debug", {
1074
1079
  date: /* @__PURE__ */ new Date(),
1075
- logs: [result.stdout]
1080
+ logs: [result.stdout.trimEnd()]
1076
1081
  });
1077
- if (logLevel > LogLevel.silent) console.log(result.stdout);
1082
+ if (logLevel > LogLevel.silent) console.log(result.stdout.trimEnd());
1078
1083
  await context.emit("hook:end", {
1079
- command: command$1,
1084
+ command,
1080
1085
  args,
1081
1086
  id,
1082
1087
  success: true,
@@ -1084,8 +1089,8 @@ const plainLogger = defineLogger({
1084
1089
  });
1085
1090
  } catch (err) {
1086
1091
  const error = err;
1087
- const stderr = typeof error.stderr === "string" ? error.stderr : String(error.stderr);
1088
- const stdout = typeof error.stdout === "string" ? error.stdout : String(error.stdout);
1092
+ const stderr = error.output?.stderr ?? "";
1093
+ const stdout = error.output?.stdout ?? "";
1089
1094
  await context.emit("debug", {
1090
1095
  date: /* @__PURE__ */ new Date(),
1091
1096
  logs: [stdout, stderr].filter(Boolean)
@@ -1094,7 +1099,7 @@ const plainLogger = defineLogger({
1094
1099
  if (stdout) console.log(stdout);
1095
1100
  const errorMessage = /* @__PURE__ */ new Error(`Hook execute failed: ${commandWithArgs}`);
1096
1101
  await context.emit("hook:end", {
1097
- command: command$1,
1102
+ command,
1098
1103
  args,
1099
1104
  id,
1100
1105
  success: false,
@@ -1103,9 +1108,9 @@ const plainLogger = defineLogger({
1103
1108
  await context.emit("error", errorMessage);
1104
1109
  }
1105
1110
  });
1106
- context.on("hook:end", ({ command: command$1, args }) => {
1111
+ context.on("hook:end", ({ command, args }) => {
1107
1112
  if (logLevel <= LogLevel.silent) return;
1108
- const text = getMessage(`Hook ${args?.length ? `${command$1} ${args.join(" ")}` : command$1} completed`);
1113
+ const text = getMessage(`Hook ${args?.length ? `${command} ${args.join(" ")}` : command} completed`);
1109
1114
  console.log(text);
1110
1115
  });
1111
1116
  context.on("generation:summary", (config, { pluginTimings, status, hrStart, failedPlugins, filesCreated }) => {
@@ -1149,10 +1154,10 @@ async function setupLogger(context, { logLevel }) {
1149
1154
  //#region src/utils/executeHooks.ts
1150
1155
  async function executeHooks({ hooks, events }) {
1151
1156
  const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done].filter(Boolean);
1152
- for (const command$1 of commands) {
1153
- const [cmd, ...args] = [...parseArgsStringToArgv(command$1)];
1157
+ for (const command of commands) {
1158
+ const [cmd, ...args] = tokenize(command);
1154
1159
  if (!cmd) continue;
1155
- const hookId = createHash("sha256").update(command$1).digest("hex");
1160
+ const hookId = createHash("sha256").update(command).digest("hex");
1156
1161
  await events.emit("hook:start", {
1157
1162
  id: hookId,
1158
1163
  command: cmd,
@@ -1160,7 +1165,7 @@ async function executeHooks({ hooks, events }) {
1160
1165
  });
1161
1166
  await events.onOnce("hook:end", async ({ success, error }) => {
1162
1167
  if (!success) throw error;
1163
- await events.emit("success", `${pc.dim(command$1)} successfully executed`);
1168
+ await events.emit("success", `${styleText("dim", command)} successfully executed`);
1164
1169
  });
1165
1170
  }
1166
1171
  }
@@ -1186,12 +1191,12 @@ async function generate({ input, config: userConfig, events, logLevel }) {
1186
1191
  }
1187
1192
  };
1188
1193
  await events.emit("generation:start", config);
1189
- await events.emit("info", config.name ? `Setup generation ${pc.bold(config.name)}` : "Setup generation", inputPath);
1194
+ await events.emit("info", config.name ? `Setup generation ${styleText("bold", config.name)}` : "Setup generation", inputPath);
1190
1195
  const { sources, fabric, pluginManager } = await setup({
1191
1196
  config,
1192
1197
  events
1193
1198
  });
1194
- await events.emit("info", config.name ? `Build generation ${pc.bold(config.name)}` : "Build generation", inputPath);
1199
+ await events.emit("info", config.name ? `Build generation ${styleText("bold", config.name)}` : "Build generation", inputPath);
1195
1200
  const { files, failedPlugins, pluginTimings, error } = await safeBuild({
1196
1201
  config,
1197
1202
  events
@@ -1226,7 +1231,7 @@ async function generate({ input, config: userConfig, events, logLevel }) {
1226
1231
  if (!detectedFormatter) await events.emit("warn", "No formatter found (biome, prettier, or oxfmt). Skipping formatting.");
1227
1232
  else {
1228
1233
  formatter = detectedFormatter;
1229
- await events.emit("info", `Auto-detected formatter: ${pc.dim(formatter)}`);
1234
+ await events.emit("info", `Auto-detected formatter: ${styleText("dim", formatter)}`);
1230
1235
  }
1231
1236
  }
1232
1237
  if (formatter && formatter !== "auto" && formatter in formatters) {
@@ -1239,18 +1244,18 @@ async function generate({ input, config: userConfig, events, logLevel }) {
1239
1244
  command: formatterConfig.command,
1240
1245
  args: formatterConfig.args(outputPath)
1241
1246
  });
1242
- await events.onOnce("hook:end", async ({ success, error: error$1 }) => {
1243
- if (!success) throw error$1;
1247
+ await events.onOnce("hook:end", async ({ success, error }) => {
1248
+ if (!success) throw error;
1244
1249
  await events.emit("success", [
1245
- `Formatting with ${pc.dim(formatter)}`,
1246
- logLevel >= LogLevel.info ? `on ${pc.dim(outputPath)}` : void 0,
1250
+ `Formatting with ${styleText("dim", formatter)}`,
1251
+ logLevel >= LogLevel.info ? `on ${styleText("dim", outputPath)}` : void 0,
1247
1252
  "successfully"
1248
1253
  ].filter(Boolean).join(" "));
1249
1254
  });
1250
1255
  } catch (caughtError) {
1251
- const error$1 = new Error(formatterConfig.errorMessage);
1252
- error$1.cause = caughtError;
1253
- await events.emit("error", error$1);
1256
+ const error = new Error(formatterConfig.errorMessage);
1257
+ error.cause = caughtError;
1258
+ await events.emit("error", error);
1254
1259
  }
1255
1260
  }
1256
1261
  await events.emit("format:end");
@@ -1263,7 +1268,7 @@ async function generate({ input, config: userConfig, events, logLevel }) {
1263
1268
  if (!detectedLinter) await events.emit("warn", "No linter found (biome, oxlint, or eslint). Skipping linting.");
1264
1269
  else {
1265
1270
  linter = detectedLinter;
1266
- await events.emit("info", `Auto-detected linter: ${pc.dim(linter)}`);
1271
+ await events.emit("info", `Auto-detected linter: ${styleText("dim", linter)}`);
1267
1272
  }
1268
1273
  }
1269
1274
  if (linter && linter !== "auto" && linter in linters) {
@@ -1276,18 +1281,18 @@ async function generate({ input, config: userConfig, events, logLevel }) {
1276
1281
  command: linterConfig.command,
1277
1282
  args: linterConfig.args(outputPath)
1278
1283
  });
1279
- await events.onOnce("hook:end", async ({ success, error: error$1 }) => {
1280
- if (!success) throw error$1;
1284
+ await events.onOnce("hook:end", async ({ success, error }) => {
1285
+ if (!success) throw error;
1281
1286
  await events.emit("success", [
1282
- `Linting with ${pc.dim(linter)}`,
1283
- logLevel >= LogLevel.info ? `on ${pc.dim(outputPath)}` : void 0,
1287
+ `Linting with ${styleText("dim", linter)}`,
1288
+ logLevel >= LogLevel.info ? `on ${styleText("dim", outputPath)}` : void 0,
1284
1289
  "successfully"
1285
1290
  ].filter(Boolean).join(" "));
1286
1291
  });
1287
1292
  } catch (caughtError) {
1288
- const error$1 = new Error(linterConfig.errorMessage);
1289
- error$1.cause = caughtError;
1290
- await events.emit("error", error$1);
1293
+ const error = new Error(linterConfig.errorMessage);
1294
+ error.cause = caughtError;
1295
+ await events.emit("error", error);
1291
1296
  }
1292
1297
  }
1293
1298
  await events.emit("lint:end");
@@ -1362,17 +1367,17 @@ async function getCosmiConfig(moduleName, config) {
1362
1367
 
1363
1368
  //#endregion
1364
1369
  //#region src/utils/watcher.ts
1365
- async function startWatcher(path$1, cb) {
1370
+ async function startWatcher(path, cb) {
1366
1371
  const { watch } = await import("chokidar");
1367
- watch(path$1, {
1372
+ watch(path, {
1368
1373
  ignorePermissionErrors: true,
1369
1374
  ignored: "**/{.git,node_modules}/**"
1370
1375
  }).on("all", async (type, file) => {
1371
- console.log(pc.yellow(pc.bold(`Change detected: ${type} ${file}`)));
1376
+ console.log(styleText("yellow", styleText("bold", `Change detected: ${type} ${file}`)));
1372
1377
  try {
1373
- await cb(path$1);
1378
+ await cb(path);
1374
1379
  } catch (_e) {
1375
- console.log(pc.red("Watcher failed"));
1380
+ console.log(styleText("red", "Watcher failed"));
1376
1381
  }
1377
1382
  });
1378
1383
  }
@@ -1440,8 +1445,10 @@ const command = defineCommand({
1440
1445
  const logLevel = LogLevel[args.logLevel] || 3;
1441
1446
  await setupLogger(events, { logLevel });
1442
1447
  await executeIfOnline(async () => {
1443
- const latestVersion = await getLatestVersion("@kubb/cli");
1444
- if (lt(version, latestVersion)) await events.emit("version:new", version, latestVersion);
1448
+ try {
1449
+ const latestVersion = (await (await fetch("https://registry.npmjs.org/@kubb/cli/latest")).json()).version;
1450
+ if (latestVersion && version < latestVersion) await events.emit("version:new", version, latestVersion);
1451
+ } catch {}
1445
1452
  });
1446
1453
  try {
1447
1454
  const result = await getCosmiConfig("kubb", args.config);
@@ -1455,13 +1462,14 @@ const command = defineCommand({
1455
1462
  return async () => {
1456
1463
  if (isInputPath(config) && args.watch) {
1457
1464
  await startWatcher([input || config.input.path], async (paths) => {
1465
+ events.removeAll();
1458
1466
  await generate({
1459
1467
  input,
1460
1468
  config,
1461
1469
  logLevel,
1462
1470
  events
1463
1471
  });
1464
- clack.log.step(pc.yellow(`Watching for changes in ${paths.join(" and ")}`));
1472
+ clack.log.step(styleText("yellow", `Watching for changes in ${paths.join(" and ")}`));
1465
1473
  });
1466
1474
  return;
1467
1475
  }
@@ -1481,8 +1489,7 @@ const command = defineCommand({
1481
1489
  }
1482
1490
  }
1483
1491
  });
1484
- var generate_default = command;
1485
1492
 
1486
1493
  //#endregion
1487
- export { generate_default as default };
1488
- //# sourceMappingURL=generate-CQudcsre.js.map
1494
+ export { command as default };
1495
+ //# sourceMappingURL=generate-CGEE6Etf.js.map