@kubb/cli 4.12.7 → 4.12.9

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.
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-CbDLau6x.cjs');
2
- const require_package = require('./package-CrqsFX0R.cjs');
2
+ const require_package = require('./package-BH-tJYrG.cjs');
3
3
  let citty = require("citty");
4
4
  let node_path = require("node:path");
5
5
  node_path = require_chunk.__toESM(node_path);
@@ -21,6 +21,7 @@ let seedrandom = require("seedrandom");
21
21
  seedrandom = require_chunk.__toESM(seedrandom);
22
22
  let node_stream = require("node:stream");
23
23
  let _kubb_core_fs = require("@kubb/core/fs");
24
+ let node_crypto = require("node:crypto");
24
25
  let string_argv = require("string-argv");
25
26
  let cosmiconfig = require("cosmiconfig");
26
27
  let jiti = require("jiti");
@@ -127,6 +128,21 @@ const clackLogger = (0, _kubb_core.defineLogger)({
127
128
  isSpinning: false,
128
129
  activeProgress: /* @__PURE__ */ new Map()
129
130
  };
131
+ function reset() {
132
+ for (const [_key, active] of state.activeProgress) {
133
+ if (active.interval) clearInterval(active.interval);
134
+ active.progressBar?.stop();
135
+ }
136
+ state.totalPlugins = 0;
137
+ state.completedPlugins = 0;
138
+ state.failedPlugins = 0;
139
+ state.totalFiles = 0;
140
+ state.processedFiles = 0;
141
+ state.hrStart = node_process.default.hrtime();
142
+ state.spinner = _clack_prompts.spinner();
143
+ state.isSpinning = false;
144
+ state.activeProgress.clear();
145
+ }
130
146
  function showProgressStep() {
131
147
  if (logLevel <= _kubb_core.LogLevel.silent) return;
132
148
  const parts = [];
@@ -137,8 +153,8 @@ const clackLogger = (0, _kubb_core.defineLogger)({
137
153
  }
138
154
  if (state.totalFiles > 0) parts.push(`Files ${picocolors.default.green(state.processedFiles.toString())}/${state.totalFiles}`);
139
155
  if (parts.length > 0) {
140
- parts.push(picocolors.default.green(duration));
141
- _clack_prompts.log.step(parts.join(picocolors.default.dim(" | ")));
156
+ parts.push(`${picocolors.default.green(duration)} elapsed`);
157
+ _clack_prompts.log.step(getMessage(parts.join(picocolors.default.dim(" | "))));
142
158
  }
143
159
  }
144
160
  function getMessage(message) {
@@ -223,6 +239,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
223
239
  "#F5A217",
224
240
  "#F55A17"
225
241
  ])(`Kubb ${version$1} 🧩`));
242
+ reset();
226
243
  });
227
244
  context.on("config:start", () => {
228
245
  if (logLevel <= _kubb_core.LogLevel.silent) return;
@@ -237,11 +254,9 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
237
254
  });
238
255
  context.on("generation:start", (config) => {
239
256
  state.totalPlugins = config.plugins?.length || 0;
240
- state.completedPlugins = 0;
241
- state.failedPlugins = 0;
242
- state.hrStart = node_process.default.hrtime();
243
257
  const text = getMessage(["Generation started", config.name ? `for ${picocolors.default.dim(config.name)}` : void 0].filter(Boolean).join(" "));
244
258
  _clack_prompts.intro(text);
259
+ reset();
245
260
  });
246
261
  context.on("plugin:start", (plugin) => {
247
262
  if (logLevel <= _kubb_core.LogLevel.silent) return;
@@ -255,7 +270,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
255
270
  progressBar.start(text);
256
271
  const interval = setInterval(() => {
257
272
  progressBar.advance();
258
- }, 50);
273
+ }, 100);
259
274
  state.activeProgress.set(plugin.name, {
260
275
  progressBar,
261
276
  interval
@@ -312,7 +327,28 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
312
327
  const text = getMessage(config.name ? `Generation completed for ${picocolors.default.dim(config.name)}` : "Generation completed");
313
328
  _clack_prompts.outro(text);
314
329
  });
