@kubb/cli 4.33.0 → 4.33.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-CduUX7Ye.cjs → agent-Bd1QdPVV.cjs} +7 -7
- package/dist/agent-Bd1QdPVV.cjs.map +1 -0
- package/dist/{agent-DrnwQBZf.cjs → agent-D83d9Pud.cjs} +7 -7
- package/dist/agent-D83d9Pud.cjs.map +1 -0
- package/dist/{agent-D0A3RQho.js → agent-DgKQXSmR.js} +5 -5
- package/dist/agent-DgKQXSmR.js.map +1 -0
- package/dist/{agent-CJ69TqoO.js → agent-u_Ehwz6r.js} +5 -5
- package/dist/agent-u_Ehwz6r.js.map +1 -0
- package/dist/{constants-CnPOlsJq.cjs → constants-BTUap0zs.cjs} +1 -19
- package/dist/{constants-CnPOlsJq.cjs.map → constants-BTUap0zs.cjs.map} +1 -1
- package/dist/{constants-CEKRremI.js → constants-CM3dJzjK.js} +2 -14
- package/dist/{constants-CEKRremI.js.map → constants-CM3dJzjK.js.map} +1 -1
- package/dist/{types-CLtz0jem.js → define--M_JMcDC.js} +6 -6
- package/dist/define--M_JMcDC.js.map +1 -0
- package/dist/{types-Ck2lzFON.cjs → define-D6Kfm7-Z.cjs} +6 -6
- package/dist/define-D6Kfm7-Z.cjs.map +1 -0
- package/dist/{errors-bSLTEh4e.js → errors-6mF_WKxg.js} +5 -5
- package/dist/errors-6mF_WKxg.js.map +1 -0
- package/dist/{errors-BUjJsNoe.cjs → errors-DBW0N9w4.cjs} +5 -5
- package/dist/errors-DBW0N9w4.cjs.map +1 -0
- package/dist/{generate-CiUPO5ds.cjs → generate-Bn8n4w1O.cjs} +3 -3
- package/dist/generate-Bn8n4w1O.cjs.map +1 -0
- package/dist/{generate-HP5ySfjV.js → generate-CAsV9wSx.js} +271 -149
- package/dist/generate-CAsV9wSx.js.map +1 -0
- package/dist/{generate-DIIxtkWT.js → generate-D-59YK0L.js} +3 -3
- package/dist/generate-D-59YK0L.js.map +1 -0
- package/dist/{generate-ByMgAV76.cjs → generate-JC65igQh.cjs} +275 -153
- package/dist/generate-JC65igQh.cjs.map +1 -0
- package/dist/index.cjs +13 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/{init-DyKK2fTp.js → init-C-InrmSY.js} +42 -31
- package/dist/init-C-InrmSY.js.map +1 -0
- package/dist/{init-DLNrkDF4.js → init-CXP8OfMe.js} +4 -4
- package/dist/init-CXP8OfMe.js.map +1 -0
- package/dist/{init-Df_aXezV.cjs → init-CbeE-L-0.cjs} +5 -4
- package/dist/init-CbeE-L-0.cjs.map +1 -0
- package/dist/{init-Cd1hCb7q.cjs → init-hmolV6B4.cjs} +47 -37
- package/dist/init-hmolV6B4.cjs.map +1 -0
- package/dist/{jiti-BdskUHhD.cjs → jiti-Cd3S0xwr.cjs} +1 -1
- package/dist/{jiti-BdskUHhD.cjs.map → jiti-Cd3S0xwr.cjs.map} +1 -1
- package/dist/{jiti-Cl7t20dO.js → jiti-e08mD2Ph.js} +1 -1
- package/dist/{jiti-Cl7t20dO.js.map → jiti-e08mD2Ph.js.map} +1 -1
- package/dist/{mcp-Clg-Qnkr.cjs → mcp-BDxg2oJm.cjs} +5 -4
- package/dist/mcp-BDxg2oJm.cjs.map +1 -0
- package/dist/{mcp-B73FC8dF.cjs → mcp-ChHFPRzD.cjs} +4 -4
- package/dist/mcp-ChHFPRzD.cjs.map +1 -0
- package/dist/{mcp-Cf-1dsB-.js → mcp-D2SHEg_d.js} +4 -4
- package/dist/mcp-D2SHEg_d.js.map +1 -0
- package/dist/{mcp-Bd9LITaI.js → mcp-MSoE4vNA.js} +4 -4
- package/dist/mcp-MSoE4vNA.js.map +1 -0
- package/dist/{package-aKgzEJtp.cjs → package-CUVyeIbt.cjs} +2 -2
- package/dist/package-CUVyeIbt.cjs.map +1 -0
- package/dist/package-Cbd8OC6q.js +6 -0
- package/dist/package-Cbd8OC6q.js.map +1 -0
- package/dist/shell-7HPrTCJ5.cjs +57 -0
- package/dist/shell-7HPrTCJ5.cjs.map +1 -0
- package/dist/shell-DqqWsHCD.js +46 -0
- package/dist/shell-DqqWsHCD.js.map +1 -0
- package/dist/{telemetry-T5IA2dWA.cjs → telemetry-Cn9X1I5B.cjs} +46 -9
- package/dist/telemetry-Cn9X1I5B.cjs.map +1 -0
- package/dist/{telemetry-C4gOKX2x.js → telemetry-DxiR7clS.js} +40 -9
- package/dist/telemetry-DxiR7clS.js.map +1 -0
- package/dist/{validate-DURmg-2Q.cjs → validate-BG8A3aQS.cjs} +5 -4
- package/dist/validate-BG8A3aQS.cjs.map +1 -0
- package/dist/{validate-Cr26q5xX.js → validate-BZ1UFkwA.js} +4 -4
- package/dist/validate-BZ1UFkwA.js.map +1 -0
- package/dist/{validate-Dqi9T_c4.cjs → validate-Bbrn3Q-A.cjs} +4 -4
- package/dist/validate-Bbrn3Q-A.cjs.map +1 -0
- package/dist/{validate-Chjg23AE.js → validate-l8vLmwKA.js} +4 -4
- package/dist/validate-l8vLmwKA.js.map +1 -0
- package/package.json +6 -5
- package/src/commands/agent/start.ts +1 -1
- package/src/commands/agent.ts +1 -1
- package/src/commands/generate.ts +1 -1
- package/src/commands/init.ts +1 -1
- package/src/commands/mcp.ts +1 -1
- package/src/commands/validate.ts +1 -1
- package/src/constants.ts +0 -1
- package/src/index.ts +1 -1
- package/src/loggers/clackLogger.ts +26 -28
- package/src/loggers/fileSystemLogger.ts +1 -2
- package/src/loggers/githubActionsLogger.ts +26 -28
- package/src/loggers/plainLogger.ts +25 -26
- package/src/loggers/utils.ts +4 -5
- package/src/runners/agent.ts +1 -1
- package/src/runners/generate.ts +20 -7
- package/src/runners/init.ts +2 -1
- package/src/runners/mcp.ts +1 -1
- package/src/runners/validate.ts +1 -1
- package/src/utils/executeHooks.ts +2 -2
- package/src/utils/getIntro.ts +1 -80
- package/src/utils/getSummary.ts +1 -2
- package/src/utils/packageManager.ts +2 -2
- package/src/utils/runHook.ts +2 -2
- package/src/utils/telemetry.ts +1 -2
- package/dist/agent-CJ69TqoO.js.map +0 -1
- package/dist/agent-CduUX7Ye.cjs.map +0 -1
- package/dist/agent-D0A3RQho.js.map +0 -1
- package/dist/agent-DrnwQBZf.cjs.map +0 -1
- package/dist/errors-BUjJsNoe.cjs.map +0 -1
- package/dist/errors-bSLTEh4e.js.map +0 -1
- package/dist/generate-ByMgAV76.cjs.map +0 -1
- package/dist/generate-CiUPO5ds.cjs.map +0 -1
- package/dist/generate-DIIxtkWT.js.map +0 -1
- package/dist/generate-HP5ySfjV.js.map +0 -1
- package/dist/init-Cd1hCb7q.cjs.map +0 -1
- package/dist/init-DLNrkDF4.js.map +0 -1
- package/dist/init-Df_aXezV.cjs.map +0 -1
- package/dist/init-DyKK2fTp.js.map +0 -1
- package/dist/mcp-B73FC8dF.cjs.map +0 -1
- package/dist/mcp-Bd9LITaI.js.map +0 -1
- package/dist/mcp-Cf-1dsB-.js.map +0 -1
- package/dist/mcp-Clg-Qnkr.cjs.map +0 -1
- package/dist/package-681jTtCk.js +0 -6
- package/dist/package-681jTtCk.js.map +0 -1
- package/dist/package-aKgzEJtp.cjs.map +0 -1
- package/dist/telemetry-C4gOKX2x.js.map +0 -1
- package/dist/telemetry-T5IA2dWA.cjs.map +0 -1
- package/dist/types-CLtz0jem.js.map +0 -1
- package/dist/types-Ck2lzFON.cjs.map +0 -1
- package/dist/validate-Chjg23AE.js.map +0 -1
- package/dist/validate-Cr26q5xX.js.map +0 -1
- package/dist/validate-DURmg-2Q.cjs.map +0 -1
- package/dist/validate-Dqi9T_c4.cjs.map +0 -1
- package/src/cli/adapters/nodeAdapter.ts +0 -159
- package/src/cli/help.ts +0 -36
- package/src/cli/index.ts +0 -16
- package/src/cli/parse.ts +0 -18
- package/src/cli/schema.ts +0 -38
- package/src/cli/types.ts +0 -95
- package/src/utils/envDetection.ts +0 -34
- package/src/utils/errors.ts +0 -23
- package/src/utils/formatMsWithColor.ts +0 -22
- package/src/utils/randomColor.ts +0 -14
- package/src/utils/spawnAsync.ts +0 -47
|
@@ -1,74 +1,143 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { n as toCause, r as toError } from "./errors-6mF_WKxg.js";
|
|
3
|
+
import { a as canUseTTY, i as executeIfOnline, o as isGitHubActions, r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-DxiR7clS.js";
|
|
4
|
+
import { n as tokenize } from "./shell-DqqWsHCD.js";
|
|
5
|
+
import { t as version } from "./package-Cbd8OC6q.js";
|
|
6
|
+
import { i as WATCHER_IGNORED_PATHS, r as SUMMARY_SEPARATOR, t as KUBB_NPM_PACKAGE_URL } from "./constants-CM3dJzjK.js";
|
|
6
7
|
import { styleText } from "node:util";
|
|
8
|
+
import { EventEmitter } from "node:events";
|
|
7
9
|
import { createHash } from "node:crypto";
|
|
10
|
+
import "node:fs";
|
|
11
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
12
|
+
import path, { dirname, relative, resolve } from "node:path";
|
|
8
13
|
import process$1 from "node:process";
|
|
9
|
-
import { AsyncEventEmitter, detectFormatter, detectLinter, executeIfOnline, formatHrtime, formatMs, formatters, getConfigs, linters, tokenize } from "@kubb/core/utils";
|
|
10
|
-
import path, { relative, resolve } from "node:path";
|
|
11
14
|
import * as clack from "@clack/prompts";
|
|
12
|
-
import {
|
|
15
|
+
import { PromiseManager, defineLogger, detectFormatter, detectLinter, formatters, getConfigs, isInputPath, linters, logLevel, safeBuild, setup } from "@kubb/core";
|
|
13
16
|
import { NonZeroExitError, x } from "tinyexec";
|
|
14
17
|
import { Writable } from "node:stream";
|
|
15
|
-
import { write } from "@kubb/core/fs";
|
|
16
18
|
import { cosmiconfig } from "cosmiconfig";
|
|
17
19
|
import { createJiti } from "jiti";
|
|
18
|
-
//#region
|
|
20
|
+
//#region ../../internals/utils/src/asyncEventEmitter.ts
|
|
19
21
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* - Yellow: > 500ms and <= 1000ms
|
|
23
|
-
* - Red: > 1000ms
|
|
22
|
+
* A typed EventEmitter that awaits all async listeners before resolving.
|
|
23
|
+
* Wraps Node's `EventEmitter` with full TypeScript event-map inference.
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
var AsyncEventEmitter = class {
|
|
26
|
+
/**
|
|
27
|
+
* `maxListener` controls the maximum number of listeners per event before Node emits a memory-leak warning.
|
|
28
|
+
* @default 10
|
|
29
|
+
*/
|
|
30
|
+
constructor(maxListener = 10) {
|
|
31
|
+
this.#emitter.setMaxListeners(maxListener);
|
|
32
|
+
}
|
|
33
|
+
#emitter = new EventEmitter();
|
|
34
|
+
/**
|
|
35
|
+
* Emits an event and awaits all registered listeners in parallel.
|
|
36
|
+
* Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.
|
|
37
|
+
*/
|
|
38
|
+
async emit(eventName, ...eventArgs) {
|
|
39
|
+
const listeners = this.#emitter.listeners(eventName);
|
|
40
|
+
if (listeners.length === 0) return;
|
|
41
|
+
await Promise.all(listeners.map(async (listener) => {
|
|
42
|
+
try {
|
|
43
|
+
return await listener(...eventArgs);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
let serializedArgs;
|
|
46
|
+
try {
|
|
47
|
+
serializedArgs = JSON.stringify(eventArgs);
|
|
48
|
+
} catch {
|
|
49
|
+
serializedArgs = String(eventArgs);
|
|
50
|
+
}
|
|
51
|
+
throw new Error(`Error in async listener for "${eventName}" with eventArgs ${serializedArgs}`, { cause: toError(err) });
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
/** Registers a persistent listener for the given event. */
|
|
56
|
+
on(eventName, handler) {
|
|
57
|
+
this.#emitter.on(eventName, handler);
|
|
58
|
+
}
|
|
59
|
+
/** Registers a one-shot listener that removes itself after the first invocation. */
|
|
60
|
+
onOnce(eventName, handler) {
|
|
61
|
+
const wrapper = (...args) => {
|
|
62
|
+
this.off(eventName, wrapper);
|
|
63
|
+
return handler(...args);
|
|
64
|
+
};
|
|
65
|
+
this.on(eventName, wrapper);
|
|
66
|
+
}
|
|
67
|
+
/** Removes a previously registered listener. */
|
|
68
|
+
off(eventName, handler) {
|
|
69
|
+
this.#emitter.off(eventName, handler);
|
|
70
|
+
}
|
|
71
|
+
/** Removes all listeners from every event channel. */
|
|
72
|
+
removeAll() {
|
|
73
|
+
this.#emitter.removeAllListeners();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region ../../internals/utils/src/time.ts
|
|
78
|
+
/**
|
|
79
|
+
* Calculates elapsed time in milliseconds from a high-resolution start time.
|
|
80
|
+
* Rounds to 2 decimal places to provide sub-millisecond precision without noise.
|
|
81
|
+
*/
|
|
82
|
+
function getElapsedMs(hrStart) {
|
|
83
|
+
const [seconds, nanoseconds] = process.hrtime(hrStart);
|
|
84
|
+
const ms = seconds * 1e3 + nanoseconds / 1e6;
|
|
85
|
+
return Math.round(ms * 100) / 100;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Converts a millisecond duration into a human-readable string.
|
|
89
|
+
* Adjusts units (ms, s, m s) based on the magnitude of the duration.
|
|
90
|
+
*/
|
|
91
|
+
function formatMs(ms) {
|
|
92
|
+
if (ms >= 6e4) return `${Math.floor(ms / 6e4)}m ${(ms % 6e4 / 1e3).toFixed(1)}s`;
|
|
93
|
+
if (ms >= 1e3) return `${(ms / 1e3).toFixed(2)}s`;
|
|
94
|
+
return `${Math.round(ms)}ms`;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Convenience helper: formats the elapsed time since `hrStart` in one step.
|
|
98
|
+
*/
|
|
99
|
+
function formatHrtime(hrStart) {
|
|
100
|
+
return formatMs(getElapsedMs(hrStart));
|
|
30
101
|
}
|
|
31
102
|
//#endregion
|
|
32
|
-
//#region
|
|
103
|
+
//#region ../../internals/utils/src/colors.ts
|
|
33
104
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
105
|
+
* Parses a CSS hex color string (`#RGB`) into its RGB channels.
|
|
106
|
+
* Falls back to `255` for any channel that cannot be parsed.
|
|
36
107
|
*/
|
|
37
|
-
/** Parse a hex color string into RGB components, defaulting to 255 on invalid input. */
|
|
38
108
|
function parseHex(color) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
109
|
+
const int = Number.parseInt(color.replace("#", ""), 16);
|
|
110
|
+
return Number.isNaN(int) ? {
|
|
111
|
+
r: 255,
|
|
112
|
+
g: 255,
|
|
113
|
+
b: 255
|
|
114
|
+
} : {
|
|
115
|
+
r: int >> 16 & 255,
|
|
116
|
+
g: int >> 8 & 255,
|
|
117
|
+
b: int & 255
|
|
47
118
|
};
|
|
48
119
|
}
|
|
49
120
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* @returns Function that wraps text with the color
|
|
121
|
+
* Returns a function that wraps a string in a 24-bit ANSI true-color escape sequence
|
|
122
|
+
* for the given hex color.
|
|
53
123
|
*/
|
|
54
124
|
function hex(color) {
|
|
55
125
|
const { r, g, b } = parseHex(color);
|
|
56
126
|
return (text) => `\x1b[38;2;${r};${g};${b}m${text}\x1b[0m`;
|
|
57
127
|
}
|
|
58
|
-
function gradient(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}).join("");
|
|
69
|
-
};
|
|
128
|
+
function gradient(colorStops, text) {
|
|
129
|
+
const chars = text.split("");
|
|
130
|
+
return chars.map((char, i) => {
|
|
131
|
+
const t = chars.length <= 1 ? 0 : i / (chars.length - 1);
|
|
132
|
+
const seg = Math.min(Math.floor(t * (colorStops.length - 1)), colorStops.length - 2);
|
|
133
|
+
const lt = t * (colorStops.length - 1) - seg;
|
|
134
|
+
const from = parseHex(colorStops[seg]);
|
|
135
|
+
const to = parseHex(colorStops[seg + 1]);
|
|
136
|
+
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`;
|
|
137
|
+
}).join("");
|
|
70
138
|
}
|
|
71
|
-
|
|
139
|
+
/** ANSI color functions for each part of the Kubb mascot illustration. */
|
|
140
|
+
const palette = {
|
|
72
141
|
lid: hex("#F55A17"),
|
|
73
142
|
woodTop: hex("#F5A217"),
|
|
74
143
|
woodMid: hex("#F58517"),
|
|
@@ -78,32 +147,85 @@ const colors = {
|
|
|
78
147
|
blush: hex("#FDA4AF")
|
|
79
148
|
};
|
|
80
149
|
/**
|
|
81
|
-
* Generates the Kubb mascot
|
|
82
|
-
* @param version - The version string to display
|
|
83
|
-
* @returns Formatted mascot face string
|
|
150
|
+
* Generates the Kubb mascot welcome banner.
|
|
84
151
|
*/
|
|
85
152
|
function getIntro({ title, description, version, areEyesOpen }) {
|
|
86
153
|
const kubbVersion = gradient([
|
|
87
154
|
"#F58517",
|
|
88
155
|
"#F5A217",
|
|
89
156
|
"#F55A17"
|
|
90
|
-
]
|
|
91
|
-
const eyeTop = areEyesOpen ?
|
|
92
|
-
const eyeBottom = areEyesOpen ?
|
|
157
|
+
], `KUBB v${version}`);
|
|
158
|
+
const eyeTop = areEyesOpen ? palette.eye("█▀█") : palette.eye("───");
|
|
159
|
+
const eyeBottom = areEyesOpen ? palette.eye("▀▀▀") : palette.eye("───");
|
|
93
160
|
return `
|
|
94
|
-
${
|
|
95
|
-
${
|
|
96
|
-
${
|
|
97
|
-
${
|
|
98
|
-
${
|
|
161
|
+
${palette.lid("▄▄▄▄▄▄▄▄▄▄▄▄▄")}
|
|
162
|
+
${palette.woodTop("█ ")}${palette.highlight("▄▄")}${palette.woodTop(" ")}${palette.highlight("▄▄")}${palette.woodTop(" █")} ${kubbVersion}
|
|
163
|
+
${palette.woodMid("█ ")}${eyeTop}${palette.woodMid(" ")}${eyeTop}${palette.woodMid(" █")} ${styleText("gray", title)}
|
|
164
|
+
${palette.woodMid("█ ")}${eyeBottom}${palette.woodMid(" ")}${palette.blush("◡")}${palette.woodMid(" ")}${eyeBottom}${palette.woodMid(" █")} ${styleText("yellow", "➜")} ${styleText("white", description)}
|
|
165
|
+
${palette.woodBase("▀▀▀▀▀▀▀▀▀▀▀▀▀")}
|
|
99
166
|
`;
|
|
100
167
|
}
|
|
101
|
-
|
|
102
|
-
|
|
168
|
+
/** ANSI color names available for terminal output. */
|
|
169
|
+
const randomColors = [
|
|
170
|
+
"black",
|
|
171
|
+
"red",
|
|
172
|
+
"green",
|
|
173
|
+
"yellow",
|
|
174
|
+
"blue",
|
|
175
|
+
"white",
|
|
176
|
+
"magenta",
|
|
177
|
+
"cyan",
|
|
178
|
+
"gray"
|
|
179
|
+
];
|
|
180
|
+
/**
|
|
181
|
+
* Returns the text wrapped in a deterministic ANSI color derived from the text's SHA-256 hash.
|
|
182
|
+
*/
|
|
103
183
|
function randomCliColor(text) {
|
|
104
184
|
if (!text) return "";
|
|
105
185
|
return styleText(randomColors[createHash("sha256").update(text).digest().readUInt32BE(0) % randomColors.length] ?? "white", text);
|
|
106
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Formats a millisecond duration with an ANSI color based on thresholds:
|
|
189
|
+
* green ≤ 500 ms · yellow ≤ 1 000 ms · red > 1 000 ms
|
|
190
|
+
*/
|
|
191
|
+
function formatMsWithColor(ms) {
|
|
192
|
+
const formatted = formatMs(ms);
|
|
193
|
+
if (ms <= 500) return styleText("green", formatted);
|
|
194
|
+
if (ms <= 1e3) return styleText("yellow", formatted);
|
|
195
|
+
return styleText("red", formatted);
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region ../../internals/utils/src/fs.ts
|
|
199
|
+
/**
|
|
200
|
+
* Writes `data` to `path`, trimming leading/trailing whitespace before saving.
|
|
201
|
+
* Skips the write and returns `undefined` when the trimmed content is empty or
|
|
202
|
+
* identical to what is already on disk.
|
|
203
|
+
* Creates any missing parent directories automatically.
|
|
204
|
+
* When `sanity` is `true`, re-reads the file after writing and throws if the
|
|
205
|
+
* content does not match — useful for catching write failures on unreliable file systems.
|
|
206
|
+
*/
|
|
207
|
+
async function write(path, data, options = {}) {
|
|
208
|
+
const trimmed = data.trim();
|
|
209
|
+
if (trimmed === "") return void 0;
|
|
210
|
+
const resolved = resolve(path);
|
|
211
|
+
if (typeof Bun !== "undefined") {
|
|
212
|
+
const file = Bun.file(resolved);
|
|
213
|
+
if ((await file.exists() ? await file.text() : null) === trimmed) return void 0;
|
|
214
|
+
await Bun.write(resolved, trimmed);
|
|
215
|
+
return trimmed;
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
if (await readFile(resolved, { encoding: "utf-8" }) === trimmed) return void 0;
|
|
219
|
+
} catch {}
|
|
220
|
+
await mkdir(dirname(resolved), { recursive: true });
|
|
221
|
+
await writeFile(resolved, trimmed, { encoding: "utf-8" });
|
|
222
|
+
if (options.sanity) {
|
|
223
|
+
const savedData = await readFile(resolved, { encoding: "utf-8" });
|
|
224
|
+
if (savedData !== trimmed) throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
225
|
+
return savedData;
|
|
226
|
+
}
|
|
227
|
+
return trimmed;
|
|
228
|
+
}
|
|
107
229
|
//#endregion
|
|
108
230
|
//#region src/utils/getSummary.ts
|
|
109
231
|
function getSummary({ failedPlugins, filesCreated, status, hrStart, config, pluginTimings }) {
|
|
@@ -221,7 +343,7 @@ var ClackWritable = class extends Writable {
|
|
|
221
343
|
const clackLogger = defineLogger({
|
|
222
344
|
name: "clack",
|
|
223
345
|
install(context, options) {
|
|
224
|
-
const logLevel = options?.logLevel ??
|
|
346
|
+
const logLevel$8 = options?.logLevel ?? logLevel.info;
|
|
225
347
|
const state = {
|
|
226
348
|
totalPlugins: 0,
|
|
227
349
|
completedPlugins: 0,
|
|
@@ -249,12 +371,12 @@ const clackLogger = defineLogger({
|
|
|
249
371
|
state.activeProgress.clear();
|
|
250
372
|
}
|
|
251
373
|
function showProgressStep() {
|
|
252
|
-
if (logLevel <=
|
|
374
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
253
375
|
const line = buildProgressLine(state);
|
|
254
376
|
if (line) clack.log.step(getMessage(line));
|
|
255
377
|
}
|
|
256
378
|
function getMessage(message) {
|
|
257
|
-
return formatMessage(message, logLevel);
|
|
379
|
+
return formatMessage(message, logLevel$8);
|
|
258
380
|
}
|
|
259
381
|
function startSpinner(text) {
|
|
260
382
|
state.spinner.start(text);
|
|
@@ -265,7 +387,7 @@ const clackLogger = defineLogger({
|
|
|
265
387
|
state.isSpinning = false;
|
|
266
388
|
}
|
|
267
389
|
context.on("info", (message, info = "") => {
|
|
268
|
-
if (logLevel <=
|
|
390
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
269
391
|
const text = getMessage([
|
|
270
392
|
styleText("blue", "ℹ"),
|
|
271
393
|
message,
|
|
@@ -275,21 +397,21 @@ const clackLogger = defineLogger({
|
|
|
275
397
|
else clack.log.info(text);
|
|
276
398
|
});
|
|
277
399
|
context.on("success", (message, info = "") => {
|
|
278
|
-
if (logLevel <=
|
|
400
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
279
401
|
const text = getMessage([
|
|
280
402
|
styleText("blue", "✓"),
|
|
281
403
|
message,
|
|
282
|
-
logLevel >=
|
|
404
|
+
logLevel$8 >= logLevel.info ? styleText("dim", info) : void 0
|
|
283
405
|
].filter(Boolean).join(" "));
|
|
284
406
|
if (state.isSpinning) stopSpinner(text);
|
|
285
407
|
else clack.log.success(text);
|
|
286
408
|
});
|
|
287
409
|
context.on("warn", (message, info) => {
|
|
288
|
-
if (logLevel <
|
|
410
|
+
if (logLevel$8 < logLevel.warn) return;
|
|
289
411
|
const text = getMessage([
|
|
290
412
|
styleText("yellow", "⚠"),
|
|
291
413
|
message,
|
|
292
|
-
logLevel >=
|
|
414
|
+
logLevel$8 >= logLevel.info && info ? styleText("dim", info) : void 0
|
|
293
415
|
].filter(Boolean).join(" "));
|
|
294
416
|
clack.log.warn(text);
|
|
295
417
|
});
|
|
@@ -298,7 +420,7 @@ const clackLogger = defineLogger({
|
|
|
298
420
|
const text = [styleText("red", "✗"), error.message].join(" ");
|
|
299
421
|
if (state.isSpinning) stopSpinner(getMessage(text));
|
|
300
422
|
else clack.log.error(getMessage(text));
|
|
301
|
-
if (logLevel >=
|
|
423
|
+
if (logLevel$8 >= logLevel.debug && error.stack) {
|
|
302
424
|
const frames = error.stack.split("\n").slice(1, 4);
|
|
303
425
|
for (const frame of frames) clack.log.message(getMessage(styleText("dim", frame.trim())));
|
|
304
426
|
if (caused?.stack) {
|
|
@@ -309,7 +431,7 @@ const clackLogger = defineLogger({
|
|
|
309
431
|
}
|
|
310
432
|
});
|
|
311
433
|
context.on("version:new", (version, latestVersion) => {
|
|
312
|
-
if (logLevel <=
|
|
434
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
313
435
|
clack.box(`\`v${version}\` → \`v${latestVersion}\`
|
|
314
436
|
Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
315
437
|
width: "auto",
|
|
@@ -330,13 +452,13 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
330
452
|
reset();
|
|
331
453
|
});
|
|
332
454
|
context.on("config:start", () => {
|
|
333
|
-
if (logLevel <=
|
|
455
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
334
456
|
const text = getMessage("Configuration started");
|
|
335
457
|
clack.intro(text);
|
|
336
458
|
startSpinner(getMessage("Configuration loading"));
|
|
337
459
|
});
|
|
338
460
|
context.on("config:end", (_configs) => {
|
|
339
|
-
if (logLevel <=
|
|
461
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
340
462
|
const text = getMessage("Configuration completed");
|
|
341
463
|
clack.outro(text);
|
|
342
464
|
});
|
|
@@ -347,7 +469,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
347
469
|
clack.intro(text);
|
|
348
470
|
});
|
|
349
471
|
context.on("plugin:start", (plugin) => {
|
|
350
|
-
if (logLevel <=
|
|
472
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
351
473
|
stopSpinner();
|
|
352
474
|
const progressBar = clack.progress({
|
|
353
475
|
style: "block",
|
|
@@ -367,7 +489,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
367
489
|
context.on("plugin:end", (plugin, { duration, success }) => {
|
|
368
490
|
stopSpinner();
|
|
369
491
|
const active = state.activeProgress.get(plugin.name);
|
|
370
|
-
if (!active || logLevel ===
|
|
492
|
+
if (!active || logLevel$8 === logLevel.silent) return;
|
|
371
493
|
clearInterval(active.interval);
|
|
372
494
|
if (success) state.completedPlugins++;
|
|
373
495
|
else state.failedPlugins++;
|
|
@@ -378,7 +500,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
378
500
|
showProgressStep();
|
|
379
501
|
});
|
|
380
502
|
context.on("files:processing:start", (files) => {
|
|
381
|
-
if (logLevel <=
|
|
503
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
382
504
|
stopSpinner();
|
|
383
505
|
state.totalFiles = files.length;
|
|
384
506
|
state.processedFiles = 0;
|
|
@@ -393,7 +515,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
393
515
|
state.activeProgress.set("files", { progressBar });
|
|
394
516
|
});
|
|
395
517
|
context.on("file:processing:update", ({ file, config }) => {
|
|
396
|
-
if (logLevel <=
|
|
518
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
397
519
|
stopSpinner();
|
|
398
520
|
state.processedFiles++;
|
|
399
521
|
const text = `Writing ${relative(config.root, file.path)}`;
|
|
@@ -402,7 +524,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
402
524
|
active.progressBar.advance(void 0, text);
|
|
403
525
|
});
|
|
404
526
|
context.on("files:processing:end", () => {
|
|
405
|
-
if (logLevel <=
|
|
527
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
406
528
|
stopSpinner();
|
|
407
529
|
const text = getMessage("Files written successfully");
|
|
408
530
|
const active = state.activeProgress.get("files");
|
|
@@ -416,22 +538,22 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
416
538
|
clack.outro(text);
|
|
417
539
|
});
|
|
418
540
|
context.on("format:start", () => {
|
|
419
|
-
if (logLevel <=
|
|
541
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
420
542
|
const text = getMessage("Format started");
|
|
421
543
|
clack.intro(text);
|
|
422
544
|
});
|
|
423
545
|
context.on("format:end", () => {
|
|
424
|
-
if (logLevel <=
|
|
546
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
425
547
|
const text = getMessage("Format completed");
|
|
426
548
|
clack.outro(text);
|
|
427
549
|
});
|
|
428
550
|
context.on("lint:start", () => {
|
|
429
|
-
if (logLevel <=
|
|
551
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
430
552
|
const text = getMessage("Lint started");
|
|
431
553
|
clack.intro(text);
|
|
432
554
|
});
|
|
433
555
|
context.on("lint:end", () => {
|
|
434
|
-
if (logLevel <=
|
|
556
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
435
557
|
const text = getMessage("Lint completed");
|
|
436
558
|
clack.outro(text);
|
|
437
559
|
});
|
|
@@ -439,7 +561,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
439
561
|
const commandWithArgs = formatCommandWithArgs(command, args);
|
|
440
562
|
const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} started`);
|
|
441
563
|
if (!id) return;
|
|
442
|
-
if (logLevel <=
|
|
564
|
+
if (logLevel$8 <= logLevel.silent) {
|
|
443
565
|
await runHook({
|
|
444
566
|
id,
|
|
445
567
|
command,
|
|
@@ -454,7 +576,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
454
576
|
return;
|
|
455
577
|
}
|
|
456
578
|
clack.intro(text);
|
|
457
|
-
const logger = clack.taskLog({ title: getMessage(["Executing hook", logLevel >=
|
|
579
|
+
const logger = clack.taskLog({ title: getMessage(["Executing hook", logLevel$8 >= logLevel.info ? styleText("dim", commandWithArgs) : void 0].filter(Boolean).join(" ")) });
|
|
458
580
|
const writable = new ClackWritable(logger);
|
|
459
581
|
await runHook({
|
|
460
582
|
id,
|
|
@@ -471,7 +593,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
471
593
|
});
|
|
472
594
|
});
|
|
473
595
|
context.on("hook:end", ({ command, args }) => {
|
|
474
|
-
if (logLevel <=
|
|
596
|
+
if (logLevel$8 <= logLevel.silent) return;
|
|
475
597
|
const text = getMessage(`Hook ${styleText("dim", formatCommandWithArgs(command, args))} successfully executed`);
|
|
476
598
|
clack.outro(text);
|
|
477
599
|
});
|
|
@@ -482,7 +604,7 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
|
|
|
482
604
|
config,
|
|
483
605
|
status,
|
|
484
606
|
hrStart,
|
|
485
|
-
pluginTimings: logLevel >=
|
|
607
|
+
pluginTimings: logLevel$8 >= logLevel.verbose ? pluginTimings : void 0
|
|
486
608
|
});
|
|
487
609
|
const title = config.name || "";
|
|
488
610
|
summary.unshift("\n");
|
|
@@ -617,7 +739,7 @@ const fileSystemLogger = defineLogger({
|
|
|
617
739
|
const githubActionsLogger = defineLogger({
|
|
618
740
|
name: "github-actions",
|
|
619
741
|
install(context, options) {
|
|
620
|
-
const logLevel = options?.logLevel ??
|
|
742
|
+
const logLevel$7 = options?.logLevel ?? logLevel.info;
|
|
621
743
|
const state = {
|
|
622
744
|
totalPlugins: 0,
|
|
623
745
|
completedPlugins: 0,
|
|
@@ -637,12 +759,12 @@ const githubActionsLogger = defineLogger({
|
|
|
637
759
|
state.currentConfigs = [];
|
|
638
760
|
}
|
|
639
761
|
function showProgressStep() {
|
|
640
|
-
if (logLevel <=
|
|
762
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
641
763
|
const line = buildProgressLine(state);
|
|
642
764
|
if (line) console.log(getMessage(line));
|
|
643
765
|
}
|
|
644
766
|
function getMessage(message) {
|
|
645
|
-
return formatMessage(message, logLevel);
|
|
767
|
+
return formatMessage(message, logLevel$7);
|
|
646
768
|
}
|
|
647
769
|
function openGroup(name) {
|
|
648
770
|
console.log(`::group::${name}`);
|
|
@@ -651,7 +773,7 @@ const githubActionsLogger = defineLogger({
|
|
|
651
773
|
console.log("::endgroup::");
|
|
652
774
|
}
|
|
653
775
|
context.on("info", (message, info = "") => {
|
|
654
|
-
if (logLevel <=
|
|
776
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
655
777
|
const text = getMessage([
|
|
656
778
|
styleText("blue", "ℹ"),
|
|
657
779
|
message,
|
|
@@ -660,29 +782,29 @@ const githubActionsLogger = defineLogger({
|
|
|
660
782
|
console.log(text);
|
|
661
783
|
});
|
|
662
784
|
context.on("success", (message, info = "") => {
|
|
663
|
-
if (logLevel <=
|
|
785
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
664
786
|
const text = getMessage([
|
|
665
787
|
styleText("blue", "✓"),
|
|
666
788
|
message,
|
|
667
|
-
logLevel >=
|
|
789
|
+
logLevel$7 >= logLevel.info ? styleText("dim", info) : void 0
|
|
668
790
|
].filter(Boolean).join(" "));
|
|
669
791
|
console.log(text);
|
|
670
792
|
});
|
|
671
793
|
context.on("warn", (message, info = "") => {
|
|
672
|
-
if (logLevel <=
|
|
794
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
673
795
|
const text = getMessage([
|
|
674
796
|
styleText("yellow", "⚠"),
|
|
675
797
|
message,
|
|
676
|
-
logLevel >=
|
|
798
|
+
logLevel$7 >= logLevel.info ? styleText("dim", info) : void 0
|
|
677
799
|
].filter(Boolean).join(" "));
|
|
678
800
|
console.warn(`::warning::${text}`);
|
|
679
801
|
});
|
|
680
802
|
context.on("error", (error) => {
|
|
681
803
|
const caused = toCause(error);
|
|
682
|
-
if (logLevel <=
|
|
804
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
683
805
|
const message = error.message || String(error);
|
|
684
806
|
console.error(`::error::${message}`);
|
|
685
|
-
if (logLevel >=
|
|
807
|
+
if (logLevel$7 >= logLevel.debug && error.stack) {
|
|
686
808
|
const frames = error.stack.split("\n").slice(1, 4);
|
|
687
809
|
for (const frame of frames) console.log(getMessage(styleText("dim", frame.trim())));
|
|
688
810
|
if (caused?.stack) {
|
|
@@ -697,14 +819,14 @@ const githubActionsLogger = defineLogger({
|
|
|
697
819
|
reset();
|
|
698
820
|
});
|
|
699
821
|
context.on("config:start", () => {
|
|
700
|
-
if (logLevel <=
|
|
822
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
701
823
|
const text = getMessage("Configuration started");
|
|
702
824
|
openGroup("Configuration");
|
|
703
825
|
console.log(text);
|
|
704
826
|
});
|
|
705
827
|
context.on("config:end", (configs) => {
|
|
706
828
|
state.currentConfigs = configs;
|
|
707
|
-
if (logLevel <=
|
|
829
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
708
830
|
const text = getMessage("Configuration completed");
|
|
709
831
|
console.log(text);
|
|
710
832
|
closeGroup("Configuration");
|
|
@@ -717,13 +839,13 @@ const githubActionsLogger = defineLogger({
|
|
|
717
839
|
if (state.currentConfigs.length === 1) console.log(getMessage(text));
|
|
718
840
|
});
|
|
719
841
|
context.on("plugin:start", (plugin) => {
|
|
720
|
-
if (logLevel <=
|
|
842
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
721
843
|
const text = getMessage(`Generating ${styleText("bold", plugin.name)}`);
|
|
722
844
|
if (state.currentConfigs.length === 1) openGroup(`Plugin: ${plugin.name}`);
|
|
723
845
|
console.log(text);
|
|
724
846
|
});
|
|
725
847
|
context.on("plugin:end", (plugin, { duration, success }) => {
|
|
726
|
-
if (logLevel <=
|
|
848
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
727
849
|
if (success) state.completedPlugins++;
|
|
728
850
|
else state.failedPlugins++;
|
|
729
851
|
const durationStr = formatMsWithColor(duration);
|
|
@@ -734,7 +856,7 @@ const githubActionsLogger = defineLogger({
|
|
|
734
856
|
showProgressStep();
|
|
735
857
|
});
|
|
736
858
|
context.on("files:processing:start", (files) => {
|
|
737
|
-
if (logLevel <=
|
|
859
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
738
860
|
state.totalFiles = files.length;
|
|
739
861
|
state.processedFiles = 0;
|
|
740
862
|
if (state.currentConfigs.length === 1) openGroup("File Generation");
|
|
@@ -742,14 +864,14 @@ const githubActionsLogger = defineLogger({
|
|
|
742
864
|
console.log(text);
|
|
743
865
|
});
|
|
744
866
|
context.on("files:processing:end", () => {
|
|
745
|
-
if (logLevel <=
|
|
867
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
746
868
|
const text = getMessage("Files written successfully");
|
|
747
869
|
console.log(text);
|
|
748
870
|
if (state.currentConfigs.length === 1) closeGroup("File Generation");
|
|
749
871
|
showProgressStep();
|
|
750
872
|
});
|
|
751
873
|
context.on("file:processing:update", () => {
|
|
752
|
-
if (logLevel <=
|
|
874
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
753
875
|
state.processedFiles++;
|
|
754
876
|
});
|
|
755
877
|
context.on("generation:end", (config) => {
|
|
@@ -757,25 +879,25 @@ const githubActionsLogger = defineLogger({
|
|
|
757
879
|
console.log(text);
|
|
758
880
|
});
|
|
759
881
|
context.on("format:start", () => {
|
|
760
|
-
if (logLevel <=
|
|
882
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
761
883
|
const text = getMessage("Format started");
|
|
762
884
|
if (state.currentConfigs.length === 1) openGroup("Formatting");
|
|
763
885
|
console.log(text);
|
|
764
886
|
});
|
|
765
887
|
context.on("format:end", () => {
|
|
766
|
-
if (logLevel <=
|
|
888
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
767
889
|
const text = getMessage("Format completed");
|
|
768
890
|
console.log(text);
|
|
769
891
|
if (state.currentConfigs.length === 1) closeGroup("Formatting");
|
|
770
892
|
});
|
|
771
893
|
context.on("lint:start", () => {
|
|
772
|
-
if (logLevel <=
|
|
894
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
773
895
|
const text = getMessage("Lint started");
|
|
774
896
|
if (state.currentConfigs.length === 1) openGroup("Linting");
|
|
775
897
|
console.log(text);
|
|
776
898
|
});
|
|
777
899
|
context.on("lint:end", () => {
|
|
778
|
-
if (logLevel <=
|
|
900
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
779
901
|
const text = getMessage("Lint completed");
|
|
780
902
|
console.log(text);
|
|
781
903
|
if (state.currentConfigs.length === 1) closeGroup("Linting");
|
|
@@ -783,7 +905,7 @@ const githubActionsLogger = defineLogger({
|
|
|
783
905
|
context.on("hook:start", async ({ id, command, args }) => {
|
|
784
906
|
const commandWithArgs = formatCommandWithArgs(command, args);
|
|
785
907
|
const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} started`);
|
|
786
|
-
if (logLevel >
|
|
908
|
+
if (logLevel$7 > logLevel.silent) {
|
|
787
909
|
if (state.currentConfigs.length === 1) openGroup(`Hook ${commandWithArgs}`);
|
|
788
910
|
console.log(text);
|
|
789
911
|
}
|
|
@@ -795,13 +917,13 @@ const githubActionsLogger = defineLogger({
|
|
|
795
917
|
commandWithArgs,
|
|
796
918
|
context,
|
|
797
919
|
sink: {
|
|
798
|
-
onStdout: logLevel >
|
|
799
|
-
onStderr: logLevel >
|
|
920
|
+
onStdout: logLevel$7 > logLevel.silent ? (s) => console.log(s) : void 0,
|
|
921
|
+
onStderr: logLevel$7 > logLevel.silent ? (s) => console.error(`::error::${s}`) : void 0
|
|
800
922
|
}
|
|
801
923
|
});
|
|
802
924
|
});
|
|
803
925
|
context.on("hook:end", ({ command, args }) => {
|
|
804
|
-
if (logLevel <=
|
|
926
|
+
if (logLevel$7 <= logLevel.silent) return;
|
|
805
927
|
const commandWithArgs = formatCommandWithArgs(command, args);
|
|
806
928
|
const text = getMessage(`Hook ${styleText("dim", commandWithArgs)} completed`);
|
|
807
929
|
console.log(text);
|
|
@@ -829,12 +951,12 @@ const githubActionsLogger = defineLogger({
|
|
|
829
951
|
const plainLogger = defineLogger({
|
|
830
952
|
name: "plain",
|
|
831
953
|
install(context, options) {
|
|
832
|
-
const logLevel = options?.logLevel ??
|
|
954
|
+
const logLevel$6 = options?.logLevel ?? logLevel.info;
|
|
833
955
|
function getMessage(message) {
|
|
834
|
-
return formatMessage(message, logLevel);
|
|
956
|
+
return formatMessage(message, logLevel$6);
|
|
835
957
|
}
|
|
836
958
|
context.on("info", (message, info) => {
|
|
837
|
-
if (logLevel <=
|
|
959
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
838
960
|
const text = getMessage([
|
|
839
961
|
"ℹ",
|
|
840
962
|
message,
|
|
@@ -843,20 +965,20 @@ const plainLogger = defineLogger({
|
|
|
843
965
|
console.log(text);
|
|
844
966
|
});
|
|
845
967
|
context.on("success", (message, info = "") => {
|
|
846
|
-
if (logLevel <=
|
|
968
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
847
969
|
const text = getMessage([
|
|
848
970
|
"✓",
|
|
849
971
|
message,
|
|
850
|
-
logLevel >=
|
|
972
|
+
logLevel$6 >= logLevel.info ? info : void 0
|
|
851
973
|
].filter(Boolean).join(" "));
|
|
852
974
|
console.log(text);
|
|
853
975
|
});
|
|
854
976
|
context.on("warn", (message, info) => {
|
|
855
|
-
if (logLevel <
|
|
977
|
+
if (logLevel$6 < logLevel.warn) return;
|
|
856
978
|
const text = getMessage([
|
|
857
979
|
"⚠",
|
|
858
980
|
message,
|
|
859
|
-
logLevel >=
|
|
981
|
+
logLevel$6 >= logLevel.info ? info : void 0
|
|
860
982
|
].filter(Boolean).join(" "));
|
|
861
983
|
console.log(text);
|
|
862
984
|
});
|
|
@@ -864,7 +986,7 @@ const plainLogger = defineLogger({
|
|
|
864
986
|
const caused = toCause(error);
|
|
865
987
|
const text = getMessage(["✗", error.message].join(" "));
|
|
866
988
|
console.log(text);
|
|
867
|
-
if (logLevel >=
|
|
989
|
+
if (logLevel$6 >= logLevel.debug && error.stack) {
|
|
868
990
|
const frames = error.stack.split("\n").slice(1, 4);
|
|
869
991
|
for (const frame of frames) console.log(getMessage(frame.trim()));
|
|
870
992
|
if (caused?.stack) {
|
|
@@ -878,12 +1000,12 @@ const plainLogger = defineLogger({
|
|
|
878
1000
|
console.log("Kubb CLI 🧩");
|
|
879
1001
|
});
|
|
880
1002
|
context.on("config:start", () => {
|
|
881
|
-
if (logLevel <=
|
|
1003
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
882
1004
|
const text = getMessage("Configuration started");
|
|
883
1005
|
console.log(text);
|
|
884
1006
|
});
|
|
885
1007
|
context.on("config:end", () => {
|
|
886
|
-
if (logLevel <=
|
|
1008
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
887
1009
|
const text = getMessage("Configuration completed");
|
|
888
1010
|
console.log(text);
|
|
889
1011
|
});
|
|
@@ -892,28 +1014,28 @@ const plainLogger = defineLogger({
|
|
|
892
1014
|
console.log(text);
|
|
893
1015
|
});
|
|
894
1016
|
context.on("plugin:start", (plugin) => {
|
|
895
|
-
if (logLevel <=
|
|
1017
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
896
1018
|
const text = getMessage(`Generating ${plugin.name}`);
|
|
897
1019
|
console.log(text);
|
|
898
1020
|
});
|
|
899
1021
|
context.on("plugin:end", (plugin, { duration, success }) => {
|
|
900
|
-
if (logLevel <=
|
|
1022
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
901
1023
|
const durationStr = formatMs(duration);
|
|
902
1024
|
const text = getMessage(success ? `${plugin.name} completed in ${durationStr}` : `${plugin.name} failed in ${durationStr}`);
|
|
903
1025
|
console.log(text);
|
|
904
1026
|
});
|
|
905
1027
|
context.on("files:processing:start", (files) => {
|
|
906
|
-
if (logLevel <=
|
|
1028
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
907
1029
|
const text = getMessage(`Writing ${files.length} files`);
|
|
908
1030
|
console.log(text);
|
|
909
1031
|
});
|
|
910
1032
|
context.on("file:processing:update", ({ file, config }) => {
|
|
911
|
-
if (logLevel <=
|
|
1033
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
912
1034
|
const text = getMessage(`Writing ${relative(config.root, file.path)}`);
|
|
913
1035
|
console.log(text);
|
|
914
1036
|
});
|
|
915
1037
|
context.on("files:processing:end", () => {
|
|
916
|
-
if (logLevel <=
|
|
1038
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
917
1039
|
const text = getMessage("Files written successfully");
|
|
918
1040
|
console.log(text);
|
|
919
1041
|
});
|
|
@@ -922,29 +1044,29 @@ const plainLogger = defineLogger({
|
|
|
922
1044
|
console.log(text);
|
|
923
1045
|
});
|
|
924
1046
|
context.on("format:start", () => {
|
|
925
|
-
if (logLevel <=
|
|
1047
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
926
1048
|
const text = getMessage("Format started");
|
|
927
1049
|
console.log(text);
|
|
928
1050
|
});
|
|
929
1051
|
context.on("format:end", () => {
|
|
930
|
-
if (logLevel <=
|
|
1052
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
931
1053
|
const text = getMessage("Format completed");
|
|
932
1054
|
console.log(text);
|
|
933
1055
|
});
|
|
934
1056
|
context.on("lint:start", () => {
|
|
935
|
-
if (logLevel <=
|
|
1057
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
936
1058
|
const text = getMessage("Lint started");
|
|
937
1059
|
console.log(text);
|
|
938
1060
|
});
|
|
939
1061
|
context.on("lint:end", () => {
|
|
940
|
-
if (logLevel <=
|
|
1062
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
941
1063
|
const text = getMessage("Lint completed");
|
|
942
1064
|
console.log(text);
|
|
943
1065
|
});
|
|
944
1066
|
context.on("hook:start", async ({ id, command, args }) => {
|
|
945
1067
|
const commandWithArgs = formatCommandWithArgs(command, args);
|
|
946
1068
|
const text = getMessage(`Hook ${commandWithArgs} started`);
|
|
947
|
-
if (logLevel >
|
|
1069
|
+
if (logLevel$6 > logLevel.silent) console.log(text);
|
|
948
1070
|
if (!id) return;
|
|
949
1071
|
await runHook({
|
|
950
1072
|
id,
|
|
@@ -953,13 +1075,13 @@ const plainLogger = defineLogger({
|
|
|
953
1075
|
commandWithArgs,
|
|
954
1076
|
context,
|
|
955
1077
|
sink: {
|
|
956
|
-
onStdout: logLevel >
|
|
957
|
-
onStderr: logLevel >
|
|
1078
|
+
onStdout: logLevel$6 > logLevel.silent ? (s) => console.log(s) : void 0,
|
|
1079
|
+
onStderr: logLevel$6 > logLevel.silent ? (s) => console.error(s) : void 0
|
|
958
1080
|
}
|
|
959
1081
|
});
|
|
960
1082
|
});
|
|
961
1083
|
context.on("hook:end", ({ command, args }) => {
|
|
962
|
-
if (logLevel <=
|
|
1084
|
+
if (logLevel$6 <= logLevel.silent) return;
|
|
963
1085
|
const text = getMessage(`Hook ${formatCommandWithArgs(command, args)} completed`);
|
|
964
1086
|
console.log(text);
|
|
965
1087
|
});
|
|
@@ -970,7 +1092,7 @@ const plainLogger = defineLogger({
|
|
|
970
1092
|
config,
|
|
971
1093
|
status,
|
|
972
1094
|
hrStart,
|
|
973
|
-
pluginTimings: logLevel >=
|
|
1095
|
+
pluginTimings: logLevel$6 >= logLevel.verbose ? pluginTimings : void 0
|
|
974
1096
|
});
|
|
975
1097
|
console.log(SUMMARY_SEPARATOR);
|
|
976
1098
|
console.log(summary.join("\n"));
|
|
@@ -984,8 +1106,8 @@ const plainLogger = defineLogger({
|
|
|
984
1106
|
* Optionally prefix a message with a [HH:MM:SS] timestamp when logLevel >= verbose.
|
|
985
1107
|
* Shared across all logger adapters to avoid duplication.
|
|
986
1108
|
*/
|
|
987
|
-
function formatMessage(message, logLevel) {
|
|
988
|
-
if (logLevel >=
|
|
1109
|
+
function formatMessage(message, logLevel$4) {
|
|
1110
|
+
if (logLevel$4 >= logLevel.verbose) return `${styleText("dim", `[${(/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
989
1111
|
hour12: false,
|
|
990
1112
|
hour: "2-digit",
|
|
991
1113
|
minute: "2-digit",
|
|
@@ -1026,12 +1148,12 @@ const logMapper = {
|
|
|
1026
1148
|
plain: plainLogger,
|
|
1027
1149
|
"github-actions": githubActionsLogger
|
|
1028
1150
|
};
|
|
1029
|
-
async function setupLogger(context, { logLevel }) {
|
|
1151
|
+
async function setupLogger(context, { logLevel: logLevel$5 }) {
|
|
1030
1152
|
const type = detectLogger();
|
|
1031
1153
|
const logger = logMapper[type];
|
|
1032
1154
|
if (!logger) throw new Error(`Unknown adapter type: ${type}`);
|
|
1033
|
-
const cleanup = await logger.install(context, { logLevel });
|
|
1034
|
-
if (logLevel >=
|
|
1155
|
+
const cleanup = await logger.install(context, { logLevel: logLevel$5 });
|
|
1156
|
+
if (logLevel$5 >= logLevel.debug) await fileSystemLogger.install(context, { logLevel: logLevel$5 });
|
|
1035
1157
|
return cleanup;
|
|
1036
1158
|
}
|
|
1037
1159
|
//#endregion
|
|
@@ -1131,7 +1253,7 @@ async function startWatcher(path, cb) {
|
|
|
1131
1253
|
}
|
|
1132
1254
|
//#endregion
|
|
1133
1255
|
//#region src/runners/generate.ts
|
|
1134
|
-
async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefix, noToolMessage, configName, outputPath, logLevel, events, onStart, onEnd }) {
|
|
1256
|
+
async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefix, noToolMessage, configName, outputPath, logLevel: logLevel$1, events, onStart, onEnd }) {
|
|
1135
1257
|
await onStart();
|
|
1136
1258
|
let resolvedTool = toolValue;
|
|
1137
1259
|
if (resolvedTool === "auto") {
|
|
@@ -1156,7 +1278,7 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
|
|
|
1156
1278
|
}
|
|
1157
1279
|
events.emit("success", [
|
|
1158
1280
|
`${successPrefix} with ${styleText("dim", resolvedTool)}`,
|
|
1159
|
-
logLevel >=
|
|
1281
|
+
logLevel$1 >= logLevel.info ? `on ${styleText("dim", outputPath)}` : void 0,
|
|
1160
1282
|
"successfully"
|
|
1161
1283
|
].filter(Boolean).join(" ")).then(resolve).catch(reject);
|
|
1162
1284
|
};
|
|
@@ -1176,7 +1298,7 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
|
|
|
1176
1298
|
}
|
|
1177
1299
|
await onEnd();
|
|
1178
1300
|
}
|
|
1179
|
-
async function generate({ input, config: userConfig, events, logLevel }) {
|
|
1301
|
+
async function generate({ input, config: userConfig, events, logLevel: logLevel$2 }) {
|
|
1180
1302
|
const inputPath = input ?? ("path" in userConfig.input ? userConfig.input.path : void 0);
|
|
1181
1303
|
const hrStart = process$1.hrtime();
|
|
1182
1304
|
const config = {
|
|
@@ -1220,7 +1342,7 @@ async function generate({ input, config: userConfig, events, logLevel }) {
|
|
|
1220
1342
|
filesCreated: files.length,
|
|
1221
1343
|
status: "failed",
|
|
1222
1344
|
hrStart,
|
|
1223
|
-
pluginTimings: logLevel >=
|
|
1345
|
+
pluginTimings: logLevel$2 >= logLevel.verbose ? pluginTimings : void 0
|
|
1224
1346
|
});
|
|
1225
1347
|
await sendTelemetry(buildTelemetryEvent({
|
|
1226
1348
|
command: "generate",
|
|
@@ -1247,7 +1369,7 @@ async function generate({ input, config: userConfig, events, logLevel }) {
|
|
|
1247
1369
|
noToolMessage: "No formatter found (biome, prettier, or oxfmt). Skipping formatting.",
|
|
1248
1370
|
configName: config.name,
|
|
1249
1371
|
outputPath,
|
|
1250
|
-
logLevel,
|
|
1372
|
+
logLevel: logLevel$2,
|
|
1251
1373
|
events,
|
|
1252
1374
|
onStart: () => events.emit("format:start"),
|
|
1253
1375
|
onEnd: () => events.emit("format:end")
|
|
@@ -1261,7 +1383,7 @@ async function generate({ input, config: userConfig, events, logLevel }) {
|
|
|
1261
1383
|
noToolMessage: "No linter found (biome, oxlint, or eslint). Skipping linting.",
|
|
1262
1384
|
configName: config.name,
|
|
1263
1385
|
outputPath,
|
|
1264
|
-
logLevel,
|
|
1386
|
+
logLevel: logLevel$2,
|
|
1265
1387
|
events,
|
|
1266
1388
|
onStart: () => events.emit("lint:start"),
|
|
1267
1389
|
onEnd: () => events.emit("lint:end")
|
|
@@ -1294,10 +1416,10 @@ async function generate({ input, config: userConfig, events, logLevel }) {
|
|
|
1294
1416
|
}));
|
|
1295
1417
|
}
|
|
1296
1418
|
async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, watch }) {
|
|
1297
|
-
const logLevel =
|
|
1419
|
+
const logLevel$3 = logLevel[logLevelKey] ?? logLevel.info;
|
|
1298
1420
|
const events = new AsyncEventEmitter();
|
|
1299
1421
|
const promiseManager = new PromiseManager();
|
|
1300
|
-
await setupLogger(events, { logLevel });
|
|
1422
|
+
await setupLogger(events, { logLevel: logLevel$3 });
|
|
1301
1423
|
await executeIfOnline(async () => {
|
|
1302
1424
|
try {
|
|
1303
1425
|
const latestVersion = (await (await fetch(KUBB_NPM_PACKAGE_URL)).json()).version;
|
|
@@ -1320,7 +1442,7 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
|
|
|
1320
1442
|
await generate({
|
|
1321
1443
|
input,
|
|
1322
1444
|
config,
|
|
1323
|
-
logLevel,
|
|
1445
|
+
logLevel: logLevel$3,
|
|
1324
1446
|
events
|
|
1325
1447
|
});
|
|
1326
1448
|
clack.log.step(styleText("yellow", `Watching for changes in ${paths.join(" and ")}`));
|
|
@@ -1330,7 +1452,7 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
|
|
|
1330
1452
|
await generate({
|
|
1331
1453
|
input,
|
|
1332
1454
|
config,
|
|
1333
|
-
logLevel,
|
|
1455
|
+
logLevel: logLevel$3,
|
|
1334
1456
|
events
|
|
1335
1457
|
});
|
|
1336
1458
|
};
|
|
@@ -1345,4 +1467,4 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
|
|
|
1345
1467
|
//#endregion
|
|
1346
1468
|
export { runGenerateCommand };
|
|
1347
1469
|
|
|
1348
|
-
//# sourceMappingURL=generate-
|
|
1470
|
+
//# sourceMappingURL=generate-CAsV9wSx.js.map
|