@kubb/cli 5.0.0-beta.40 → 5.0.0-beta.42

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 (56) hide show
  1. package/README.md +11 -15
  2. package/dist/{agent-DQerNyd8.cjs → agent-BumEm07_.cjs} +3 -3
  3. package/dist/{agent-DQerNyd8.cjs.map → agent-BumEm07_.cjs.map} +1 -1
  4. package/dist/{agent-ZKJkTTGN.js → agent-gLdUEJW4.js} +3 -3
  5. package/dist/{agent-ZKJkTTGN.js.map → agent-gLdUEJW4.js.map} +1 -1
  6. package/dist/{generate-DQLvFw4z.cjs → generate-Bi4BSF56.cjs} +2 -2
  7. package/dist/{generate-DQLvFw4z.cjs.map → generate-Bi4BSF56.cjs.map} +1 -1
  8. package/dist/{generate-40x9PP4o.js → generate-CUxL5Jcs.js} +2 -2
  9. package/dist/{generate-40x9PP4o.js.map → generate-CUxL5Jcs.js.map} +1 -1
  10. package/dist/index.cjs +6 -6
  11. package/dist/index.js +6 -6
  12. package/dist/{init-CT9RChdK.js → init-3HTDWMFe.js} +3 -3
  13. package/dist/{init-CT9RChdK.js.map → init-3HTDWMFe.js.map} +1 -1
  14. package/dist/{init-sEaUN7Dj.cjs → init-C8CwBts1.cjs} +3 -3
  15. package/dist/{init-sEaUN7Dj.cjs.map → init-C8CwBts1.cjs.map} +1 -1
  16. package/dist/{mcp-Siyb6fTT.cjs → mcp-DbzlupRr.cjs} +2 -2
  17. package/dist/{mcp-Siyb6fTT.cjs.map → mcp-DbzlupRr.cjs.map} +1 -1
  18. package/dist/{mcp-cjPrOeot.js → mcp-fY6xSxpb.js} +2 -2
  19. package/dist/{mcp-cjPrOeot.js.map → mcp-fY6xSxpb.js.map} +1 -1
  20. package/dist/package-CXq9vu7l.js +6 -0
  21. package/dist/package-CXq9vu7l.js.map +1 -0
  22. package/dist/{package-BJ6qam2Y.cjs → package-DE-_IDOs.cjs} +2 -2
  23. package/dist/package-DE-_IDOs.cjs.map +1 -0
  24. package/dist/{run-C_NMctua.cjs → run-B1Bc6OVr.cjs} +2 -2
  25. package/dist/run-B1Bc6OVr.cjs.map +1 -0
  26. package/dist/{run-BQ3Qj0xB.js → run-Bm3WebIl.js} +2 -2
  27. package/dist/{run-BQ3Qj0xB.js.map → run-Bm3WebIl.js.map} +1 -1
  28. package/dist/{run-D-s2LdlW.cjs → run-CZC17tSi.cjs} +2 -2
  29. package/dist/{run-D-s2LdlW.cjs.map → run-CZC17tSi.cjs.map} +1 -1
  30. package/dist/{run-D8dCWepS.js → run-CvEVkbIx.js} +2 -2
  31. package/dist/run-CvEVkbIx.js.map +1 -0
  32. package/dist/{run-CcQawFNK.cjs → run-D4WAzrjB.cjs} +50 -298
  33. package/dist/run-D4WAzrjB.cjs.map +1 -0
  34. package/dist/{run-CHZKHTv0.js → run-DeQ7UlYB.js} +71 -319
  35. package/dist/run-DeQ7UlYB.js.map +1 -0
  36. package/dist/{validate-8pgfxUTy.js → validate-BO5yaxys.js} +2 -2
  37. package/dist/{validate-8pgfxUTy.js.map → validate-BO5yaxys.js.map} +1 -1
  38. package/dist/{validate-CstV7Pc2.cjs → validate-Uw_LUtUk.cjs} +2 -2
  39. package/dist/{validate-CstV7Pc2.cjs.map → validate-Uw_LUtUk.cjs.map} +1 -1
  40. package/package.json +6 -6
  41. package/src/loggers/clackLogger.ts +22 -25
  42. package/src/loggers/plainLogger.ts +3 -6
  43. package/src/loggers/types.ts +1 -2
  44. package/src/loggers/utils.ts +11 -68
  45. package/src/runners/agent/run.ts +3 -1
  46. package/src/runners/generate/run.ts +9 -16
  47. package/src/runners/generate/utils.ts +17 -20
  48. package/src/runners/init/run.ts +1 -1
  49. package/dist/package-BJ6qam2Y.cjs.map +0 -1
  50. package/dist/package-CR5vEK4K.js +0 -6
  51. package/dist/package-CR5vEK4K.js.map +0 -1
  52. package/dist/run-CHZKHTv0.js.map +0 -1
  53. package/dist/run-C_NMctua.cjs.map +0 -1
  54. package/dist/run-CcQawFNK.cjs.map +0 -1
  55. package/dist/run-D8dCWepS.js.map +0 -1
  56. package/src/loggers/githubActionsLogger.ts +0 -377