315
- context.on("hook:execute", async ({ command: command$1, args }, cb) => {
330
+ context.on("format:start", () => {
331
+ if (logLevel <= _kubb_core.LogLevel.silent) return;
332
+ const text = getMessage("Format started");
333
+ _clack_prompts.intro(text);
334
+ });
335
+ context.on("format:end", () => {
336
+ if (logLevel <= _kubb_core.LogLevel.silent) return;
337
+ const text = getMessage("Format completed");
338
+ _clack_prompts.outro(text);
339
+ });
340
+ context.on("lint:start", () => {
341
+ if (logLevel <= _kubb_core.LogLevel.silent) return;
342
+ const text = getMessage("Lint started");
343
+ _clack_prompts.intro(text);
344
+ });
345
+ context.on("lint:end", () => {
346
+ if (logLevel <= _kubb_core.LogLevel.silent) return;
347
+ const text = getMessage("Lint completed");
348
+ _clack_prompts.outro(text);
349
+ });
350
+ context.on("hook:start", async ({ id, command: command$1, args }) => {
351
+ const text = getMessage(`Hook ${picocolors.default.dim(command$1)} started`);
316
352
  if (logLevel <= _kubb_core.LogLevel.silent) {
317
353
  try {
318
354
  const result = await (0, execa.execa)(command$1, args, {
@@ -323,7 +359,10 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
323
359
  date: /* @__PURE__ */ new Date(),
324
360
  logs: [result.stdout]
325
361
  });
326
- cb();
362
+ await context.emit("hook:end", {
363
+ command: command$1,
364
+ id
365
+ });
327
366
  } catch (err) {
328
367
  const error = /* @__PURE__ */ new Error("Hook execute failed");
329
368
  error.cause = err;
@@ -335,6 +374,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
335
374
  }
336
375
  return;
337
376
  }
377
+ _clack_prompts.intro(text);
338
378
  const writable = new ClackWritable(_clack_prompts.taskLog({ title: getMessage(["Executing hook", logLevel >= _kubb_core.LogLevel.info ? picocolors.default.dim(`${command$1} ${args?.join(" ")}`) : void 0].filter(Boolean).join(" ")) }));
339
379
  try {
340
380
  const result = await (0, execa.execa)(command$1, args, {
@@ -346,7 +386,10 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
346
386
  date: /* @__PURE__ */ new Date(),
347
387
  logs: [result.stdout]
348
388
  });
349
- cb();
389
+ await context.emit("hook:end", {
390
+ command: command$1,
391
+ id
392
+ });
350
393
  } catch (err) {
351
394
  const error = /* @__PURE__ */ new Error("Hook execute failed");
352
395
  error.cause = err;
@@ -357,34 +400,9 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
357
400
  await context.emit("error", error);
358
401
  }
359
402
  });
360
- context.on("format:start", () => {
361
- if (logLevel <= _kubb_core.LogLevel.silent) return;
362
- const text = getMessage("Format started");
363
- _clack_prompts.intro(text);
364
- });
365
- context.on("format:end", () => {
403
+ context.on("hook:end", ({ command: command$1 }) => {
366
404
  if (logLevel <= _kubb_core.LogLevel.silent) return;
367
- const text = getMessage("Format completed");
368
- _clack_prompts.outro(text);
369
- });
370
- context.on("lint:start", () => {
371
- if (logLevel <= _kubb_core.LogLevel.silent) return;
372
- const text = getMessage("Lint started");
373
- _clack_prompts.intro(text);
374
- });
375
- context.on("lint:end", () => {
376
- if (logLevel <= _kubb_core.LogLevel.silent) return;
377
- const text = getMessage("Lint completed");
378
- _clack_prompts.outro(text);
379
- });
380
- context.on("hook:start", (command$1) => {
381
- if (logLevel <= _kubb_core.LogLevel.silent) return;
382
- const text = getMessage(`Hook ${picocolors.default.dim(command$1)} started`);
383
- _clack_prompts.intro(text);
384
- });
385
- context.on("hook:end", (command$1) => {
386
- if (logLevel <= _kubb_core.LogLevel.silent) return;
387
- const text = getMessage(`Hook ${picocolors.default.dim(command$1)} completed`);
405
+ const text = getMessage(`Hook ${picocolors.default.dim(command$1)} successfully executed`);
388
406
  _clack_prompts.outro(text);
389
407
  });
390
408
  context.on("generation:summary", (config, { pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
@@ -420,11 +438,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
420
438
  });
421
439
  });
422
440
  context.on("lifecycle:end", () => {
423
- for (const [_key, active] of state.activeProgress) {
424
- if (active.interval) clearInterval(active.interval);
425
- active.progressBar?.stop();
426
- }
427
- state.activeProgress.clear();
441
+ reset();
428
442
  });
429
443
  }
430
444
  });
