@kubb/cli 5.0.0-beta.29 → 5.0.0-beta.30

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 (40) hide show
  1. package/dist/{agent-C5Fwtkwy.js → agent-CPKt8QQU.js} +2 -2
  2. package/dist/{agent-C5Fwtkwy.js.map → agent-CPKt8QQU.js.map} +1 -1
  3. package/dist/{agent-BBnJ3z1X.cjs → agent-lxTI4Krn.cjs} +2 -2
  4. package/dist/{agent-BBnJ3z1X.cjs.map → agent-lxTI4Krn.cjs.map} +1 -1
  5. package/dist/{generate-DoOmhbH4.cjs → generate-DgTJz23F.cjs} +2 -2
  6. package/dist/{generate-DoOmhbH4.cjs.map → generate-DgTJz23F.cjs.map} +1 -1
  7. package/dist/{generate-Ga3rWDun.js → generate-qCPyPiD6.js} +2 -2
  8. package/dist/{generate-Ga3rWDun.js.map → generate-qCPyPiD6.js.map} +1 -1
  9. package/dist/index.cjs +6 -6
  10. package/dist/index.js +6 -6
  11. package/dist/{init-zA8dUkIL.cjs → init-CM61rK5A.cjs} +2 -2
  12. package/dist/{init-zA8dUkIL.cjs.map → init-CM61rK5A.cjs.map} +1 -1
  13. package/dist/{init-DBl4w2eq.js → init-_-CN-ASE.js} +2 -2
  14. package/dist/{init-DBl4w2eq.js.map → init-_-CN-ASE.js.map} +1 -1
  15. package/dist/{mcp-Dy2q0IpZ.js → mcp-1ld_vD4n.js} +2 -2
  16. package/dist/{mcp-Dy2q0IpZ.js.map → mcp-1ld_vD4n.js.map} +1 -1
  17. package/dist/{mcp-vcwhUjDa.cjs → mcp-IMkVgOtF.cjs} +2 -2
  18. package/dist/{mcp-vcwhUjDa.cjs.map → mcp-IMkVgOtF.cjs.map} +1 -1
  19. package/dist/package-BDL80yHv.js +6 -0
  20. package/dist/package-BDL80yHv.js.map +1 -0
  21. package/dist/{package-DlcR7TDy.cjs → package-CHmy7tzG.cjs} +2 -2
  22. package/dist/package-CHmy7tzG.cjs.map +1 -0
  23. package/dist/{run-Cmub7x_z.js → run-BonExv0-.js} +111 -125
  24. package/dist/run-BonExv0-.js.map +1 -0
  25. package/dist/{run-BGQSMjOH.cjs → run-e1Pda1tW.cjs} +111 -125
  26. package/dist/run-e1Pda1tW.cjs.map +1 -0
  27. package/dist/{validate-DVs01Mu6.js → validate-26X6uBG3.js} +2 -2
  28. package/dist/{validate-DVs01Mu6.js.map → validate-26X6uBG3.js.map} +1 -1
  29. package/dist/{validate-B8z4X5Cc.cjs → validate-BAEo4Dcd.cjs} +2 -2
  30. package/dist/{validate-B8z4X5Cc.cjs.map → validate-BAEo4Dcd.cjs.map} +1 -1
  31. package/package.json +6 -6
  32. package/src/loggers/clackLogger.ts +18 -42
  33. package/src/loggers/githubActionsLogger.ts +51 -106
  34. package/src/loggers/plainLogger.ts +25 -83
  35. package/src/loggers/utils.ts +76 -1
  36. package/dist/package-DlcR7TDy.cjs.map +0 -1
  37. package/dist/package-DmWpQ3SY.js +0 -6
  38. package/dist/package-DmWpQ3SY.js.map +0 -1
  39. package/dist/run-BGQSMjOH.cjs.map +0 -1
  40. package/dist/run-Cmub7x_z.js.map +0 -1
