@kubb/cli 4.28.1 → 4.29.1
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/{agent-DrV6PuuK.js → agent-BzD6f3mV.js} +4 -5
- package/dist/{agent-DrV6PuuK.js.map → agent-BzD6f3mV.js.map} +1 -1
- package/dist/{agent-BHBMSAC7.cjs → agent-NAhMf2ot.cjs} +4 -5
- package/dist/{agent-BHBMSAC7.cjs.map → agent-NAhMf2ot.cjs.map} +1 -1
- package/dist/{chunk-C1_xRkKa.cjs → chunk-CNbaEX1y.cjs} +1 -1
- package/dist/{chunk-jHaXqnEa.js → chunk-DKWOrOAv.js} +1 -1
- package/dist/{generate-CQudcsre.js → generate-CGEE6Etf.js} +192 -185
- package/dist/generate-CGEE6Etf.js.map +1 -0
- package/dist/{generate-B8XICi_S.cjs → generate-b2shdOTg.cjs} +191 -188
- package/dist/generate-b2shdOTg.cjs.map +1 -0
- package/dist/index.cjs +9 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/{init-Byzguonv.js → init-CPrROO67.js} +22 -23
- package/dist/init-CPrROO67.js.map +1 -0
- package/dist/{init-CRG4HVMq.cjs → init-CaoLbJ4R.cjs} +22 -24
- package/dist/init-CaoLbJ4R.cjs.map +1 -0
- package/dist/{mcp-DGyip5BX.cjs → mcp-97TXkJVX.cjs} +5 -7
- package/dist/mcp-97TXkJVX.cjs.map +1 -0
- package/dist/{mcp-C-e4yatL.js → mcp-Jboea6xH.js} +5 -6
- package/dist/mcp-Jboea6xH.js.map +1 -0
- package/dist/package-1sFkRYXi.js +6 -0
- package/dist/package-1sFkRYXi.js.map +1 -0
- package/dist/{package-DIc1GFdF.cjs → package-DPA0iPrU.cjs} +2 -2
- package/dist/package-DPA0iPrU.cjs.map +1 -0
- package/dist/{start-jaV7_Xss.js → start-CYuU23PX.js} +27 -24
- package/dist/start-CYuU23PX.js.map +1 -0
- package/dist/{start-DqKYNdp1.cjs → start-lrn1-P52.cjs} +27 -25
- package/dist/start-lrn1-P52.cjs.map +1 -0
- package/dist/{validate-Cvb5aOEb.cjs → validate-BgYhe_55.cjs} +3 -4
- package/dist/{validate-Cvb5aOEb.cjs.map → validate-BgYhe_55.cjs.map} +1 -1
- package/dist/{validate-YI4YkVTl.js → validate-DOeZKiGx.js} +3 -4
- package/dist/{validate-YI4YkVTl.js.map → validate-DOeZKiGx.js.map} +1 -1
- package/package.json +12 -21
- package/src/commands/agent/start.ts +17 -16
- package/src/commands/generate.ts +14 -7
- package/src/commands/init.ts +14 -14
- package/src/commands/mcp.ts +2 -2
- package/src/loggers/clackLogger.ts +49 -40
- package/src/loggers/githubActionsLogger.ts +36 -32
- package/src/loggers/plainLogger.ts +9 -9
- package/src/runners/generate.ts +9 -7
- package/src/utils/Writables.ts +2 -2
- package/src/utils/executeHooks.ts +4 -5
- package/src/utils/formatMsWithColor.ts +4 -4
- package/src/utils/getIntro.ts +52 -6
- package/src/utils/getSummary.ts +6 -6
- package/src/utils/packageManager.ts +3 -9
- package/src/utils/randomColor.ts +5 -6
- package/src/utils/watcher.ts +3 -3
- package/dist/generate-B8XICi_S.cjs.map +0 -1
- package/dist/generate-CQudcsre.js.map +0 -1
- package/dist/index.d.cts +0 -6
- package/dist/init-Byzguonv.js.map +0 -1
- package/dist/init-CRG4HVMq.cjs.map +0 -1
- package/dist/mcp-C-e4yatL.js.map +0 -1
- package/dist/mcp-DGyip5BX.cjs.map +0 -1
- package/dist/package-DIc1GFdF.cjs.map +0 -1
- package/dist/package-G_AvcVgZ.js +0 -6
- package/dist/package-G_AvcVgZ.js.map +0 -1
- package/dist/start-DqKYNdp1.cjs.map +0 -1
- package/dist/start-jaV7_Xss.js.map +0 -1
- package/src/utils/ansiColors.ts +0 -23
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-
|
|
2
|
-
const require_package = require('./package-
|
|
1
|
+
const require_chunk = require('./chunk-CNbaEX1y.cjs');
|
|
2
|
+
const require_package = require('./package-DPA0iPrU.cjs');
|
|
3
3
|
let citty = require("citty");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_chunk.__toESM(node_path);
|
|
6
6
|
let node_process = require("node:process");
|
|
7
7
|
node_process = require_chunk.__toESM(node_process);
|
|
8
|
+
let node_util = require("node:util");
|
|
8
9
|
let _clack_prompts = require("@clack/prompts");
|
|
9
10
|
_clack_prompts = require_chunk.__toESM(_clack_prompts);
|
|
10
|
-
let execa = require("execa");
|
|
11
|
-
let picocolors = require("picocolors");
|
|
12
|
-
picocolors = require_chunk.__toESM(picocolors);
|
|
13
11
|
let _kubb_core = require("@kubb/core");
|
|
14
12
|
let _kubb_core_utils = require("@kubb/core/utils");
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
let semver = require("semver");
|
|
18
|
-
let gradient_string = require("gradient-string");
|
|
19
|
-
gradient_string = require_chunk.__toESM(gradient_string);
|
|
20
|
-
let seedrandom = require("seedrandom");
|
|
21
|
-
seedrandom = require_chunk.__toESM(seedrandom);
|
|
13
|
+
let tinyexec = require("tinyexec");
|
|
14
|
+
let node_crypto = require("node:crypto");
|
|
22
15
|
let node_stream = require("node:stream");
|
|
23
16
|
let _kubb_core_fs = require("@kubb/core/fs");
|
|
24
|
-
let node_crypto = require("node:crypto");
|
|
25
|
-
let string_argv = require("string-argv");
|
|
26
17
|
let cosmiconfig = require("cosmiconfig");
|
|
27
18
|
let jiti = require("jiti");
|
|
28
19
|
|
|
@@ -35,13 +26,13 @@ let jiti = require("jiti");
|
|
|
35
26
|
*/
|
|
36
27
|
function formatMsWithColor(ms) {
|
|
37
28
|
const formatted = (0, _kubb_core_utils.formatMs)(ms);
|
|
38
|
-
if (ms <= 500) return
|
|
39
|
-
if (ms <= 1e3) return
|
|
40
|
-
return
|
|
29
|
+
if (ms <= 500) return (0, node_util.styleText)("green", formatted);
|
|
30
|
+
if (ms <= 1e3) return (0, node_util.styleText)("yellow", formatted);
|
|
31
|
+
return (0, node_util.styleText)("red", formatted);
|
|
41
32
|
}
|
|
42
33
|
|
|
43
34
|
//#endregion
|
|
44
|
-
//#region src/utils/
|
|
35
|
+
//#region src/utils/getIntro.ts
|
|
45
36
|
/**
|
|
46
37
|
* ANSI True Color (24-bit) utilities for terminal output
|
|
47
38
|
* Supports hex color codes without external dependencies like chalk
|
|
@@ -61,9 +52,27 @@ function hex(color) {
|
|
|
61
52
|
const safeB = Number.isNaN(b) ? 255 : b;
|
|
62
53
|
return (text) => `\x1b[38;2;${safeR};${safeG};${safeB}m${text}\x1b[0m`;
|
|
63
54
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
function hexToRgb(color) {
|
|
56
|
+
const c = color.replace("#", "");
|
|
57
|
+
return {
|
|
58
|
+
r: Number.parseInt(c.slice(0, 2), 16),
|
|
59
|
+
g: Number.parseInt(c.slice(2, 4), 16),
|
|
60
|
+
b: Number.parseInt(c.slice(4, 6), 16)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function gradient(colors) {
|
|
64
|
+
return (text) => {
|
|
65
|
+
const chars = [...text];
|
|
66
|
+
return chars.map((char, i) => {
|
|
67
|
+
const t = chars.length <= 1 ? 0 : i / (chars.length - 1);
|
|
68
|
+
const seg = Math.min(Math.floor(t * (colors.length - 1)), colors.length - 2);
|
|
69
|
+
const lt = t * (colors.length - 1) - seg;
|
|
70
|
+
const from = hexToRgb(colors[seg]);
|
|
71
|
+
const to = hexToRgb(colors[seg + 1]);
|
|
72
|
+
return `\x1b[38;2;${Math.round(from.r + (to.r - from.r) * lt)};${Math.round(from.g + (to.g - from.g) * lt)};${Math.round(from.b + (to.b - from.b) * lt)}m${char}\x1b[0m`;
|
|
73
|
+
}).join("");
|
|
74
|
+
};
|
|
75
|
+
}
|
|
67
76
|
const colors = {
|
|
68
77
|
lid: hex("#F55A17"),
|
|
69
78
|
woodTop: hex("#F5A217"),
|
|
@@ -78,19 +87,19 @@ const colors = {
|
|
|
78
87
|
* @param version - The version string to display
|
|
79
88
|
* @returns Formatted mascot face string
|
|
80
89
|
*/
|
|
81
|
-
function getIntro({ title, description, version
|
|
82
|
-
const kubbVersion = (
|
|
90
|
+
function getIntro({ title, description, version, areEyesOpen }) {
|
|
91
|
+
const kubbVersion = gradient([
|
|
83
92
|
"#F58517",
|
|
84
93
|
"#F5A217",
|
|
85
94
|
"#F55A17"
|
|
86
|
-
])(`KUBB v${version
|
|
95
|
+
])(`KUBB v${version}`);
|
|
87
96
|
const eyeTop = areEyesOpen ? colors.eye("█▀█") : colors.eye("───");
|
|
88
97
|
const eyeBottom = areEyesOpen ? colors.eye("▀▀▀") : colors.eye("───");
|
|
89
98
|
return `
|
|
90
99
|
${colors.lid("▄▄▄▄▄▄▄▄▄▄▄▄▄")}
|
|
91
100
|
${colors.woodTop("█ ")}${colors.highlight("▄▄")}${colors.woodTop(" ")}${colors.highlight("▄▄")}${colors.woodTop(" █")} ${kubbVersion}
|
|
92
|
-
${colors.woodMid("█ ")}${eyeTop}${colors.woodMid(" ")}${eyeTop}${colors.woodMid(" █")} ${
|
|
93
|
-
${colors.woodMid("█ ")}${eyeBottom}${colors.woodMid(" ")}${colors.blush("◡")}${colors.woodMid(" ")}${eyeBottom}${colors.woodMid(" █")} ${
|
|
101
|
+
${colors.woodMid("█ ")}${eyeTop}${colors.woodMid(" ")}${eyeTop}${colors.woodMid(" █")} ${(0, node_util.styleText)("gray", title)}
|
|
102
|
+
${colors.woodMid("█ ")}${eyeBottom}${colors.woodMid(" ")}${colors.blush("◡")}${colors.woodMid(" ")}${eyeBottom}${colors.woodMid(" █")} ${(0, node_util.styleText)("yellow", "➜")} ${(0, node_util.styleText)("white", description)}
|
|
94
103
|
${colors.woodBase("▀▀▀▀▀▀▀▀▀▀▀▀▀")}
|
|
95
104
|
`;
|
|
96
105
|
}
|
|
@@ -111,13 +120,11 @@ function randomColor(text) {
|
|
|
111
120
|
"cyan",
|
|
112
121
|
"gray"
|
|
113
122
|
];
|
|
114
|
-
|
|
115
|
-
return defaultColors.at(Math.floor(random() * defaultColors.length)) || "white";
|
|
123
|
+
return defaultColors[(0, node_crypto.createHash)("sha256").update(text).digest().readUInt32BE(0) % defaultColors.length] ?? "white";
|
|
116
124
|
}
|
|
117
125
|
function randomCliColor(text) {
|
|
118
126
|
if (!text) return "";
|
|
119
|
-
|
|
120
|
-
return fn ? fn(text) : text;
|
|
127
|
+
return (0, node_util.styleText)(randomColor(text), text);
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
//#endregion
|
|
@@ -127,10 +134,10 @@ function getSummary({ failedPlugins, filesCreated, status, hrStart, config, plug
|
|
|
127
134
|
const pluginsCount = config.plugins?.length || 0;
|
|
128
135
|
const successCount = pluginsCount - failedPlugins.size;
|
|
129
136
|
const meta = {
|
|
130
|
-
plugins: status === "success" ? `${
|
|
137
|
+
plugins: status === "success" ? `${(0, node_util.styleText)("green", `${successCount} successful`)}, ${pluginsCount} total` : `${(0, node_util.styleText)("green", `${successCount} successful`)}, ${(0, node_util.styleText)("red", `${failedPlugins.size} failed`)}, ${pluginsCount} total`,
|
|
131
138
|
pluginsFailed: status === "failed" ? [...failedPlugins]?.map(({ plugin }) => randomCliColor(plugin.name))?.join(", ") : void 0,
|
|
132
139
|
filesCreated,
|
|
133
|
-
time:
|
|
140
|
+
time: (0, node_util.styleText)("green", duration),
|
|
134
141
|
output: node_path.default.isAbsolute(config.root) ? node_path.default.resolve(config.root, config.output.path) : config.root
|
|
135
142
|
};
|
|
136
143
|
const labels = {
|
|
@@ -154,8 +161,8 @@ function getSummary({ failedPlugins, filesCreated, status, hrStart, config, plug
|
|
|
154
161
|
sortedTimings.forEach(([name, time]) => {
|
|
155
162
|
const timeStr = time >= 1e3 ? `${(time / 1e3).toFixed(2)}s` : `${Math.round(time)}ms`;
|
|
156
163
|
const barLength = Math.min(Math.ceil(time / TIME_SCALE_DIVISOR), MAX_BAR_LENGTH);
|
|
157
|
-
const bar =
|
|
158
|
-
summaryLines.push(`${
|
|
164
|
+
const bar = (0, node_util.styleText)("dim", "█".repeat(barLength));
|
|
165
|
+
summaryLines.push(`${(0, node_util.styleText)("dim", "•")} ${name.padEnd(maxLength + 1)}${bar} ${timeStr}`);
|
|
159
166
|
});
|
|
160
167
|
}
|
|
161
168
|
}
|
|
@@ -172,7 +179,7 @@ var ClackWritable = class extends node_stream.Writable {
|
|
|
172
179
|
this.taskLog = taskLog;
|
|
173
180
|
}
|
|
174
181
|
_write(chunk, _encoding, callback) {
|
|
175
|
-
this.taskLog.message(`${
|
|
182
|
+
this.taskLog.message(`${(0, node_util.styleText)("dim", chunk?.toString())}`);
|
|
176
183
|
callback();
|
|
177
184
|
}
|
|
178
185
|
};
|
|
@@ -218,25 +225,22 @@ const clackLogger = (0, _kubb_core.defineLogger)({
|
|
|
218
225
|
const parts = [];
|
|
219
226
|
const duration = (0, _kubb_core_utils.formatHrtime)(state.hrStart);
|
|
220
227
|
if (state.totalPlugins > 0) {
|
|
221
|
-
const pluginStr = state.failedPlugins > 0 ? `Plugins ${
|
|
228
|
+
const pluginStr = state.failedPlugins > 0 ? `Plugins ${(0, node_util.styleText)("green", state.completedPlugins.toString())}/${state.totalPlugins} ${(0, node_util.styleText)("red", `(${state.failedPlugins} failed)`)}` : `Plugins ${(0, node_util.styleText)("green", state.completedPlugins.toString())}/${state.totalPlugins}`;
|
|
222
229
|
parts.push(pluginStr);
|
|
223
230
|
}
|
|
224
|
-
if (state.totalFiles > 0) parts.push(`Files ${
|
|
231
|
+
if (state.totalFiles > 0) parts.push(`Files ${(0, node_util.styleText)("green", state.processedFiles.toString())}/${state.totalFiles}`);
|
|
225
232
|
if (parts.length > 0) {
|
|
226
|
-
parts.push(`${
|
|
227
|
-
_clack_prompts.log.step(getMessage(parts.join(
|
|
233
|
+
parts.push(`${(0, node_util.styleText)("green", duration)} elapsed`);
|
|
234
|
+
_clack_prompts.log.step(getMessage(parts.join((0, node_util.styleText)("dim", " | "))));
|
|
228
235
|
}
|
|
229
236
|
}
|
|
230
237
|
function getMessage(message) {
|
|
231
|
-
if (logLevel >= _kubb_core.LogLevel.verbose) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
});
|
|
238
|
-
return [picocolors.default.dim(`[${timestamp}]`), message].join(" ");
|
|
239
|
-
}
|
|
238
|
+
if (logLevel >= _kubb_core.LogLevel.verbose) return [(0, node_util.styleText)("dim", `[${(/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
239
|
+
hour12: false,
|
|
240
|
+
hour: "2-digit",
|
|
241
|
+
minute: "2-digit",
|
|
242
|
+
second: "2-digit"
|
|
243
|
+
})}]`), message].join(" ");
|
|
240
244
|
return message;
|
|
241
245
|
}
|
|
242
246
|
function startSpinner(text) {
|
|
@@ -250,9 +254,9 @@ const clackLogger = (0, _kubb_core.defineLogger)({
|
|
|
250
254
|
context.on("info", (message, info = "") => {
|
|
251
255
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
252
256
|
const text = getMessage([
|
|
253
|
-
|
|
257
|
+
(0, node_util.styleText)("blue", "ℹ"),
|
|
254
258
|
message,
|
|
255
|
-
|
|
259
|
+
(0, node_util.styleText)("dim", info)
|
|
256
260
|
].join(" "));
|
|
257
261
|
if (state.isSpinning) state.spinner.message(text);
|
|
258
262
|
else _clack_prompts.log.info(text);
|
|
@@ -260,9 +264,9 @@ const clackLogger = (0, _kubb_core.defineLogger)({
|
|
|
260
264
|
context.on("success", (message, info = "") => {
|
|
261
265
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
262
266
|
const text = getMessage([
|
|
263
|
-
|
|
267
|
+
(0, node_util.styleText)("blue", "✓"),
|
|
264
268
|
message,
|
|
265
|
-
logLevel >= _kubb_core.LogLevel.info ?
|
|
269
|
+
logLevel >= _kubb_core.LogLevel.info ? (0, node_util.styleText)("dim", info) : void 0
|
|
266
270
|
].filter(Boolean).join(" "));
|
|
267
271
|
if (state.isSpinning) stopSpinner(text);
|
|
268
272
|
else _clack_prompts.log.success(text);
|
|
@@ -270,44 +274,44 @@ const clackLogger = (0, _kubb_core.defineLogger)({
|
|
|
270
274
|
context.on("warn", (message, info) => {
|
|
271
275
|
if (logLevel < _kubb_core.LogLevel.warn) return;
|
|
272
276
|
const text = getMessage([
|
|
273
|
-
|
|
277
|
+
(0, node_util.styleText)("yellow", "⚠"),
|
|
274
278
|
message,
|
|
275
|
-
logLevel >= _kubb_core.LogLevel.info ?
|
|
279
|
+
logLevel >= _kubb_core.LogLevel.info && info ? (0, node_util.styleText)("dim", info) : void 0
|
|
276
280
|
].filter(Boolean).join(" "));
|
|
277
281
|
_clack_prompts.log.warn(text);
|
|
278
282
|
});
|
|
279
283
|
context.on("error", (error) => {
|
|
280
284
|
const caused = error.cause;
|
|
281
|
-
const text = [
|
|
285
|
+
const text = [(0, node_util.styleText)("red", "✗"), error.message].join(" ");
|
|
282
286
|
if (state.isSpinning) stopSpinner(getMessage(text));
|
|
283
287
|
else _clack_prompts.log.error(getMessage(text));
|
|
284
288
|
if (logLevel >= _kubb_core.LogLevel.debug && error.stack) {
|
|
285
289
|
const frames = error.stack.split("\n").slice(1, 4);
|
|
286
|
-
for (const frame of frames) _clack_prompts.log.message(getMessage(
|
|
290
|
+
for (const frame of frames) _clack_prompts.log.message(getMessage((0, node_util.styleText)("dim", frame.trim())));
|
|
287
291
|
if (caused?.stack) {
|
|
288
|
-
_clack_prompts.log.message(
|
|
289
|
-
const frames
|
|
290
|
-
for (const frame of frames
|
|
292
|
+
_clack_prompts.log.message((0, node_util.styleText)("dim", `└─ caused by ${caused.message}`));
|
|
293
|
+
const frames = caused.stack.split("\n").slice(1, 4);
|
|
294
|
+
for (const frame of frames) _clack_prompts.log.message(getMessage(` ${(0, node_util.styleText)("dim", frame.trim())}`));
|
|
291
295
|
}
|
|
292
296
|
}
|
|
293
297
|
});
|
|
294
|
-
context.on("version:new", (version
|
|
298
|
+
context.on("version:new", (version, latestVersion) => {
|
|
295
299
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
296
|
-
_clack_prompts.box(`\`v${version
|
|
300
|
+
_clack_prompts.box(`\`v${version}\` → \`v${latestVersion}\`
|
|
297
301
|
Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
298
302
|
width: "auto",
|
|
299
|
-
formatBorder:
|
|
303
|
+
formatBorder: (s) => (0, node_util.styleText)("yellow", s),
|
|
300
304
|
rounded: true,
|
|
301
305
|
withGuide: false,
|
|
302
306
|
contentAlign: "center",
|
|
303
307
|
titleAlign: "center"
|
|
304
308
|
});
|
|
305
309
|
});
|
|
306
|
-
context.on("lifecycle:start", async (version
|
|
310
|
+
context.on("lifecycle:start", async (version) => {
|
|
307
311
|
console.log(`\n${getIntro({
|
|
308
312
|
title: "The ultimate toolkit for working with APIs",
|
|
309
313
|
description: "Ready to start",
|
|
310
|
-
version
|
|
314
|
+
version,
|
|
311
315
|
areEyesOpen: true
|
|
312
316
|
})}\n`);
|
|
313
317
|
reset();
|
|
@@ -325,7 +329,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
325
329
|
});
|
|
326
330
|
context.on("generation:start", (config) => {
|
|
327
331
|
state.totalPlugins = config.plugins?.length || 0;
|
|
328
|
-
const text = getMessage(["Generation started", config.name ? `for ${
|
|
332
|
+
const text = getMessage(["Generation started", config.name ? `for ${(0, node_util.styleText)("dim", config.name)}` : void 0].filter(Boolean).join(" "));
|
|
329
333
|
_clack_prompts.intro(text);
|
|
330
334
|
reset();
|
|
331
335
|
});
|
|
@@ -337,7 +341,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
337
341
|
max: 100,
|
|
338
342
|
size: 30
|
|
339
343
|
});
|
|
340
|
-
const text = getMessage(`Generating ${
|
|
344
|
+
const text = getMessage(`Generating ${(0, node_util.styleText)("bold", plugin.name)}`);
|
|
341
345
|
progressBar.start(text);
|
|
342
346
|
const interval = setInterval(() => {
|
|
343
347
|
progressBar.advance();
|
|
@@ -355,7 +359,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
355
359
|
if (success) state.completedPlugins++;
|
|
356
360
|
else state.failedPlugins++;
|
|
357
361
|
const durationStr = formatMsWithColor(duration);
|
|
358
|
-
const text = getMessage(success ? `${
|
|
362
|
+
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", (0, _kubb_core_utils.formatMs)(duration))}`);
|
|
359
363
|
active.progressBar.stop(text);
|
|
360
364
|
state.activeProgress.delete(plugin.name);
|
|
361
365
|
showProgressStep();
|
|
@@ -395,7 +399,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
395
399
|
showProgressStep();
|
|
396
400
|
});
|
|
397
401
|
context.on("generation:end", (config) => {
|
|
398
|
-
const text = getMessage(config.name ? `Generation completed for ${
|
|
402
|
+
const text = getMessage(config.name ? `Generation completed for ${(0, node_util.styleText)("dim", config.name)}` : "Generation completed");
|
|
399
403
|
_clack_prompts.outro(text);
|
|
400
404
|
});
|
|
401
405
|
context.on("format:start", () => {
|
|
@@ -418,22 +422,22 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
418
422
|
const text = getMessage("Lint completed");
|
|
419
423
|
_clack_prompts.outro(text);
|
|
420
424
|
});
|
|
421
|
-
context.on("hook:start", async ({ id, command
|
|
422
|
-
const commandWithArgs = args?.length ? `${command
|
|
423
|
-
const text = getMessage(`Hook ${
|
|
425
|
+
context.on("hook:start", async ({ id, command, args }) => {
|
|
426
|
+
const commandWithArgs = args?.length ? `${command} ${args.join(" ")}` : command;
|
|
427
|
+
const text = getMessage(`Hook ${(0, node_util.styleText)("dim", commandWithArgs)} started`);
|
|
424
428
|
if (!id) return;
|
|
425
429
|
if (logLevel <= _kubb_core.LogLevel.silent) {
|
|
426
430
|
try {
|
|
427
|
-
const result = await (0,
|
|
428
|
-
detached: true,
|
|
429
|
-
|
|
431
|
+
const result = await (0, tinyexec.x)(command, [...args ?? []], {
|
|
432
|
+
nodeOptions: { detached: true },
|
|
433
|
+
throwOnError: true
|
|
430
434
|
});
|
|
431
435
|
await context.emit("debug", {
|
|
432
436
|
date: /* @__PURE__ */ new Date(),
|
|
433
|
-
logs: [result.stdout]
|
|
437
|
+
logs: [result.stdout.trimEnd()]
|
|
434
438
|
});
|
|
435
439
|
await context.emit("hook:end", {
|
|
436
|
-
command
|
|
440
|
+
command,
|
|
437
441
|
args,
|
|
438
442
|
id,
|
|
439
443
|
success: true,
|
|
@@ -441,8 +445,8 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
441
445
|
});
|
|
442
446
|
} catch (err) {
|
|
443
447
|
const error = err;
|
|
444
|
-
const stderr =
|
|
445
|
-
const stdout =
|
|
448
|
+
const stderr = error.output?.stderr ?? "";
|
|
449
|
+
const stdout = error.output?.stdout ?? "";
|
|
446
450
|
await context.emit("debug", {
|
|
447
451
|
date: /* @__PURE__ */ new Date(),
|
|
448
452
|
logs: [stdout, stderr].filter(Boolean)
|
|
@@ -451,7 +455,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
451
455
|
if (stdout) console.log(stdout);
|
|
452
456
|
const errorMessage = /* @__PURE__ */ new Error(`Hook execute failed: ${commandWithArgs}`);
|
|
453
457
|
await context.emit("hook:end", {
|
|
454
|
-
command
|
|
458
|
+
command,
|
|
455
459
|
args,
|
|
456
460
|
id,
|
|
457
461
|
success: false,
|
|
@@ -462,20 +466,21 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
462
466
|
return;
|
|
463
467
|
}
|
|
464
468
|
_clack_prompts.intro(text);
|
|
465
|
-
const logger = _clack_prompts.taskLog({ title: getMessage(["Executing hook", logLevel >= _kubb_core.LogLevel.info ?
|
|
469
|
+
const logger = _clack_prompts.taskLog({ title: getMessage(["Executing hook", logLevel >= _kubb_core.LogLevel.info ? (0, node_util.styleText)("dim", commandWithArgs) : void 0].filter(Boolean).join(" ")) });
|
|
466
470
|
const writable = new ClackWritable(logger);
|
|
467
471
|
try {
|
|
468
|
-
const
|
|
469
|
-
detached: true,
|
|
470
|
-
|
|
471
|
-
stripFinalNewline: true
|
|
472
|
+
const proc = (0, tinyexec.x)(command, [...args ?? []], {
|
|
473
|
+
nodeOptions: { detached: true },
|
|
474
|
+
throwOnError: true
|
|
472
475
|
});
|
|
476
|
+
for await (const line of proc) writable.write(line);
|
|
477
|
+
const result = await proc;
|
|
473
478
|
await context.emit("debug", {
|
|
474
479
|
date: /* @__PURE__ */ new Date(),
|
|
475
|
-
logs: [result.stdout]
|
|
480
|
+
logs: [result.stdout.trimEnd()]
|
|
476
481
|
});
|
|
477
482
|
await context.emit("hook:end", {
|
|
478
|
-
command
|
|
483
|
+
command,
|
|
479
484
|
args,
|
|
480
485
|
id,
|
|
481
486
|
success: true,
|
|
@@ -483,8 +488,8 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
483
488
|
});
|
|
484
489
|
} catch (err) {
|
|
485
490
|
const error = err;
|
|
486
|
-
const stderr =
|
|
487
|
-
const stdout =
|
|
491
|
+
const stderr = error.output?.stderr ?? "";
|
|
492
|
+
const stdout = error.output?.stdout ?? "";
|
|
488
493
|
await context.emit("debug", {
|
|
489
494
|
date: /* @__PURE__ */ new Date(),
|
|
490
495
|
logs: [stdout, stderr].filter(Boolean)
|
|
@@ -493,7 +498,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
493
498
|
if (stdout) logger.message(stdout);
|
|
494
499
|
const errorMessage = /* @__PURE__ */ new Error(`Hook execute failed: ${commandWithArgs}`);
|
|
495
500
|
await context.emit("hook:end", {
|
|
496
|
-
command
|
|
501
|
+
command,
|
|
497
502
|
args,
|
|
498
503
|
id,
|
|
499
504
|
success: false,
|
|
@@ -502,10 +507,9 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
502
507
|
await context.emit("error", errorMessage);
|
|
503
508
|
}
|
|
504
509
|
});
|
|
505
|
-
context.on("hook:end", ({ command
|
|
510
|
+
context.on("hook:end", ({ command, args }) => {
|
|
506
511
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
507
|
-
const
|
|
508
|
-
const text = getMessage(`Hook ${picocolors.default.dim(commandWithArgs)} successfully executed`);
|
|
512
|
+
const text = getMessage(`Hook ${(0, node_util.styleText)("dim", args?.length ? `${command} ${args.join(" ")}` : command)} successfully executed`);
|
|
509
513
|
_clack_prompts.outro(text);
|
|
510
514
|
});
|
|
511
515
|
context.on("generation:summary", (config, { pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
|
|
@@ -523,7 +527,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
523
527
|
if (status === "success") {
|
|
524
528
|
_clack_prompts.box(summary.join("\n"), getMessage(title), {
|
|
525
529
|
width: "auto",
|
|
526
|
-
formatBorder:
|
|
530
|
+
formatBorder: (s) => (0, node_util.styleText)("green", s),
|
|
527
531
|
rounded: true,
|
|
528
532
|
withGuide: false,
|
|
529
533
|
contentAlign: "left",
|
|
@@ -533,7 +537,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
533
537
|
}
|
|
534
538
|
_clack_prompts.box(summary.join("\n"), getMessage(title), {
|
|
535
539
|
width: "auto",
|
|
536
|
-
formatBorder:
|
|
540
|
+
formatBorder: (s) => (0, node_util.styleText)("red", s),
|
|
537
541
|
rounded: true,
|
|
538
542
|
withGuide: false,
|
|
539
543
|
contentAlign: "left",
|
|
@@ -715,25 +719,22 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
715
719
|
const parts = [];
|
|
716
720
|
const duration = (0, _kubb_core_utils.formatHrtime)(state.hrStart);
|
|
717
721
|
if (state.totalPlugins > 0) {
|
|
718
|
-
const pluginStr = state.failedPlugins > 0 ? `Plugins ${
|
|
722
|
+
const pluginStr = state.failedPlugins > 0 ? `Plugins ${(0, node_util.styleText)("green", state.completedPlugins.toString())}/${state.totalPlugins} ${(0, node_util.styleText)("red", `(${state.failedPlugins} failed)`)}` : `Plugins ${(0, node_util.styleText)("green", state.completedPlugins.toString())}/${state.totalPlugins}`;
|
|
719
723
|
parts.push(pluginStr);
|
|
720
724
|
}
|
|
721
|
-
if (state.totalFiles > 0) parts.push(`Files ${
|
|
725
|
+
if (state.totalFiles > 0) parts.push(`Files ${(0, node_util.styleText)("green", state.processedFiles.toString())}/${state.totalFiles}`);
|
|
722
726
|
if (parts.length > 0) {
|
|
723
|
-
parts.push(`${
|
|
724
|
-
console.log(getMessage(parts.join(
|
|
727
|
+
parts.push(`${(0, node_util.styleText)("green", duration)} elapsed`);
|
|
728
|
+
console.log(getMessage(parts.join((0, node_util.styleText)("dim", " | "))));
|
|
725
729
|
}
|
|
726
730
|
}
|
|
727
731
|
function getMessage(message) {
|
|
728
|
-
if (logLevel >= _kubb_core.LogLevel.verbose) {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
});
|
|
735
|
-
return [picocolors.default.dim(`[${timestamp}]`), message].join(" ");
|
|
736
|
-
}
|
|
732
|
+
if (logLevel >= _kubb_core.LogLevel.verbose) return [(0, node_util.styleText)("dim", `[${(/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
733
|
+
hour12: false,
|
|
734
|
+
hour: "2-digit",
|
|
735
|
+
minute: "2-digit",
|
|
736
|
+
second: "2-digit"
|
|
737
|
+
})}]`), message].join(" ");
|
|
737
738
|
return message;
|
|
738
739
|
}
|
|
739
740
|
function openGroup(name) {
|
|
@@ -745,27 +746,27 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
745
746
|
context.on("info", (message, info = "") => {
|
|
746
747
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
747
748
|
const text = getMessage([
|
|
748
|
-
|
|
749
|
+
(0, node_util.styleText)("blue", "ℹ"),
|
|
749
750
|
message,
|
|
750
|
-
|
|
751
|
+
(0, node_util.styleText)("dim", info)
|
|
751
752
|
].join(" "));
|
|
752
753
|
console.log(text);
|
|
753
754
|
});
|
|
754
755
|
context.on("success", (message, info = "") => {
|
|
755
756
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
756
757
|
const text = getMessage([
|
|
757
|
-
|
|
758
|
+
(0, node_util.styleText)("blue", "✓"),
|
|
758
759
|
message,
|
|
759
|
-
logLevel >= _kubb_core.LogLevel.info ?
|
|
760
|
+
logLevel >= _kubb_core.LogLevel.info ? (0, node_util.styleText)("dim", info) : void 0
|
|
760
761
|
].filter(Boolean).join(" "));
|
|
761
762
|
console.log(text);
|
|
762
763
|
});
|
|
763
764
|
context.on("warn", (message, info = "") => {
|
|
764
765
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
765
766
|
const text = getMessage([
|
|
766
|
-
|
|
767
|
+
(0, node_util.styleText)("yellow", "⚠"),
|
|
767
768
|
message,
|
|
768
|
-
logLevel >= _kubb_core.LogLevel.info ?
|
|
769
|
+
logLevel >= _kubb_core.LogLevel.info ? (0, node_util.styleText)("dim", info) : void 0
|
|
769
770
|
].filter(Boolean).join(" "));
|
|
770
771
|
console.warn(`::warning::${text}`);
|
|
771
772
|
});
|
|
@@ -776,16 +777,16 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
776
777
|
console.error(`::error::${message}`);
|
|
777
778
|
if (logLevel >= _kubb_core.LogLevel.debug && error.stack) {
|
|
778
779
|
const frames = error.stack.split("\n").slice(1, 4);
|
|
779
|
-
for (const frame of frames) console.log(getMessage(
|
|
780
|
+
for (const frame of frames) console.log(getMessage((0, node_util.styleText)("dim", frame.trim())));
|
|
780
781
|
if (caused?.stack) {
|
|
781
|
-
console.log(
|
|
782
|
-
const frames
|
|
783
|
-
for (const frame of frames
|
|
782
|
+
console.log((0, node_util.styleText)("dim", `└─ caused by ${caused.message}`));
|
|
783
|
+
const frames = caused.stack.split("\n").slice(1, 4);
|
|
784
|
+
for (const frame of frames) console.log(getMessage(` ${(0, node_util.styleText)("dim", frame.trim())}`));
|
|
784
785
|
}
|
|
785
786
|
}
|
|
786
787
|
});
|
|
787
|
-
context.on("lifecycle:start", (version
|
|
788
|
-
console.log(
|
|
788
|
+
context.on("lifecycle:start", (version) => {
|
|
789
|
+
console.log((0, node_util.styleText)("yellow", `Kubb ${version} 🧩`));
|
|
789
790
|
reset();
|
|
790
791
|
});
|
|
791
792
|
context.on("config:start", () => {
|
|
@@ -803,14 +804,14 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
803
804
|
});
|
|
804
805
|
context.on("generation:start", (config) => {
|
|
805
806
|
state.totalPlugins = config.plugins?.length || 0;
|
|
806
|
-
const text = config.name ? `Generation for ${
|
|
807
|
+
const text = config.name ? `Generation for ${(0, node_util.styleText)("bold", config.name)}` : "Generation";
|
|
807
808
|
if (state.currentConfigs.length > 1) openGroup(text);
|
|
808
809
|
if (state.currentConfigs.length === 1) console.log(getMessage(text));
|
|
809
810
|
reset();
|
|
810
811
|
});
|
|
811
812
|
context.on("plugin:start", (plugin) => {
|
|
812
813
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
813
|
-
const text = getMessage(`Generating ${
|
|
814
|
+
const text = getMessage(`Generating ${(0, node_util.styleText)("bold", plugin.name)}`);
|
|
814
815
|
if (state.currentConfigs.length === 1) openGroup(`Plugin: ${plugin.name}`);
|
|
815
816
|
console.log(text);
|
|
816
817
|
});
|
|
@@ -819,7 +820,7 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
819
820
|
if (success) state.completedPlugins++;
|
|
820
821
|
else state.failedPlugins++;
|
|
821
822
|
const durationStr = formatMsWithColor(duration);
|
|
822
|
-
const text = getMessage(success ? `${
|
|
823
|
+
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", (0, _kubb_core_utils.formatMs)(duration))}`);
|
|
823
824
|
console.log(text);
|
|
824
825
|
if (state.currentConfigs.length > 1) console.log(" ");
|
|
825
826
|
if (state.currentConfigs.length === 1) closeGroup(`Plugin: ${plugin.name}`);
|
|
@@ -848,7 +849,7 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
848
849
|
showProgressStep();
|
|
849
850
|
});
|
|
850
851
|
context.on("generation:end", (config) => {
|
|
851
|
-
const text = getMessage(config.name ? `${
|
|
852
|
+
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`);
|
|
852
853
|
console.log(text);
|
|
853
854
|
});
|
|
854
855
|
context.on("format:start", () => {
|
|
@@ -875,26 +876,26 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
875
876
|
console.log(text);
|
|
876
877
|
if (state.currentConfigs.length === 1) closeGroup("Linting");
|
|
877
878
|
});
|
|
878
|
-
context.on("hook:start", async ({ id, command
|
|
879
|
-
const commandWithArgs = args?.length ? `${command
|
|
880
|
-
const text = getMessage(`Hook ${
|
|
879
|
+
context.on("hook:start", async ({ id, command, args }) => {
|
|
880
|
+
const commandWithArgs = args?.length ? `${command} ${args.join(" ")}` : command;
|
|
881
|
+
const text = getMessage(`Hook ${(0, node_util.styleText)("dim", commandWithArgs)} started`);
|
|
881
882
|
if (logLevel > _kubb_core.LogLevel.silent) {
|
|
882
883
|
if (state.currentConfigs.length === 1) openGroup(`Hook ${commandWithArgs}`);
|
|
883
884
|
console.log(text);
|
|
884
885
|
}
|
|
885
886
|
if (!id) return;
|
|
886
887
|
try {
|
|
887
|
-
const result = await (0,
|
|
888
|
-
detached: true,
|
|
889
|
-
|
|
888
|
+
const result = await (0, tinyexec.x)(command, [...args ?? []], {
|
|
889
|
+
nodeOptions: { detached: true },
|
|
890
|
+
throwOnError: true
|
|
890
891
|
});
|
|
891
892
|
await context.emit("debug", {
|
|
892
893
|
date: /* @__PURE__ */ new Date(),
|
|
893
|
-
logs: [result.stdout]
|
|
894
|
+
logs: [result.stdout.trimEnd()]
|
|
894
895
|
});
|
|
895
|
-
if (logLevel > _kubb_core.LogLevel.silent) console.log(result.stdout);
|
|
896
|
+
if (logLevel > _kubb_core.LogLevel.silent) console.log(result.stdout.trimEnd());
|
|
896
897
|
await context.emit("hook:end", {
|
|
897
|
-
command
|
|
898
|
+
command,
|
|
898
899
|
args,
|
|
899
900
|
id,
|
|
900
901
|
success: true,
|
|
@@ -902,8 +903,8 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
902
903
|
});
|
|
903
904
|
} catch (err) {
|
|
904
905
|
const error = err;
|
|
905
|
-
const stderr =
|
|
906
|
-
const stdout =
|
|
906
|
+
const stderr = error.output?.stderr ?? "";
|
|
907
|
+
const stdout = error.output?.stdout ?? "";
|
|
907
908
|
await context.emit("debug", {
|
|
908
909
|
date: /* @__PURE__ */ new Date(),
|
|
909
910
|
logs: [stdout, stderr].filter(Boolean)
|
|
@@ -912,7 +913,7 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
912
913
|
if (stdout) console.log(stdout);
|
|
913
914
|
const errorMessage = /* @__PURE__ */ new Error(`Hook execute failed: ${commandWithArgs}`);
|
|
914
915
|
await context.emit("hook:end", {
|
|
915
|
-
command
|
|
916
|
+
command,
|
|
916
917
|
args,
|
|
917
918
|
id,
|
|
918
919
|
success: false,
|
|
@@ -921,10 +922,10 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
921
922
|
await context.emit("error", errorMessage);
|
|
922
923
|
}
|
|
923
924
|
});
|
|
924
|
-
context.on("hook:end", ({ command
|
|
925
|
+
context.on("hook:end", ({ command, args }) => {
|
|
925
926
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
926
|
-
const commandWithArgs = args?.length ? `${command
|
|
927
|
-
const text = getMessage(`Hook ${
|
|
927
|
+
const commandWithArgs = args?.length ? `${command} ${args.join(" ")}` : command;
|
|
928
|
+
const text = getMessage(`Hook ${(0, node_util.styleText)("dim", commandWithArgs)} completed`);
|
|
928
929
|
console.log(text);
|
|
929
930
|
if (state.currentConfigs.length === 1) closeGroup(`Hook ${commandWithArgs}`);
|
|
930
931
|
});
|
|
@@ -933,8 +934,8 @@ const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
|
933
934
|
const successCount = pluginsCount - failedPlugins.size;
|
|
934
935
|
const duration = (0, _kubb_core_utils.formatHrtime)(hrStart);
|
|
935
936
|
if (state.currentConfigs.length > 1) console.log(" ");
|
|
936
|
-
console.log(status === "success" ? `Kubb Summary: ${
|
|
937
|
-
if (state.currentConfigs.length > 1) closeGroup(config.name ? `Generation for ${
|
|
937
|
+
console.log(status === "success" ? `Kubb Summary: ${(0, node_util.styleText)("blue", "✓")} ${`${successCount} successful`}, ${pluginsCount} total, ${(0, node_util.styleText)("green", duration)}` : `Kubb Summary: ${(0, node_util.styleText)("blue", "✓")} ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total, ${(0, node_util.styleText)("green", duration)}`);
|
|
938
|
+
if (state.currentConfigs.length > 1) closeGroup(config.name ? `Generation for ${(0, node_util.styleText)("bold", config.name)}` : "Generation");
|
|
938
939
|
});
|
|
939
940
|
}
|
|
940
941
|
});
|
|
@@ -994,8 +995,8 @@ const plainLogger = (0, _kubb_core.defineLogger)({
|
|
|
994
995
|
for (const frame of frames) console.log(getMessage(frame.trim()));
|
|
995
996
|
if (caused?.stack) {
|
|
996
997
|
console.log(`└─ caused by ${caused.message}`);
|
|
997
|
-
const frames
|
|
998
|
-
for (const frame of frames
|
|
998
|
+
const frames = caused.stack.split("\n").slice(1, 4);
|
|
999
|
+
for (const frame of frames) console.log(getMessage(` ${frame.trim()}`));
|
|
999
1000
|
}
|
|
1000
1001
|
}
|
|
1001
1002
|
});
|
|
@@ -1066,23 +1067,23 @@ const plainLogger = (0, _kubb_core.defineLogger)({
|
|
|
1066
1067
|
const text = getMessage("Lint completed");
|
|
1067
1068
|
console.log(text);
|
|
1068
1069
|
});
|
|
1069
|
-
context.on("hook:start", async ({ id, command
|
|
1070
|
-
const commandWithArgs = args?.length ? `${command
|
|
1070
|
+
context.on("hook:start", async ({ id, command, args }) => {
|
|
1071
|
+
const commandWithArgs = args?.length ? `${command} ${args.join(" ")}` : command;
|
|
1071
1072
|
const text = getMessage(`Hook ${commandWithArgs} started`);
|
|
1072
1073
|
if (logLevel > _kubb_core.LogLevel.silent) console.log(text);
|
|
1073
1074
|
if (!id) return;
|
|
1074
1075
|
try {
|
|
1075
|
-
const result = await (0,
|
|
1076
|
-
detached: true,
|
|
1077
|
-
|
|
1076
|
+
const result = await (0, tinyexec.x)(command, [...args ?? []], {
|
|
1077
|
+
nodeOptions: { detached: true },
|
|
1078
|
+
throwOnError: true
|
|
1078
1079
|
});
|
|
1079
1080
|
await context.emit("debug", {
|
|
1080
1081
|
date: /* @__PURE__ */ new Date(),
|
|
1081
|
-
logs: [result.stdout]
|
|
1082
|
+
logs: [result.stdout.trimEnd()]
|
|
1082
1083
|
});
|
|
1083
|
-
if (logLevel > _kubb_core.LogLevel.silent) console.log(result.stdout);
|
|
1084
|
+
if (logLevel > _kubb_core.LogLevel.silent) console.log(result.stdout.trimEnd());
|
|
1084
1085
|
await context.emit("hook:end", {
|
|
1085
|
-
command
|
|
1086
|
+
command,
|
|
1086
1087
|
args,
|
|
1087
1088
|
id,
|
|
1088
1089
|
success: true,
|
|
@@ -1090,8 +1091,8 @@ const plainLogger = (0, _kubb_core.defineLogger)({
|
|
|
1090
1091
|
});
|
|
1091
1092
|
} catch (err) {
|
|
1092
1093
|
const error = err;
|
|
1093
|
-
const stderr =
|
|
1094
|
-
const stdout =
|
|
1094
|
+
const stderr = error.output?.stderr ?? "";
|
|
1095
|
+
const stdout = error.output?.stdout ?? "";
|
|
1095
1096
|
await context.emit("debug", {
|
|
1096
1097
|
date: /* @__PURE__ */ new Date(),
|
|
1097
1098
|
logs: [stdout, stderr].filter(Boolean)
|
|
@@ -1100,7 +1101,7 @@ const plainLogger = (0, _kubb_core.defineLogger)({
|
|
|
1100
1101
|
if (stdout) console.log(stdout);
|
|
1101
1102
|
const errorMessage = /* @__PURE__ */ new Error(`Hook execute failed: ${commandWithArgs}`);
|
|
1102
1103
|
await context.emit("hook:end", {
|
|
1103
|
-
command
|
|
1104
|
+
command,
|
|
1104
1105
|
args,
|
|
1105
1106
|
id,
|
|
1106
1107
|
success: false,
|
|
@@ -1109,9 +1110,9 @@ const plainLogger = (0, _kubb_core.defineLogger)({
|
|
|
1109
1110
|
await context.emit("error", errorMessage);
|
|
1110
1111
|
}
|
|
1111
1112
|
});
|
|
1112
|
-
context.on("hook:end", ({ command
|
|
1113
|
+
context.on("hook:end", ({ command, args }) => {
|
|
1113
1114
|
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
1114
|
-
const text = getMessage(`Hook ${args?.length ? `${command
|
|
1115
|
+
const text = getMessage(`Hook ${args?.length ? `${command} ${args.join(" ")}` : command} completed`);
|
|
1115
1116
|
console.log(text);
|
|
1116
1117
|
});
|
|
1117
1118
|
context.on("generation:summary", (config, { pluginTimings, status, hrStart, failedPlugins, filesCreated }) => {
|
|
@@ -1155,10 +1156,10 @@ async function setupLogger(context, { logLevel }) {
|
|
|
1155
1156
|
//#region src/utils/executeHooks.ts
|
|
1156
1157
|
async function executeHooks({ hooks, events }) {
|
|
1157
1158
|
const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done].filter(Boolean);
|
|
1158
|
-
for (const command
|
|
1159
|
-
const [cmd, ...args] =
|
|
1159
|
+
for (const command of commands) {
|
|
1160
|
+
const [cmd, ...args] = (0, _kubb_core_utils.tokenize)(command);
|
|
1160
1161
|
if (!cmd) continue;
|
|
1161
|
-
const hookId = (0, node_crypto.createHash)("sha256").update(command
|
|
1162
|
+
const hookId = (0, node_crypto.createHash)("sha256").update(command).digest("hex");
|
|
1162
1163
|
await events.emit("hook:start", {
|
|
1163
1164
|
id: hookId,
|
|
1164
1165
|
command: cmd,
|
|
@@ -1166,7 +1167,7 @@ async function executeHooks({ hooks, events }) {
|
|
|
1166
1167
|
});
|
|
1167
1168
|
await events.onOnce("hook:end", async ({ success, error }) => {
|
|
1168
1169
|
if (!success) throw error;
|
|
1169
|
-
await events.emit("success", `${
|
|
1170
|
+
await events.emit("success", `${(0, node_util.styleText)("dim", command)} successfully executed`);
|
|
1170
1171
|
});
|
|
1171
1172
|
}
|
|
1172
1173
|
}
|
|
@@ -1192,12 +1193,12 @@ async function generate({ input, config: userConfig, events, logLevel }) {
|
|
|
1192
1193
|
}
|
|
1193
1194
|
};
|
|
1194
1195
|
await events.emit("generation:start", config);
|
|
1195
|
-
await events.emit("info", config.name ? `Setup generation ${
|
|
1196
|
+
await events.emit("info", config.name ? `Setup generation ${(0, node_util.styleText)("bold", config.name)}` : "Setup generation", inputPath);
|
|
1196
1197
|
const { sources, fabric, pluginManager } = await (0, _kubb_core.setup)({
|
|
1197
1198
|
config,
|
|
1198
1199
|
events
|
|
1199
1200
|
});
|
|
1200
|
-
await events.emit("info", config.name ? `Build generation ${
|
|
1201
|
+
await events.emit("info", config.name ? `Build generation ${(0, node_util.styleText)("bold", config.name)}` : "Build generation", inputPath);
|
|
1201
1202
|
const { files, failedPlugins, pluginTimings, error } = await (0, _kubb_core.safeBuild)({
|
|
1202
1203
|
config,
|
|
1203
1204
|
events
|
|
@@ -1232,7 +1233,7 @@ async function generate({ input, config: userConfig, events, logLevel }) {
|
|
|
1232
1233
|
if (!detectedFormatter) await events.emit("warn", "No formatter found (biome, prettier, or oxfmt). Skipping formatting.");
|
|
1233
1234
|
else {
|
|
1234
1235
|
formatter = detectedFormatter;
|
|
1235
|
-
await events.emit("info", `Auto-detected formatter: ${
|
|
1236
|
+
await events.emit("info", `Auto-detected formatter: ${(0, node_util.styleText)("dim", formatter)}`);
|
|
1236
1237
|
}
|
|
1237
1238
|
}
|
|
1238
1239
|
if (formatter && formatter !== "auto" && formatter in _kubb_core_utils.formatters) {
|
|
@@ -1245,18 +1246,18 @@ async function generate({ input, config: userConfig, events, logLevel }) {
|
|
|
1245
1246
|
command: formatterConfig.command,
|
|
1246
1247
|
args: formatterConfig.args(outputPath)
|
|
1247
1248
|
});
|
|
1248
|
-
await events.onOnce("hook:end", async ({ success, error
|
|
1249
|
-
if (!success) throw error
|
|
1249
|
+
await events.onOnce("hook:end", async ({ success, error }) => {
|
|
1250
|
+
if (!success) throw error;
|
|
1250
1251
|
await events.emit("success", [
|
|
1251
|
-
`Formatting with ${
|
|
1252
|
-
logLevel >= _kubb_core.LogLevel.info ? `on ${
|
|
1252
|
+
`Formatting with ${(0, node_util.styleText)("dim", formatter)}`,
|
|
1253
|
+
logLevel >= _kubb_core.LogLevel.info ? `on ${(0, node_util.styleText)("dim", outputPath)}` : void 0,
|
|
1253
1254
|
"successfully"
|
|
1254
1255
|
].filter(Boolean).join(" "));
|
|
1255
1256
|
});
|
|
1256
1257
|
} catch (caughtError) {
|
|
1257
|
-
const error
|
|
1258
|
-
error
|
|
1259
|
-
await events.emit("error", error
|
|
1258
|
+
const error = new Error(formatterConfig.errorMessage);
|
|
1259
|
+
error.cause = caughtError;
|
|
1260
|
+
await events.emit("error", error);
|
|
1260
1261
|
}
|
|
1261
1262
|
}
|
|
1262
1263
|
await events.emit("format:end");
|
|
@@ -1269,7 +1270,7 @@ async function generate({ input, config: userConfig, events, logLevel }) {
|
|
|
1269
1270
|
if (!detectedLinter) await events.emit("warn", "No linter found (biome, oxlint, or eslint). Skipping linting.");
|
|
1270
1271
|
else {
|
|
1271
1272
|
linter = detectedLinter;
|
|
1272
|
-
await events.emit("info", `Auto-detected linter: ${
|
|
1273
|
+
await events.emit("info", `Auto-detected linter: ${(0, node_util.styleText)("dim", linter)}`);
|
|
1273
1274
|
}
|
|
1274
1275
|
}
|
|
1275
1276
|
if (linter && linter !== "auto" && linter in _kubb_core_utils.linters) {
|
|
@@ -1282,18 +1283,18 @@ async function generate({ input, config: userConfig, events, logLevel }) {
|
|
|
1282
1283
|
command: linterConfig.command,
|
|
1283
1284
|
args: linterConfig.args(outputPath)
|
|
1284
1285
|
});
|
|
1285
|
-
await events.onOnce("hook:end", async ({ success, error
|
|
1286
|
-
if (!success) throw error
|
|
1286
|
+
await events.onOnce("hook:end", async ({ success, error }) => {
|
|
1287
|
+
if (!success) throw error;
|
|
1287
1288
|
await events.emit("success", [
|
|
1288
|
-
`Linting with ${
|
|
1289
|
-
logLevel >= _kubb_core.LogLevel.info ? `on ${
|
|
1289
|
+
`Linting with ${(0, node_util.styleText)("dim", linter)}`,
|
|
1290
|
+
logLevel >= _kubb_core.LogLevel.info ? `on ${(0, node_util.styleText)("dim", outputPath)}` : void 0,
|
|
1290
1291
|
"successfully"
|
|
1291
1292
|
].filter(Boolean).join(" "));
|
|
1292
1293
|
});
|
|
1293
1294
|
} catch (caughtError) {
|
|
1294
|
-
const error
|
|
1295
|
-
error
|
|
1296
|
-
await events.emit("error", error
|
|
1295
|
+
const error = new Error(linterConfig.errorMessage);
|
|
1296
|
+
error.cause = caughtError;
|
|
1297
|
+
await events.emit("error", error);
|
|
1297
1298
|
}
|
|
1298
1299
|
}
|
|
1299
1300
|
await events.emit("lint:end");
|
|
@@ -1368,17 +1369,17 @@ async function getCosmiConfig(moduleName, config) {
|
|
|
1368
1369
|
|
|
1369
1370
|
//#endregion
|
|
1370
1371
|
//#region src/utils/watcher.ts
|
|
1371
|
-
async function startWatcher(path
|
|
1372
|
+
async function startWatcher(path, cb) {
|
|
1372
1373
|
const { watch } = await import("chokidar");
|
|
1373
|
-
watch(path
|
|
1374
|
+
watch(path, {
|
|
1374
1375
|
ignorePermissionErrors: true,
|
|
1375
1376
|
ignored: "**/{.git,node_modules}/**"
|
|
1376
1377
|
}).on("all", async (type, file) => {
|
|
1377
|
-
console.log(
|
|
1378
|
+
console.log((0, node_util.styleText)("yellow", (0, node_util.styleText)("bold", `Change detected: ${type} ${file}`)));
|
|
1378
1379
|
try {
|
|
1379
|
-
await cb(path
|
|
1380
|
+
await cb(path);
|
|
1380
1381
|
} catch (_e) {
|
|
1381
|
-
console.log(
|
|
1382
|
+
console.log((0, node_util.styleText)("red", "Watcher failed"));
|
|
1382
1383
|
}
|
|
1383
1384
|
});
|
|
1384
1385
|
}
|
|
@@ -1446,8 +1447,10 @@ const command = (0, citty.defineCommand)({
|
|
|
1446
1447
|
const logLevel = _kubb_core.LogLevel[args.logLevel] || 3;
|
|
1447
1448
|
await setupLogger(events, { logLevel });
|
|
1448
1449
|
await (0, _kubb_core_utils.executeIfOnline)(async () => {
|
|
1449
|
-
|
|
1450
|
-
|
|
1450
|
+
try {
|
|
1451
|
+
const latestVersion = (await (await fetch("https://registry.npmjs.org/@kubb/cli/latest")).json()).version;
|
|
1452
|
+
if (latestVersion && require_package.version < latestVersion) await events.emit("version:new", require_package.version, latestVersion);
|
|
1453
|
+
} catch {}
|
|
1451
1454
|
});
|
|
1452
1455
|
try {
|
|
1453
1456
|
const result = await getCosmiConfig("kubb", args.config);
|
|
@@ -1461,13 +1464,14 @@ const command = (0, citty.defineCommand)({
|
|
|
1461
1464
|
return async () => {
|
|
1462
1465
|
if ((0, _kubb_core.isInputPath)(config) && args.watch) {
|
|
1463
1466
|
await startWatcher([input || config.input.path], async (paths) => {
|
|
1467
|
+
events.removeAll();
|
|
1464
1468
|
await generate({
|
|
1465
1469
|
input,
|
|
1466
1470
|
config,
|
|
1467
1471
|
logLevel,
|
|
1468
1472
|
events
|
|
1469
1473
|
});
|
|
1470
|
-
_clack_prompts.log.step(
|
|
1474
|
+
_clack_prompts.log.step((0, node_util.styleText)("yellow", `Watching for changes in ${paths.join(" and ")}`));
|
|
1471
1475
|
});
|
|
1472
1476
|
return;
|
|
1473
1477
|
}
|
|
@@ -1487,8 +1491,7 @@ const command = (0, citty.defineCommand)({
|
|
|
1487
1491
|
}
|
|
1488
1492
|
}
|
|
1489
1493
|
});
|
|
1490
|
-
var generate_default = command;
|
|
1491
1494
|
|
|
1492
1495
|
//#endregion
|
|
1493
|
-
exports.default =
|
|
1494
|
-
//# sourceMappingURL=generate-
|
|
1496
|
+
exports.default = command;
|
|
1497
|
+
//# sourceMappingURL=generate-b2shdOTg.cjs.map
|