@kaynooo/cli-check 0.20.1 → 0.21.2
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 +17 -15
- package/dist/cli.js +441 -217
- package/dist/errs-cli.js +478 -188
- package/dist/j-cli.js +1600 -1318
- package/package.json +7 -9
- package/dist/fix-cli.js +0 -2216
package/dist/cli.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env -S bun --no-env-file --config=/dev/null
|
|
2
2
|
// @bun
|
|
3
|
+
var __esm = (fn, res, err) => () => {
|
|
4
|
+
if (fn)
|
|
5
|
+
try {
|
|
6
|
+
res = fn(fn = 0);
|
|
7
|
+
} catch (e) {
|
|
8
|
+
err = [e];
|
|
9
|
+
}
|
|
10
|
+
if (err)
|
|
11
|
+
throw err[0];
|
|
12
|
+
return res;
|
|
13
|
+
};
|
|
3
14
|
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
// ../kit/src/args.ts
|
|
7
|
-
import process10 from "process";
|
|
8
|
-
import { parseArgs } from "util";
|
|
9
|
-
|
|
10
|
-
// ../kit/src/format.ts
|
|
11
|
-
import process7 from "process";
|
|
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 = "...") {
|
|
15
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rkhsft4a.js
|
|
16
|
+
function Ao(t, e, r = "...") {
|
|
18
17
|
let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
|
|
19
18
|
if (t.length <= e)
|
|
20
19
|
return t;
|
|
@@ -25,13 +24,22 @@ function ko(t, e, r = "...") {
|
|
|
25
24
|
c = c.trimEnd();
|
|
26
25
|
return s ? (c + n).slice(0, l) : c + n;
|
|
27
26
|
}
|
|
28
|
-
var
|
|
29
|
-
var
|
|
27
|
+
var N, Nt, Y, be, W;
|
|
28
|
+
var init_chunk_rkhsft4a = __esm(() => {
|
|
29
|
+
N = new Map;
|
|
30
|
+
Nt = /\s+\S*$/;
|
|
31
|
+
Y = /\s/;
|
|
32
|
+
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));
|
|
33
|
+
W = new Map;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/text.js
|
|
37
|
+
var init_text = __esm(() => {
|
|
38
|
+
init_chunk_rkhsft4a();
|
|
39
|
+
});
|
|
30
40
|
|
|
31
41
|
// ../kit/src/mode.ts
|
|
32
42
|
import process2 from "process";
|
|
33
|
-
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
34
|
-
var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
35
43
|
function isSet(value) {
|
|
36
44
|
return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
37
45
|
}
|
|
@@ -48,12 +56,13 @@ function outputMode(stream = process2.stdout, env = process2.env) {
|
|
|
48
56
|
function isInteractive(streams = process2) {
|
|
49
57
|
return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
|
|
50
58
|
}
|
|
59
|
+
var MODES, AGENT_VARIABLES;
|
|
60
|
+
var init_mode = __esm(() => {
|
|
61
|
+
MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
62
|
+
AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
63
|
+
});
|
|
51
64
|
|
|
52
|
-
//
|
|
53
|
-
import process6 from "process";
|
|
54
|
-
|
|
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;
|
|
65
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
57
66
|
function b(r) {
|
|
58
67
|
let e = r.startsWith("#") ? r.slice(1) : r;
|
|
59
68
|
if (!G2.test(e))
|
|
@@ -64,11 +73,6 @@ function b(r) {
|
|
|
64
73
|
throw Error(`Invalid hex color length: ${e.length}`);
|
|
65
74
|
return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
|
|
66
75
|
}
|
|
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
76
|
function C(r, e = globalThis.process?.env ?? {}) {
|
|
73
77
|
if (e.FORCE_COLOR !== undefined)
|
|
74
78
|
return h.has(e.FORCE_COLOR);
|
|
@@ -82,7 +86,7 @@ function f(r, e = []) {
|
|
|
82
86
|
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
83
87
|
let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
|
|
84
88
|
return new Proxy(c, { get(t, i) {
|
|
85
|
-
let a =
|
|
89
|
+
let a = B[i];
|
|
86
90
|
if (Array.isArray(a)) {
|
|
87
91
|
let s = g.get(i);
|
|
88
92
|
if (s === undefined)
|
|
@@ -105,13 +109,21 @@ function f(r, e = []) {
|
|
|
105
109
|
function Fe(r = {}) {
|
|
106
110
|
return f(r);
|
|
107
111
|
}
|
|
108
|
-
var
|
|
112
|
+
var G2, B, h, o;
|
|
113
|
+
var init_chunk_x450vn3m = __esm(() => {
|
|
114
|
+
G2 = /^[a-f0-9]+$/i;
|
|
115
|
+
B = { 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") => {
|
|
116
|
+
let [l, n, c] = b(r);
|
|
117
|
+
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
118
|
+
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
119
|
+
h = new Set(["", "1", "2", "3", "true"]);
|
|
120
|
+
o = Fe();
|
|
121
|
+
});
|
|
109
122
|
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
import process5 from "process";
|
|
123
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/tools/colors.js
|
|
124
|
+
var init_colors = __esm(() => {
|
|
125
|
+
init_chunk_x450vn3m();
|
|
126
|
+
});
|
|
115
127
|
|
|
116
128
|
// ../kit/src/config.ts
|
|
117
129
|
import { existsSync } from "fs";
|
|
@@ -127,15 +139,21 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
127
139
|
return;
|
|
128
140
|
}
|
|
129
141
|
}
|
|
142
|
+
var init_config = __esm(() => {
|
|
143
|
+
init_args();
|
|
144
|
+
});
|
|
130
145
|
|
|
131
146
|
// ../kit/src/user-config.ts
|
|
132
147
|
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
133
148
|
import { homedir } from "os";
|
|
134
|
-
import { join as join2 } from "path";
|
|
149
|
+
import { isAbsolute, join as join2 } from "path";
|
|
135
150
|
import process4 from "process";
|
|
151
|
+
function xdgFolder(value, fallback) {
|
|
152
|
+
return value !== undefined && isAbsolute(value) ? value : fallback;
|
|
153
|
+
}
|
|
136
154
|
function configBase(where = {}) {
|
|
137
155
|
const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
|
|
138
|
-
return xdg
|
|
156
|
+
return xdgFolder(xdg, join2(where.home ?? homedir(), ".config"));
|
|
139
157
|
}
|
|
140
158
|
function userConfigPath(bin, where = {}) {
|
|
141
159
|
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
@@ -158,36 +176,18 @@ function readUserConfig(bin, where = {}, legacy = []) {
|
|
|
158
176
|
return {};
|
|
159
177
|
}
|
|
160
178
|
}
|
|
179
|
+
var init_user_config = () => {};
|
|
161
180
|
|
|
162
181
|
// ../kit/src/theme.ts
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
168
|
-
bins: {},
|
|
169
|
-
gradient: ["#c084fc", "#67e8f9"]
|
|
170
|
-
};
|
|
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: "|" };
|
|
174
|
-
var PRESETS = {
|
|
175
|
-
default: {},
|
|
176
|
-
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
177
|
-
mono: { colors: MONO, accents: ["bold"], gradient: undefined },
|
|
178
|
-
ascii: { glyphs: ASCII }
|
|
179
|
-
};
|
|
180
|
-
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"]);
|
|
181
|
-
var HEX = /^#[0-9a-f]{6}$/i;
|
|
182
|
-
var CONTROL = /\p{Cc}/u;
|
|
183
|
-
var MAX_FILE_BYTES = 64 * 1024;
|
|
184
|
-
var SPACES = /\s+/;
|
|
182
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
183
|
+
import { homedir as homedir2 } from "os";
|
|
184
|
+
import { join as join3, resolve as resolve2 } from "path";
|
|
185
|
+
import process5 from "process";
|
|
185
186
|
function isColorSpec(spec) {
|
|
186
187
|
if (typeof spec === "number")
|
|
187
188
|
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
188
189
|
return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
|
|
189
190
|
}
|
|
190
|
-
var CUBE = [0, 95, 135, 175, 215, 255];
|
|
191
191
|
function cubeLevel(channel) {
|
|
192
192
|
return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
|
|
193
193
|
}
|
|
@@ -292,7 +292,6 @@ function applyFile(theme, file, where, warn) {
|
|
|
292
292
|
function endsWalk(home) {
|
|
293
293
|
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
294
294
|
}
|
|
295
|
-
var warned = new Set;
|
|
296
295
|
function warnOnce(message) {
|
|
297
296
|
if (warned.has(message))
|
|
298
297
|
return;
|
|
@@ -329,8 +328,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
|
|
|
329
328
|
}
|
|
330
329
|
return { theme, sources, preset };
|
|
331
330
|
}
|
|
332
|
-
var current;
|
|
333
|
-
var currentKey = "";
|
|
334
331
|
function activeTheme() {
|
|
335
332
|
const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
|
|
336
333
|
if (current === undefined || key !== currentKey) {
|
|
@@ -339,9 +336,38 @@ function activeTheme() {
|
|
|
339
336
|
}
|
|
340
337
|
return current;
|
|
341
338
|
}
|
|
339
|
+
var ENDS, DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
|
|
340
|
+
var init_theme = __esm(() => {
|
|
341
|
+
init_config();
|
|
342
|
+
init_user_config();
|
|
343
|
+
ENDS = new Map;
|
|
344
|
+
DEFAULT = {
|
|
345
|
+
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" },
|
|
346
|
+
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" },
|
|
347
|
+
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
348
|
+
bins: {},
|
|
349
|
+
gradient: ["#c084fc", "#67e8f9"]
|
|
350
|
+
};
|
|
351
|
+
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" };
|
|
352
|
+
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" };
|
|
353
|
+
ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
|
|
354
|
+
PRESETS = {
|
|
355
|
+
default: {},
|
|
356
|
+
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
357
|
+
mono: { colors: MONO, accents: ["bold"], gradient: undefined },
|
|
358
|
+
ascii: { glyphs: ASCII }
|
|
359
|
+
};
|
|
360
|
+
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"]);
|
|
361
|
+
HEX = /^#[0-9a-f]{6}$/i;
|
|
362
|
+
CONTROL = /\p{Cc}/u;
|
|
363
|
+
MAX_FILE_BYTES = 64 * 1024;
|
|
364
|
+
SPACES = /\s+/;
|
|
365
|
+
CUBE = [0, 95, 135, 175, 215, 255];
|
|
366
|
+
warned = new Set;
|
|
367
|
+
});
|
|
342
368
|
|
|
343
369
|
// ../kit/src/style.ts
|
|
344
|
-
|
|
370
|
+
import process6 from "process";
|
|
345
371
|
function takesControlCodes(stream, env = process6.env) {
|
|
346
372
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
347
373
|
}
|
|
@@ -364,14 +390,6 @@ function role(name, stream, env = process6.env) {
|
|
|
364
390
|
const colors = paint(stream, env);
|
|
365
391
|
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
366
392
|
}
|
|
367
|
-
var STATUS_WORDS = {
|
|
368
|
-
passed: ["passed", "success", "succeeded", "ok"],
|
|
369
|
-
failed: ["failed", "failure", "error", "errored"],
|
|
370
|
-
running: ["running", "in_progress", "started", "holding"],
|
|
371
|
-
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
372
|
-
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
373
|
-
};
|
|
374
|
-
var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
375
393
|
function header(bin, context, stream, env = process6.env) {
|
|
376
394
|
if (!takesControlCodes(stream, env))
|
|
377
395
|
return "";
|
|
@@ -382,9 +400,24 @@ function header(bin, context, stream, env = process6.env) {
|
|
|
382
400
|
const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
|
|
383
401
|
return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
|
|
384
402
|
}
|
|
403
|
+
var MARK_WORDS, STATUS_WORDS, STATUS_OF;
|
|
404
|
+
var init_style = __esm(() => {
|
|
405
|
+
init_colors();
|
|
406
|
+
init_mode();
|
|
407
|
+
init_theme();
|
|
408
|
+
MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
|
|
409
|
+
STATUS_WORDS = {
|
|
410
|
+
passed: ["passed", "success", "succeeded", "ok"],
|
|
411
|
+
failed: ["failed", "failure", "error", "errored"],
|
|
412
|
+
running: ["running", "in_progress", "started", "holding"],
|
|
413
|
+
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
414
|
+
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
415
|
+
};
|
|
416
|
+
STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
417
|
+
});
|
|
385
418
|
|
|
386
419
|
// ../kit/src/format.ts
|
|
387
|
-
|
|
420
|
+
import process7 from "process";
|
|
388
421
|
function formatSeconds(total) {
|
|
389
422
|
let rest = Math.max(0, Math.round(total));
|
|
390
423
|
const amounts = UNITS.map(([unit, size]) => {
|
|
@@ -406,10 +439,8 @@ function upTo(text, separator) {
|
|
|
406
439
|
return end === -1 ? text : text.slice(0, end);
|
|
407
440
|
}
|
|
408
441
|
function truncate(text, width) {
|
|
409
|
-
return
|
|
442
|
+
return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
|
|
410
443
|
}
|
|
411
|
-
var LINE_BREAKS = /\s*\n\s*/g;
|
|
412
|
-
var ESCAPE = String.fromCharCode(27);
|
|
413
444
|
function textWidth(text) {
|
|
414
445
|
return Bun.stringWidth(text);
|
|
415
446
|
}
|
|
@@ -458,14 +489,40 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
|
|
|
458
489
|
function printJson(value) {
|
|
459
490
|
console.log(jsonText(value));
|
|
460
491
|
}
|
|
492
|
+
var UNITS, LINE_BREAKS, ESCAPE;
|
|
493
|
+
var init_format = __esm(() => {
|
|
494
|
+
init_text();
|
|
495
|
+
init_mode();
|
|
496
|
+
init_style();
|
|
497
|
+
UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
|
|
498
|
+
LINE_BREAKS = /\s*\n\s*/g;
|
|
499
|
+
ESCAPE = String.fromCharCode(27);
|
|
500
|
+
});
|
|
461
501
|
|
|
462
502
|
// ../kit/src/help.ts
|
|
463
503
|
import process8 from "process";
|
|
464
|
-
var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
465
|
-
var USAGE_PREFIX = /^usage:\s*/i;
|
|
466
|
-
var FULL_STOP = /\.$/;
|
|
467
504
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
468
|
-
|
|
505
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
506
|
+
`);
|
|
507
|
+
const blank = lines.indexOf("");
|
|
508
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
509
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
510
|
+
const colon = synopses[0].indexOf(": ");
|
|
511
|
+
const inline = synopses[0].slice(colon + 2);
|
|
512
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
513
|
+
if (colon !== -1)
|
|
514
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
515
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
516
|
+
`)}`;
|
|
517
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
518
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
519
|
+
return [head, ...lead, ...rest].join(`
|
|
520
|
+
`);
|
|
521
|
+
}
|
|
522
|
+
function prose(line, colors) {
|
|
523
|
+
if (colors.cyan("x") === "x")
|
|
524
|
+
return line;
|
|
525
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
469
526
|
}
|
|
470
527
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
471
528
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -500,7 +557,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
|
500
557
|
return [];
|
|
501
558
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
502
559
|
}
|
|
503
|
-
var MAX_INLINE_CHOICES = 24;
|
|
504
560
|
function optionRows(options, colors = paint(process8.stdout)) {
|
|
505
561
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
506
562
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
@@ -515,9 +571,17 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
515
571
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
516
572
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
517
573
|
}
|
|
574
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
575
|
+
var init_help = __esm(() => {
|
|
576
|
+
init_mode();
|
|
577
|
+
init_style();
|
|
578
|
+
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
579
|
+
USAGE_PREFIX = /^usage:\s*/i;
|
|
580
|
+
FULL_STOP = /\.$/;
|
|
581
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
582
|
+
});
|
|
518
583
|
|
|
519
584
|
// ../kit/src/text.ts
|
|
520
|
-
var ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
|
|
521
585
|
function stripAnsi(text) {
|
|
522
586
|
return text.replace(ANSI, "");
|
|
523
587
|
}
|
|
@@ -546,10 +610,13 @@ function closest(name, names) {
|
|
|
546
610
|
const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
|
|
547
611
|
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
548
612
|
}
|
|
613
|
+
var ANSI;
|
|
614
|
+
var init_text2 = __esm(() => {
|
|
615
|
+
ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
|
|
616
|
+
});
|
|
617
|
+
|
|
549
618
|
// ../kit/src/input.ts
|
|
550
619
|
import process9 from "process";
|
|
551
|
-
var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
552
|
-
var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
553
620
|
function duration(value, name, fallback, unit = "s") {
|
|
554
621
|
if (value === undefined)
|
|
555
622
|
return fallback;
|
|
@@ -570,40 +637,26 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
|
570
637
|
fail(`no file ${path}`);
|
|
571
638
|
return file.text();
|
|
572
639
|
}
|
|
640
|
+
var DURATION, UNIT_MS;
|
|
641
|
+
var init_input = __esm(() => {
|
|
642
|
+
init_args();
|
|
643
|
+
DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
644
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
645
|
+
});
|
|
573
646
|
|
|
574
647
|
// ../kit/src/args.ts
|
|
575
|
-
|
|
648
|
+
import process10 from "process";
|
|
649
|
+
import { parseArgs } from "util";
|
|
576
650
|
function jsonOption(holds) {
|
|
577
651
|
return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
|
|
578
652
|
}
|
|
579
|
-
class Exit extends Error {
|
|
580
|
-
code;
|
|
581
|
-
hint;
|
|
582
|
-
constructor(message, code, hint) {
|
|
583
|
-
super(message);
|
|
584
|
-
this.code = code;
|
|
585
|
-
this.hint = hint;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
653
|
function fail(message, code = 2, hint) {
|
|
589
654
|
throw new Exit(message, code, hint);
|
|
590
655
|
}
|
|
591
|
-
|
|
592
|
-
class UsageError extends Exit {
|
|
593
|
-
constructor(message, hint) {
|
|
594
|
-
super(message, 2, hint);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
656
|
function badUsage(message) {
|
|
598
657
|
throw new UsageError(message);
|
|
599
658
|
}
|
|
600
659
|
|
|
601
|
-
class HelpShown extends Exit {
|
|
602
|
-
constructor() {
|
|
603
|
-
super("help shown", 0);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
660
|
class Completing {
|
|
608
661
|
options;
|
|
609
662
|
positionals;
|
|
@@ -614,11 +667,6 @@ class Completing {
|
|
|
614
667
|
this.candidates = candidates;
|
|
615
668
|
}
|
|
616
669
|
}
|
|
617
|
-
var completion = { active: false };
|
|
618
|
-
var OUTPUT_OPTIONS = {
|
|
619
|
-
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
620
|
-
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
621
|
-
};
|
|
622
670
|
function applyOutput(color, plain, env = process10.env) {
|
|
623
671
|
const when = plain === true ? "never" : color ?? "auto";
|
|
624
672
|
if (when === "auto")
|
|
@@ -772,7 +820,6 @@ function parseError(error) {
|
|
|
772
820
|
const message = upTo(error instanceof Error ? error.message : String(error), ". ");
|
|
773
821
|
return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
|
|
774
822
|
}
|
|
775
|
-
var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
776
823
|
function nearestOption(message, options, allowNegative) {
|
|
777
824
|
const typed = UNKNOWN_OPTION.exec(message)?.[1];
|
|
778
825
|
if (typed === undefined)
|
|
@@ -788,6 +835,72 @@ function nearestOption(message, options, allowNegative) {
|
|
|
788
835
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
789
836
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
790
837
|
}
|
|
838
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
839
|
+
var init_args = __esm(() => {
|
|
840
|
+
init_format();
|
|
841
|
+
init_help();
|
|
842
|
+
init_text2();
|
|
843
|
+
init_help();
|
|
844
|
+
init_input();
|
|
845
|
+
DASHES = /^-+/;
|
|
846
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
847
|
+
Exit = class Exit extends Error {
|
|
848
|
+
code;
|
|
849
|
+
hint;
|
|
850
|
+
[EXIT] = true;
|
|
851
|
+
constructor(message, code, hint) {
|
|
852
|
+
super(message);
|
|
853
|
+
this.code = code;
|
|
854
|
+
this.hint = hint;
|
|
855
|
+
}
|
|
856
|
+
static [Symbol.hasInstance](value) {
|
|
857
|
+
if (this !== Exit)
|
|
858
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
859
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
UsageError = class UsageError extends Exit {
|
|
863
|
+
constructor(message, hint) {
|
|
864
|
+
super(message, 2, hint);
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
HelpShown = class HelpShown extends Exit {
|
|
868
|
+
constructor() {
|
|
869
|
+
super("help shown", 0);
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
completion = { active: false };
|
|
873
|
+
OUTPUT_OPTIONS = {
|
|
874
|
+
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
875
|
+
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
876
|
+
};
|
|
877
|
+
UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
// ../kit/src/folders.ts
|
|
881
|
+
import { homedir as homedir5 } from "os";
|
|
882
|
+
import { join as join7 } from "path";
|
|
883
|
+
import process18 from "process";
|
|
884
|
+
function ignoredFolders(extra = [], where = {}) {
|
|
885
|
+
const configured = readUserConfig("config", where).ignore;
|
|
886
|
+
const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
|
|
887
|
+
return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
|
|
888
|
+
}
|
|
889
|
+
function cacheFolder({ home = homedir5(), env = process18.env } = {}) {
|
|
890
|
+
return xdgFolder(env.XDG_CACHE_HOME, join7(home, ".cache"));
|
|
891
|
+
}
|
|
892
|
+
var SKIPPED_FOLDERS;
|
|
893
|
+
var init_folders = __esm(() => {
|
|
894
|
+
init_user_config();
|
|
895
|
+
SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
// src/cli.ts
|
|
899
|
+
import process24 from "process";
|
|
900
|
+
|
|
901
|
+
// ../kit/src/index.ts
|
|
902
|
+
init_args();
|
|
903
|
+
|
|
791
904
|
// ../kit/src/argv.ts
|
|
792
905
|
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
793
906
|
import { resolve as resolve3 } from "path";
|
|
@@ -812,11 +925,25 @@ function scriptArgs(argv = process11.argv.slice(2), cmdline = commandLine(), scr
|
|
|
812
925
|
const after = at === -1 ? [] : cmdline.slice(at + 1);
|
|
813
926
|
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
814
927
|
}
|
|
928
|
+
// ../kit/src/chart.ts
|
|
929
|
+
init_format();
|
|
930
|
+
init_mode();
|
|
931
|
+
init_style();
|
|
932
|
+
init_theme();
|
|
933
|
+
// ../kit/src/ci.ts
|
|
934
|
+
init_args();
|
|
935
|
+
init_format();
|
|
936
|
+
|
|
937
|
+
// ../kit/src/progress.ts
|
|
938
|
+
init_format();
|
|
939
|
+
|
|
815
940
|
// ../kit/src/process.ts
|
|
941
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
816
942
|
import { constants } from "os";
|
|
817
943
|
import process12 from "process";
|
|
818
944
|
var KILL_GRACE_MS = 2000;
|
|
819
945
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
946
|
+
var GROUP_SIGNALS = new Set(["SIGINT", "SIGHUP"]);
|
|
820
947
|
function exitCodeOf(code, signal) {
|
|
821
948
|
if (code !== null)
|
|
822
949
|
return code;
|
|
@@ -824,6 +951,21 @@ function exitCodeOf(code, signal) {
|
|
|
824
951
|
return 128 + signal;
|
|
825
952
|
return signal === null ? 129 : 128 + constants.signals[signal];
|
|
826
953
|
}
|
|
954
|
+
function groupsOf(pid) {
|
|
955
|
+
try {
|
|
956
|
+
const stat = readFileSync4(`/proc/${pid}/stat`, "utf8");
|
|
957
|
+
const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
|
|
958
|
+
return { group: Number(fields[2]), foreground: Number(fields[5]) };
|
|
959
|
+
} catch {
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
function heardTheTerminal(child) {
|
|
964
|
+
if (child.pid === undefined)
|
|
965
|
+
return false;
|
|
966
|
+
const own = groupsOf("self");
|
|
967
|
+
return own !== undefined && own.group === own.foreground && groupsOf(child.pid)?.group === own.group;
|
|
968
|
+
}
|
|
827
969
|
function holdSignals(cleanup) {
|
|
828
970
|
let received;
|
|
829
971
|
let child;
|
|
@@ -842,7 +984,8 @@ function holdSignals(cleanup) {
|
|
|
842
984
|
function onSignal(signal) {
|
|
843
985
|
received = signal;
|
|
844
986
|
if (child !== undefined) {
|
|
845
|
-
|
|
987
|
+
if (!GROUP_SIGNALS.has(signal) || !heardTheTerminal(child))
|
|
988
|
+
child.kill(signal);
|
|
846
989
|
return;
|
|
847
990
|
}
|
|
848
991
|
if (cleanup === undefined)
|
|
@@ -855,10 +998,10 @@ function holdSignals(cleanup) {
|
|
|
855
998
|
process12.on(signal, onSignal);
|
|
856
999
|
return held;
|
|
857
1000
|
}
|
|
858
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1001
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
859
1002
|
const chunks = [];
|
|
860
1003
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
861
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1004
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
862
1005
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
863
1006
|
const timers = [];
|
|
864
1007
|
const killGroup = (killing) => {
|
|
@@ -898,12 +1041,19 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
898
1041
|
stop();
|
|
899
1042
|
continue;
|
|
900
1043
|
}
|
|
1044
|
+
if (state.truncated)
|
|
1045
|
+
continue;
|
|
1046
|
+
let kept = data;
|
|
901
1047
|
if (state.kept + data.length > maxBytes) {
|
|
1048
|
+
let cut = maxBytes - state.kept;
|
|
1049
|
+
while (cut > 0 && ((data[cut] ?? 0) & 192) === 128)
|
|
1050
|
+
cut--;
|
|
1051
|
+
kept = data.subarray(0, cut);
|
|
902
1052
|
state.truncated = true;
|
|
903
|
-
continue;
|
|
904
1053
|
}
|
|
905
|
-
state.kept +=
|
|
906
|
-
|
|
1054
|
+
state.kept += kept.length;
|
|
1055
|
+
if (kept.length > 0)
|
|
1056
|
+
chunks.push({ stream: name, data: kept });
|
|
907
1057
|
}
|
|
908
1058
|
};
|
|
909
1059
|
try {
|
|
@@ -920,6 +1070,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
920
1070
|
const joined = () => Buffer.concat(chunks.map(({ data }) => data));
|
|
921
1071
|
let output;
|
|
922
1072
|
let text;
|
|
1073
|
+
let stdout;
|
|
923
1074
|
return {
|
|
924
1075
|
code: exitCodeOf(proc.exitCode, proc.signalCode),
|
|
925
1076
|
chunks,
|
|
@@ -930,19 +1081,70 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
930
1081
|
},
|
|
931
1082
|
get text() {
|
|
932
1083
|
return text ??= (output ??= joined()).toString();
|
|
1084
|
+
},
|
|
1085
|
+
get stdout() {
|
|
1086
|
+
return stdout ??= Buffer.concat(chunks.filter((chunk) => chunk.stream === "stdout").map((chunk) => chunk.data)).toString();
|
|
933
1087
|
}
|
|
934
1088
|
};
|
|
935
1089
|
}
|
|
936
1090
|
|
|
937
1091
|
// ../kit/src/progress.ts
|
|
1092
|
+
init_style();
|
|
1093
|
+
init_theme();
|
|
938
1094
|
var ESC = String.fromCharCode(27);
|
|
939
1095
|
var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
|
|
940
1096
|
var RESET_STYLE = `${ESC}[0m`;
|
|
941
1097
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
1098
|
+
|
|
1099
|
+
// ../kit/src/ci.ts
|
|
1100
|
+
init_style();
|
|
1101
|
+
|
|
1102
|
+
// ../kit/src/tool.ts
|
|
1103
|
+
init_format();
|
|
942
1104
|
// ../kit/src/cli.ts
|
|
943
|
-
|
|
1105
|
+
init_args();
|
|
1106
|
+
import { readFileSync as readFileSync5, realpathSync as realpathSync2 } from "fs";
|
|
944
1107
|
import { dirname as dirname3, join as join6 } from "path";
|
|
945
|
-
import
|
|
1108
|
+
import process17 from "process";
|
|
1109
|
+
|
|
1110
|
+
// ../kit/src/askpass.ts
|
|
1111
|
+
import process13 from "process";
|
|
1112
|
+
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1113
|
+
async function askpassClient(argv) {
|
|
1114
|
+
const socketPath = process13.env[SOCKET_VARIABLE];
|
|
1115
|
+
if (socketPath === undefined)
|
|
1116
|
+
return;
|
|
1117
|
+
const request = { prompt: argv[0] ?? "", ...process13.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
|
|
1118
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
1119
|
+
let received = "";
|
|
1120
|
+
try {
|
|
1121
|
+
await Bun.connect({
|
|
1122
|
+
unix: socketPath,
|
|
1123
|
+
socket: {
|
|
1124
|
+
open: (socket) => void socket.write(`${JSON.stringify(request)}
|
|
1125
|
+
`),
|
|
1126
|
+
data: (_, chunk) => {
|
|
1127
|
+
received += chunk.toString();
|
|
1128
|
+
},
|
|
1129
|
+
close: () => resolve(received),
|
|
1130
|
+
error: () => resolve("")
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
} catch {
|
|
1134
|
+
return 1;
|
|
1135
|
+
}
|
|
1136
|
+
const reply = await promise;
|
|
1137
|
+
if (reply === "")
|
|
1138
|
+
return 1;
|
|
1139
|
+
const { answer } = JSON.parse(reply);
|
|
1140
|
+
if (request.notice === true)
|
|
1141
|
+
return 0;
|
|
1142
|
+
if (answer === undefined)
|
|
1143
|
+
return 1;
|
|
1144
|
+
process13.stdout.write(`${answer}
|
|
1145
|
+
`);
|
|
1146
|
+
return 0;
|
|
1147
|
+
}
|
|
946
1148
|
|
|
947
1149
|
// ../kit/src/completions.ts
|
|
948
1150
|
var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
|
|
@@ -1005,49 +1207,54 @@ compdef __kaynooo_cli_complete ${bins.join(" ")}
|
|
|
1005
1207
|
}
|
|
1006
1208
|
|
|
1007
1209
|
// ../kit/src/notify.ts
|
|
1008
|
-
|
|
1210
|
+
init_format();
|
|
1211
|
+
init_mode();
|
|
1212
|
+
import process14 from "process";
|
|
1009
1213
|
var NOTIFY_AFTER_MS = 1e4;
|
|
1010
1214
|
var CANCELLED = 130;
|
|
1011
1215
|
function base64(text) {
|
|
1012
1216
|
return Buffer.from(text).toString("base64");
|
|
1013
1217
|
}
|
|
1014
|
-
function notification(title, body, env =
|
|
1015
|
-
const id = `kit${
|
|
1218
|
+
function notification(title, body, env = process14.env) {
|
|
1219
|
+
const id = `kit${process14.pid}`;
|
|
1016
1220
|
const codes = [`\x1B]99;i=${id}:d=0:o=unfocused:e=1;${base64(title)}\x1B\\`, `\x1B]99;i=${id}:p=body:e=1;${base64(body)}\x1B\\`];
|
|
1017
1221
|
return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
|
|
1018
1222
|
}
|
|
1019
|
-
function notifyEnd(command, code, ms, { stream =
|
|
1223
|
+
function notifyEnd(command, code, ms, { stream = process14.stderr, env = process14.env } = {}) {
|
|
1020
1224
|
if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
|
|
1021
1225
|
return;
|
|
1022
1226
|
stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
|
|
1023
1227
|
}
|
|
1024
1228
|
|
|
1229
|
+
// ../kit/src/cli.ts
|
|
1230
|
+
init_style();
|
|
1231
|
+
init_text2();
|
|
1232
|
+
|
|
1025
1233
|
// ../kit/src/usage.ts
|
|
1026
1234
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1027
1235
|
import { homedir as homedir4 } from "os";
|
|
1028
|
-
import { dirname as dirname2,
|
|
1029
|
-
import
|
|
1236
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
1237
|
+
import process16 from "process";
|
|
1030
1238
|
|
|
1031
1239
|
// ../kit/src/logs.ts
|
|
1240
|
+
init_user_config();
|
|
1032
1241
|
import { lstatSync, openSync } from "fs";
|
|
1033
1242
|
import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
|
|
1034
1243
|
import { homedir as homedir3, tmpdir } from "os";
|
|
1035
1244
|
import { join as join4 } from "path";
|
|
1036
|
-
import
|
|
1245
|
+
import process15 from "process";
|
|
1037
1246
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
1038
1247
|
var CLI_FOLDER = "kaynooo-cli";
|
|
1039
1248
|
function isPrivateDirectory(path) {
|
|
1040
1249
|
try {
|
|
1041
1250
|
const info = lstatSync(path, { throwIfNoEntry: false });
|
|
1042
|
-
return info !== undefined && info.isDirectory() && info.uid === (
|
|
1251
|
+
return info !== undefined && info.isDirectory() && info.uid === (process15.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
|
|
1043
1252
|
} catch {
|
|
1044
1253
|
return false;
|
|
1045
1254
|
}
|
|
1046
1255
|
}
|
|
1047
|
-
async function privateLogDirectory(name, env =
|
|
1048
|
-
const
|
|
1049
|
-
const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
|
|
1050
|
-
const path = join4(base, name);
|
|
1256
|
+
async function privateLogDirectory(name, env = process15.env) {
|
|
1257
|
+
const path = join4(xdgFolder(env.XDG_RUNTIME_DIR, join4(homedir3(), ".cache")), CLI_FOLDER, name);
|
|
1051
1258
|
try {
|
|
1052
1259
|
await mkdir(path, { recursive: true, mode: 448 });
|
|
1053
1260
|
if (isPrivateDirectory(path))
|
|
@@ -1077,6 +1284,7 @@ async function sweepLogs(dir, maxAgeMs = DAY_MS, now = Date.now()) {
|
|
|
1077
1284
|
}
|
|
1078
1285
|
|
|
1079
1286
|
// ../kit/src/usage.ts
|
|
1287
|
+
init_user_config();
|
|
1080
1288
|
var UNKNOWN_OPTION2 = /unknown option '(--[a-z][a-z0-9-]*)[=']/;
|
|
1081
1289
|
var FLAG_NAME = /^(?:--[a-z][a-z0-9-]*|-[a-zA-Z])$/;
|
|
1082
1290
|
var LONGEST_NAME = 40;
|
|
@@ -1084,14 +1292,13 @@ var usageError;
|
|
|
1084
1292
|
function noteUsageError(message) {
|
|
1085
1293
|
usageError = message;
|
|
1086
1294
|
}
|
|
1087
|
-
function stateHome(env =
|
|
1088
|
-
|
|
1089
|
-
return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
|
|
1295
|
+
function stateHome(env = process16.env) {
|
|
1296
|
+
return xdgFolder(env.XDG_STATE_HOME, join5(homedir4(), ".local", "state"));
|
|
1090
1297
|
}
|
|
1091
|
-
function usagePath(env =
|
|
1298
|
+
function usagePath(env = process16.env) {
|
|
1092
1299
|
return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1093
1300
|
}
|
|
1094
|
-
function usageRecorded(env =
|
|
1301
|
+
function usageRecorded(env = process16.env) {
|
|
1095
1302
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1096
1303
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1097
1304
|
}
|
|
@@ -1100,12 +1307,12 @@ function flagNames(argv) {
|
|
|
1100
1307
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
1101
1308
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
1102
1309
|
}
|
|
1103
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
1310
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
1104
1311
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
1105
1312
|
usageError = undefined;
|
|
1106
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1313
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
1107
1314
|
}
|
|
1108
|
-
function recordUsage(entry, env =
|
|
1315
|
+
function recordUsage(entry, env = process16.env) {
|
|
1109
1316
|
if (!usageRecorded(env))
|
|
1110
1317
|
return;
|
|
1111
1318
|
try {
|
|
@@ -1127,8 +1334,8 @@ var TOP_OPTIONS = {
|
|
|
1127
1334
|
completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
|
|
1128
1335
|
};
|
|
1129
1336
|
function printError(prefix, message, hint, cause) {
|
|
1130
|
-
const colors = paint(
|
|
1131
|
-
const styled = takesControlCodes(
|
|
1337
|
+
const colors = paint(process17.stderr);
|
|
1338
|
+
const styled = takesControlCodes(process17.stderr);
|
|
1132
1339
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1133
1340
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1134
1341
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1230,7 +1437,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1230
1437
|
} catch {}
|
|
1231
1438
|
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1232
1439
|
try {
|
|
1233
|
-
const { version } = JSON.parse(
|
|
1440
|
+
const { version } = JSON.parse(readFileSync5(join6(dir, "package.json"), "utf8"));
|
|
1234
1441
|
if (typeof version === "string")
|
|
1235
1442
|
return version;
|
|
1236
1443
|
} catch {}
|
|
@@ -1239,6 +1446,9 @@ function packageVersion(entry = Bun.main) {
|
|
|
1239
1446
|
}
|
|
1240
1447
|
}
|
|
1241
1448
|
async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
|
|
1449
|
+
const answered = await askpassClient(argv);
|
|
1450
|
+
if (answered !== undefined)
|
|
1451
|
+
return answered;
|
|
1242
1452
|
if (argv[0] === COMPLETE)
|
|
1243
1453
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1244
1454
|
if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
|
|
@@ -1257,12 +1467,17 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
|
|
|
1257
1467
|
notifyEnd(name, code, performance.now() - started);
|
|
1258
1468
|
if (usage !== false) {
|
|
1259
1469
|
try {
|
|
1260
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
1470
|
+
recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
|
|
1261
1471
|
} catch {}
|
|
1262
1472
|
}
|
|
1263
1473
|
return code;
|
|
1264
1474
|
}
|
|
1475
|
+
|
|
1476
|
+
// ../kit/src/index.ts
|
|
1477
|
+
init_config();
|
|
1478
|
+
|
|
1265
1479
|
// ../kit/src/excerpt.ts
|
|
1480
|
+
init_text2();
|
|
1266
1481
|
var BASH_ECHO = /^\$ /;
|
|
1267
1482
|
var DURATION2 = / \[[\d.]+m?s\]$/;
|
|
1268
1483
|
var BOUNDARY = /^(?:\((?:pass|fail|skip|todo)\) |\S+\.test\.[jt]sx?:$)/;
|
|
@@ -1417,32 +1632,49 @@ function failureExcerpt(output) {
|
|
|
1417
1632
|
return cut(squeeze(recognised(lines, PARSERS) ?? lines.slice(-TAIL)));
|
|
1418
1633
|
}
|
|
1419
1634
|
var LOG_PATTERNS = { BASH_ECHO, DURATION: DURATION2, BOUNDARY, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_CONTINUATION, TSC_FRAME, TSC_SUMMARY, ESLINT_PROBLEM, ESLINT_SUMMARY };
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1635
|
+
|
|
1636
|
+
// ../kit/src/index.ts
|
|
1637
|
+
init_folders();
|
|
1638
|
+
init_format();
|
|
1639
|
+
|
|
1640
|
+
// ../kit/src/git.ts
|
|
1641
|
+
init_args();
|
|
1642
|
+
// ../kit/src/limit.ts
|
|
1643
|
+
init_args();
|
|
1644
|
+
|
|
1645
|
+
// ../kit/src/index.ts
|
|
1646
|
+
init_mode();
|
|
1647
|
+
|
|
1648
|
+
// ../kit/src/report.ts
|
|
1649
|
+
init_style();
|
|
1650
|
+
init_text2();
|
|
1433
1651
|
// ../kit/src/secrets.ts
|
|
1434
1652
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1653
|
+
var NOT_PASSWORDS = new Set(["compass", "encompass", "bypass", "overpass", "underpass", "surpass", "trespass"]);
|
|
1435
1654
|
// ../kit/src/sessions.ts
|
|
1436
1655
|
var {Glob } = globalThis.Bun;
|
|
1437
1656
|
var SESSION_FILES = new Glob("*.json");
|
|
1438
1657
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1658
|
+
|
|
1659
|
+
// ../kit/src/index.ts
|
|
1660
|
+
init_style();
|
|
1661
|
+
init_text2();
|
|
1662
|
+
init_theme();
|
|
1663
|
+
init_user_config();
|
|
1664
|
+
|
|
1665
|
+
// ../kit/src/watch.ts
|
|
1666
|
+
init_args();
|
|
1667
|
+
init_input();
|
|
1668
|
+
init_style();
|
|
1669
|
+
// ../kit/src/workspace-root.ts
|
|
1670
|
+
init_user_config();
|
|
1439
1671
|
// package.json
|
|
1440
|
-
var version = "0.
|
|
1672
|
+
var version = "0.21.2";
|
|
1441
1673
|
|
|
1442
1674
|
// src/check.ts
|
|
1443
1675
|
import { writeFile as writeFile3 } from "fs/promises";
|
|
1444
1676
|
import { basename as basename4, join as join14 } from "path";
|
|
1445
|
-
import
|
|
1677
|
+
import process23 from "process";
|
|
1446
1678
|
|
|
1447
1679
|
// ../kit/src/shell.ts
|
|
1448
1680
|
var SEPARATORS = new Set([`
|
|
@@ -1453,6 +1685,7 @@ var COMMENT_PREFIXES = new Set([";", "&", "|", "(", ")"]);
|
|
|
1453
1685
|
var SAFE_WORD = /^[\w@%+=:,./-]+$/;
|
|
1454
1686
|
var DOUBLE_QUOTED_ESCAPES = new Set(["$", "`", '"', "\\"]);
|
|
1455
1687
|
var KEYWORDS = new Set(["then", "do", "else", "if", "elif", "while", "until", "!", "{", "}"]);
|
|
1688
|
+
var FISH_COMBINERS = new Set(["and", "or", "not"]);
|
|
1456
1689
|
var SHELLS = new Set(["sh", "bash", "zsh", "dash", "ash", "ksh", "fish", "csh", "tcsh", "nu", "xonsh", "elvish", "pwsh", "powershell"]);
|
|
1457
1690
|
var SCANNED_PROGRAMS = new Set(["su", "runuser", "flock"]);
|
|
1458
1691
|
var COMMAND_STRING_PROGRAMS = new Set([...SHELLS, ...SCANNED_PROGRAMS]);
|
|
@@ -1464,6 +1697,7 @@ var FIND_EXEC = new Set(["-exec", "-execdir", "-ok", "-okdir"]);
|
|
|
1464
1697
|
function wrapper(short = "", long = [], operands = 0, runsString = false) {
|
|
1465
1698
|
return { short, long, operands, runsString };
|
|
1466
1699
|
}
|
|
1700
|
+
var RUNNER = { ...wrapper(), afterDashes: true };
|
|
1467
1701
|
var WRAPPERS = new Map([
|
|
1468
1702
|
["command", wrapper()],
|
|
1469
1703
|
["builtin", wrapper()],
|
|
@@ -1485,7 +1719,23 @@ var WRAPPERS = new Map([
|
|
|
1485
1719
|
["parallel", wrapper("jnNSaIPlLdTsC", ["--jobs", "--max-args", "--max-replace-args", "--sshlogin", "--arg-file", "--delimiter", "--colsep"], 0, true)],
|
|
1486
1720
|
["unbuffer", wrapper()],
|
|
1487
1721
|
["systemd-run", wrapper("puEMH", ["--property", "--unit", "--description", "--slice", "--setenv", "--machine", "--host", "--uid", "--gid", "--working-directory", "--nice", "--service-type"])],
|
|
1488
|
-
["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])]
|
|
1722
|
+
["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])],
|
|
1723
|
+
["strace", wrapper("abeEIoOpPsSuUX", ["--trace", "--output", "--attach", "--string-limit", "--user", "--env", "--columns", "--trace-path", "--signal", "--status", "--summary-sort-by", "--summary-columns", "--const-print-style", "--interruptible", "--detach-on"])],
|
|
1724
|
+
["ltrace", wrapper("aeFlnopsuxX", ["--output", "--user", "--library", "--config", "--align", "--indent"])],
|
|
1725
|
+
["taskset", wrapper("", [], 1)],
|
|
1726
|
+
["fakeroot", wrapper("lsib", ["--lib", "--faked"])],
|
|
1727
|
+
["sshpass", wrapper("pfdP")],
|
|
1728
|
+
["coproc", wrapper()],
|
|
1729
|
+
["proxychains", wrapper("f")],
|
|
1730
|
+
["proxychains4", wrapper("f")],
|
|
1731
|
+
["torsocks", wrapper("upaP", ["--user", "--pass", "--address", "--port"])],
|
|
1732
|
+
["chrt", wrapper("TPD", ["--sched-runtime", "--sched-period", "--sched-deadline"], 1)],
|
|
1733
|
+
["unshare", wrapper("SGRw", ["--setuid", "--setgid", "--root", "--wd", "--map-user", "--map-group", "--map-users", "--map-groups", "--propagation", "--setgroups"])],
|
|
1734
|
+
["nsenter", wrapper("tSG", ["--target", "--setuid", "--setgid"])],
|
|
1735
|
+
["out", RUNNER],
|
|
1736
|
+
["slot", RUNNER],
|
|
1737
|
+
["waitfor", RUNNER],
|
|
1738
|
+
["base", RUNNER]
|
|
1489
1739
|
]);
|
|
1490
1740
|
function shellQuote(word) {
|
|
1491
1741
|
return SAFE_WORD.test(word) && !word.startsWith("=") ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
@@ -1495,7 +1745,7 @@ function shellQuote(word) {
|
|
|
1495
1745
|
import { existsSync as existsSync4 } from "fs";
|
|
1496
1746
|
import { homedir as homedir6 } from "os";
|
|
1497
1747
|
import { basename, dirname as dirname4, join as join8, relative, resolve as resolve4 } from "path";
|
|
1498
|
-
import
|
|
1748
|
+
import process20 from "process";
|
|
1499
1749
|
var COMPOSE_FILES = ["compose.yaml", "compose.yml", "docker-compose.yaml", "docker-compose.yml"];
|
|
1500
1750
|
var OVERRIDE_FILES = ["compose.override.yaml", "compose.override.yml", "docker-compose.override.yaml", "docker-compose.override.yml"];
|
|
1501
1751
|
var PS_TIMEOUT_MS = 20000;
|
|
@@ -1539,7 +1789,7 @@ async function variables(composeDir) {
|
|
|
1539
1789
|
if (match !== null && !line.trimStart().startsWith("#"))
|
|
1540
1790
|
env[match[1] ?? ""] = (match[2] ?? "").trim().replace(QUOTED, "$2");
|
|
1541
1791
|
}
|
|
1542
|
-
for (const [key, value] of Object.entries(
|
|
1792
|
+
for (const [key, value] of Object.entries(process20.env)) {
|
|
1543
1793
|
if (value !== undefined)
|
|
1544
1794
|
env[key] = value;
|
|
1545
1795
|
}
|
|
@@ -1675,7 +1925,7 @@ async function place(dir, program, { service, host } = {}) {
|
|
|
1675
1925
|
fail(`--in ${service}: no compose project mounts ${dir}`);
|
|
1676
1926
|
return;
|
|
1677
1927
|
}
|
|
1678
|
-
if (Bun.which("docker", { PATH:
|
|
1928
|
+
if (Bun.which("docker", { PATH: process20.env.PATH ?? "" }) === null) {
|
|
1679
1929
|
if (service !== undefined)
|
|
1680
1930
|
fail(`--in ${service}: docker not found`);
|
|
1681
1931
|
if (!noticed.has(found.composeDir)) {
|
|
@@ -1727,7 +1977,7 @@ class Stack {
|
|
|
1727
1977
|
}
|
|
1728
1978
|
static async running(composeDir) {
|
|
1729
1979
|
try {
|
|
1730
|
-
const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env:
|
|
1980
|
+
const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process20.env, timeoutMs: PS_TIMEOUT_MS });
|
|
1731
1981
|
if (ran.code !== 0)
|
|
1732
1982
|
return `docker compose ps failed in ${composeDir}: ${ran.text.trim().split(`
|
|
1733
1983
|
`).at(-1) ?? `exit ${ran.code}`}`;
|
|
@@ -1762,7 +2012,7 @@ function placeSettings(values) {
|
|
|
1762
2012
|
import { existsSync as existsSync5, statSync as statSync2 } from "fs";
|
|
1763
2013
|
import { rename, writeFile as writeFile2 } from "fs/promises";
|
|
1764
2014
|
import { join as join12 } from "path";
|
|
1765
|
-
import
|
|
2015
|
+
import process22 from "process";
|
|
1766
2016
|
|
|
1767
2017
|
// src/changes.ts
|
|
1768
2018
|
import { stat as stat2 } from "fs/promises";
|
|
@@ -1944,17 +2194,13 @@ async function discover(dir) {
|
|
|
1944
2194
|
}
|
|
1945
2195
|
|
|
1946
2196
|
// src/options.ts
|
|
1947
|
-
var
|
|
2197
|
+
var options = {
|
|
1948
2198
|
list: { type: "boolean", short: "l", description: "print the steps (or, with --fix, the fixers) found, the commands that run them and where (host or service), without running them" },
|
|
1949
|
-
only: { type: "string", short: "o", description: `comma separated steps to run, among ${STEP_NAMES.join(", ")}; with --fix the fixers to run, by the names --list prints
|
|
2199
|
+
only: { type: "string", short: "o", description: `comma separated steps to run, among ${STEP_NAMES.join(", ")}; with --fix the fixers to run, by the names --list prints`, candidates: () => [...STEP_NAMES] },
|
|
1950
2200
|
timeout: { type: "string", short: "t", description: "longest a step or fixer may run before it is ended (30s, 5m, 1h), none by default" },
|
|
1951
2201
|
...placeOptions,
|
|
1952
|
-
json: jsonOption()
|
|
1953
|
-
}
|
|
1954
|
-
var options = {
|
|
1955
|
-
...fixOptions,
|
|
1956
|
-
only: { ...fixOptions.only, candidates: () => [...STEP_NAMES] },
|
|
1957
|
-
fix: { type: "boolean", short: "f", description: "run the folder's fixers and formatters instead of the steps, as the fix bin does" },
|
|
2202
|
+
json: jsonOption("[{name, command, in?, ok, ms, log, failed?}], with --list [{name, command, source, in?}], with --fix {fixers, changed}"),
|
|
2203
|
+
fix: { type: "boolean", short: "f", description: "run the folder's fixers and formatters instead of the steps" },
|
|
1958
2204
|
quiet: { type: "boolean", short: "q", description: "print nothing for a passing step, and nothing at all when every step passes" },
|
|
1959
2205
|
failed: { type: "boolean", description: "run only the steps that failed in the last run of this folder, read from the run folder" },
|
|
1960
2206
|
changed: { type: "boolean", short: "c", description: "narrow lint and test to the files changed against HEAD (a bare linter script, a bare bun test script), every other step runs in full and says so" },
|
|
@@ -1978,14 +2224,14 @@ function pick(steps, only, noun = "step") {
|
|
|
1978
2224
|
// src/run.ts
|
|
1979
2225
|
import { mkdir as mkdir2, readdir as readdir3, stat as stat3, writeFile } from "fs/promises";
|
|
1980
2226
|
import { basename as basename2, join as join11 } from "path";
|
|
1981
|
-
import
|
|
2227
|
+
import process21 from "process";
|
|
1982
2228
|
var LOG_MAX_AGE_MS = 3 * 24 * 60 * 60 * 1000;
|
|
1983
2229
|
var RESULTS_FILE = "results.json";
|
|
1984
2230
|
var runPrefix = (cwd) => `${basename2(cwd)}-${Bun.hash(cwd).toString(36)}-`;
|
|
1985
2231
|
async function logDirectory(cwd) {
|
|
1986
2232
|
const root = await privateLogDirectory("check");
|
|
1987
2233
|
await sweepLogs(root, LOG_MAX_AGE_MS);
|
|
1988
|
-
const path = join11(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${
|
|
2234
|
+
const path = join11(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process21.pid}`);
|
|
1989
2235
|
await mkdir2(path, { mode: 448 });
|
|
1990
2236
|
return path;
|
|
1991
2237
|
}
|
|
@@ -2013,7 +2259,7 @@ async function lastFailed(cwd) {
|
|
|
2013
2259
|
async function saveLog(output) {
|
|
2014
2260
|
const root = await privateLogDirectory("errs");
|
|
2015
2261
|
await sweepLogs(root);
|
|
2016
|
-
const path = join11(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${
|
|
2262
|
+
const path = join11(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process21.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
|
|
2017
2263
|
await writeFile(path, output, { mode: 384, flag: "wx" });
|
|
2018
2264
|
return path;
|
|
2019
2265
|
}
|
|
@@ -2021,7 +2267,7 @@ async function runStep(command, cwd, logFile, { env = {}, timeoutMs, held } = {}
|
|
|
2021
2267
|
const started = Date.now();
|
|
2022
2268
|
const { code, text, timedOut } = await runCommand(["sh", "-c", `${command} 2>&1`], {
|
|
2023
2269
|
cwd,
|
|
2024
|
-
env: { ...
|
|
2270
|
+
env: { ...process21.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
|
|
2025
2271
|
...timeoutMs === undefined ? {} : { timeoutMs },
|
|
2026
2272
|
...held === undefined ? {} : { onStart: (child) => held.forward(child) }
|
|
2027
2273
|
});
|
|
@@ -2037,8 +2283,8 @@ function outcomeJson(name, command, logFile, outcome, service) {
|
|
|
2037
2283
|
return { name, command, ...service === undefined ? {} : { in: service }, ok: outcome.ok, ms: outcome.ms, log: logFile, ...outcome.timedOut === true ? { timedOut: true } : {}, ...outcome.ok ? {} : { failed: failureExcerpt(outcome.output) } };
|
|
2038
2284
|
}
|
|
2039
2285
|
function printOutcome(name, width, command, logFile, outcome) {
|
|
2040
|
-
const colors = paint(
|
|
2041
|
-
const path = role("path",
|
|
2286
|
+
const colors = paint(process21.stdout);
|
|
2287
|
+
const path = role("path", process21.stdout);
|
|
2042
2288
|
const took = colors.dim(formatDuration(outcome.ms));
|
|
2043
2289
|
if (outcome.ok) {
|
|
2044
2290
|
console.log(`${colors.bold(colors.green("ok "))} ${name.padEnd(width)} ${took} ${path(logFile)}`);
|
|
@@ -2054,27 +2300,18 @@ function printOutcome(name, width, command, logFile, outcome) {
|
|
|
2054
2300
|
}
|
|
2055
2301
|
|
|
2056
2302
|
// src/fix.ts
|
|
2057
|
-
var fixUsage = `fix [--only <fixers>] [--timeout <duration>] [--in <service> | --host] [--list]
|
|
2058
|
-
|
|
2059
|
-
Alias of \`check --fix\`. Runs the folder's fixers: the project's own \`fix\` script, else its \`lint:fix\` and \`format\` ones (package.json through bun run, composer.json, a Justfile or a Makefile), then the formatters its files call for: php-cs-fixer where configured and composer.json has no fixer, just --fmt, go fmt and go mod tidy, cargo fmt, ruff where configured, and every Makefile target declared .PHONY.
|
|
2060
|
-
It looks at the folder itself only, so each package of a monorepo gets its own run.
|
|
2061
|
-
A script or php-cs-fixer runs inside the docker compose service that bind-mounts the folder (found in compose.yml, compose.yaml or docker-compose.yml, up to the repository root), at the matching path; a service that is down is never started, the fixer fails naming it. The formatters run on the host. --in picks the service, --host forces the host.
|
|
2062
|
-
Prints one line per fixer, what a failing one said, then the files the run changed. Each fixer's full output is saved to the file whose path ends its line.
|
|
2063
|
-
A fixer still running after --timeout is ended with everything it started, but not what it started inside a container.
|
|
2064
|
-
--json prints {fixers: [{name, command, in?, ok, ms, log, failed?} or {name, command, skipped}], changed} once every fixer ran, changed null outside a git repository.`;
|
|
2065
|
-
var EXITS = [[0, "every fixer ran or was skipped for a missing binary"], [1, "one failed"], [2, "bad usage, nothing applies or a fixer timed out"]];
|
|
2066
2303
|
var RUNNING = "KAYNOOO_CLI_FIX";
|
|
2067
2304
|
var JUSTFILES2 = ["justfile", "Justfile", ".justfile"];
|
|
2068
2305
|
var RUFF_CONFIGS = ["ruff.toml", ".ruff.toml"];
|
|
2069
2306
|
var RUFF_SECTION = /^\[tool\.ruff/m;
|
|
2070
2307
|
var MAX_CHANGED = 30;
|
|
2071
2308
|
async function replaceFile(path, content) {
|
|
2072
|
-
const temporary = `${path}.${
|
|
2309
|
+
const temporary = `${path}.${process22.pid}.tmp`;
|
|
2073
2310
|
await writeFile2(temporary, content, { mode: statSync2(path).mode & 511 });
|
|
2074
2311
|
await rename(temporary, path);
|
|
2075
2312
|
}
|
|
2076
2313
|
async function projectFixers(dir) {
|
|
2077
|
-
const found = await candidates(dir, "
|
|
2314
|
+
const found = await candidates(dir, "check");
|
|
2078
2315
|
const named = (name) => found.find((step) => step.name === name);
|
|
2079
2316
|
const all = named("fix");
|
|
2080
2317
|
if (all !== undefined)
|
|
@@ -2106,7 +2343,6 @@ async function toolFixers(dir) {
|
|
|
2106
2343
|
fixers.push({ name: "python", command: "ruff check --fix . && ruff format .", source: "ruff", requires: "ruff" });
|
|
2107
2344
|
return fixers;
|
|
2108
2345
|
}
|
|
2109
|
-
var fixParseOptions = { ...fixOptions, only: { ...fixOptions.only, candidates: async () => (await fixers(process21.cwd())).map((fixer) => fixer.name) } };
|
|
2110
2346
|
async function fixers(dir) {
|
|
2111
2347
|
const project = await projectFixers(dir);
|
|
2112
2348
|
const csFixer = await firstFile(dir, CS_FIXER_CONFIGS);
|
|
@@ -2142,15 +2378,11 @@ function printChanged(changed) {
|
|
|
2142
2378
|
if (changed.length > MAX_CHANGED)
|
|
2143
2379
|
console.log(` and ${changed.length - MAX_CHANGED} more`);
|
|
2144
2380
|
}
|
|
2145
|
-
async function fix(args, cwd = process21.cwd()) {
|
|
2146
|
-
const parsed = parse(args, fixUsage, fixParseOptions, { exits: EXITS, replaces: "running each fixer and formatter by hand, or docker compose exec <service> bun run lint:fix", examples: ["fix", ["fix --list", "the fixers it would run"]] });
|
|
2147
|
-
return runFixers(parsed.values, cwd);
|
|
2148
|
-
}
|
|
2149
2381
|
async function runFixers(values, cwd) {
|
|
2150
2382
|
const parsed = { values };
|
|
2151
2383
|
const settings = placeSettings(values);
|
|
2152
|
-
if (
|
|
2153
|
-
fail("a fixer called fix again, which would recurse: give its script another command");
|
|
2384
|
+
if (process22.env[RUNNING] !== undefined)
|
|
2385
|
+
fail("a fixer called check --fix again, which would recurse: give its script another command");
|
|
2154
2386
|
const found = await fixers(cwd);
|
|
2155
2387
|
if (found.length === 0)
|
|
2156
2388
|
fail("nothing to fix here: no fix, lint:fix or format script, php-cs-fixer config, Makefile, Justfile, go.mod, Cargo.toml nor ruff config");
|
|
@@ -2183,7 +2415,7 @@ async function runFixers(values, cwd) {
|
|
|
2183
2415
|
break;
|
|
2184
2416
|
if (missing(fixer)) {
|
|
2185
2417
|
if (!json)
|
|
2186
|
-
console.log(`${paint(
|
|
2418
|
+
console.log(`${paint(process22.stdout).yellow("skip ")} ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
|
|
2187
2419
|
ran.push({ name: fixer.name, command: fixer.command, skipped: `${fixer.requires} is not installed` });
|
|
2188
2420
|
continue;
|
|
2189
2421
|
}
|
|
@@ -2293,19 +2525,11 @@ async function scriptText(dir, name) {
|
|
|
2293
2525
|
var usage2 = `check [--only <steps>] [--changed] [--failed] [--quiet] [--timeout <duration>] [--slot | --no-slot] [--parallel] [--in <service> | --host] [--list]
|
|
2294
2526
|
check --fix [--only <fixers>] [--timeout <duration>] [--in <service> | --host] [--list]
|
|
2295
2527
|
|
|
2296
|
-
Runs the repo's check, typecheck, lint and test steps,
|
|
2297
|
-
A
|
|
2298
|
-
A step
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
Each step queues for one of the machine-wide slots shared by every session (slot, half the CPUs) when the slot bin is installed, so concurrent runs do not overload the machine; --no-slot skips the queue, --slot fails when the bin is missing.
|
|
2302
|
-
With --parallel, the steps run at the same time, each one's output held and printed in step order as the earlier ones finish; each still queues for its own slot. Steps writing the same files may trip over each other.
|
|
2303
|
-
With --quiet, passing steps print nothing, and a fully passing run prints nothing at all: only the failing steps and the closing summary of a run that failed.
|
|
2304
|
-
A step still running after --timeout is ended with everything it started, but not what it started inside a container.
|
|
2305
|
-
With --failed, only the steps that failed in the last run of this folder run again, read from that run's folder of logs; when no last run failed, it says so and exits 2.
|
|
2306
|
-
With --fix, the folder's fixers and formatters run instead of the steps, exactly as the \`fix\` bin does (it is the alias of \`check --fix\`): its own scripts, php-cs-fixer, just --fmt, go fmt, cargo fmt, ruff and the Makefile's .PHONY targets, then the files the run changed are listed. --only then names fixers, as --list prints them; --changed, --failed, --slot, --no-slot and --parallel do not apply.
|
|
2307
|
-
--json prints [{name, command, in?, ok, ms, log, failed?}] once every step ran, --list --json [{name, command, source, in?}], in the compose service the step ran in; with --fix the shape \`fix --json\` prints.`;
|
|
2308
|
-
var EXITS2 = [[0, "every step passed"], [1, "one failed"], [2, "bad usage, no step is found or a step timed out"]];
|
|
2528
|
+
Runs the repo's check, typecheck, lint and test steps, found in package.json scripts, composer.json, a Justfile, a Makefile or the PHP tools' configs; a folder with no steps runs its subfolders' (api/, client/).
|
|
2529
|
+
A step runs inside the running compose service that mounts its folder and never starts one, and queues for a machine-wide slot when \`slot\` is installed.
|
|
2530
|
+
A passing step prints one line, a failing one only what failed, and each step's full log is saved to the file its line ends with.
|
|
2531
|
+
With --fix, the project's fix, lint:fix and format scripts run instead, then the formatters its files call for (php-cs-fixer, \`just --fmt\`, go fmt, cargo fmt, ruff), and the files they changed are listed.`;
|
|
2532
|
+
var EXITS = [[0, "every step passed"], [1, "one failed"], [2, "bad usage, no step is found or a step timed out"]];
|
|
2309
2533
|
function slotted(command) {
|
|
2310
2534
|
return `slot -- sh -c ${shellQuote(command)}`;
|
|
2311
2535
|
}
|
|
@@ -2334,14 +2558,14 @@ function launch(step) {
|
|
|
2334
2558
|
return step.placement === undefined ? step.command : shellIn(step.placement, step.command);
|
|
2335
2559
|
}
|
|
2336
2560
|
function summaryLine(outcomes) {
|
|
2337
|
-
const colors = paint(
|
|
2561
|
+
const colors = paint(process23.stdout);
|
|
2338
2562
|
const failed = outcomes.filter((outcome) => !outcome.ok).length;
|
|
2339
2563
|
const passed = outcomes.length - failed;
|
|
2340
2564
|
const parts = [colors.green(`${passed} passed`), ...failed === 0 ? [] : [colors.red(`${failed} failed`)], colors.dim(formatDuration(outcomes.reduce((sum, outcome) => sum + outcome.ms, 0)))];
|
|
2341
2565
|
return parts.join(colors.dim(" \xB7 "));
|
|
2342
2566
|
}
|
|
2343
|
-
async function check(args, cwd =
|
|
2344
|
-
const parsed = parse(args, usage2, options, { exits:
|
|
2567
|
+
async function check(args, cwd = process23.cwd()) {
|
|
2568
|
+
const parsed = parse(args, usage2, options, { exits: EXITS, replaces: "chaining docker compose exec <service> bun run check | tail, lint and test by hand, or bun run check && bun run lint && bun run test read through tail, and with --fix each fixer and formatter run by hand", examples: ["check", ["check --only lint,test", "two of the steps"], ["check --in app", "every step inside the app service"], ["check --fix", "the fixers and formatters instead"], ["check --fix --list", "the fixers it would run"]] });
|
|
2345
2569
|
const settings = placeSettings(parsed.values);
|
|
2346
2570
|
if (parsed.values.fix === true) {
|
|
2347
2571
|
for (const flag of ["changed", "failed", "slot", "no-slot", "parallel"]) {
|
|
@@ -2353,7 +2577,7 @@ async function check(args, cwd = process22.cwd()) {
|
|
|
2353
2577
|
const timeoutMs = parsed.values.timeout === undefined ? undefined : duration(parsed.values.timeout, "timeout", 0);
|
|
2354
2578
|
if (parsed.values.slot === true && parsed.values["no-slot"] === true)
|
|
2355
2579
|
fail("--slot and --no-slot exclude each other");
|
|
2356
|
-
const hasSlot = Bun.which("slot", { PATH:
|
|
2580
|
+
const hasSlot = Bun.which("slot", { PATH: process23.env.PATH ?? "" }) !== null;
|
|
2357
2581
|
if (parsed.values.slot === true && !hasSlot)
|
|
2358
2582
|
fail("--slot needs the slot bin: bun install -g @kaynooo/cli-wait");
|
|
2359
2583
|
const slotting = parsed.values["no-slot"] !== true && hasSlot;
|
|
@@ -2386,7 +2610,7 @@ async function check(args, cwd = process22.cwd()) {
|
|
|
2386
2610
|
const width = Math.max(...steps.map((step) => step.label.length));
|
|
2387
2611
|
const outcomes = [];
|
|
2388
2612
|
const quiet = parsed.values.quiet === true;
|
|
2389
|
-
const heading = json || quiet ? "" : header("check", `${basename4(cwd)} \xB7 ${steps.length} ${steps.length === 1 ? "step" : "steps"}`,
|
|
2613
|
+
const heading = json || quiet ? "" : header("check", `${basename4(cwd)} \xB7 ${steps.length} ${steps.length === 1 ? "step" : "steps"}`, process23.stdout);
|
|
2390
2614
|
if (heading !== "")
|
|
2391
2615
|
console.log(heading);
|
|
2392
2616
|
const execute = async (step, signals) => {
|
|
@@ -2439,4 +2663,4 @@ async function check(args, cwd = process22.cwd()) {
|
|
|
2439
2663
|
}
|
|
2440
2664
|
|
|
2441
2665
|
// src/cli.ts
|
|
2442
|
-
|
|
2666
|
+
process24.exitCode = await runMain({ name: "check", version, run: async (args) => check(args) });
|