@kaynooo/cli-env 0.11.0 → 0.13.0
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/ev.js +204 -334
- package/dist/redact.js +188 -323
- package/package.json +2 -2
- package/src/audit.ts +1 -2
- package/src/commands/audit.ts +5 -3
- package/src/commands/compare.ts +9 -3
- package/src/ev.ts +1 -1
- package/src/files.ts +3 -2
- package/src/pins.ts +1 -1
- package/src/redact.ts +1 -1
package/dist/redact.js
CHANGED
|
@@ -1,290 +1,118 @@
|
|
|
1
|
-
#!/usr/bin/env -S bun --no-env-file
|
|
1
|
+
#!/usr/bin/env -S bun --no-env-file --config=/dev/null
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/redact.ts
|
|
5
|
-
import
|
|
5
|
+
import process15 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
|
-
import
|
|
7
|
+
import process10 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
9
9
|
|
|
10
10
|
// ../kit/src/format.ts
|
|
11
|
-
import
|
|
11
|
+
import process7 from "process";
|
|
12
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
|
|
13
|
+
var N = new Map;
|
|
14
|
+
var Nt = /\s+\S*$/;
|
|
15
|
+
var Y = /\s/;
|
|
16
|
+
function ko(t, e, r = "...") {
|
|
17
|
+
let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
|
|
18
|
+
if (t.length <= e)
|
|
19
|
+
return t;
|
|
20
|
+
let l = Math.max(0, e), c = t.substring(0, Math.max(0, s ? l - n.length : l));
|
|
21
|
+
if (o && !Y.test(t[c.length] ?? " "))
|
|
22
|
+
c = c.replace(Nt, "") || c;
|
|
23
|
+
if (o)
|
|
24
|
+
c = c.trimEnd();
|
|
25
|
+
return s ? (c + n).slice(0, l) : c + n;
|
|
26
|
+
}
|
|
27
|
+
var be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
|
|
28
|
+
var z = new Map;
|
|
29
|
+
// ../kit/src/mode.ts
|
|
30
|
+
import process2 from "process";
|
|
31
|
+
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
32
|
+
var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
33
|
+
function isSet(value) {
|
|
34
|
+
return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
35
|
+
}
|
|
36
|
+
function outputMode(stream = process2.stdout, env = process2.env) {
|
|
37
|
+
const chosen = env.KIT_MODE;
|
|
38
|
+
if (chosen !== undefined && MODES.has(chosen))
|
|
39
|
+
return chosen;
|
|
40
|
+
if (AGENT_VARIABLES.some((name) => isSet(env[name])))
|
|
41
|
+
return "agent";
|
|
42
|
+
if (stream.isTTY === true)
|
|
43
|
+
return "terminal";
|
|
44
|
+
return isSet(env.CI) ? "ci" : "pipe";
|
|
45
|
+
}
|
|
12
46
|
|
|
13
47
|
// ../kit/src/style.ts
|
|
14
|
-
import
|
|
48
|
+
import process6 from "process";
|
|
15
49
|
|
|
16
|
-
// ../../node_modules/.bun/@kaynooo+utils@
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
50
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
51
|
+
var G2 = /^[a-f0-9]+$/i;
|
|
52
|
+
function b(r) {
|
|
53
|
+
let e = r.startsWith("#") ? r.slice(1) : r;
|
|
54
|
+
if (!G2.test(e))
|
|
20
55
|
return [0, 0, 0];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
return `#${(r << 24 | t << 16 | n << 8 | Math.round((a ?? 1) * 255)).toString(16).padStart(8, "0").toUpperCase()}`;
|
|
37
|
-
return `#${(r << 16 | t << 8 | n).toString(16).padStart(6, "0").toUpperCase()}`;
|
|
38
|
-
}
|
|
39
|
-
function R(s, r, t) {
|
|
40
|
-
s = (s % 360 + 360) % 360, t /= 100;
|
|
41
|
-
let n = r * Math.min(t, 1 - t) / 100, a = (b) => {
|
|
42
|
-
let o = (b + s / 30) % 12, y = t - n * Math.max(Math.min(o - 3, 9 - o, 1), -1);
|
|
43
|
-
return Math.round(255 * y);
|
|
44
|
-
};
|
|
45
|
-
return [a(0), a(8), a(4)];
|
|
46
|
-
}
|
|
47
|
-
function k(s) {
|
|
48
|
-
let [r, t, n] = s;
|
|
49
|
-
r /= 255, t /= 255, n /= 255;
|
|
50
|
-
let a = Math.max(r, t, n), b = Math.min(r, t, n), o = 0, y = 0, c = (a + b) / 2;
|
|
51
|
-
if (a !== b) {
|
|
52
|
-
let u = a - b;
|
|
53
|
-
if (y = c > 0 && c < 1 ? u / (1 - Math.abs(2 * c - 1)) : 0, a === r)
|
|
54
|
-
o = (t - n) / u + (t < n ? 6 : 0);
|
|
55
|
-
else if (a === t)
|
|
56
|
-
o = (n - r) / u + 2;
|
|
57
|
-
else
|
|
58
|
-
o = (r - t) / u + 4;
|
|
59
|
-
o /= 6;
|
|
60
|
-
}
|
|
61
|
-
return [Math.round(o * 360), Math.round(y * 100), Math.round(c * 100)];
|
|
62
|
-
}
|
|
63
|
-
function H(s, r, t) {
|
|
64
|
-
s = (s % 360 + 360) % 360, r /= 100, t /= 100;
|
|
65
|
-
let n = (a) => {
|
|
66
|
-
let b = (a + s / 60) % 6, o = t - t * r * Math.max(Math.min(b, 4 - b, 1), 0);
|
|
67
|
-
return Math.round(255 * o);
|
|
68
|
-
};
|
|
69
|
-
return [n(5), n(3), n(1)];
|
|
70
|
-
}
|
|
71
|
-
function f(s) {
|
|
72
|
-
let [r, t, n] = s;
|
|
73
|
-
r /= 255, t /= 255, n /= 255;
|
|
74
|
-
let a = Math.max(r, t, n), b = Math.min(r, t, n), o = a - b, y = 0, c = a === 0 ? 0 : o / a, u = a;
|
|
75
|
-
if (o !== 0) {
|
|
76
|
-
if (a === r)
|
|
77
|
-
y = (t - n) / o + (t < n ? 6 : 0);
|
|
78
|
-
else if (a === t)
|
|
79
|
-
y = (n - r) / o + 2;
|
|
80
|
-
else
|
|
81
|
-
y = (r - t) / o + 4;
|
|
82
|
-
y /= 6;
|
|
83
|
-
}
|
|
84
|
-
return [Math.round(y * 360), Math.round(c * 100), Math.round(u * 100)];
|
|
85
|
-
}
|
|
86
|
-
function O(s) {
|
|
87
|
-
let r = s[0] / 255, t = s[1] / 255, n = s[2] / 255, a = 1 - Math.max(r, t, n);
|
|
88
|
-
if (a === 1)
|
|
89
|
-
return [0, 0, 0, 100];
|
|
90
|
-
let b = (1 - r - a) / (1 - a), o = (1 - t - a) / (1 - a), y = (1 - n - a) / (1 - a);
|
|
91
|
-
return [Math.round(b * 100), Math.round(o * 100), Math.round(y * 100), Math.round(a * 100)];
|
|
92
|
-
}
|
|
93
|
-
function v(s, r, t, n) {
|
|
94
|
-
return s /= 100, r /= 100, t /= 100, n /= 100, [Math.round(255 * (1 - s) * (1 - n)), Math.round(255 * (1 - r) * (1 - n)), Math.round(255 * (1 - t) * (1 - n))];
|
|
95
|
-
}
|
|
96
|
-
var m = (s) => s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
97
|
-
var p = (s) => s <= 0.0031308 ? 12.92 * s : 1.055 * s ** 0.4166666666666667 - 0.055;
|
|
98
|
-
var i = (s, r) => Math.round(s * 10 ** r) / 10 ** r;
|
|
99
|
-
function T(s) {
|
|
100
|
-
let r = m(s[0] / 255), t = m(s[1] / 255), n = m(s[2] / 255), a = Math.cbrt(0.4122214708 * r + 0.5363325363 * t + 0.0514459929 * n), b = Math.cbrt(0.2119034982 * r + 0.6806995451 * t + 0.1073969566 * n), o = Math.cbrt(0.0883024619 * r + 0.2817188376 * t + 0.6299787005 * n);
|
|
101
|
-
return [i(0.2104542553 * a + 0.793617785 * b - 0.0040720468 * o, 4), i(1.9779984951 * a - 2.428592205 * b + 0.4505937099 * o, 4), i(0.0259040371 * a + 0.7827717662 * b - 0.808675766 * o, 4)];
|
|
102
|
-
}
|
|
103
|
-
function M(s, r, t) {
|
|
104
|
-
let n = (s + 0.3963377774 * r + 0.2158037573 * t) ** 3, a = (s - 0.1055613458 * r - 0.0638541728 * t) ** 3, b = (s - 0.0894841775 * r - 1.291485548 * t) ** 3, o = p(4.0767416621 * n - 3.3077115913 * a + 0.2309699292 * b), y = p(-1.2684380046 * n + 2.6097574011 * a - 0.3413193965 * b), c = p(-0.0041960863 * n - 0.7034186147 * a + 1.707614701 * b), u = (h) => Math.min(255, Math.max(0, Math.round(h * 255)));
|
|
105
|
-
return [u(o), u(y), u(c)];
|
|
106
|
-
}
|
|
107
|
-
function d(s) {
|
|
108
|
-
let [r, t, n] = T(s), a = Math.sqrt(t * t + n * n), b = (Math.atan2(n, t) * 180 / Math.PI + 360) % 360;
|
|
109
|
-
return [i(r, 4), i(a, 4), i(b, 2)];
|
|
110
|
-
}
|
|
111
|
-
function C(s, r, t) {
|
|
112
|
-
let n = t * Math.PI / 180;
|
|
113
|
-
return M(s, r * Math.cos(n), r * Math.sin(n));
|
|
114
|
-
}
|
|
115
|
-
function l(s) {
|
|
116
|
-
let r = s / 255;
|
|
117
|
-
return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
class e {
|
|
121
|
-
r;
|
|
122
|
-
g;
|
|
123
|
-
b;
|
|
124
|
-
a;
|
|
125
|
-
constructor(s, r, t, n = 1) {
|
|
126
|
-
this.r = s, this.g = r, this.b = t, this.a = n;
|
|
127
|
-
}
|
|
128
|
-
static from(s, r) {
|
|
129
|
-
if (s === "hex") {
|
|
130
|
-
let [t, n, a, b] = x(r);
|
|
131
|
-
return new e(t, n, a, b);
|
|
132
|
-
}
|
|
133
|
-
if (s === "rgb") {
|
|
134
|
-
if (Array.isArray(r)) {
|
|
135
|
-
let [o, y, c, u] = r;
|
|
136
|
-
return new e(o, y, c, u);
|
|
137
|
-
}
|
|
138
|
-
let { r: t, g: n, b: a, a: b } = r;
|
|
139
|
-
return new e(t, n, a, b);
|
|
140
|
-
}
|
|
141
|
-
if (s === "hsl") {
|
|
142
|
-
let t, n, a, b;
|
|
143
|
-
if (Array.isArray(r))
|
|
144
|
-
[t, n, a, b] = r;
|
|
145
|
-
else
|
|
146
|
-
({ h: t, s: n, l: a, a: b } = r);
|
|
147
|
-
let [o, y, c] = R(t, n, a);
|
|
148
|
-
return new e(o, y, c, b);
|
|
149
|
-
}
|
|
150
|
-
if (s === "hsv") {
|
|
151
|
-
let t, n, a, b;
|
|
152
|
-
if (Array.isArray(r))
|
|
153
|
-
[t, n, a, b] = r;
|
|
154
|
-
else
|
|
155
|
-
({ h: t, s: n, v: a, a: b } = r);
|
|
156
|
-
let [o, y, c] = H(t, n, a);
|
|
157
|
-
return new e(o, y, c, b);
|
|
158
|
-
}
|
|
159
|
-
if (s === "cmyk") {
|
|
160
|
-
let t, n, a, b, o;
|
|
161
|
-
if (Array.isArray(r))
|
|
162
|
-
[t, n, a, b, o] = r;
|
|
163
|
-
else
|
|
164
|
-
({ c: t, m: n, y: a, k: b, a: o } = r);
|
|
165
|
-
let [y, c, u] = v(t, n, a, b);
|
|
166
|
-
return new e(y, c, u, o);
|
|
167
|
-
}
|
|
168
|
-
if (s === "oklch") {
|
|
169
|
-
let t, n, a, b;
|
|
170
|
-
if (Array.isArray(r))
|
|
171
|
-
[t, n, a, b] = r;
|
|
172
|
-
else
|
|
173
|
-
({ l: t, c: n, h: a, a: b } = r);
|
|
174
|
-
let [o, y, c] = C(t, n, a);
|
|
175
|
-
return new e(o, y, c, b);
|
|
176
|
-
}
|
|
177
|
-
if (s === "oklab") {
|
|
178
|
-
let t, n, a, b;
|
|
179
|
-
if (Array.isArray(r))
|
|
180
|
-
[t, n, a, b] = r;
|
|
181
|
-
else
|
|
182
|
-
({ l: t, a: n, b: a, alpha: b } = r);
|
|
183
|
-
let [o, y, c] = M(t, n, a);
|
|
184
|
-
return new e(o, y, c, b);
|
|
185
|
-
}
|
|
186
|
-
throw Error("Invalid input");
|
|
187
|
-
}
|
|
188
|
-
to(s) {
|
|
189
|
-
switch (s) {
|
|
190
|
-
case "rgb":
|
|
191
|
-
return [this.r, this.g, this.b];
|
|
192
|
-
case "rgba":
|
|
193
|
-
return [this.r, this.g, this.b, this.a];
|
|
194
|
-
case "hex":
|
|
195
|
-
return A([this.r, this.g, this.b]);
|
|
196
|
-
case "hexa":
|
|
197
|
-
return A([this.r, this.g, this.b, this.a]);
|
|
198
|
-
case "hsl":
|
|
199
|
-
return k([this.r, this.g, this.b]);
|
|
200
|
-
case "hsla":
|
|
201
|
-
return [...k([this.r, this.g, this.b]), this.a];
|
|
202
|
-
case "hsv":
|
|
203
|
-
return f([this.r, this.g, this.b]);
|
|
204
|
-
case "hsva":
|
|
205
|
-
return [...f([this.r, this.g, this.b]), this.a];
|
|
206
|
-
case "cmyk":
|
|
207
|
-
return O([this.r, this.g, this.b]);
|
|
208
|
-
case "cmyka":
|
|
209
|
-
return [...O([this.r, this.g, this.b]), this.a];
|
|
210
|
-
case "oklch":
|
|
211
|
-
return d([this.r, this.g, this.b]);
|
|
212
|
-
case "oklcha":
|
|
213
|
-
return [...d([this.r, this.g, this.b]), this.a];
|
|
214
|
-
case "oklab":
|
|
215
|
-
return T([this.r, this.g, this.b]);
|
|
216
|
-
case "oklaba":
|
|
217
|
-
return [...T([this.r, this.g, this.b]), this.a];
|
|
218
|
-
default:
|
|
219
|
-
return [this.r, this.g, this.b];
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
getLuminance() {
|
|
223
|
-
let s = l(this.r), r = l(this.g), t = l(this.b);
|
|
224
|
-
return 0.2126 * s + 0.7152 * r + 0.0722 * t;
|
|
225
|
-
}
|
|
226
|
-
contrastRatio(s) {
|
|
227
|
-
let r = this.getLuminance(), t = s.getLuminance(), [n, a] = r >= t ? [r, t] : [t, r];
|
|
228
|
-
return (n + 0.05) / (a + 0.05);
|
|
229
|
-
}
|
|
230
|
-
bestContrastForeground() {
|
|
231
|
-
let s = new e(255, 255, 255, 1), r = new e(0, 0, 0, 1), t = this.contrastRatio(s), n = this.contrastRatio(r);
|
|
232
|
-
return t >= n ? s : r;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-y1msbssb.js
|
|
237
|
-
var r = 39;
|
|
238
|
-
var o = 49;
|
|
239
|
-
var f2 = "\x1B[";
|
|
240
|
-
var C2 = { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29], black: [30, r], red: [31, r], green: [32, r], yellow: [33, r], blue: [34, r], magenta: [35, r], cyan: [36, r], white: [37, r], gray: [90, r], grey: [90, r], blackBright: [90, r], redBright: [91, r], greenBright: [92, r], yellowBright: [93, r], blueBright: [94, r], magentaBright: [95, r], cyanBright: [96, r], whiteBright: [97, r], bgBlack: [40, o], bgRed: [41, o], bgGreen: [42, o], bgYellow: [43, o], bgBlue: [44, o], bgMagenta: [45, o], bgCyan: [46, o], bgWhite: [47, o], bgBlackBright: [100, o], bgRedBright: [101, o], bgGreenBright: [102, o], bgYellowBright: [103, o], bgBlueBright: [104, o], bgMagentaBright: [105, o], bgCyanBright: [106, o], bgWhiteBright: [107, o], rgb: (i, n, a, l = "fg") => [`${l === "fg" ? 38 : 48};2;${i};${n};${a}`, l === "fg" ? r : o], hex: (i, n = "fg") => {
|
|
241
|
-
let [a, l, s] = e.from("hex", i).to("rgb");
|
|
242
|
-
return [`${n === "fg" ? 38 : 48};2;${a};${l};${s}`, n === "fg" ? r : o];
|
|
243
|
-
}, ansi256: (i, n = "fg") => [`${n === "fg" ? 38 : 48};5;${i}`, n === "fg" ? r : o] };
|
|
244
|
-
var b = new Set(["", "1", "2", "3", "true"]);
|
|
245
|
-
function h(i, n = globalThis.process?.env ?? {}) {
|
|
246
|
-
if (n.FORCE_COLOR !== undefined)
|
|
247
|
-
return b.has(n.FORCE_COLOR);
|
|
248
|
-
if (n.NO_COLOR !== undefined || n.NODE_DISABLE_COLORS !== undefined || n.TERM === "dumb")
|
|
56
|
+
if (e.length === 3 || e.length === 4)
|
|
57
|
+
return [Number.parseInt(e[0] + e[0], 16), Number.parseInt(e[1] + e[1], 16), Number.parseInt(e[2] + e[2], 16)];
|
|
58
|
+
if (e.length !== 6 && e.length !== 8)
|
|
59
|
+
throw Error(`Invalid hex color length: ${e.length}`);
|
|
60
|
+
return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
|
|
61
|
+
}
|
|
62
|
+
var B2 = { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29], black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], gray: [90, 39], grey: [90, 39], blackBright: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39], bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49], rgb: (r, e, l, n = "fg") => [`${n === "fg" ? 38 : 48};2;${r};${e};${l}`, n === "fg" ? 39 : 49], hex: (r, e = "fg") => {
|
|
63
|
+
let [l, n, c] = b(r);
|
|
64
|
+
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
65
|
+
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
66
|
+
var h = new Set(["", "1", "2", "3", "true"]);
|
|
67
|
+
function C(r, e = globalThis.process?.env ?? {}) {
|
|
68
|
+
if (e.FORCE_COLOR !== undefined)
|
|
69
|
+
return h.has(e.FORCE_COLOR);
|
|
70
|
+
if (e.NO_COLOR !== undefined || e.NODE_DISABLE_COLORS !== undefined || e.TERM === "dumb")
|
|
249
71
|
return false;
|
|
250
|
-
return
|
|
251
|
-
}
|
|
252
|
-
function
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
if (
|
|
266
|
-
return
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
72
|
+
return r?.isTTY === true;
|
|
73
|
+
}
|
|
74
|
+
function f2(r, e = []) {
|
|
75
|
+
let l = "", n = "";
|
|
76
|
+
for (let t = 0, i = e.length;t < i; t++)
|
|
77
|
+
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
78
|
+
let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
|
|
79
|
+
return new Proxy(c, { get(t, i) {
|
|
80
|
+
let a = B2[i];
|
|
81
|
+
if (Array.isArray(a)) {
|
|
82
|
+
let s = g.get(i);
|
|
83
|
+
if (s === undefined)
|
|
84
|
+
s = f2(r, [...e, a]), g.set(i, s);
|
|
85
|
+
return s;
|
|
86
|
+
}
|
|
87
|
+
if (typeof a === "function")
|
|
88
|
+
return (...s) => {
|
|
89
|
+
let y = `${i}:${s.join(",")}`, u = g.get(y);
|
|
90
|
+
if (u === undefined) {
|
|
91
|
+
if (g.size >= 64)
|
|
92
|
+
g.clear();
|
|
93
|
+
u = f2(r, [...e, a(...s)]), g.set(y, u);
|
|
94
|
+
}
|
|
95
|
+
return u;
|
|
96
|
+
};
|
|
97
|
+
throw Error(`Unknown style: ${String(i)}`);
|
|
270
98
|
} });
|
|
271
99
|
}
|
|
272
|
-
function
|
|
273
|
-
return
|
|
100
|
+
function Fe2(r = {}) {
|
|
101
|
+
return f2(r);
|
|
274
102
|
}
|
|
275
|
-
var
|
|
103
|
+
var o2 = Fe2();
|
|
276
104
|
|
|
277
105
|
// ../kit/src/theme.ts
|
|
278
106
|
import { existsSync as existsSync2, readFileSync, statSync } from "fs";
|
|
279
107
|
import { homedir as homedir2 } from "os";
|
|
280
108
|
import { join as join3, resolve as resolve2 } from "path";
|
|
281
|
-
import
|
|
109
|
+
import process5 from "process";
|
|
282
110
|
|
|
283
111
|
// ../kit/src/config.ts
|
|
284
112
|
import { existsSync } from "fs";
|
|
285
113
|
import { dirname, join, resolve } from "path";
|
|
286
|
-
import
|
|
287
|
-
function findUp(names, from =
|
|
114
|
+
import process3 from "process";
|
|
115
|
+
function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
288
116
|
const wanted = typeof names === "string" ? [names] : names;
|
|
289
117
|
for (let dir = resolve(from);; dir = dirname(dir)) {
|
|
290
118
|
const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
|
|
@@ -298,9 +126,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
|
|
|
298
126
|
// ../kit/src/user-config.ts
|
|
299
127
|
import { homedir } from "os";
|
|
300
128
|
import { join as join2 } from "path";
|
|
301
|
-
import
|
|
129
|
+
import process4 from "process";
|
|
302
130
|
function configBase(where = {}) {
|
|
303
|
-
const xdg = where.xdg ?? (where.home === undefined ?
|
|
131
|
+
const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
|
|
304
132
|
return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
|
|
305
133
|
}
|
|
306
134
|
function userConfigPath(bin, where = {}) {
|
|
@@ -308,19 +136,21 @@ function userConfigPath(bin, where = {}) {
|
|
|
308
136
|
}
|
|
309
137
|
|
|
310
138
|
// ../kit/src/theme.ts
|
|
139
|
+
var ENDS = new Map;
|
|
311
140
|
var DEFAULT = {
|
|
312
|
-
colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
|
|
313
|
-
glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
|
|
141
|
+
colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", plan: "magenta", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
|
|
142
|
+
glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", plan: "\u25C7", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D", open: "\u2022", leaf: "\xB7", guide: "\u2502" },
|
|
314
143
|
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
315
|
-
bins: {}
|
|
144
|
+
bins: {},
|
|
145
|
+
gradient: ["#c084fc", "#67e8f9"]
|
|
316
146
|
};
|
|
317
|
-
var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
|
|
318
|
-
var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
|
|
319
|
-
var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
|
|
147
|
+
var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", plan: "magentaBright", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
|
|
148
|
+
var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", plan: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
|
|
149
|
+
var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
|
|
320
150
|
var PRESETS = {
|
|
321
151
|
default: {},
|
|
322
|
-
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
|
|
323
|
-
mono: { colors: MONO, accents: ["bold"] },
|
|
152
|
+
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
153
|
+
mono: { colors: MONO, accents: ["bold"], gradient: undefined },
|
|
324
154
|
ascii: { glyphs: ASCII }
|
|
325
155
|
};
|
|
326
156
|
var STYLES = new Set(["bold", "dim", "italic", "underline", "inverse", "strikethrough", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray", "grey", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright"]);
|
|
@@ -333,10 +163,30 @@ function isColorSpec(spec) {
|
|
|
333
163
|
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
334
164
|
return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
|
|
335
165
|
}
|
|
336
|
-
|
|
166
|
+
var CUBE = [0, 95, 135, 175, 215, 255];
|
|
167
|
+
function cubeLevel(channel) {
|
|
168
|
+
return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
|
|
169
|
+
}
|
|
170
|
+
function nearest256(hex) {
|
|
171
|
+
const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
|
|
172
|
+
const levels = rgb.map(cubeLevel);
|
|
173
|
+
const cube = levels.map((level) => CUBE[level]);
|
|
174
|
+
const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
|
|
175
|
+
const greyValue = 8 + grey * 10;
|
|
176
|
+
const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
|
|
177
|
+
return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
|
|
178
|
+
}
|
|
179
|
+
function hasTrueColor(env) {
|
|
180
|
+
return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
|
|
181
|
+
}
|
|
182
|
+
function tinted(colors, spec, env = process5.env) {
|
|
337
183
|
if (typeof spec === "number")
|
|
338
184
|
return colors.ansi256(spec);
|
|
339
|
-
return spec.trim().split(SPACES).reduce((chain, token) =>
|
|
185
|
+
return spec.trim().split(SPACES).reduce((chain, token) => {
|
|
186
|
+
if (HEX.test(token))
|
|
187
|
+
return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
|
|
188
|
+
return chain[token] ?? chain;
|
|
189
|
+
}, colors);
|
|
340
190
|
}
|
|
341
191
|
function isRecord(value) {
|
|
342
192
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -371,6 +221,8 @@ function applyPreset(theme, name, warn, where) {
|
|
|
371
221
|
Object.assign(theme.glyphs, preset.glyphs);
|
|
372
222
|
if (preset.accents !== undefined)
|
|
373
223
|
theme.accents = [...preset.accents];
|
|
224
|
+
if (Object.hasOwn(preset, "gradient"))
|
|
225
|
+
theme.gradient = preset.gradient;
|
|
374
226
|
return name;
|
|
375
227
|
}
|
|
376
228
|
function applyFile(theme, file, where, warn) {
|
|
@@ -398,6 +250,12 @@ function applyFile(theme, file, where, warn) {
|
|
|
398
250
|
theme.accents = [...file.accents];
|
|
399
251
|
else if (file.accents !== undefined)
|
|
400
252
|
warn(`${where}: accents must be a non-empty list of colours`);
|
|
253
|
+
if (file.gradient === null)
|
|
254
|
+
theme.gradient = undefined;
|
|
255
|
+
else if (Array.isArray(file.gradient) && file.gradient.length === 2 && file.gradient.every((end) => typeof end === "string" && HEX.test(end)))
|
|
256
|
+
theme.gradient = [file.gradient[0], file.gradient[1]];
|
|
257
|
+
else if (file.gradient !== undefined)
|
|
258
|
+
warn(`${where}: gradient must be two \`#rrggbb\` colours, or null for none`);
|
|
401
259
|
if (isRecord(file.bins)) {
|
|
402
260
|
for (const [bin, value] of Object.entries(file.bins)) {
|
|
403
261
|
if (isColorSpec(value))
|
|
@@ -420,8 +278,8 @@ function warnOnce(message) {
|
|
|
420
278
|
function isPath(chosen) {
|
|
421
279
|
return chosen.includes("/") || chosen.endsWith(".json");
|
|
422
280
|
}
|
|
423
|
-
function loadTheme({ env =
|
|
424
|
-
const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
|
|
281
|
+
function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
|
|
282
|
+
const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null), gradient: DEFAULT.gradient };
|
|
425
283
|
const sources = [];
|
|
426
284
|
const chosen = env.KIT_THEME ?? "";
|
|
427
285
|
const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
|
|
@@ -450,7 +308,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
|
|
|
450
308
|
var current;
|
|
451
309
|
var currentKey = "";
|
|
452
310
|
function activeTheme() {
|
|
453
|
-
const key = `${
|
|
311
|
+
const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
|
|
454
312
|
if (current === undefined || key !== currentKey) {
|
|
455
313
|
current = loadTheme();
|
|
456
314
|
currentKey = key;
|
|
@@ -459,33 +317,33 @@ function activeTheme() {
|
|
|
459
317
|
}
|
|
460
318
|
|
|
461
319
|
// ../kit/src/style.ts
|
|
462
|
-
var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
|
|
463
|
-
function takesControlCodes(stream, env =
|
|
464
|
-
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
|
|
320
|
+
var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
|
|
321
|
+
function takesControlCodes(stream, env = process6.env) {
|
|
322
|
+
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
465
323
|
}
|
|
466
|
-
function paint(stream, env =
|
|
467
|
-
return
|
|
324
|
+
function paint(stream, env = process6.env) {
|
|
325
|
+
return Fe2({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
468
326
|
}
|
|
469
|
-
function marked(mark, text, stream, detail, env =
|
|
327
|
+
function marked(mark, text, stream, detail, env = process6.env) {
|
|
470
328
|
const colors = paint(stream, env);
|
|
471
329
|
let head = MARK_WORDS[mark];
|
|
472
330
|
if (takesControlCodes(stream, env)) {
|
|
473
331
|
const { theme } = activeTheme();
|
|
474
|
-
head = tinted(colors.bold, theme.colors[mark])(theme.glyphs[mark]);
|
|
332
|
+
head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
|
|
475
333
|
}
|
|
476
334
|
return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
|
|
477
335
|
}
|
|
478
336
|
function ok(text, detail) {
|
|
479
|
-
console.log(marked("ok", text,
|
|
337
|
+
console.log(marked("ok", text, process6.stdout, detail));
|
|
480
338
|
}
|
|
481
|
-
function role(name, stream, env =
|
|
339
|
+
function role(name, stream, env = process6.env) {
|
|
482
340
|
const colors = paint(stream, env);
|
|
483
|
-
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
|
|
341
|
+
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
484
342
|
}
|
|
485
343
|
var STATUS_WORDS = {
|
|
486
344
|
passed: ["passed", "success", "succeeded", "ok"],
|
|
487
345
|
failed: ["failed", "failure", "error", "errored"],
|
|
488
|
-
running: ["running", "in_progress", "started"],
|
|
346
|
+
running: ["running", "in_progress", "started", "holding"],
|
|
489
347
|
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
490
348
|
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
491
349
|
};
|
|
@@ -497,15 +355,18 @@ function upTo(text, separator) {
|
|
|
497
355
|
return end === -1 ? text : text.slice(0, end);
|
|
498
356
|
}
|
|
499
357
|
function truncate(text, width) {
|
|
500
|
-
return text
|
|
358
|
+
return ko(text, width, { suffix: "\u2026", includeSuffix: true });
|
|
501
359
|
}
|
|
502
360
|
var LINE_BREAKS = /\s*\n\s*/g;
|
|
503
361
|
var ESCAPE = String.fromCharCode(27);
|
|
504
362
|
function textWidth(text) {
|
|
505
363
|
return Bun.stringWidth(text);
|
|
506
364
|
}
|
|
507
|
-
function table(rows, { cellWidth, header = false, align = [], fit, stream =
|
|
365
|
+
function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
|
|
508
366
|
const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
|
|
367
|
+
if (outputMode(stream, env) === "agent")
|
|
368
|
+
return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
|
|
369
|
+
`);
|
|
509
370
|
const widths = [];
|
|
510
371
|
for (const row of cells) {
|
|
511
372
|
for (const [index, cell] of row.entries())
|
|
@@ -540,32 +401,35 @@ function narrow(rows, widths, limit) {
|
|
|
540
401
|
}
|
|
541
402
|
return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
|
|
542
403
|
}
|
|
404
|
+
function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
|
|
405
|
+
return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
|
|
406
|
+
}
|
|
543
407
|
function printJson(value) {
|
|
544
|
-
console.log(
|
|
408
|
+
console.log(jsonText(value));
|
|
545
409
|
}
|
|
546
410
|
|
|
547
411
|
// ../kit/src/help.ts
|
|
548
|
-
import
|
|
412
|
+
import process8 from "process";
|
|
549
413
|
var OPTIONAL = /\[[^\]]+\]/g;
|
|
550
414
|
var USAGE_PREFIX = /^usage:\s*/i;
|
|
551
415
|
var FULL_STOP = /\.$/;
|
|
552
|
-
function usageLine(usage, colors = paint(
|
|
416
|
+
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
553
417
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
554
418
|
}
|
|
555
|
-
function helpText(usage, options, colors = paint(
|
|
419
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
|
|
556
420
|
return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
557
421
|
`);
|
|
558
422
|
}
|
|
559
|
-
function exitRows(exits, colors = paint(
|
|
423
|
+
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
560
424
|
if (exits.length === 0)
|
|
561
425
|
return [];
|
|
562
426
|
const width = Math.max(...exits.map(([code]) => String(code).length));
|
|
563
427
|
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
564
428
|
}
|
|
565
|
-
function replacesRows(replaces, colors = paint(
|
|
566
|
-
return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
429
|
+
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
430
|
+
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
567
431
|
}
|
|
568
|
-
function wantsHelpJson(env =
|
|
432
|
+
function wantsHelpJson(env = process8.env) {
|
|
569
433
|
return env.KIT_HELP === "json";
|
|
570
434
|
}
|
|
571
435
|
function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
@@ -584,12 +448,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
|
584
448
|
...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
|
|
585
449
|
};
|
|
586
450
|
}
|
|
587
|
-
function exampleRows(examples, colors = paint(
|
|
588
|
-
if (examples.length === 0)
|
|
451
|
+
function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
452
|
+
if (examples.length === 0 || outputMode() === "agent")
|
|
589
453
|
return [];
|
|
590
454
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
591
455
|
}
|
|
592
|
-
function optionRows(options, colors = paint(
|
|
456
|
+
function optionRows(options, colors = paint(process8.stdout)) {
|
|
593
457
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
594
458
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
595
459
|
const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
|
|
@@ -621,10 +485,10 @@ function closest(name, names) {
|
|
|
621
485
|
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
622
486
|
}
|
|
623
487
|
// ../kit/src/input.ts
|
|
624
|
-
import
|
|
488
|
+
import process9 from "process";
|
|
625
489
|
async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
626
490
|
if (path === "-") {
|
|
627
|
-
if (
|
|
491
|
+
if (process9.stdin.isTTY)
|
|
628
492
|
fail(noStdin);
|
|
629
493
|
return Bun.stdin.text();
|
|
630
494
|
}
|
|
@@ -639,7 +503,6 @@ var DASHES = /^-+/;
|
|
|
639
503
|
function jsonOption(holds) {
|
|
640
504
|
return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
|
|
641
505
|
}
|
|
642
|
-
|
|
643
506
|
class Exit extends Error {
|
|
644
507
|
code;
|
|
645
508
|
hint;
|
|
@@ -683,7 +546,7 @@ var OUTPUT_OPTIONS = {
|
|
|
683
546
|
color: { type: "string", description: "auto (on a terminal alone), always or never" },
|
|
684
547
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
685
548
|
};
|
|
686
|
-
function applyOutput(color, plain, env =
|
|
549
|
+
function applyOutput(color, plain, env = process10.env) {
|
|
687
550
|
const when = plain === true ? "never" : color ?? "auto";
|
|
688
551
|
if (when === "auto")
|
|
689
552
|
return;
|
|
@@ -860,13 +723,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
|
860
723
|
// ../kit/src/cli.ts
|
|
861
724
|
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
862
725
|
import { dirname as dirname3, join as join5 } from "path";
|
|
863
|
-
import
|
|
726
|
+
import process12 from "process";
|
|
864
727
|
|
|
865
728
|
// ../kit/src/usage.ts
|
|
866
729
|
import { appendFileSync, mkdirSync } from "fs";
|
|
867
730
|
import { homedir as homedir3 } from "os";
|
|
868
731
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
869
|
-
import
|
|
732
|
+
import process11 from "process";
|
|
870
733
|
|
|
871
734
|
// ../kit/src/logs.ts
|
|
872
735
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -880,14 +743,14 @@ var usageError;
|
|
|
880
743
|
function noteUsageError(message) {
|
|
881
744
|
usageError = message;
|
|
882
745
|
}
|
|
883
|
-
function stateHome(env =
|
|
746
|
+
function stateHome(env = process11.env) {
|
|
884
747
|
const dir = env.XDG_STATE_HOME;
|
|
885
748
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
886
749
|
}
|
|
887
|
-
function usagePath(env =
|
|
750
|
+
function usagePath(env = process11.env) {
|
|
888
751
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
889
752
|
}
|
|
890
|
-
function usageRecorded(env =
|
|
753
|
+
function usageRecorded(env = process11.env) {
|
|
891
754
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
892
755
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
893
756
|
}
|
|
@@ -901,7 +764,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
901
764
|
usageError = undefined;
|
|
902
765
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
903
766
|
}
|
|
904
|
-
function recordUsage(entry, env =
|
|
767
|
+
function recordUsage(entry, env = process11.env) {
|
|
905
768
|
if (!usageRecorded(env))
|
|
906
769
|
return;
|
|
907
770
|
try {
|
|
@@ -992,8 +855,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
992
855
|
`);
|
|
993
856
|
}
|
|
994
857
|
function printError(prefix, message, hint, cause) {
|
|
995
|
-
const colors = paint(
|
|
996
|
-
const styled = takesControlCodes(
|
|
858
|
+
const colors = paint(process12.stderr);
|
|
859
|
+
const styled = takesControlCodes(process12.stderr);
|
|
997
860
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
998
861
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
999
862
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1036,11 +899,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1036
899
|
}
|
|
1037
900
|
}
|
|
1038
901
|
if (name === undefined && level.path.length > 1) {
|
|
1039
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
902
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stderr));
|
|
1040
903
|
return 2;
|
|
1041
904
|
}
|
|
1042
905
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1043
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
906
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stdout));
|
|
1044
907
|
return 0;
|
|
1045
908
|
}
|
|
1046
909
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1167,7 +1030,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1167
1030
|
return "0.0.0";
|
|
1168
1031
|
}
|
|
1169
1032
|
}
|
|
1170
|
-
async function runCli(cli, argv =
|
|
1033
|
+
async function runCli(cli, argv = process12.argv.slice(2)) {
|
|
1171
1034
|
const version = cli.version ?? packageVersion();
|
|
1172
1035
|
if (argv[0] === COMPLETE)
|
|
1173
1036
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
@@ -1194,7 +1057,7 @@ function commandPath(scope, argv) {
|
|
|
1194
1057
|
}
|
|
1195
1058
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1196
1059
|
}
|
|
1197
|
-
async function runMain({ name, version, run, redact, usage }, argv =
|
|
1060
|
+
async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
|
|
1198
1061
|
if (argv[0] === COMPLETE)
|
|
1199
1062
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1200
1063
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
@@ -1223,6 +1086,8 @@ async function captureOutput(argv, { cwd, env } = {}) {
|
|
|
1223
1086
|
async function compose(args, { flags = [], ...options } = {}) {
|
|
1224
1087
|
return captureOutput(["docker", "compose", ...flags, ...args], options);
|
|
1225
1088
|
}
|
|
1089
|
+
// ../kit/src/folders.ts
|
|
1090
|
+
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1226
1091
|
// ../kit/src/secrets.ts
|
|
1227
1092
|
var SECRET_PART = /token|secret|passw|credential|private|dsn|apikey|accesskey|key$/i;
|
|
1228
1093
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
@@ -1235,7 +1100,7 @@ var {Glob } = globalThis.Bun;
|
|
|
1235
1100
|
var SESSION_FILES = new Glob("*.json");
|
|
1236
1101
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1237
1102
|
// src/commands/redact.ts
|
|
1238
|
-
import
|
|
1103
|
+
import process14 from "process";
|
|
1239
1104
|
|
|
1240
1105
|
// src/files.ts
|
|
1241
1106
|
import { chmod, chown, readdir, realpath, rename, rm, stat, writeFile } from "fs/promises";
|
|
@@ -1532,7 +1397,7 @@ function maskValue(key, value, known) {
|
|
|
1532
1397
|
var ENV_FILE = /^(?:\.env(?:\..+)?|.+\.env|\.envrc)$/;
|
|
1533
1398
|
var TEMPLATE = /\.(?:example|sample|template|dist|defaults)$/;
|
|
1534
1399
|
var KNOWN_DEPTH = 3;
|
|
1535
|
-
var SKIPPED = new Set([
|
|
1400
|
+
var SKIPPED = new Set([...SKIPPED_FOLDERS, ".git", ".kay"]);
|
|
1536
1401
|
var LOCK_WAIT_MS = 5000;
|
|
1537
1402
|
var LOCK_STALE_MS = 30000;
|
|
1538
1403
|
var REAP_STALE_MS = 5000;
|
|
@@ -1822,10 +1687,10 @@ async function redact(args) {
|
|
|
1822
1687
|
const redactor = new Redactor(known);
|
|
1823
1688
|
const decoder = new TextDecoder;
|
|
1824
1689
|
for await (const chunk of Bun.stdin.stream())
|
|
1825
|
-
|
|
1826
|
-
|
|
1690
|
+
process14.stdout.write(redactor.push(decoder.decode(chunk, { stream: true })));
|
|
1691
|
+
process14.stdout.write(redactor.push(decoder.decode()) + redactor.end());
|
|
1827
1692
|
return 0;
|
|
1828
1693
|
}
|
|
1829
1694
|
|
|
1830
1695
|
// src/redact.ts
|
|
1831
|
-
|
|
1696
|
+
process15.exitCode = await runMain({ name: "redact", run: redact });
|