@kubb/cli 4.12.7 → 4.12.8
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-7e5eF2O-.cjs → generate-BIq4hG_7.cjs} +243 -135
- package/dist/generate-BIq4hG_7.cjs.map +1 -0
- package/dist/{generate--x91ECr5.js → generate-DbvDQY54.js} +243 -135
- package/dist/generate-DbvDQY54.js.map +1 -0
- package/dist/index.cjs +3 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/{package-CrqsFX0R.cjs → package-DIKLcg4Q.cjs} +2 -2
- package/dist/package-DIKLcg4Q.cjs.map +1 -0
- package/dist/package-sWmJhaYS.js +6 -0
- package/dist/package-sWmJhaYS.js.map +1 -0
- package/package.json +4 -4
- package/src/commands/generate.ts +10 -0
- package/src/index.ts +0 -9
- package/src/loggers/clackLogger.ts +74 -68
- package/src/loggers/fileSystemLogger.ts +81 -15
- package/src/loggers/githubActionsLogger.ts +51 -45
- package/src/loggers/plainLogger.ts +29 -33
- package/src/runners/generate.ts +56 -45
- package/src/utils/executeHooks.ts +7 -4
- package/dist/generate--x91ECr5.js.map +0 -1
- package/dist/generate-7e5eF2O-.cjs.map +0 -1
- package/dist/package-CrqsFX0R.cjs.map +0 -1
- package/dist/package-V7YSB1bN.js +0 -6
- package/dist/package-V7YSB1bN.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "./package-
|
|
1
|
+
import { t as version } from "./package-sWmJhaYS.js";
|
|
2
2
|
import { defineCommand, showUsage } from "citty";
|
|
3
3
|
import path, { relative, resolve } from "node:path";
|
|
4
4
|
import * as process$2 from "node:process";
|
|
@@ -14,6 +14,7 @@ import gradientString from "gradient-string";
|
|
|
14
14
|
import seedrandom from "seedrandom";
|
|
15
15
|
import { Writable } from "node:stream";
|
|
16
16
|
import { write } from "@kubb/core/fs";
|
|
17
|
+
import { createHash } from "node:crypto";
|
|
17
18
|
import { parseArgsStringToArgv } from "string-argv";
|
|
18
19
|
import { cosmiconfig } from "cosmiconfig";
|
|
19
20
|
import { createJiti } from "jiti";
|
|
@@ -120,6 +121,21 @@ const clackLogger = defineLogger({
|
|
|
120
121
|
isSpinning: false,
|
|
121
122
|
activeProgress: /* @__PURE__ */ new Map()
|
|
122
123
|
};
|
|
124
|
+
function reset() {
|
|
125
|
+
for (const [_key, active] of state.activeProgress) {
|
|
126
|
+
if (active.interval) clearInterval(active.interval);
|
|
127
|
+
active.progressBar?.stop();
|
|
128
|
+
}
|
|
129
|
+
state.totalPlugins = 0;
|
|
130
|
+
state.completedPlugins = 0;
|
|
131
|
+
state.failedPlugins = 0;
|
|
132
|
+
state.totalFiles = 0;
|
|
133
|
+
state.processedFiles = 0;
|
|
134
|
+
state.hrStart = process$1.hrtime();
|
|
135
|
+
state.spinner = clack.spinner();
|
|
136
|
+
state.isSpinning = false;
|
|
137
|
+
state.activeProgress.clear();
|
|
138
|
+
}
|
|
123
139
|
function showProgressStep() {
|
|
124
140
|
if (logLevel <= LogLevel.silent) return;
|
|
125
141
|
const parts = [];
|
|
@@ -130,8 +146,8 @@ const clackLogger = defineLogger({
|
|
|
130
146
|
}
|
|
131
147
|
if (state.totalFiles > 0) parts.push(`Files ${pc.green(state.processedFiles.toString())}/${state.totalFiles}`);
|
|
132
148
|
if (parts.length > 0) {
|
|
133
|
-
parts.push(pc.green(duration));
|
|
134
|
-
clack.log.step(parts.join(pc.dim(" | ")));
|
|
149
|
+
parts.push(`${pc.green(duration)} elapsed`);
|
|
150
|
+
clack.log.step(getMessage(parts.join(pc.dim(" | "))));
|
|
135
151
|
}
|
|
136
152
|
}
|
|
137
153
|
function getMessage(message) {
|
|
@@ -216,6 +232,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
216
232
|
"#F5A217",
|
|
217
233
|
"#F55A17"
|
|
218
234
|
])(`Kubb ${version$1} 🧩`));
|
|
235
|
+
reset();
|
|
219
236
|
});
|
|
220
237
|
context.on("config:start", () => {
|
|
221
238
|
if (logLevel <= LogLevel.silent) return;
|
|
@@ -230,11 +247,9 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
230
247
|
});
|
|
231
248
|
context.on("generation:start", (config) => {
|
|
232
249
|
state.totalPlugins = config.plugins?.length || 0;
|
|
233
|
-
state.completedPlugins = 0;
|
|
234
|
-
state.failedPlugins = 0;
|
|
235
|
-
state.hrStart = process$1.hrtime();
|
|
236
250
|
const text = getMessage(["Generation started", config.name ? `for ${pc.dim(config.name)}` : void 0].filter(Boolean).join(" "));
|
|
237
251
|
clack.intro(text);
|
|
252
|
+
reset();
|
|
238
253
|
});
|
|
239
254
|
context.on("plugin:start", (plugin) => {
|
|
240
255
|
if (logLevel <= LogLevel.silent) return;
|
|
@@ -248,7 +263,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
248
263
|
progressBar.start(text);
|
|
249
264
|
const interval = setInterval(() => {
|
|
250
265
|
progressBar.advance();
|
|
251
|
-
},
|
|
266
|
+
}, 100);
|
|
252
267
|
state.activeProgress.set(plugin.name, {
|
|
253
268
|
progressBar,
|
|
254
269
|
interval
|
|
@@ -305,7 +320,28 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
305
320
|
const text = getMessage(config.name ? `Generation completed for ${pc.dim(config.name)}` : "Generation completed");
|
|
306
321
|
clack.outro(text);
|
|
307
322
|
});
|
|
308
|
-
context.on("
|
|
323
|
+
context.on("format:start", () => {
|
|
324
|
+
if (logLevel <= LogLevel.silent) return;
|
|
325
|
+
const text = getMessage("Format started");
|
|
326
|
+
clack.intro(text);
|
|
327
|
+
});
|
|
328
|
+
context.on("format:end", () => {
|
|
329
|
+
if (logLevel <= LogLevel.silent) return;
|
|
330
|
+
const text = getMessage("Format completed");
|
|
331
|
+
clack.outro(text);
|
|
332
|
+
});
|
|
333
|
+
context.on("lint:start", () => {
|
|
334
|
+
if (logLevel <= LogLevel.silent) return;
|
|
335
|
+
const text = getMessage("Lint started");
|
|
336
|
+
clack.intro(text);
|
|
337
|
+
});
|
|
338
|
+
context.on("lint:end", () => {
|
|
339
|
+
if (logLevel <= LogLevel.silent) return;
|
|
340
|
+
const text = getMessage("Lint completed");
|
|
341
|
+
clack.outro(text);
|
|
342
|
+
});
|
|
343
|
+
context.on("hook:start", async ({ id, command: command$1, args }) => {
|
|
344
|
+
const text = getMessage(`Hook ${pc.dim(command$1)} started`);
|
|
309
345
|
if (logLevel <= LogLevel.silent) {
|
|
310
346
|
try {
|
|
311
347
|
const result = await execa(command$1, args, {
|
|
@@ -316,7 +352,10 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
316
352
|
date: /* @__PURE__ */ new Date(),
|
|
317
353
|
logs: [result.stdout]
|
|
318
354
|
});
|
|
319
|
-
|
|
355
|
+
await context.emit("hook:end", {
|
|
356
|
+
command: command$1,
|
|
357
|
+
id
|
|
358
|
+
});
|
|
320
359
|
} catch (err) {
|
|
321
360
|
const error = /* @__PURE__ */ new Error("Hook execute failed");
|
|
322
361
|
error.cause = err;
|
|
@@ -328,6 +367,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
328
367
|
}
|
|
329
368
|
return;
|
|
330
369
|
}
|
|
370
|
+
clack.intro(text);
|
|
331
371
|
const writable = new ClackWritable(clack.taskLog({ title: getMessage(["Executing hook", logLevel >= LogLevel.info ? pc.dim(`${command$1} ${args?.join(" ")}`) : void 0].filter(Boolean).join(" ")) }));
|
|
332
372
|
try {
|
|
333
373
|
const result = await execa(command$1, args, {
|
|
@@ -339,7 +379,10 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
339
379
|
date: /* @__PURE__ */ new Date(),
|
|
340
380
|
logs: [result.stdout]
|
|
341
381
|
});
|
|
342
|
-
|
|
382
|
+
await context.emit("hook:end", {
|
|
383
|
+
command: command$1,
|
|
384
|
+
id
|
|
385
|
+
});
|
|
343
386
|
} catch (err) {
|
|
344
387
|
const error = /* @__PURE__ */ new Error("Hook execute failed");
|
|
345
388
|
error.cause = err;
|
|
@@ -350,34 +393,9 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
350
393
|
await context.emit("error", error);
|
|
351
394
|
}
|
|
352
395
|
});
|
|
353
|
-
context.on("
|
|
354
|
-
if (logLevel <= LogLevel.silent) return;
|
|
355
|
-
const text = getMessage("Format started");
|
|
356
|
-
clack.intro(text);
|
|
357
|
-
});
|
|
358
|
-
context.on("format:end", () => {
|
|
396
|
+
context.on("hook:end", ({ command: command$1 }) => {
|
|
359
397
|
if (logLevel <= LogLevel.silent) return;
|
|
360
|
-
const text = getMessage(
|
|
361
|
-
clack.outro(text);
|
|
362
|
-
});
|
|
363
|
-
context.on("lint:start", () => {
|
|
364
|
-
if (logLevel <= LogLevel.silent) return;
|
|
365
|
-
const text = getMessage("Lint started");
|
|
366
|
-
clack.intro(text);
|
|
367
|
-
});
|
|
368
|
-
context.on("lint:end", () => {
|
|
369
|
-
if (logLevel <= LogLevel.silent) return;
|
|
370
|
-
const text = getMessage("Lint completed");
|
|
371
|
-
clack.outro(text);
|
|
372
|
-
});
|
|
373
|
-
context.on("hook:start", (command$1) => {
|
|
374
|
-
if (logLevel <= LogLevel.silent) return;
|
|
375
|
-
const text = getMessage(`Hook ${pc.dim(command$1)} started`);
|
|
376
|
-
clack.intro(text);
|
|
377
|
-
});
|
|
378
|
-
context.on("hook:end", (command$1) => {
|
|
379
|
-
if (logLevel <= LogLevel.silent) return;
|
|
380
|
-
const text = getMessage(`Hook ${pc.dim(command$1)} completed`);
|
|
398
|
+
const text = getMessage(`Hook ${pc.dim(command$1)} successfully executed`);
|
|
381
399
|
clack.outro(text);
|
|
382
400
|
});
|
|
383
401
|
context.on("generation:summary", (config, { pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
|
|
@@ -413,11 +431,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
413
431
|
});
|
|
414
432
|
});
|
|
415
433
|
context.on("lifecycle:end", () => {
|
|
416
|
-
|
|
417
|
-
if (active.interval) clearInterval(active.interval);
|
|
418
|
-
active.progressBar?.stop();
|
|
419
|
-
}
|
|
420
|
-
state.activeProgress.clear();
|
|
434
|
+
reset();
|
|
421
435
|
});
|
|
422
436
|
}
|
|
423
437
|
});
|
|
@@ -455,36 +469,97 @@ function canUseTTY() {
|
|
|
455
469
|
const fileSystemLogger = defineLogger({
|
|
456
470
|
name: "filesystem",
|
|
457
471
|
install(context) {
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
472
|
+
const state = {
|
|
473
|
+
cachedLogs: /* @__PURE__ */ new Set(),
|
|
474
|
+
startDate: Date.now()
|
|
475
|
+
};
|
|
476
|
+
function reset() {
|
|
477
|
+
state.cachedLogs = /* @__PURE__ */ new Set();
|
|
478
|
+
state.startDate = Date.now();
|
|
479
|
+
}
|
|
480
|
+
async function writeLogs(name) {
|
|
481
|
+
if (state.cachedLogs.size === 0) return;
|
|
462
482
|
const files = {};
|
|
463
|
-
for (const log of cachedLogs) {
|
|
464
|
-
const
|
|
465
|
-
|
|
483
|
+
for (const log of state.cachedLogs) {
|
|
484
|
+
const baseName = log.fileName || `${[
|
|
485
|
+
"kubb",
|
|
486
|
+
name,
|
|
487
|
+
state.startDate
|
|
488
|
+
].filter(Boolean).join("-")}.log`;
|
|
489
|
+
const pathName = resolve(process.cwd(), ".kubb", baseName);
|
|
490
|
+
if (!files[pathName]) files[pathName] = [];
|
|
466
491
|
if (log.logs.length > 0) {
|
|
467
492
|
const timestamp = log.date.toLocaleString();
|
|
468
|
-
files[
|
|
493
|
+
files[pathName].push(`[${timestamp}]\n${log.logs.join("\n")}`);
|
|
469
494
|
}
|
|
470
495
|
}
|
|
471
496
|
await Promise.all(Object.entries(files).map(async ([fileName, logs]) => {
|
|
472
497
|
return write(fileName, logs.join("\n\n"));
|
|
473
498
|
}));
|
|
474
|
-
cachedLogs.clear();
|
|
475
499
|
}
|
|
500
|
+
context.on("info", (message, info) => {
|
|
501
|
+
state.cachedLogs.add({
|
|
502
|
+
date: /* @__PURE__ */ new Date(),
|
|
503
|
+
logs: [`ℹ ${message} ${info}`],
|
|
504
|
+
fileName: void 0
|
|
505
|
+
});
|
|
506
|
+
});
|
|
507
|
+
context.on("success", (message, info) => {
|
|
508
|
+
state.cachedLogs.add({
|
|
509
|
+
date: /* @__PURE__ */ new Date(),
|
|
510
|
+
logs: [`✓ ${message} ${info}`],
|
|
511
|
+
fileName: void 0
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
context.on("warn", (message, info) => {
|
|
515
|
+
state.cachedLogs.add({
|
|
516
|
+
date: /* @__PURE__ */ new Date(),
|
|
517
|
+
logs: [`⚠ ${message} ${info}`],
|
|
518
|
+
fileName: void 0
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
context.on("error", (error) => {
|
|
522
|
+
state.cachedLogs.add({
|
|
523
|
+
date: /* @__PURE__ */ new Date(),
|
|
524
|
+
logs: [`✗ ${error.message}`, error.stack || "unknown stack"],
|
|
525
|
+
fileName: void 0
|
|
526
|
+
});
|
|
527
|
+
});
|
|
476
528
|
context.on("debug", (message) => {
|
|
477
|
-
cachedLogs.add({
|
|
529
|
+
state.cachedLogs.add({
|
|
478
530
|
date: /* @__PURE__ */ new Date(),
|
|
479
531
|
logs: message.logs,
|
|
480
532
|
fileName: void 0
|
|
481
533
|
});
|
|
482
534
|
});
|
|
483
|
-
context.on("
|
|
484
|
-
|
|
535
|
+
context.on("plugin:start", (plugin) => {
|
|
536
|
+
state.cachedLogs.add({
|
|
537
|
+
date: /* @__PURE__ */ new Date(),
|
|
538
|
+
logs: [`Generating ${plugin.name}`],
|
|
539
|
+
fileName: void 0
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
context.on("plugin:end", (plugin, { duration, success }) => {
|
|
543
|
+
const durationStr = formatMs(duration);
|
|
544
|
+
state.cachedLogs.add({
|
|
545
|
+
date: /* @__PURE__ */ new Date(),
|
|
546
|
+
logs: [success ? `${plugin.name} completed in ${durationStr}` : `${plugin.name} failed in ${durationStr}`],
|
|
547
|
+
fileName: void 0
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
context.on("files:processing:start", (files) => {
|
|
551
|
+
state.cachedLogs.add({
|
|
552
|
+
date: /* @__PURE__ */ new Date(),
|
|
553
|
+
logs: [`Start ${files.length} writing:`, ...files.map((file) => file.path)],
|
|
554
|
+
fileName: void 0
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
context.on("generation:end", async (config) => {
|
|
558
|
+
await writeLogs(config.name);
|
|
559
|
+
reset();
|
|
485
560
|
});
|
|
486
561
|
const exitHandler = () => {
|
|
487
|
-
if (cachedLogs.size > 0) writeLogs().catch(() => {});
|
|
562
|
+
if (state.cachedLogs.size > 0) writeLogs().catch(() => {});
|
|
488
563
|
};
|
|
489
564
|
process.once("exit", exitHandler);
|
|
490
565
|
process.once("SIGINT", exitHandler);
|
|
@@ -511,6 +586,14 @@ const githubActionsLogger = defineLogger({
|
|
|
511
586
|
hrStart: process.hrtime(),
|
|
512
587
|
currentConfigs: []
|
|
513
588
|
};
|
|
589
|
+
function reset() {
|
|
590
|
+
state.totalPlugins = 0;
|
|
591
|
+
state.completedPlugins = 0;
|
|
592
|
+
state.failedPlugins = 0;
|
|
593
|
+
state.totalFiles = 0;
|
|
594
|
+
state.processedFiles = 0;
|
|
595
|
+
state.hrStart = process.hrtime();
|
|
596
|
+
}
|
|
514
597
|
function showProgressStep() {
|
|
515
598
|
if (logLevel <= LogLevel.silent) return;
|
|
516
599
|
const parts = [];
|
|
@@ -521,8 +604,8 @@ const githubActionsLogger = defineLogger({
|
|
|
521
604
|
}
|
|
522
605
|
if (state.totalFiles > 0) parts.push(`Files ${pc.green(state.processedFiles.toString())}/${state.totalFiles}`);
|
|
523
606
|
if (parts.length > 0) {
|
|
524
|
-
parts.push(pc.green(duration));
|
|
525
|
-
console.log(parts.join(pc.dim(" | ")));
|
|
607
|
+
parts.push(`${pc.green(duration)} elapsed`);
|
|
608
|
+
console.log(getMessage(parts.join(pc.dim(" | "))));
|
|
526
609
|
}
|
|
527
610
|
}
|
|
528
611
|
function getMessage(message) {
|
|
@@ -577,6 +660,7 @@ const githubActionsLogger = defineLogger({
|
|
|
577
660
|
});
|
|
578
661
|
context.on("lifecycle:start", (version$1) => {
|
|
579
662
|
console.log(pc.yellow(`Kubb ${version$1} 🧩`));
|
|
663
|
+
reset();
|
|
580
664
|
});
|
|
581
665
|
context.on("config:start", () => {
|
|
582
666
|
if (logLevel <= LogLevel.silent) return;
|
|
@@ -593,12 +677,10 @@ const githubActionsLogger = defineLogger({
|
|
|
593
677
|
});
|
|
594
678
|
context.on("generation:start", (config) => {
|
|
595
679
|
state.totalPlugins = config.plugins?.length || 0;
|
|
596
|
-
state.completedPlugins = 0;
|
|
597
|
-
state.failedPlugins = 0;
|
|
598
|
-
state.hrStart = process.hrtime();
|
|
599
680
|
const text = config.name ? `Generation for ${pc.bold(config.name)}` : "Generation";
|
|
600
681
|
if (state.currentConfigs.length > 1) openGroup(text);
|
|
601
682
|
if (state.currentConfigs.length === 1) console.log(getMessage(text));
|
|
683
|
+
reset();
|
|
602
684
|
});
|
|
603
685
|
context.on("plugin:start", (plugin) => {
|
|
604
686
|
if (logLevel <= LogLevel.silent) return;
|
|
@@ -643,28 +725,6 @@ const githubActionsLogger = defineLogger({
|
|
|
643
725
|
const text = getMessage(config.name ? `${pc.blue("✓")} Generation completed for ${pc.dim(config.name)}` : `${pc.blue("✓")} Generation completed`);
|
|
644
726
|
console.log(text);
|
|
645
727
|
});
|
|
646
|
-
context.on("hook:execute", async ({ command: command$1, args }, cb) => {
|
|
647
|
-
try {
|
|
648
|
-
const result = await execa(command$1, args, {
|
|
649
|
-
detached: true,
|
|
650
|
-
stripFinalNewline: true
|
|
651
|
-
});
|
|
652
|
-
await context.emit("debug", {
|
|
653
|
-
date: /* @__PURE__ */ new Date(),
|
|
654
|
-
logs: [result.stdout]
|
|
655
|
-
});
|
|
656
|
-
console.log(result.stdout);
|
|
657
|
-
cb();
|
|
658
|
-
} catch (err) {
|
|
659
|
-
const error = /* @__PURE__ */ new Error("Hook execute failed");
|
|
660
|
-
error.cause = err;
|
|
661
|
-
await context.emit("debug", {
|
|
662
|
-
date: /* @__PURE__ */ new Date(),
|
|
663
|
-
logs: [err.stdout]
|
|
664
|
-
});
|
|
665
|
-
await context.emit("error", error);
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
728
|
context.on("format:start", () => {
|
|
669
729
|
if (logLevel <= LogLevel.silent) return;
|
|
670
730
|
const text = getMessage("Format started");
|
|
@@ -689,23 +749,48 @@ const githubActionsLogger = defineLogger({
|
|
|
689
749
|
console.log(text);
|
|
690
750
|
if (state.currentConfigs.length === 1) closeGroup("Linting");
|
|
691
751
|
});
|
|
692
|
-
context.on("hook:start", (command$1) => {
|
|
693
|
-
if (logLevel <= LogLevel.silent) return;
|
|
752
|
+
context.on("hook:start", async ({ id, command: command$1, args }) => {
|
|
694
753
|
const text = getMessage(`Hook ${pc.dim(command$1)} started`);
|
|
695
|
-
if (
|
|
696
|
-
|
|
754
|
+
if (logLevel > LogLevel.silent) {
|
|
755
|
+
if (state.currentConfigs.length === 1) openGroup(`Hook ${command$1}`);
|
|
756
|
+
console.log(text);
|
|
757
|
+
}
|
|
758
|
+
try {
|
|
759
|
+
const result = await execa(command$1, args, {
|
|
760
|
+
detached: true,
|
|
761
|
+
stripFinalNewline: true
|
|
762
|
+
});
|
|
763
|
+
await context.emit("debug", {
|
|
764
|
+
date: /* @__PURE__ */ new Date(),
|
|
765
|
+
logs: [result.stdout]
|
|
766
|
+
});
|
|
767
|
+
console.log(result.stdout);
|
|
768
|
+
await context.emit("hook:end", {
|
|
769
|
+
command: command$1,
|
|
770
|
+
id
|
|
771
|
+
});
|
|
772
|
+
} catch (err) {
|
|
773
|
+
const error = /* @__PURE__ */ new Error("Hook execute failed");
|
|
774
|
+
error.cause = err;
|
|
775
|
+
await context.emit("debug", {
|
|
776
|
+
date: /* @__PURE__ */ new Date(),
|
|
777
|
+
logs: [err.stdout]
|
|
778
|
+
});
|
|
779
|
+
await context.emit("error", error);
|
|
780
|
+
}
|
|
697
781
|
});
|
|
698
|
-
context.on("hook:end", (command$1) => {
|
|
782
|
+
context.on("hook:end", ({ command: command$1 }) => {
|
|
699
783
|
if (logLevel <= LogLevel.silent) return;
|
|
700
784
|
const text = getMessage(`Hook ${pc.dim(command$1)} completed`);
|
|
701
785
|
console.log(text);
|
|
702
786
|
if (state.currentConfigs.length === 1) closeGroup(`Hook ${command$1}`);
|
|
703
787
|
});
|
|
704
|
-
context.on("generation:summary", (config, { status, failedPlugins }) => {
|
|
788
|
+
context.on("generation:summary", (config, { status, hrStart, failedPlugins }) => {
|
|
705
789
|
const pluginsCount = config.plugins?.length || 0;
|
|
706
790
|
const successCount = pluginsCount - failedPlugins.size;
|
|
791
|
+
const duration = formatHrtime(hrStart);
|
|
707
792
|
if (state.currentConfigs.length > 1) console.log(" ");
|
|
708
|
-
console.log(status === "success" ? `Kubb Summary: ${pc.blue("✓")} ${`${successCount} successful`}, ${pluginsCount} total` : `Kubb Summary: ${pc.blue("✓")} ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`);
|
|
793
|
+
console.log(status === "success" ? `Kubb Summary: ${pc.blue("✓")} ${`${successCount} successful`}, ${pluginsCount} total, ${pc.green(duration)}` : `Kubb Summary: ${pc.blue("✓")} ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total, ${pc.green(duration)}`);
|
|
709
794
|
if (state.currentConfigs.length > 1) closeGroup(config.name ? `Generation for ${pc.bold(config.name)}` : "Generation");
|
|
710
795
|
});
|
|
711
796
|
}
|
|
@@ -818,28 +903,6 @@ const plainLogger = defineLogger({
|
|
|
818
903
|
const text = getMessage(config.name ? `Generation completed for ${config.name}` : "Generation completed");
|
|
819
904
|
console.log(text);
|
|
820
905
|
});
|
|
821
|
-
context.on("hook:execute", async ({ command: command$1, args }, cb) => {
|
|
822
|
-
try {
|
|
823
|
-
const result = await execa(command$1, args, {
|
|
824
|
-
detached: true,
|
|
825
|
-
stripFinalNewline: true
|
|
826
|
-
});
|
|
827
|
-
await context.emit("debug", {
|
|
828
|
-
date: /* @__PURE__ */ new Date(),
|
|
829
|
-
logs: [result.stdout]
|
|
830
|
-
});
|
|
831
|
-
console.log(result.stdout);
|
|
832
|
-
cb();
|
|
833
|
-
} catch (err) {
|
|
834
|
-
const error = /* @__PURE__ */ new Error("Hook execute failed");
|
|
835
|
-
error.cause = err;
|
|
836
|
-
await context.emit("debug", {
|
|
837
|
-
date: /* @__PURE__ */ new Date(),
|
|
838
|
-
logs: [err.stdout]
|
|
839
|
-
});
|
|
840
|
-
await context.emit("error", error);
|
|
841
|
-
}
|
|
842
|
-
});
|
|
843
906
|
context.on("format:start", () => {
|
|
844
907
|
if (logLevel <= LogLevel.silent) return;
|
|
845
908
|
const text = getMessage("Format started");
|
|
@@ -860,10 +923,32 @@ const plainLogger = defineLogger({
|
|
|
860
923
|
const text = getMessage("Lint completed");
|
|
861
924
|
console.log(text);
|
|
862
925
|
});
|
|
863
|
-
context.on("hook:start", (command$1) => {
|
|
864
|
-
if (logLevel <= LogLevel.silent) return;
|
|
926
|
+
context.on("hook:start", async ({ id, command: command$1, args }) => {
|
|
865
927
|
const text = getMessage(`Hook ${command$1} started`);
|
|
866
|
-
console.log(text);
|
|
928
|
+
if (logLevel > LogLevel.silent) console.log(text);
|
|
929
|
+
try {
|
|
930
|
+
const result = await execa(command$1, args, {
|
|
931
|
+
detached: true,
|
|
932
|
+
stripFinalNewline: true
|
|
933
|
+
});
|
|
934
|
+
await context.emit("debug", {
|
|
935
|
+
date: /* @__PURE__ */ new Date(),
|
|
936
|
+
logs: [result.stdout]
|
|
937
|
+
});
|
|
938
|
+
console.log(result.stdout);
|
|
939
|
+
await context.emit("hook:end", {
|
|
940
|
+
command: command$1,
|
|
941
|
+
id
|
|
942
|
+
});
|
|
943
|
+
} catch (err) {
|
|
944
|
+
const error = /* @__PURE__ */ new Error("Hook execute failed");
|
|
945
|
+
error.cause = err;
|
|
946
|
+
await context.emit("debug", {
|
|
947
|
+
date: /* @__PURE__ */ new Date(),
|
|
948
|
+
logs: [err.stdout]
|
|
949
|
+
});
|
|
950
|
+
await context.emit("error", error);
|
|
951
|
+
}
|
|
867
952
|
});
|
|
868
953
|
context.on("hook:end", (command$1) => {
|
|
869
954
|
if (logLevel <= LogLevel.silent) return;
|
|
@@ -914,13 +999,14 @@ async function executeHooks({ hooks, events }) {
|
|
|
914
999
|
for (const command$1 of commands) {
|
|
915
1000
|
const [cmd, ...args] = [...parseArgsStringToArgv(command$1)];
|
|
916
1001
|
if (!cmd) continue;
|
|
917
|
-
|
|
918
|
-
await events.emit("hook:
|
|
1002
|
+
const hookId = createHash("sha256").update(command$1).digest("hex");
|
|
1003
|
+
await events.emit("hook:start", {
|
|
1004
|
+
id: hookId,
|
|
919
1005
|
command: cmd,
|
|
920
1006
|
args
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
await events.emit("
|
|
1007
|
+
});
|
|
1008
|
+
await events.on("hook:end", async ({ id }) => {
|
|
1009
|
+
if (id === hookId) await events.emit("success", `${pc.dim(command$1)} successfully executed`);
|
|
924
1010
|
});
|
|
925
1011
|
}
|
|
926
1012
|
}
|
|
@@ -983,15 +1069,18 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
983
1069
|
await events.emit("info", [`Formatting with ${pc.dim(config.output.format)}`, logLevel >= LogLevel.info ? `on ${pc.dim(path.resolve(definedConfig.root, definedConfig.output.path))}` : void 0].filter(Boolean).join(" "));
|
|
984
1070
|
if (config.output.format === "prettier") {
|
|
985
1071
|
try {
|
|
986
|
-
|
|
1072
|
+
const hookId = createHash("sha256").update(config.output.format).digest("hex");
|
|
1073
|
+
await events.emit("hook:start", {
|
|
1074
|
+
id: hookId,
|
|
987
1075
|
command: "prettier",
|
|
988
1076
|
args: [
|
|
989
1077
|
"--ignore-unknown",
|
|
990
1078
|
"--write",
|
|
991
1079
|
path.resolve(definedConfig.root, definedConfig.output.path)
|
|
992
1080
|
]
|
|
993
|
-
}
|
|
994
|
-
|
|
1081
|
+
});
|
|
1082
|
+
await events.on("hook:end", async ({ id }) => {
|
|
1083
|
+
if (id === hookId) await events.emit("success", [
|
|
995
1084
|
`Formatting with ${pc.dim(config.output.format)}`,
|
|
996
1085
|
logLevel >= LogLevel.info ? `on ${pc.dim(path.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
|
|
997
1086
|
"successfully"
|
|
@@ -1003,15 +1092,18 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
1003
1092
|
await events.emit("success", `Formatted with ${config.output.format}`);
|
|
1004
1093
|
}
|
|
1005
1094
|
if (config.output.format === "biome") try {
|
|
1006
|
-
|
|
1095
|
+
const hookId = createHash("sha256").update(config.output.format).digest("hex");
|
|
1096
|
+
await events.emit("hook:start", {
|
|
1097
|
+
id: hookId,
|
|
1007
1098
|
command: "biome",
|
|
1008
1099
|
args: [
|
|
1009
1100
|
"format",
|
|
1010
1101
|
"--write",
|
|
1011
1102
|
path.resolve(definedConfig.root, definedConfig.output.path)
|
|
1012
1103
|
]
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1104
|
+
});
|
|
1105
|
+
await events.on("hook:end", async ({ id }) => {
|
|
1106
|
+
if (id === hookId) await events.emit("success", [
|
|
1015
1107
|
`Formatting with ${pc.dim(config.output.format)}`,
|
|
1016
1108
|
logLevel >= LogLevel.info ? `on ${pc.dim(path.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
|
|
1017
1109
|
"successfully"
|
|
@@ -1028,11 +1120,14 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
1028
1120
|
await events.emit("lint:start");
|
|
1029
1121
|
await events.emit("info", [`Linting with ${pc.dim(config.output.lint)}`, logLevel >= LogLevel.info ? `on ${pc.dim(path.resolve(definedConfig.root, definedConfig.output.path))}` : void 0].filter(Boolean).join(" "));
|
|
1030
1122
|
if (config.output.lint === "eslint") try {
|
|
1031
|
-
|
|
1123
|
+
const hookId = createHash("sha256").update(config.output.lint).digest("hex");
|
|
1124
|
+
await events.emit("hook:start", {
|
|
1125
|
+
id: hookId,
|
|
1032
1126
|
command: "eslint",
|
|
1033
1127
|
args: [path.resolve(definedConfig.root, definedConfig.output.path), "--fix"]
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1128
|
+
});
|
|
1129
|
+
await events.on("hook:end", async ({ id }) => {
|
|
1130
|
+
if (id === hookId) await events.emit("success", [
|
|
1036
1131
|
`Linted with ${pc.dim(config.output.lint)}`,
|
|
1037
1132
|
logLevel >= LogLevel.info ? `on ${pc.dim(path.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
|
|
1038
1133
|
"successfully"
|
|
@@ -1044,15 +1139,18 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
1044
1139
|
await events.emit("error", error$1);
|
|
1045
1140
|
}
|
|
1046
1141
|
if (config.output.lint === "biome") try {
|
|
1047
|
-
|
|
1142
|
+
const hookId = createHash("sha256").update(config.output.lint).digest("hex");
|
|
1143
|
+
await events.emit("hook:start", {
|
|
1144
|
+
id: hookId,
|
|
1048
1145
|
command: "biome",
|
|
1049
1146
|
args: [
|
|
1050
1147
|
"lint",
|
|
1051
1148
|
"--fix",
|
|
1052
1149
|
path.resolve(definedConfig.root, definedConfig.output.path)
|
|
1053
1150
|
]
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1151
|
+
});
|
|
1152
|
+
await events.on("hook:end", async ({ id }) => {
|
|
1153
|
+
if (id === hookId) await events.emit("success", [
|
|
1056
1154
|
`Linted with ${pc.dim(config.output.lint)}`,
|
|
1057
1155
|
logLevel >= LogLevel.info ? `on ${pc.dim(path.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
|
|
1058
1156
|
"successfully"
|
|
@@ -1064,11 +1162,14 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
1064
1162
|
await events.emit("error", error$1);
|
|
1065
1163
|
}
|
|
1066
1164
|
if (config.output.lint === "oxlint") try {
|
|
1067
|
-
|
|
1165
|
+
const hookId = createHash("sha256").update(config.output.lint).digest("hex");
|
|
1166
|
+
await events.emit("hook:start", {
|
|
1167
|
+
id: hookId,
|
|
1068
1168
|
command: "oxlint",
|
|
1069
1169
|
args: ["--fix", path.resolve(definedConfig.root, definedConfig.output.path)]
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1170
|
+
});
|
|
1171
|
+
await events.on("hook:end", async ({ id }) => {
|
|
1172
|
+
if (id === hookId) await events.emit("success", [
|
|
1072
1173
|
`Linted with ${pc.dim(config.output.lint)}`,
|
|
1073
1174
|
logLevel >= LogLevel.info ? `on ${pc.dim(path.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
|
|
1074
1175
|
"successfully"
|
|
@@ -1251,6 +1352,12 @@ const command = defineCommand({
|
|
|
1251
1352
|
alias: "v",
|
|
1252
1353
|
default: false
|
|
1253
1354
|
},
|
|
1355
|
+
silent: {
|
|
1356
|
+
type: "boolean",
|
|
1357
|
+
description: "Override logLevel to silent",
|
|
1358
|
+
alias: "s",
|
|
1359
|
+
default: false
|
|
1360
|
+
},
|
|
1254
1361
|
help: {
|
|
1255
1362
|
type: "boolean",
|
|
1256
1363
|
description: "Show help",
|
|
@@ -1266,6 +1373,7 @@ const command = defineCommand({
|
|
|
1266
1373
|
if (args.help) return showUsage(command);
|
|
1267
1374
|
if (args.debug) args.logLevel = "debug";
|
|
1268
1375
|
if (args.verbose) args.logLevel = "verbose";
|
|
1376
|
+
if (args.silent) args.logLevel = "silent";
|
|
1269
1377
|
const logLevel = LogLevel[args.logLevel] || 3;
|
|
1270
1378
|
await setupLogger(events, { logLevel });
|
|
1271
1379
|
const latestVersion = await getLatestVersion("@kubb/cli");
|
|
@@ -1312,4 +1420,4 @@ var generate_default = command;
|
|
|
1312
1420
|
|
|
1313
1421
|
//#endregion
|
|
1314
1422
|
export { generate_default as default };
|
|
1315
|
-
//# sourceMappingURL=generate
|
|
1423
|
+
//# sourceMappingURL=generate-DbvDQY54.js.map
|