@@ -1,11 +1,11 @@
1
1
  import "./chunk-CRm0XQPb.js";
2
2
  import { n as toCause, r as toError } from "./errors-CoxrNXaA.js";
3
3
  import { n as tokenize } from "./shell-BrqyJdB7.js";
4
- import { t as version } from "./package-CR5vEK4K.js";
4
+ import { t as version } from "./package-CXq9vu7l.js";
5
5
  import { r as WATCHER_IGNORED_PATHS, t as KUBB_NPM_PACKAGE_URL } from "./constants-84a47qA-.js";
6
6
  import { styleText } from "node:util";
7
7
  import { EventEmitter } from "node:events";
8
- import { createHash } from "node:crypto";
8
+ import { hash } from "node:crypto";
9
9
  import { spawn } from "node:child_process";
10
10
  import { existsSync } from "node:fs";
11
11
  import path, { relative } from "node:path";
@@ -303,19 +303,6 @@ function formatMsWithColor(ms) {
303
303
  //#endregion
304
304
  //#region ../../internals/utils/src/env.ts
305
305
  /**
306
- * Returns `true` when running inside a GitHub Actions workflow.
307
- *
308
- * @example
309
- * ```ts
310
- * if (isGitHubActions()) {
311
- * core.setOutput('result', 'ok')
312
- * }
313
- * ```
314
- */
315
- function isGitHubActions() {
316
- return !!process.env.GITHUB_ACTIONS;
317
- }
318
- /**
319
306
  * Returns `true` when the process is running in a CI environment.
320
307
  * Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,
321
308
  * TeamCity, Buildkite, and Azure Pipelines.
@@ -530,7 +517,7 @@ async function executeIfOnline(fn) {
530
517
  const clackLogger = defineLogger({
531
518
  name: "clack",
532
519
  install(context, options) {
533
- const logLevel$6 = options?.logLevel ?? logLevel.info;
520
+ const logLevel$5 = options?.logLevel ?? logLevel.info;
534
521
  const state = {
535
522
  ...createProgressCounters(),
536
523
  spinner: clack.spinner(),
@@ -559,16 +546,16 @@ const clackLogger = defineLogger({
559
546
  return getMessage(running.length > 0 ? `Generating ${running.join(", ")}` : "Generating plugins");
560
547
  }
561
548
  function showProgressStep() {
562
- if (logLevel$6 <= logLevel.silent) return;
549
+ if (logLevel$5 <= logLevel.silent) return;
563
550
  const line = buildProgressLine(state);
564
551
  if (line) clack.log.step(getMessage(line));
565
552
  }
566
553
  function getMessage(message) {
567
- return formatMessage(message, logLevel$6);
554
+ return formatMessage(message, logLevel$5);
568
555
  }
569
556
  function onStep(event, message) {
570
557
  context.on(event, () => {
571
- if (logLevel$6 <= logLevel.silent) return;
558
+ if (logLevel$5 <= logLevel.silent) return;
572
559
  clack.log.step(getMessage(message));
573
560
  });
574
561
  }
@@ -582,7 +569,7 @@ const clackLogger = defineLogger({
582
569
  state.isSpinning = false;
583
570
  }
584
571
  context.on("kubb:info", ({ message, info = "" }) => {
585
- if (logLevel$6 <= logLevel.silent) return;
572
+ if (logLevel$5 <= logLevel.silent) return;
586
573
  const text = getMessage([
587
574
  styleText("blue", "ℹ"),
588
575
  message,
@@ -595,11 +582,11 @@ const clackLogger = defineLogger({
595
582
  clack.log.info(text);
596
583
  });
597
584
  context.on("kubb:success", ({ message, info = "" }) => {
598
- if (logLevel$6 <= logLevel.silent) return;
585
+ if (logLevel$5 <= logLevel.silent) return;
599
586
  const text = getMessage([
600
587
  styleText("blue", "✓"),
601
588
  message,
602
- logLevel$6 >= logLevel.info ? styleText("dim", info) : void 0
589
+ logLevel$5 >= logLevel.info ? styleText("dim", info) : void 0
603
590
  ].filter(Boolean).join(" "));
604
591
  if (state.isSpinning) {
605
592
  stopSpinner(text);
@@ -608,11 +595,11 @@ const clackLogger = defineLogger({
608
595
  clack.log.success(text);
609
596
  });
610
597
  context.on("kubb:warn", ({ message, info }) => {
611
- if (logLevel$6 < logLevel.warn) return;
598
+ if (logLevel$5 < logLevel.warn) return;
612
599
  const text = getMessage([
613
600
  styleText("yellow", "⚠"),
614
601
  message,
615
- logLevel$6 >= logLevel.info && info ? styleText("dim", info) : void 0
602
+ logLevel$5 >= logLevel.info && info ? styleText("dim", info) : void 0
616
603
  ].filter(Boolean).join(" "));
617
604
  clack.log.warn(text);
618
605
  });
@@ -624,7 +611,7 @@ const clackLogger = defineLogger({
624
611
  return;
625
612
  }
626
613
  clack.log.error(getMessage(text));
627
- if (logLevel$6 >= logLevel.verbose && error.stack) {
614
+ if (logLevel$5 >= logLevel.verbose && error.stack) {
628
615
  const frames = error.stack.split("\n").slice(1, 4);
629
616
  for (const frame of frames) clack.log.message(getMessage(styleText("dim", frame.trim())));
630
617
  if (caused?.stack) {
@@ -635,7 +622,7 @@ const clackLogger = defineLogger({
635
622
  }
636
623
  });
637
624
  context.on("kubb:diagnostic", ({ diagnostic }) => {
638
- if (logLevel$6 <= logLevel.silent && diagnostic.severity !== "error") return;
625
+ if (logLevel$5 <= logLevel.silent && diagnostic.severity !== "error") return;
639
626
  stopSpinner();
640
627
  stopActiveProgress();
641
628
  if (Diagnostics.isUpdate(diagnostic)) {
@@ -663,25 +650,25 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
663
650
  reset();
664
651
  });
665
652
  context.on("kubb:config:start", () => {
666
- if (logLevel$6 <= logLevel.silent) return;
653
+ if (logLevel$5 <= logLevel.silent) return;
667
654
  const text = getMessage("Configuration started");
668
655
  clack.intro(text);
669
656
  startSpinner(getMessage("Configuration loading"));
670
657
  });
671
658
  context.on("kubb:config:end", () => {
672
- if (logLevel$6 <= logLevel.silent) return;
659
+ if (logLevel$5 <= logLevel.silent) return;
673
660
  const text = getMessage("Configuration completed");
674
661
  clack.outro(text);
675
662
  });
676
663
  context.on("kubb:generation:start", ({ config }) => {
677
664
  reset();
678
665
  state.totalPlugins = config.plugins?.length ?? 0;
679
- if (logLevel$6 <= logLevel.silent) return;
666
+ if (logLevel$5 <= logLevel.silent) return;
680
667
  const text = getMessage(["Generation started", config.name ? `for ${styleText("dim", config.name)}` : void 0].filter(Boolean).join(" "));
681
668
  clack.intro(text);
682
669
  });
683
670
  context.on("kubb:plugin:start", ({ plugin }) => {
684
- if (logLevel$6 <= logLevel.silent) return;
671
+ if (logLevel$5 <= logLevel.silent) return;
685
672
  stopSpinner();
686
673
  state.runningPlugins.add(plugin.name);
687
674
  const active = state.activeProgress.get("plugins");
@@ -701,7 +688,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
701
688
  context.on("kubb:plugin:end", ({ plugin, success }) => {
702
689
  stopSpinner();
703
690
  const active = state.activeProgress.get("plugins");
704
- if (!active || logLevel$6 === logLevel.silent) return;
691
+ if (!active || logLevel$5 === logLevel.silent) return;
705
692
  state.runningPlugins.delete(plugin.name);
706
693
  recordPluginResult(state, success);
707
694
  active.progressBar.advance(1, pluginProgressText());
@@ -712,7 +699,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
712
699
  }
713
700
  });
714
701
  context.on("kubb:files:processing:start", ({ files }) => {
715
- if (logLevel$6 <= logLevel.silent) return;
702
+ if (logLevel$5 <= logLevel.silent) return;
716
703
  stopSpinner();
717
704
  state.totalFiles = files.length;
718
705
  state.processedFiles = 0;
@@ -727,7 +714,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
727
714
  state.activeProgress.set("files", { progressBar });
728
715
  });
729
716
  context.on("kubb:files:processing:update", ({ files }) => {
730
- if (logLevel$6 <= logLevel.silent) return;
717
+ if (logLevel$5 <= logLevel.silent) return;
731
718
  stopSpinner();
732
719
  const active = state.activeProgress.get("files");
733
720
  for (const { file, config } of files) {
@@ -736,7 +723,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
736
723
  }
737
724
  });
738
725
  context.on("kubb:files:processing:end", () => {
739
- if (logLevel$6 <= logLevel.silent) return;
726
+ if (logLevel$5 <= logLevel.silent) return;
740
727
  stopSpinner();
741
728
  const text = getMessage("Files written successfully");
742
729
  const active = state.activeProgress.get("files");
@@ -754,7 +741,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
754
741
  onStep("kubb:lint:start", "Linting");
755
742
  onStep("kubb:hooks:start", "Running hooks");
756
743
  context.on("kubb:hook:start", ({ id, command, args }) => {
757
- if (logLevel$6 <= logLevel.silent || !id) return;
744
+ if (logLevel$5 <= logLevel.silent || !id) return;
758
745
  stopSpinner();
759
746
  const title = getMessage(`Running ${styleText("dim", formatCommandWithArgs(command, args))}`);
760
747
  const taskLog = clack.taskLog({ title });
@@ -763,8 +750,18 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
763
750
  hrStart: process$1.hrtime()
764
751
  });
765
752
  });
766
- context.on("kubb:hook:end", ({ id, command, args, success, error }) => {
767
- if (logLevel$6 <= logLevel.silent || !id) return;
753
+ if (logLevel$5 > logLevel.silent) context.on("kubb:hook:line", ({ id, line }) => {
754
+ state.activeHookLogs.get(id)?.taskLog.message(styleText("dim", line));
755
+ });
756
+ context.on("kubb:hook:end", ({ id, command, args, success, error, stdout, stderr }) => {
757
+ if (!id) return;
758
+ if (logLevel$5 <= logLevel.silent) {
759
+ if (!success) {
760
+ if (stdout) console.log(stdout);
761
+ if (stderr) console.error(stderr);
762
+ }
763
+ return;
764
+ }
768
765
  const active = state.activeHookLogs.get(id);
769
766
  if (!active) return;
770
767
  state.activeHookLogs.delete(id);
@@ -779,233 +776,6 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
779
776
  context.on("kubb:lifecycle:end", () => {
780
777
  reset();
781
778
  });
782
- return (_commandWithArgs, hookId) => {
783
- if (logLevel$6 <= logLevel.silent) return {
784
- onStdout: (s) => console.log(s),
785
- onStderr: (s) => console.error(s)
786
- };
787
- const active = state.activeHookLogs.get(hookId);
788
- if (!active) return null;
789
- const { taskLog } = active;
790
- return {
791
- stream: true,
792
- onLine: (line) => taskLog.message(styleText("dim", line)),
793
- onStdout: (s) => taskLog.message(s),
794
- onStderr: (s) => taskLog.message(styleText("red", s))
795
- };
796
- };
797
- }
798
- });
799
- //#endregion
800
- //#region src/loggers/githubActionsLogger.ts
801
- /**
802
- * GitHub Actions logger using group annotations for collapsible sections in CI.
803
- */
804
- const githubActionsLogger = defineLogger({
805
- name: "github-actions",
806
- install(context, options) {
807
- const logLevel$5 = options?.logLevel ?? logLevel.info;
808
- const state = {
809
- ...createProgressCounters(),
810
- currentConfigs: [],
811
- openGroupDepth: 0
812
- };
813
- const hookTimer = createHookTimer();
814
- function reset() {
815
- closeAllGroups();
816
- resetProgressCounters(state);
817
- state.currentConfigs = [];
818
- hookTimer.clear();
819
- }
820
- function showProgressStep() {
821
- if (logLevel$5 <= logLevel.silent) return;
822
- const line = buildProgressLine(state);
823
- if (line) console.log(getMessage(line));
824
- }
825
- function getMessage(message) {
826
- return formatMessage(message, logLevel$5);
827
- }
828
- function openGroup(name) {
829
- console.log(`::group::${name}`);
830
- state.openGroupDepth++;
831
- }
832
- function closeGroup(_name) {
833
- console.log("::endgroup::");
834
- if (state.openGroupDepth > 0) state.openGroupDepth--;
835
- }
836
- function closeAllGroups() {
837
- while (state.openGroupDepth > 0) {
838
- console.log("::endgroup::");
839
- state.openGroupDepth--;
840
- }
841
- }
842
- function onGroupStart(event, message, group) {
843
- context.on(event, () => {
844
- if (logLevel$5 <= logLevel.silent) return;
845
- if (state.currentConfigs.length === 1) openGroup(group);
846
- console.log(getMessage(message));
847
- });
848
- }
849
- function onGroupEnd(event, message, group) {
850
- context.on(event, () => {
851
- if (logLevel$5 <= logLevel.silent) return;
852
- console.log(getMessage(message));
853
- if (state.currentConfigs.length === 1) closeGroup(group);
854
- });
855
- }
856
- context.on("kubb:info", ({ message, info = "" }) => {
857
- if (logLevel$5 <= logLevel.silent) return;
858
- const text = getMessage([
859
- styleText("blue", "ℹ"),
860
- message,
861
- styleText("dim", info)
862
- ].join(" "));
863
- console.log(text);
864
- });
865
- context.on("kubb:success", ({ message, info = "" }) => {
866
- if (logLevel$5 <= logLevel.silent) return;
867
- const text = getMessage([
868
- styleText("blue", "✓"),
869
- message,
870
- logLevel$5 >= logLevel.info ? styleText("dim", info) : void 0
871
- ].filter(Boolean).join(" "));
872
- console.log(text);
873
- });
874
- context.on("kubb:warn", ({ message, info = "" }) => {
875
- if (logLevel$5 <= logLevel.silent) return;
876
- const text = getMessage([
877
- styleText("yellow", "⚠"),
878
- message,
879
- logLevel$5 >= logLevel.info ? styleText("dim", info) : void 0
880
- ].filter(Boolean).join(" "));
881
- console.warn(`::warning::${text}`);
882
- });
883
- context.on("kubb:error", ({ error }) => {
884
- const caused = toCause(error);
885
- closeAllGroups();
886
- const message = error.message || String(error);
887
- console.error(`::error::${message}`);
888
- if (logLevel$5 >= logLevel.verbose && error.stack) {
889
- const frames = error.stack.split("\n").slice(1, 4);
890
- for (const frame of frames) console.log(getMessage(styleText("dim", frame.trim())));
891
- if (caused?.stack) {
892
- console.log(styleText("dim", `└─ caused by ${caused.message}`));
893
- const frames = caused.stack.split("\n").slice(1, 4);
894
- for (const frame of frames) console.log(getMessage(` ${styleText("dim", frame.trim())}`));
895
- }
896
- }
897
- });
898
- context.on("kubb:diagnostic", ({ diagnostic }) => {
899
- closeAllGroups();
900
- if (logLevel$5 <= logLevel.silent && diagnostic.severity !== "error") return;
901
- if (!Diagnostics.isProblem(diagnostic)) {
902
- console.log(`::notice::${diagnostic.message}`);
903
- return;
904
- }
905
- const parts = [`${diagnostic.code} ${diagnostic.message}`];
906
- if (diagnostic.location && "pointer" in diagnostic.location) parts.push(`(at ${diagnostic.location.pointer})`);
907
- if (diagnostic.plugin) parts.push(`[plugin: ${diagnostic.plugin}]`);
908
- if (diagnostic.help) parts.push(`help: ${diagnostic.help}`);
909
- if (diagnostic.code !== Diagnostics.code.unknown) parts.push(`docs: ${Diagnostics.docsUrl(diagnostic.code)}`);
910
- console.error(`::error::${parts.join(" ")}`);
911
- });
912
- context.on("kubb:lifecycle:start", ({ version }) => {
913
- console.log(styleText("yellow", `Kubb ${version} 🧩`));
914
- reset();
915
- });
916
- context.on("kubb:config:start", () => {
917
- if (logLevel$5 <= logLevel.silent) return;
918
- const text = getMessage("Configuration started");
919
- openGroup("Configuration");
920
- console.log(text);
921
- });
922
- context.on("kubb:config:end", ({ configs }) => {
923
- state.currentConfigs = configs;
924
- if (logLevel$5 <= logLevel.silent) return;
925
- const text = getMessage("Configuration completed");
926
- console.log(text);
927
- closeGroup("Configuration");
928
- });
929
- context.on("kubb:generation:start", ({ config }) => {
930
- reset();
931
- state.totalPlugins = config.plugins?.length ?? 0;
932
- const text = config.name ? `Generation for ${styleText("bold", config.name)}` : "Generation";
933
- if (state.currentConfigs.length > 1) openGroup(text);
934
- if (state.currentConfigs.length === 1) console.log(getMessage(text));
935
- });
936
- context.on("kubb:plugin:start", ({ plugin }) => {
937
- if (logLevel$5 <= logLevel.silent) return;
938
- const text = getMessage(`Generating ${styleText("bold", plugin.name)}`);
939
- if (state.currentConfigs.length === 1) openGroup(`Plugin: ${plugin.name}`);
940
- console.log(text);
941
- });
942
- context.on("kubb:plugin:end", ({ plugin, duration, success }) => {
943
- if (logLevel$5 <= logLevel.silent) return;
944
- recordPluginResult(state, success);
945
- const durationStr = formatMsWithColor(duration);
946
- const text = getMessage(success ? `${styleText("bold", plugin.name)} completed in ${durationStr}` : `${styleText("bold", plugin.name)} failed in ${styleText("red", formatMs(duration))}`);
947
- console.log(text);
948
- if (state.currentConfigs.length > 1) console.log(" ");
949
- if (state.currentConfigs.length === 1) closeGroup(`Plugin: ${plugin.name}`);
950
- showProgressStep();
951
- });
952
- context.on("kubb:files:processing:start", ({ files }) => {
953
- if (logLevel$5 <= logLevel.silent) return;
954
- state.totalFiles = files.length;
955
- state.processedFiles = 0;
956
- if (state.currentConfigs.length === 1) openGroup("File Generation");
957
- const text = getMessage(`Writing ${files.length} files`);
958
- console.log(text);
959
- });
960
- context.on("kubb:files:processing:end", () => {
961
- if (logLevel$5 <= logLevel.silent) return;
962
- const text = getMessage("Files written successfully");
963
- console.log(text);
964
- if (state.currentConfigs.length === 1) closeGroup("File Generation");
965
- showProgressStep();
966
- });
967
- context.on("kubb:files:processing:update", ({ files }) => {
968
- if (logLevel$5 <= logLevel.silent) return;
969
- state.processedFiles += files.length;
970
- });
971
- context.on("kubb:generation:end", ({ config }) => {
972
- const text = getMessage(config.name ? `${styleText("blue", "✓")} Generation completed for ${styleText("dim", config.name)}` : `${styleText("blue", "✓")} Generation completed`);
973
- console.log(text);
974
- if (state.currentConfigs.length > 1) closeGroup(config.name ? `Generation for ${styleText("bold", config.name)}` : "Generation");
975
- });
976
- onGroupStart("kubb:format:start", "Format started", "Formatting");
977
- onGroupEnd("kubb:format:end", "Format completed", "Formatting");
978
- onGroupStart("kubb:lint:start", "Lint started", "Linting");
979
- onGroupEnd("kubb:lint:end", "Lint completed", "Linting");
980
- onGroupStart("kubb:hooks:start", "Hooks started", "Hooks");
981
- onGroupEnd("kubb:hooks:end", "Hooks completed", "Hooks");
982
- context.on("kubb:hook:start", ({ id, command, args }) => {
983
- if (logLevel$5 <= logLevel.silent) return;
984
- if (id) hookTimer.start(id);
985
- const commandWithArgs = formatCommandWithArgs(command, args);
986
- const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} started`);
987
- if (state.currentConfigs.length === 1) openGroup(`Hook ${commandWithArgs}`);
988
- console.log(text);
989
- });
990
- context.on("kubb:hook:end", ({ id, command, args, success, error }) => {
991
- if (logLevel$5 <= logLevel.silent) return;
992
- const ms = id ? hookTimer.end(id) : void 0;
993
- const durationStr = ms !== void 0 ? ` in ${formatMsWithColor(ms)}` : "";
994
- const commandWithArgs = formatCommandWithArgs(command, args);
995
- if (success) console.log(getMessage(`${styleText("green", "✓")} Hook ${styleText("dim", commandWithArgs)} completed${durationStr}`));
996
- else {
997
- const reason = error?.message ? ` (${error.message})` : "";
998
- console.log(`::error::Hook ${commandWithArgs} failed${durationStr}${reason}`);
999
- }
1000
- if (state.currentConfigs.length === 1) closeGroup(`Hook ${commandWithArgs}`);
1001
- });
1002
- context.on("kubb:lifecycle:end", () => {
1003
- reset();
1004
- });
1005
- return (_commandWithArgs, _hookId) => ({
1006
- onStdout: logLevel$5 > logLevel.silent ? (s) => console.log(s) : void 0,
1007
- onStderr: logLevel$5 > logLevel.silent ? (s) => console.error(`::error::${s}`) : void 0
1008
- });
1009
779
  }
1010
780
  });
1011
781
  //#endregion
@@ -1122,21 +892,19 @@ const plainLogger = defineLogger({
1122
892
  const commandWithArgs = formatCommandWithArgs(command, args);
1123
893
  console.log(getMessage(`Hook ${commandWithArgs} started`));
1124
894
  });
1125
- context.on("kubb:hook:end", ({ id, command, args, success, error }) => {
895
+ context.on("kubb:hook:end", ({ id, command, args, success, error, stdout, stderr }) => {
1126
896
  if (logLevel$4 <= logLevel.silent) return;
1127
897
  const ms = id ? hookTimer.end(id) : void 0;
1128
898
  const durationStr = ms !== void 0 ? ` in ${formatMs(ms)}` : "";
1129
899
  const commandWithArgs = formatCommandWithArgs(command, args);
1130
900
  if (success) console.log(getMessage(`✓ Hook ${commandWithArgs} completed${durationStr}`));
1131
901
  else {
902
+ if (stdout) console.log(stdout);
903
+ if (stderr) console.error(stderr);
1132
904
  const reason = error?.message ? ` (${error.message})` : "";
1133
905
  console.log(getMessage(`✗ Hook ${commandWithArgs} failed${durationStr}${reason}`));
1134
906
  }
1135
907
  });
1136
- return (_commandWithArgs, _hookId) => ({
1137
- onStdout: logLevel$4 > logLevel.silent ? (s) => console.log(s) : void 0,
1138
- onStderr: logLevel$4 > logLevel.silent ? (s) => console.error(s) : void 0
1139
- });
1140
908
  }
1141
909
  });
1142
910
  //#endregion
@@ -1155,7 +923,7 @@ function formatMessage(message, logLevel$3) {
1155
923
  return message;
1156
924
  }
1157
925
  /**
1158
- * Build the progress summary line shared by clack and GitHub Actions loggers.
926
+ * Build the progress summary line shown by the clack logger.
1159
927
  * Returns null when there is nothing to display.
1160
928
  */
1161
929
  function buildProgressLine(state) {
@@ -1171,7 +939,7 @@ function buildProgressLine(state) {
1171
939
  return parts.join(styleText("dim", " | "));
1172
940
  }
1173
941
  /**
1174
- * Creates the per-run progress counters shared by the clack and GitHub Actions loggers.
942
+ * Creates the per-run progress counters used by the clack logger.
1175
943
  */
1176
944
  function createProgressCounters() {
1177
945
  return {
@@ -1229,14 +997,12 @@ function formatCommandWithArgs(command, args) {
1229
997
  return args?.length ? `${command} ${args.join(" ")}` : command;
1230
998
  }
1231
999
  function detectLogger() {
1232
- if (isGitHubActions()) return "github-actions";
1233
1000
  if (canUseTTY()) return "clack";
1234
1001
  return "plain";
1235
1002
  }
1236
1003
  const logMapper = {
1237
1004
  clack: clackLogger,
1238
- plain: plainLogger,
1239
- "github-actions": githubActionsLogger
1005
+ plain: plainLogger
1240
1006
  };
1241
1007
  /**
1242
1008
  * Bridges a {@link Reporter} onto the run's event emitter: calls `report` with each config's
@@ -1255,9 +1021,10 @@ function installReporter(context, reporter, ctx) {
1255
1021
  if (reporter.drain) context.on("kubb:lifecycle:end", () => reporter.drain?.(ctx));
1256
1022
  }
1257
1023
  /**
1258
- * Installs the live logger (the TUI view) and the given reporters (the output), returning the
1259
- * terminal logger's hook sink when one was installed. The reporters are already selected by the
1260
- * caller (the CLI maps `--reporter` to names via `selectReporters`); this only wires them.
1024
+ * Installs the live logger (the TUI view) and the given reporters (the output). The reporters are
1025
+ * already selected by the caller (the CLI maps `--reporter` to names via `selectReporters`); this
1026
+ * only wires them. Loggers receive hook subprocess output through `kubb:hook:line` and the
1027
+ * `stdout`/`stderr` on `kubb:hook:end`, so nothing is returned here.
1261
1028
  *
1262
1029
  * Loggers and reporters are independent: the `cli` reporter also activates the env logger summary.
1263
1030
  * The `json` reporter owns stdout, so the live logger and the `cli` summary are suppressed whenever
@@ -1266,19 +1033,16 @@ function installReporter(context, reporter, ctx) {
1266
1033
  async function setupReporters(context, { logLevel, reporters }) {
1267
1034
  const hasJson = reporters.some((reporter) => reporter.name === "json");
1268
1035
  const ctx = { logLevel };
1269
- let makeSink = null;
1270
1036
  for (const reporter of reporters) {
1271
1037
  if (reporter.name === "cli") {
1272
1038
  if (hasJson) continue;
1273
1039
  const type = detectLogger();
1274
1040
  const logger = logMapper[type];
1275
1041
  if (!logger) throw new Error(`Unknown adapter type: ${type}`);
1276
- const sink = await logger.install(context, { logLevel });
1277
- makeSink = typeof sink === "function" ? sink : null;
1042
+ await logger.install(context, { logLevel });
1278
1043
  }
1279
1044
  installReporter(context, reporter, ctx);
1280
1045
  }
1281
- return makeSink;
1282
1046
  }
1283
1047
  //#endregion
1284
1048
  //#region src/runners/generate/utils.ts
@@ -1359,48 +1123,46 @@ async function getConfigs({ configPath, input, watch, logLevel }) {
1359
1123
  /**
1360
1124
  * Runs the `done` hooks defined in a Kubb config in sequence.
1361
1125
  */
1362
- async function executeHooks({ configHooks, hooks, makeSink }) {
1126
+ async function executeHooks({ configHooks, hooks }) {
1363
1127
  const commands = Array.isArray(configHooks.done) ? configHooks.done : [configHooks.done].filter(Boolean);
1364
1128
  for (const command of commands) {
1365
1129
  const [cmd, ...args] = tokenize(command);
1366
1130
  if (!cmd) continue;
1367
- const hookId = createHash("sha256").update(command).digest("hex");
1131
+ const hookId = hash("sha256", command, "hex");
1368
1132
  const commandWithArgs = [cmd, ...args].join(" ");
1369
1133
  await hooks.emit("kubb:hook:start", {
1370
1134
  id: hookId,
1371
1135
  command: cmd,
1372
1136
  args
1373
1137
  });
1374
- const { stream = false, onLine, onStdout, onStderr } = makeSink?.(commandWithArgs, hookId) ?? {};
1375
1138
  await runHook({
1376
1139
  id: hookId,
1377
1140
  command: cmd,
1378
1141
  args,
1379
1142
  commandWithArgs,
1380
- hooks,
1381
- stream,
1382
- sink: {
1383
- onLine,
1384
- onStdout,
1385
- onStderr
1386
- }
1143
+ hooks
1387
1144
  });
1388
1145
  }
1389
1146
  }
1390
- async function runHook({ id, command, args, commandWithArgs, hooks, stream = false, sink }) {
1391
- const emitEnd = (success, error) => hooks.emit("kubb:hook:end", {
1147
+ async function runHook({ id, command, args, commandWithArgs, hooks }) {
1148
+ const emitEnd = (success, error, output) => hooks.emit("kubb:hook:end", {
1392
1149
  command,
1393
1150
  args,
1394
1151
  id,
1395
1152
  success,
1396
- error
1153
+ error,
1154
+ ...output
1397
1155
  });
1156
+ const stream = hooks.listenerCount("kubb:hook:line") > 0;
1398
1157
  try {
1399
1158
  const proc = x(command, [...args ?? []], {
1400
1159
  nodeOptions: { detached: process.platform !== "win32" },
1401
1160
  throwOnError: true
1402
1161
  });
1403
- if (stream && sink?.onLine) for await (const line of proc) sink.onLine(line);
1162
+ if (stream) for await (const line of proc) await hooks.emit("kubb:hook:line", {
1163
+ id,
1164
+ line
1165
+ });
1404
1166
  await proc;
1405
1167
  await hooks.emit("kubb:success", { message: `${styleText("dim", commandWithArgs)} successfully executed` });
1406
1168
  await emitEnd(true, null);
@@ -1411,9 +1173,10 @@ async function runHook({ id, command, args, commandWithArgs, hooks, stream = fal
1411
1173
  }
1412
1174
  const stderr = err.output?.stderr ?? "";
1413
1175
  const stdout = err.output?.stdout ?? "";
1414
- if (stderr) sink?.onStderr?.(stderr);
1415
- if (stdout) sink?.onStdout?.(stdout);
1416
- await emitEnd(false, /* @__PURE__ */ new Error(`Hook execute failed: ${commandWithArgs}`));
1176
+ await emitEnd(false, /* @__PURE__ */ new Error(`Hook execute failed: ${commandWithArgs}`), {
1177
+ stdout,
1178
+ stderr
1179
+ });
1417
1180
  }
1418
1181
  }
1419
1182
  /**
@@ -1464,7 +1227,7 @@ function waitForHookEnd(hooks, hookId, onSuccess, fallbackErrorMessage) {
1464
1227
  hooks.on("kubb:hook:end", handler);
1465
1228
  });
1466
1229
  }
1467
- async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefix, noToolMessage, configName, outputPath, logLevel: logLevel$1, hooks, makeSink, onStart, onEnd }) {
1230
+ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefix, noToolMessage, configName, outputPath, logLevel: logLevel$1, hooks, onStart, onEnd }) {
1468
1231
  await onStart();
1469
1232
  let resolvedTool = toolValue;
1470
1233
  if (resolvedTool === "auto") {
@@ -1478,7 +1241,7 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1478
1241
  let toolError;
1479
1242
  if (resolvedTool && resolvedTool !== "auto" && resolvedTool in toolMap && existsSync(outputPath)) {
1480
1243
  const toolConfig = toolMap[resolvedTool];
1481
- const hookId = createHash("sha256").update([configName, resolvedTool].filter(Boolean).join("-")).digest("hex");
1244
+ const hookId = hash("sha256", [configName, resolvedTool].filter(Boolean).join("-"), "hex");
1482
1245
  const successMessage = [
1483
1246
  `${successPrefix} with ${styleText("dim", resolvedTool)}`,
1484
1247
  logLevel$1 >= logLevel.info ? `on ${styleText("dim", outputPath)}` : void 0,
@@ -1493,19 +1256,12 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1493
1256
  command: toolConfig.command,
1494
1257
  args: hookArgs
1495
1258
  });
1496
- const { stream = false, onLine, onStdout, onStderr } = makeSink?.(commandWithArgs, hookId) ?? {};
1497
1259
  runHook({
1498
1260
  id: hookId,
1499
1261
  command: toolConfig.command,
1500
1262
  args: hookArgs,
1501
1263
  commandWithArgs,
1502
- hooks,
1503
- stream,
1504
- sink: {
1505
- onLine,
1506
- onStdout,
1507
- onStderr
1508
- }
1264
+ hooks
1509
1265
  }).catch(() => {});
1510
1266
  await hookEndPromise;
1511
1267
  } catch (caughtError) {
@@ -1516,7 +1272,7 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1516
1272
  if (toolError) throw toolError;
1517
1273
  }
1518
1274
  async function generate(options) {
1519
- const { input, hooks, logLevel, makeSink } = options;
1275
+ const { input, hooks, logLevel } = options;
1520
1276
  const hrStart = process$1.hrtime();
1521
1277
  const inputPath = input ?? (options.config.input && "path" in options.config.input ? options.config.input.path : void 0);
1522
1278
  const config = {
@@ -1599,8 +1355,7 @@ async function generate(options) {
1599
1355
  configName: config.name,
1600
1356
  outputPath,
1601
1357
  logLevel,
1602
- hooks,
1603
- makeSink
1358
+ hooks
1604
1359
  });
1605
1360
  } catch (caughtError) {
1606
1361
  const diagnostic = outputDiagnostic(code, pass.toolLabel, caughtError);
@@ -1617,8 +1372,7 @@ async function generate(options) {
1617
1372
  try {
1618
1373
  await executeHooks({
1619
1374
  configHooks: config.hooks,
1620
- hooks,
1621
- makeSink
1375
+ hooks
1622
1376
  });
1623
1377
  } finally {
1624
1378
  hooks.off("kubb:hook:end", onHookEnd);
@@ -1700,7 +1454,7 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
1700
1454
  process$1.exit(1);
1701
1455
  }
1702
1456
  const requestedNames = cliReporters?.length ? cliReporters : ["cli"];
1703
- const makeSink = await setupReporters(hooks, {
1457
+ await setupReporters(hooks, {
1704
1458
  logLevel: logLevel$2,
1705
1459
  reporters: selectReporters(configs[0]?.reporters ?? [], requestedNames)
1706
1460
  });
@@ -1724,8 +1478,7 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
1724
1478
  input,
1725
1479
  config,
1726
1480
  logLevel: logLevel$2,
1727
- hooks,
1728
- makeSink
1481
+ hooks
1729
1482
  });
1730
1483
  clack.log.step(styleText("yellow", `Watching for changes in ${paths.join(" and ")}`));
1731
1484
  }, {
@@ -1737,8 +1490,7 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
1737
1490
  input,
1738
1491
  config,
1739
1492
  logLevel: logLevel$2,
1740
- hooks,
1741
- makeSink
1493
+ hooks
1742
1494
  })) anyFailed = true;
1743
1495
  } catch (configError) {
1744
1496
  await hooks.emit("kubb:error", { error: toError(configError) });
@@ -1754,4 +1506,4 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
1754
1506
  //#endregion
1755
1507
  export { run };
1756
1508
 
1757
- //# sourceMappingURL=run-CHZKHTv0.js.map
1509
+ //# sourceMappingURL=run-DeQ7UlYB.js.map