@kubb/cli 4.12.5 → 4.12.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{generate-DKUIRxiL.js → generate--x91ECr5.js} +137 -71
- package/dist/generate--x91ECr5.js.map +1 -0
- package/dist/{generate-BGEmIdHW.cjs → generate-7e5eF2O-.cjs} +136 -70
- package/dist/generate-7e5eF2O-.cjs.map +1 -0
- package/dist/index.cjs +5 -5
- package/dist/index.js +5 -5
- package/dist/{mcp-LLlOFV3c.js → mcp-B5FWDVjp.js} +3 -3
- package/dist/mcp-B5FWDVjp.js.map +1 -0
- package/dist/{mcp-N1IVyiXf.cjs → mcp-D7d_8Bma.cjs} +3 -3
- package/dist/mcp-D7d_8Bma.cjs.map +1 -0
- package/dist/{package-ChTBCRJt.cjs → package-CrqsFX0R.cjs} +2 -2
- package/dist/package-CrqsFX0R.cjs.map +1 -0
- package/dist/package-V7YSB1bN.js +6 -0
- package/dist/package-V7YSB1bN.js.map +1 -0
- package/dist/{validate-BptoQ-63.js → validate-Bt922JN-.js} +3 -3
- package/dist/validate-Bt922JN-.js.map +1 -0
- package/dist/{validate-Dn6hZ7Z4.cjs → validate-D9LPzg3-.cjs} +3 -3
- package/dist/validate-D9LPzg3-.cjs.map +1 -0
- package/package.json +4 -4
- package/src/commands/generate.ts +2 -2
- package/src/commands/mcp.ts +3 -5
- package/src/commands/validate.ts +3 -5
- package/src/loggers/clackLogger.ts +85 -25
- package/src/loggers/githubActionsLogger.ts +94 -20
- package/src/loggers/plainLogger.ts +4 -3
- package/src/runners/generate.ts +10 -10
- package/src/utils/Writables.ts +0 -8
- package/src/utils/getCosmiConfig.ts +2 -2
- package/src/utils/getSummary.ts +3 -3
- package/dist/generate-BGEmIdHW.cjs.map +0 -1
- package/dist/generate-DKUIRxiL.js.map +0 -1
- package/dist/mcp-LLlOFV3c.js.map +0 -1
- package/dist/mcp-N1IVyiXf.cjs.map +0 -1
- package/dist/package-BqxUFXm-.js +0 -6
- package/dist/package-BqxUFXm-.js.map +0 -1
- package/dist/package-ChTBCRJt.cjs.map +0 -1
- package/dist/validate-BptoQ-63.js.map +0 -1
- package/dist/validate-Dn6hZ7Z4.cjs.map +0 -1
- package/src/utils/parseHrtimeToSeconds.ts +0 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
-
const require_package = require('./package-
|
|
2
|
+
const require_package = require('./package-CrqsFX0R.cjs');
|
|
3
3
|
let citty = require("citty");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_chunk.__toESM(node_path);
|
|
@@ -25,12 +25,6 @@ let string_argv = require("string-argv");
|
|
|
25
25
|
let cosmiconfig = require("cosmiconfig");
|
|
26
26
|
let jiti = require("jiti");
|
|
27
27
|
|
|
28
|
-
//#region src/utils/parseHrtimeToSeconds.ts
|
|
29
|
-
function parseHrtimeToSeconds(hrtime) {
|
|
30
|
-
return (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
28
|
//#region src/utils/randomColour.ts
|
|
35
29
|
function randomColour(text) {
|
|
36
30
|
if (!text) return "white";
|
|
@@ -58,14 +52,14 @@ function randomCliColour(text) {
|
|
|
58
52
|
//#endregion
|
|
59
53
|
//#region src/utils/getSummary.ts
|
|
60
54
|
function getSummary({ failedPlugins, filesCreated, status, hrStart, config, pluginTimings }) {
|
|
61
|
-
const
|
|
55
|
+
const duration = (0, _kubb_core_utils.formatHrtime)(hrStart);
|
|
62
56
|
const pluginsCount = config.plugins?.length || 0;
|
|
63
57
|
const successCount = pluginsCount - failedPlugins.size;
|
|
64
58
|
const meta = {
|
|
65
59
|
plugins: status === "success" ? `${picocolors.default.green(`${successCount} successful`)}, ${pluginsCount} total` : `${picocolors.default.green(`${successCount} successful`)}, ${picocolors.default.red(`${failedPlugins.size} failed`)}, ${pluginsCount} total`,
|
|
66
60
|
pluginsFailed: status === "failed" ? [...failedPlugins]?.map(({ plugin }) => randomCliColour(plugin.name))?.join(", ") : void 0,
|
|
67
61
|
filesCreated,
|
|
68
|
-
time:
|
|
62
|
+
time: picocolors.default.green(duration),
|
|
69
63
|
output: node_path.default.isAbsolute(config.root) ? node_path.default.resolve(config.root, config.output.path) : config.root
|
|
70
64
|
};
|
|
71
65
|
const labels = {
|
|
@@ -122,9 +116,31 @@ const clackLogger = (0, _kubb_core.defineLogger)({
|
|
|
122
116
|
name: "clack",
|
|
123
117
|
install(context, options) {
|
|
124
118
|
const logLevel = options?.logLevel || _kubb_core.LogLevel.info;
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
119
|
+
const state = {
|
|
120
|
+
totalPlugins: 0,
|
|
121
|
+
completedPlugins: 0,
|
|
122
|
+
failedPlugins: 0,
|
|
123
|
+
totalFiles: 0,
|
|
124
|
+
processedFiles: 0,
|
|
125
|
+
hrStart: node_process.default.hrtime(),
|
|
126
|
+
spinner: _clack_prompts.spinner(),
|
|
127
|
+
isSpinning: false,
|
|
128
|
+
activeProgress: /* @__PURE__ */ new Map()
|
|
129
|
+
};
|
|
130
|
+
function showProgressStep() {
|
|
131
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
132
|
+
const parts = [];
|
|
133
|
+
const duration = (0, _kubb_core_utils.formatHrtime)(state.hrStart);
|
|
134
|
+
if (state.totalPlugins > 0) {
|
|
135
|
+
const pluginStr = state.failedPlugins > 0 ? `Plugins ${picocolors.default.green(state.completedPlugins.toString())}/${state.totalPlugins} ${picocolors.default.red(`(${state.failedPlugins} failed)`)}` : `Plugins ${picocolors.default.green(state.completedPlugins.toString())}/${state.totalPlugins}`;
|
|
136
|
+
parts.push(pluginStr);
|
|
137
|
+
}
|
|
138
|
+
if (state.totalFiles > 0) parts.push(`Files ${picocolors.default.green(state.processedFiles.toString())}/${state.totalFiles}`);
|
|
139
|
+
if (parts.length > 0) {
|
|
140
|
+
parts.push(picocolors.default.green(duration));
|
|
141
|
+
_clack_prompts.log.step(parts.join(picocolors.default.dim(" | ")));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
128
144
|
function getMessage(message) {
|
|
129
145
|
if (logLevel >= _kubb_core.LogLevel.verbose) {
|
|
130
146
|
const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
@@ -138,12 +154,12 @@ const clackLogger = (0, _kubb_core.defineLogger)({
|
|
|
138
154
|
return message;
|
|
139
155
|
}
|
|
140
156
|
function startSpinner(text) {
|
|
141
|
-
spinner.start(text);
|
|
142
|
-
isSpinning = true;
|
|
157
|
+
state.spinner.start(text);
|
|
158
|
+
state.isSpinning = true;
|
|
143
159
|
}
|
|
144
160
|
function stopSpinner(text) {
|
|
145
|
-
spinner.stop(text);
|
|
146
|
-
isSpinning = false;
|
|
161
|
+
state.spinner.stop(text);
|
|
162
|
+
state.isSpinning = false;
|
|
147
163
|
}
|
|
148
164
|
context.on("info", (message, info = "") => {
|
|
149
165
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
@@ -152,7 +168,7 @@ const clackLogger = (0, _kubb_core.defineLogger)({
|
|
|
152
168
|
message,
|
|
153
169
|
picocolors.default.dim(info)
|
|
154
170
|
].join(" "));
|
|
155
|
-
if (isSpinning) spinner.message(text);
|
|
171
|
+
if (state.isSpinning) state.spinner.message(text);
|
|
156
172
|
else _clack_prompts.log.info(text);
|
|
157
173
|
});
|
|
158
174
|
context.on("success", (message, info = "") => {
|
|
@@ -162,7 +178,7 @@ const clackLogger = (0, _kubb_core.defineLogger)({
|
|
|
162
178
|
message,
|
|
163
179
|
logLevel >= _kubb_core.LogLevel.info ? picocolors.default.dim(info) : void 0
|
|
164
180
|
].filter(Boolean).join(" "));
|
|
165
|
-
if (isSpinning) stopSpinner(text);
|
|
181
|
+
if (state.isSpinning) stopSpinner(text);
|
|
166
182
|
else _clack_prompts.log.success(text);
|
|
167
183
|
});
|
|
168
184
|
context.on("warn", (message, info) => {
|
|
@@ -177,7 +193,7 @@ const clackLogger = (0, _kubb_core.defineLogger)({
|
|
|
177
193
|
context.on("error", (error) => {
|
|
178
194
|
const caused = error.cause;
|
|
179
195
|
const text = [picocolors.default.red("✗"), error.message].join(" ");
|
|
180
|
-
if (isSpinning) stopSpinner(getMessage(text));
|
|
196
|
+
if (state.isSpinning) stopSpinner(getMessage(text));
|
|
181
197
|
else _clack_prompts.log.error(getMessage(text));
|
|
182
198
|
if (logLevel >= _kubb_core.LogLevel.debug && error.stack) {
|
|
183
199
|
const frames = error.stack.split("\n").slice(1, 4);
|
|
@@ -214,12 +230,16 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
214
230
|
_clack_prompts.intro(text);
|
|
215
231
|
startSpinner(getMessage("Configuration loading"));
|
|
216
232
|
});
|
|
217
|
-
context.on("config:end", () => {
|
|
233
|
+
context.on("config:end", (_configs) => {
|
|
218
234
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
219
235
|
const text = getMessage("Configuration completed");
|
|
220
236
|
_clack_prompts.outro(text);
|
|
221
237
|
});
|
|
222
238
|
context.on("generation:start", (config) => {
|
|
239
|
+
state.totalPlugins = config.plugins?.length || 0;
|
|
240
|
+
state.completedPlugins = 0;
|
|
241
|
+
state.failedPlugins = 0;
|
|
242
|
+
state.hrStart = node_process.default.hrtime();
|
|
223
243
|
const text = getMessage(["Generation started", config.name ? `for ${picocolors.default.dim(config.name)}` : void 0].filter(Boolean).join(" "));
|
|
224
244
|
_clack_prompts.intro(text);
|
|
225
245
|
});
|
|
@@ -236,24 +256,29 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
236
256
|
const interval = setInterval(() => {
|
|
237
257
|
progressBar.advance();
|
|
238
258
|
}, 50);
|
|
239
|
-
activeProgress.set(plugin.name, {
|
|
259
|
+
state.activeProgress.set(plugin.name, {
|
|
240
260
|
progressBar,
|
|
241
261
|
interval
|
|
242
262
|
});
|
|
243
263
|
});
|
|
244
|
-
context.on("plugin:end", (plugin, duration) => {
|
|
264
|
+
context.on("plugin:end", (plugin, { duration, success }) => {
|
|
245
265
|
stopSpinner();
|
|
246
|
-
const active = activeProgress.get(plugin.name);
|
|
266
|
+
const active = state.activeProgress.get(plugin.name);
|
|
247
267
|
if (!active || logLevel === _kubb_core.LogLevel.silent) return;
|
|
248
268
|
clearInterval(active.interval);
|
|
249
|
-
|
|
250
|
-
|
|
269
|
+
if (success) state.completedPlugins++;
|
|
270
|
+
else state.failedPlugins++;
|
|
271
|
+
const durationStr = (0, _kubb_core_utils.formatMs)(duration);
|
|
272
|
+
const text = getMessage(success ? `${picocolors.default.bold(plugin.name)} completed in ${picocolors.default.green(durationStr)}` : `${picocolors.default.bold(plugin.name)} failed in ${picocolors.default.red(durationStr)}`);
|
|
251
273
|
active.progressBar.stop(text);
|
|
252
|
-
activeProgress.delete(plugin.name);
|
|
274
|
+
state.activeProgress.delete(plugin.name);
|
|
275
|
+
showProgressStep();
|
|
253
276
|
});
|
|
254
277
|
context.on("files:processing:start", (files) => {
|
|
255
278
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
256
279
|
stopSpinner();
|
|
280
|
+
state.totalFiles = files.length;
|
|
281
|
+
state.processedFiles = 0;
|
|
257
282
|
const text = `Writing ${files.length} files`;
|
|
258
283
|
const progressBar = _clack_prompts.progress({
|
|
259
284
|
style: "block",
|
|
@@ -262,13 +287,14 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
262
287
|
});
|
|
263
288
|
context.emit("info", text);
|
|
264
289
|
progressBar.start(getMessage(text));
|
|
265
|
-
activeProgress.set("files", { progressBar });
|
|
290
|
+
state.activeProgress.set("files", { progressBar });
|
|
266
291
|
});
|
|
267
292
|
context.on("file:processing:update", ({ file, config }) => {
|
|
268
293
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
269
294
|
stopSpinner();
|
|
295
|
+
state.processedFiles++;
|
|
270
296
|
const text = `Writing ${(0, node_path.relative)(config.root, file.path)}`;
|
|
271
|
-
const active = activeProgress.get("files");
|
|
297
|
+
const active = state.activeProgress.get("files");
|
|
272
298
|
if (!active) return;
|
|
273
299
|
active.progressBar.advance(void 0, text);
|
|
274
300
|
});
|
|
@@ -276,10 +302,11 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
276
302
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
277
303
|
stopSpinner();
|
|
278
304
|
const text = getMessage("Files written successfully");
|
|
279
|
-
const active = activeProgress.get("files");
|
|
305
|
+
const active = state.activeProgress.get("files");
|
|
280
306
|
if (!active) return;
|
|
281
307
|
active.progressBar.stop(text);
|
|
282
|
-
activeProgress.delete("files");
|
|
308
|
+
state.activeProgress.delete("files");
|
|
309
|
+
showProgressStep();
|
|
283
310
|
});
|
|
284
311
|
context.on("generation:end", (config) => {
|
|
285
312
|
const text = getMessage(config.name ? `Generation completed for ${picocolors.default.dim(config.name)}` : "Generation completed");
|
|
@@ -393,11 +420,11 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
393
420
|
});
|
|
394
421
|
});
|
|
395
422
|
context.on("lifecycle:end", () => {
|
|
396
|
-
for (const [_key, active] of activeProgress) {
|
|
423
|
+
for (const [_key, active] of state.activeProgress) {
|
|
397
424
|
if (active.interval) clearInterval(active.interval);
|
|
398
425
|
active.progressBar?.stop();
|
|
399
426
|
}
|
|
400
|
-
activeProgress.clear();
|
|
427
|
+
state.activeProgress.clear();
|
|
401
428
|
});
|
|
402
429
|
}
|
|
403
430
|
});
|
|
@@ -482,7 +509,29 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
482
509
|
name: "github-actions",
|
|
483
510
|
install(context, options) {
|
|
484
511
|
const logLevel = options?.logLevel || _kubb_core.LogLevel.info;
|
|
485
|
-
|
|
512
|
+
const state = {
|
|
513
|
+
totalPlugins: 0,
|
|
514
|
+
completedPlugins: 0,
|
|
515
|
+
failedPlugins: 0,
|
|
516
|
+
totalFiles: 0,
|
|
517
|
+
processedFiles: 0,
|
|
518
|
+
hrStart: process.hrtime(),
|
|
519
|
+
currentConfigs: []
|
|
520
|
+
};
|
|
521
|
+
function showProgressStep() {
|
|
522
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
523
|
+
const parts = [];
|
|
524
|
+
const duration = (0, _kubb_core_utils.formatHrtime)(state.hrStart);
|
|
525
|
+
if (state.totalPlugins > 0) {
|
|
526
|
+
const pluginStr = state.failedPlugins > 0 ? `Plugins ${picocolors.default.green(state.completedPlugins.toString())}/${state.totalPlugins} ${picocolors.default.red(`(${state.failedPlugins} failed)`)}` : `Plugins ${picocolors.default.green(state.completedPlugins.toString())}/${state.totalPlugins}`;
|
|
527
|
+
parts.push(pluginStr);
|
|
528
|
+
}
|
|
529
|
+
if (state.totalFiles > 0) parts.push(`Files ${picocolors.default.green(state.processedFiles.toString())}/${state.totalFiles}`);
|
|
530
|
+
if (parts.length > 0) {
|
|
531
|
+
parts.push(picocolors.default.green(duration));
|
|
532
|
+
console.log(parts.join(picocolors.default.dim(" | ")));
|
|
533
|
+
}
|
|
534
|
+
}
|
|
486
535
|
function getMessage(message) {
|
|
487
536
|
if (logLevel >= _kubb_core.LogLevel.verbose) {
|
|
488
537
|
const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
@@ -543,34 +592,43 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
543
592
|
console.log(text);
|
|
544
593
|
});
|
|
545
594
|
context.on("config:end", (configs) => {
|
|
546
|
-
currentConfigs = configs;
|
|
595
|
+
state.currentConfigs = configs;
|
|
547
596
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
548
597
|
const text = getMessage("Configuration completed");
|
|
549
598
|
console.log(text);
|
|
550
599
|
closeGroup("Configuration");
|
|
551
600
|
});
|
|
552
601
|
context.on("generation:start", (config) => {
|
|
602
|
+
state.totalPlugins = config.plugins?.length || 0;
|
|
603
|
+
state.completedPlugins = 0;
|
|
604
|
+
state.failedPlugins = 0;
|
|
605
|
+
state.hrStart = process.hrtime();
|
|
553
606
|
const text = config.name ? `Generation for ${picocolors.default.bold(config.name)}` : "Generation";
|
|
554
|
-
if (currentConfigs.length > 1) openGroup(text);
|
|
555
|
-
if (currentConfigs.length === 1) console.log(getMessage(text));
|
|
607
|
+
if (state.currentConfigs.length > 1) openGroup(text);
|
|
608
|
+
if (state.currentConfigs.length === 1) console.log(getMessage(text));
|
|
556
609
|
});
|
|
557
610
|
context.on("plugin:start", (plugin) => {
|
|
558
611
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
559
612
|
const text = getMessage(`Generating ${picocolors.default.bold(plugin.name)}`);
|
|
560
|
-
if (currentConfigs.length === 1) openGroup(`Plugin: ${plugin.name}`);
|
|
613
|
+
if (state.currentConfigs.length === 1) openGroup(`Plugin: ${plugin.name}`);
|
|
561
614
|
console.log(text);
|
|
562
615
|
});
|
|
563
|
-
context.on("plugin:end", (plugin, duration) => {
|
|
616
|
+
context.on("plugin:end", (plugin, { duration, success }) => {
|
|
564
617
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
565
|
-
|
|
566
|
-
|
|
618
|
+
if (success) state.completedPlugins++;
|
|
619
|
+
else state.failedPlugins++;
|
|
620
|
+
const durationStr = (0, _kubb_core_utils.formatMs)(duration);
|
|
621
|
+
const text = getMessage(success ? `${picocolors.default.bold(plugin.name)} completed in ${picocolors.default.green(durationStr)}` : `${picocolors.default.bold(plugin.name)} failed in ${picocolors.default.red(durationStr)}`);
|
|
567
622
|
console.log(text);
|
|
568
|
-
if (currentConfigs.length > 1) console.log(" ");
|
|
569
|
-
if (currentConfigs.length === 1) closeGroup(`Plugin: ${plugin.name}`);
|
|
623
|
+
if (state.currentConfigs.length > 1) console.log(" ");
|
|
624
|
+
if (state.currentConfigs.length === 1) closeGroup(`Plugin: ${plugin.name}`);
|
|
625
|
+
showProgressStep();
|
|
570
626
|
});
|
|
571
627
|
context.on("files:processing:start", (files) => {
|
|
572
628
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
573
|
-
|
|
629
|
+
state.totalFiles = files.length;
|
|
630
|
+
state.processedFiles = 0;
|
|
631
|
+
if (state.currentConfigs.length === 1) openGroup("File Generation");
|
|
574
632
|
const text = getMessage(`Writing ${files.length} files`);
|
|
575
633
|
console.log(text);
|
|
576
634
|
});
|
|
@@ -578,7 +636,15 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
578
636
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
579
637
|
const text = getMessage("Files written successfully");
|
|
580
638
|
console.log(text);
|
|
581
|
-
if (currentConfigs.length === 1) closeGroup("File Generation");
|
|
639
|
+
if (state.currentConfigs.length === 1) closeGroup("File Generation");
|
|
640
|
+
});
|
|
641
|
+
context.on("file:processing:update", () => {
|
|
642
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
643
|
+
state.processedFiles++;
|
|
644
|
+
});
|
|
645
|
+
context.on("files:processing:end", () => {
|
|
646
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
647
|
+
showProgressStep();
|
|
582
648
|
});
|
|
583
649
|
context.on("generation:end", (config) => {
|
|
584
650
|
const text = getMessage(config.name ? `${picocolors.default.blue("✓")} Generation completed for ${picocolors.default.dim(config.name)}` : `${picocolors.default.blue("✓")} Generation completed`);
|
|
@@ -609,45 +675,45 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
609
675
|
context.on("format:start", () => {
|
|
610
676
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
611
677
|
const text = getMessage("Format started");
|
|
612
|
-
if (currentConfigs.length === 1) openGroup("Formatting");
|
|
678
|
+
if (state.currentConfigs.length === 1) openGroup("Formatting");
|
|
613
679
|
console.log(text);
|
|
614
680
|
});
|
|
615
681
|
context.on("format:end", () => {
|
|
616
682
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
617
683
|
const text = getMessage("Format completed");
|
|
618
684
|
console.log(text);
|
|
619
|
-
if (currentConfigs.length === 1) closeGroup("Formatting");
|
|
685
|
+
if (state.currentConfigs.length === 1) closeGroup("Formatting");
|
|
620
686
|
});
|
|
621
687
|
context.on("lint:start", () => {
|
|
622
688
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
623
689
|
const text = getMessage("Lint started");
|
|
624
|
-
if (currentConfigs.length === 1) openGroup("Linting");
|
|
690
|
+
if (state.currentConfigs.length === 1) openGroup("Linting");
|
|
625
691
|
console.log(text);
|
|
626
692
|
});
|
|
627
693
|
context.on("lint:end", () => {
|
|
628
694
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
629
695
|
const text = getMessage("Lint completed");
|
|
630
696
|
console.log(text);
|
|
631
|
-
if (currentConfigs.length === 1) closeGroup("Linting");
|
|
697
|
+
if (state.currentConfigs.length === 1) closeGroup("Linting");
|
|
632
698
|
});
|
|
633
699
|
context.on("hook:start", (command$1) => {
|
|
634
700
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
635
701
|
const text = getMessage(`Hook ${picocolors.default.dim(command$1)} started`);
|
|
636
|
-
if (currentConfigs.length === 1) openGroup(`Hook ${command$1}`);
|
|
702
|
+
if (state.currentConfigs.length === 1) openGroup(`Hook ${command$1}`);
|
|
637
703
|
console.log(text);
|
|
638
704
|
});
|
|
639
705
|
context.on("hook:end", (command$1) => {
|
|
640
706
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
641
707
|
const text = getMessage(`Hook ${picocolors.default.dim(command$1)} completed`);
|
|
642
708
|
console.log(text);
|
|
643
|
-
if (currentConfigs.length === 1) closeGroup(`Hook ${command$1}`);
|
|
709
|
+
if (state.currentConfigs.length === 1) closeGroup(`Hook ${command$1}`);
|
|
644
710
|
});
|
|
645
711
|
context.on("generation:summary", (config, { status, failedPlugins }) => {
|
|
646
712
|
const pluginsCount = config.plugins?.length || 0;
|
|
647
713
|
const successCount = pluginsCount - failedPlugins.size;
|
|
648
|
-
if (currentConfigs.length > 1) console.log(" ");
|
|
714
|
+
if (state.currentConfigs.length > 1) console.log(" ");
|
|
649
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`);
|
|
650
|
-
if (currentConfigs.length > 1) closeGroup(config.name ? `Generation for ${picocolors.default.bold(config.name)}` : "Generation");
|
|
716
|
+
if (state.currentConfigs.length > 1) closeGroup(config.name ? `Generation for ${picocolors.default.bold(config.name)}` : "Generation");
|
|
651
717
|
});
|
|
652
718
|
}
|
|
653
719
|
});
|
|
@@ -734,10 +800,10 @@ const plainLogger = (0, _kubb_core.defineLogger)({
|
|
|
734
800
|
const text = getMessage(`Generating ${plugin.name}`);
|
|
735
801
|
console.log(text);
|
|
736
802
|
});
|
|
737
|
-
context.on("plugin:end", (plugin, duration) => {
|
|
803
|
+
context.on("plugin:end", (plugin, { duration, success }) => {
|
|
738
804
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
739
|
-
const durationStr =
|
|
740
|
-
const text = getMessage(`${plugin.name} completed in ${durationStr}`);
|
|
805
|
+
const durationStr = (0, _kubb_core_utils.formatMs)(duration);
|
|
806
|
+
const text = getMessage(success ? `${plugin.name} completed in ${durationStr}` : `${plugin.name} failed in ${durationStr}`);
|
|
741
807
|
console.log(text);
|
|
742
808
|
});
|
|
743
809
|
context.on("files:processing:start", (files) => {
|
|
@@ -938,8 +1004,8 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
938
1004
|
"successfully"
|
|
939
1005
|
].filter(Boolean).join(" "));
|
|
940
1006
|
});
|
|
941
|
-
} catch (
|
|
942
|
-
await events.emit("error",
|
|
1007
|
+
} catch (caughtError) {
|
|
1008
|
+
await events.emit("error", caughtError);
|
|
943
1009
|
}
|
|
944
1010
|
await events.emit("success", `Formatted with ${config.output.format}`);
|
|
945
1011
|
}
|
|
@@ -958,9 +1024,9 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
958
1024
|
"successfully"
|
|
959
1025
|
].filter(Boolean).join(" "));
|
|
960
1026
|
});
|
|
961
|
-
} catch (
|
|
1027
|
+
} catch (caughtError) {
|
|
962
1028
|
const error$1 = /* @__PURE__ */ new Error("Biome not found");
|
|
963
|
-
error$1.cause =
|
|
1029
|
+
error$1.cause = caughtError;
|
|
964
1030
|
await events.emit("error", error$1);
|
|
965
1031
|
}
|
|
966
1032
|
await events.emit("format:end");
|
|
@@ -979,9 +1045,9 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
979
1045
|
"successfully"
|
|
980
1046
|
].filter(Boolean).join(" "));
|
|
981
1047
|
});
|
|
982
|
-
} catch (
|
|
1048
|
+
} catch (caughtError) {
|
|
983
1049
|
const error$1 = /* @__PURE__ */ new Error("Eslint not found");
|
|
984
|
-
error$1.cause =
|
|
1050
|
+
error$1.cause = caughtError;
|
|
985
1051
|
await events.emit("error", error$1);
|
|
986
1052
|
}
|
|
987
1053
|
if (config.output.lint === "biome") try {
|
|
@@ -999,9 +1065,9 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
999
1065
|
"successfully"
|
|
1000
1066
|
].filter(Boolean).join(" "));
|
|
1001
1067
|
});
|
|
1002
|
-
} catch (
|
|
1068
|
+
} catch (caughtError) {
|
|
1003
1069
|
const error$1 = /* @__PURE__ */ new Error("Biome not found");
|
|
1004
|
-
error$1.cause =
|
|
1070
|
+
error$1.cause = caughtError;
|
|
1005
1071
|
await events.emit("error", error$1);
|
|
1006
1072
|
}
|
|
1007
1073
|
if (config.output.lint === "oxlint") try {
|
|
@@ -1015,9 +1081,9 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
1015
1081
|
"successfully"
|
|
1016
1082
|
].filter(Boolean).join(" "));
|
|
1017
1083
|
});
|
|
1018
|
-
} catch (
|
|
1084
|
+
} catch (caughtError) {
|
|
1019
1085
|
const error$1 = /* @__PURE__ */ new Error("Oxlint not found");
|
|
1020
|
-
error$1.cause =
|
|
1086
|
+
error$1.cause = caughtError;
|
|
1021
1087
|
await events.emit("error", error$1);
|
|
1022
1088
|
}
|
|
1023
1089
|
await events.emit("lint:end");
|
|
@@ -1130,8 +1196,8 @@ async function getCosmiConfig(moduleName, config) {
|
|
|
1130
1196
|
});
|
|
1131
1197
|
try {
|
|
1132
1198
|
result = config ? await explorer.load(config) : await explorer.search();
|
|
1133
|
-
} catch (
|
|
1134
|
-
throw new Error("Config failed loading", { cause:
|
|
1199
|
+
} catch (error) {
|
|
1200
|
+
throw new Error("Config failed loading", { cause: error });
|
|
1135
1201
|
}
|
|
1136
1202
|
if (result?.isEmpty || !result || !result.config) throw new Error("Config not defined, create a kubb.config.js or pass through your config with the option --config");
|
|
1137
1203
|
return result;
|
|
@@ -1244,8 +1310,8 @@ const command = (0, citty.defineCommand)({
|
|
|
1244
1310
|
});
|
|
1245
1311
|
await promiseManager.run("seq", promises);
|
|
1246
1312
|
await events.emit("lifecycle:end");
|
|
1247
|
-
} catch (
|
|
1248
|
-
await events.emit("error",
|
|
1313
|
+
} catch (error) {
|
|
1314
|
+
await events.emit("error", error);
|
|
1249
1315
|
}
|
|
1250
1316
|
}
|
|
1251
1317
|
});
|
|
@@ -1253,4 +1319,4 @@ var generate_default = command;
|
|
|
1253
1319
|
|
|
1254
1320
|
//#endregion
|
|
1255
1321
|
exports.default = generate_default;
|
|
1256
|
-
//# sourceMappingURL=generate-
|
|
1322
|
+
//# sourceMappingURL=generate-7e5eF2O-.cjs.map
|