@@ -462,36 +476,97 @@ function canUseTTY() {
462
476
  const fileSystemLogger = (0, _kubb_core.defineLogger)({
463
477
  name: "filesystem",
464
478
  install(context) {
465
- const cachedLogs = /* @__PURE__ */ new Set();
466
- const startDate = Date.now();
467
- async function writeLogs() {
468
- if (cachedLogs.size === 0) return;
479
+ const state = {
480
+ cachedLogs: /* @__PURE__ */ new Set(),
481
+ startDate: Date.now()
482
+ };
483
+ function reset() {
484
+ state.cachedLogs = /* @__PURE__ */ new Set();
485
+ state.startDate = Date.now();
486
+ }
487
+ async function writeLogs(name) {
488
+ if (state.cachedLogs.size === 0) return;
469
489
  const files = {};
470
- for (const log of cachedLogs) {
471
- const fileName = (0, node_path.resolve)(process.cwd(), ".kubb", log.fileName || `kubb-${startDate}.log`);
472
- if (!files[fileName]) files[fileName] = [];
490
+ for (const log of state.cachedLogs) {
491
+ const baseName = log.fileName || `${[
492
+ "kubb",
493
+ name,
494
+ state.startDate
495
+ ].filter(Boolean).join("-")}.log`;
496
+ const pathName = (0, node_path.resolve)(process.cwd(), ".kubb", baseName);
497
+ if (!files[pathName]) files[pathName] = [];
473
498
  if (log.logs.length > 0) {
474
499
  const timestamp = log.date.toLocaleString();
475
- files[fileName].push(`[${timestamp}]\n${log.logs.join("\n")}`);
500
+ files[pathName].push(`[${timestamp}]\n${log.logs.join("\n")}`);
476
501
  }
477
502
  }
478
503
  await Promise.all(Object.entries(files).map(async ([fileName, logs]) => {
479
504
  return (0, _kubb_core_fs.write)(fileName, logs.join("\n\n"));
480
505
  }));
481
- cachedLogs.clear();
482
506
  }
507
+ context.on("info", (message, info) => {
508
+ state.cachedLogs.add({
509
+ date: /* @__PURE__ */ new Date(),
510
+ logs: [`ℹ ${message} ${info}`],
511
+ fileName: void 0
512
+ });
513
+ });
514
+ context.on("success", (message, info) => {
515
+ state.cachedLogs.add({
516
+ date: /* @__PURE__ */ new Date(),
517
+ logs: [`✓ ${message} ${info}`],
518
+ fileName: void 0
519
+ });
520
+ });
521
+ context.on("warn", (message, info) => {
522
+ state.cachedLogs.add({
523
+ date: /* @__PURE__ */ new Date(),
524
+ logs: [`⚠ ${message} ${info}`],
525
+ fileName: void 0
526
+ });
527
+ });
528
+ context.on("error", (error) => {
529
+ state.cachedLogs.add({
530
+ date: /* @__PURE__ */ new Date(),
531
+ logs: [`✗ ${error.message}`, error.stack || "unknown stack"],
532
+ fileName: void 0
533
+ });
534
+ });
483
535
  context.on("debug", (message) => {
484
- cachedLogs.add({
536
+ state.cachedLogs.add({
485
537
  date: /* @__PURE__ */ new Date(),
486
538
  logs: message.logs,
487
539
  fileName: void 0
488
540
  });
489
541
  });
490
- context.on("lifecycle:end", async () => {
491
- await writeLogs();
542
+ context.on("plugin:start", (plugin) => {
543
+ state.cachedLogs.add({
544
+ date: /* @__PURE__ */ new Date(),
545
+ logs: [`Generating ${plugin.name}`],
546
+ fileName: void 0
547
+ });
548
+ });
549
+ context.on("plugin:end", (plugin, { duration, success }) => {
550
+ const durationStr = (0, _kubb_core_utils.formatMs)(duration);
551
+ state.cachedLogs.add({
552
+ date: /* @__PURE__ */ new Date(),
553
+ logs: [success ? `${plugin.name} completed in ${durationStr}` : `${plugin.name} failed in ${durationStr}`],
554
+ fileName: void 0
555
+ });
556
+ });
557
+ context.on("files:processing:start", (files) => {
558
+ state.cachedLogs.add({
559
+ date: /* @__PURE__ */ new Date(),
560
+ logs: [`Start ${files.length} writing:`, ...files.map((file) => file.path)],
561
+ fileName: void 0
562
+ });
563
+ });
564
+ context.on("generation:end", async (config) => {
565
+ await writeLogs(config.name);
566
+ reset();
492
567
  });
493
568
  const exitHandler = () => {
494
- if (cachedLogs.size > 0) writeLogs().catch(() => {});
569
+ if (state.cachedLogs.size > 0) writeLogs().catch(() => {});
495
570
  };
496
571
  process.once("exit", exitHandler);
497
572
  process.once("SIGINT", exitHandler);
@@ -518,6 +593,14 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
518
593
  hrStart: process.hrtime(),
519
594
  currentConfigs: []
520
595
  };
596
+ function reset() {
597
+ state.totalPlugins = 0;
598
+ state.completedPlugins = 0;
599
+ state.failedPlugins = 0;
600
+ state.totalFiles = 0;
601
+ state.processedFiles = 0;
602
+ state.hrStart = process.hrtime();
603
+ }
521
604
  function showProgressStep() {
522
605
  if (logLevel <= _kubb_core.LogLevel.silent) return;
523
606
  const parts = [];
@@ -528,8 +611,8 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
528
611
  }
529
612
  if (state.totalFiles > 0) parts.push(`Files ${picocolors.default.green(state.processedFiles.toString())}/${state.totalFiles}`);
530
613
  if (parts.length > 0) {
531
- parts.push(picocolors.default.green(duration));
532
- console.log(parts.join(picocolors.default.dim(" | ")));
614
+ parts.push(`${picocolors.default.green(duration)} elapsed`);
615
+ console.log(getMessage(parts.join(picocolors.default.dim(" | "))));
533
616
  }
534
617
  }
535
618
  function getMessage(message) {
@@ -584,6 +667,7 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
584
667
  });
585
668
  context.on("lifecycle:start", (version$1) => {
586
669
  console.log(picocolors.default.yellow(`Kubb ${version$1} 🧩`));
670
+ reset();
587
671
  });
588
672
  context.on("config:start", () => {
589
673
  if (logLevel <= _kubb_core.LogLevel.silent) return;
@@ -600,12 +684,10 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
600
684
  });
601
685
  context.on("generation:start", (config) => {
602
686
  state.totalPlugins = config.plugins?.length || 0;
603
- state.completedPlugins = 0;
604
- state.failedPlugins = 0;
605
- state.hrStart = process.hrtime();
606
687
  const text = config.name ? `Generation for ${picocolors.default.bold(config.name)}` : "Generation";
607
688
  if (state.currentConfigs.length > 1) openGroup(text);
608
689
  if (state.currentConfigs.length === 1) console.log(getMessage(text));
690
+ reset();
609
691
  });
610
692
  context.on("plugin:start", (plugin) => {
611
693
  if (logLevel <= _kubb_core.LogLevel.silent) return;
@@ -650,28 +732,6 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
650
732
  const text = getMessage(config.name ? `${picocolors.default.blue("✓")} Generation completed for ${picocolors.default.dim(config.name)}` : `${picocolors.default.blue("✓")} Generation completed`);
651
733
  console.log(text);
652
734
  });
653
- context.on("hook:execute", async ({ command: command$1, args }, cb) => {
654
- try {
655
- const result = await (0, execa.execa)(command$1, args, {
656
- detached: true,
657
- stripFinalNewline: true
658
- });
659
- await context.emit("debug", {
660
- date: /* @__PURE__ */ new Date(),
661
- logs: [result.stdout]
662
- });
663
- console.log(result.stdout);
664
- cb();
665
- } catch (err) {
666
- const error = /* @__PURE__ */ new Error("Hook execute failed");
667
- error.cause = err;
668
- await context.emit("debug", {
669
- date: /* @__PURE__ */ new Date(),
670
- logs: [err.stdout]
671
- });
672
- await context.emit("error", error);
673
- }
674
- });
675
735
  context.on("format:start", () => {
676
736
  if (logLevel <= _kubb_core.LogLevel.silent) return;
677
737
  const text = getMessage("Format started");
@@ -696,23 +756,48 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
696
756
  console.log(text);
697
757
  if (state.currentConfigs.length === 1) closeGroup("Linting");
698
758
  });
699
- context.on("hook:start", (command$1) => {
700
- if (logLevel <= _kubb_core.LogLevel.silent) return;
759
+ context.on("hook:start", async ({ id, command: command$1, args }) => {
701
760
  const text = getMessage(`Hook ${picocolors.default.dim(command$1)} started`);
702
- if (state.currentConfigs.length === 1) openGroup(`Hook ${command$1}`);
703
- console.log(text);
761
+ if (logLevel > _kubb_core.LogLevel.silent) {
762
+ if (state.currentConfigs.length === 1) openGroup(`Hook ${command$1}`);
763
+ console.log(text);
764
+ }
765
+ try {
766
+ const result = await (0, execa.execa)(command$1, args, {
767
+ detached: true,
768
+ stripFinalNewline: true
769
+ });
770
+ await context.emit("debug", {
771
+ date: /* @__PURE__ */ new Date(),
772
+ logs: [result.stdout]
773
+ });
774
+ console.log(result.stdout);
775
+ await context.emit("hook:end", {
776
+ command: command$1,
777
+ id
778
+ });
779
+ } catch (err) {
780
+ const error = /* @__PURE__ */ new Error("Hook execute failed");
781
+ error.cause = err;
782
+ await context.emit("debug", {
783
+ date: /* @__PURE__ */ new Date(),
784
+ logs: [err.stdout]
785
+ });
786
+ await context.emit("error", error);
787
+ }
704
788
  });
705
- context.on("hook:end", (command$1) => {
789
+ context.on("hook:end", ({ command: command$1 }) => {
706
790
  if (logLevel <= _kubb_core.LogLevel.silent) return;
707
791
  const text = getMessage(`Hook ${picocolors.default.dim(command$1)} completed`);
708
792
  console.log(text);
709
793
  if (state.currentConfigs.length === 1) closeGroup(`Hook ${command$1}`);
710
794
  });
711
- context.on("generation:summary", (config, { status, failedPlugins }) => {
795
+ context.on("generation:summary", (config, { status, hrStart, failedPlugins }) => {
712
796
  const pluginsCount = config.plugins?.length || 0;
713
797
  const successCount = pluginsCount - failedPlugins.size;
798
+ const duration = (0, _kubb_core_utils.formatHrtime)(hrStart);
714
799
  if (state.currentConfigs.length > 1) console.log(" ");
715
- console.log(status === "success" ? `Kubb Summary: ${picocolors.default.blue("✓")} ${`${successCount} successful`}, ${pluginsCount} total` : `Kubb Summary: ${picocolors.default.blue("✓")} ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`);
800
+ console.log(status === "success" ? `Kubb Summary: ${picocolors.default.blue("✓")} ${`${successCount} successful`}, ${pluginsCount} total, ${picocolors.default.green(duration)}` : `Kubb Summary: ${picocolors.default.blue("✓")} ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total, ${picocolors.default.green(duration)}`);
716
801
  if (state.currentConfigs.length > 1) closeGroup(config.name ? `Generation for ${picocolors.default.bold(config.name)}` : "Generation");
717
802
  });
718
803
  }
@@ -825,28 +910,6 @@ const plainLogger = (0, _kubb_core.defineLogger)({
825
910
  const text = getMessage(config.name ? `Generation completed for ${config.name}` : "Generation completed");
826
911
  console.log(text);
827
912
  });
828
- context.on("hook:execute", async ({ command: command$1, args }, cb) => {
829
- try {
830
- const result = await (0, execa.execa)(command$1, args, {
831
- detached: true,
832
- stripFinalNewline: true
833
- });
834
- await context.emit("debug", {
835
- date: /* @__PURE__ */ new Date(),
836
- logs: [result.stdout]
837
- });
838
- console.log(result.stdout);
839
- cb();
840
- } catch (err) {
841
- const error = /* @__PURE__ */ new Error("Hook execute failed");
842
- error.cause = err;
843
- await context.emit("debug", {
844
- date: /* @__PURE__ */ new Date(),
845
- logs: [err.stdout]
846
- });
847
- await context.emit("error", error);
848
- }
849
- });
850
913
  context.on("format:start", () => {
851
914
  if (logLevel <= _kubb_core.LogLevel.silent) return;
852
915
  const text = getMessage("Format started");
@@ -867,10 +930,32 @@ const plainLogger = (0, _kubb_core.defineLogger)({
867
930
  const text = getMessage("Lint completed");
868
931
  console.log(text);
869
932
  });
870
- context.on("hook:start", (command$1) => {
871
- if (logLevel <= _kubb_core.LogLevel.silent) return;
933
+ context.on("hook:start", async ({ id, command: command$1, args }) => {
872
934
  const text = getMessage(`Hook ${command$1} started`);
873
- console.log(text);
935
+ if (logLevel > _kubb_core.LogLevel.silent) console.log(text);
936
+ try {
937
+ const result = await (0, execa.execa)(command$1, args, {
938
+ detached: true,
939
+ stripFinalNewline: true
940
+ });
941
+ await context.emit("debug", {
942
+ date: /* @__PURE__ */ new Date(),
943
+ logs: [result.stdout]
944
+ });
945
+ console.log(result.stdout);
946
+ await context.emit("hook:end", {
947
+ command: command$1,
948
+ id
949
+ });
950
+ } catch (err) {
951
+ const error = /* @__PURE__ */ new Error("Hook execute failed");
952
+ error.cause = err;
953
+ await context.emit("debug", {
954
+ date: /* @__PURE__ */ new Date(),
955
+ logs: [err.stdout]
956
+ });
957
+ await context.emit("error", error);
958
+ }
874
959
  });
875
960
  context.on("hook:end", (command$1) => {
876
961
  if (logLevel <= _kubb_core.LogLevel.silent) return;
@@ -921,13 +1006,14 @@ async function executeHooks({ hooks, events }) {
921
1006
  for (const command$1 of commands) {
922
1007
  const [cmd, ...args] = [...(0, string_argv.parseArgsStringToArgv)(command$1)];
923
1008
  if (!cmd) continue;
924
- await events.emit("hook:start", command$1);
925
- await events.emit("hook:execute", {
1009
+ const hookId = (0, node_crypto.createHash)("sha256").update(command$1).digest("hex");
1010
+ await events.emit("hook:start", {
1011
+ id: hookId,
926
1012
  command: cmd,
927
1013
  args
928
- }, async () => {
929
- await events.emit("success", `${picocolors.default.dim(command$1)} successfully executed`);
930
- await events.emit("hook:end", command$1);
1014
+ });
1015
+ await events.on("hook:end", async ({ id }) => {
1016
+ if (id === hookId) await events.emit("success", `${picocolors.default.dim(command$1)} successfully executed`);
931
1017
  });
932
1018
  }
933
1019
  }
@@ -990,15 +1076,18 @@ async function generate({ input, config, events, logLevel }) {
990
1076
  await events.emit("info", [`Formatting with ${picocolors.default.dim(config.output.format)}`, logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0].filter(Boolean).join(" "));
991
1077
  if (config.output.format === "prettier") {
992
1078
  try {
993
- await events.emit("hook:execute", {
1079
+ const hookId = (0, node_crypto.createHash)("sha256").update([config.name, config.output.format].filter(Boolean).join("-")).digest("hex");
1080
+ await events.emit("hook:start", {
1081
+ id: hookId,
994
1082
  command: "prettier",
995
1083
  args: [
996
1084
  "--ignore-unknown",
997
1085
  "--write",
998
1086
  node_path.default.resolve(definedConfig.root, definedConfig.output.path)
999
1087
  ]
1000
- }, async () => {
1001
- await events.emit("success", [
1088
+ });
1089
+ await events.on("hook:end", async ({ id }) => {
1090
+ if (id === hookId) await events.emit("success", [
1002
1091
  `Formatting with ${picocolors.default.dim(config.output.format)}`,
1003
1092
  logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
1004
1093
  "successfully"
@@ -1010,15 +1099,18 @@ async function generate({ input, config, events, logLevel }) {
1010
1099
  await events.emit("success", `Formatted with ${config.output.format}`);
1011
1100
  }
1012
1101
  if (config.output.format === "biome") try {
1013
- await events.emit("hook:execute", {
1102
+ const hookId = (0, node_crypto.createHash)("sha256").update([config.name, config.output.format].filter(Boolean).join("-")).digest("hex");
1103
+ await events.emit("hook:start", {
1104
+ id: hookId,
1014
1105
  command: "biome",
1015
1106
  args: [
1016
1107
  "format",
1017
1108
  "--write",
1018
1109
  node_path.default.resolve(definedConfig.root, definedConfig.output.path)
1019
1110
  ]
1020
- }, async () => {
1021
- await events.emit("success", [
1111
+ });
1112
+ await events.on("hook:end", async ({ id }) => {
1113
+ if (id === hookId) await events.emit("success", [
1022
1114
  `Formatting with ${picocolors.default.dim(config.output.format)}`,
1023
1115
  logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
1024
1116
  "successfully"
@@ -1035,11 +1127,14 @@ async function generate({ input, config, events, logLevel }) {
1035
1127
  await events.emit("lint:start");
1036
1128
  await events.emit("info", [`Linting with ${picocolors.default.dim(config.output.lint)}`, logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0].filter(Boolean).join(" "));
1037
1129
  if (config.output.lint === "eslint") try {
1038
- await events.emit("hook:execute", {
1130
+ const hookId = (0, node_crypto.createHash)("sha256").update([config.name, config.output.lint].filter(Boolean).join("-")).digest("hex");
1131
+ await events.emit("hook:start", {
1132
+ id: hookId,
1039
1133
  command: "eslint",
1040
1134
  args: [node_path.default.resolve(definedConfig.root, definedConfig.output.path), "--fix"]
1041
- }, async () => {
1042
- await events.emit("success", [
1135
+ });
1136
+ await events.on("hook:end", async ({ id }) => {
1137
+ if (id === hookId) await events.emit("success", [
1043
1138
  `Linted with ${picocolors.default.dim(config.output.lint)}`,
1044
1139
  logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
1045
1140
  "successfully"
@@ -1051,15 +1146,18 @@ async function generate({ input, config, events, logLevel }) {
1051
1146
  await events.emit("error", error$1);
1052
1147
  }
1053
1148
  if (config.output.lint === "biome") try {
1054
- await events.emit("hook:execute", {
1149
+ const hookId = (0, node_crypto.createHash)("sha256").update([config.name, config.output.lint].filter(Boolean).join("-")).digest("hex");
1150
+ await events.emit("hook:start", {
1151
+ id: hookId,
1055
1152
  command: "biome",
1056
1153
  args: [
1057
1154
  "lint",
1058
1155
  "--fix",
1059
1156
  node_path.default.resolve(definedConfig.root, definedConfig.output.path)
1060
1157
  ]
1061
- }, async () => {
1062
- await events.emit("success", [
1158
+ });
1159
+ await events.on("hook:end", async ({ id }) => {
1160
+ if (id === hookId) await events.emit("success", [
1063
1161
  `Linted with ${picocolors.default.dim(config.output.lint)}`,
1064
1162
  logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
1065
1163
  "successfully"
@@ -1071,11 +1169,14 @@ async function generate({ input, config, events, logLevel }) {
1071
1169
  await events.emit("error", error$1);
1072
1170
  }
1073
1171
  if (config.output.lint === "oxlint") try {
1074
- await events.emit("hook:execute", {
1172
+ const hookId = (0, node_crypto.createHash)("sha256").update([config.name, config.output.lint].filter(Boolean).join("-")).digest("hex");
1173
+ await events.emit("hook:start", {
1174
+ id: hookId,
1075
1175
  command: "oxlint",
1076
1176
  args: ["--fix", node_path.default.resolve(definedConfig.root, definedConfig.output.path)]
1077
- }, async () => {
1078
- await events.emit("success", [
1177
+ });
1178
+ await events.on("hook:end", async ({ id }) => {
1179
+ if (id === hookId) await events.emit("success", [
1079
1180
  `Linted with ${picocolors.default.dim(config.output.lint)}`,
1080
1181
  logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
1081
1182
  "successfully"
@@ -1258,6 +1359,12 @@ const command = (0, citty.defineCommand)({
1258
1359
  alias: "v",
1259
1360
  default: false
1260
1361
  },
1362
+ silent: {
1363
+ type: "boolean",
1364
+ description: "Override logLevel to silent",
1365
+ alias: "s",
1366
+ default: false
1367
+ },
1261
1368
  help: {
1262
1369
  type: "boolean",
1263
1370
  description: "Show help",
@@ -1273,6 +1380,7 @@ const command = (0, citty.defineCommand)({
1273
1380
  if (args.help) return (0, citty.showUsage)(command);
1274
1381
  if (args.debug) args.logLevel = "debug";
1275
1382
  if (args.verbose) args.logLevel = "verbose";
1383
+ if (args.silent) args.logLevel = "silent";
1276
1384
  const logLevel = _kubb_core.LogLevel[args.logLevel] || 3;
1277
1385
  await setupLogger(events, { logLevel });
1278
1386
  const latestVersion = await (0, latest_version.default)("@kubb/cli");
@@ -1319,4 +1427,4 @@ var generate_default = command;
1319
1427
 
1320
1428
  //#endregion
1321
1429
  exports.default = generate_default;
1322
- //# sourceMappingURL=generate-7e5eF2O-.cjs.map
1430
+ //# sourceMappingURL=generate-BjcMVX3W.cjs.map