@kubb/cli 5.14.6 → 5.15.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/bin/kubb.js +2 -1
- package/dist/{Telemetry-B5V_ufmv.cjs → Telemetry-B52pKz9i.cjs} +14 -118
- package/dist/Telemetry-B52pKz9i.cjs.map +1 -0
- package/dist/{Telemetry-DrnGartf.js → Telemetry-C7Qwy2s7.js} +12 -86
- package/dist/Telemetry-C7Qwy2s7.js.map +1 -0
- package/dist/{background-DlK0by5c.js → background-BJCuXYuB.js} +5 -6
- package/dist/{background-DlK0by5c.js.map → background-BJCuXYuB.js.map} +1 -1
- package/dist/{background-CdPT1eaq.cjs → background-CK2gQtTU.cjs} +5 -6
- package/dist/{background-CdPT1eaq.cjs.map → background-CK2gQtTU.cjs.map} +1 -1
- package/dist/{background-C6XHpEo7.js → background-D4mZCg-4.js} +1 -1
- package/dist/banner-BdTTDFkG.js +140 -0
- package/dist/banner-BdTTDFkG.js.map +1 -0
- package/dist/banner-wJFk-L-c.cjs +163 -0
- package/dist/banner-wJFk-L-c.cjs.map +1 -0
- package/dist/config-BL3HnFhb.js +1 -0
- package/dist/config-BWj9jBVj.cjs +62 -0
- package/dist/config-BWj9jBVj.cjs.map +1 -0
- package/dist/{config-CNqgDSu3.js → config-CQTxXvIG.js} +6 -52
- package/dist/config-CQTxXvIG.js.map +1 -0
- package/dist/{config-BG_Nr2CZ.cjs → config-CRrmj88c.cjs} +15 -62
- package/dist/config-CRrmj88c.cjs.map +1 -0
- package/dist/config-Uk3rbZfb.js +49 -0
- package/dist/config-Uk3rbZfb.js.map +1 -0
- package/dist/configFile-C0DIXNMD.js +993 -0
- package/dist/configFile-C0DIXNMD.js.map +1 -0
- package/dist/configFile-CoEpHdXG.cjs +1028 -0
- package/dist/configFile-CoEpHdXG.cjs.map +1 -0
- package/dist/{credentials-C8tjAhTo.js → credentials-B77iJx9H.js} +1 -1
- package/dist/{credentials-DDaKqtJn.cjs → credentials-DEsGwcGD.cjs} +3 -4
- package/dist/{credentials-DDaKqtJn.cjs.map → credentials-DEsGwcGD.cjs.map} +1 -1
- package/dist/{credentials-CZK6zPLv.js → credentials-osgjujE_.js} +3 -4
- package/dist/{credentials-CZK6zPLv.js.map → credentials-osgjujE_.js.map} +1 -1
- package/dist/env-C3xHRMez.js +1 -0
- package/dist/env-eu3XyKqJ.cjs +55 -0
- package/dist/env-eu3XyKqJ.cjs.map +1 -0
- package/dist/env-rv-VgSGN.js +34 -0
- package/dist/env-rv-VgSGN.js.map +1 -0
- package/dist/{errors-Cl69p_vI.cjs → errors-BponpdjN.cjs} +3 -4
- package/dist/{errors-Cl69p_vI.cjs.map → errors-BponpdjN.cjs.map} +1 -1
- package/dist/{errors-DmC83ALX.js → errors-wzqmMpMo.js} +3 -4
- package/dist/{errors-DmC83ALX.js.map → errors-wzqmMpMo.js.map} +1 -1
- package/dist/index.cjs +37 -2719
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +35 -2713
- package/dist/index.js.map +1 -1
- package/dist/installWithSpinner-DpnpxHq5.js +49 -0
- package/dist/installWithSpinner-DpnpxHq5.js.map +1 -0
- package/dist/installWithSpinner-ONGfIVUJ.cjs +56 -0
- package/dist/installWithSpinner-ONGfIVUJ.cjs.map +1 -0
- package/dist/{text-CL6N6yPS.js → intro-9PB8sE8z.js} +8 -52
- package/dist/intro-9PB8sE8z.js.map +1 -0
- package/dist/{text-DrsG1EDN.cjs → intro-YPaf1Imr.cjs} +12 -80
- package/dist/intro-YPaf1Imr.cjs.map +1 -0
- package/dist/isCIEnvironment-D6xtAAZ2.js +14 -0
- package/dist/isCIEnvironment-D6xtAAZ2.js.map +1 -0
- package/dist/isCIEnvironment-DiVOMI5Q.cjs +20 -0
- package/dist/isCIEnvironment-DiVOMI5Q.cjs.map +1 -0
- package/dist/mascot--q1xjKw1.js +63 -0
- package/dist/mascot--q1xjKw1.js.map +1 -0
- package/dist/mascot-JSA0j3Q_.cjs +80 -0
- package/dist/mascot-JSA0j3Q_.cjs.map +1 -0
- package/dist/mcp-CcseJJwh.cjs +20 -0
- package/dist/mcp-CcseJJwh.cjs.map +1 -0
- package/dist/mcp-DUTsS8tR.js +21 -0
- package/dist/mcp-DUTsS8tR.js.map +1 -0
- package/dist/package-B1hUUjio.cjs +10 -0
- package/dist/package-B1hUUjio.cjs.map +1 -0
- package/dist/package-MYPMnnTX.js +5 -0
- package/dist/package-MYPMnnTX.js.map +1 -0
- package/dist/{registry-DOGpflct.js → registry-B3eYk4LN.js} +7 -67
- package/dist/registry-B3eYk4LN.js.map +1 -0
- package/dist/{registry-BzBp6aZI.cjs → registry-YE1pFWL-.cjs} +4 -82
- package/dist/registry-YE1pFWL-.cjs.map +1 -0
- package/dist/{reporters-GzXlc4CK.cjs → reporters-2cgjvXwR.cjs} +32 -40
- package/dist/{reporters-GzXlc4CK.cjs.map → reporters-2cgjvXwR.cjs.map} +1 -1
- package/dist/{reporters-mYHIUZSx.js → reporters-BM430HdQ.js} +19 -27
- package/dist/{reporters-mYHIUZSx.js.map → reporters-BM430HdQ.js.map} +1 -1
- package/dist/{rolldown-runtime-CPE0t6oh.cjs → rolldown-runtime-C3-Zg-KD.cjs} +1 -2
- package/dist/{rolldown-runtime-CRm0XQPb.js → rolldown-runtime-xo6NMXYd.js} +1 -2
- package/dist/run-1H9TGT8v.js +77 -0
- package/dist/run-1H9TGT8v.js.map +1 -0
- package/dist/run-BYP_t9dR.cjs +324 -0
- package/dist/run-BYP_t9dR.cjs.map +1 -0
- package/dist/run-Bq6gcfkS.js +1 -0
- package/dist/run-BrM7-NSV.js +181 -0
- package/dist/run-BrM7-NSV.js.map +1 -0
- package/dist/run-BsrNfFIl.js +228 -0
- package/dist/run-BsrNfFIl.js.map +1 -0
- package/dist/{run-l8IiOR_c.js → run-CLiHI99L.js} +9 -9
- package/dist/{run-l8IiOR_c.js.map → run-CLiHI99L.js.map} +1 -1
- package/dist/{run-C8Prej7s.cjs → run-CQORv7Gq.cjs} +44 -37
- package/dist/run-CQORv7Gq.cjs.map +1 -0
- package/dist/{run-EJtgdIin.js → run-CXVhxFfC.js} +31 -23
- package/dist/run-CXVhxFfC.js.map +1 -0
- package/dist/run-CrM4jsix.cjs +80 -0
- package/dist/run-CrM4jsix.cjs.map +1 -0
- package/dist/run-CvFakE3B.cjs +185 -0
- package/dist/run-CvFakE3B.cjs.map +1 -0
- package/dist/{run-DC_xH5H3.cjs → run-CyzKy-0p.cjs} +49 -41
- package/dist/run-CyzKy-0p.cjs.map +1 -0
- package/dist/run-D-nn9-Wq.js +319 -0
- package/dist/run-D-nn9-Wq.js.map +1 -0
- package/dist/run-DBnSbwtU.cjs +389 -0
- package/dist/run-DBnSbwtU.cjs.map +1 -0
- package/dist/{run-j1g5si5R.js → run-DTqMrPS9.js} +5 -6
- package/dist/{run-j1g5si5R.js.map → run-DTqMrPS9.js.map} +1 -1
- package/dist/{run-9fs2T2Je.js → run-DUwX6Icx.js} +26 -20
- package/dist/run-DUwX6Icx.js.map +1 -0
- package/dist/run-FEiyv6_U.js +385 -0
- package/dist/run-FEiyv6_U.js.map +1 -0
- package/dist/run-LY_UAYyM.cjs +233 -0
- package/dist/run-LY_UAYyM.cjs.map +1 -0
- package/dist/{run-sjzj0ir-.cjs → run-dMTJfs4_.cjs} +10 -10
- package/dist/{run-sjzj0ir-.cjs.map → run-dMTJfs4_.cjs.map} +1 -1
- package/dist/{run-CypFtkVE.cjs → run-uPA5s3rI.cjs} +5 -6
- package/dist/{run-CypFtkVE.cjs.map → run-uPA5s3rI.cjs.map} +1 -1
- package/dist/shared-C0EtrdUm.cjs +123 -0
- package/dist/shared-C0EtrdUm.cjs.map +1 -0
- package/dist/shared-Ct9stKpp.js +94 -0
- package/dist/shared-Ct9stKpp.js.map +1 -0
- package/dist/{snapshot-laSRD0z1.cjs → snapshot-CPF9zyZj.cjs} +13 -14
- package/dist/{snapshot-laSRD0z1.cjs.map → snapshot-CPF9zyZj.cjs.map} +1 -1
- package/dist/{snapshot-BJWnL6hE.js → snapshot-CiV08NJr.js} +10 -11
- package/dist/{snapshot-BJWnL6hE.js.map → snapshot-CiV08NJr.js.map} +1 -1
- package/dist/spinner-BZaln7O8.js +160 -0
- package/dist/spinner-BZaln7O8.js.map +1 -0
- package/dist/spinner-CfB0sIPy.cjs +208 -0
- package/dist/spinner-CfB0sIPy.cjs.map +1 -0
- package/dist/{status-DFEdbBPu.cjs → status-C066YA-4.cjs} +7 -8
- package/dist/{status-DFEdbBPu.cjs.map → status-C066YA-4.cjs.map} +1 -1
- package/dist/{status-BjmXLRm2.js → status-Dj8tivag.js} +6 -7
- package/dist/{status-BjmXLRm2.js.map → status-Dj8tivag.js.map} +1 -1
- package/dist/studio-B4XsXgKj.js +215 -0
- package/dist/studio-B4XsXgKj.js.map +1 -0
- package/dist/studio-D9_-mKee.cjs +218 -0
- package/dist/studio-D9_-mKee.cjs.map +1 -0
- package/dist/studioWorker.js +4 -5
- package/dist/{summary-DDnI70tn.js → summary-CbmQKA8l.js} +5 -6
- package/dist/{summary-DDnI70tn.js.map → summary-CbmQKA8l.js.map} +1 -1
- package/dist/{summary-1DCwzWEU.cjs → summary-Clvl5Hxs.cjs} +7 -8
- package/dist/{summary-1DCwzWEU.cjs.map → summary-Clvl5Hxs.cjs.map} +1 -1
- package/dist/table-BlRe9YTZ.cjs +15 -0
- package/dist/table-BlRe9YTZ.cjs.map +1 -0
- package/dist/table-CR7iZJGo.js +10 -0
- package/dist/table-CR7iZJGo.js.map +1 -0
- package/dist/text-BmiI4s6N.js +13 -0
- package/dist/text-BmiI4s6N.js.map +1 -0
- package/dist/text-Ep3AulAS.cjs +24 -0
- package/dist/text-Ep3AulAS.cjs.map +1 -0
- package/dist/time-3BKoci3G.cjs +82 -0
- package/dist/time-3BKoci3G.cjs.map +1 -0
- package/dist/time-C-wU7VhC.js +65 -0
- package/dist/time-C-wU7VhC.js.map +1 -0
- package/dist/utils-BdibacYq.js +244 -0
- package/dist/utils-BdibacYq.js.map +1 -0
- package/dist/utils-CO89mxRU.cjs +290 -0
- package/dist/utils-CO89mxRU.cjs.map +1 -0
- package/dist/utils-CbJ6hS_t.js +222 -0
- package/dist/utils-CbJ6hS_t.js.map +1 -0
- package/dist/utils-CcARPB45.cjs +286 -0
- package/dist/utils-CcARPB45.cjs.map +1 -0
- package/dist/validate-B3tLWYJU.cjs +27 -0
- package/dist/validate-B3tLWYJU.cjs.map +1 -0
- package/dist/validate-C5fyNF4v.js +28 -0
- package/dist/validate-C5fyNF4v.js.map +1 -0
- package/package.json +7 -7
- package/dist/Telemetry-B5V_ufmv.cjs.map +0 -1
- package/dist/Telemetry-DrnGartf.js.map +0 -1
- package/dist/config-BG_Nr2CZ.cjs.map +0 -1
- package/dist/config-CNqgDSu3.js.map +0 -1
- package/dist/config-DWDpFSn1.js +0 -1
- package/dist/registry-BzBp6aZI.cjs.map +0 -1
- package/dist/registry-DOGpflct.js.map +0 -1
- package/dist/run-9fs2T2Je.js.map +0 -1
- package/dist/run-C8Prej7s.cjs.map +0 -1
- package/dist/run-CXVme-aS.js +0 -1
- package/dist/run-DC_xH5H3.cjs.map +0 -1
- package/dist/run-EJtgdIin.js.map +0 -1
- package/dist/text-CL6N6yPS.js.map +0 -1
- package/dist/text-DrsG1EDN.cjs.map +0 -1
- package/dist/utils-C3vTpUje.cjs +0 -645
- package/dist/utils-C3vTpUje.cjs.map +0 -1
- package/dist/utils-CIc8YFtr.js +0 -536
- package/dist/utils-CIc8YFtr.js.map +0 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import "./rolldown-runtime-xo6NMXYd.js";
|
|
2
|
+
import { t as formatMs } from "./time-C-wU7VhC.js";
|
|
3
|
+
import { styleText } from "node:util";
|
|
4
|
+
// src/loggers/banner.ts
|
|
5
|
+
/**
|
|
6
|
+
* xterm-256 color for each pixel letter of the mascot. Fixed codes rather than named colors, so a
|
|
7
|
+
* terminal theme cannot repaint it.
|
|
8
|
+
*/
|
|
9
|
+
const colors = {
|
|
10
|
+
/** Hoodie. */
|
|
11
|
+
O: 208,
|
|
12
|
+
/** Shadow where the hood meets the face. */
|
|
13
|
+
R: 166,
|
|
14
|
+
/** Face. */
|
|
15
|
+
F: 223,
|
|
16
|
+
/** Eyes. */
|
|
17
|
+
K: 16,
|
|
18
|
+
/** Blush. */
|
|
19
|
+
B: 217,
|
|
20
|
+
/** Mouth. */
|
|
21
|
+
M: 131
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The two pixel rows of the face around the eyes, for each expression.
|
|
25
|
+
*/
|
|
26
|
+
const eyes = {
|
|
27
|
+
open: ["FFFFFFFFFF", "FFKFFFFKFF"],
|
|
28
|
+
left: ["FFFFFFFFFF", "FKFFFFKFFF"],
|
|
29
|
+
right: ["FFFFFFFFFF", "FFFKFFFFKF"],
|
|
30
|
+
blink: ["FFFFFFFFFF", "FKKFFFFKKF"],
|
|
31
|
+
happy: ["FFKFFFFKFF", "FKFKFFKFKF"]
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The frames the mascot plays when the CLI starts, each with how long it stays on screen. It ends on
|
|
35
|
+
* open eyes, which stay.
|
|
36
|
+
*/
|
|
37
|
+
const wakeUp = [
|
|
38
|
+
["blink", 100],
|
|
39
|
+
["open", 180],
|
|
40
|
+
["left", 140],
|
|
41
|
+
["right", 140],
|
|
42
|
+
["open", 80],
|
|
43
|
+
["happy", 220],
|
|
44
|
+
["open", 0]
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* The kid in the orange hoodie from the Kubb logo, one letter per pixel and `.` for none. Each
|
|
48
|
+
* 2 × 2 block becomes one terminal cell, so a block holds at most two colors.
|
|
49
|
+
*/
|
|
50
|
+
function pixels(expression) {
|
|
51
|
+
const [top, bottom] = eyes[expression];
|
|
52
|
+
return [
|
|
53
|
+
"....OOOOOOOOOO....",
|
|
54
|
+
"..OORRRRRRRRRROO..",
|
|
55
|
+
`..OO${top}OO..`,
|
|
56
|
+
`OOFF${bottom}FFOO`,
|
|
57
|
+
"OOFFBBFFMMFFBBFFOO",
|
|
58
|
+
"..OOOOFFFFFFOOOO.."
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Quadrant glyphs indexed by which quarters are filled: top left 1, top right 2, bottom left 4,
|
|
63
|
+
* bottom right 8.
|
|
64
|
+
*/
|
|
65
|
+
const quadrants = " ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█";
|
|
66
|
+
/**
|
|
67
|
+
* Draws each 2 × 2 block of pixels as one quadrant glyph. The glyph's filled quarters take the first
|
|
68
|
+
* color in the block and the rest take the other.
|
|
69
|
+
*/
|
|
70
|
+
function drawHead(expression) {
|
|
71
|
+
const rows = pixels(expression);
|
|
72
|
+
const lines = [];
|
|
73
|
+
for (let y = 0; y < rows.length; y += 2) {
|
|
74
|
+
let line = "";
|
|
75
|
+
for (let x = 0; x < rows[y].length; x += 2) {
|
|
76
|
+
const block = [
|
|
77
|
+
rows[y][x],
|
|
78
|
+
rows[y][x + 1],
|
|
79
|
+
rows[y + 1][x],
|
|
80
|
+
rows[y + 1][x + 1]
|
|
81
|
+
];
|
|
82
|
+
const fg = block.find((pixel) => pixel in colors);
|
|
83
|
+
if (!fg) {
|
|
84
|
+
line += " ";
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const bg = colors[block.find((pixel) => pixel !== fg) ?? "."];
|
|
88
|
+
const mask = block.reduce((bits, pixel, index) => pixel === fg ? bits | 1 << index : bits, 0);
|
|
89
|
+
line += `\x1b[38;5;${colors[fg]}${bg === void 0 ? "" : `;48;5;${bg}`}m${quadrants[mask]}\x1b[0m`;
|
|
90
|
+
}
|
|
91
|
+
lines.push(line);
|
|
92
|
+
}
|
|
93
|
+
return lines;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Generates the Kubb mascot welcome banner as an ANSI-colored string: the head with the version,
|
|
97
|
+
* title, and description beside it.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* console.log(getIntro({ title: 'kubb.config.ts', description: 'generating…', version: '5.0.0', expression: 'open' }))
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
function getIntro({ title, description, version, expression }) {
|
|
105
|
+
const brand = (value, bold = false) => `\x1b[${bold ? "1;" : ""}38;5;${colors.O}m${value}\x1b[0m`;
|
|
106
|
+
const text = [
|
|
107
|
+
brand(`KUBB v${version}`, true),
|
|
108
|
+
styleText("gray", title),
|
|
109
|
+
`${brand("➜")} ${styleText("white", description)}`
|
|
110
|
+
];
|
|
111
|
+
return drawHead(expression).map((line, index) => ` ${line} ${text[index]}`).join("\n");
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Formats a millisecond duration with a threshold-based ANSI color.
|
|
115
|
+
* `≤ 500 ms` → green · `≤ 1 000 ms` → yellow · `> 1 000 ms` → red.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* formatMsWithColor(200) // '\x1b[32m200ms\x1b[39m'
|
|
120
|
+
* formatMsWithColor(800) // '\x1b[33m800ms\x1b[39m'
|
|
121
|
+
* formatMsWithColor(1500) // '\x1b[31m1.50s\x1b[39m'
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
function formatMsWithColor(ms) {
|
|
125
|
+
const formatted = formatMs(ms);
|
|
126
|
+
if (ms <= 500) return styleText("green", formatted);
|
|
127
|
+
if (ms <= 1e3) return styleText("yellow", formatted);
|
|
128
|
+
return styleText("red", formatted);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A `size`-cell progress bar: `done` of `total` as filled cells, the rest light. Any progress shows
|
|
132
|
+
* at least one cell, and only a finished bar fills the last one.
|
|
133
|
+
*/
|
|
134
|
+
function formatBar(done, total, size = 20) {
|
|
135
|
+
const filled = !done ? 0 : done >= total ? size : Math.min(size - 1, Math.max(1, Math.round(done / total * size)));
|
|
136
|
+
return styleText("magenta", "█".repeat(filled)) + styleText("dim", "░".repeat(size - filled));
|
|
137
|
+
}
|
|
138
|
+
export { wakeUp as i, formatMsWithColor as n, getIntro as r, formatBar as t };
|
|
139
|
+
|
|
140
|
+
//# sourceMappingURL=banner-BdTTDFkG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner-BdTTDFkG.js","names":[],"sources":["../src/loggers/banner.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport { formatMs } from '@internals/utils'\n\n/**\n * xterm-256 color for each pixel letter of the mascot. Fixed codes rather than named colors, so a\n * terminal theme cannot repaint it.\n */\nconst colors: Record<string, number> = {\n /** Hoodie. */\n O: 208,\n /** Shadow where the hood meets the face. */\n R: 166,\n /** Face. */\n F: 223,\n /** Eyes. */\n K: 16,\n /** Blush. */\n B: 217,\n /** Mouth. */\n M: 131,\n}\n\n/**\n * The two pixel rows of the face around the eyes, for each expression.\n */\nconst eyes = {\n open: ['FFFFFFFFFF', 'FFKFFFFKFF'],\n left: ['FFFFFFFFFF', 'FKFFFFKFFF'],\n right: ['FFFFFFFFFF', 'FFFKFFFFKF'],\n blink: ['FFFFFFFFFF', 'FKKFFFFKKF'],\n happy: ['FFKFFFFKFF', 'FKFKFFKFKF'],\n} as const\n\nexport type Expression = keyof typeof eyes\n\n/**\n * The frames the mascot plays when the CLI starts, each with how long it stays on screen. It ends on\n * open eyes, which stay.\n */\nexport const wakeUp: ReadonlyArray<readonly [Expression, number]> = [\n ['blink', 100],\n ['open', 180],\n ['left', 140],\n ['right', 140],\n ['open', 80],\n ['happy', 220],\n ['open', 0],\n]\n\n/**\n * The kid in the orange hoodie from the Kubb logo, one letter per pixel and `.` for none. Each\n * 2 × 2 block becomes one terminal cell, so a block holds at most two colors.\n */\nexport function pixels(expression: Expression): Array<string> {\n const [top, bottom] = eyes[expression]\n\n // prettier-ignore\n return [\n '....OOOOOOOOOO....',\n '..OORRRRRRRRRROO..',\n `..OO${top}OO..`,\n `OOFF${bottom}FFOO`,\n 'OOFFBBFFMMFFBBFFOO',\n '..OOOOFFFFFFOOOO..',\n ]\n}\n\n/**\n * Quadrant glyphs indexed by which quarters are filled: top left 1, top right 2, bottom left 4,\n * bottom right 8.\n */\nconst quadrants = ' ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█'\n\n/**\n * Draws each 2 × 2 block of pixels as one quadrant glyph. The glyph's filled quarters take the first\n * color in the block and the rest take the other.\n */\nfunction drawHead(expression: Expression): Array<string> {\n const rows = pixels(expression)\n const lines: Array<string> = []\n\n for (let y = 0; y < rows.length; y += 2) {\n let line = ''\n for (let x = 0; x < rows[y]!.length; x += 2) {\n const block = [rows[y]![x]!, rows[y]![x + 1]!, rows[y + 1]![x]!, rows[y + 1]![x + 1]!]\n const fg = block.find((pixel) => pixel in colors)\n if (!fg) {\n line += ' '\n continue\n }\n const bg = colors[block.find((pixel) => pixel !== fg) ?? '.']\n const mask = block.reduce((bits, pixel, index) => (pixel === fg ? bits | (1 << index) : bits), 0)\n line += `\\x1b[38;5;${colors[fg]}${bg === undefined ? '' : `;48;5;${bg}`}m${quadrants[mask]}\\x1b[0m`\n }\n lines.push(line)\n }\n\n return lines\n}\n\n/**\n * Generates the Kubb mascot welcome banner as an ANSI-colored string: the head with the version,\n * title, and description beside it.\n *\n * @example\n * ```ts\n * console.log(getIntro({ title: 'kubb.config.ts', description: 'generating…', version: '5.0.0', expression: 'open' }))\n * ```\n */\nexport function getIntro({\n title,\n description,\n version,\n expression,\n}: {\n /**\n * Name of the active configuration or tool being started.\n */\n title: string\n /**\n * Short subtitle shown next to the arrow prompt.\n */\n description: string\n /**\n * Kubb version string rendered in the header.\n */\n version: string\n /**\n * Which face the mascot makes.\n */\n expression: Expression\n}): string {\n // The hoodie's fixed code, so the title is Kubb orange whatever the terminal theme does to `yellow`.\n const brand = (value: string, bold = false) => `\\x1b[${bold ? '1;' : ''}38;5;${colors.O}m${value}\\x1b[0m`\n const text = [brand(`KUBB v${version}`, true), styleText('gray', title), `${brand('➜')} ${styleText('white', description)}`]\n\n return drawHead(expression)\n .map((line, index) => ` ${line} ${text[index]}`)\n .join('\\n')\n}\n\n/**\n * Formats a millisecond duration with a threshold-based ANSI color.\n * `≤ 500 ms` → green · `≤ 1 000 ms` → yellow · `> 1 000 ms` → red.\n *\n * @example\n * ```ts\n * formatMsWithColor(200) // '\\x1b[32m200ms\\x1b[39m'\n * formatMsWithColor(800) // '\\x1b[33m800ms\\x1b[39m'\n * formatMsWithColor(1500) // '\\x1b[31m1.50s\\x1b[39m'\n * ```\n */\nexport function formatMsWithColor(ms: number): string {\n const formatted = formatMs(ms)\n if (ms <= 500) return styleText('green', formatted)\n if (ms <= 1000) return styleText('yellow', formatted)\n\n return styleText('red', formatted)\n}\n\n/**\n * A `size`-cell progress bar: `done` of `total` as filled cells, the rest light. Any progress shows\n * at least one cell, and only a finished bar fills the last one.\n */\nexport function formatBar(done: number, total: number, size = 20): string {\n const filled = !done ? 0 : done >= total ? size : Math.min(size - 1, Math.max(1, Math.round((done / total) * size)))\n return styleText('magenta', '█'.repeat(filled)) + styleText('dim', '░'.repeat(size - filled))\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,SAAiC;;CAErC,GAAG;;CAEH,GAAG;;CAEH,GAAG;;CAEH,GAAG;;CAEH,GAAG;;CAEH,GAAG;AACL;;;;AAKA,MAAM,OAAO;CACX,MAAM,CAAC,cAAc,YAAY;CACjC,MAAM,CAAC,cAAc,YAAY;CACjC,OAAO,CAAC,cAAc,YAAY;CAClC,OAAO,CAAC,cAAc,YAAY;CAClC,OAAO,CAAC,cAAc,YAAY;AACpC;;;;;AAQA,MAAa,SAAuD;CAClE,CAAC,SAAS,GAAG;CACb,CAAC,QAAQ,GAAG;CACZ,CAAC,QAAQ,GAAG;CACZ,CAAC,SAAS,GAAG;CACb,CAAC,QAAQ,EAAE;CACX,CAAC,SAAS,GAAG;CACb,CAAC,QAAQ,CAAC;AACZ;;;;;AAMA,SAAgB,OAAO,YAAuC;CAC5D,MAAM,CAAC,KAAK,UAAU,KAAK;CAG3B,OAAO;EACL;EACA;EACA,OAAO,IAAI;EACX,OAAO,OAAO;EACd;EACA;CACF;AACF;;;;;AAMA,MAAM,YAAY;;;;;AAMlB,SAAS,SAAS,YAAuC;CACvD,MAAM,OAAO,OAAO,UAAU;CAC9B,MAAM,QAAuB,CAAC;CAE9B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG;EACvC,IAAI,OAAO;EACX,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,EAAE,CAAE,QAAQ,KAAK,GAAG;GAC3C,MAAM,QAAQ;IAAC,KAAK,EAAE,CAAE;IAAK,KAAK,EAAE,CAAE,IAAI;IAAK,KAAK,IAAI,EAAE,CAAE;IAAK,KAAK,IAAI,EAAE,CAAE,IAAI;GAAG;GACrF,MAAM,KAAK,MAAM,MAAM,UAAU,SAAS,MAAM;GAChD,IAAI,CAAC,IAAI;IACP,QAAQ;IACR;GACF;GACA,MAAM,KAAK,OAAO,MAAM,MAAM,UAAU,UAAU,EAAE,KAAK;GACzD,MAAM,OAAO,MAAM,QAAQ,MAAM,OAAO,UAAW,UAAU,KAAK,OAAQ,KAAK,QAAS,MAAO,CAAC;GAChG,QAAQ,aAAa,OAAO,MAAM,OAAO,KAAA,IAAY,KAAK,SAAS,KAAK,GAAG,UAAU,MAAM;EAC7F;EACA,MAAM,KAAK,IAAI;CACjB;CAEA,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,SAAS,EACvB,OACA,aACA,SACA,cAkBS;CAET,MAAM,SAAS,OAAe,OAAO,UAAU,QAAQ,OAAO,OAAO,GAAG,OAAO,OAAO,EAAE,GAAG,MAAM;CACjG,MAAM,OAAO;EAAC,MAAM,SAAS,WAAW,IAAI;EAAG,UAAU,QAAQ,KAAK;EAAG,GAAG,MAAM,GAAG,EAAE,GAAG,UAAU,SAAS,WAAW;CAAG;CAE3H,OAAO,SAAS,UAAU,CAAC,CACxB,KAAK,MAAM,UAAU,KAAK,KAAK,IAAI,KAAK,QAAQ,CAAC,CACjD,KAAK,IAAI;AACd;;;;;;;;;;;;AAaA,SAAgB,kBAAkB,IAAoB;CACpD,MAAM,YAAY,SAAS,EAAE;CAC7B,IAAI,MAAM,KAAK,OAAO,UAAU,SAAS,SAAS;CAClD,IAAI,MAAM,KAAM,OAAO,UAAU,UAAU,SAAS;CAEpD,OAAO,UAAU,OAAO,SAAS;AACnC;;;;;AAMA,SAAgB,UAAU,MAAc,OAAe,OAAO,IAAY;CACxE,MAAM,SAAS,CAAC,OAAO,IAAI,QAAQ,QAAQ,OAAO,KAAK,IAAI,OAAO,GAAG,KAAK,IAAI,GAAG,KAAK,MAAO,OAAO,QAAS,IAAI,CAAC,CAAC;CACnH,OAAO,UAAU,WAAW,IAAI,OAAO,MAAM,CAAC,IAAI,UAAU,OAAO,IAAI,OAAO,OAAO,MAAM,CAAC;AAC9F"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
require("./rolldown-runtime-C3-Zg-KD.cjs");
|
|
2
|
+
const require_time = require("./time-3BKoci3G.cjs");
|
|
3
|
+
let node_util = require("node:util");
|
|
4
|
+
// src/loggers/banner.ts
|
|
5
|
+
/**
|
|
6
|
+
* xterm-256 color for each pixel letter of the mascot. Fixed codes rather than named colors, so a
|
|
7
|
+
* terminal theme cannot repaint it.
|
|
8
|
+
*/
|
|
9
|
+
const colors = {
|
|
10
|
+
/** Hoodie. */
|
|
11
|
+
O: 208,
|
|
12
|
+
/** Shadow where the hood meets the face. */
|
|
13
|
+
R: 166,
|
|
14
|
+
/** Face. */
|
|
15
|
+
F: 223,
|
|
16
|
+
/** Eyes. */
|
|
17
|
+
K: 16,
|
|
18
|
+
/** Blush. */
|
|
19
|
+
B: 217,
|
|
20
|
+
/** Mouth. */
|
|
21
|
+
M: 131
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The two pixel rows of the face around the eyes, for each expression.
|
|
25
|
+
*/
|
|
26
|
+
const eyes = {
|
|
27
|
+
open: ["FFFFFFFFFF", "FFKFFFFKFF"],
|
|
28
|
+
left: ["FFFFFFFFFF", "FKFFFFKFFF"],
|
|
29
|
+
right: ["FFFFFFFFFF", "FFFKFFFFKF"],
|
|
30
|
+
blink: ["FFFFFFFFFF", "FKKFFFFKKF"],
|
|
31
|
+
happy: ["FFKFFFFKFF", "FKFKFFKFKF"]
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The frames the mascot plays when the CLI starts, each with how long it stays on screen. It ends on
|
|
35
|
+
* open eyes, which stay.
|
|
36
|
+
*/
|
|
37
|
+
const wakeUp = [
|
|
38
|
+
["blink", 100],
|
|
39
|
+
["open", 180],
|
|
40
|
+
["left", 140],
|
|
41
|
+
["right", 140],
|
|
42
|
+
["open", 80],
|
|
43
|
+
["happy", 220],
|
|
44
|
+
["open", 0]
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* The kid in the orange hoodie from the Kubb logo, one letter per pixel and `.` for none. Each
|
|
48
|
+
* 2 × 2 block becomes one terminal cell, so a block holds at most two colors.
|
|
49
|
+
*/
|
|
50
|
+
function pixels(expression) {
|
|
51
|
+
const [top, bottom] = eyes[expression];
|
|
52
|
+
return [
|
|
53
|
+
"....OOOOOOOOOO....",
|
|
54
|
+
"..OORRRRRRRRRROO..",
|
|
55
|
+
`..OO${top}OO..`,
|
|
56
|
+
`OOFF${bottom}FFOO`,
|
|
57
|
+
"OOFFBBFFMMFFBBFFOO",
|
|
58
|
+
"..OOOOFFFFFFOOOO.."
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Quadrant glyphs indexed by which quarters are filled: top left 1, top right 2, bottom left 4,
|
|
63
|
+
* bottom right 8.
|
|
64
|
+
*/
|
|
65
|
+
const quadrants = " ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█";
|
|
66
|
+
/**
|
|
67
|
+
* Draws each 2 × 2 block of pixels as one quadrant glyph. The glyph's filled quarters take the first
|
|
68
|
+
* color in the block and the rest take the other.
|
|
69
|
+
*/
|
|
70
|
+
function drawHead(expression) {
|
|
71
|
+
const rows = pixels(expression);
|
|
72
|
+
const lines = [];
|
|
73
|
+
for (let y = 0; y < rows.length; y += 2) {
|
|
74
|
+
let line = "";
|
|
75
|
+
for (let x = 0; x < rows[y].length; x += 2) {
|
|
76
|
+
const block = [
|
|
77
|
+
rows[y][x],
|
|
78
|
+
rows[y][x + 1],
|
|
79
|
+
rows[y + 1][x],
|
|
80
|
+
rows[y + 1][x + 1]
|
|
81
|
+
];
|
|
82
|
+
const fg = block.find((pixel) => pixel in colors);
|
|
83
|
+
if (!fg) {
|
|
84
|
+
line += " ";
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const bg = colors[block.find((pixel) => pixel !== fg) ?? "."];
|
|
88
|
+
const mask = block.reduce((bits, pixel, index) => pixel === fg ? bits | 1 << index : bits, 0);
|
|
89
|
+
line += `\x1b[38;5;${colors[fg]}${bg === void 0 ? "" : `;48;5;${bg}`}m${quadrants[mask]}\x1b[0m`;
|
|
90
|
+
}
|
|
91
|
+
lines.push(line);
|
|
92
|
+
}
|
|
93
|
+
return lines;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Generates the Kubb mascot welcome banner as an ANSI-colored string: the head with the version,
|
|
97
|
+
* title, and description beside it.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* console.log(getIntro({ title: 'kubb.config.ts', description: 'generating…', version: '5.0.0', expression: 'open' }))
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
function getIntro({ title, description, version, expression }) {
|
|
105
|
+
const brand = (value, bold = false) => `\x1b[${bold ? "1;" : ""}38;5;${colors.O}m${value}\x1b[0m`;
|
|
106
|
+
const text = [
|
|
107
|
+
brand(`KUBB v${version}`, true),
|
|
108
|
+
(0, node_util.styleText)("gray", title),
|
|
109
|
+
`${brand("➜")} ${(0, node_util.styleText)("white", description)}`
|
|
110
|
+
];
|
|
111
|
+
return drawHead(expression).map((line, index) => ` ${line} ${text[index]}`).join("\n");
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Formats a millisecond duration with a threshold-based ANSI color.
|
|
115
|
+
* `≤ 500 ms` → green · `≤ 1 000 ms` → yellow · `> 1 000 ms` → red.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* formatMsWithColor(200) // '\x1b[32m200ms\x1b[39m'
|
|
120
|
+
* formatMsWithColor(800) // '\x1b[33m800ms\x1b[39m'
|
|
121
|
+
* formatMsWithColor(1500) // '\x1b[31m1.50s\x1b[39m'
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
function formatMsWithColor(ms) {
|
|
125
|
+
const formatted = require_time.formatMs(ms);
|
|
126
|
+
if (ms <= 500) return (0, node_util.styleText)("green", formatted);
|
|
127
|
+
if (ms <= 1e3) return (0, node_util.styleText)("yellow", formatted);
|
|
128
|
+
return (0, node_util.styleText)("red", formatted);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A `size`-cell progress bar: `done` of `total` as filled cells, the rest light. Any progress shows
|
|
132
|
+
* at least one cell, and only a finished bar fills the last one.
|
|
133
|
+
*/
|
|
134
|
+
function formatBar(done, total, size = 20) {
|
|
135
|
+
const filled = !done ? 0 : done >= total ? size : Math.min(size - 1, Math.max(1, Math.round(done / total * size)));
|
|
136
|
+
return (0, node_util.styleText)("magenta", "█".repeat(filled)) + (0, node_util.styleText)("dim", "░".repeat(size - filled));
|
|
137
|
+
}
|
|
138
|
+
Object.defineProperty(exports, "formatBar", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function() {
|
|
141
|
+
return formatBar;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "formatMsWithColor", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function() {
|
|
147
|
+
return formatMsWithColor;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
Object.defineProperty(exports, "getIntro", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function() {
|
|
153
|
+
return getIntro;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, "wakeUp", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function() {
|
|
159
|
+
return wakeUp;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
//# sourceMappingURL=banner-wJFk-L-c.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner-wJFk-L-c.cjs","names":["styleText","formatMs"],"sources":["../src/loggers/banner.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport { formatMs } from '@internals/utils'\n\n/**\n * xterm-256 color for each pixel letter of the mascot. Fixed codes rather than named colors, so a\n * terminal theme cannot repaint it.\n */\nconst colors: Record<string, number> = {\n /** Hoodie. */\n O: 208,\n /** Shadow where the hood meets the face. */\n R: 166,\n /** Face. */\n F: 223,\n /** Eyes. */\n K: 16,\n /** Blush. */\n B: 217,\n /** Mouth. */\n M: 131,\n}\n\n/**\n * The two pixel rows of the face around the eyes, for each expression.\n */\nconst eyes = {\n open: ['FFFFFFFFFF', 'FFKFFFFKFF'],\n left: ['FFFFFFFFFF', 'FKFFFFKFFF'],\n right: ['FFFFFFFFFF', 'FFFKFFFFKF'],\n blink: ['FFFFFFFFFF', 'FKKFFFFKKF'],\n happy: ['FFKFFFFKFF', 'FKFKFFKFKF'],\n} as const\n\nexport type Expression = keyof typeof eyes\n\n/**\n * The frames the mascot plays when the CLI starts, each with how long it stays on screen. It ends on\n * open eyes, which stay.\n */\nexport const wakeUp: ReadonlyArray<readonly [Expression, number]> = [\n ['blink', 100],\n ['open', 180],\n ['left', 140],\n ['right', 140],\n ['open', 80],\n ['happy', 220],\n ['open', 0],\n]\n\n/**\n * The kid in the orange hoodie from the Kubb logo, one letter per pixel and `.` for none. Each\n * 2 × 2 block becomes one terminal cell, so a block holds at most two colors.\n */\nexport function pixels(expression: Expression): Array<string> {\n const [top, bottom] = eyes[expression]\n\n // prettier-ignore\n return [\n '....OOOOOOOOOO....',\n '..OORRRRRRRRRROO..',\n `..OO${top}OO..`,\n `OOFF${bottom}FFOO`,\n 'OOFFBBFFMMFFBBFFOO',\n '..OOOOFFFFFFOOOO..',\n ]\n}\n\n/**\n * Quadrant glyphs indexed by which quarters are filled: top left 1, top right 2, bottom left 4,\n * bottom right 8.\n */\nconst quadrants = ' ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█'\n\n/**\n * Draws each 2 × 2 block of pixels as one quadrant glyph. The glyph's filled quarters take the first\n * color in the block and the rest take the other.\n */\nfunction drawHead(expression: Expression): Array<string> {\n const rows = pixels(expression)\n const lines: Array<string> = []\n\n for (let y = 0; y < rows.length; y += 2) {\n let line = ''\n for (let x = 0; x < rows[y]!.length; x += 2) {\n const block = [rows[y]![x]!, rows[y]![x + 1]!, rows[y + 1]![x]!, rows[y + 1]![x + 1]!]\n const fg = block.find((pixel) => pixel in colors)\n if (!fg) {\n line += ' '\n continue\n }\n const bg = colors[block.find((pixel) => pixel !== fg) ?? '.']\n const mask = block.reduce((bits, pixel, index) => (pixel === fg ? bits | (1 << index) : bits), 0)\n line += `\\x1b[38;5;${colors[fg]}${bg === undefined ? '' : `;48;5;${bg}`}m${quadrants[mask]}\\x1b[0m`\n }\n lines.push(line)\n }\n\n return lines\n}\n\n/**\n * Generates the Kubb mascot welcome banner as an ANSI-colored string: the head with the version,\n * title, and description beside it.\n *\n * @example\n * ```ts\n * console.log(getIntro({ title: 'kubb.config.ts', description: 'generating…', version: '5.0.0', expression: 'open' }))\n * ```\n */\nexport function getIntro({\n title,\n description,\n version,\n expression,\n}: {\n /**\n * Name of the active configuration or tool being started.\n */\n title: string\n /**\n * Short subtitle shown next to the arrow prompt.\n */\n description: string\n /**\n * Kubb version string rendered in the header.\n */\n version: string\n /**\n * Which face the mascot makes.\n */\n expression: Expression\n}): string {\n // The hoodie's fixed code, so the title is Kubb orange whatever the terminal theme does to `yellow`.\n const brand = (value: string, bold = false) => `\\x1b[${bold ? '1;' : ''}38;5;${colors.O}m${value}\\x1b[0m`\n const text = [brand(`KUBB v${version}`, true), styleText('gray', title), `${brand('➜')} ${styleText('white', description)}`]\n\n return drawHead(expression)\n .map((line, index) => ` ${line} ${text[index]}`)\n .join('\\n')\n}\n\n/**\n * Formats a millisecond duration with a threshold-based ANSI color.\n * `≤ 500 ms` → green · `≤ 1 000 ms` → yellow · `> 1 000 ms` → red.\n *\n * @example\n * ```ts\n * formatMsWithColor(200) // '\\x1b[32m200ms\\x1b[39m'\n * formatMsWithColor(800) // '\\x1b[33m800ms\\x1b[39m'\n * formatMsWithColor(1500) // '\\x1b[31m1.50s\\x1b[39m'\n * ```\n */\nexport function formatMsWithColor(ms: number): string {\n const formatted = formatMs(ms)\n if (ms <= 500) return styleText('green', formatted)\n if (ms <= 1000) return styleText('yellow', formatted)\n\n return styleText('red', formatted)\n}\n\n/**\n * A `size`-cell progress bar: `done` of `total` as filled cells, the rest light. Any progress shows\n * at least one cell, and only a finished bar fills the last one.\n */\nexport function formatBar(done: number, total: number, size = 20): string {\n const filled = !done ? 0 : done >= total ? size : Math.min(size - 1, Math.max(1, Math.round((done / total) * size)))\n return styleText('magenta', '█'.repeat(filled)) + styleText('dim', '░'.repeat(size - filled))\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,SAAiC;;CAErC,GAAG;;CAEH,GAAG;;CAEH,GAAG;;CAEH,GAAG;;CAEH,GAAG;;CAEH,GAAG;AACL;;;;AAKA,MAAM,OAAO;CACX,MAAM,CAAC,cAAc,YAAY;CACjC,MAAM,CAAC,cAAc,YAAY;CACjC,OAAO,CAAC,cAAc,YAAY;CAClC,OAAO,CAAC,cAAc,YAAY;CAClC,OAAO,CAAC,cAAc,YAAY;AACpC;;;;;AAQA,MAAa,SAAuD;CAClE,CAAC,SAAS,GAAG;CACb,CAAC,QAAQ,GAAG;CACZ,CAAC,QAAQ,GAAG;CACZ,CAAC,SAAS,GAAG;CACb,CAAC,QAAQ,EAAE;CACX,CAAC,SAAS,GAAG;CACb,CAAC,QAAQ,CAAC;AACZ;;;;;AAMA,SAAgB,OAAO,YAAuC;CAC5D,MAAM,CAAC,KAAK,UAAU,KAAK;CAG3B,OAAO;EACL;EACA;EACA,OAAO,IAAI;EACX,OAAO,OAAO;EACd;EACA;CACF;AACF;;;;;AAMA,MAAM,YAAY;;;;;AAMlB,SAAS,SAAS,YAAuC;CACvD,MAAM,OAAO,OAAO,UAAU;CAC9B,MAAM,QAAuB,CAAC;CAE9B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG;EACvC,IAAI,OAAO;EACX,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,EAAE,CAAE,QAAQ,KAAK,GAAG;GAC3C,MAAM,QAAQ;IAAC,KAAK,EAAE,CAAE;IAAK,KAAK,EAAE,CAAE,IAAI;IAAK,KAAK,IAAI,EAAE,CAAE;IAAK,KAAK,IAAI,EAAE,CAAE,IAAI;GAAG;GACrF,MAAM,KAAK,MAAM,MAAM,UAAU,SAAS,MAAM;GAChD,IAAI,CAAC,IAAI;IACP,QAAQ;IACR;GACF;GACA,MAAM,KAAK,OAAO,MAAM,MAAM,UAAU,UAAU,EAAE,KAAK;GACzD,MAAM,OAAO,MAAM,QAAQ,MAAM,OAAO,UAAW,UAAU,KAAK,OAAQ,KAAK,QAAS,MAAO,CAAC;GAChG,QAAQ,aAAa,OAAO,MAAM,OAAO,KAAA,IAAY,KAAK,SAAS,KAAK,GAAG,UAAU,MAAM;EAC7F;EACA,MAAM,KAAK,IAAI;CACjB;CAEA,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,SAAS,EACvB,OACA,aACA,SACA,cAkBS;CAET,MAAM,SAAS,OAAe,OAAO,UAAU,QAAQ,OAAO,OAAO,GAAG,OAAO,OAAO,EAAE,GAAG,MAAM;CACjG,MAAM,OAAO;EAAC,MAAM,SAAS,WAAW,IAAI;GAAGA,GAAAA,UAAAA,UAAAA,CAAU,QAAQ,KAAK;EAAG,GAAG,MAAM,GAAG,EAAE,IAAA,GAAGA,UAAAA,UAAAA,CAAU,SAAS,WAAW;CAAG;CAE3H,OAAO,SAAS,UAAU,CAAC,CACxB,KAAK,MAAM,UAAU,KAAK,KAAK,IAAI,KAAK,QAAQ,CAAC,CACjD,KAAK,IAAI;AACd;;;;;;;;;;;;AAaA,SAAgB,kBAAkB,IAAoB;CACpD,MAAM,YAAYC,aAAAA,SAAS,EAAE;CAC7B,IAAI,MAAM,KAAK,QAAA,GAAOD,UAAAA,UAAAA,CAAU,SAAS,SAAS;CAClD,IAAI,MAAM,KAAM,QAAA,GAAOA,UAAAA,UAAAA,CAAU,UAAU,SAAS;CAEpD,QAAA,GAAOA,UAAAA,UAAAA,CAAU,OAAO,SAAS;AACnC;;;;;AAMA,SAAgB,UAAU,MAAc,OAAe,OAAO,IAAY;CACxE,MAAM,SAAS,CAAC,OAAO,IAAI,QAAQ,QAAQ,OAAO,KAAK,IAAI,OAAO,GAAG,KAAK,IAAI,GAAG,KAAK,MAAO,OAAO,QAAS,IAAI,CAAC,CAAC;CACnH,QAAA,GAAOA,UAAAA,UAAAA,CAAU,WAAW,IAAI,OAAO,MAAM,CAAC,KAAA,GAAIA,UAAAA,UAAAA,CAAU,OAAO,IAAI,OAAO,OAAO,MAAM,CAAC;AAC9F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as getConfigs } from "./config-Uk3rbZfb.js";
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C3-Zg-KD.cjs");
|
|
2
|
+
const require_errors = require("./errors-BponpdjN.cjs");
|
|
3
|
+
const require_config = require("./config-CRrmj88c.cjs");
|
|
4
|
+
let node_process = require("node:process");
|
|
5
|
+
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
6
|
+
let node_path = require("node:path");
|
|
7
|
+
let _kubb_core = require("@kubb/core");
|
|
8
|
+
// src/config.ts
|
|
9
|
+
var config_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({ getConfigs: () => getConfigs });
|
|
10
|
+
/** Discovers the Kubb config and resolves it into normalized configs, each guaranteed to have a `plugins` array. */
|
|
11
|
+
async function getConfigs({ configPath, input, watch, logLevel }) {
|
|
12
|
+
const file = configPath ? (0, node_path.resolve)(configPath) : require_config.findConfigFile();
|
|
13
|
+
if (!file) throw new _kubb_core.Diagnostics.Error({
|
|
14
|
+
code: _kubb_core.Diagnostics.code.unknown,
|
|
15
|
+
severity: "error",
|
|
16
|
+
message: `No Kubb config found. Looked for kubb.config.* and .kubbrc.* (${require_config.CONFIG_EXTENSIONS.join(", ")}) in ${node_process.default.cwd()}, its .config/ and configs/ folders, and each parent folder.`,
|
|
17
|
+
help: "Run `kubb init` to create one, or pass a path with `--config`.",
|
|
18
|
+
location: { kind: "config" }
|
|
19
|
+
});
|
|
20
|
+
let configs;
|
|
21
|
+
try {
|
|
22
|
+
configs = await require_config.loadConfigFile({
|
|
23
|
+
file,
|
|
24
|
+
cli: {
|
|
25
|
+
config: configPath,
|
|
26
|
+
input,
|
|
27
|
+
watch,
|
|
28
|
+
logLevel
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw new _kubb_core.Diagnostics.Error({
|
|
33
|
+
code: _kubb_core.Diagnostics.code.unknown,
|
|
34
|
+
severity: "error",
|
|
35
|
+
message: `Config failed loading: ${file}`,
|
|
36
|
+
help: "Fix the error the config file throws, shown under `caused by:`.",
|
|
37
|
+
location: { kind: "config" },
|
|
38
|
+
cause: require_errors.toError(error)
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
configPath: file,
|
|
43
|
+
configs: configs.map((item) => ({
|
|
44
|
+
...item,
|
|
45
|
+
plugins: item.plugins ?? []
|
|
46
|
+
}))
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
Object.defineProperty(exports, "config_exports", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function() {
|
|
52
|
+
return config_exports;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, "getConfigs", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function() {
|
|
58
|
+
return getConfigs;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=config-BWj9jBVj.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-BWj9jBVj.cjs","names":["resolve","findConfigFile","Diagnostics","CONFIG_EXTENSIONS","process","loadConfigFile","toError"],"sources":["../src/config.ts"],"sourcesContent":["import { resolve } from 'node:path'\nimport process from 'node:process'\nimport { CONFIG_EXTENSIONS, findConfigFile, loadConfigFile } from '@internals/shared'\nimport { type CLIOptions, type Config, Diagnostics } from '@kubb/core'\nimport { toError } from '@internals/utils'\n\ntype GetConfigsOptions = {\n /** Explicit path to the Kubb config file. When omitted, the loader searches up from `process.cwd()`. */\n configPath?: string\n /** OpenAPI input path or URL that overrides `config.input` for this run. */\n input?: string\n /** Watch flag forwarded to the user's `defineConfig` function. */\n watch?: boolean\n /** Log level forwarded to the user's `defineConfig` function. */\n logLevel?: CLIOptions['logLevel']\n}\n\ntype GetConfigsResult = {\n /** Absolute path to the resolved config file. */\n configPath: string\n /** Resolved and normalized Kubb configs, each guaranteed to have a `plugins` array. */\n configs: Array<Config>\n}\n\n/** Discovers the Kubb config and resolves it into normalized configs, each guaranteed to have a `plugins` array. */\nexport async function getConfigs({ configPath, input, watch, logLevel }: GetConfigsOptions): Promise<GetConfigsResult> {\n const file = configPath ? resolve(configPath) : findConfigFile()\n if (!file) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `No Kubb config found. Looked for kubb.config.* and .kubbrc.* (${CONFIG_EXTENSIONS.join(', ')}) in ${process.cwd()}, its .config/ and configs/ folders, and each parent folder.`,\n help: 'Run `kubb init` to create one, or pass a path with `--config`.',\n location: { kind: 'config' },\n })\n }\n\n let configs: Array<Config>\n try {\n configs = await loadConfigFile<Config>({ file, cli: { config: configPath, input, watch, logLevel } satisfies CLIOptions })\n } catch (error) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `Config failed loading: ${file}`,\n help: 'Fix the error the config file throws, shown under `caused by:`.',\n location: { kind: 'config' },\n cause: toError(error),\n })\n }\n\n return { configPath: file, configs: configs.map((item) => ({ ...item, plugins: item.plugins ?? [] })) }\n}\n"],"mappings":";;;;;;;;;;AAyBA,eAAsB,WAAW,EAAE,YAAY,OAAO,OAAO,YAA0D;CACrH,MAAM,OAAO,cAAA,GAAaA,UAAAA,QAAAA,CAAQ,UAAU,IAAIC,eAAAA,eAAe;CAC/D,IAAI,CAAC,MACH,MAAM,IAAIC,WAAAA,YAAY,MAAM;EAC1B,MAAMA,WAAAA,YAAY,KAAK;EACvB,UAAU;EACV,SAAS,iEAAiEC,eAAAA,kBAAkB,KAAK,IAAI,EAAE,OAAOC,aAAAA,QAAQ,IAAI,EAAE;EAC5H,MAAM;EACN,UAAU,EAAE,MAAM,SAAS;CAC7B,CAAC;CAGH,IAAI;CACJ,IAAI;EACF,UAAU,MAAMC,eAAAA,eAAuB;GAAE;GAAM,KAAK;IAAE,QAAQ;IAAY;IAAO;IAAO;GAAS;EAAuB,CAAC;CAC3H,SAAS,OAAO;EACd,MAAM,IAAIH,WAAAA,YAAY,MAAM;GAC1B,MAAMA,WAAAA,YAAY,KAAK;GACvB,UAAU;GACV,SAAS,0BAA0B;GACnC,MAAM;GACN,UAAU,EAAE,MAAM,SAAS;GAC3B,OAAOI,eAAAA,QAAQ,KAAK;EACtB,CAAC;CACH;CAEA,OAAO;EAAE,YAAY;EAAM,SAAS,QAAQ,KAAK,UAAU;GAAE,GAAG;GAAM,SAAS,KAAK,WAAW,CAAC;EAAE,EAAE;CAAE;AACxG"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import "./rolldown-runtime-
|
|
2
|
-
import { n as toError } from "./errors-DmC83ALX.js";
|
|
1
|
+
import "./rolldown-runtime-xo6NMXYd.js";
|
|
3
2
|
import process from "node:process";
|
|
4
3
|
import { readFile } from "node:fs/promises";
|
|
5
4
|
import { basename, dirname, join, resolve } from "node:path";
|
|
6
5
|
import { existsSync } from "node:fs";
|
|
7
|
-
import { Diagnostics } from "@kubb/core";
|
|
8
6
|
import { createJiti } from "jiti";
|
|
9
|
-
|
|
7
|
+
// ../../internals/shared/src/constants.ts
|
|
10
8
|
const KUBB_CONFIG_FILENAME = "kubb.config.ts";
|
|
11
9
|
/** File extensions a Kubb config file may use. */
|
|
12
10
|
const CONFIG_EXTENSIONS = [
|
|
@@ -33,8 +31,7 @@ const initDefaults = {
|
|
|
33
31
|
outputPath: "./src/gen",
|
|
34
32
|
plugins: ["plugin-ts"]
|
|
35
33
|
};
|
|
36
|
-
|
|
37
|
-
//#region ../../internals/shared/src/loader.ts
|
|
34
|
+
// ../../internals/shared/src/loader.ts
|
|
38
35
|
/**
|
|
39
36
|
* jiti options for loading Kubb config modules: the automatic JSX runtime pointed at
|
|
40
37
|
* `@kubb/renderer-jsx`, and `moduleCache` off so a re-load re-evaluates the file.
|
|
@@ -72,8 +69,7 @@ async function loadModule(filePath, options) {
|
|
|
72
69
|
});
|
|
73
70
|
return options?.default ? mod?.default ?? mod : mod;
|
|
74
71
|
}
|
|
75
|
-
|
|
76
|
-
//#region ../../internals/shared/src/config.ts
|
|
72
|
+
// ../../internals/shared/src/config.ts
|
|
77
73
|
const CONFIG_FOLDERS = [".config", "configs"];
|
|
78
74
|
const SEARCH_FILES = ["", ...CONFIG_FOLDERS.map((folder) => `${folder}/`)].flatMap((prefix) => [`${prefix}.kubbrc`, `${prefix}kubb.config`]);
|
|
79
75
|
/**
|
|
@@ -108,48 +104,6 @@ async function loadConfigFile({ file, cli }) {
|
|
|
108
104
|
root: resolve(dir, config.root ?? ".")
|
|
109
105
|
}));
|
|
110
106
|
}
|
|
111
|
-
|
|
112
|
-
//#region src/config.ts
|
|
113
|
-
/** Discovers the Kubb config and resolves it into normalized configs, each guaranteed to have a `plugins` array. */
|
|
114
|
-
async function getConfigs({ configPath, input, watch, logLevel }) {
|
|
115
|
-
const file = configPath ? resolve(configPath) : findConfigFile();
|
|
116
|
-
if (!file) throw new Diagnostics.Error({
|
|
117
|
-
code: Diagnostics.code.unknown,
|
|
118
|
-
severity: "error",
|
|
119
|
-
message: `No Kubb config found. Looked for kubb.config.* and .kubbrc.* (${CONFIG_EXTENSIONS.join(", ")}) in ${process.cwd()}, its .config/ and configs/ folders, and each parent folder.`,
|
|
120
|
-
help: "Run `kubb init` to create one, or pass a path with `--config`.",
|
|
121
|
-
location: { kind: "config" }
|
|
122
|
-
});
|
|
123
|
-
let configs;
|
|
124
|
-
try {
|
|
125
|
-
configs = await loadConfigFile({
|
|
126
|
-
file,
|
|
127
|
-
cli: {
|
|
128
|
-
config: configPath,
|
|
129
|
-
input,
|
|
130
|
-
watch,
|
|
131
|
-
logLevel
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
} catch (error) {
|
|
135
|
-
throw new Diagnostics.Error({
|
|
136
|
-
code: Diagnostics.code.unknown,
|
|
137
|
-
severity: "error",
|
|
138
|
-
message: `Config failed loading: ${file}`,
|
|
139
|
-
help: "Fix the error the config file throws, shown under `caused by:`.",
|
|
140
|
-
location: { kind: "config" },
|
|
141
|
-
cause: toError(error)
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
return {
|
|
145
|
-
configPath: file,
|
|
146
|
-
configs: configs.map((item) => ({
|
|
147
|
-
...item,
|
|
148
|
-
plugins: item.plugins ?? []
|
|
149
|
-
}))
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
//#endregion
|
|
153
|
-
export { KUBB_PACKAGE_NAME as a, KUBB_CONFIG_FILENAME as i, findConfigFile as n, initDefaults as o, BUNDLED_PACKAGES as r, getConfigs as t };
|
|
107
|
+
export { KUBB_CONFIG_FILENAME as a, CONFIG_EXTENSIONS as i, loadConfigFile as n, KUBB_PACKAGE_NAME as o, BUNDLED_PACKAGES as r, initDefaults as s, findConfigFile as t };
|
|
154
108
|
|
|
155
|
-
//# sourceMappingURL=config-
|
|
109
|
+
//# sourceMappingURL=config-CQTxXvIG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-CQTxXvIG.js","names":[],"sources":["../../../internals/shared/src/constants.ts","../../../internals/shared/src/loader.ts","../../../internals/shared/src/config.ts"],"sourcesContent":["export const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const\n\n/** File extensions a Kubb config file may use. */\nexport const CONFIG_EXTENSIONS = ['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs'] as const\n\nexport const KUBB_PACKAGE_NAME = 'kubb' as const\n\n/**\n * Extensions `kubb` ships at its own version, so they count as installed without being a direct\n * dependency. `constants.test.ts` checks it against the `kubb` package's dependencies.\n */\nexport const BUNDLED_PACKAGES: ReadonlyArray<string> = ['@kubb/adapter-oas', '@kubb/parser-ts', '@kubb/parser-md', '@kubb/plugin-barrel']\n\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-ts'],\n} as const\n","import { readFile } from 'node:fs/promises'\nimport { createJiti } from 'jiti'\n\n/**\n * jiti options for loading Kubb config modules: the automatic JSX runtime pointed at\n * `@kubb/renderer-jsx`, and `moduleCache` off so a re-load re-evaluates the file.\n */\nconst JITI_OPTIONS = {\n jsx: { runtime: 'automatic', importSource: '@kubb/renderer-jsx' },\n moduleCache: false,\n} satisfies Parameters<typeof createJiti>[1]\n\n/**\n * Plain JavaScript files. jiti hands these to Node's native `import()`, whose module cache never\n * lets go of a file, so `moduleCache: false` alone would keep returning the first version of it.\n */\nconst JAVASCRIPT_EXTENSION = /\\.[cm]?jsx?$/\n\n/**\n * Per-call options for {@link loadModule}.\n */\ntype LoadModuleOptions = {\n /**\n * Return the module's default export instead of the full namespace.\n */\n default?: boolean\n}\n\nconst jiti = createJiti(import.meta.url, JITI_OPTIONS)\n\n/**\n * Loads a Kubb TypeScript or JavaScript config module via jiti.\n *\n * jiti transpiles TypeScript and the `@kubb/renderer-jsx` JSX runtime on the fly. Every load\n * re-evaluates the file, so a config edited on disk is picked up by the next load.\n *\n * @example\n * ```ts\n * const config = await loadModule('/abs/kubb.config.ts', { default: true })\n * ```\n */\nexport async function loadModule<T = unknown>(filePath: string, options?: LoadModuleOptions): Promise<T> {\n if (!JAVASCRIPT_EXTENSION.test(filePath)) {\n return (options?.default ? jiti.import(filePath, { default: true }) : jiti.import(filePath)) as Promise<T>\n }\n\n // Transpiled through jiti instead, so every load re-evaluates the file as it is on disk now.\n // A TypeScript file it imports reloads too. A plain JavaScript file it imports still goes\n // through Node's `import()` and stays cached until the process restarts.\n const mod = (await jiti.evalModule(await readFile(filePath, 'utf8'), { filename: filePath, async: true, forceTranspile: true })) as\n | { default?: unknown }\n | undefined\n return (options?.default ? (mod?.default ?? mod) : mod) as T\n}\n","import { existsSync } from 'node:fs'\nimport { basename, dirname, join, resolve } from 'node:path'\nimport process from 'node:process'\nimport { CONFIG_EXTENSIONS } from './constants.ts'\nimport { loadModule } from './loader.ts'\n\n// A config in one of these folders belongs to the folder above it.\nconst CONFIG_FOLDERS = ['.config', 'configs']\nconst SEARCH_FILES = ['', ...CONFIG_FOLDERS.map((folder) => `${folder}/`)].flatMap((prefix) => [`${prefix}.kubbrc`, `${prefix}kubb.config`])\n\n/**\n * Every config file path the Kubb CLI checks in `dir`, in the order it checks them.\n */\nexport function configFileCandidates(dir: string): Array<string> {\n return SEARCH_FILES.flatMap((file) => CONFIG_EXTENSIONS.map((extension) => join(dir, `${file}${extension}`)))\n}\n\n/**\n * The first Kubb config file in `cwd` or the nearest parent folder that has one: `.kubbrc` before\n * `kubb.config`, the folder itself before its `.config/` and `configs/`, and {@link CONFIG_EXTENSIONS} in order.\n */\nexport function findConfigFile(cwd: string = process.cwd()): string | undefined {\n for (let dir = resolve(cwd); ; dir = dirname(dir)) {\n const found = configFileCandidates(dir).find((file) => existsSync(file))\n if (found || dirname(dir) === dir) return found\n }\n}\n\n/**\n * Loads a Kubb config module, calls it with `cli` when it exports a function, and returns its\n * configs as a list, so a single config and a `defineConfig([...])` array read the same. Each\n * `root` resolves from the folder the config belongs to: the file's folder, or the folder above\n * `.config/` and `configs/`. A missing `root` becomes that folder, so the CLI, the bundler, and\n * an editor read the same paths wherever they run.\n */\nexport async function loadConfigFile<T extends { root?: string }>({ file, cli }: { file: string; cli: unknown }): Promise<Array<T>> {\n const loaded = await loadModule<unknown>(file, { default: true })\n const resolved = (await (typeof loaded === 'function' ? loaded(cli) : loaded)) as T | Array<T>\n const dir = CONFIG_FOLDERS.includes(basename(dirname(file))) ? dirname(dirname(file)) : dirname(file)\n return (Array.isArray(resolved) ? resolved : [resolved]).map((config) => ({ ...config, root: resolve(dir, config.root ?? '.') }))\n}\n"],"mappings":";;;;;;;AAAA,MAAa,uBAAuB;;AAGpC,MAAa,oBAAoB;CAAC;CAAO;CAAQ;CAAQ;CAAO;CAAQ;AAAM;AAE9E,MAAa,oBAAoB;;;;;AAMjC,MAAa,mBAA0C;CAAC;CAAqB;CAAmB;CAAmB;AAAqB;AAExI,MAAa,eAAe;CAC1B,WAAW;CACX,YAAY;CACZ,SAAS,CAAC,WAAW;AACvB;;;;;;ACVA,MAAM,eAAe;CACnB,KAAK;EAAE,SAAS;EAAa,cAAc;CAAqB;CAChE,aAAa;AACf;;;;;AAMA,MAAM,uBAAuB;AAY7B,MAAM,OAAO,WAAW,YAAY,KAAK,YAAY;;;;;;;;;;;;AAarD,eAAsB,WAAwB,UAAkB,SAAyC;CACvG,IAAI,CAAC,qBAAqB,KAAK,QAAQ,GACrC,OAAQ,SAAS,UAAU,KAAK,OAAO,UAAU,EAAE,SAAS,KAAK,CAAC,IAAI,KAAK,OAAO,QAAQ;CAM5F,MAAM,MAAO,MAAM,KAAK,WAAW,MAAM,SAAS,UAAU,MAAM,GAAG;EAAE,UAAU;EAAU,OAAO;EAAM,gBAAgB;CAAK,CAAC;CAG9H,OAAQ,SAAS,UAAW,KAAK,WAAW,MAAO;AACrD;;AC9CA,MAAM,iBAAiB,CAAC,WAAW,SAAS;AAC5C,MAAM,eAAe,CAAC,IAAI,GAAG,eAAe,KAAK,WAAW,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,OAAO,UAAU,GAAG,OAAO,YAAY,CAAC;;;;AAK3I,SAAgB,qBAAqB,KAA4B;CAC/D,OAAO,aAAa,SAAS,SAAS,kBAAkB,KAAK,cAAc,KAAK,KAAK,GAAG,OAAO,WAAW,CAAC,CAAC;AAC9G;;;;;AAMA,SAAgB,eAAe,MAAc,QAAQ,IAAI,GAAuB;CAC9E,KAAK,IAAI,MAAM,QAAQ,GAAG,IAAK,MAAM,QAAQ,GAAG,GAAG;EACjD,MAAM,QAAQ,qBAAqB,GAAG,CAAC,CAAC,MAAM,SAAS,WAAW,IAAI,CAAC;EACvE,IAAI,SAAS,QAAQ,GAAG,MAAM,KAAK,OAAO;CAC5C;AACF;;;;;;;;AASA,eAAsB,eAA4C,EAAE,MAAM,OAA0D;CAClI,MAAM,SAAS,MAAM,WAAoB,MAAM,EAAE,SAAS,KAAK,CAAC;CAChE,MAAM,WAAY,OAAO,OAAO,WAAW,aAAa,OAAO,GAAG,IAAI;CACtE,MAAM,MAAM,eAAe,SAAS,SAAS,QAAQ,IAAI,CAAC,CAAC,IAAI,QAAQ,QAAQ,IAAI,CAAC,IAAI,QAAQ,IAAI;CACpG,QAAQ,MAAM,QAAQ,QAAQ,IAAI,WAAW,CAAC,QAAQ,EAAA,CAAG,KAAK,YAAY;EAAE,GAAG;EAAQ,MAAM,QAAQ,KAAK,OAAO,QAAQ,GAAG;CAAE,EAAE;AAClI"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
2
|
-
const require_errors = require("./errors-Cl69p_vI.cjs");
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C3-Zg-KD.cjs");
|
|
3
2
|
let node_process = require("node:process");
|
|
4
3
|
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
5
4
|
let node_fs_promises = require("node:fs/promises");
|
|
6
5
|
let node_path = require("node:path");
|
|
7
6
|
let node_fs = require("node:fs");
|
|
8
|
-
let _kubb_core = require("@kubb/core");
|
|
9
7
|
let jiti = require("jiti");
|
|
10
|
-
|
|
8
|
+
// ../../internals/shared/src/constants.ts
|
|
11
9
|
const KUBB_CONFIG_FILENAME = "kubb.config.ts";
|
|
12
10
|
/** File extensions a Kubb config file may use. */
|
|
13
11
|
const CONFIG_EXTENSIONS = [
|
|
@@ -34,8 +32,7 @@ const initDefaults = {
|
|
|
34
32
|
outputPath: "./src/gen",
|
|
35
33
|
plugins: ["plugin-ts"]
|
|
36
34
|
};
|
|
37
|
-
|
|
38
|
-
//#region ../../internals/shared/src/loader.ts
|
|
35
|
+
// ../../internals/shared/src/loader.ts
|
|
39
36
|
/**
|
|
40
37
|
* jiti options for loading Kubb config modules: the automatic JSX runtime pointed at
|
|
41
38
|
* `@kubb/renderer-jsx`, and `moduleCache` off so a re-load re-evaluates the file.
|
|
@@ -73,8 +70,7 @@ async function loadModule(filePath, options) {
|
|
|
73
70
|
});
|
|
74
71
|
return options?.default ? mod?.default ?? mod : mod;
|
|
75
72
|
}
|
|
76
|
-
|
|
77
|
-
//#region ../../internals/shared/src/config.ts
|
|
73
|
+
// ../../internals/shared/src/config.ts
|
|
78
74
|
const CONFIG_FOLDERS = [".config", "configs"];
|
|
79
75
|
const SEARCH_FILES = ["", ...CONFIG_FOLDERS.map((folder) => `${folder}/`)].flatMap((prefix) => [`${prefix}.kubbrc`, `${prefix}kubb.config`]);
|
|
80
76
|
/**
|
|
@@ -109,71 +105,28 @@ async function loadConfigFile({ file, cli }) {
|
|
|
109
105
|
root: (0, node_path.resolve)(dir, config.root ?? ".")
|
|
110
106
|
}));
|
|
111
107
|
}
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/config.ts
|
|
114
|
-
var config_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({ getConfigs: () => getConfigs });
|
|
115
|
-
/** Discovers the Kubb config and resolves it into normalized configs, each guaranteed to have a `plugins` array. */
|
|
116
|
-
async function getConfigs({ configPath, input, watch, logLevel }) {
|
|
117
|
-
const file = configPath ? (0, node_path.resolve)(configPath) : findConfigFile();
|
|
118
|
-
if (!file) throw new _kubb_core.Diagnostics.Error({
|
|
119
|
-
code: _kubb_core.Diagnostics.code.unknown,
|
|
120
|
-
severity: "error",
|
|
121
|
-
message: `No Kubb config found. Looked for kubb.config.* and .kubbrc.* (${CONFIG_EXTENSIONS.join(", ")}) in ${node_process.default.cwd()}, its .config/ and configs/ folders, and each parent folder.`,
|
|
122
|
-
help: "Run `kubb init` to create one, or pass a path with `--config`.",
|
|
123
|
-
location: { kind: "config" }
|
|
124
|
-
});
|
|
125
|
-
let configs;
|
|
126
|
-
try {
|
|
127
|
-
configs = await loadConfigFile({
|
|
128
|
-
file,
|
|
129
|
-
cli: {
|
|
130
|
-
config: configPath,
|
|
131
|
-
input,
|
|
132
|
-
watch,
|
|
133
|
-
logLevel
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
} catch (error) {
|
|
137
|
-
throw new _kubb_core.Diagnostics.Error({
|
|
138
|
-
code: _kubb_core.Diagnostics.code.unknown,
|
|
139
|
-
severity: "error",
|
|
140
|
-
message: `Config failed loading: ${file}`,
|
|
141
|
-
help: "Fix the error the config file throws, shown under `caused by:`.",
|
|
142
|
-
location: { kind: "config" },
|
|
143
|
-
cause: require_errors.toError(error)
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
return {
|
|
147
|
-
configPath: file,
|
|
148
|
-
configs: configs.map((item) => ({
|
|
149
|
-
...item,
|
|
150
|
-
plugins: item.plugins ?? []
|
|
151
|
-
}))
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
//#endregion
|
|
155
108
|
Object.defineProperty(exports, "BUNDLED_PACKAGES", {
|
|
156
109
|
enumerable: true,
|
|
157
110
|
get: function() {
|
|
158
111
|
return BUNDLED_PACKAGES;
|
|
159
112
|
}
|
|
160
113
|
});
|
|
161
|
-
Object.defineProperty(exports, "
|
|
114
|
+
Object.defineProperty(exports, "CONFIG_EXTENSIONS", {
|
|
162
115
|
enumerable: true,
|
|
163
116
|
get: function() {
|
|
164
|
-
return
|
|
117
|
+
return CONFIG_EXTENSIONS;
|
|
165
118
|
}
|
|
166
119
|
});
|
|
167
|
-
Object.defineProperty(exports, "
|
|
120
|
+
Object.defineProperty(exports, "KUBB_CONFIG_FILENAME", {
|
|
168
121
|
enumerable: true,
|
|
169
122
|
get: function() {
|
|
170
|
-
return
|
|
123
|
+
return KUBB_CONFIG_FILENAME;
|
|
171
124
|
}
|
|
172
125
|
});
|
|
173
|
-
Object.defineProperty(exports, "
|
|
126
|
+
Object.defineProperty(exports, "KUBB_PACKAGE_NAME", {
|
|
174
127
|
enumerable: true,
|
|
175
128
|
get: function() {
|
|
176
|
-
return
|
|
129
|
+
return KUBB_PACKAGE_NAME;
|
|
177
130
|
}
|
|
178
131
|
});
|
|
179
132
|
Object.defineProperty(exports, "findConfigFile", {
|
|
@@ -182,17 +135,17 @@ Object.defineProperty(exports, "findConfigFile", {
|
|
|
182
135
|
return findConfigFile;
|
|
183
136
|
}
|
|
184
137
|
});
|
|
185
|
-
Object.defineProperty(exports, "
|
|
138
|
+
Object.defineProperty(exports, "initDefaults", {
|
|
186
139
|
enumerable: true,
|
|
187
140
|
get: function() {
|
|
188
|
-
return
|
|
141
|
+
return initDefaults;
|
|
189
142
|
}
|
|
190
143
|
});
|
|
191
|
-
Object.defineProperty(exports, "
|
|
144
|
+
Object.defineProperty(exports, "loadConfigFile", {
|
|
192
145
|
enumerable: true,
|
|
193
146
|
get: function() {
|
|
194
|
-
return
|
|
147
|
+
return loadConfigFile;
|
|
195
148
|
}
|
|
196
149
|
});
|
|
197
150
|
|
|
198
|
-
//# sourceMappingURL=config-
|
|
151
|
+
//# sourceMappingURL=config-CRrmj88c.cjs.map
|