@kaynooo/cli-check 0.17.0 → 0.18.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/README.md +2 -1
- package/dist/cli.js +123 -284
- package/dist/errs-cli.js +109 -273
- package/dist/fix-cli.js +114 -277
- package/dist/j-cli.js +149 -313
- package/package.json +2 -2
package/dist/j-cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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/j-cli.ts
|
|
@@ -10,6 +10,24 @@ import { parseArgs } from "util";
|
|
|
10
10
|
// ../kit/src/format.ts
|
|
11
11
|
import process7 from "process";
|
|
12
12
|
|
|
13
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
|
|
14
|
+
var N = new Map;
|
|
15
|
+
var Nt = /\s+\S*$/;
|
|
16
|
+
var Y = /\s/;
|
|
17
|
+
function ko(t, e, r = "...") {
|
|
18
|
+
let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
|
|
19
|
+
if (t.length <= e)
|
|
20
|
+
return t;
|
|
21
|
+
let l = Math.max(0, e), c = t.substring(0, Math.max(0, s ? l - n.length : l));
|
|
22
|
+
if (o && !Y.test(t[c.length] ?? " "))
|
|
23
|
+
c = c.replace(Nt, "") || c;
|
|
24
|
+
if (o)
|
|
25
|
+
c = c.trimEnd();
|
|
26
|
+
return s ? (c + n).slice(0, l) : c + n;
|
|
27
|
+
}
|
|
28
|
+
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));
|
|
29
|
+
var z = new Map;
|
|
30
|
+
|
|
13
31
|
// ../kit/src/mode.ts
|
|
14
32
|
import process2 from "process";
|
|
15
33
|
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
@@ -34,269 +52,63 @@ function isInteractive(streams = process2) {
|
|
|
34
52
|
// ../kit/src/style.ts
|
|
35
53
|
import process6 from "process";
|
|
36
54
|
|
|
37
|
-
// ../../node_modules/.bun/@kaynooo+utils@
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
55
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
56
|
+
var G2 = /^[a-f0-9]+$/i;
|
|
57
|
+
function b(r) {
|
|
58
|
+
let e = r.startsWith("#") ? r.slice(1) : r;
|
|
59
|
+
if (!G2.test(e))
|
|
41
60
|
return [0, 0, 0];
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
return `#${(r << 24 | t << 16 | n << 8 | Math.round((a ?? 1) * 255)).toString(16).padStart(8, "0").toUpperCase()}`;
|
|
58
|
-
return `#${(r << 16 | t << 8 | n).toString(16).padStart(6, "0").toUpperCase()}`;
|
|
59
|
-
}
|
|
60
|
-
function R(s, r, t) {
|
|
61
|
-
s = (s % 360 + 360) % 360, t /= 100;
|
|
62
|
-
let n = r * Math.min(t, 1 - t) / 100, a = (b) => {
|
|
63
|
-
let o = (b + s / 30) % 12, y = t - n * Math.max(Math.min(o - 3, 9 - o, 1), -1);
|
|
64
|
-
return Math.round(255 * y);
|
|
65
|
-
};
|
|
66
|
-
return [a(0), a(8), a(4)];
|
|
67
|
-
}
|
|
68
|
-
function k(s) {
|
|
69
|
-
let [r, t, n] = s;
|
|
70
|
-
r /= 255, t /= 255, n /= 255;
|
|
71
|
-
let a = Math.max(r, t, n), b = Math.min(r, t, n), o = 0, y = 0, c = (a + b) / 2;
|
|
72
|
-
if (a !== b) {
|
|
73
|
-
let u = a - b;
|
|
74
|
-
if (y = c > 0 && c < 1 ? u / (1 - Math.abs(2 * c - 1)) : 0, a === r)
|
|
75
|
-
o = (t - n) / u + (t < n ? 6 : 0);
|
|
76
|
-
else if (a === t)
|
|
77
|
-
o = (n - r) / u + 2;
|
|
78
|
-
else
|
|
79
|
-
o = (r - t) / u + 4;
|
|
80
|
-
o /= 6;
|
|
81
|
-
}
|
|
82
|
-
return [Math.round(o * 360), Math.round(y * 100), Math.round(c * 100)];
|
|
83
|
-
}
|
|
84
|
-
function H(s, r, t) {
|
|
85
|
-
s = (s % 360 + 360) % 360, r /= 100, t /= 100;
|
|
86
|
-
let n = (a) => {
|
|
87
|
-
let b = (a + s / 60) % 6, o = t - t * r * Math.max(Math.min(b, 4 - b, 1), 0);
|
|
88
|
-
return Math.round(255 * o);
|
|
89
|
-
};
|
|
90
|
-
return [n(5), n(3), n(1)];
|
|
91
|
-
}
|
|
92
|
-
function f(s) {
|
|
93
|
-
let [r, t, n] = s;
|
|
94
|
-
r /= 255, t /= 255, n /= 255;
|
|
95
|
-
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;
|
|
96
|
-
if (o !== 0) {
|
|
97
|
-
if (a === r)
|
|
98
|
-
y = (t - n) / o + (t < n ? 6 : 0);
|
|
99
|
-
else if (a === t)
|
|
100
|
-
y = (n - r) / o + 2;
|
|
101
|
-
else
|
|
102
|
-
y = (r - t) / o + 4;
|
|
103
|
-
y /= 6;
|
|
104
|
-
}
|
|
105
|
-
return [Math.round(y * 360), Math.round(c * 100), Math.round(u * 100)];
|
|
106
|
-
}
|
|
107
|
-
function O(s) {
|
|
108
|
-
let r = s[0] / 255, t = s[1] / 255, n = s[2] / 255, a = 1 - Math.max(r, t, n);
|
|
109
|
-
if (a === 1)
|
|
110
|
-
return [0, 0, 0, 100];
|
|
111
|
-
let b = (1 - r - a) / (1 - a), o = (1 - t - a) / (1 - a), y = (1 - n - a) / (1 - a);
|
|
112
|
-
return [Math.round(b * 100), Math.round(o * 100), Math.round(y * 100), Math.round(a * 100)];
|
|
113
|
-
}
|
|
114
|
-
function v(s, r, t, n) {
|
|
115
|
-
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))];
|
|
116
|
-
}
|
|
117
|
-
var m = (s) => s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
118
|
-
var p = (s) => s <= 0.0031308 ? 12.92 * s : 1.055 * s ** 0.4166666666666667 - 0.055;
|
|
119
|
-
var i = (s, r) => Math.round(s * 10 ** r) / 10 ** r;
|
|
120
|
-
function T(s) {
|
|
121
|
-
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);
|
|
122
|
-
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)];
|
|
123
|
-
}
|
|
124
|
-
function M(s, r, t) {
|
|
125
|
-
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)));
|
|
126
|
-
return [u(o), u(y), u(c)];
|
|
127
|
-
}
|
|
128
|
-
function d(s) {
|
|
129
|
-
let [r, t, n] = T(s), a = Math.sqrt(t * t + n * n), b = (Math.atan2(n, t) * 180 / Math.PI + 360) % 360;
|
|
130
|
-
return [i(r, 4), i(a, 4), i(b, 2)];
|
|
131
|
-
}
|
|
132
|
-
function C(s, r, t) {
|
|
133
|
-
let n = t * Math.PI / 180;
|
|
134
|
-
return M(s, r * Math.cos(n), r * Math.sin(n));
|
|
135
|
-
}
|
|
136
|
-
function l(s) {
|
|
137
|
-
let r = s / 255;
|
|
138
|
-
return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
class e {
|
|
142
|
-
r;
|
|
143
|
-
g;
|
|
144
|
-
b;
|
|
145
|
-
a;
|
|
146
|
-
constructor(s, r, t, n = 1) {
|
|
147
|
-
this.r = s, this.g = r, this.b = t, this.a = n;
|
|
148
|
-
}
|
|
149
|
-
static from(s, r) {
|
|
150
|
-
if (s === "hex") {
|
|
151
|
-
let [t, n, a, b] = x(r);
|
|
152
|
-
return new e(t, n, a, b);
|
|
153
|
-
}
|
|
154
|
-
if (s === "rgb") {
|
|
155
|
-
if (Array.isArray(r)) {
|
|
156
|
-
let [o, y, c, u] = r;
|
|
157
|
-
return new e(o, y, c, u);
|
|
158
|
-
}
|
|
159
|
-
let { r: t, g: n, b: a, a: b } = r;
|
|
160
|
-
return new e(t, n, a, b);
|
|
161
|
-
}
|
|
162
|
-
if (s === "hsl") {
|
|
163
|
-
let t, n, a, b;
|
|
164
|
-
if (Array.isArray(r))
|
|
165
|
-
[t, n, a, b] = r;
|
|
166
|
-
else
|
|
167
|
-
({ h: t, s: n, l: a, a: b } = r);
|
|
168
|
-
let [o, y, c] = R(t, n, a);
|
|
169
|
-
return new e(o, y, c, b);
|
|
170
|
-
}
|
|
171
|
-
if (s === "hsv") {
|
|
172
|
-
let t, n, a, b;
|
|
173
|
-
if (Array.isArray(r))
|
|
174
|
-
[t, n, a, b] = r;
|
|
175
|
-
else
|
|
176
|
-
({ h: t, s: n, v: a, a: b } = r);
|
|
177
|
-
let [o, y, c] = H(t, n, a);
|
|
178
|
-
return new e(o, y, c, b);
|
|
179
|
-
}
|
|
180
|
-
if (s === "cmyk") {
|
|
181
|
-
let t, n, a, b, o;
|
|
182
|
-
if (Array.isArray(r))
|
|
183
|
-
[t, n, a, b, o] = r;
|
|
184
|
-
else
|
|
185
|
-
({ c: t, m: n, y: a, k: b, a: o } = r);
|
|
186
|
-
let [y, c, u] = v(t, n, a, b);
|
|
187
|
-
return new e(y, c, u, o);
|
|
188
|
-
}
|
|
189
|
-
if (s === "oklch") {
|
|
190
|
-
let t, n, a, b;
|
|
191
|
-
if (Array.isArray(r))
|
|
192
|
-
[t, n, a, b] = r;
|
|
193
|
-
else
|
|
194
|
-
({ l: t, c: n, h: a, a: b } = r);
|
|
195
|
-
let [o, y, c] = C(t, n, a);
|
|
196
|
-
return new e(o, y, c, b);
|
|
197
|
-
}
|
|
198
|
-
if (s === "oklab") {
|
|
199
|
-
let t, n, a, b;
|
|
200
|
-
if (Array.isArray(r))
|
|
201
|
-
[t, n, a, b] = r;
|
|
202
|
-
else
|
|
203
|
-
({ l: t, a: n, b: a, alpha: b } = r);
|
|
204
|
-
let [o, y, c] = M(t, n, a);
|
|
205
|
-
return new e(o, y, c, b);
|
|
206
|
-
}
|
|
207
|
-
throw Error("Invalid input");
|
|
208
|
-
}
|
|
209
|
-
to(s) {
|
|
210
|
-
switch (s) {
|
|
211
|
-
case "rgb":
|
|
212
|
-
return [this.r, this.g, this.b];
|
|
213
|
-
case "rgba":
|
|
214
|
-
return [this.r, this.g, this.b, this.a];
|
|
215
|
-
case "hex":
|
|
216
|
-
return A([this.r, this.g, this.b]);
|
|
217
|
-
case "hexa":
|
|
218
|
-
return A([this.r, this.g, this.b, this.a]);
|
|
219
|
-
case "hsl":
|
|
220
|
-
return k([this.r, this.g, this.b]);
|
|
221
|
-
case "hsla":
|
|
222
|
-
return [...k([this.r, this.g, this.b]), this.a];
|
|
223
|
-
case "hsv":
|
|
224
|
-
return f([this.r, this.g, this.b]);
|
|
225
|
-
case "hsva":
|
|
226
|
-
return [...f([this.r, this.g, this.b]), this.a];
|
|
227
|
-
case "cmyk":
|
|
228
|
-
return O([this.r, this.g, this.b]);
|
|
229
|
-
case "cmyka":
|
|
230
|
-
return [...O([this.r, this.g, this.b]), this.a];
|
|
231
|
-
case "oklch":
|
|
232
|
-
return d([this.r, this.g, this.b]);
|
|
233
|
-
case "oklcha":
|
|
234
|
-
return [...d([this.r, this.g, this.b]), this.a];
|
|
235
|
-
case "oklab":
|
|
236
|
-
return T([this.r, this.g, this.b]);
|
|
237
|
-
case "oklaba":
|
|
238
|
-
return [...T([this.r, this.g, this.b]), this.a];
|
|
239
|
-
default:
|
|
240
|
-
return [this.r, this.g, this.b];
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
getLuminance() {
|
|
244
|
-
let s = l(this.r), r = l(this.g), t = l(this.b);
|
|
245
|
-
return 0.2126 * s + 0.7152 * r + 0.0722 * t;
|
|
246
|
-
}
|
|
247
|
-
contrastRatio(s) {
|
|
248
|
-
let r = this.getLuminance(), t = s.getLuminance(), [n, a] = r >= t ? [r, t] : [t, r];
|
|
249
|
-
return (n + 0.05) / (a + 0.05);
|
|
250
|
-
}
|
|
251
|
-
bestContrastForeground() {
|
|
252
|
-
let s = new e(255, 255, 255, 1), r = new e(0, 0, 0, 1), t = this.contrastRatio(s), n = this.contrastRatio(r);
|
|
253
|
-
return t >= n ? s : r;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-y1msbssb.js
|
|
258
|
-
var r = 39;
|
|
259
|
-
var o = 49;
|
|
260
|
-
var f2 = "\x1B[";
|
|
261
|
-
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") => {
|
|
262
|
-
let [a, l, s] = e.from("hex", i).to("rgb");
|
|
263
|
-
return [`${n === "fg" ? 38 : 48};2;${a};${l};${s}`, n === "fg" ? r : o];
|
|
264
|
-
}, ansi256: (i, n = "fg") => [`${n === "fg" ? 38 : 48};5;${i}`, n === "fg" ? r : o] };
|
|
265
|
-
var b = new Set(["", "1", "2", "3", "true"]);
|
|
266
|
-
function h(i, n = globalThis.process?.env ?? {}) {
|
|
267
|
-
if (n.FORCE_COLOR !== undefined)
|
|
268
|
-
return b.has(n.FORCE_COLOR);
|
|
269
|
-
if (n.NO_COLOR !== undefined || n.NODE_DISABLE_COLORS !== undefined || n.TERM === "dumb")
|
|
61
|
+
if (e.length === 3 || e.length === 4)
|
|
62
|
+
return [Number.parseInt(e[0] + e[0], 16), Number.parseInt(e[1] + e[1], 16), Number.parseInt(e[2] + e[2], 16)];
|
|
63
|
+
if (e.length !== 6 && e.length !== 8)
|
|
64
|
+
throw Error(`Invalid hex color length: ${e.length}`);
|
|
65
|
+
return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
|
|
66
|
+
}
|
|
67
|
+
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") => {
|
|
68
|
+
let [l, n, c] = b(r);
|
|
69
|
+
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
70
|
+
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
71
|
+
var h = new Set(["", "1", "2", "3", "true"]);
|
|
72
|
+
function C(r, e = globalThis.process?.env ?? {}) {
|
|
73
|
+
if (e.FORCE_COLOR !== undefined)
|
|
74
|
+
return h.has(e.FORCE_COLOR);
|
|
75
|
+
if (e.NO_COLOR !== undefined || e.NODE_DISABLE_COLORS !== undefined || e.TERM === "dumb")
|
|
270
76
|
return false;
|
|
271
|
-
return
|
|
272
|
-
}
|
|
273
|
-
function
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (
|
|
287
|
-
return
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
77
|
+
return r?.isTTY === true;
|
|
78
|
+
}
|
|
79
|
+
function f(r, e = []) {
|
|
80
|
+
let l = "", n = "";
|
|
81
|
+
for (let t = 0, i = e.length;t < i; t++)
|
|
82
|
+
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
83
|
+
let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
|
|
84
|
+
return new Proxy(c, { get(t, i) {
|
|
85
|
+
let a = B2[i];
|
|
86
|
+
if (Array.isArray(a)) {
|
|
87
|
+
let s = g.get(i);
|
|
88
|
+
if (s === undefined)
|
|
89
|
+
s = f(r, [...e, a]), g.set(i, s);
|
|
90
|
+
return s;
|
|
91
|
+
}
|
|
92
|
+
if (typeof a === "function")
|
|
93
|
+
return (...s) => {
|
|
94
|
+
let y = `${i}:${s.join(",")}`, u = g.get(y);
|
|
95
|
+
if (u === undefined) {
|
|
96
|
+
if (g.size >= 64)
|
|
97
|
+
g.clear();
|
|
98
|
+
u = f(r, [...e, a(...s)]), g.set(y, u);
|
|
99
|
+
}
|
|
100
|
+
return u;
|
|
101
|
+
};
|
|
102
|
+
throw Error(`Unknown style: ${String(i)}`);
|
|
291
103
|
} });
|
|
292
104
|
}
|
|
293
|
-
function
|
|
294
|
-
return
|
|
105
|
+
function Fe(r = {}) {
|
|
106
|
+
return f(r);
|
|
295
107
|
}
|
|
296
|
-
var
|
|
108
|
+
var o = Fe();
|
|
297
109
|
|
|
298
110
|
// ../kit/src/theme.ts
|
|
299
|
-
import { existsSync as
|
|
111
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
300
112
|
import { homedir as homedir2 } from "os";
|
|
301
113
|
import { join as join3, resolve as resolve2 } from "path";
|
|
302
114
|
import process5 from "process";
|
|
@@ -317,6 +129,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
317
129
|
}
|
|
318
130
|
|
|
319
131
|
// ../kit/src/user-config.ts
|
|
132
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
320
133
|
import { homedir } from "os";
|
|
321
134
|
import { join as join2 } from "path";
|
|
322
135
|
import process4 from "process";
|
|
@@ -327,19 +140,37 @@ function configBase(where = {}) {
|
|
|
327
140
|
function userConfigPath(bin, where = {}) {
|
|
328
141
|
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
329
142
|
}
|
|
143
|
+
function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
144
|
+
const current = userConfigPath(bin, where);
|
|
145
|
+
if (existsSync2(current))
|
|
146
|
+
return current;
|
|
147
|
+
const base = configBase(where);
|
|
148
|
+
return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
|
|
149
|
+
}
|
|
150
|
+
function readUserConfig(bin, where = {}, legacy = []) {
|
|
151
|
+
const path = userConfigReadPath(bin, legacy, where);
|
|
152
|
+
if (!existsSync2(path))
|
|
153
|
+
return {};
|
|
154
|
+
try {
|
|
155
|
+
const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
|
|
156
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
157
|
+
} catch {
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
330
161
|
|
|
331
162
|
// ../kit/src/theme.ts
|
|
332
163
|
var ENDS = new Map;
|
|
333
164
|
var DEFAULT = {
|
|
334
|
-
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" },
|
|
335
|
-
glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
|
|
165
|
+
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" },
|
|
166
|
+
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" },
|
|
336
167
|
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
337
168
|
bins: {},
|
|
338
169
|
gradient: ["#c084fc", "#67e8f9"]
|
|
339
170
|
};
|
|
340
|
-
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" };
|
|
341
|
-
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" };
|
|
342
|
-
var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
|
|
171
|
+
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" };
|
|
172
|
+
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" };
|
|
173
|
+
var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
|
|
343
174
|
var PRESETS = {
|
|
344
175
|
default: {},
|
|
345
176
|
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
@@ -393,7 +224,7 @@ function readThemeFile(path, warn) {
|
|
|
393
224
|
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
394
225
|
return;
|
|
395
226
|
}
|
|
396
|
-
const parsed = JSON.parse(
|
|
227
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
397
228
|
if (isRecord(parsed))
|
|
398
229
|
return parsed;
|
|
399
230
|
warn(`${path} is not a JSON object, theme ignored`);
|
|
@@ -459,7 +290,7 @@ function applyFile(theme, file, where, warn) {
|
|
|
459
290
|
}
|
|
460
291
|
}
|
|
461
292
|
function endsWalk(home) {
|
|
462
|
-
return (dir) => dir === resolve2(home) ||
|
|
293
|
+
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
463
294
|
}
|
|
464
295
|
var warned = new Set;
|
|
465
296
|
function warnOnce(message) {
|
|
@@ -510,12 +341,12 @@ function activeTheme() {
|
|
|
510
341
|
}
|
|
511
342
|
|
|
512
343
|
// ../kit/src/style.ts
|
|
513
|
-
var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
|
|
344
|
+
var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
|
|
514
345
|
function takesControlCodes(stream, env = process6.env) {
|
|
515
346
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
516
347
|
}
|
|
517
348
|
function paint(stream, env = process6.env) {
|
|
518
|
-
return
|
|
349
|
+
return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
519
350
|
}
|
|
520
351
|
function marked(mark, text, stream, detail, env = process6.env) {
|
|
521
352
|
const colors = paint(stream, env);
|
|
@@ -575,7 +406,7 @@ function upTo(text, separator) {
|
|
|
575
406
|
return end === -1 ? text : text.slice(0, end);
|
|
576
407
|
}
|
|
577
408
|
function truncate(text, width) {
|
|
578
|
-
return text
|
|
409
|
+
return ko(text, width, { suffix: "\u2026", includeSuffix: true });
|
|
579
410
|
}
|
|
580
411
|
var LINE_BREAKS = /\s*\n\s*/g;
|
|
581
412
|
var ESCAPE = String.fromCharCode(27);
|
|
@@ -1077,7 +908,7 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
|
|
|
1077
908
|
var RESET_STYLE = `${ESC}[0m`;
|
|
1078
909
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
1079
910
|
// ../kit/src/cli.ts
|
|
1080
|
-
import { readFileSync as
|
|
911
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
1081
912
|
import { dirname as dirname3, join as join6 } from "path";
|
|
1082
913
|
import process14 from "process";
|
|
1083
914
|
|
|
@@ -1268,7 +1099,7 @@ async function printCandidates(found) {
|
|
|
1268
1099
|
function packageVersion(entry = Bun.main) {
|
|
1269
1100
|
for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
|
|
1270
1101
|
try {
|
|
1271
|
-
const { version } = JSON.parse(
|
|
1102
|
+
const { version } = JSON.parse(readFileSync3(join6(dir, "package.json"), "utf8"));
|
|
1272
1103
|
if (typeof version === "string")
|
|
1273
1104
|
return version;
|
|
1274
1105
|
} catch {}
|
|
@@ -1298,6 +1129,11 @@ async function runMain({ name, version, run, redact, usage }, argv = process14.a
|
|
|
1298
1129
|
}
|
|
1299
1130
|
// ../kit/src/folders.ts
|
|
1300
1131
|
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1132
|
+
function ignoredFolders(extra = [], where = {}) {
|
|
1133
|
+
const configured = readUserConfig("config", where).ignore;
|
|
1134
|
+
const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
|
|
1135
|
+
return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
|
|
1136
|
+
}
|
|
1301
1137
|
// ../kit/src/secrets.ts
|
|
1302
1138
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1303
1139
|
// ../kit/src/sessions.ts
|
|
@@ -1305,13 +1141,13 @@ var {Glob } = globalThis.Bun;
|
|
|
1305
1141
|
var SESSION_FILES = new Glob("*.json");
|
|
1306
1142
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1307
1143
|
// package.json
|
|
1308
|
-
var version = "0.
|
|
1144
|
+
var version = "0.18.1";
|
|
1309
1145
|
|
|
1310
1146
|
// src/j.ts
|
|
1311
1147
|
import process21 from "process";
|
|
1312
1148
|
|
|
1313
1149
|
// ../kit/src/picker.ts
|
|
1314
|
-
import { existsSync as
|
|
1150
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync } from "fs";
|
|
1315
1151
|
import { homedir as homedir5 } from "os";
|
|
1316
1152
|
import { dirname as dirname4, join as join7 } from "path";
|
|
1317
1153
|
import process18 from "process";
|
|
@@ -1409,7 +1245,9 @@ var COLUMN_GAP = 2;
|
|
|
1409
1245
|
var PASTE_START = "\x1B[200~";
|
|
1410
1246
|
var PASTE_END = "\x1B[201~";
|
|
1411
1247
|
var LAST_WORD = /\S*\s*$/;
|
|
1412
|
-
var KEY_SEQUENCES = /\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
|
|
1248
|
+
var KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
|
|
1249
|
+
var MOUSE = /^\x1B\[<(\d+);\d+;\d+[a-z]$/i;
|
|
1250
|
+
var WHEEL_LINES = 3;
|
|
1413
1251
|
var KEYS = {
|
|
1414
1252
|
"\x1B[A": "up",
|
|
1415
1253
|
"\x1BOA": "up",
|
|
@@ -1491,6 +1329,9 @@ function lay(rows, searched) {
|
|
|
1491
1329
|
function parseKeys(input, paste = { active: false }, ctrls = []) {
|
|
1492
1330
|
const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
|
|
1493
1331
|
return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
|
|
1332
|
+
const wheel = MOUSE.exec(sequence)?.[1];
|
|
1333
|
+
if (wheel !== undefined)
|
|
1334
|
+
return repeat(wheel === "64" ? "up" : "down", wheel === "64" || wheel === "65" ? WHEEL_LINES : 0);
|
|
1494
1335
|
const named = codes.get(sequence);
|
|
1495
1336
|
const key = named === undefined ? KEYS[sequence] : { ctrl: named };
|
|
1496
1337
|
if (sequence === PASTE_START || sequence === PASTE_END) {
|
|
@@ -1733,7 +1574,7 @@ function caretColumn(state, layout) {
|
|
|
1733
1574
|
}
|
|
1734
1575
|
function helpLines(state, layout, theme) {
|
|
1735
1576
|
const lines = [
|
|
1736
|
-
"type to filter, up, down, ctrl-p, ctrl-n, pgup, pgdn, home, end move",
|
|
1577
|
+
"type to filter, up, down, ctrl-p, ctrl-n, pgup, pgdn, home, end, the wheel move",
|
|
1737
1578
|
`enter picks${state.multi ? ", tab marks" : ""}, ctrl-u clears the query, ctrl-w a word, esc or ctrl-c cancels`,
|
|
1738
1579
|
...state.expect.length > 0 ? [`${state.expect.join(", ")} end the pick as this command asks`] : []
|
|
1739
1580
|
];
|
|
@@ -1783,8 +1624,11 @@ var ESCAPE_WAIT_MS = 30;
|
|
|
1783
1624
|
var OPEN = { ctrl: "open" };
|
|
1784
1625
|
var HIDE_CURSOR = "\x1B[?25l";
|
|
1785
1626
|
var SHOW_CURSOR = "\x1B[?25h";
|
|
1627
|
+
var CARET = "\x1B[7m \x1B[27m";
|
|
1786
1628
|
var PASTE_ON = "\x1B[?2004h";
|
|
1787
1629
|
var PASTE_OFF = "\x1B[?2004l";
|
|
1630
|
+
var MOUSE_ON = "\x1B[?1000h\x1B[?1006h";
|
|
1631
|
+
var MOUSE_OFF = "\x1B[?1006l\x1B[?1000l";
|
|
1788
1632
|
var CLEAR_BELOW = "\r\x1B[J";
|
|
1789
1633
|
var SIGNALS2 = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
1790
1634
|
function up(lines) {
|
|
@@ -1847,21 +1691,18 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
1847
1691
|
let finish;
|
|
1848
1692
|
let restored = false;
|
|
1849
1693
|
let escape;
|
|
1850
|
-
let caret;
|
|
1851
1694
|
function draw(clear = false) {
|
|
1852
1695
|
if (restored)
|
|
1853
1696
|
return;
|
|
1854
1697
|
const layout = layoutFor({ columns: terminal.columns, rows: terminal.rows }, settings.height, settings.preview !== undefined, settings.previewPosition);
|
|
1855
1698
|
let frame = HIDE_CURSOR;
|
|
1856
1699
|
if (reserved !== layout.height || clear) {
|
|
1857
|
-
frame += clear && caret !== undefined ? up(Math.floor((caret - 1) / terminal.columns)) : "";
|
|
1858
1700
|
frame += CLEAR_BELOW + `
|
|
1859
1701
|
`.repeat(layout.height - 1) + up(layout.height - 1);
|
|
1860
1702
|
reserved = layout.height;
|
|
1861
1703
|
}
|
|
1862
|
-
caret = caretColumn(state, layout);
|
|
1863
1704
|
frame += `\r${render(state, layout, theme, preview).map((line) => `\x1B[2K${line}`).join(`
|
|
1864
|
-
`)}${up(layout.height - 1)}\r\x1B[${
|
|
1705
|
+
`)}${up(layout.height - 1)}\r\x1B[${caretColumn(state, layout)}G${CARET}\r`;
|
|
1865
1706
|
terminal.write(frame);
|
|
1866
1707
|
}
|
|
1867
1708
|
function pageSize() {
|
|
@@ -1900,7 +1741,7 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
1900
1741
|
clearTimeout(previewTimer);
|
|
1901
1742
|
clearTimeout(escape);
|
|
1902
1743
|
previewing.abort();
|
|
1903
|
-
terminal.write(`${CLEAR_BELOW}${PASTE_OFF}${SHOW_CURSOR}`);
|
|
1744
|
+
terminal.write(`${CLEAR_BELOW}${MOUSE_OFF}${PASTE_OFF}${SHOW_CURSOR}`);
|
|
1904
1745
|
terminal.close();
|
|
1905
1746
|
}
|
|
1906
1747
|
const stop = () => {
|
|
@@ -1979,7 +1820,7 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
1979
1820
|
for (const signal of SIGNALS2)
|
|
1980
1821
|
process17.once(signal, stop);
|
|
1981
1822
|
try {
|
|
1982
|
-
terminal.write(PASTE_ON);
|
|
1823
|
+
terminal.write(`${PASTE_ON}${MOUSE_ON}`);
|
|
1983
1824
|
terminal.listen(onChunk, () => draw(true));
|
|
1984
1825
|
refreshPreview();
|
|
1985
1826
|
draw(true);
|
|
@@ -2027,7 +1868,7 @@ function historyFile(name) {
|
|
|
2027
1868
|
function history(name) {
|
|
2028
1869
|
try {
|
|
2029
1870
|
const file = historyFile(name);
|
|
2030
|
-
return
|
|
1871
|
+
return existsSync4(file) ? JSON.parse(readFileSync4(file, "utf-8")) : {};
|
|
2031
1872
|
} catch {
|
|
2032
1873
|
return {};
|
|
2033
1874
|
}
|
|
@@ -2104,16 +1945,13 @@ async function ask(question, { hint, terminal = process19 }, render, press) {
|
|
|
2104
1945
|
if (!isInteractive(terminal))
|
|
2105
1946
|
fail(`cannot ask "${question}" off a terminal`, 2, hint);
|
|
2106
1947
|
const colors = paint(stderr);
|
|
2107
|
-
let drawn = [];
|
|
2108
1948
|
let current = "asking";
|
|
2109
1949
|
let outcome;
|
|
2110
1950
|
const columns = () => stderr.columns || 80;
|
|
2111
|
-
const draw = (state) => {
|
|
1951
|
+
const draw = (state, last = false) => {
|
|
2112
1952
|
const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
`)}`);
|
|
2116
|
-
drawn = frame;
|
|
1953
|
+
stderr.write(`\r\x1B[0J${frame.join(`
|
|
1954
|
+
`)}${last || frame.length < 2 ? "" : `\x1B[${frame.length - 1}A`}${last ? "" : "\r"}`);
|
|
2117
1955
|
current = state;
|
|
2118
1956
|
};
|
|
2119
1957
|
const redraw = () => draw(current);
|
|
@@ -2149,7 +1987,7 @@ async function ask(question, { hint, terminal = process19 }, render, press) {
|
|
|
2149
1987
|
});
|
|
2150
1988
|
} finally {
|
|
2151
1989
|
stderr.off?.("resize", redraw);
|
|
2152
|
-
draw(outcome ?? "cancel");
|
|
1990
|
+
draw(outcome ?? "cancel", true);
|
|
2153
1991
|
stderr.write(`
|
|
2154
1992
|
\x1B[?25h\x1B[?2004l`);
|
|
2155
1993
|
stdin.setRawMode(false);
|
|
@@ -2161,7 +1999,7 @@ async function ask(question, { hint, terminal = process19 }, render, press) {
|
|
|
2161
1999
|
import process20 from "process";
|
|
2162
2000
|
|
|
2163
2001
|
// src/jobs.ts
|
|
2164
|
-
import { existsSync as
|
|
2002
|
+
import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync5 } from "fs";
|
|
2165
2003
|
import { dirname as dirname5, join as join9, resolve as resolvePath } from "path";
|
|
2166
2004
|
|
|
2167
2005
|
// src/steps.ts
|
|
@@ -2175,7 +2013,6 @@ var CS_FIXER_CONFIGS = [".php-cs-fixer.php", ".php-cs-fixer.dist.php"];
|
|
|
2175
2013
|
var JUST_TIMEOUT_MS = 1e4;
|
|
2176
2014
|
var PHPSTAN_CONFIGS = ["phpstan.neon", "phpstan.neon.dist", "phpstan.dist.neon"];
|
|
2177
2015
|
var PHPUNIT_CONFIGS = ["phpunit.xml", "phpunit.xml.dist", "phpunit.dist.xml"];
|
|
2178
|
-
var SKIPPED = new Set([...SKIPPED_FOLDERS, "var", "tmp"]);
|
|
2179
2016
|
async function readFirst(dir, files) {
|
|
2180
2017
|
for (const file of files) {
|
|
2181
2018
|
const handle = Bun.file(join8(dir, file));
|
|
@@ -2270,8 +2107,9 @@ async function discoverProjects(dir) {
|
|
|
2270
2107
|
return [{ dir, steps: own }];
|
|
2271
2108
|
const projects = [];
|
|
2272
2109
|
const entries = await readdir2(dir, { withFileTypes: true });
|
|
2110
|
+
const ignored = ignoredFolders(["var", "tmp"]);
|
|
2273
2111
|
for (const entry of entries.toSorted((a, b) => a.name.localeCompare(b.name))) {
|
|
2274
|
-
if (!entry.isDirectory() || entry.name.startsWith(".") ||
|
|
2112
|
+
if (!entry.isDirectory() || entry.name.startsWith(".") || ignored.has(entry.name))
|
|
2275
2113
|
continue;
|
|
2276
2114
|
const steps = await discover(join8(dir, entry.name));
|
|
2277
2115
|
if (steps.length > 0)
|
|
@@ -2318,16 +2156,17 @@ function list2(dir) {
|
|
|
2318
2156
|
}
|
|
2319
2157
|
function locate(dir, here, names) {
|
|
2320
2158
|
for (let current = dir;; current = join9(current, "..")) {
|
|
2321
|
-
const found = names.find((name) =>
|
|
2159
|
+
const found = names.find((name) => existsSync5(join9(current, name)));
|
|
2322
2160
|
if (found !== undefined)
|
|
2323
2161
|
return join9(current, found);
|
|
2324
2162
|
const absolute = resolvePath(current);
|
|
2325
|
-
if (!here ||
|
|
2163
|
+
if (!here || existsSync5(join9(current, ".git")) || dirname5(absolute) === absolute)
|
|
2326
2164
|
return;
|
|
2327
2165
|
}
|
|
2328
2166
|
}
|
|
2329
2167
|
function children(dir = ".") {
|
|
2330
|
-
|
|
2168
|
+
const ignored = ignoredFolders();
|
|
2169
|
+
return readdirSync(dir, { withFileTypes: true }).filter((child) => child.isDirectory() && !child.name.startsWith(".") && !ignored.has(child.name)).map((child) => child.name).toSorted();
|
|
2331
2170
|
}
|
|
2332
2171
|
function build(base, items) {
|
|
2333
2172
|
return items.map((item) => ({ ...base, doc: null, parameters: [], ...item }));
|
|
@@ -2411,10 +2250,10 @@ function show(source, target) {
|
|
|
2411
2250
|
`).trimEnd();
|
|
2412
2251
|
}
|
|
2413
2252
|
function make(dir) {
|
|
2414
|
-
const file = MAKEFILES.find((name) =>
|
|
2253
|
+
const file = MAKEFILES.find((name) => existsSync5(join9(dir, name)));
|
|
2415
2254
|
if (file === undefined)
|
|
2416
2255
|
return [];
|
|
2417
|
-
const source =
|
|
2256
|
+
const source = readFileSync5(join9(dir, file), "utf-8");
|
|
2418
2257
|
return build({ kind: "make", tag: "make", runner: ["make"], separated: false, dir }, targets2(source).map((target) => ({ ...target, body: show(source, target.name) })));
|
|
2419
2258
|
}
|
|
2420
2259
|
function manager(dir, manifest) {
|
|
@@ -2423,7 +2262,7 @@ function manager(dir, manifest) {
|
|
|
2423
2262
|
if (known !== undefined)
|
|
2424
2263
|
return known[1];
|
|
2425
2264
|
for (let current = resolvePath(dir);; current = dirname5(current)) {
|
|
2426
|
-
const found = LOCKFILES.find(([file]) =>
|
|
2265
|
+
const found = LOCKFILES.find(([file]) => existsSync5(join9(current, file)));
|
|
2427
2266
|
if (found !== undefined)
|
|
2428
2267
|
return found[1];
|
|
2429
2268
|
if (dirname5(current) === current)
|
|
@@ -2437,7 +2276,7 @@ function packageScripts(dir, here) {
|
|
|
2437
2276
|
const file = locate(dir, here, ["package.json"]);
|
|
2438
2277
|
if (file === undefined)
|
|
2439
2278
|
return [];
|
|
2440
|
-
const manifest = JSON.parse(
|
|
2279
|
+
const manifest = JSON.parse(readFileSync5(file, "utf-8"));
|
|
2441
2280
|
const tool = manager(dirname5(file), manifest);
|
|
2442
2281
|
const items = Object.entries(table2(manifest.scripts)).map(([name, command]) => ({ name, body: text2(command) }));
|
|
2443
2282
|
return build({ kind: "package", tag: tool, runner: [tool, "run"], separated: tool === "npm", dir: dirname5(file) }, items);
|
|
@@ -2446,7 +2285,7 @@ function composer(dir, here) {
|
|
|
2446
2285
|
const file = locate(dir, here, ["composer.json"]);
|
|
2447
2286
|
if (file === undefined)
|
|
2448
2287
|
return [];
|
|
2449
|
-
const manifest = JSON.parse(
|
|
2288
|
+
const manifest = JSON.parse(readFileSync5(file, "utf-8"));
|
|
2450
2289
|
const descriptions = table2(manifest["scripts-descriptions"]);
|
|
2451
2290
|
const items = Object.entries(table2(manifest.scripts)).map(([name, command]) => ({ name, doc: field(descriptions, name), body: text2(command) }));
|
|
2452
2291
|
return build({ kind: "composer", tag: "composer", runner: ["composer", "run"], separated: true, dir: dirname5(file) }, items);
|
|
@@ -2455,7 +2294,7 @@ function deno(dir, here) {
|
|
|
2455
2294
|
const file = locate(dir, here, ["deno.json", "deno.jsonc"]);
|
|
2456
2295
|
if (file === undefined)
|
|
2457
2296
|
return [];
|
|
2458
|
-
const manifest = Bun.JSONC.parse(
|
|
2297
|
+
const manifest = Bun.JSONC.parse(readFileSync5(file, "utf-8"));
|
|
2459
2298
|
const items = Object.entries(table2(manifest.tasks)).map(([name, task]) => ({ name, doc: field(task, "description"), body: field(task, "command") ?? text2(task) }));
|
|
2460
2299
|
return build({ kind: "deno", tag: "deno", runner: ["deno", "task"], separated: false, dir: dirname5(file) }, items);
|
|
2461
2300
|
}
|
|
@@ -2463,12 +2302,12 @@ function taskfile(dir, here) {
|
|
|
2463
2302
|
const file = locate(dir, here, TASKFILES);
|
|
2464
2303
|
if (file === undefined)
|
|
2465
2304
|
return [];
|
|
2466
|
-
const tasks = table2(Bun.YAML.parse(
|
|
2305
|
+
const tasks = table2(Bun.YAML.parse(readFileSync5(file, "utf-8"))?.tasks);
|
|
2467
2306
|
const items = Object.entries(tasks).filter(([, task]) => !(task !== null && typeof task === "object" && task.internal === true)).map(([name, task]) => ({ name, doc: field(task, "desc") ?? field(task, "summary"), body: text2(task) }));
|
|
2468
2307
|
return build({ kind: "task", tag: "task", runner: ["task"], separated: true, dir: dirname5(file) }, items);
|
|
2469
2308
|
}
|
|
2470
2309
|
function mise(dir, here) {
|
|
2471
|
-
if (!has("mise") || !here && !MISE_FILES.some((name) =>
|
|
2310
|
+
if (!has("mise") || !here && !MISE_FILES.some((name) => existsSync5(join9(dir, name))))
|
|
2472
2311
|
return [];
|
|
2473
2312
|
const proc = Bun.spawnSync(["mise", "tasks", "ls", "--json"], { cwd: dir, stderr: "pipe" });
|
|
2474
2313
|
if (!proc.success)
|
|
@@ -2482,7 +2321,7 @@ function pyproject(dir, here) {
|
|
|
2482
2321
|
const file = locate(dir, here, ["pyproject.toml"]);
|
|
2483
2322
|
if (file === undefined)
|
|
2484
2323
|
return [];
|
|
2485
|
-
const manifest = Bun.TOML.parse(
|
|
2324
|
+
const manifest = Bun.TOML.parse(readFileSync5(file, "utf-8"));
|
|
2486
2325
|
const tool = table2(manifest.tool);
|
|
2487
2326
|
const project = table2(manifest.project);
|
|
2488
2327
|
const uv = locate(dirname5(file), true, ["uv.lock"]) !== undefined;
|
|
@@ -2514,9 +2353,9 @@ function readOr(read, fallback) {
|
|
|
2514
2353
|
}
|
|
2515
2354
|
}
|
|
2516
2355
|
function workspaces() {
|
|
2517
|
-
const manifest = readOr(() => JSON.parse(
|
|
2356
|
+
const manifest = readOr(() => JSON.parse(readFileSync5("package.json", "utf-8")), {});
|
|
2518
2357
|
const declared = Array.isArray(manifest.workspaces) ? manifest.workspaces : table2(manifest.workspaces).packages;
|
|
2519
|
-
const pnpm = readOr(() => table2(Bun.YAML.parse(
|
|
2358
|
+
const pnpm = readOr(() => table2(Bun.YAML.parse(readFileSync5("pnpm-workspace.yaml", "utf-8"))).packages, undefined);
|
|
2520
2359
|
const patterns = [declared, pnpm].flatMap((value) => Array.isArray(value) ? value.filter((pattern) => typeof pattern === "string") : []);
|
|
2521
2360
|
const excluded = patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => new Bun.Glob(pattern.slice(1)));
|
|
2522
2361
|
return patterns.filter((pattern) => !pattern.startsWith("!")).flatMap((pattern) => [...new Bun.Glob(`${pattern.replace(TRAILING_SLASHES, "")}/package.json`).scanSync({ cwd: "." })].map((file) => dirname5(file))).filter((dir) => !dir.split("/").includes("node_modules") && !excluded.some((glob) => glob.match(dir)));
|
|
@@ -2529,7 +2368,7 @@ function guarded(reader, dir, here, isWarned = false) {
|
|
|
2529
2368
|
return reader(dir, here);
|
|
2530
2369
|
} catch (error) {
|
|
2531
2370
|
if (isWarned)
|
|
2532
|
-
|
|
2371
|
+
warn(`j: skipped ${join9(dir, MANIFEST_OF.get(reader) ?? "a manifest")}, it does not parse (${error instanceof Error ? error.message : String(error)})`);
|
|
2533
2372
|
return [];
|
|
2534
2373
|
}
|
|
2535
2374
|
}
|
|
@@ -2643,13 +2482,10 @@ function listed2(found) {
|
|
|
2643
2482
|
editsTyped: true
|
|
2644
2483
|
}));
|
|
2645
2484
|
}
|
|
2646
|
-
function
|
|
2485
|
+
function listing(found) {
|
|
2647
2486
|
const colors = paint(process21.stdout);
|
|
2648
2487
|
const labels = labelled(found);
|
|
2649
|
-
|
|
2650
|
-
const widths = rows[0]?.map((_, column) => Math.max(...rows.map((cells) => cells[column].length))) ?? [];
|
|
2651
|
-
return found.map((entry, index) => `${rows[index].map((cell, column) => cell.padEnd(widths[column])).join(" ")} ${colors.dim(entry.doc ?? "")}`.trimEnd()).join(`
|
|
2652
|
-
`);
|
|
2488
|
+
return table(found.map((entry) => [...labels ? [entry.tag] : [], key(entry), signature(entry), colors.dim(entry.doc ?? "")]));
|
|
2653
2489
|
}
|
|
2654
2490
|
function missing(entry, given) {
|
|
2655
2491
|
return entry.parameters.slice(given.length).filter((parameter) => parameter.default === null && parameter.kind === "singular").map((parameter) => parameter.name);
|
|
@@ -2658,7 +2494,7 @@ function commandOf(entry, args) {
|
|
|
2658
2494
|
const separated = entry.separated && args.length > 0 ? ["--"] : [];
|
|
2659
2495
|
return [...entry.dir === "." ? [] : ["env", "-C", entry.dir], ...entry.runner, entry.name, ...separated, ...args];
|
|
2660
2496
|
}
|
|
2661
|
-
async function
|
|
2497
|
+
async function j2(argv) {
|
|
2662
2498
|
const [flag = ""] = argv;
|
|
2663
2499
|
if (flag === "--show") {
|
|
2664
2500
|
const [kind = "just", dir = ".", name = ""] = argv.slice(1);
|
|
@@ -2712,7 +2548,7 @@ async function j(argv) {
|
|
|
2712
2548
|
if (parsed.values.json === true)
|
|
2713
2549
|
printJson(found.map((each) => ({ id: id(each), key: key(each), runner: each.tag, dir: each.dir, name: each.name, doc: each.doc, parameters: each.parameters })));
|
|
2714
2550
|
else
|
|
2715
|
-
console.log(
|
|
2551
|
+
console.log(listing(found));
|
|
2716
2552
|
return 0;
|
|
2717
2553
|
}
|
|
2718
2554
|
entry = await pickJob(byRecency(found, previous, id));
|
|
@@ -2747,4 +2583,4 @@ async function j(argv) {
|
|
|
2747
2583
|
}
|
|
2748
2584
|
|
|
2749
2585
|
// src/j-cli.ts
|
|
2750
|
-
process22.exitCode = await runMain({ name: "j", version, run:
|
|
2586
|
+
process22.exitCode = await runMain({ name: "j", version, run: j2 });
|