@@ -2,7 +2,7 @@ const require_chunk = require("./chunk-ByKO4r7w.cjs");
2
2
  const require_errors = require("./errors-CLCjoSg0.cjs");
3
3
  const require_telemetry = require("./telemetry-B2iWkY5e.cjs");
4
4
  const require_shell = require("./shell-475fQKaX.cjs");
5
- const require_package = require("./package-DlcR7TDy.cjs");
5
+ const require_package = require("./package-CHmy7tzG.cjs");
6
6
  const require_constants = require("./constants-BINTA5VZ.cjs");
7
7
  let node_util = require("node:util");
8
8
  let node_events = require("node:events");
@@ -500,12 +500,7 @@ const clackLogger = (0, _kubb_core.defineLogger)({
500
500
  install(context, options) {
501
501
  const logLevel = options?.logLevel ?? _kubb_core.logLevel.info;
502
502
  const state = {
503
- totalPlugins: 0,
504
- completedPlugins: 0,
505
- failedPlugins: 0,
506
- totalFiles: 0,
507
- processedFiles: 0,
508
- hrStart: node_process.default.hrtime(),
503
+ ...createProgressCounters(),
509
504
  spinner: _clack_prompts.spinner(),
510
505
  isSpinning: false,
511
506
  activeProgress: /* @__PURE__ */ new Map(),
@@ -516,12 +511,7 @@ const clackLogger = (0, _kubb_core.defineLogger)({
516
511
  if (active.interval) clearInterval(active.interval);
517
512
  active.progressBar?.stop();
518
513
  }
519
- state.totalPlugins = 0;
520
- state.completedPlugins = 0;
521
- state.failedPlugins = 0;
522
- state.totalFiles = 0;
523
- state.processedFiles = 0;
524
- state.hrStart = node_process.default.hrtime();
514
+ resetProgressCounters(state);
525
515
  state.spinner = _clack_prompts.spinner();
526
516
  state.isSpinning = false;
527
517
  state.activeProgress.clear();
@@ -535,6 +525,12 @@ const clackLogger = (0, _kubb_core.defineLogger)({
535
525
  function getMessage(message) {
536
526
  return formatMessage(message, logLevel);
537
527
  }
528
+ function onStep(event, message) {
529
+ context.on(event, () => {
530
+ if (logLevel <= _kubb_core.logLevel.silent) return;
531
+ _clack_prompts.log.step(getMessage(message));
532
+ });
533
+ }
538
534
  function startSpinner(text) {
539
535
  state.spinner.start(text);
540
536
  state.isSpinning = true;
@@ -664,8 +660,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
664
660
  const active = state.activeProgress.get(plugin.name);
665
661
  if (!active || logLevel === _kubb_core.logLevel.silent) return;
666
662
  clearInterval(active.interval);
667
- if (success) state.completedPlugins++;
668
- else state.failedPlugins++;
663
+ recordPluginResult(state, success);
669
664
  const durationStr = formatMsWithColor(duration);
670
665
  const text = getMessage(success ? `${(0, node_util.styleText)("bold", plugin.name)} completed in ${durationStr}` : `${(0, node_util.styleText)("bold", plugin.name)} failed in ${(0, node_util.styleText)("red", formatMs(duration))}`);
671
666
  active.progressBar.stop(text);
@@ -711,18 +706,9 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
711
706
  const text = getMessage(config.name ? `Generation completed for ${(0, node_util.styleText)("dim", config.name)}` : "Generation completed");
712
707
  _clack_prompts.outro(text);
713
708
  });
714
- context.on("kubb:format:start", () => {
715
- if (logLevel <= _kubb_core.logLevel.silent) return;
716
- _clack_prompts.log.step(getMessage("Formatting"));
717
- });
718
- context.on("kubb:lint:start", () => {
719
- if (logLevel <= _kubb_core.logLevel.silent) return;
720
- _clack_prompts.log.step(getMessage("Linting"));
721
- });
722
- context.on("kubb:hooks:start", () => {
723
- if (logLevel <= _kubb_core.logLevel.silent) return;
724
- _clack_prompts.log.step(getMessage("Running hooks"));
725
- });
709
+ onStep("kubb:format:start", "Formatting");
710
+ onStep("kubb:lint:start", "Linting");
711
+ onStep("kubb:hooks:start", "Running hooks");
726
712
  context.on("kubb:hook:start", ({ id, command, args }) => {
727
713
  if (logLevel <= _kubb_core.logLevel.silent || !id) return;
728
714
  stopSpinner();
@@ -910,26 +896,16 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
910
896
  install(context, options) {
911
897
  const logLevel = options?.logLevel ?? _kubb_core.logLevel.info;
912
898
  const state = {
913
- totalPlugins: 0,
914
- completedPlugins: 0,
915
- failedPlugins: 0,
916
- totalFiles: 0,
917
- processedFiles: 0,
918
- hrStart: node_process.default.hrtime(),
899
+ ...createProgressCounters(),
919
900
  currentConfigs: [],
920
- hookStarts: /* @__PURE__ */ new Map(),
921
901
  openGroupDepth: 0
922
902
  };
903
+ const hookTimer = createHookTimer();
923
904
  function reset() {
924
905
  closeAllGroups();
925
- state.totalPlugins = 0;
926
- state.completedPlugins = 0;
927
- state.failedPlugins = 0;
928
- state.totalFiles = 0;
929
- state.processedFiles = 0;
930
- state.hrStart = node_process.default.hrtime();
906
+ resetProgressCounters(state);
931
907
  state.currentConfigs = [];
932
- state.hookStarts.clear();
908
+ hookTimer.clear();
933
909
  }
934
910
  function showProgressStep() {
935
911
  if (logLevel <= _kubb_core.logLevel.silent) return;
@@ -953,6 +929,20 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
953
929
  state.openGroupDepth--;
954
930
  }
955
931
  }
932
+ function onGroupStart(event, message, group) {
933
+ context.on(event, () => {
934
+ if (logLevel <= _kubb_core.logLevel.silent) return;
935
+ if (state.currentConfigs.length === 1) openGroup(group);
936
+ console.log(getMessage(message));
937
+ });
938
+ }
939
+ function onGroupEnd(event, message, group) {
940
+ context.on(event, () => {
941
+ if (logLevel <= _kubb_core.logLevel.silent) return;
942
+ console.log(getMessage(message));
943
+ if (state.currentConfigs.length === 1) closeGroup(group);
944
+ });
945
+ }
956
946
  context.on("kubb:info", ({ message, info = "" }) => {
957
947
  if (logLevel <= _kubb_core.logLevel.silent) return;
958
948
  const text = getMessage([
@@ -1031,8 +1021,7 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
1031
1021
  });
1032
1022
  context.on("kubb:plugin:end", ({ plugin, duration, success }) => {
1033
1023
  if (logLevel <= _kubb_core.logLevel.silent) return;
1034
- if (success) state.completedPlugins++;
1035
- else state.failedPlugins++;
1024
+ recordPluginResult(state, success);
1036
1025
  const durationStr = formatMsWithColor(duration);
1037
1026
  const text = getMessage(success ? `${(0, node_util.styleText)("bold", plugin.name)} completed in ${durationStr}` : `${(0, node_util.styleText)("bold", plugin.name)} failed in ${(0, node_util.styleText)("red", formatMs(duration))}`);
1038
1027
  console.log(text);
@@ -1063,43 +1052,15 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
1063
1052
  const text = getMessage(config.name ? `${(0, node_util.styleText)("blue", "✓")} Generation completed for ${(0, node_util.styleText)("dim", config.name)}` : `${(0, node_util.styleText)("blue", "✓")} Generation completed`);
1064
1053
  console.log(text);
1065
1054
  });
1066
- context.on("kubb:format:start", () => {
1067
- if (logLevel <= _kubb_core.logLevel.silent) return;
1068
- const text = getMessage("Format started");
1069
- if (state.currentConfigs.length === 1) openGroup("Formatting");
1070
- console.log(text);
1071
- });
1072
- context.on("kubb:format:end", () => {
1073
- if (logLevel <= _kubb_core.logLevel.silent) return;
1074
- const text = getMessage("Format completed");
1075
- console.log(text);
1076
- if (state.currentConfigs.length === 1) closeGroup("Formatting");
1077
- });
1078
- context.on("kubb:lint:start", () => {
1079
- if (logLevel <= _kubb_core.logLevel.silent) return;
1080
- const text = getMessage("Lint started");
1081
- if (state.currentConfigs.length === 1) openGroup("Linting");
1082
- console.log(text);
1083
- });
1084
- context.on("kubb:lint:end", () => {
1085
- if (logLevel <= _kubb_core.logLevel.silent) return;
1086
- const text = getMessage("Lint completed");
1087
- console.log(text);
1088
- if (state.currentConfigs.length === 1) closeGroup("Linting");
1089
- });
1090
- context.on("kubb:hooks:start", () => {
1091
- if (logLevel <= _kubb_core.logLevel.silent) return;
1092
- if (state.currentConfigs.length === 1) openGroup("Hooks");
1093
- console.log(getMessage("Hooks started"));
1094
- });
1095
- context.on("kubb:hooks:end", () => {
1096
- if (logLevel <= _kubb_core.logLevel.silent) return;
1097
- console.log(getMessage("Hooks completed"));
1098
- if (state.currentConfigs.length === 1) closeGroup("Hooks");
1099
- });
1055
+ onGroupStart("kubb:format:start", "Format started", "Formatting");
1056
+ onGroupEnd("kubb:format:end", "Format completed", "Formatting");
1057
+ onGroupStart("kubb:lint:start", "Lint started", "Linting");
1058
+ onGroupEnd("kubb:lint:end", "Lint completed", "Linting");
1059
+ onGroupStart("kubb:hooks:start", "Hooks started", "Hooks");
1060
+ onGroupEnd("kubb:hooks:end", "Hooks completed", "Hooks");
1100
1061
  context.on("kubb:hook:start", ({ id, command, args }) => {
1101
1062
  if (logLevel <= _kubb_core.logLevel.silent) return;
1102
- if (id) state.hookStarts.set(id, node_process.default.hrtime());
1063
+ if (id) hookTimer.start(id);
1103
1064
  const commandWithArgs = formatCommandWithArgs(command, args);
1104
1065
  const text = getMessage(`Hook ${(0, node_util.styleText)("dim", commandWithArgs)} started`);
1105
1066
  if (state.currentConfigs.length === 1) openGroup(`Hook ${commandWithArgs}`);
@@ -1107,9 +1068,8 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
1107
1068
  });
1108
1069
  context.on("kubb:hook:end", ({ id, command, args, success, error }) => {
1109
1070
  if (logLevel <= _kubb_core.logLevel.silent) return;
1110
- const hrStart = id ? state.hookStarts.get(id) : void 0;
1111
- if (id) state.hookStarts.delete(id);
1112
- const durationStr = hrStart ? ` in ${formatMsWithColor(getElapsedMs(hrStart))}` : "";
1071
+ const ms = id ? hookTimer.end(id) : void 0;
1072
+ const durationStr = ms !== void 0 ? ` in ${formatMsWithColor(ms)}` : "";
1113
1073
  const commandWithArgs = formatCommandWithArgs(command, args);
1114
1074
  if (success) console.log(getMessage(`${(0, node_util.styleText)("green", "✓")} Hook ${(0, node_util.styleText)("dim", commandWithArgs)} completed${durationStr}`));
1115
1075
  else {
@@ -1144,10 +1104,16 @@ const plainLogger = (0, _kubb_core.defineLogger)({
1144
1104
  name: "plain",
1145
1105
  install(context, options) {
1146
1106
  const logLevel = options?.logLevel ?? _kubb_core.logLevel.info;
1147
- const hookStarts = /* @__PURE__ */ new Map();
1107
+ const hookTimer = createHookTimer();
1148
1108
  function getMessage(message) {
1149
1109
  return formatMessage(message, logLevel);
1150
1110
  }
1111
+ function onStep(event, message) {
1112
+ context.on(event, () => {
1113
+ if (logLevel <= _kubb_core.logLevel.silent) return;
1114
+ console.log(getMessage(message));
1115
+ });
1116
+ }
1151
1117
  context.on("kubb:info", ({ message, info }) => {
1152
1118
  if (logLevel <= _kubb_core.logLevel.silent) return;
1153
1119
  const text = getMessage([
@@ -1196,16 +1162,8 @@ const plainLogger = (0, _kubb_core.defineLogger)({
1196
1162
  if (logLevel <= _kubb_core.logLevel.silent) return;
1197
1163
  console.log(getMessage(`Update available: v${currentVersion} → v${latestVersion}. Run \`npm install -g @kubb/cli\` to update.`));
1198
1164
  });
1199
- context.on("kubb:config:start", () => {
1200
- if (logLevel <= _kubb_core.logLevel.silent) return;
1201
- const text = getMessage("Configuration started");
1202
- console.log(text);
1203
- });
1204
- context.on("kubb:config:end", () => {
1205
- if (logLevel <= _kubb_core.logLevel.silent) return;
1206
- const text = getMessage("Configuration completed");
1207
- console.log(text);
1208
- });
1165
+ onStep("kubb:config:start", "Configuration started");
1166
+ onStep("kubb:config:end", "Configuration completed");
1209
1167
  context.on("kubb:generation:start", () => {
1210
1168
  const text = getMessage("Generation started");
1211
1169
  console.log(text);
@@ -1239,45 +1197,22 @@ const plainLogger = (0, _kubb_core.defineLogger)({
1239
1197
  const text = getMessage(config.name ? `Generation completed for ${config.name}` : "Generation completed");
1240
1198
  console.log(text);
1241
1199
  });
1242
- context.on("kubb:format:start", () => {
1243
- if (logLevel <= _kubb_core.logLevel.silent) return;
1244
- const text = getMessage("Format started");
1245
- console.log(text);
1246
- });
1247
- context.on("kubb:format:end", () => {
1248
- if (logLevel <= _kubb_core.logLevel.silent) return;
1249
- const text = getMessage("Format completed");
1250
- console.log(text);
1251
- });
1252
- context.on("kubb:lint:start", () => {
1253
- if (logLevel <= _kubb_core.logLevel.silent) return;
1254
- const text = getMessage("Lint started");
1255
- console.log(text);
1256
- });
1257
- context.on("kubb:lint:end", () => {
1258
- if (logLevel <= _kubb_core.logLevel.silent) return;
1259
- const text = getMessage("Lint completed");
1260
- console.log(text);
1261
- });
1262
- context.on("kubb:hooks:start", () => {
1263
- if (logLevel <= _kubb_core.logLevel.silent) return;
1264
- console.log(getMessage("Hooks started"));
1265
- });
1266
- context.on("kubb:hooks:end", () => {
1267
- if (logLevel <= _kubb_core.logLevel.silent) return;
1268
- console.log(getMessage("Hooks completed"));
1269
- });
1200
+ onStep("kubb:format:start", "Format started");
1201
+ onStep("kubb:format:end", "Format completed");
1202
+ onStep("kubb:lint:start", "Lint started");
1203
+ onStep("kubb:lint:end", "Lint completed");
1204
+ onStep("kubb:hooks:start", "Hooks started");
1205
+ onStep("kubb:hooks:end", "Hooks completed");
1270
1206
  context.on("kubb:hook:start", ({ id, command, args }) => {
1271
1207
  if (logLevel <= _kubb_core.logLevel.silent) return;
1272
- if (id) hookStarts.set(id, node_process.default.hrtime());
1208
+ if (id) hookTimer.start(id);
1273
1209
  const commandWithArgs = formatCommandWithArgs(command, args);
1274
1210
  console.log(getMessage(`Hook ${commandWithArgs} started`));
1275
1211
  });
1276
1212
  context.on("kubb:hook:end", ({ id, command, args, success, error }) => {
1277
1213
  if (logLevel <= _kubb_core.logLevel.silent) return;
1278
- const hrStart = id ? hookStarts.get(id) : void 0;
1279
- if (id) hookStarts.delete(id);
1280
- const durationStr = hrStart ? ` in ${formatMs(getElapsedMs(hrStart))}` : "";
1214
+ const ms = id ? hookTimer.end(id) : void 0;
1215
+ const durationStr = ms !== void 0 ? ` in ${formatMs(ms)}` : "";
1281
1216
  const commandWithArgs = formatCommandWithArgs(command, args);
1282
1217
  if (success) console.log(getMessage(`✓ Hook ${commandWithArgs} completed${durationStr}`));
1283
1218
  else {
@@ -1336,6 +1271,57 @@ function buildProgressLine(state) {
1336
1271
  return parts.join((0, node_util.styleText)("dim", " | "));
1337
1272
  }
1338
1273
  /**
1274
+ * Creates the per-run progress counters shared by the clack and GitHub Actions loggers.
1275
+ */
1276
+ function createProgressCounters() {
1277
+ return {
1278
+ totalPlugins: 0,
1279
+ completedPlugins: 0,
1280
+ failedPlugins: 0,
1281
+ totalFiles: 0,
1282
+ processedFiles: 0,
1283
+ hrStart: node_process.default.hrtime()
1284
+ };
1285
+ }
1286
+ /**
1287
+ * Resets the progress counters in place at the start/end of a generation run.
1288
+ */
1289
+ function resetProgressCounters(state) {
1290
+ state.totalPlugins = 0;
1291
+ state.completedPlugins = 0;
1292
+ state.failedPlugins = 0;
1293
+ state.totalFiles = 0;
1294
+ state.processedFiles = 0;
1295
+ state.hrStart = node_process.default.hrtime();
1296
+ }
1297
+ /**
1298
+ * Records a finished plugin against the progress counters.
1299
+ */
1300
+ function recordPluginResult(state, success) {
1301
+ if (success) state.completedPlugins++;
1302
+ else state.failedPlugins++;
1303
+ }
1304
+ /**
1305
+ * Creates a {@link HookTimer} backed by a private `id → hrtime` map.
1306
+ */
1307
+ function createHookTimer() {
1308
+ const starts = /* @__PURE__ */ new Map();
1309
+ return {
1310
+ start(id) {
1311
+ starts.set(id, node_process.default.hrtime());
1312
+ },
1313
+ end(id) {
1314
+ const hrStart = starts.get(id);
1315
+ if (!hrStart) return;
1316
+ starts.delete(id);
1317
+ return getElapsedMs(hrStart);
1318
+ },
1319
+ clear() {
1320
+ starts.clear();
1321
+ }
1322
+ };
1323
+ }
1324
+ /**
1339
1325
  * Join a command and its optional args into a single display string.
1340
1326
  * e.g. ("prettier", ["--write", "."]) → "prettier --write ."
1341
1327
  */
@@ -1835,4 +1821,4 @@ async function run({ input, configPath, logLevel: logLevelKey, watch }) {
1835
1821
  //#endregion
1836
1822
  exports.run = run;
1837
1823
 
1838
- //# sourceMappingURL=run-BGQSMjOH.cjs.map
1824
+ //# sourceMappingURL=run-e1Pda1tW.cjs.map