@kaynooo/cli-check 0.20.0 → 0.21.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 +17 -15
- package/dist/cli.js +456 -201
- package/dist/errs-cli.js +442 -164
- package/dist/j-cli.js +1545 -1234
- package/package.json +7 -9
- package/dist/fix-cli.js +0 -2135
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,6 +139,9 @@ 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";
|
|
@@ -158,36 +173,18 @@ function readUserConfig(bin, where = {}, legacy = []) {
|
|
|
158
173
|
return {};
|
|
159
174
|
}
|
|
160
175
|
}
|
|
176
|
+
var init_user_config = () => {};
|
|
161
177
|
|
|
162
178
|
// ../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+/;
|
|
179
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
180
|
+
import { homedir as homedir2 } from "os";
|
|
181
|
+
import { join as join3, resolve as resolve2 } from "path";
|
|
182
|
+
import process5 from "process";
|
|
185
183
|
function isColorSpec(spec) {
|
|
186
184
|
if (typeof spec === "number")
|
|
187
185
|
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
188
186
|
return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
|
|
189
187
|
}
|
|
190
|
-
var CUBE = [0, 95, 135, 175, 215, 255];
|
|
191
188
|
function cubeLevel(channel) {
|
|
192
189
|
return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
|
|
193
190
|
}
|
|
@@ -292,7 +289,6 @@ function applyFile(theme, file, where, warn) {
|
|
|
292
289
|
function endsWalk(home) {
|
|
293
290
|
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
294
291
|
}
|
|
295
|
-
var warned = new Set;
|
|
296
292
|
function warnOnce(message) {
|
|
297
293
|
if (warned.has(message))
|
|
298
294
|
return;
|
|
@@ -329,8 +325,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
|
|
|
329
325
|
}
|
|
330
326
|
return { theme, sources, preset };
|
|
331
327
|
}
|
|
332
|
-
var current;
|
|
333
|
-
var currentKey = "";
|
|
334
328
|
function activeTheme() {
|
|
335
329
|
const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
|
|
336
330
|
if (current === undefined || key !== currentKey) {
|
|
@@ -339,9 +333,38 @@ function activeTheme() {
|
|
|
339
333
|
}
|
|
340
334
|
return current;
|
|
341
335
|
}
|
|
336
|
+
var ENDS, DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
|
|
337
|
+
var init_theme = __esm(() => {
|
|
338
|
+
init_config();
|
|
339
|
+
init_user_config();
|
|
340
|
+
ENDS = new Map;
|
|
341
|
+
DEFAULT = {
|
|
342
|
+
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" },
|
|
343
|
+
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" },
|
|
344
|
+
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
345
|
+
bins: {},
|
|
346
|
+
gradient: ["#c084fc", "#67e8f9"]
|
|
347
|
+
};
|
|
348
|
+
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" };
|
|
349
|
+
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" };
|
|
350
|
+
ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
|
|
351
|
+
PRESETS = {
|
|
352
|
+
default: {},
|
|
353
|
+
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
354
|
+
mono: { colors: MONO, accents: ["bold"], gradient: undefined },
|
|
355
|
+
ascii: { glyphs: ASCII }
|
|
356
|
+
};
|
|
357
|
+
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"]);
|
|
358
|
+
HEX = /^#[0-9a-f]{6}$/i;
|
|
359
|
+
CONTROL = /\p{Cc}/u;
|
|
360
|
+
MAX_FILE_BYTES = 64 * 1024;
|
|
361
|
+
SPACES = /\s+/;
|
|
362
|
+
CUBE = [0, 95, 135, 175, 215, 255];
|
|
363
|
+
warned = new Set;
|
|
364
|
+
});
|
|
342
365
|
|
|
343
366
|
// ../kit/src/style.ts
|
|
344
|
-
|
|
367
|
+
import process6 from "process";
|
|
345
368
|
function takesControlCodes(stream, env = process6.env) {
|
|
346
369
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
347
370
|
}
|
|
@@ -364,14 +387,6 @@ function role(name, stream, env = process6.env) {
|
|
|
364
387
|
const colors = paint(stream, env);
|
|
365
388
|
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
366
389
|
}
|
|
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
390
|
function header(bin, context, stream, env = process6.env) {
|
|
376
391
|
if (!takesControlCodes(stream, env))
|
|
377
392
|
return "";
|
|
@@ -382,9 +397,24 @@ function header(bin, context, stream, env = process6.env) {
|
|
|
382
397
|
const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
|
|
383
398
|
return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
|
|
384
399
|
}
|
|
400
|
+
var MARK_WORDS, STATUS_WORDS, STATUS_OF;
|
|
401
|
+
var init_style = __esm(() => {
|
|
402
|
+
init_colors();
|
|
403
|
+
init_mode();
|
|
404
|
+
init_theme();
|
|
405
|
+
MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
|
|
406
|
+
STATUS_WORDS = {
|
|
407
|
+
passed: ["passed", "success", "succeeded", "ok"],
|
|
408
|
+
failed: ["failed", "failure", "error", "errored"],
|
|
409
|
+
running: ["running", "in_progress", "started", "holding"],
|
|
410
|
+
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
411
|
+
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
412
|
+
};
|
|
413
|
+
STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
414
|
+
});
|
|
385
415
|
|
|
386
416
|
// ../kit/src/format.ts
|
|
387
|
-
|
|
417
|
+
import process7 from "process";
|
|
388
418
|
function formatSeconds(total) {
|
|
389
419
|
let rest = Math.max(0, Math.round(total));
|
|
390
420
|
const amounts = UNITS.map(([unit, size]) => {
|
|
@@ -406,10 +436,8 @@ function upTo(text, separator) {
|
|
|
406
436
|
return end === -1 ? text : text.slice(0, end);
|
|
407
437
|
}
|
|
408
438
|
function truncate(text, width) {
|
|
409
|
-
return
|
|
439
|
+
return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
|
|
410
440
|
}
|
|
411
|
-
var LINE_BREAKS = /\s*\n\s*/g;
|
|
412
|
-
var ESCAPE = String.fromCharCode(27);
|
|
413
441
|
function textWidth(text) {
|
|
414
442
|
return Bun.stringWidth(text);
|
|
415
443
|
}
|
|
@@ -458,14 +486,40 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
|
|
|
458
486
|
function printJson(value) {
|
|
459
487
|
console.log(jsonText(value));
|
|
460
488
|
}
|
|
489
|
+
var UNITS, LINE_BREAKS, ESCAPE;
|
|
490
|
+
var init_format = __esm(() => {
|
|
491
|
+
init_text();
|
|
492
|
+
init_mode();
|
|
493
|
+
init_style();
|
|
494
|
+
UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
|
|
495
|
+
LINE_BREAKS = /\s*\n\s*/g;
|
|
496
|
+
ESCAPE = String.fromCharCode(27);
|
|
497
|
+
});
|
|
461
498
|
|
|
462
499
|
// ../kit/src/help.ts
|
|
463
500
|
import process8 from "process";
|
|
464
|
-
var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
465
|
-
var USAGE_PREFIX = /^usage:\s*/i;
|
|
466
|
-
var FULL_STOP = /\.$/;
|
|
467
501
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
468
|
-
|
|
502
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
503
|
+
`);
|
|
504
|
+
const blank = lines.indexOf("");
|
|
505
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
506
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
507
|
+
const colon = synopses[0].indexOf(": ");
|
|
508
|
+
const inline = synopses[0].slice(colon + 2);
|
|
509
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
510
|
+
if (colon !== -1)
|
|
511
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
512
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
513
|
+
`)}`;
|
|
514
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
515
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
516
|
+
return [head, ...lead, ...rest].join(`
|
|
517
|
+
`);
|
|
518
|
+
}
|
|
519
|
+
function prose(line, colors) {
|
|
520
|
+
if (colors.cyan("x") === "x")
|
|
521
|
+
return line;
|
|
522
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
469
523
|
}
|
|
470
524
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
471
525
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -500,7 +554,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
|
500
554
|
return [];
|
|
501
555
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
502
556
|
}
|
|
503
|
-
var MAX_INLINE_CHOICES = 24;
|
|
504
557
|
function optionRows(options, colors = paint(process8.stdout)) {
|
|
505
558
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
506
559
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
@@ -515,9 +568,17 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
515
568
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
516
569
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
517
570
|
}
|
|
571
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
572
|
+
var init_help = __esm(() => {
|
|
573
|
+
init_mode();
|
|
574
|
+
init_style();
|
|
575
|
+
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
576
|
+
USAGE_PREFIX = /^usage:\s*/i;
|
|
577
|
+
FULL_STOP = /\.$/;
|
|
578
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
579
|
+
});
|
|
518
580
|
|
|
519
581
|
// ../kit/src/text.ts
|
|
520
|
-
var ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
|
|
521
582
|
function stripAnsi(text) {
|
|
522
583
|
return text.replace(ANSI, "");
|
|
523
584
|
}
|
|
@@ -546,10 +607,13 @@ function closest(name, names) {
|
|
|
546
607
|
const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
|
|
547
608
|
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
548
609
|
}
|
|
610
|
+
var ANSI;
|
|
611
|
+
var init_text2 = __esm(() => {
|
|
612
|
+
ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
|
|
613
|
+
});
|
|
614
|
+
|
|
549
615
|
// ../kit/src/input.ts
|
|
550
616
|
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
617
|
function duration(value, name, fallback, unit = "s") {
|
|
554
618
|
if (value === undefined)
|
|
555
619
|
return fallback;
|
|
@@ -570,40 +634,26 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
|
570
634
|
fail(`no file ${path}`);
|
|
571
635
|
return file.text();
|
|
572
636
|
}
|
|
637
|
+
var DURATION, UNIT_MS;
|
|
638
|
+
var init_input = __esm(() => {
|
|
639
|
+
init_args();
|
|
640
|
+
DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
641
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
642
|
+
});
|
|
573
643
|
|
|
574
644
|
// ../kit/src/args.ts
|
|
575
|
-
|
|
645
|
+
import process10 from "process";
|
|
646
|
+
import { parseArgs } from "util";
|
|
576
647
|
function jsonOption(holds) {
|
|
577
648
|
return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
|
|
578
649
|
}
|
|
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
650
|
function fail(message, code = 2, hint) {
|
|
589
651
|
throw new Exit(message, code, hint);
|
|
590
652
|
}
|
|
591
|
-
|
|
592
|
-
class UsageError extends Exit {
|
|
593
|
-
constructor(message, hint) {
|
|
594
|
-
super(message, 2, hint);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
653
|
function badUsage(message) {
|
|
598
654
|
throw new UsageError(message);
|
|
599
655
|
}
|
|
600
656
|
|
|
601
|
-
class HelpShown extends Exit {
|
|
602
|
-
constructor() {
|
|
603
|
-
super("help shown", 0);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
657
|
class Completing {
|
|
608
658
|
options;
|
|
609
659
|
positionals;
|
|
@@ -614,11 +664,6 @@ class Completing {
|
|
|
614
664
|
this.candidates = candidates;
|
|
615
665
|
}
|
|
616
666
|
}
|
|
617
|
-
var completion = { active: false };
|
|
618
|
-
var OUTPUT_OPTIONS = {
|
|
619
|
-
color: { type: "string", description: "auto (on a terminal alone), always or never" },
|
|
620
|
-
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
621
|
-
};
|
|
622
667
|
function applyOutput(color, plain, env = process10.env) {
|
|
623
668
|
const when = plain === true ? "never" : color ?? "auto";
|
|
624
669
|
if (when === "auto")
|
|
@@ -772,7 +817,6 @@ function parseError(error) {
|
|
|
772
817
|
const message = upTo(error instanceof Error ? error.message : String(error), ". ");
|
|
773
818
|
return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
|
|
774
819
|
}
|
|
775
|
-
var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
776
820
|
function nearestOption(message, options, allowNegative) {
|
|
777
821
|
const typed = UNKNOWN_OPTION.exec(message)?.[1];
|
|
778
822
|
if (typed === undefined)
|
|
@@ -788,6 +832,72 @@ function nearestOption(message, options, allowNegative) {
|
|
|
788
832
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
789
833
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
790
834
|
}
|
|
835
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
836
|
+
var init_args = __esm(() => {
|
|
837
|
+
init_format();
|
|
838
|
+
init_help();
|
|
839
|
+
init_text2();
|
|
840
|
+
init_help();
|
|
841
|
+
init_input();
|
|
842
|
+
DASHES = /^-+/;
|
|
843
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
844
|
+
Exit = class Exit extends Error {
|
|
845
|
+
code;
|
|
846
|
+
hint;
|
|
847
|
+
[EXIT] = true;
|
|
848
|
+
constructor(message, code, hint) {
|
|
849
|
+
super(message);
|
|
850
|
+
this.code = code;
|
|
851
|
+
this.hint = hint;
|
|
852
|
+
}
|
|
853
|
+
static [Symbol.hasInstance](value) {
|
|
854
|
+
if (this !== Exit)
|
|
855
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
856
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
UsageError = class UsageError extends Exit {
|
|
860
|
+
constructor(message, hint) {
|
|
861
|
+
super(message, 2, hint);
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
HelpShown = class HelpShown extends Exit {
|
|
865
|
+
constructor() {
|
|
866
|
+
super("help shown", 0);
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
completion = { active: false };
|
|
870
|
+
OUTPUT_OPTIONS = {
|
|
871
|
+
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
872
|
+
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
873
|
+
};
|
|
874
|
+
UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
875
|
+
});
|
|
876
|
+
|
|
877
|
+
// ../kit/src/folders.ts
|
|
878
|
+
import { homedir as homedir5 } from "os";
|
|
879
|
+
import { join as join7 } from "path";
|
|
880
|
+
import process18 from "process";
|
|
881
|
+
function ignoredFolders(extra = [], where = {}) {
|
|
882
|
+
const configured = readUserConfig("config", where).ignore;
|
|
883
|
+
const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
|
|
884
|
+
return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
|
|
885
|
+
}
|
|
886
|
+
function cacheFolder({ home = homedir5(), env = process18.env } = {}) {
|
|
887
|
+
return env.XDG_CACHE_HOME ?? join7(home, ".cache");
|
|
888
|
+
}
|
|
889
|
+
var SKIPPED_FOLDERS;
|
|
890
|
+
var init_folders = __esm(() => {
|
|
891
|
+
init_user_config();
|
|
892
|
+
SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
893
|
+
});
|
|
894
|
+
|
|
895
|
+
// src/cli.ts
|
|
896
|
+
import process24 from "process";
|
|
897
|
+
|
|
898
|
+
// ../kit/src/index.ts
|
|
899
|
+
init_args();
|
|
900
|
+
|
|
791
901
|
// ../kit/src/argv.ts
|
|
792
902
|
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
793
903
|
import { resolve as resolve3 } from "path";
|
|
@@ -812,6 +922,18 @@ function scriptArgs(argv = process11.argv.slice(2), cmdline = commandLine(), scr
|
|
|
812
922
|
const after = at === -1 ? [] : cmdline.slice(at + 1);
|
|
813
923
|
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
814
924
|
}
|
|
925
|
+
// ../kit/src/chart.ts
|
|
926
|
+
init_format();
|
|
927
|
+
init_mode();
|
|
928
|
+
init_style();
|
|
929
|
+
init_theme();
|
|
930
|
+
// ../kit/src/ci.ts
|
|
931
|
+
init_args();
|
|
932
|
+
init_format();
|
|
933
|
+
|
|
934
|
+
// ../kit/src/progress.ts
|
|
935
|
+
init_format();
|
|
936
|
+
|
|
815
937
|
// ../kit/src/process.ts
|
|
816
938
|
import { constants } from "os";
|
|
817
939
|
import process12 from "process";
|
|
@@ -855,10 +977,10 @@ function holdSignals(cleanup) {
|
|
|
855
977
|
process12.on(signal, onSignal);
|
|
856
978
|
return held;
|
|
857
979
|
}
|
|
858
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
980
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
859
981
|
const chunks = [];
|
|
860
982
|
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 } : {} });
|
|
983
|
+
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
984
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
863
985
|
const timers = [];
|
|
864
986
|
const killGroup = (killing) => {
|
|
@@ -935,56 +1057,170 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
935
1057
|
}
|
|
936
1058
|
|
|
937
1059
|
// ../kit/src/progress.ts
|
|
1060
|
+
init_style();
|
|
1061
|
+
init_theme();
|
|
938
1062
|
var ESC = String.fromCharCode(27);
|
|
939
1063
|
var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
|
|
940
1064
|
var RESET_STYLE = `${ESC}[0m`;
|
|
941
1065
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
1066
|
+
|
|
1067
|
+
// ../kit/src/ci.ts
|
|
1068
|
+
init_style();
|
|
1069
|
+
|
|
1070
|
+
// ../kit/src/tool.ts
|
|
1071
|
+
init_format();
|
|
942
1072
|
// ../kit/src/cli.ts
|
|
1073
|
+
init_args();
|
|
943
1074
|
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
944
1075
|
import { dirname as dirname3, join as join6 } from "path";
|
|
945
|
-
import
|
|
1076
|
+
import process17 from "process";
|
|
946
1077
|
|
|
947
|
-
// ../kit/src/
|
|
1078
|
+
// ../kit/src/askpass.ts
|
|
948
1079
|
import process13 from "process";
|
|
1080
|
+
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1081
|
+
async function askpassClient(argv) {
|
|
1082
|
+
const socketPath = process13.env[SOCKET_VARIABLE];
|
|
1083
|
+
if (socketPath === undefined)
|
|
1084
|
+
return;
|
|
1085
|
+
const request = { prompt: argv[0] ?? "", ...process13.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
|
|
1086
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
1087
|
+
let received = "";
|
|
1088
|
+
try {
|
|
1089
|
+
await Bun.connect({
|
|
1090
|
+
unix: socketPath,
|
|
1091
|
+
socket: {
|
|
1092
|
+
open: (socket) => void socket.write(`${JSON.stringify(request)}
|
|
1093
|
+
`),
|
|
1094
|
+
data: (_, chunk) => {
|
|
1095
|
+
received += chunk.toString();
|
|
1096
|
+
},
|
|
1097
|
+
close: () => resolve(received),
|
|
1098
|
+
error: () => resolve("")
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
1101
|
+
} catch {
|
|
1102
|
+
return 1;
|
|
1103
|
+
}
|
|
1104
|
+
const reply = await promise;
|
|
1105
|
+
if (reply === "")
|
|
1106
|
+
return 1;
|
|
1107
|
+
const { answer } = JSON.parse(reply);
|
|
1108
|
+
if (request.notice === true)
|
|
1109
|
+
return 0;
|
|
1110
|
+
if (answer === undefined)
|
|
1111
|
+
return 1;
|
|
1112
|
+
process13.stdout.write(`${answer}
|
|
1113
|
+
`);
|
|
1114
|
+
return 0;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
// ../kit/src/completions.ts
|
|
1118
|
+
var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
|
|
1119
|
+
var FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
|
|
1120
|
+
set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
|
|
1121
|
+
set -l current (commandline -ct)
|
|
1122
|
+
for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
|
|
1123
|
+
if test "$line" = __files__
|
|
1124
|
+
__fish_complete_path $current
|
|
1125
|
+
else
|
|
1126
|
+
echo $line
|
|
1127
|
+
end
|
|
1128
|
+
end
|
|
1129
|
+
end`;
|
|
1130
|
+
var BASH_FUNCTION = `__kaynooo_cli_complete() {
|
|
1131
|
+
local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
|
|
1132
|
+
local -a lines
|
|
1133
|
+
COMPREPLY=()
|
|
1134
|
+
lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
|
|
1135
|
+
for line in "\${lines[@]}"; do
|
|
1136
|
+
if [[ $line == __files__ ]]; then
|
|
1137
|
+
COMPREPLY+=($(compgen -f -- "$cur"))
|
|
1138
|
+
else
|
|
1139
|
+
words+="\${line%%$'\\t'*}"$'\\n'
|
|
1140
|
+
fi
|
|
1141
|
+
done
|
|
1142
|
+
COMPREPLY+=($(compgen -W "$words" -- "$cur"))
|
|
1143
|
+
}`;
|
|
1144
|
+
var ZSH_FUNCTION = `__kaynooo_cli_complete() {
|
|
1145
|
+
local line
|
|
1146
|
+
local -a described plain
|
|
1147
|
+
for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
|
|
1148
|
+
if [[ $line == __files__ ]]; then
|
|
1149
|
+
_files
|
|
1150
|
+
elif [[ $line == *$'\\t'* ]]; then
|
|
1151
|
+
described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
|
|
1152
|
+
else
|
|
1153
|
+
plain+=("$line")
|
|
1154
|
+
fi
|
|
1155
|
+
done
|
|
1156
|
+
(( \${#described} )) && _describe -V value described
|
|
1157
|
+
(( \${#plain} )) && compadd -- "\${plain[@]}"
|
|
1158
|
+
return 0
|
|
1159
|
+
}`;
|
|
1160
|
+
function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
|
|
1161
|
+
if (shell === "fish")
|
|
1162
|
+
return `${header}
|
|
1163
|
+
${FISH_FUNCTION}
|
|
1164
|
+
${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
|
|
1165
|
+
`).join("")}`;
|
|
1166
|
+
if (shell === "bash")
|
|
1167
|
+
return `${header}
|
|
1168
|
+
${BASH_FUNCTION}
|
|
1169
|
+
complete -F __kaynooo_cli_complete ${bins.join(" ")}
|
|
1170
|
+
`;
|
|
1171
|
+
return `${header}
|
|
1172
|
+
${ZSH_FUNCTION}
|
|
1173
|
+
compdef __kaynooo_cli_complete ${bins.join(" ")}
|
|
1174
|
+
`;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
// ../kit/src/notify.ts
|
|
1178
|
+
init_format();
|
|
1179
|
+
init_mode();
|
|
1180
|
+
import process14 from "process";
|
|
949
1181
|
var NOTIFY_AFTER_MS = 1e4;
|
|
950
1182
|
var CANCELLED = 130;
|
|
951
1183
|
function base64(text) {
|
|
952
1184
|
return Buffer.from(text).toString("base64");
|
|
953
1185
|
}
|
|
954
|
-
function notification(title, body, env =
|
|
955
|
-
const id = `kit${
|
|
1186
|
+
function notification(title, body, env = process14.env) {
|
|
1187
|
+
const id = `kit${process14.pid}`;
|
|
956
1188
|
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\\`];
|
|
957
1189
|
return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
|
|
958
1190
|
}
|
|
959
|
-
function notifyEnd(command, code, ms, { stream =
|
|
1191
|
+
function notifyEnd(command, code, ms, { stream = process14.stderr, env = process14.env } = {}) {
|
|
960
1192
|
if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
|
|
961
1193
|
return;
|
|
962
1194
|
stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
|
|
963
1195
|
}
|
|
964
1196
|
|
|
1197
|
+
// ../kit/src/cli.ts
|
|
1198
|
+
init_style();
|
|
1199
|
+
init_text2();
|
|
1200
|
+
|
|
965
1201
|
// ../kit/src/usage.ts
|
|
966
1202
|
import { appendFileSync, mkdirSync } from "fs";
|
|
967
1203
|
import { homedir as homedir4 } from "os";
|
|
968
1204
|
import { dirname as dirname2, isAbsolute, join as join5 } from "path";
|
|
969
|
-
import
|
|
1205
|
+
import process16 from "process";
|
|
970
1206
|
|
|
971
1207
|
// ../kit/src/logs.ts
|
|
972
1208
|
import { lstatSync, openSync } from "fs";
|
|
973
1209
|
import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
|
|
974
1210
|
import { homedir as homedir3, tmpdir } from "os";
|
|
975
1211
|
import { join as join4 } from "path";
|
|
976
|
-
import
|
|
1212
|
+
import process15 from "process";
|
|
977
1213
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
978
1214
|
var CLI_FOLDER = "kaynooo-cli";
|
|
979
1215
|
function isPrivateDirectory(path) {
|
|
980
1216
|
try {
|
|
981
1217
|
const info = lstatSync(path, { throwIfNoEntry: false });
|
|
982
|
-
return info !== undefined && info.isDirectory() && info.uid === (
|
|
1218
|
+
return info !== undefined && info.isDirectory() && info.uid === (process15.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
|
|
983
1219
|
} catch {
|
|
984
1220
|
return false;
|
|
985
1221
|
}
|
|
986
1222
|
}
|
|
987
|
-
async function privateLogDirectory(name, env =
|
|
1223
|
+
async function privateLogDirectory(name, env = process15.env) {
|
|
988
1224
|
const runtime = env.XDG_RUNTIME_DIR;
|
|
989
1225
|
const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
|
|
990
1226
|
const path = join4(base, name);
|
|
@@ -1024,14 +1260,14 @@ var usageError;
|
|
|
1024
1260
|
function noteUsageError(message) {
|
|
1025
1261
|
usageError = message;
|
|
1026
1262
|
}
|
|
1027
|
-
function stateHome(env =
|
|
1263
|
+
function stateHome(env = process16.env) {
|
|
1028
1264
|
const dir = env.XDG_STATE_HOME;
|
|
1029
1265
|
return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
|
|
1030
1266
|
}
|
|
1031
|
-
function usagePath(env =
|
|
1267
|
+
function usagePath(env = process16.env) {
|
|
1032
1268
|
return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1033
1269
|
}
|
|
1034
|
-
function usageRecorded(env =
|
|
1270
|
+
function usageRecorded(env = process16.env) {
|
|
1035
1271
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1036
1272
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1037
1273
|
}
|
|
@@ -1040,12 +1276,12 @@ function flagNames(argv) {
|
|
|
1040
1276
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
1041
1277
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
1042
1278
|
}
|
|
1043
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
1279
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
1044
1280
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
1045
1281
|
usageError = undefined;
|
|
1046
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1282
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
1047
1283
|
}
|
|
1048
|
-
function recordUsage(entry, env =
|
|
1284
|
+
function recordUsage(entry, env = process16.env) {
|
|
1049
1285
|
if (!usageRecorded(env))
|
|
1050
1286
|
return;
|
|
1051
1287
|
try {
|
|
@@ -1061,10 +1297,14 @@ var LEVEL_OPTIONS = {
|
|
|
1061
1297
|
...OUTPUT_OPTIONS,
|
|
1062
1298
|
help: { type: "boolean", short: "h", description: "show this help" }
|
|
1063
1299
|
};
|
|
1064
|
-
var TOP_OPTIONS = {
|
|
1300
|
+
var TOP_OPTIONS = {
|
|
1301
|
+
...LEVEL_OPTIONS,
|
|
1302
|
+
version: { type: "boolean", short: "v", description: "print the version" },
|
|
1303
|
+
completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
|
|
1304
|
+
};
|
|
1065
1305
|
function printError(prefix, message, hint, cause) {
|
|
1066
|
-
const colors = paint(
|
|
1067
|
-
const styled = takesControlCodes(
|
|
1306
|
+
const colors = paint(process17.stderr);
|
|
1307
|
+
const styled = takesControlCodes(process17.stderr);
|
|
1068
1308
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1069
1309
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1070
1310
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1141,6 +1381,19 @@ async function leafCandidates(run, words) {
|
|
|
1141
1381
|
const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
|
|
1142
1382
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1143
1383
|
}
|
|
1384
|
+
var COMPLETIONS = "--completions";
|
|
1385
|
+
function flagValue([flag = "", ...rest]) {
|
|
1386
|
+
return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
|
|
1387
|
+
}
|
|
1388
|
+
function printCompletionScript(name, args) {
|
|
1389
|
+
const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
|
|
1390
|
+
if (shell === undefined || args.length !== 1) {
|
|
1391
|
+
printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
|
|
1392
|
+
return 2;
|
|
1393
|
+
}
|
|
1394
|
+
console.log(completionScript(shell, [name]).trimEnd());
|
|
1395
|
+
return 0;
|
|
1396
|
+
}
|
|
1144
1397
|
async function printCandidates(found) {
|
|
1145
1398
|
for (const line of await found)
|
|
1146
1399
|
console.log(line);
|
|
@@ -1162,8 +1415,13 @@ function packageVersion(entry = Bun.main) {
|
|
|
1162
1415
|
}
|
|
1163
1416
|
}
|
|
1164
1417
|
async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
|
|
1418
|
+
const answered = await askpassClient(argv);
|
|
1419
|
+
if (answered !== undefined)
|
|
1420
|
+
return answered;
|
|
1165
1421
|
if (argv[0] === COMPLETE)
|
|
1166
1422
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1423
|
+
if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
|
|
1424
|
+
return printCompletionScript(name, flagValue(argv));
|
|
1167
1425
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
1168
1426
|
console.log(version ?? packageVersion());
|
|
1169
1427
|
return 0;
|
|
@@ -1178,12 +1436,17 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
|
|
|
1178
1436
|
notifyEnd(name, code, performance.now() - started);
|
|
1179
1437
|
if (usage !== false) {
|
|
1180
1438
|
try {
|
|
1181
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
1439
|
+
recordUsage(usageEntry(name, undefined, argv, code, { ms: performance.now() - started }));
|
|
1182
1440
|
} catch {}
|
|
1183
1441
|
}
|
|
1184
1442
|
return code;
|
|
1185
1443
|
}
|
|
1444
|
+
|
|
1445
|
+
// ../kit/src/index.ts
|
|
1446
|
+
init_config();
|
|
1447
|
+
|
|
1186
1448
|
// ../kit/src/excerpt.ts
|
|
1449
|
+
init_text2();
|
|
1187
1450
|
var BASH_ECHO = /^\$ /;
|
|
1188
1451
|
var DURATION2 = / \[[\d.]+m?s\]$/;
|
|
1189
1452
|
var BOUNDARY = /^(?:\((?:pass|fail|skip|todo)\) |\S+\.test\.[jt]sx?:$)/;
|
|
@@ -1338,32 +1601,48 @@ function failureExcerpt(output) {
|
|
|
1338
1601
|
return cut(squeeze(recognised(lines, PARSERS) ?? lines.slice(-TAIL)));
|
|
1339
1602
|
}
|
|
1340
1603
|
var LOG_PATTERNS = { BASH_ECHO, DURATION: DURATION2, BOUNDARY, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_CONTINUATION, TSC_FRAME, TSC_SUMMARY, ESLINT_PROBLEM, ESLINT_SUMMARY };
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1604
|
+
|
|
1605
|
+
// ../kit/src/index.ts
|
|
1606
|
+
init_folders();
|
|
1607
|
+
init_format();
|
|
1608
|
+
|
|
1609
|
+
// ../kit/src/git.ts
|
|
1610
|
+
init_args();
|
|
1611
|
+
// ../kit/src/limit.ts
|
|
1612
|
+
init_args();
|
|
1613
|
+
|
|
1614
|
+
// ../kit/src/index.ts
|
|
1615
|
+
init_mode();
|
|
1616
|
+
|
|
1617
|
+
// ../kit/src/report.ts
|
|
1618
|
+
init_style();
|
|
1619
|
+
init_text2();
|
|
1354
1620
|
// ../kit/src/secrets.ts
|
|
1355
1621
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1356
1622
|
// ../kit/src/sessions.ts
|
|
1357
1623
|
var {Glob } = globalThis.Bun;
|
|
1358
1624
|
var SESSION_FILES = new Glob("*.json");
|
|
1359
1625
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1626
|
+
|
|
1627
|
+
// ../kit/src/index.ts
|
|
1628
|
+
init_style();
|
|
1629
|
+
init_text2();
|
|
1630
|
+
init_theme();
|
|
1631
|
+
init_user_config();
|
|
1632
|
+
|
|
1633
|
+
// ../kit/src/watch.ts
|
|
1634
|
+
init_args();
|
|
1635
|
+
init_input();
|
|
1636
|
+
init_style();
|
|
1637
|
+
// ../kit/src/workspace-root.ts
|
|
1638
|
+
init_user_config();
|
|
1360
1639
|
// package.json
|
|
1361
|
-
var version = "0.
|
|
1640
|
+
var version = "0.21.1";
|
|
1362
1641
|
|
|
1363
1642
|
// src/check.ts
|
|
1364
1643
|
import { writeFile as writeFile3 } from "fs/promises";
|
|
1365
1644
|
import { basename as basename4, join as join14 } from "path";
|
|
1366
|
-
import
|
|
1645
|
+
import process23 from "process";
|
|
1367
1646
|
|
|
1368
1647
|
// ../kit/src/shell.ts
|
|
1369
1648
|
var SEPARATORS = new Set([`
|
|
@@ -1416,7 +1695,7 @@ function shellQuote(word) {
|
|
|
1416
1695
|
import { existsSync as existsSync4 } from "fs";
|
|
1417
1696
|
import { homedir as homedir6 } from "os";
|
|
1418
1697
|
import { basename, dirname as dirname4, join as join8, relative, resolve as resolve4 } from "path";
|
|
1419
|
-
import
|
|
1698
|
+
import process20 from "process";
|
|
1420
1699
|
var COMPOSE_FILES = ["compose.yaml", "compose.yml", "docker-compose.yaml", "docker-compose.yml"];
|
|
1421
1700
|
var OVERRIDE_FILES = ["compose.override.yaml", "compose.override.yml", "docker-compose.override.yaml", "docker-compose.override.yml"];
|
|
1422
1701
|
var PS_TIMEOUT_MS = 20000;
|
|
@@ -1460,7 +1739,7 @@ async function variables(composeDir) {
|
|
|
1460
1739
|
if (match !== null && !line.trimStart().startsWith("#"))
|
|
1461
1740
|
env[match[1] ?? ""] = (match[2] ?? "").trim().replace(QUOTED, "$2");
|
|
1462
1741
|
}
|
|
1463
|
-
for (const [key, value] of Object.entries(
|
|
1742
|
+
for (const [key, value] of Object.entries(process20.env)) {
|
|
1464
1743
|
if (value !== undefined)
|
|
1465
1744
|
env[key] = value;
|
|
1466
1745
|
}
|
|
@@ -1596,7 +1875,7 @@ async function place(dir, program, { service, host } = {}) {
|
|
|
1596
1875
|
fail(`--in ${service}: no compose project mounts ${dir}`);
|
|
1597
1876
|
return;
|
|
1598
1877
|
}
|
|
1599
|
-
if (Bun.which("docker", { PATH:
|
|
1878
|
+
if (Bun.which("docker", { PATH: process20.env.PATH ?? "" }) === null) {
|
|
1600
1879
|
if (service !== undefined)
|
|
1601
1880
|
fail(`--in ${service}: docker not found`);
|
|
1602
1881
|
if (!noticed.has(found.composeDir)) {
|
|
@@ -1648,7 +1927,7 @@ class Stack {
|
|
|
1648
1927
|
}
|
|
1649
1928
|
static async running(composeDir) {
|
|
1650
1929
|
try {
|
|
1651
|
-
const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env:
|
|
1930
|
+
const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process20.env, timeoutMs: PS_TIMEOUT_MS });
|
|
1652
1931
|
if (ran.code !== 0)
|
|
1653
1932
|
return `docker compose ps failed in ${composeDir}: ${ran.text.trim().split(`
|
|
1654
1933
|
`).at(-1) ?? `exit ${ran.code}`}`;
|
|
@@ -1683,7 +1962,7 @@ function placeSettings(values) {
|
|
|
1683
1962
|
import { existsSync as existsSync5, statSync as statSync2 } from "fs";
|
|
1684
1963
|
import { rename, writeFile as writeFile2 } from "fs/promises";
|
|
1685
1964
|
import { join as join12 } from "path";
|
|
1686
|
-
import
|
|
1965
|
+
import process22 from "process";
|
|
1687
1966
|
|
|
1688
1967
|
// src/changes.ts
|
|
1689
1968
|
import { stat as stat2 } from "fs/promises";
|
|
@@ -1865,16 +2144,13 @@ async function discover(dir) {
|
|
|
1865
2144
|
}
|
|
1866
2145
|
|
|
1867
2146
|
// src/options.ts
|
|
1868
|
-
var
|
|
2147
|
+
var options = {
|
|
1869
2148
|
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" },
|
|
1870
|
-
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
|
|
2149
|
+
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] },
|
|
1871
2150
|
timeout: { type: "string", short: "t", description: "longest a step or fixer may run before it is ended (30s, 5m, 1h), none by default" },
|
|
1872
2151
|
...placeOptions,
|
|
1873
|
-
json: jsonOption()
|
|
1874
|
-
}
|
|
1875
|
-
var options = {
|
|
1876
|
-
...fixOptions,
|
|
1877
|
-
fix: { type: "boolean", short: "f", description: "run the folder's fixers and formatters instead of the steps, as the fix bin does" },
|
|
2152
|
+
json: jsonOption("[{name, command, in?, ok, ms, log, failed?}], with --list [{name, command, source, in?}], with --fix {fixers, changed}"),
|
|
2153
|
+
fix: { type: "boolean", short: "f", description: "run the folder's fixers and formatters instead of the steps" },
|
|
1878
2154
|
quiet: { type: "boolean", short: "q", description: "print nothing for a passing step, and nothing at all when every step passes" },
|
|
1879
2155
|
failed: { type: "boolean", description: "run only the steps that failed in the last run of this folder, read from the run folder" },
|
|
1880
2156
|
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" },
|
|
@@ -1898,14 +2174,14 @@ function pick(steps, only, noun = "step") {
|
|
|
1898
2174
|
// src/run.ts
|
|
1899
2175
|
import { mkdir as mkdir2, readdir as readdir3, stat as stat3, writeFile } from "fs/promises";
|
|
1900
2176
|
import { basename as basename2, join as join11 } from "path";
|
|
1901
|
-
import
|
|
2177
|
+
import process21 from "process";
|
|
1902
2178
|
var LOG_MAX_AGE_MS = 3 * 24 * 60 * 60 * 1000;
|
|
1903
2179
|
var RESULTS_FILE = "results.json";
|
|
1904
2180
|
var runPrefix = (cwd) => `${basename2(cwd)}-${Bun.hash(cwd).toString(36)}-`;
|
|
1905
2181
|
async function logDirectory(cwd) {
|
|
1906
2182
|
const root = await privateLogDirectory("check");
|
|
1907
2183
|
await sweepLogs(root, LOG_MAX_AGE_MS);
|
|
1908
|
-
const path = join11(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${
|
|
2184
|
+
const path = join11(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process21.pid}`);
|
|
1909
2185
|
await mkdir2(path, { mode: 448 });
|
|
1910
2186
|
return path;
|
|
1911
2187
|
}
|
|
@@ -1933,7 +2209,7 @@ async function lastFailed(cwd) {
|
|
|
1933
2209
|
async function saveLog(output) {
|
|
1934
2210
|
const root = await privateLogDirectory("errs");
|
|
1935
2211
|
await sweepLogs(root);
|
|
1936
|
-
const path = join11(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${
|
|
2212
|
+
const path = join11(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process21.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
|
|
1937
2213
|
await writeFile(path, output, { mode: 384, flag: "wx" });
|
|
1938
2214
|
return path;
|
|
1939
2215
|
}
|
|
@@ -1941,7 +2217,7 @@ async function runStep(command, cwd, logFile, { env = {}, timeoutMs, held } = {}
|
|
|
1941
2217
|
const started = Date.now();
|
|
1942
2218
|
const { code, text, timedOut } = await runCommand(["sh", "-c", `${command} 2>&1`], {
|
|
1943
2219
|
cwd,
|
|
1944
|
-
env: { ...
|
|
2220
|
+
env: { ...process21.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
|
|
1945
2221
|
...timeoutMs === undefined ? {} : { timeoutMs },
|
|
1946
2222
|
...held === undefined ? {} : { onStart: (child) => held.forward(child) }
|
|
1947
2223
|
});
|
|
@@ -1957,8 +2233,8 @@ function outcomeJson(name, command, logFile, outcome, service) {
|
|
|
1957
2233
|
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) } };
|
|
1958
2234
|
}
|
|
1959
2235
|
function printOutcome(name, width, command, logFile, outcome) {
|
|
1960
|
-
const colors = paint(
|
|
1961
|
-
const path = role("path",
|
|
2236
|
+
const colors = paint(process21.stdout);
|
|
2237
|
+
const path = role("path", process21.stdout);
|
|
1962
2238
|
const took = colors.dim(formatDuration(outcome.ms));
|
|
1963
2239
|
if (outcome.ok) {
|
|
1964
2240
|
console.log(`${colors.bold(colors.green("ok "))} ${name.padEnd(width)} ${took} ${path(logFile)}`);
|
|
@@ -1974,27 +2250,18 @@ function printOutcome(name, width, command, logFile, outcome) {
|
|
|
1974
2250
|
}
|
|
1975
2251
|
|
|
1976
2252
|
// src/fix.ts
|
|
1977
|
-
var fixUsage = `fix [--only <fixers>] [--timeout <duration>] [--in <service> | --host] [--list]
|
|
1978
|
-
|
|
1979
|
-
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.
|
|
1980
|
-
It looks at the folder itself only, so each package of a monorepo gets its own run.
|
|
1981
|
-
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.
|
|
1982
|
-
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.
|
|
1983
|
-
A fixer still running after --timeout is ended with everything it started, but not what it started inside a container.
|
|
1984
|
-
--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.`;
|
|
1985
|
-
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"]];
|
|
1986
2253
|
var RUNNING = "KAYNOOO_CLI_FIX";
|
|
1987
2254
|
var JUSTFILES2 = ["justfile", "Justfile", ".justfile"];
|
|
1988
2255
|
var RUFF_CONFIGS = ["ruff.toml", ".ruff.toml"];
|
|
1989
2256
|
var RUFF_SECTION = /^\[tool\.ruff/m;
|
|
1990
2257
|
var MAX_CHANGED = 30;
|
|
1991
2258
|
async function replaceFile(path, content) {
|
|
1992
|
-
const temporary = `${path}.${
|
|
2259
|
+
const temporary = `${path}.${process22.pid}.tmp`;
|
|
1993
2260
|
await writeFile2(temporary, content, { mode: statSync2(path).mode & 511 });
|
|
1994
2261
|
await rename(temporary, path);
|
|
1995
2262
|
}
|
|
1996
2263
|
async function projectFixers(dir) {
|
|
1997
|
-
const found = await candidates(dir, "
|
|
2264
|
+
const found = await candidates(dir, "check");
|
|
1998
2265
|
const named = (name) => found.find((step) => step.name === name);
|
|
1999
2266
|
const all = named("fix");
|
|
2000
2267
|
if (all !== undefined)
|
|
@@ -2061,15 +2328,11 @@ function printChanged(changed) {
|
|
|
2061
2328
|
if (changed.length > MAX_CHANGED)
|
|
2062
2329
|
console.log(` and ${changed.length - MAX_CHANGED} more`);
|
|
2063
2330
|
}
|
|
2064
|
-
async function fix(args, cwd = process21.cwd()) {
|
|
2065
|
-
const parsed = parse(args, fixUsage, fixOptions, { 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"]] });
|
|
2066
|
-
return runFixers(parsed.values, cwd);
|
|
2067
|
-
}
|
|
2068
2331
|
async function runFixers(values, cwd) {
|
|
2069
2332
|
const parsed = { values };
|
|
2070
2333
|
const settings = placeSettings(values);
|
|
2071
|
-
if (
|
|
2072
|
-
fail("a fixer called fix again, which would recurse: give its script another command");
|
|
2334
|
+
if (process22.env[RUNNING] !== undefined)
|
|
2335
|
+
fail("a fixer called check --fix again, which would recurse: give its script another command");
|
|
2073
2336
|
const found = await fixers(cwd);
|
|
2074
2337
|
if (found.length === 0)
|
|
2075
2338
|
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");
|
|
@@ -2102,7 +2365,7 @@ async function runFixers(values, cwd) {
|
|
|
2102
2365
|
break;
|
|
2103
2366
|
if (missing(fixer)) {
|
|
2104
2367
|
if (!json)
|
|
2105
|
-
console.log(`${paint(
|
|
2368
|
+
console.log(`${paint(process22.stdout).yellow("skip ")} ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
|
|
2106
2369
|
ran.push({ name: fixer.name, command: fixer.command, skipped: `${fixer.requires} is not installed` });
|
|
2107
2370
|
continue;
|
|
2108
2371
|
}
|
|
@@ -2212,19 +2475,11 @@ async function scriptText(dir, name) {
|
|
|
2212
2475
|
var usage2 = `check [--only <steps>] [--changed] [--failed] [--quiet] [--timeout <duration>] [--slot | --no-slot] [--parallel] [--in <service> | --host] [--list]
|
|
2213
2476
|
check --fix [--only <fixers>] [--timeout <duration>] [--in <service> | --host] [--list]
|
|
2214
2477
|
|
|
2215
|
-
Runs the repo's check, typecheck, lint and test steps,
|
|
2216
|
-
A
|
|
2217
|
-
A step
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
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.
|
|
2221
|
-
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.
|
|
2222
|
-
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.
|
|
2223
|
-
A step still running after --timeout is ended with everything it started, but not what it started inside a container.
|
|
2224
|
-
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.
|
|
2225
|
-
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.
|
|
2226
|
-
--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.`;
|
|
2227
|
-
var EXITS2 = [[0, "every step passed"], [1, "one failed"], [2, "bad usage, no step is found or a step timed out"]];
|
|
2478
|
+
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/).
|
|
2479
|
+
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.
|
|
2480
|
+
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.
|
|
2481
|
+
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.`;
|
|
2482
|
+
var EXITS = [[0, "every step passed"], [1, "one failed"], [2, "bad usage, no step is found or a step timed out"]];
|
|
2228
2483
|
function slotted(command) {
|
|
2229
2484
|
return `slot -- sh -c ${shellQuote(command)}`;
|
|
2230
2485
|
}
|
|
@@ -2253,14 +2508,14 @@ function launch(step) {
|
|
|
2253
2508
|
return step.placement === undefined ? step.command : shellIn(step.placement, step.command);
|
|
2254
2509
|
}
|
|
2255
2510
|
function summaryLine(outcomes) {
|
|
2256
|
-
const colors = paint(
|
|
2511
|
+
const colors = paint(process23.stdout);
|
|
2257
2512
|
const failed = outcomes.filter((outcome) => !outcome.ok).length;
|
|
2258
2513
|
const passed = outcomes.length - failed;
|
|
2259
2514
|
const parts = [colors.green(`${passed} passed`), ...failed === 0 ? [] : [colors.red(`${failed} failed`)], colors.dim(formatDuration(outcomes.reduce((sum, outcome) => sum + outcome.ms, 0)))];
|
|
2260
2515
|
return parts.join(colors.dim(" \xB7 "));
|
|
2261
2516
|
}
|
|
2262
|
-
async function check(args, cwd =
|
|
2263
|
-
const parsed = parse(args, usage2, options, { exits:
|
|
2517
|
+
async function check(args, cwd = process23.cwd()) {
|
|
2518
|
+
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"]] });
|
|
2264
2519
|
const settings = placeSettings(parsed.values);
|
|
2265
2520
|
if (parsed.values.fix === true) {
|
|
2266
2521
|
for (const flag of ["changed", "failed", "slot", "no-slot", "parallel"]) {
|
|
@@ -2272,7 +2527,7 @@ async function check(args, cwd = process22.cwd()) {
|
|
|
2272
2527
|
const timeoutMs = parsed.values.timeout === undefined ? undefined : duration(parsed.values.timeout, "timeout", 0);
|
|
2273
2528
|
if (parsed.values.slot === true && parsed.values["no-slot"] === true)
|
|
2274
2529
|
fail("--slot and --no-slot exclude each other");
|
|
2275
|
-
const hasSlot = Bun.which("slot", { PATH:
|
|
2530
|
+
const hasSlot = Bun.which("slot", { PATH: process23.env.PATH ?? "" }) !== null;
|
|
2276
2531
|
if (parsed.values.slot === true && !hasSlot)
|
|
2277
2532
|
fail("--slot needs the slot bin: bun install -g @kaynooo/cli-wait");
|
|
2278
2533
|
const slotting = parsed.values["no-slot"] !== true && hasSlot;
|
|
@@ -2305,7 +2560,7 @@ async function check(args, cwd = process22.cwd()) {
|
|
|
2305
2560
|
const width = Math.max(...steps.map((step) => step.label.length));
|
|
2306
2561
|
const outcomes = [];
|
|
2307
2562
|
const quiet = parsed.values.quiet === true;
|
|
2308
|
-
const heading = json || quiet ? "" : header("check", `${basename4(cwd)} \xB7 ${steps.length} ${steps.length === 1 ? "step" : "steps"}`,
|
|
2563
|
+
const heading = json || quiet ? "" : header("check", `${basename4(cwd)} \xB7 ${steps.length} ${steps.length === 1 ? "step" : "steps"}`, process23.stdout);
|
|
2309
2564
|
if (heading !== "")
|
|
2310
2565
|
console.log(heading);
|
|
2311
2566
|
const execute = async (step, signals) => {
|
|
@@ -2358,4 +2613,4 @@ async function check(args, cwd = process22.cwd()) {
|
|
|
2358
2613
|
}
|
|
2359
2614
|
|
|
2360
2615
|
// src/cli.ts
|
|
2361
|
-
|
|
2616
|
+
process24.exitCode = await runMain({ name: "check", version, run: async (args) => check(args) });
|