@kubb/cli 4.12.3 → 4.12.4
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-BnRvfGd7.cjs → generate-C1hm2vvZ.cjs} +118 -118
- package/dist/{generate-BnRvfGd7.cjs.map → generate-C1hm2vvZ.cjs.map} +1 -1
- package/dist/{generate-b1OPOn10.js → generate-C7IfJXyC.js} +2 -2
- package/dist/{generate-b1OPOn10.js.map → generate-C7IfJXyC.js.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/{package-CMcNxxJL.cjs → package-DI-gizpt.cjs} +2 -2
- package/dist/package-DI-gizpt.cjs.map +1 -0
- package/dist/package-GRapUKbG.js +6 -0
- package/dist/package-GRapUKbG.js.map +1 -0
- package/package.json +4 -4
- package/dist/package-B2TE8So1.js +0 -6
- package/dist/package-B2TE8So1.js.map +0 -1
- package/dist/package-CMcNxxJL.cjs.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
-
const require_package = require('./package-
|
|
2
|
+
const require_package = require('./package-DI-gizpt.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
|
|
9
|
-
|
|
10
|
-
let
|
|
11
|
-
let
|
|
8
|
+
let _clack_prompts = require("@clack/prompts");
|
|
9
|
+
_clack_prompts = require_chunk.__toESM(_clack_prompts);
|
|
10
|
+
let _kubb_core = require("@kubb/core");
|
|
11
|
+
let _kubb_core_utils = require("@kubb/core/utils");
|
|
12
12
|
let latest_version = require("latest-version");
|
|
13
13
|
latest_version = require_chunk.__toESM(latest_version);
|
|
14
14
|
let picocolors = require("picocolors");
|
|
@@ -20,7 +20,7 @@ gradient_string = require_chunk.__toESM(gradient_string);
|
|
|
20
20
|
let seedrandom = require("seedrandom");
|
|
21
21
|
seedrandom = require_chunk.__toESM(seedrandom);
|
|
22
22
|
let node_stream = require("node:stream");
|
|
23
|
-
let
|
|
23
|
+
let _kubb_core_fs = require("@kubb/core/fs");
|
|
24
24
|
let string_argv = require("string-argv");
|
|
25
25
|
let cosmiconfig = require("cosmiconfig");
|
|
26
26
|
let jiti = require("jiti");
|
|
@@ -118,15 +118,15 @@ var ClackWritable = class extends node_stream.Writable {
|
|
|
118
118
|
* Clack adapter for local TTY environments
|
|
119
119
|
* Provides a beautiful CLI UI with flat structure inspired by Claude's CLI patterns
|
|
120
120
|
*/
|
|
121
|
-
const clackLogger = (0,
|
|
121
|
+
const clackLogger = (0, _kubb_core.defineLogger)({
|
|
122
122
|
name: "clack",
|
|
123
123
|
install(context, options) {
|
|
124
|
-
const logLevel = options?.logLevel ||
|
|
124
|
+
const logLevel = options?.logLevel || _kubb_core.LogLevel.info;
|
|
125
125
|
const activeProgress = /* @__PURE__ */ new Map();
|
|
126
|
-
const spinner =
|
|
126
|
+
const spinner = _clack_prompts.spinner();
|
|
127
127
|
let isSpinning = false;
|
|
128
128
|
function getMessage(message) {
|
|
129
|
-
if (logLevel >=
|
|
129
|
+
if (logLevel >= _kubb_core.LogLevel.verbose) {
|
|
130
130
|
const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
131
131
|
hour12: false,
|
|
132
132
|
hour: "2-digit",
|
|
@@ -146,52 +146,52 @@ const clackLogger = (0, __kubb_core.defineLogger)({
|
|
|
146
146
|
isSpinning = false;
|
|
147
147
|
}
|
|
148
148
|
context.on("info", (message, info = "") => {
|
|
149
|
-
if (logLevel <=
|
|
149
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
150
150
|
const text = getMessage([
|
|
151
151
|
picocolors.default.blue("ℹ"),
|
|
152
152
|
message,
|
|
153
153
|
picocolors.default.dim(info)
|
|
154
154
|
].join(" "));
|
|
155
155
|
if (isSpinning) spinner.message(text);
|
|
156
|
-
else
|
|
156
|
+
else _clack_prompts.log.info(text);
|
|
157
157
|
});
|
|
158
158
|
context.on("success", (message, info = "") => {
|
|
159
|
-
if (logLevel <=
|
|
159
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
160
160
|
const text = getMessage([
|
|
161
161
|
picocolors.default.blue("✓"),
|
|
162
162
|
message,
|
|
163
|
-
logLevel >=
|
|
163
|
+
logLevel >= _kubb_core.LogLevel.info ? picocolors.default.dim(info) : void 0
|
|
164
164
|
].filter(Boolean).join(" "));
|
|
165
165
|
if (isSpinning) stopSpinner(text);
|
|
166
|
-
else
|
|
166
|
+
else _clack_prompts.log.success(text);
|
|
167
167
|
});
|
|
168
168
|
context.on("warn", (message, info) => {
|
|
169
|
-
if (logLevel <
|
|
169
|
+
if (logLevel < _kubb_core.LogLevel.warn) return;
|
|
170
170
|
const text = getMessage([
|
|
171
171
|
picocolors.default.yellow("⚠"),
|
|
172
172
|
message,
|
|
173
|
-
logLevel >=
|
|
173
|
+
logLevel >= _kubb_core.LogLevel.info ? picocolors.default.dim(info) : void 0
|
|
174
174
|
].filter(Boolean).join(" "));
|
|
175
|
-
|
|
175
|
+
_clack_prompts.log.warn(text);
|
|
176
176
|
});
|
|
177
177
|
context.on("error", (error) => {
|
|
178
178
|
const caused = error.cause;
|
|
179
179
|
const text = [picocolors.default.red("✗"), error.message].join(" ");
|
|
180
180
|
if (isSpinning) stopSpinner(getMessage(text));
|
|
181
|
-
else
|
|
182
|
-
if (logLevel >=
|
|
181
|
+
else _clack_prompts.log.error(getMessage(text));
|
|
182
|
+
if (logLevel >= _kubb_core.LogLevel.debug && error.stack) {
|
|
183
183
|
const frames = error.stack.split("\n").slice(1, 4);
|
|
184
|
-
for (const frame of frames)
|
|
184
|
+
for (const frame of frames) _clack_prompts.log.message(getMessage(picocolors.default.dim(frame.trim())));
|
|
185
185
|
if (caused?.stack) {
|
|
186
|
-
|
|
186
|
+
_clack_prompts.log.message(picocolors.default.dim(`└─ caused by ${caused.message}`));
|
|
187
187
|
const frames$1 = caused.stack.split("\n").slice(1, 4);
|
|
188
|
-
for (const frame of frames$1)
|
|
188
|
+
for (const frame of frames$1) _clack_prompts.log.message(getMessage(` ${picocolors.default.dim(frame.trim())}`));
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
});
|
|
192
192
|
context.on("version:new", (version$1, latestVersion) => {
|
|
193
|
-
if (logLevel <=
|
|
194
|
-
|
|
193
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
194
|
+
_clack_prompts.box(`\`v${version$1}\` → \`v${latestVersion}\`
|
|
195
195
|
Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
196
196
|
width: "auto",
|
|
197
197
|
formatBorder: picocolors.default.yellow,
|
|
@@ -209,24 +209,24 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
209
209
|
])(`Kubb ${version$1} 🧩`));
|
|
210
210
|
});
|
|
211
211
|
context.on("config:start", () => {
|
|
212
|
-
if (logLevel <=
|
|
212
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
213
213
|
const text = getMessage("Configuration started");
|
|
214
|
-
|
|
214
|
+
_clack_prompts.intro(text);
|
|
215
215
|
startSpinner(getMessage("Configuration loading"));
|
|
216
216
|
});
|
|
217
217
|
context.on("config:end", () => {
|
|
218
|
-
if (logLevel <=
|
|
218
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
219
219
|
const text = getMessage("Configuration completed");
|
|
220
|
-
|
|
220
|
+
_clack_prompts.outro(text);
|
|
221
221
|
});
|
|
222
222
|
context.on("generation:start", (config) => {
|
|
223
223
|
const text = getMessage(["Generation started", config.name ? `for ${picocolors.default.dim(config.name)}` : void 0].filter(Boolean).join(" "));
|
|
224
|
-
|
|
224
|
+
_clack_prompts.intro(text);
|
|
225
225
|
});
|
|
226
226
|
context.on("plugin:start", (plugin) => {
|
|
227
|
-
if (logLevel <=
|
|
227
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
228
228
|
stopSpinner();
|
|
229
|
-
const progressBar =
|
|
229
|
+
const progressBar = _clack_prompts.progress({
|
|
230
230
|
style: "block",
|
|
231
231
|
max: 100,
|
|
232
232
|
size: 30
|
|
@@ -244,7 +244,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
244
244
|
context.on("plugin:end", (plugin, duration) => {
|
|
245
245
|
stopSpinner();
|
|
246
246
|
const active = activeProgress.get(plugin.name);
|
|
247
|
-
if (!active || logLevel ===
|
|
247
|
+
if (!active || logLevel === _kubb_core.LogLevel.silent) return;
|
|
248
248
|
clearInterval(active.interval);
|
|
249
249
|
const durationStr = duration >= 1e3 ? `${(duration / 1e3).toFixed(2)}s` : `${duration}ms`;
|
|
250
250
|
const text = getMessage(`${picocolors.default.bold(plugin.name)} completed in ${picocolors.default.green(durationStr)}`);
|
|
@@ -252,10 +252,10 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
252
252
|
activeProgress.delete(plugin.name);
|
|
253
253
|
});
|
|
254
254
|
context.on("files:processing:start", (files) => {
|
|
255
|
-
if (logLevel <=
|
|
255
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
256
256
|
stopSpinner();
|
|
257
257
|
const text = `Writing ${files.length} files`;
|
|
258
|
-
const progressBar =
|
|
258
|
+
const progressBar = _clack_prompts.progress({
|
|
259
259
|
style: "block",
|
|
260
260
|
max: files.length,
|
|
261
261
|
size: 30
|
|
@@ -265,7 +265,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
265
265
|
activeProgress.set("files", { progressBar });
|
|
266
266
|
});
|
|
267
267
|
context.on("file:processing:update", ({ file, config }) => {
|
|
268
|
-
if (logLevel <=
|
|
268
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
269
269
|
stopSpinner();
|
|
270
270
|
const text = `Writing ${(0, node_path.relative)(config.root, file.path)}`;
|
|
271
271
|
const active = activeProgress.get("files");
|
|
@@ -273,7 +273,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
273
273
|
active.progressBar.advance(void 0, text);
|
|
274
274
|
});
|
|
275
275
|
context.on("files:processing:end", () => {
|
|
276
|
-
if (logLevel <=
|
|
276
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
277
277
|
stopSpinner();
|
|
278
278
|
const text = getMessage("Files written successfully");
|
|
279
279
|
const active = activeProgress.get("files");
|
|
@@ -283,10 +283,10 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
283
283
|
});
|
|
284
284
|
context.on("generation:end", (config) => {
|
|
285
285
|
const text = getMessage(config.name ? `Generation completed for ${picocolors.default.dim(config.name)}` : "Generation completed");
|
|
286
|
-
|
|
286
|
+
_clack_prompts.outro(text);
|
|
287
287
|
});
|
|
288
288
|
context.on("hook:execute", async ({ command: command$1, args }, cb) => {
|
|
289
|
-
if (logLevel <=
|
|
289
|
+
if (logLevel <= _kubb_core.LogLevel.silent) {
|
|
290
290
|
try {
|
|
291
291
|
const result = await (0, execa.execa)(command$1, args, {
|
|
292
292
|
detached: true,
|
|
@@ -308,7 +308,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
308
308
|
}
|
|
309
309
|
return;
|
|
310
310
|
}
|
|
311
|
-
const writable = new ClackWritable(
|
|
311
|
+
const writable = new ClackWritable(_clack_prompts.taskLog({ title: getMessage(["Executing hook", logLevel >= _kubb_core.LogLevel.info ? picocolors.default.dim(`${command$1} ${args?.join(" ")}`) : void 0].filter(Boolean).join(" ")) }));
|
|
312
312
|
try {
|
|
313
313
|
const result = await (0, execa.execa)(command$1, args, {
|
|
314
314
|
detached: true,
|
|
@@ -331,34 +331,34 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
331
331
|
}
|
|
332
332
|
});
|
|
333
333
|
context.on("format:start", () => {
|
|
334
|
-
if (logLevel <=
|
|
334
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
335
335
|
const text = getMessage("Format started");
|
|
336
|
-
|
|
336
|
+
_clack_prompts.intro(text);
|
|
337
337
|
});
|
|
338
338
|
context.on("format:end", () => {
|
|
339
|
-
if (logLevel <=
|
|
339
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
340
340
|
const text = getMessage("Format completed");
|
|
341
|
-
|
|
341
|
+
_clack_prompts.outro(text);
|
|
342
342
|
});
|
|
343
343
|
context.on("lint:start", () => {
|
|
344
|
-
if (logLevel <=
|
|
344
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
345
345
|
const text = getMessage("Lint started");
|
|
346
|
-
|
|
346
|
+
_clack_prompts.intro(text);
|
|
347
347
|
});
|
|
348
348
|
context.on("lint:end", () => {
|
|
349
|
-
if (logLevel <=
|
|
349
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
350
350
|
const text = getMessage("Lint completed");
|
|
351
|
-
|
|
351
|
+
_clack_prompts.outro(text);
|
|
352
352
|
});
|
|
353
353
|
context.on("hook:start", (command$1) => {
|
|
354
|
-
if (logLevel <=
|
|
354
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
355
355
|
const text = getMessage(`Hook ${picocolors.default.dim(command$1)} started`);
|
|
356
|
-
|
|
356
|
+
_clack_prompts.intro(text);
|
|
357
357
|
});
|
|
358
358
|
context.on("hook:end", (command$1) => {
|
|
359
|
-
if (logLevel <=
|
|
359
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
360
360
|
const text = getMessage(`Hook ${picocolors.default.dim(command$1)} completed`);
|
|
361
|
-
|
|
361
|
+
_clack_prompts.outro(text);
|
|
362
362
|
});
|
|
363
363
|
context.on("generation:summary", (config, { pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
|
|
364
364
|
const summary = getSummary({
|
|
@@ -367,13 +367,13 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
367
367
|
config,
|
|
368
368
|
status,
|
|
369
369
|
hrStart,
|
|
370
|
-
pluginTimings: logLevel >=
|
|
370
|
+
pluginTimings: logLevel >= _kubb_core.LogLevel.verbose ? pluginTimings : void 0
|
|
371
371
|
});
|
|
372
372
|
const title = config.name || "";
|
|
373
373
|
summary.unshift("\n");
|
|
374
374
|
summary.push("\n");
|
|
375
375
|
if (status === "success") {
|
|
376
|
-
|
|
376
|
+
_clack_prompts.box(summary.join("\n"), getMessage(title), {
|
|
377
377
|
width: "auto",
|
|
378
378
|
formatBorder: picocolors.default.green,
|
|
379
379
|
rounded: true,
|
|
@@ -383,7 +383,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
383
383
|
});
|
|
384
384
|
return;
|
|
385
385
|
}
|
|
386
|
-
|
|
386
|
+
_clack_prompts.box(summary.join("\n"), getMessage(title), {
|
|
387
387
|
width: "auto",
|
|
388
388
|
formatBorder: picocolors.default.red,
|
|
389
389
|
rounded: true,
|
|
@@ -432,7 +432,7 @@ function canUseTTY() {
|
|
|
432
432
|
* Note: Logs are written on lifecycle:end or process exit. If the process crashes
|
|
433
433
|
* before these events, some cached logs may be lost.
|
|
434
434
|
*/
|
|
435
|
-
const fileSystemLogger = (0,
|
|
435
|
+
const fileSystemLogger = (0, _kubb_core.defineLogger)({
|
|
436
436
|
name: "filesystem",
|
|
437
437
|
install(context) {
|
|
438
438
|
const cachedLogs = /* @__PURE__ */ new Set();
|
|
@@ -449,7 +449,7 @@ const fileSystemLogger = (0, __kubb_core.defineLogger)({
|
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
451
|
await Promise.all(Object.entries(files).map(async ([fileName, logs]) => {
|
|
452
|
-
return (0,
|
|
452
|
+
return (0, _kubb_core_fs.write)(fileName, logs.join("\n\n"));
|
|
453
453
|
}));
|
|
454
454
|
cachedLogs.clear();
|
|
455
455
|
}
|
|
@@ -478,13 +478,13 @@ const fileSystemLogger = (0, __kubb_core.defineLogger)({
|
|
|
478
478
|
* GitHub Actions adapter for CI environments
|
|
479
479
|
* Uses ::group:: and ::endgroup:: annotations for collapsible sections
|
|
480
480
|
*/
|
|
481
|
-
const githubActionsLogger = (0,
|
|
481
|
+
const githubActionsLogger = (0, _kubb_core.defineLogger)({
|
|
482
482
|
name: "github-actions",
|
|
483
483
|
install(context, options) {
|
|
484
|
-
const logLevel = options?.logLevel ||
|
|
484
|
+
const logLevel = options?.logLevel || _kubb_core.LogLevel.info;
|
|
485
485
|
let currentConfigs = [];
|
|
486
486
|
function getMessage(message) {
|
|
487
|
-
if (logLevel >=
|
|
487
|
+
if (logLevel >= _kubb_core.LogLevel.verbose) {
|
|
488
488
|
const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
489
489
|
hour12: false,
|
|
490
490
|
hour: "2-digit",
|
|
@@ -502,7 +502,7 @@ const githubActionsLogger = (0, __kubb_core.defineLogger)({
|
|
|
502
502
|
console.log("::endgroup::");
|
|
503
503
|
}
|
|
504
504
|
context.on("info", (message, info = "") => {
|
|
505
|
-
if (logLevel <=
|
|
505
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
506
506
|
const text = getMessage([
|
|
507
507
|
picocolors.default.blue("ℹ"),
|
|
508
508
|
message,
|
|
@@ -511,25 +511,25 @@ const githubActionsLogger = (0, __kubb_core.defineLogger)({
|
|
|
511
511
|
console.log(text);
|
|
512
512
|
});
|
|
513
513
|
context.on("success", (message, info = "") => {
|
|
514
|
-
if (logLevel <=
|
|
514
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
515
515
|
const text = getMessage([
|
|
516
516
|
picocolors.default.blue("✓"),
|
|
517
517
|
message,
|
|
518
|
-
logLevel >=
|
|
518
|
+
logLevel >= _kubb_core.LogLevel.info ? picocolors.default.dim(info) : void 0
|
|
519
519
|
].filter(Boolean).join(" "));
|
|
520
520
|
console.log(text);
|
|
521
521
|
});
|
|
522
522
|
context.on("warn", (message, info = "") => {
|
|
523
|
-
if (logLevel <=
|
|
523
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
524
524
|
const text = getMessage([
|
|
525
525
|
picocolors.default.yellow("⚠"),
|
|
526
526
|
message,
|
|
527
|
-
logLevel >=
|
|
527
|
+
logLevel >= _kubb_core.LogLevel.info ? picocolors.default.dim(info) : void 0
|
|
528
528
|
].filter(Boolean).join(" "));
|
|
529
529
|
console.warn(`::warning::${text}`);
|
|
530
530
|
});
|
|
531
531
|
context.on("error", (error) => {
|
|
532
|
-
if (logLevel <=
|
|
532
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
533
533
|
const message = error.message || String(error);
|
|
534
534
|
console.error(`::error::${message}`);
|
|
535
535
|
});
|
|
@@ -537,14 +537,14 @@ const githubActionsLogger = (0, __kubb_core.defineLogger)({
|
|
|
537
537
|
console.log(picocolors.default.yellow(`Kubb ${version$1} 🧩`));
|
|
538
538
|
});
|
|
539
539
|
context.on("config:start", () => {
|
|
540
|
-
if (logLevel <=
|
|
540
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
541
541
|
const text = getMessage("Configuration started");
|
|
542
542
|
openGroup("Configuration");
|
|
543
543
|
console.log(text);
|
|
544
544
|
});
|
|
545
545
|
context.on("config:end", (configs) => {
|
|
546
546
|
currentConfigs = configs;
|
|
547
|
-
if (logLevel <=
|
|
547
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
548
548
|
const text = getMessage("Configuration completed");
|
|
549
549
|
console.log(text);
|
|
550
550
|
closeGroup("Configuration");
|
|
@@ -555,13 +555,13 @@ const githubActionsLogger = (0, __kubb_core.defineLogger)({
|
|
|
555
555
|
if (currentConfigs.length === 1) console.log(getMessage(text));
|
|
556
556
|
});
|
|
557
557
|
context.on("plugin:start", (plugin) => {
|
|
558
|
-
if (logLevel <=
|
|
558
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
559
559
|
const text = getMessage(`Generating ${picocolors.default.bold(plugin.name)}`);
|
|
560
560
|
if (currentConfigs.length === 1) openGroup(`Plugin: ${plugin.name}`);
|
|
561
561
|
console.log(text);
|
|
562
562
|
});
|
|
563
563
|
context.on("plugin:end", (plugin, duration) => {
|
|
564
|
-
if (logLevel <=
|
|
564
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
565
565
|
const durationStr = duration >= 1e3 ? `${(duration / 1e3).toFixed(2)}s` : `${duration}ms`;
|
|
566
566
|
const text = getMessage(`${picocolors.default.bold(plugin.name)} completed in ${picocolors.default.green(durationStr)}`);
|
|
567
567
|
console.log(text);
|
|
@@ -569,13 +569,13 @@ const githubActionsLogger = (0, __kubb_core.defineLogger)({
|
|
|
569
569
|
if (currentConfigs.length === 1) closeGroup(`Plugin: ${plugin.name}`);
|
|
570
570
|
});
|
|
571
571
|
context.on("files:processing:start", (files) => {
|
|
572
|
-
if (logLevel <=
|
|
572
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
573
573
|
if (currentConfigs.length === 1) openGroup("File Generation");
|
|
574
574
|
const text = getMessage(`Writing ${files.length} files`);
|
|
575
575
|
console.log(text);
|
|
576
576
|
});
|
|
577
577
|
context.on("files:processing:end", () => {
|
|
578
|
-
if (logLevel <=
|
|
578
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
579
579
|
const text = getMessage("Files written successfully");
|
|
580
580
|
console.log(text);
|
|
581
581
|
if (currentConfigs.length === 1) closeGroup("File Generation");
|
|
@@ -607,37 +607,37 @@ const githubActionsLogger = (0, __kubb_core.defineLogger)({
|
|
|
607
607
|
}
|
|
608
608
|
});
|
|
609
609
|
context.on("format:start", () => {
|
|
610
|
-
if (logLevel <=
|
|
610
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
611
611
|
const text = getMessage("Format started");
|
|
612
612
|
if (currentConfigs.length === 1) openGroup("Formatting");
|
|
613
613
|
console.log(text);
|
|
614
614
|
});
|
|
615
615
|
context.on("format:end", () => {
|
|
616
|
-
if (logLevel <=
|
|
616
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
617
617
|
const text = getMessage("Format completed");
|
|
618
618
|
console.log(text);
|
|
619
619
|
if (currentConfigs.length === 1) closeGroup("Formatting");
|
|
620
620
|
});
|
|
621
621
|
context.on("lint:start", () => {
|
|
622
|
-
if (logLevel <=
|
|
622
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
623
623
|
const text = getMessage("Lint started");
|
|
624
624
|
if (currentConfigs.length === 1) openGroup("Linting");
|
|
625
625
|
console.log(text);
|
|
626
626
|
});
|
|
627
627
|
context.on("lint:end", () => {
|
|
628
|
-
if (logLevel <=
|
|
628
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
629
629
|
const text = getMessage("Lint completed");
|
|
630
630
|
console.log(text);
|
|
631
631
|
if (currentConfigs.length === 1) closeGroup("Linting");
|
|
632
632
|
});
|
|
633
633
|
context.on("hook:start", (command$1) => {
|
|
634
|
-
if (logLevel <=
|
|
634
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
635
635
|
const text = getMessage(`Hook ${picocolors.default.dim(command$1)} started`);
|
|
636
636
|
if (currentConfigs.length === 1) openGroup(`Hook ${command$1}`);
|
|
637
637
|
console.log(text);
|
|
638
638
|
});
|
|
639
639
|
context.on("hook:end", (command$1) => {
|
|
640
|
-
if (logLevel <=
|
|
640
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
641
641
|
const text = getMessage(`Hook ${picocolors.default.dim(command$1)} completed`);
|
|
642
642
|
console.log(text);
|
|
643
643
|
if (currentConfigs.length === 1) closeGroup(`Hook ${command$1}`);
|
|
@@ -658,12 +658,12 @@ const githubActionsLogger = (0, __kubb_core.defineLogger)({
|
|
|
658
658
|
* Plain console adapter for non-TTY environments
|
|
659
659
|
* Simple console.log output with indentation
|
|
660
660
|
*/
|
|
661
|
-
const plainLogger = (0,
|
|
661
|
+
const plainLogger = (0, _kubb_core.defineLogger)({
|
|
662
662
|
name: "plain",
|
|
663
663
|
install(context, options) {
|
|
664
664
|
const logLevel = options?.logLevel || 3;
|
|
665
665
|
function getMessage(message) {
|
|
666
|
-
if (logLevel >=
|
|
666
|
+
if (logLevel >= _kubb_core.LogLevel.verbose) return [`[${(/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
667
667
|
hour12: false,
|
|
668
668
|
hour: "2-digit",
|
|
669
669
|
minute: "2-digit",
|
|
@@ -672,7 +672,7 @@ const plainLogger = (0, __kubb_core.defineLogger)({
|
|
|
672
672
|
return message;
|
|
673
673
|
}
|
|
674
674
|
context.on("info", (message, info) => {
|
|
675
|
-
if (logLevel <=
|
|
675
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
676
676
|
const text = getMessage([
|
|
677
677
|
"ℹ",
|
|
678
678
|
message,
|
|
@@ -681,20 +681,20 @@ const plainLogger = (0, __kubb_core.defineLogger)({
|
|
|
681
681
|
console.log(text);
|
|
682
682
|
});
|
|
683
683
|
context.on("success", (message, info = "") => {
|
|
684
|
-
if (logLevel <=
|
|
684
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
685
685
|
const text = getMessage([
|
|
686
686
|
"✓",
|
|
687
687
|
message,
|
|
688
|
-
logLevel >=
|
|
688
|
+
logLevel >= _kubb_core.LogLevel.info ? info : void 0
|
|
689
689
|
].filter(Boolean).join(" "));
|
|
690
690
|
console.log(text);
|
|
691
691
|
});
|
|
692
692
|
context.on("warn", (message, info) => {
|
|
693
|
-
if (logLevel <
|
|
693
|
+
if (logLevel < _kubb_core.LogLevel.warn) return;
|
|
694
694
|
const text = getMessage([
|
|
695
695
|
"⚠",
|
|
696
696
|
message,
|
|
697
|
-
logLevel >=
|
|
697
|
+
logLevel >= _kubb_core.LogLevel.info ? info : void 0
|
|
698
698
|
].filter(Boolean).join(" "));
|
|
699
699
|
console.log(text);
|
|
700
700
|
});
|
|
@@ -702,7 +702,7 @@ const plainLogger = (0, __kubb_core.defineLogger)({
|
|
|
702
702
|
const caused = error.cause;
|
|
703
703
|
const text = getMessage(["✗", error.message].join(" "));
|
|
704
704
|
console.log(text);
|
|
705
|
-
if (logLevel >=
|
|
705
|
+
if (logLevel >= _kubb_core.LogLevel.debug && error.stack) {
|
|
706
706
|
const frames = error.stack.split("\n").slice(1, 4);
|
|
707
707
|
for (const frame of frames) console.log(getMessage(frame.trim()));
|
|
708
708
|
if (caused?.stack) {
|
|
@@ -716,12 +716,12 @@ const plainLogger = (0, __kubb_core.defineLogger)({
|
|
|
716
716
|
console.log("Kubb CLI 🧩");
|
|
717
717
|
});
|
|
718
718
|
context.on("config:start", () => {
|
|
719
|
-
if (logLevel <=
|
|
719
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
720
720
|
const text = getMessage("Configuration started");
|
|
721
721
|
console.log(text);
|
|
722
722
|
});
|
|
723
723
|
context.on("config:end", () => {
|
|
724
|
-
if (logLevel <=
|
|
724
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
725
725
|
const text = getMessage("Configuration completed");
|
|
726
726
|
console.log(text);
|
|
727
727
|
});
|
|
@@ -730,28 +730,28 @@ const plainLogger = (0, __kubb_core.defineLogger)({
|
|
|
730
730
|
console.log(text);
|
|
731
731
|
});
|
|
732
732
|
context.on("plugin:start", (plugin) => {
|
|
733
|
-
if (logLevel <=
|
|
733
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
734
734
|
const text = getMessage(`Generating ${plugin.name}`);
|
|
735
735
|
console.log(text);
|
|
736
736
|
});
|
|
737
737
|
context.on("plugin:end", (plugin, duration) => {
|
|
738
|
-
if (logLevel <=
|
|
738
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
739
739
|
const durationStr = duration >= 1e3 ? `${(duration / 1e3).toFixed(2)}s` : `${duration}ms`;
|
|
740
740
|
const text = getMessage(`${plugin.name} completed in ${durationStr}`);
|
|
741
741
|
console.log(text);
|
|
742
742
|
});
|
|
743
743
|
context.on("files:processing:start", (files) => {
|
|
744
|
-
if (logLevel <=
|
|
744
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
745
745
|
const text = getMessage(`Writing ${files.length} files`);
|
|
746
746
|
console.log(text);
|
|
747
747
|
});
|
|
748
748
|
context.on("file:processing:update", ({ file, config }) => {
|
|
749
|
-
if (logLevel <=
|
|
749
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
750
750
|
const text = getMessage(`Writing ${(0, node_path.relative)(config.root, file.path)}`);
|
|
751
751
|
console.log(text);
|
|
752
752
|
});
|
|
753
753
|
context.on("files:processing:end", () => {
|
|
754
|
-
if (logLevel <=
|
|
754
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
755
755
|
const text = getMessage("Files written successfully");
|
|
756
756
|
console.log(text);
|
|
757
757
|
});
|
|
@@ -782,32 +782,32 @@ const plainLogger = (0, __kubb_core.defineLogger)({
|
|
|
782
782
|
}
|
|
783
783
|
});
|
|
784
784
|
context.on("format:start", () => {
|
|
785
|
-
if (logLevel <=
|
|
785
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
786
786
|
const text = getMessage("Format started");
|
|
787
787
|
console.log(text);
|
|
788
788
|
});
|
|
789
789
|
context.on("format:end", () => {
|
|
790
|
-
if (logLevel <=
|
|
790
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
791
791
|
const text = getMessage("Format completed");
|
|
792
792
|
console.log(text);
|
|
793
793
|
});
|
|
794
794
|
context.on("lint:start", () => {
|
|
795
|
-
if (logLevel <=
|
|
795
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
796
796
|
const text = getMessage("Lint started");
|
|
797
797
|
console.log(text);
|
|
798
798
|
});
|
|
799
799
|
context.on("lint:end", () => {
|
|
800
|
-
if (logLevel <=
|
|
800
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
801
801
|
const text = getMessage("Lint completed");
|
|
802
802
|
console.log(text);
|
|
803
803
|
});
|
|
804
804
|
context.on("hook:start", (command$1) => {
|
|
805
|
-
if (logLevel <=
|
|
805
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
806
806
|
const text = getMessage(`Hook ${command$1} started`);
|
|
807
807
|
console.log(text);
|
|
808
808
|
});
|
|
809
809
|
context.on("hook:end", (command$1) => {
|
|
810
|
-
if (logLevel <=
|
|
810
|
+
if (logLevel <= _kubb_core.LogLevel.silent) return;
|
|
811
811
|
const text = getMessage(`Hook ${command$1} completed`);
|
|
812
812
|
console.log(text);
|
|
813
813
|
});
|
|
@@ -818,7 +818,7 @@ const plainLogger = (0, __kubb_core.defineLogger)({
|
|
|
818
818
|
config,
|
|
819
819
|
status,
|
|
820
820
|
hrStart,
|
|
821
|
-
pluginTimings: logLevel >=
|
|
821
|
+
pluginTimings: logLevel >= _kubb_core.LogLevel.verbose ? pluginTimings : void 0
|
|
822
822
|
});
|
|
823
823
|
console.log("---------------------------");
|
|
824
824
|
console.log(summary.join("\n"));
|
|
@@ -844,7 +844,7 @@ async function setupLogger(context, { logLevel }) {
|
|
|
844
844
|
const logger = logMapper[type];
|
|
845
845
|
if (!logger) throw new Error(`Unknown adapter type: ${type}`);
|
|
846
846
|
const cleanup = await logger.install(context, { logLevel });
|
|
847
|
-
if (logLevel >=
|
|
847
|
+
if (logLevel >= _kubb_core.LogLevel.debug) await fileSystemLogger.install(context, { logLevel });
|
|
848
848
|
return cleanup;
|
|
849
849
|
}
|
|
850
850
|
|
|
@@ -889,12 +889,12 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
889
889
|
};
|
|
890
890
|
await events.emit("generation:start", definedConfig);
|
|
891
891
|
await events.emit("info", config.name ? `Setup generation ${picocolors.default.bold(config.name)}` : "Setup generation", inputPath);
|
|
892
|
-
const { fabric, pluginManager } = await (0,
|
|
892
|
+
const { fabric, pluginManager } = await (0, _kubb_core.setup)({
|
|
893
893
|
config: definedConfig,
|
|
894
894
|
events
|
|
895
895
|
});
|
|
896
896
|
await events.emit("info", config.name ? `Build generation ${picocolors.default.bold(config.name)}` : "Build generation", inputPath);
|
|
897
|
-
const { files, failedPlugins, pluginTimings, error } = await (0,
|
|
897
|
+
const { files, failedPlugins, pluginTimings, error } = await (0, _kubb_core.safeBuild)({
|
|
898
898
|
config: definedConfig,
|
|
899
899
|
events
|
|
900
900
|
}, {
|
|
@@ -913,7 +913,7 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
913
913
|
filesCreated: files.length,
|
|
914
914
|
status: failedPlugins.size > 0 || error ? "failed" : "success",
|
|
915
915
|
hrStart,
|
|
916
|
-
pluginTimings: logLevel >=
|
|
916
|
+
pluginTimings: logLevel >= _kubb_core.LogLevel.verbose ? pluginTimings : void 0
|
|
917
917
|
});
|
|
918
918
|
node_process.default.exit(1);
|
|
919
919
|
}
|
|
@@ -921,7 +921,7 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
921
921
|
await events.emit("generation:end", definedConfig);
|
|
922
922
|
if (config.output.format) {
|
|
923
923
|
await events.emit("format:start");
|
|
924
|
-
await events.emit("info", [`Formatting with ${picocolors.default.dim(config.output.format)}`, logLevel >=
|
|
924
|
+
await events.emit("info", [`Formatting with ${picocolors.default.dim(config.output.format)}`, logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0].filter(Boolean).join(" "));
|
|
925
925
|
if (config.output.format === "prettier") {
|
|
926
926
|
try {
|
|
927
927
|
await events.emit("hook:execute", {
|
|
@@ -934,7 +934,7 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
934
934
|
}, async () => {
|
|
935
935
|
await events.emit("success", [
|
|
936
936
|
`Formatting with ${picocolors.default.dim(config.output.format)}`,
|
|
937
|
-
logLevel >=
|
|
937
|
+
logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
|
|
938
938
|
"successfully"
|
|
939
939
|
].filter(Boolean).join(" "));
|
|
940
940
|
});
|
|
@@ -954,7 +954,7 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
954
954
|
}, async () => {
|
|
955
955
|
await events.emit("success", [
|
|
956
956
|
`Formatting with ${picocolors.default.dim(config.output.format)}`,
|
|
957
|
-
logLevel >=
|
|
957
|
+
logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
|
|
958
958
|
"successfully"
|
|
959
959
|
].filter(Boolean).join(" "));
|
|
960
960
|
});
|
|
@@ -967,7 +967,7 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
967
967
|
}
|
|
968
968
|
if (config.output.lint) {
|
|
969
969
|
await events.emit("lint:start");
|
|
970
|
-
await events.emit("info", [`Linting with ${picocolors.default.dim(config.output.lint)}`, logLevel >=
|
|
970
|
+
await events.emit("info", [`Linting with ${picocolors.default.dim(config.output.lint)}`, logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0].filter(Boolean).join(" "));
|
|
971
971
|
if (config.output.lint === "eslint") try {
|
|
972
972
|
await events.emit("hook:execute", {
|
|
973
973
|
command: "eslint",
|
|
@@ -975,7 +975,7 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
975
975
|
}, async () => {
|
|
976
976
|
await events.emit("success", [
|
|
977
977
|
`Linted with ${picocolors.default.dim(config.output.lint)}`,
|
|
978
|
-
logLevel >=
|
|
978
|
+
logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
|
|
979
979
|
"successfully"
|
|
980
980
|
].filter(Boolean).join(" "));
|
|
981
981
|
});
|
|
@@ -995,7 +995,7 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
995
995
|
}, async () => {
|
|
996
996
|
await events.emit("success", [
|
|
997
997
|
`Linted with ${picocolors.default.dim(config.output.lint)}`,
|
|
998
|
-
logLevel >=
|
|
998
|
+
logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
|
|
999
999
|
"successfully"
|
|
1000
1000
|
].filter(Boolean).join(" "));
|
|
1001
1001
|
});
|
|
@@ -1011,7 +1011,7 @@ async function generate({ input, config, events, logLevel }) {
|
|
|
1011
1011
|
}, async () => {
|
|
1012
1012
|
await events.emit("success", [
|
|
1013
1013
|
`Linted with ${picocolors.default.dim(config.output.lint)}`,
|
|
1014
|
-
logLevel >=
|
|
1014
|
+
logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(definedConfig.root, definedConfig.output.path))}` : void 0,
|
|
1015
1015
|
"successfully"
|
|
1016
1016
|
].filter(Boolean).join(" "));
|
|
1017
1017
|
});
|
|
@@ -1065,7 +1065,7 @@ async function getConfig(result, args) {
|
|
|
1065
1065
|
let kubbUserConfig = Promise.resolve(config);
|
|
1066
1066
|
if (typeof config === "function") {
|
|
1067
1067
|
const possiblePromise = config(args);
|
|
1068
|
-
if ((0,
|
|
1068
|
+
if ((0, _kubb_core_utils.isPromise)(possiblePromise)) kubbUserConfig = possiblePromise;
|
|
1069
1069
|
kubbUserConfig = Promise.resolve(possiblePromise);
|
|
1070
1070
|
}
|
|
1071
1071
|
let JSONConfig = await kubbUserConfig;
|
|
@@ -1202,12 +1202,12 @@ const command = (0, citty.defineCommand)({
|
|
|
1202
1202
|
async run(commandContext) {
|
|
1203
1203
|
const { args } = commandContext;
|
|
1204
1204
|
const input = args._[0];
|
|
1205
|
-
const events = new
|
|
1206
|
-
const promiseManager = new
|
|
1205
|
+
const events = new _kubb_core_utils.AsyncEventEmitter();
|
|
1206
|
+
const promiseManager = new _kubb_core.PromiseManager();
|
|
1207
1207
|
if (args.help) return (0, citty.showUsage)(command);
|
|
1208
1208
|
if (args.debug) args.logLevel = "debug";
|
|
1209
1209
|
if (args.verbose) args.logLevel = "verbose";
|
|
1210
|
-
const logLevel =
|
|
1210
|
+
const logLevel = _kubb_core.LogLevel[args.logLevel] || 3;
|
|
1211
1211
|
await setupLogger(events, { logLevel });
|
|
1212
1212
|
const latestVersion = await (0, latest_version.default)("@kubb/cli");
|
|
1213
1213
|
if ((0, semver.lt)(require_package.version, latestVersion)) await events.emit("version:new", require_package.version, latestVersion);
|
|
@@ -1222,7 +1222,7 @@ const command = (0, citty.defineCommand)({
|
|
|
1222
1222
|
await events.emit("config:end", configs);
|
|
1223
1223
|
const promises = configs.map((config$1) => {
|
|
1224
1224
|
return async () => {
|
|
1225
|
-
if ((0,
|
|
1225
|
+
if ((0, _kubb_core.isInputPath)(config$1) && args.watch) {
|
|
1226
1226
|
await startWatcher([input || config$1.input.path], async (paths) => {
|
|
1227
1227
|
await generate({
|
|
1228
1228
|
input,
|
|
@@ -1230,7 +1230,7 @@ const command = (0, citty.defineCommand)({
|
|
|
1230
1230
|
logLevel,
|
|
1231
1231
|
events
|
|
1232
1232
|
});
|
|
1233
|
-
|
|
1233
|
+
_clack_prompts.log.step(picocolors.default.yellow(`Watching for changes in ${paths.join(" and ")}`));
|
|
1234
1234
|
});
|
|
1235
1235
|
return;
|
|
1236
1236
|
}
|
|
@@ -1253,4 +1253,4 @@ var generate_default = command;
|
|
|
1253
1253
|
|
|
1254
1254
|
//#endregion
|
|
1255
1255
|
exports.default = generate_default;
|
|
1256
|
-
//# sourceMappingURL=generate-
|
|
1256
|
+
//# sourceMappingURL=generate-C1hm2vvZ.cjs.map
|