@kaynooo/cli-forgejo 0.30.3 → 0.30.5
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 +3 -3
- package/dist/cli.js +986 -249
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -1,21 +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 ct = /[aeiou]y$/;
|
|
15
|
-
var N = new Map;
|
|
16
|
-
var Ot = /(?:leaf|loaf|thief|wolf|half|calf|elf|sheaf|scarf|dwarf|hoof|wharf)$/;
|
|
17
|
-
var Gt = /(?:knife|life|wife)$/;
|
|
18
|
-
function K(t, e, { plural: r, zero: n = "singular" } = {}) {
|
|
15
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rkhsft4a.js
|
|
16
|
+
function G(t, e, { plural: r, zero: n = "singular" } = {}) {
|
|
19
17
|
if (e === 1 || e === 0 && n === "singular")
|
|
20
18
|
return t;
|
|
21
19
|
if (r !== undefined)
|
|
@@ -28,12 +26,10 @@ function K(t, e, { plural: r, zero: n = "singular" } = {}) {
|
|
|
28
26
|
return `${t.slice(0, -1)}ves`;
|
|
29
27
|
return Gt.test(t) ? `${t.slice(0, -2)}ves` : `${t}s`;
|
|
30
28
|
}
|
|
31
|
-
function
|
|
32
|
-
return `${t} ${
|
|
29
|
+
function bo(t, e, { zero: r = "plural", ...n } = {}) {
|
|
30
|
+
return `${t} ${G(e, t, { ...n, zero: r })}`;
|
|
33
31
|
}
|
|
34
|
-
|
|
35
|
-
var Y = /\s/;
|
|
36
|
-
function ko(t, e, r = "...") {
|
|
32
|
+
function Ao(t, e, r = "...") {
|
|
37
33
|
let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
|
|
38
34
|
if (t.length <= e)
|
|
39
35
|
return t;
|
|
@@ -44,13 +40,25 @@ function ko(t, e, r = "...") {
|
|
|
44
40
|
c = c.trimEnd();
|
|
45
41
|
return s ? (c + n).slice(0, l) : c + n;
|
|
46
42
|
}
|
|
47
|
-
var
|
|
48
|
-
var
|
|
43
|
+
var ct, N, Ot, Gt, Nt, Y, be, W;
|
|
44
|
+
var init_chunk_rkhsft4a = __esm(() => {
|
|
45
|
+
ct = /[aeiou]y$/;
|
|
46
|
+
N = new Map;
|
|
47
|
+
Ot = /(?:leaf|loaf|thief|wolf|half|calf|elf|sheaf|scarf|dwarf|hoof|wharf)$/;
|
|
48
|
+
Gt = /(?:knife|life|wife)$/;
|
|
49
|
+
Nt = /\s+\S*$/;
|
|
50
|
+
Y = /\s/;
|
|
51
|
+
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));
|
|
52
|
+
W = new Map;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/text.js
|
|
56
|
+
var init_text = __esm(() => {
|
|
57
|
+
init_chunk_rkhsft4a();
|
|
58
|
+
});
|
|
49
59
|
|
|
50
60
|
// ../kit/src/mode.ts
|
|
51
61
|
import process2 from "process";
|
|
52
|
-
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
53
|
-
var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
54
62
|
function isSet(value) {
|
|
55
63
|
return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
56
64
|
}
|
|
@@ -64,12 +72,16 @@ function outputMode(stream = process2.stdout, env = process2.env) {
|
|
|
64
72
|
return "terminal";
|
|
65
73
|
return isSet(env.CI) ? "ci" : "pipe";
|
|
66
74
|
}
|
|
75
|
+
function isInteractive(streams = process2) {
|
|
76
|
+
return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
|
|
77
|
+
}
|
|
78
|
+
var MODES, AGENT_VARIABLES;
|
|
79
|
+
var init_mode = __esm(() => {
|
|
80
|
+
MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
81
|
+
AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
82
|
+
});
|
|
67
83
|
|
|
68
|
-
//
|
|
69
|
-
import process6 from "process";
|
|
70
|
-
|
|
71
|
-
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
72
|
-
var G2 = /^[a-f0-9]+$/i;
|
|
84
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
73
85
|
function b(r) {
|
|
74
86
|
let e = r.startsWith("#") ? r.slice(1) : r;
|
|
75
87
|
if (!G2.test(e))
|
|
@@ -80,11 +92,6 @@ function b(r) {
|
|
|
80
92
|
throw Error(`Invalid hex color length: ${e.length}`);
|
|
81
93
|
return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
|
|
82
94
|
}
|
|
83
|
-
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") => {
|
|
84
|
-
let [l, n, c] = b(r);
|
|
85
|
-
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
86
|
-
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
87
|
-
var h = new Set(["", "1", "2", "3", "true"]);
|
|
88
95
|
function C(r, e = globalThis.process?.env ?? {}) {
|
|
89
96
|
if (e.FORCE_COLOR !== undefined)
|
|
90
97
|
return h.has(e.FORCE_COLOR);
|
|
@@ -98,7 +105,7 @@ function f(r, e = []) {
|
|
|
98
105
|
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
99
106
|
let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
|
|
100
107
|
return new Proxy(c, { get(t, i) {
|
|
101
|
-
let a =
|
|
108
|
+
let a = B[i];
|
|
102
109
|
if (Array.isArray(a)) {
|
|
103
110
|
let s = g.get(i);
|
|
104
111
|
if (s === undefined)
|
|
@@ -121,13 +128,21 @@ function f(r, e = []) {
|
|
|
121
128
|
function Fe(r = {}) {
|
|
122
129
|
return f(r);
|
|
123
130
|
}
|
|
124
|
-
var
|
|
131
|
+
var G2, B, h, o;
|
|
132
|
+
var init_chunk_x450vn3m = __esm(() => {
|
|
133
|
+
G2 = /^[a-f0-9]+$/i;
|
|
134
|
+
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") => {
|
|
135
|
+
let [l, n, c] = b(r);
|
|
136
|
+
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
137
|
+
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
138
|
+
h = new Set(["", "1", "2", "3", "true"]);
|
|
139
|
+
o = Fe();
|
|
140
|
+
});
|
|
125
141
|
|
|
126
|
-
//
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
import process5 from "process";
|
|
142
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/tools/colors.js
|
|
143
|
+
var init_colors = __esm(() => {
|
|
144
|
+
init_chunk_x450vn3m();
|
|
145
|
+
});
|
|
131
146
|
|
|
132
147
|
// ../kit/src/config.ts
|
|
133
148
|
import { existsSync } from "fs";
|
|
@@ -143,6 +158,9 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
143
158
|
return;
|
|
144
159
|
}
|
|
145
160
|
}
|
|
161
|
+
var init_config = __esm(() => {
|
|
162
|
+
init_args();
|
|
163
|
+
});
|
|
146
164
|
|
|
147
165
|
// ../kit/src/user-config.ts
|
|
148
166
|
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
@@ -178,13 +196,17 @@ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
|
|
|
178
196
|
const value = readUserConfig(bin, where, legacy)[key];
|
|
179
197
|
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
|
|
180
198
|
}
|
|
199
|
+
var init_user_config = () => {};
|
|
181
200
|
|
|
182
201
|
// ../kit/src/theme.ts
|
|
202
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
203
|
+
import { homedir as homedir2 } from "os";
|
|
204
|
+
import { join as join3, resolve as resolve2 } from "path";
|
|
205
|
+
import process5 from "process";
|
|
183
206
|
function toLinear(channel) {
|
|
184
207
|
const value = channel / 255;
|
|
185
208
|
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
186
209
|
}
|
|
187
|
-
var fromLinear = (value) => Math.round(255 * Math.min(1, Math.max(0, value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055)));
|
|
188
210
|
function toOklab(hex) {
|
|
189
211
|
const [r, g, b] = [1, 3, 5].map((at) => toLinear(Number.parseInt(hex.slice(at, at + 2), 16)));
|
|
190
212
|
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
@@ -199,7 +221,6 @@ function fromOklab([lightness, a, b]) {
|
|
|
199
221
|
const channels = [4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s];
|
|
200
222
|
return `#${channels.map((channel) => fromLinear(channel).toString(16).padStart(2, "0")).join("")}`;
|
|
201
223
|
}
|
|
202
|
-
var ENDS = new Map;
|
|
203
224
|
function gradientAt(theme, ratio) {
|
|
204
225
|
if (theme.gradient === undefined)
|
|
205
226
|
return;
|
|
@@ -213,33 +234,11 @@ function gradientAt(theme, ratio) {
|
|
|
213
234
|
const [from, to] = ends;
|
|
214
235
|
return fromOklab(from.map((start, index) => start + (to[index] - start) * at));
|
|
215
236
|
}
|
|
216
|
-
var DEFAULT = {
|
|
217
|
-
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" },
|
|
218
|
-
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" },
|
|
219
|
-
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
220
|
-
bins: {},
|
|
221
|
-
gradient: ["#c084fc", "#67e8f9"]
|
|
222
|
-
};
|
|
223
|
-
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" };
|
|
224
|
-
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" };
|
|
225
|
-
var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
|
|
226
|
-
var PRESETS = {
|
|
227
|
-
default: {},
|
|
228
|
-
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
229
|
-
mono: { colors: MONO, accents: ["bold"], gradient: undefined },
|
|
230
|
-
ascii: { glyphs: ASCII }
|
|
231
|
-
};
|
|
232
|
-
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"]);
|
|
233
|
-
var HEX = /^#[0-9a-f]{6}$/i;
|
|
234
|
-
var CONTROL = /\p{Cc}/u;
|
|
235
|
-
var MAX_FILE_BYTES = 64 * 1024;
|
|
236
|
-
var SPACES = /\s+/;
|
|
237
237
|
function isColorSpec(spec) {
|
|
238
238
|
if (typeof spec === "number")
|
|
239
239
|
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
240
240
|
return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
|
|
241
241
|
}
|
|
242
|
-
var CUBE = [0, 95, 135, 175, 215, 255];
|
|
243
242
|
function cubeLevel(channel) {
|
|
244
243
|
return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
|
|
245
244
|
}
|
|
@@ -347,7 +346,6 @@ function applyFile(theme, file, where, warn) {
|
|
|
347
346
|
function endsWalk(home) {
|
|
348
347
|
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
349
348
|
}
|
|
350
|
-
var warned = new Set;
|
|
351
349
|
function warnOnce(message) {
|
|
352
350
|
if (warned.has(message))
|
|
353
351
|
return;
|
|
@@ -384,8 +382,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
|
|
|
384
382
|
}
|
|
385
383
|
return { theme, sources, preset };
|
|
386
384
|
}
|
|
387
|
-
var current;
|
|
388
|
-
var currentKey = "";
|
|
389
385
|
function activeTheme() {
|
|
390
386
|
const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
|
|
391
387
|
if (current === undefined || key !== currentKey) {
|
|
@@ -394,9 +390,38 @@ function activeTheme() {
|
|
|
394
390
|
}
|
|
395
391
|
return current;
|
|
396
392
|
}
|
|
393
|
+
var fromLinear = (value) => Math.round(255 * Math.min(1, Math.max(0, value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055))), ENDS, DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
|
|
394
|
+
var init_theme = __esm(() => {
|
|
395
|
+
init_config();
|
|
396
|
+
init_user_config();
|
|
397
|
+
ENDS = new Map;
|
|
398
|
+
DEFAULT = {
|
|
399
|
+
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" },
|
|
400
|
+
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" },
|
|
401
|
+
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
402
|
+
bins: {},
|
|
403
|
+
gradient: ["#c084fc", "#67e8f9"]
|
|
404
|
+
};
|
|
405
|
+
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" };
|
|
406
|
+
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" };
|
|
407
|
+
ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
|
|
408
|
+
PRESETS = {
|
|
409
|
+
default: {},
|
|
410
|
+
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
411
|
+
mono: { colors: MONO, accents: ["bold"], gradient: undefined },
|
|
412
|
+
ascii: { glyphs: ASCII }
|
|
413
|
+
};
|
|
414
|
+
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"]);
|
|
415
|
+
HEX = /^#[0-9a-f]{6}$/i;
|
|
416
|
+
CONTROL = /\p{Cc}/u;
|
|
417
|
+
MAX_FILE_BYTES = 64 * 1024;
|
|
418
|
+
SPACES = /\s+/;
|
|
419
|
+
CUBE = [0, 95, 135, 175, 215, 255];
|
|
420
|
+
warned = new Set;
|
|
421
|
+
});
|
|
397
422
|
|
|
398
423
|
// ../kit/src/style.ts
|
|
399
|
-
|
|
424
|
+
import process6 from "process";
|
|
400
425
|
function takesControlCodes(stream, env = process6.env) {
|
|
401
426
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
402
427
|
}
|
|
@@ -425,14 +450,6 @@ function role(name, stream, env = process6.env) {
|
|
|
425
450
|
const colors = paint(stream, env);
|
|
426
451
|
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
427
452
|
}
|
|
428
|
-
var STATUS_WORDS = {
|
|
429
|
-
passed: ["passed", "success", "succeeded", "ok"],
|
|
430
|
-
failed: ["failed", "failure", "error", "errored"],
|
|
431
|
-
running: ["running", "in_progress", "started", "holding"],
|
|
432
|
-
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
433
|
-
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
434
|
-
};
|
|
435
|
-
var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
436
453
|
function statusOf(word) {
|
|
437
454
|
return STATUS_OF.get(word.toLowerCase());
|
|
438
455
|
}
|
|
@@ -476,9 +493,24 @@ function section(title, count, stream = process6.stdout, env = process6.env, ton
|
|
|
476
493
|
function hyperlink(text, url, stream, env = process6.env) {
|
|
477
494
|
return takesControlCodes(stream, env) ? paint(stream, env).underline(link(text, url, stream, env)) : text;
|
|
478
495
|
}
|
|
496
|
+
var MARK_WORDS, STATUS_WORDS, STATUS_OF;
|
|
497
|
+
var init_style = __esm(() => {
|
|
498
|
+
init_colors();
|
|
499
|
+
init_mode();
|
|
500
|
+
init_theme();
|
|
501
|
+
MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
|
|
502
|
+
STATUS_WORDS = {
|
|
503
|
+
passed: ["passed", "success", "succeeded", "ok"],
|
|
504
|
+
failed: ["failed", "failure", "error", "errored"],
|
|
505
|
+
running: ["running", "in_progress", "started", "holding"],
|
|
506
|
+
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
507
|
+
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
508
|
+
};
|
|
509
|
+
STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
510
|
+
});
|
|
479
511
|
|
|
480
512
|
// ../kit/src/format.ts
|
|
481
|
-
|
|
513
|
+
import process7 from "process";
|
|
482
514
|
function formatSeconds(total) {
|
|
483
515
|
let rest = Math.max(0, Math.round(total));
|
|
484
516
|
const amounts = UNITS.map(([unit, size]) => {
|
|
@@ -510,10 +542,8 @@ function formatAge(date, now = Date.now()) {
|
|
|
510
542
|
return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
|
|
511
543
|
}
|
|
512
544
|
function truncate(text, width) {
|
|
513
|
-
return
|
|
545
|
+
return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
|
|
514
546
|
}
|
|
515
|
-
var LINE_BREAKS = /\s*\n\s*/g;
|
|
516
|
-
var ESCAPE = String.fromCharCode(27);
|
|
517
547
|
function textWidth(text) {
|
|
518
548
|
return Bun.stringWidth(text);
|
|
519
549
|
}
|
|
@@ -565,14 +595,40 @@ function printJson(value) {
|
|
|
565
595
|
function formatPercent(ratio, digits = 0) {
|
|
566
596
|
return `${(ratio * 100).toFixed(digits)}%`;
|
|
567
597
|
}
|
|
598
|
+
var UNITS, LINE_BREAKS, ESCAPE;
|
|
599
|
+
var init_format = __esm(() => {
|
|
600
|
+
init_text();
|
|
601
|
+
init_mode();
|
|
602
|
+
init_style();
|
|
603
|
+
UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
|
|
604
|
+
LINE_BREAKS = /\s*\n\s*/g;
|
|
605
|
+
ESCAPE = String.fromCharCode(27);
|
|
606
|
+
});
|
|
568
607
|
|
|
569
608
|
// ../kit/src/help.ts
|
|
570
609
|
import process8 from "process";
|
|
571
|
-
var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
572
|
-
var USAGE_PREFIX = /^usage:\s*/i;
|
|
573
|
-
var FULL_STOP = /\.$/;
|
|
574
610
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
575
|
-
|
|
611
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
612
|
+
`);
|
|
613
|
+
const blank = lines.indexOf("");
|
|
614
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
615
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
616
|
+
const colon = synopses[0].indexOf(": ");
|
|
617
|
+
const inline = synopses[0].slice(colon + 2);
|
|
618
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
619
|
+
if (colon !== -1)
|
|
620
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
621
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
622
|
+
`)}`;
|
|
623
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
624
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
625
|
+
return [head, ...lead, ...rest].join(`
|
|
626
|
+
`);
|
|
627
|
+
}
|
|
628
|
+
function prose(line, colors) {
|
|
629
|
+
if (colors.cyan("x") === "x")
|
|
630
|
+
return line;
|
|
631
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
576
632
|
}
|
|
577
633
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
578
634
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -607,7 +663,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
|
607
663
|
return [];
|
|
608
664
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
609
665
|
}
|
|
610
|
-
var MAX_INLINE_CHOICES = 24;
|
|
611
666
|
function optionRows(options, colors = paint(process8.stdout)) {
|
|
612
667
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
613
668
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
@@ -622,9 +677,17 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
622
677
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
623
678
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
624
679
|
}
|
|
680
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
681
|
+
var init_help = __esm(() => {
|
|
682
|
+
init_mode();
|
|
683
|
+
init_style();
|
|
684
|
+
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
685
|
+
USAGE_PREFIX = /^usage:\s*/i;
|
|
686
|
+
FULL_STOP = /\.$/;
|
|
687
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
688
|
+
});
|
|
625
689
|
|
|
626
690
|
// ../kit/src/text.ts
|
|
627
|
-
var ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
|
|
628
691
|
function stripAnsi(text) {
|
|
629
692
|
return text.replace(ANSI, "");
|
|
630
693
|
}
|
|
@@ -653,9 +716,13 @@ function closest(name, names) {
|
|
|
653
716
|
const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
|
|
654
717
|
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
655
718
|
}
|
|
719
|
+
var ANSI;
|
|
720
|
+
var init_text2 = __esm(() => {
|
|
721
|
+
ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
|
|
722
|
+
});
|
|
723
|
+
|
|
656
724
|
// ../kit/src/input.ts
|
|
657
725
|
import process9 from "process";
|
|
658
|
-
var WHOLE = /^\d+$/;
|
|
659
726
|
function wholeNumber(value, name, fallback, min = 1) {
|
|
660
727
|
if (value === undefined)
|
|
661
728
|
return fallback;
|
|
@@ -664,8 +731,6 @@ function wholeNumber(value, name, fallback, min = 1) {
|
|
|
664
731
|
badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
|
|
665
732
|
return number;
|
|
666
733
|
}
|
|
667
|
-
var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
668
|
-
var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
669
734
|
function duration(value, name, fallback, unit = "s") {
|
|
670
735
|
if (value === undefined)
|
|
671
736
|
return fallback;
|
|
@@ -686,44 +751,30 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
|
686
751
|
fail(`no file ${path}`);
|
|
687
752
|
return file.text();
|
|
688
753
|
}
|
|
754
|
+
var WHOLE, DURATION, UNIT_MS;
|
|
755
|
+
var init_input = __esm(() => {
|
|
756
|
+
init_args();
|
|
757
|
+
WHOLE = /^\d+$/;
|
|
758
|
+
DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
759
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
760
|
+
});
|
|
689
761
|
|
|
690
762
|
// ../kit/src/args.ts
|
|
691
|
-
|
|
763
|
+
import process10 from "process";
|
|
764
|
+
import { parseArgs } from "util";
|
|
692
765
|
function jsonOption(holds) {
|
|
693
766
|
return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
|
|
694
767
|
}
|
|
695
768
|
function copyOption(what) {
|
|
696
769
|
return { type: "boolean", description: `also copy ${what} to the clipboard` };
|
|
697
770
|
}
|
|
698
|
-
|
|
699
|
-
class Exit extends Error {
|
|
700
|
-
code;
|
|
701
|
-
hint;
|
|
702
|
-
constructor(message, code, hint) {
|
|
703
|
-
super(message);
|
|
704
|
-
this.code = code;
|
|
705
|
-
this.hint = hint;
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
771
|
function fail(message, code = 2, hint) {
|
|
709
772
|
throw new Exit(message, code, hint);
|
|
710
773
|
}
|
|
711
|
-
|
|
712
|
-
class UsageError extends Exit {
|
|
713
|
-
constructor(message, hint) {
|
|
714
|
-
super(message, 2, hint);
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
774
|
function badUsage(message) {
|
|
718
775
|
throw new UsageError(message);
|
|
719
776
|
}
|
|
720
777
|
|
|
721
|
-
class HelpShown extends Exit {
|
|
722
|
-
constructor() {
|
|
723
|
-
super("help shown", 0);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
778
|
class Completing {
|
|
728
779
|
options;
|
|
729
780
|
positionals;
|
|
@@ -734,11 +785,6 @@ class Completing {
|
|
|
734
785
|
this.candidates = candidates;
|
|
735
786
|
}
|
|
736
787
|
}
|
|
737
|
-
var completion = { active: false };
|
|
738
|
-
var OUTPUT_OPTIONS = {
|
|
739
|
-
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
740
|
-
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
741
|
-
};
|
|
742
788
|
function applyOutput(color, plain, env = process10.env) {
|
|
743
789
|
const when = plain === true ? "never" : color ?? "auto";
|
|
744
790
|
if (when === "auto")
|
|
@@ -892,7 +938,6 @@ function parseError(error) {
|
|
|
892
938
|
const message = upTo(error instanceof Error ? error.message : String(error), ". ");
|
|
893
939
|
return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
|
|
894
940
|
}
|
|
895
|
-
var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
896
941
|
function nearestOption(message, options, allowNegative) {
|
|
897
942
|
const typed = UNKNOWN_OPTION.exec(message)?.[1];
|
|
898
943
|
if (typed === undefined)
|
|
@@ -908,6 +953,495 @@ function nearestOption(message, options, allowNegative) {
|
|
|
908
953
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
909
954
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
910
955
|
}
|
|
956
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
957
|
+
var init_args = __esm(() => {
|
|
958
|
+
init_format();
|
|
959
|
+
init_help();
|
|
960
|
+
init_text2();
|
|
961
|
+
init_help();
|
|
962
|
+
init_input();
|
|
963
|
+
DASHES = /^-+/;
|
|
964
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
965
|
+
Exit = class Exit extends Error {
|
|
966
|
+
code;
|
|
967
|
+
hint;
|
|
968
|
+
[EXIT] = true;
|
|
969
|
+
constructor(message, code, hint) {
|
|
970
|
+
super(message);
|
|
971
|
+
this.code = code;
|
|
972
|
+
this.hint = hint;
|
|
973
|
+
}
|
|
974
|
+
static [Symbol.hasInstance](value) {
|
|
975
|
+
if (this !== Exit)
|
|
976
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
977
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
UsageError = class UsageError extends Exit {
|
|
981
|
+
constructor(message, hint) {
|
|
982
|
+
super(message, 2, hint);
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
HelpShown = class HelpShown extends Exit {
|
|
986
|
+
constructor() {
|
|
987
|
+
super("help shown", 0);
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
completion = { active: false };
|
|
991
|
+
OUTPUT_OPTIONS = {
|
|
992
|
+
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
993
|
+
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
994
|
+
};
|
|
995
|
+
UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
996
|
+
});
|
|
997
|
+
|
|
998
|
+
// ../kit/src/folders.ts
|
|
999
|
+
import { homedir as homedir3 } from "os";
|
|
1000
|
+
import { join as join4 } from "path";
|
|
1001
|
+
import process16 from "process";
|
|
1002
|
+
function cacheFolder({ home = homedir3(), env = process16.env } = {}) {
|
|
1003
|
+
return env.XDG_CACHE_HOME ?? join4(home, ".cache");
|
|
1004
|
+
}
|
|
1005
|
+
var SKIPPED_FOLDERS;
|
|
1006
|
+
var init_folders = __esm(() => {
|
|
1007
|
+
init_user_config();
|
|
1008
|
+
SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1009
|
+
});
|
|
1010
|
+
|
|
1011
|
+
// ../kit/src/answers.ts
|
|
1012
|
+
import { mkdirSync, readFileSync as readFileSync4, writeFileSync } from "fs";
|
|
1013
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
1014
|
+
function answersFile() {
|
|
1015
|
+
return join5(cacheFolder(), "kaynooo-cli", "answers.json");
|
|
1016
|
+
}
|
|
1017
|
+
function stored() {
|
|
1018
|
+
try {
|
|
1019
|
+
const parsed = JSON.parse(readFileSync4(answersFile(), "utf-8"));
|
|
1020
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
1021
|
+
return {};
|
|
1022
|
+
return Object.fromEntries(Object.entries(parsed).filter((entry) => Array.isArray(entry[1]) && entry[1].every((answer) => typeof answer === "string")));
|
|
1023
|
+
} catch {
|
|
1024
|
+
return {};
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
function earlierAnswers(key) {
|
|
1028
|
+
return stored()[key] ?? [];
|
|
1029
|
+
}
|
|
1030
|
+
function rememberAnswer(key, answer) {
|
|
1031
|
+
const all = stored();
|
|
1032
|
+
const file = answersFile();
|
|
1033
|
+
all[key] = [answer, ...(all[key] ?? []).filter((earlier) => earlier !== answer)].slice(0, KEPT);
|
|
1034
|
+
try {
|
|
1035
|
+
mkdirSync(dirname2(file), { recursive: true });
|
|
1036
|
+
writeFileSync(file, JSON.stringify(all));
|
|
1037
|
+
} catch {}
|
|
1038
|
+
}
|
|
1039
|
+
var KEPT = 50;
|
|
1040
|
+
var init_answers = __esm(() => {
|
|
1041
|
+
init_folders();
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
// ../kit/src/job.ts
|
|
1045
|
+
import process17 from "process";
|
|
1046
|
+
function stopJob() {
|
|
1047
|
+
process17.kill(0, "SIGTSTP");
|
|
1048
|
+
}
|
|
1049
|
+
var init_job = () => {};
|
|
1050
|
+
|
|
1051
|
+
// ../kit/src/picker/line.ts
|
|
1052
|
+
function isEditKey(key) {
|
|
1053
|
+
return EDIT_KEYS.has(key);
|
|
1054
|
+
}
|
|
1055
|
+
function endsKills(key) {
|
|
1056
|
+
return typeof key !== "object" && !isEditKey(key);
|
|
1057
|
+
}
|
|
1058
|
+
function isWord(char) {
|
|
1059
|
+
return char !== undefined && WORD_CHARACTER.test(char);
|
|
1060
|
+
}
|
|
1061
|
+
function wordStart(chars, from) {
|
|
1062
|
+
let at = from;
|
|
1063
|
+
while (at > 0 && !isWord(chars[at - 1]))
|
|
1064
|
+
at--;
|
|
1065
|
+
while (at > 0 && isWord(chars[at - 1]))
|
|
1066
|
+
at--;
|
|
1067
|
+
return at;
|
|
1068
|
+
}
|
|
1069
|
+
function wordEnd(chars, from) {
|
|
1070
|
+
let at = from;
|
|
1071
|
+
while (at < chars.length && !isWord(chars[at]))
|
|
1072
|
+
at++;
|
|
1073
|
+
while (at < chars.length && isWord(chars[at]))
|
|
1074
|
+
at++;
|
|
1075
|
+
return at;
|
|
1076
|
+
}
|
|
1077
|
+
function spacedStart(chars, from) {
|
|
1078
|
+
let at = from;
|
|
1079
|
+
while (at > 0 && SPACE.test(chars[at - 1] ?? ""))
|
|
1080
|
+
at--;
|
|
1081
|
+
while (at > 0 && !SPACE.test(chars[at - 1] ?? ""))
|
|
1082
|
+
at--;
|
|
1083
|
+
return at;
|
|
1084
|
+
}
|
|
1085
|
+
function cut(chars, from, to) {
|
|
1086
|
+
return { text: [...chars.slice(0, from), ...chars.slice(to)].join(""), caret: from };
|
|
1087
|
+
}
|
|
1088
|
+
function insert(chars, at, text) {
|
|
1089
|
+
const typed = [...text];
|
|
1090
|
+
return { text: [...chars.slice(0, at), ...typed, ...chars.slice(at)].join(""), caret: at + typed.length };
|
|
1091
|
+
}
|
|
1092
|
+
function editLine(line, key) {
|
|
1093
|
+
const { killed = "", chained = false } = line;
|
|
1094
|
+
const chars = [...line.text];
|
|
1095
|
+
const at = Math.min(Math.max(line.caret, 0), chars.length);
|
|
1096
|
+
const edited = edit(chars, at, key, killed);
|
|
1097
|
+
if (typeof key === "object" || !BACKWARD_KILLS.has(key) && !FORWARD_KILLS.has(key))
|
|
1098
|
+
return line.killed === undefined ? edited : { ...edited, killed };
|
|
1099
|
+
const taken = chars.slice(edited.caret, edited.caret + chars.length - [...edited.text].length).join("");
|
|
1100
|
+
if (taken === "")
|
|
1101
|
+
return { ...edited, killed, chained };
|
|
1102
|
+
if (!chained)
|
|
1103
|
+
return { ...edited, killed: taken, chained: true };
|
|
1104
|
+
return { ...edited, killed: BACKWARD_KILLS.has(key) ? taken + killed : killed + taken, chained: true };
|
|
1105
|
+
}
|
|
1106
|
+
function edit(chars, at, key, killed) {
|
|
1107
|
+
const text = chars.join("");
|
|
1108
|
+
if (typeof key === "object")
|
|
1109
|
+
return insert(chars, at, key.text);
|
|
1110
|
+
switch (key) {
|
|
1111
|
+
case "left":
|
|
1112
|
+
return { text, caret: Math.max(at - 1, 0) };
|
|
1113
|
+
case "right":
|
|
1114
|
+
return { text, caret: Math.min(at + 1, chars.length) };
|
|
1115
|
+
case "wordleft":
|
|
1116
|
+
return { text, caret: wordStart(chars, at) };
|
|
1117
|
+
case "wordright":
|
|
1118
|
+
return { text, caret: wordEnd(chars, at) };
|
|
1119
|
+
case "linestart":
|
|
1120
|
+
return { text, caret: 0 };
|
|
1121
|
+
case "lineend":
|
|
1122
|
+
return { text, caret: chars.length };
|
|
1123
|
+
case "erase":
|
|
1124
|
+
return cut(chars, Math.max(at - 1, 0), at);
|
|
1125
|
+
case "delete":
|
|
1126
|
+
return cut(chars, at, Math.min(at + 1, chars.length));
|
|
1127
|
+
case "word":
|
|
1128
|
+
return cut(chars, spacedStart(chars, at), at);
|
|
1129
|
+
case "killword":
|
|
1130
|
+
return cut(chars, wordStart(chars, at), at);
|
|
1131
|
+
case "killnext":
|
|
1132
|
+
return cut(chars, at, wordEnd(chars, at));
|
|
1133
|
+
case "clear":
|
|
1134
|
+
return cut(chars, 0, at);
|
|
1135
|
+
case "killend":
|
|
1136
|
+
return cut(chars, at, chars.length);
|
|
1137
|
+
case "yank":
|
|
1138
|
+
return insert(chars, at, killed);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
function visible({ text, caret }, room) {
|
|
1142
|
+
const chars = [...text];
|
|
1143
|
+
const at = Math.min(Math.max(caret, 0), chars.length);
|
|
1144
|
+
const cells = at === chars.length ? [...chars, " "] : chars;
|
|
1145
|
+
const widths = cells.map((char) => Bun.stringWidth(char));
|
|
1146
|
+
const width = (from, to) => widths.slice(from, to).reduce((sum, size) => sum + size, 0);
|
|
1147
|
+
const fits = (from, to) => (from > 0 ? 1 : 0) + width(from, to) + (to < cells.length ? 1 : 0) <= room;
|
|
1148
|
+
let start = at;
|
|
1149
|
+
let end = at + 1;
|
|
1150
|
+
while (start > 0 && fits(start - 1, end))
|
|
1151
|
+
start--;
|
|
1152
|
+
while (end < cells.length && fits(start, end + 1))
|
|
1153
|
+
end++;
|
|
1154
|
+
const left = start > 0 ? "\u2026" : "";
|
|
1155
|
+
const right = end < cells.length ? "\u2026" : "";
|
|
1156
|
+
return { before: left + chars.slice(start, at).join(""), at: chars[at], after: chars.slice(at + 1, end).join("") + right, column: left.length + width(start, at) };
|
|
1157
|
+
}
|
|
1158
|
+
var EDIT_KEYS, BACKWARD_KILLS, FORWARD_KILLS, WORD_CHARACTER, SPACE;
|
|
1159
|
+
var init_line = __esm(() => {
|
|
1160
|
+
EDIT_KEYS = new Set(["left", "right", "wordleft", "wordright", "linestart", "lineend", "erase", "delete", "word", "killword", "killnext", "clear", "killend", "yank"]);
|
|
1161
|
+
BACKWARD_KILLS = new Set(["word", "killword", "clear"]);
|
|
1162
|
+
FORWARD_KILLS = new Set(["killnext", "killend"]);
|
|
1163
|
+
WORD_CHARACTER = /[\p{L}\p{N}_]/u;
|
|
1164
|
+
SPACE = /\s/;
|
|
1165
|
+
});
|
|
1166
|
+
|
|
1167
|
+
// ../kit/src/picker/score.ts
|
|
1168
|
+
var BOUNDARY_AFTER, NONE;
|
|
1169
|
+
var init_score = __esm(() => {
|
|
1170
|
+
BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
|
|
1171
|
+
NONE = Number.NEGATIVE_INFINITY;
|
|
1172
|
+
});
|
|
1173
|
+
|
|
1174
|
+
// ../kit/src/picker/state.ts
|
|
1175
|
+
function repeat(value, count) {
|
|
1176
|
+
return Array.from({ length: count }).fill(value);
|
|
1177
|
+
}
|
|
1178
|
+
function parseKeys(input, paste = { active: false }, ctrls = []) {
|
|
1179
|
+
const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
|
|
1180
|
+
return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
|
|
1181
|
+
const wheel = MOUSE.exec(sequence)?.[1];
|
|
1182
|
+
if (wheel !== undefined)
|
|
1183
|
+
return repeat(wheel === "64" ? "up" : "down", wheel === "64" || wheel === "65" ? WHEEL_LINES : 0);
|
|
1184
|
+
const named = codes.get(sequence);
|
|
1185
|
+
const key = named === undefined ? KEYS[sequence] : { ctrl: named };
|
|
1186
|
+
if (sequence === PASTE_START || sequence === PASTE_END) {
|
|
1187
|
+
paste.active = sequence === PASTE_START;
|
|
1188
|
+
return [];
|
|
1189
|
+
}
|
|
1190
|
+
if (paste.active && (sequence === "\r" || sequence === `
|
|
1191
|
+
`))
|
|
1192
|
+
return [];
|
|
1193
|
+
if (key !== undefined)
|
|
1194
|
+
return [key];
|
|
1195
|
+
return IS_CONTROL.test(sequence) || sequence.startsWith("\x1B") ? [] : [{ text: sequence }];
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
var IS_CONTROL, PASTE_START = "\x1B[200~", PASTE_END = "\x1B[201~", KEY_SEQUENCES, MOUSE, WHEEL_LINES = 3, KEYS;
|
|
1199
|
+
var init_state = __esm(() => {
|
|
1200
|
+
init_text2();
|
|
1201
|
+
init_line();
|
|
1202
|
+
init_score();
|
|
1203
|
+
IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
|
|
1204
|
+
KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
|
|
1205
|
+
MOUSE = /^\x1B\[<(\d+);\d+;\d+[a-z]$/i;
|
|
1206
|
+
KEYS = {
|
|
1207
|
+
"\x1B[A": "up",
|
|
1208
|
+
"\x1BOA": "up",
|
|
1209
|
+
"\x10": "up",
|
|
1210
|
+
"\x1B[B": "down",
|
|
1211
|
+
"\x1BOB": "down",
|
|
1212
|
+
"\x0E": "down",
|
|
1213
|
+
"\x1B[5~": "pageup",
|
|
1214
|
+
"\x1B[6~": "pagedown",
|
|
1215
|
+
"\x1B[H": "home",
|
|
1216
|
+
"\x1B[1~": "home",
|
|
1217
|
+
"\x1BOH": "home",
|
|
1218
|
+
"\x1B[F": "end",
|
|
1219
|
+
"\x1B[4~": "end",
|
|
1220
|
+
"\x1BOF": "end",
|
|
1221
|
+
"\r": "enter",
|
|
1222
|
+
"\n": "enter",
|
|
1223
|
+
"\x03": "cancel",
|
|
1224
|
+
"\x1B": "cancel",
|
|
1225
|
+
"\x1B[D": "left",
|
|
1226
|
+
"\x1BOD": "left",
|
|
1227
|
+
"\x1B[C": "right",
|
|
1228
|
+
"\x1BOC": "right",
|
|
1229
|
+
"\x1B[1;5D": "wordleft",
|
|
1230
|
+
"\x1B[1;3D": "wordleft",
|
|
1231
|
+
"\x1Bb": "wordleft",
|
|
1232
|
+
"\x1B[1;5C": "wordright",
|
|
1233
|
+
"\x1B[1;3C": "wordright",
|
|
1234
|
+
"\x1Bf": "wordright",
|
|
1235
|
+
"\x01": "linestart",
|
|
1236
|
+
"\x05": "lineend",
|
|
1237
|
+
"\x7F": "erase",
|
|
1238
|
+
"\x1B[3~": "delete",
|
|
1239
|
+
"\b": "killword",
|
|
1240
|
+
"\x1B\x7F": "killword",
|
|
1241
|
+
"\x1B[3;5~": "killnext",
|
|
1242
|
+
"\x1Bd": "killnext",
|
|
1243
|
+
"\x15": "clear",
|
|
1244
|
+
"\v": "killend",
|
|
1245
|
+
"\x17": "word",
|
|
1246
|
+
"\x19": "yank",
|
|
1247
|
+
"\x1A": "suspend",
|
|
1248
|
+
"\t": "tab",
|
|
1249
|
+
"\x1F": "help",
|
|
1250
|
+
"\x1BOP": "help",
|
|
1251
|
+
"\x1B[11~": "help"
|
|
1252
|
+
};
|
|
1253
|
+
});
|
|
1254
|
+
|
|
1255
|
+
// ../kit/src/redraw.ts
|
|
1256
|
+
function overwrite(lines, columns) {
|
|
1257
|
+
return lines.map((line) => textWidth(line) % columns === 0 ? `\x1B[2K${line}` : `${line}\x1B[K`).join(`
|
|
1258
|
+
`);
|
|
1259
|
+
}
|
|
1260
|
+
function rowsTaken(lines, columns) {
|
|
1261
|
+
return lines.reduce((rows, line) => rows + Math.max(1, Math.ceil(textWidth(line) / columns)), 0);
|
|
1262
|
+
}
|
|
1263
|
+
var SYNC_START = "\x1B[?2026h", SYNC_END = "\x1B[?2026l";
|
|
1264
|
+
var init_redraw = __esm(() => {
|
|
1265
|
+
init_format();
|
|
1266
|
+
});
|
|
1267
|
+
|
|
1268
|
+
// ../kit/src/prompt.ts
|
|
1269
|
+
import process18 from "process";
|
|
1270
|
+
function readKeys(input, paste = { active: false }) {
|
|
1271
|
+
return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key) || isEditKey(key));
|
|
1272
|
+
}
|
|
1273
|
+
function roomAfter(question, columns) {
|
|
1274
|
+
return Math.max(columns - textWidth(`? ${question} `) % columns - 1, 1);
|
|
1275
|
+
}
|
|
1276
|
+
function withCaret(colors, line, room, dim = false) {
|
|
1277
|
+
const { before, at, after } = visible(line, room);
|
|
1278
|
+
const tone = dim ? colors.dim : (text) => text;
|
|
1279
|
+
return `${tone(before)}${at === undefined ? colors.dim("\u2588") : colors.inverse(at)}${tone(after)}`;
|
|
1280
|
+
}
|
|
1281
|
+
function sharedStart(texts) {
|
|
1282
|
+
const [first = [], ...rest] = texts.map((text) => [...text]);
|
|
1283
|
+
let length = first.length;
|
|
1284
|
+
for (const chars of rest) {
|
|
1285
|
+
const differs = chars.findIndex((char, index) => char !== first[index]);
|
|
1286
|
+
length = Math.min(length, differs === -1 ? chars.length : differs);
|
|
1287
|
+
}
|
|
1288
|
+
return first.slice(0, length).join("");
|
|
1289
|
+
}
|
|
1290
|
+
function listed2(colors, found, columns) {
|
|
1291
|
+
const shared = sharedStart(found);
|
|
1292
|
+
const cut = Math.max(shared.lastIndexOf("/"), shared.lastIndexOf(" ")) + 1;
|
|
1293
|
+
const names = found.slice(0, MAX_LISTED).map((each) => each.slice(cut));
|
|
1294
|
+
const more = found.length > MAX_LISTED ? ` \u2026 ${found.length - MAX_LISTED} more` : "";
|
|
1295
|
+
return ` ${colors.dim(truncate(names.join(" ") + more, Math.max(columns - 3, 1)))}`;
|
|
1296
|
+
}
|
|
1297
|
+
async function input2(question, { default: fallback, mask = false, validate, history, complete, ...settings } = {}) {
|
|
1298
|
+
let line = { text: "", caret: 0 };
|
|
1299
|
+
let invalid;
|
|
1300
|
+
let completions = [];
|
|
1301
|
+
const remembered = history === undefined || mask ? undefined : history;
|
|
1302
|
+
const earlier = remembered === undefined ? [] : earlierAnswers(remembered);
|
|
1303
|
+
let recalled = -1;
|
|
1304
|
+
let draft = line;
|
|
1305
|
+
const taken = () => line.text === "" ? fallback ?? "" : line.text;
|
|
1306
|
+
const shown = () => mask ? "*".repeat([...taken()].length) : taken();
|
|
1307
|
+
const accepted = await ask(question, settings, (colors, state, { columns }) => {
|
|
1308
|
+
if (state !== "asking")
|
|
1309
|
+
return [answer(colors, question, state, shown())];
|
|
1310
|
+
const typed = line.text === "" ? { text: shown(), caret: [...shown()].length } : { text: shown(), caret: line.caret };
|
|
1311
|
+
return [`${colors.cyan("?")} ${question} ${withCaret(colors, typed, roomAfter(question, columns), line.text === "")}`, ...invalid === undefined ? [] : [` ${colors.red(invalid)}`], ...completions.length > 1 ? [listed2(colors, completions, columns)] : []];
|
|
1312
|
+
}, (key) => {
|
|
1313
|
+
if (key === "cancel")
|
|
1314
|
+
return "cancel";
|
|
1315
|
+
invalid = undefined;
|
|
1316
|
+
completions = [];
|
|
1317
|
+
if (line.chained === true && endsKills(key))
|
|
1318
|
+
line = { ...line, chained: false };
|
|
1319
|
+
if (key === "tab") {
|
|
1320
|
+
const chars = [...line.text];
|
|
1321
|
+
const before = chars.slice(0, line.caret).join("");
|
|
1322
|
+
const found = complete?.(before) ?? [];
|
|
1323
|
+
const filled = sharedStart(found);
|
|
1324
|
+
if ([...filled].length > [...before].length)
|
|
1325
|
+
line = { ...line, text: filled + chars.slice(line.caret).join(""), caret: [...filled].length };
|
|
1326
|
+
else
|
|
1327
|
+
completions = found;
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
if (key === "enter") {
|
|
1331
|
+
invalid = validate?.(taken());
|
|
1332
|
+
return invalid === undefined ? "enter" : undefined;
|
|
1333
|
+
}
|
|
1334
|
+
if (key === "up" || key === "down") {
|
|
1335
|
+
const to = Math.min(Math.max(recalled + (key === "up" ? 1 : -1), -1), earlier.length - 1);
|
|
1336
|
+
if (recalled === -1)
|
|
1337
|
+
draft = line;
|
|
1338
|
+
recalled = to;
|
|
1339
|
+
const shown = to === -1 ? draft : { text: earlier[to], caret: [...earlier[to]].length };
|
|
1340
|
+
line = { ...shown, killed: line.killed ?? "" };
|
|
1341
|
+
return;
|
|
1342
|
+
}
|
|
1343
|
+
const edit = { home: "linestart", end: "lineend" }[key] ?? key;
|
|
1344
|
+
if (typeof edit === "object" || isEditKey(edit))
|
|
1345
|
+
line = editLine(line, edit);
|
|
1346
|
+
return;
|
|
1347
|
+
});
|
|
1348
|
+
if (!accepted)
|
|
1349
|
+
return;
|
|
1350
|
+
if (remembered !== undefined && taken() !== "")
|
|
1351
|
+
rememberAnswer(remembered, taken());
|
|
1352
|
+
return taken();
|
|
1353
|
+
}
|
|
1354
|
+
function answer(colors, question, state, picked) {
|
|
1355
|
+
return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
|
|
1356
|
+
}
|
|
1357
|
+
async function ask(question, { hint, terminal = process18 }, render, press) {
|
|
1358
|
+
const { stdin, stderr } = terminal;
|
|
1359
|
+
if (!isInteractive(terminal))
|
|
1360
|
+
fail(`cannot ask "${question}" off a terminal`, 2, hint);
|
|
1361
|
+
const colors = paint(stderr);
|
|
1362
|
+
let current = "asking";
|
|
1363
|
+
let outcome;
|
|
1364
|
+
const columns = () => stderr.columns || 80;
|
|
1365
|
+
const draw = (state, last = false) => {
|
|
1366
|
+
const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
|
|
1367
|
+
const rows = rowsTaken(frame, columns());
|
|
1368
|
+
stderr.write(`${SYNC_START}\r${overwrite(frame, columns())}\x1B[0J${last || rows < 2 ? "" : `\x1B[${rows - 1}A`}${last ? "" : "\r"}${SYNC_END}`);
|
|
1369
|
+
current = state;
|
|
1370
|
+
};
|
|
1371
|
+
const redraw = () => draw(current);
|
|
1372
|
+
const paste = { active: false };
|
|
1373
|
+
const stop = terminal.stop ?? (terminal === process18 ? stopJob : undefined);
|
|
1374
|
+
const suspend = () => {
|
|
1375
|
+
if (stop === undefined)
|
|
1376
|
+
return;
|
|
1377
|
+
stderr.write("\x1B[0J\x1B[?25h\x1B[?2004l");
|
|
1378
|
+
stdin.setRawMode(false);
|
|
1379
|
+
stop();
|
|
1380
|
+
stdin.setRawMode(true);
|
|
1381
|
+
stderr.write("\x1B[?25l\x1B[?2004h");
|
|
1382
|
+
};
|
|
1383
|
+
try {
|
|
1384
|
+
stderr.on?.("resize", redraw);
|
|
1385
|
+
stdin.setRawMode(true);
|
|
1386
|
+
stdin.resume();
|
|
1387
|
+
stderr.write("\x1B[?25l\x1B[?2004h");
|
|
1388
|
+
draw("asking");
|
|
1389
|
+
return await new Promise((resolve) => {
|
|
1390
|
+
function onData(data) {
|
|
1391
|
+
for (const key of readKeys(data.toString(), paste)) {
|
|
1392
|
+
if (key === "suspend") {
|
|
1393
|
+
suspend();
|
|
1394
|
+
continue;
|
|
1395
|
+
}
|
|
1396
|
+
const pressed = press(key);
|
|
1397
|
+
if (pressed !== undefined) {
|
|
1398
|
+
settle(pressed);
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
draw("asking");
|
|
1403
|
+
}
|
|
1404
|
+
function onEnd() {
|
|
1405
|
+
settle("cancel");
|
|
1406
|
+
}
|
|
1407
|
+
function settle(settled) {
|
|
1408
|
+
outcome = settled;
|
|
1409
|
+
stdin.off("data", onData);
|
|
1410
|
+
stdin.off("end", onEnd);
|
|
1411
|
+
resolve(settled === "enter");
|
|
1412
|
+
}
|
|
1413
|
+
stdin.on("data", onData);
|
|
1414
|
+
stdin.on("end", onEnd);
|
|
1415
|
+
});
|
|
1416
|
+
} finally {
|
|
1417
|
+
stderr.off?.("resize", redraw);
|
|
1418
|
+
draw(outcome ?? "cancel", true);
|
|
1419
|
+
stderr.write(`
|
|
1420
|
+
\x1B[?25h\x1B[?2004l`);
|
|
1421
|
+
stdin.setRawMode(false);
|
|
1422
|
+
stdin.pause();
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
var PROMPT_KEYS, MAX_LISTED = 12;
|
|
1426
|
+
var init_prompt = __esm(() => {
|
|
1427
|
+
init_answers();
|
|
1428
|
+
init_args();
|
|
1429
|
+
init_format();
|
|
1430
|
+
init_job();
|
|
1431
|
+
init_mode();
|
|
1432
|
+
init_line();
|
|
1433
|
+
init_state();
|
|
1434
|
+
init_redraw();
|
|
1435
|
+
init_style();
|
|
1436
|
+
PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "suspend", "tab"]);
|
|
1437
|
+
});
|
|
1438
|
+
|
|
1439
|
+
// src/cli.ts
|
|
1440
|
+
import process35 from "process";
|
|
1441
|
+
|
|
1442
|
+
// ../kit/src/index.ts
|
|
1443
|
+
init_args();
|
|
1444
|
+
|
|
911
1445
|
// ../kit/src/argv.ts
|
|
912
1446
|
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
913
1447
|
import { resolve as resolve3 } from "path";
|
|
@@ -933,6 +1467,10 @@ function scriptArgs(argv = process11.argv.slice(2), cmdline = commandLine(), scr
|
|
|
933
1467
|
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
934
1468
|
}
|
|
935
1469
|
// ../kit/src/chart.ts
|
|
1470
|
+
init_format();
|
|
1471
|
+
init_mode();
|
|
1472
|
+
init_style();
|
|
1473
|
+
init_theme();
|
|
936
1474
|
import process12 from "process";
|
|
937
1475
|
var FILLED = "\u2501";
|
|
938
1476
|
var EMPTY = "\u2500";
|
|
@@ -946,7 +1484,12 @@ function bar(ratio, { width = 20, stream = process12.stdout, env = process12.env
|
|
|
946
1484
|
const { theme } = activeTheme();
|
|
947
1485
|
return `${shaded(theme, colors, theme.glyphs.bar, filled, width, env)}${colors.dim(theme.glyphs.bar.repeat(width - filled))}`;
|
|
948
1486
|
}
|
|
1487
|
+
// ../kit/src/ci.ts
|
|
1488
|
+
init_args();
|
|
1489
|
+
init_format();
|
|
1490
|
+
|
|
949
1491
|
// ../kit/src/progress.ts
|
|
1492
|
+
init_format();
|
|
950
1493
|
import process14 from "process";
|
|
951
1494
|
|
|
952
1495
|
// ../kit/src/process.ts
|
|
@@ -1021,10 +1564,10 @@ async function pipeInto(argv, text) {
|
|
|
1021
1564
|
return false;
|
|
1022
1565
|
}
|
|
1023
1566
|
}
|
|
1024
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1567
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1025
1568
|
const chunks = [];
|
|
1026
1569
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
1027
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1570
|
+
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 } : {} });
|
|
1028
1571
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
1029
1572
|
const timers = [];
|
|
1030
1573
|
const killGroup = (killing) => {
|
|
@@ -1101,6 +1644,8 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
1101
1644
|
}
|
|
1102
1645
|
|
|
1103
1646
|
// ../kit/src/progress.ts
|
|
1647
|
+
init_style();
|
|
1648
|
+
init_theme();
|
|
1104
1649
|
var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
1105
1650
|
var FRAME_MS = 200;
|
|
1106
1651
|
var CLEAR_BELOW = "\r\x1B[J";
|
|
@@ -1117,10 +1662,14 @@ function liveRegion(render, stream = process14.stderr, env = process14.env) {
|
|
|
1117
1662
|
}, print: (text) => void stream.write(`${text}
|
|
1118
1663
|
`), stop: () => {
|
|
1119
1664
|
return;
|
|
1665
|
+
}, pause: () => () => {
|
|
1666
|
+
return;
|
|
1120
1667
|
} };
|
|
1121
1668
|
const write = stream.write.bind(stream);
|
|
1122
1669
|
let frame = 0;
|
|
1123
1670
|
let drawn = false;
|
|
1671
|
+
let paused = false;
|
|
1672
|
+
let stopped = false;
|
|
1124
1673
|
const columns = () => {
|
|
1125
1674
|
const now = stream.getWindowSize?.()[0] ?? stream.columns;
|
|
1126
1675
|
return now === undefined || now === 0 ? 80 : now;
|
|
@@ -1131,6 +1680,8 @@ function liveRegion(render, stream = process14.stderr, env = process14.env) {
|
|
|
1131
1680
|
drawn = false;
|
|
1132
1681
|
};
|
|
1133
1682
|
const draw = () => {
|
|
1683
|
+
if (paused)
|
|
1684
|
+
return;
|
|
1134
1685
|
const width = columns() - 1;
|
|
1135
1686
|
const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
|
|
1136
1687
|
const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
|
|
@@ -1142,16 +1693,17 @@ function liveRegion(render, stream = process14.stderr, env = process14.env) {
|
|
|
1142
1693
|
`)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
|
|
1143
1694
|
drawn = true;
|
|
1144
1695
|
};
|
|
1145
|
-
|
|
1696
|
+
let timer = setInterval(draw, FRAME_MS);
|
|
1146
1697
|
stream.on?.("resize", draw);
|
|
1147
|
-
|
|
1148
|
-
|
|
1698
|
+
let restore = interceptOutput(clear);
|
|
1699
|
+
let release = swallowInput();
|
|
1149
1700
|
const onExit = () => {
|
|
1150
1701
|
clear();
|
|
1151
1702
|
release();
|
|
1152
1703
|
};
|
|
1153
1704
|
const signals = holdSignals(stop);
|
|
1154
1705
|
function stop() {
|
|
1706
|
+
stopped = true;
|
|
1155
1707
|
clearInterval(timer);
|
|
1156
1708
|
stream.off?.("resize", draw);
|
|
1157
1709
|
clear();
|
|
@@ -1160,6 +1712,29 @@ function liveRegion(render, stream = process14.stderr, env = process14.env) {
|
|
|
1160
1712
|
process14.off("exit", onExit);
|
|
1161
1713
|
signals.release();
|
|
1162
1714
|
}
|
|
1715
|
+
function pause() {
|
|
1716
|
+
if (paused || stopped)
|
|
1717
|
+
return () => {
|
|
1718
|
+
return;
|
|
1719
|
+
};
|
|
1720
|
+
paused = true;
|
|
1721
|
+
clearInterval(timer);
|
|
1722
|
+
stream.off?.("resize", draw);
|
|
1723
|
+
clear();
|
|
1724
|
+
restore();
|
|
1725
|
+
release();
|
|
1726
|
+
return () => {
|
|
1727
|
+
if (!paused || stopped)
|
|
1728
|
+
return;
|
|
1729
|
+
paused = false;
|
|
1730
|
+
timer = setInterval(draw, FRAME_MS);
|
|
1731
|
+
timer.unref();
|
|
1732
|
+
stream.on?.("resize", draw);
|
|
1733
|
+
restore = interceptOutput(clear);
|
|
1734
|
+
release = swallowInput();
|
|
1735
|
+
draw();
|
|
1736
|
+
};
|
|
1737
|
+
}
|
|
1163
1738
|
timer.unref();
|
|
1164
1739
|
process14.on("exit", onExit);
|
|
1165
1740
|
return {
|
|
@@ -1170,7 +1745,8 @@ function liveRegion(render, stream = process14.stderr, env = process14.env) {
|
|
|
1170
1745
|
`);
|
|
1171
1746
|
draw();
|
|
1172
1747
|
},
|
|
1173
|
-
stop
|
|
1748
|
+
stop,
|
|
1749
|
+
pause
|
|
1174
1750
|
};
|
|
1175
1751
|
}
|
|
1176
1752
|
function cutToWidth(line, width) {
|
|
@@ -1241,7 +1817,11 @@ function interceptOutput(clear) {
|
|
|
1241
1817
|
};
|
|
1242
1818
|
}
|
|
1243
1819
|
|
|
1820
|
+
// ../kit/src/ci.ts
|
|
1821
|
+
init_style();
|
|
1822
|
+
|
|
1244
1823
|
// ../kit/src/tool.ts
|
|
1824
|
+
init_format();
|
|
1245
1825
|
import process15 from "process";
|
|
1246
1826
|
var PERMANENT = /\bHTTP (?:401|403|404)\b|unauthorized|forbidden|not found|couldn't be found|token is required/i;
|
|
1247
1827
|
function cwdGone() {
|
|
@@ -1270,10 +1850,10 @@ function isPermanentFailure(error) {
|
|
|
1270
1850
|
return false;
|
|
1271
1851
|
return error instanceof SpawnError && error.missing || PERMANENT.test(error.message);
|
|
1272
1852
|
}
|
|
1273
|
-
async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
|
|
1853
|
+
async function runTool(label, argv, { timeoutMs, cwd, onStart, env } = {}) {
|
|
1274
1854
|
let ran;
|
|
1275
1855
|
try {
|
|
1276
|
-
ran = await runCommand(argv, { env: process15.env, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
|
|
1856
|
+
ran = await runCommand(argv, { env: { ...process15.env, ...env }, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
|
|
1277
1857
|
} catch (error) {
|
|
1278
1858
|
throw spawnFailure(label, error);
|
|
1279
1859
|
}
|
|
@@ -1365,9 +1945,120 @@ function ciHeader(spinner, label, startedAt, out) {
|
|
|
1365
1945
|
return `${spinner} ${label} ${paint(out).dim(formatElapsed(Date.now() - startedAt))}`;
|
|
1366
1946
|
}
|
|
1367
1947
|
// ../kit/src/cli.ts
|
|
1368
|
-
|
|
1369
|
-
import {
|
|
1370
|
-
import
|
|
1948
|
+
init_args();
|
|
1949
|
+
import { readFileSync as readFileSync5, realpathSync as realpathSync2 } from "fs";
|
|
1950
|
+
import { dirname as dirname4, join as join8 } from "path";
|
|
1951
|
+
import process22 from "process";
|
|
1952
|
+
|
|
1953
|
+
// ../kit/src/askpass.ts
|
|
1954
|
+
import { chmodSync, mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
1955
|
+
import { tmpdir } from "os";
|
|
1956
|
+
import { join as join6 } from "path";
|
|
1957
|
+
import process19 from "process";
|
|
1958
|
+
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1959
|
+
var ECHOED = /username|yes\/no/i;
|
|
1960
|
+
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1961
|
+
function askpass(pause = () => () => {
|
|
1962
|
+
return;
|
|
1963
|
+
}) {
|
|
1964
|
+
if (process19.stdin.isTTY !== true || process19.stderr.isTTY !== true || process19.argv[1] === undefined)
|
|
1965
|
+
return;
|
|
1966
|
+
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
1967
|
+
const socketPath = join6(dir, "socket");
|
|
1968
|
+
const script = join6(dir, "askpass");
|
|
1969
|
+
let turn = Promise.resolve();
|
|
1970
|
+
const answer = async ({ prompt, notice }) => {
|
|
1971
|
+
const resume = pause();
|
|
1972
|
+
try {
|
|
1973
|
+
if (notice === true) {
|
|
1974
|
+
process19.stderr.write(`${prompt.trim()}
|
|
1975
|
+
`);
|
|
1976
|
+
return {};
|
|
1977
|
+
}
|
|
1978
|
+
await Promise.resolve().then(() => init_prompt());
|
|
1979
|
+
return { answer: await input2(prompt.trim(), { mask: !ECHOED.test(prompt) }) };
|
|
1980
|
+
} finally {
|
|
1981
|
+
resume();
|
|
1982
|
+
}
|
|
1983
|
+
};
|
|
1984
|
+
const respond = async (socket, request) => {
|
|
1985
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
1986
|
+
const previous = turn;
|
|
1987
|
+
let reply = {};
|
|
1988
|
+
turn = promise;
|
|
1989
|
+
await previous;
|
|
1990
|
+
try {
|
|
1991
|
+
reply = await answer(request);
|
|
1992
|
+
} catch {} finally {
|
|
1993
|
+
socket.end(`${JSON.stringify(reply)}
|
|
1994
|
+
`);
|
|
1995
|
+
resolve();
|
|
1996
|
+
}
|
|
1997
|
+
};
|
|
1998
|
+
const server = Bun.listen({
|
|
1999
|
+
unix: socketPath,
|
|
2000
|
+
socket: {
|
|
2001
|
+
open: (socket) => {
|
|
2002
|
+
socket.data = { buffered: "" };
|
|
2003
|
+
},
|
|
2004
|
+
data: (socket, chunk) => {
|
|
2005
|
+
const before = socket.data.buffered;
|
|
2006
|
+
socket.data.buffered += chunk.toString();
|
|
2007
|
+
if (before.includes(`
|
|
2008
|
+
`) || !socket.data.buffered.includes(`
|
|
2009
|
+
`))
|
|
2010
|
+
return;
|
|
2011
|
+
respond(socket, JSON.parse(socket.data.buffered));
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
});
|
|
2015
|
+
writeFileSync2(script, `#!/bin/sh
|
|
2016
|
+
${SOCKET_VARIABLE}=${quoted(socketPath)} exec ${quoted(process19.execPath)} --no-env-file --config=/dev/null ${quoted(process19.argv[1])} "$@"
|
|
2017
|
+
`);
|
|
2018
|
+
chmodSync(script, 448);
|
|
2019
|
+
return {
|
|
2020
|
+
env: { GIT_ASKPASS: script, SSH_ASKPASS: script, SSH_ASKPASS_REQUIRE: "force" },
|
|
2021
|
+
close: () => {
|
|
2022
|
+
server.stop(true);
|
|
2023
|
+
rmSync(dir, { recursive: true, force: true });
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
async function askpassClient(argv) {
|
|
2028
|
+
const socketPath = process19.env[SOCKET_VARIABLE];
|
|
2029
|
+
if (socketPath === undefined)
|
|
2030
|
+
return;
|
|
2031
|
+
const request = { prompt: argv[0] ?? "", ...process19.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
|
|
2032
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
2033
|
+
let received = "";
|
|
2034
|
+
try {
|
|
2035
|
+
await Bun.connect({
|
|
2036
|
+
unix: socketPath,
|
|
2037
|
+
socket: {
|
|
2038
|
+
open: (socket) => void socket.write(`${JSON.stringify(request)}
|
|
2039
|
+
`),
|
|
2040
|
+
data: (_, chunk) => {
|
|
2041
|
+
received += chunk.toString();
|
|
2042
|
+
},
|
|
2043
|
+
close: () => resolve(received),
|
|
2044
|
+
error: () => resolve("")
|
|
2045
|
+
}
|
|
2046
|
+
});
|
|
2047
|
+
} catch {
|
|
2048
|
+
return 1;
|
|
2049
|
+
}
|
|
2050
|
+
const reply = await promise;
|
|
2051
|
+
if (reply === "")
|
|
2052
|
+
return 1;
|
|
2053
|
+
const { answer } = JSON.parse(reply);
|
|
2054
|
+
if (request.notice === true)
|
|
2055
|
+
return 0;
|
|
2056
|
+
if (answer === undefined)
|
|
2057
|
+
return 1;
|
|
2058
|
+
process19.stdout.write(`${answer}
|
|
2059
|
+
`);
|
|
2060
|
+
return 0;
|
|
2061
|
+
}
|
|
1371
2062
|
|
|
1372
2063
|
// ../kit/src/completions.ts
|
|
1373
2064
|
var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
|
|
@@ -1430,28 +2121,34 @@ compdef __kaynooo_cli_complete ${bins.join(" ")}
|
|
|
1430
2121
|
}
|
|
1431
2122
|
|
|
1432
2123
|
// ../kit/src/notify.ts
|
|
1433
|
-
|
|
2124
|
+
init_format();
|
|
2125
|
+
init_mode();
|
|
2126
|
+
import process20 from "process";
|
|
1434
2127
|
var NOTIFY_AFTER_MS = 1e4;
|
|
1435
2128
|
var CANCELLED = 130;
|
|
1436
2129
|
function base64(text) {
|
|
1437
2130
|
return Buffer.from(text).toString("base64");
|
|
1438
2131
|
}
|
|
1439
|
-
function notification(title, body, env =
|
|
1440
|
-
const id = `kit${
|
|
2132
|
+
function notification(title, body, env = process20.env) {
|
|
2133
|
+
const id = `kit${process20.pid}`;
|
|
1441
2134
|
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\\`];
|
|
1442
2135
|
return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
|
|
1443
2136
|
}
|
|
1444
|
-
function notifyEnd(command, code, ms, { stream =
|
|
2137
|
+
function notifyEnd(command, code, ms, { stream = process20.stderr, env = process20.env } = {}) {
|
|
1445
2138
|
if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
|
|
1446
2139
|
return;
|
|
1447
2140
|
stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
|
|
1448
2141
|
}
|
|
1449
2142
|
|
|
2143
|
+
// ../kit/src/cli.ts
|
|
2144
|
+
init_style();
|
|
2145
|
+
init_text2();
|
|
2146
|
+
|
|
1450
2147
|
// ../kit/src/usage.ts
|
|
1451
|
-
import { appendFileSync, mkdirSync } from "fs";
|
|
1452
|
-
import { homedir as
|
|
1453
|
-
import { dirname as
|
|
1454
|
-
import
|
|
2148
|
+
import { appendFileSync, mkdirSync as mkdirSync2 } from "fs";
|
|
2149
|
+
import { homedir as homedir4 } from "os";
|
|
2150
|
+
import { dirname as dirname3, isAbsolute, join as join7 } from "path";
|
|
2151
|
+
import process21 from "process";
|
|
1455
2152
|
|
|
1456
2153
|
// ../kit/src/logs.ts
|
|
1457
2154
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -1465,14 +2162,14 @@ var usageError;
|
|
|
1465
2162
|
function noteUsageError(message) {
|
|
1466
2163
|
usageError = message;
|
|
1467
2164
|
}
|
|
1468
|
-
function stateHome(env =
|
|
2165
|
+
function stateHome(env = process21.env) {
|
|
1469
2166
|
const dir = env.XDG_STATE_HOME;
|
|
1470
|
-
return dir !== undefined && isAbsolute(dir) ? dir :
|
|
2167
|
+
return dir !== undefined && isAbsolute(dir) ? dir : join7(homedir4(), ".local", "state");
|
|
1471
2168
|
}
|
|
1472
|
-
function usagePath(env =
|
|
1473
|
-
return
|
|
2169
|
+
function usagePath(env = process21.env) {
|
|
2170
|
+
return join7(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1474
2171
|
}
|
|
1475
|
-
function usageRecorded(env =
|
|
2172
|
+
function usageRecorded(env = process21.env) {
|
|
1476
2173
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1477
2174
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1478
2175
|
}
|
|
@@ -1481,17 +2178,17 @@ function flagNames(argv) {
|
|
|
1481
2178
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
1482
2179
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
1483
2180
|
}
|
|
1484
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
2181
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
1485
2182
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
1486
2183
|
usageError = undefined;
|
|
1487
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
2184
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
1488
2185
|
}
|
|
1489
|
-
function recordUsage(entry, env =
|
|
2186
|
+
function recordUsage(entry, env = process21.env) {
|
|
1490
2187
|
if (!usageRecorded(env))
|
|
1491
2188
|
return;
|
|
1492
2189
|
try {
|
|
1493
2190
|
const path = usagePath(env);
|
|
1494
|
-
|
|
2191
|
+
mkdirSync2(dirname3(path), { recursive: true, mode: 448 });
|
|
1495
2192
|
appendFileSync(path, `${JSON.stringify(entry)}
|
|
1496
2193
|
`, { mode: 384 });
|
|
1497
2194
|
} catch {}
|
|
@@ -1580,8 +2277,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1580
2277
|
`);
|
|
1581
2278
|
}
|
|
1582
2279
|
function printError(prefix, message, hint, cause) {
|
|
1583
|
-
const colors = paint(
|
|
1584
|
-
const styled = takesControlCodes(
|
|
2280
|
+
const colors = paint(process22.stderr);
|
|
2281
|
+
const styled = takesControlCodes(process22.stderr);
|
|
1585
2282
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1586
2283
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1587
2284
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1591,8 +2288,8 @@ function runHint(command, effect) {
|
|
|
1591
2288
|
return `run \`${command}\`${effect === undefined ? "" : ` to ${effect}`}`;
|
|
1592
2289
|
}
|
|
1593
2290
|
function printHint(hint) {
|
|
1594
|
-
const colors = paint(
|
|
1595
|
-
console.error(` ${takesControlCodes(
|
|
2291
|
+
const colors = paint(process22.stderr);
|
|
2292
|
+
console.error(` ${takesControlCodes(process22.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
|
|
1596
2293
|
}
|
|
1597
2294
|
function printJsonError(message, hint, cause) {
|
|
1598
2295
|
console.error(JSON.stringify({ error: message, ...hint === undefined ? {} : { hint }, ...cause === undefined ? {} : { cause } }));
|
|
@@ -1631,11 +2328,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1631
2328
|
}
|
|
1632
2329
|
}
|
|
1633
2330
|
if (name === undefined && level.path.length > 1) {
|
|
1634
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
2331
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process22.stderr));
|
|
1635
2332
|
return 2;
|
|
1636
2333
|
}
|
|
1637
2334
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1638
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
2335
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process22.stdout));
|
|
1639
2336
|
return 0;
|
|
1640
2337
|
}
|
|
1641
2338
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1769,18 +2466,21 @@ function packageVersion(entry = Bun.main) {
|
|
|
1769
2466
|
try {
|
|
1770
2467
|
resolved = realpathSync2(entry);
|
|
1771
2468
|
} catch {}
|
|
1772
|
-
for (let dir =
|
|
2469
|
+
for (let dir = dirname4(resolved);; dir = dirname4(dir)) {
|
|
1773
2470
|
try {
|
|
1774
|
-
const { version } = JSON.parse(
|
|
2471
|
+
const { version } = JSON.parse(readFileSync5(join8(dir, "package.json"), "utf8"));
|
|
1775
2472
|
if (typeof version === "string")
|
|
1776
2473
|
return version;
|
|
1777
2474
|
} catch {}
|
|
1778
|
-
if (
|
|
2475
|
+
if (dirname4(dir) === dir)
|
|
1779
2476
|
return "0.0.0";
|
|
1780
2477
|
}
|
|
1781
2478
|
}
|
|
1782
2479
|
async function runCli(cli, argv = scriptArgs()) {
|
|
1783
2480
|
const version = cli.version ?? packageVersion();
|
|
2481
|
+
const answered = await askpassClient(argv);
|
|
2482
|
+
if (answered !== undefined)
|
|
2483
|
+
return answered;
|
|
1784
2484
|
if (argv[0] === COMPLETE)
|
|
1785
2485
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
1786
2486
|
if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
|
|
@@ -1791,7 +2491,7 @@ async function runCli(cli, argv = scriptArgs()) {
|
|
|
1791
2491
|
notifyEnd(command === undefined ? cli.name : `${cli.name} ${command}`, code, performance.now() - started);
|
|
1792
2492
|
if (cli.usage !== false) {
|
|
1793
2493
|
try {
|
|
1794
|
-
recordUsage(usageEntry(cli.name, command, argv, code));
|
|
2494
|
+
recordUsage(usageEntry(cli.name, command, argv, code, { ms: performance.now() - started }));
|
|
1795
2495
|
} catch {}
|
|
1796
2496
|
}
|
|
1797
2497
|
return code;
|
|
@@ -1811,7 +2511,12 @@ function commandPath(scope, argv) {
|
|
|
1811
2511
|
}
|
|
1812
2512
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1813
2513
|
}
|
|
2514
|
+
|
|
2515
|
+
// ../kit/src/index.ts
|
|
2516
|
+
init_config();
|
|
2517
|
+
|
|
1814
2518
|
// ../kit/src/excerpt.ts
|
|
2519
|
+
init_text2();
|
|
1815
2520
|
var BUN_CHECK_BLOCK = /<error file=[\s\S]*?<\/error>/g;
|
|
1816
2521
|
var BUN_CHECK_SOURCE = /<source>[\s\S]*?<\/source>\n?/g;
|
|
1817
2522
|
var BUN_CHECK_ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
@@ -1918,7 +2623,7 @@ function squeeze(lines) {
|
|
|
1918
2623
|
out.pop();
|
|
1919
2624
|
return out;
|
|
1920
2625
|
}
|
|
1921
|
-
function
|
|
2626
|
+
function cut2(shown) {
|
|
1922
2627
|
return shown.length > MAX_LINES ? [...shown.slice(0, MAX_LINES), `... ${shown.length - MAX_LINES} more lines`].join(`
|
|
1923
2628
|
`) : shown.join(`
|
|
1924
2629
|
`);
|
|
@@ -1928,13 +2633,17 @@ function recognised(lines, parsers) {
|
|
|
1928
2633
|
}
|
|
1929
2634
|
function toolExcerpt(lines) {
|
|
1930
2635
|
const found = recognised(lines.map((line) => stripAnsi(line)), TOOL_PARSERS);
|
|
1931
|
-
return found === undefined ? undefined :
|
|
2636
|
+
return found === undefined ? undefined : cut2(squeeze(found));
|
|
1932
2637
|
}
|
|
1933
|
-
|
|
1934
|
-
|
|
2638
|
+
|
|
2639
|
+
// ../kit/src/index.ts
|
|
2640
|
+
init_folders();
|
|
2641
|
+
init_format();
|
|
2642
|
+
|
|
1935
2643
|
// ../kit/src/git.ts
|
|
1936
|
-
|
|
1937
|
-
import
|
|
2644
|
+
init_args();
|
|
2645
|
+
import { basename, dirname as dirname5 } from "path";
|
|
2646
|
+
import process23 from "process";
|
|
1938
2647
|
var ORIGIN_PREFIX = /^origin\//;
|
|
1939
2648
|
var GIT_NETWORK_MS = 60000;
|
|
1940
2649
|
async function git(args, timeoutMs) {
|
|
@@ -1964,9 +2673,10 @@ async function defaultBranch() {
|
|
|
1964
2673
|
async function leaveWorktree() {
|
|
1965
2674
|
const common = await git(["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
1966
2675
|
if (basename(common) === ".git")
|
|
1967
|
-
|
|
2676
|
+
process23.chdir(dirname5(common));
|
|
1968
2677
|
}
|
|
1969
2678
|
// ../kit/src/limit.ts
|
|
2679
|
+
init_args();
|
|
1970
2680
|
function limitOptions(fallback) {
|
|
1971
2681
|
return {
|
|
1972
2682
|
limit: { type: "string", short: "n", description: `show at most this many rows, the rest counted (${fallback})` },
|
|
@@ -1987,35 +2697,44 @@ function capped(rows, limit) {
|
|
|
1987
2697
|
const more = rows.length - limit;
|
|
1988
2698
|
return more > 0 ? { shown: rows.slice(0, limit), footer: moreFooter(more) } : { shown: [...rows], footer: undefined };
|
|
1989
2699
|
}
|
|
2700
|
+
|
|
2701
|
+
// ../kit/src/index.ts
|
|
2702
|
+
init_mode();
|
|
2703
|
+
|
|
1990
2704
|
// ../kit/src/pool.ts
|
|
1991
|
-
async function pool(items, limit, task) {
|
|
2705
|
+
async function pool(items, limit, task, onDone) {
|
|
1992
2706
|
const results = Array.from({ length: items.length });
|
|
1993
2707
|
let next = 0;
|
|
2708
|
+
let done = 0;
|
|
1994
2709
|
async function worker() {
|
|
1995
2710
|
while (next < items.length) {
|
|
1996
2711
|
const index = next++;
|
|
1997
2712
|
results[index] = await task(items[index]);
|
|
2713
|
+
onDone?.(++done, items.length);
|
|
1998
2714
|
}
|
|
1999
2715
|
}
|
|
2000
2716
|
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
2001
2717
|
return results;
|
|
2002
2718
|
}
|
|
2719
|
+
// ../kit/src/report.ts
|
|
2720
|
+
init_style();
|
|
2721
|
+
init_text2();
|
|
2003
2722
|
// ../kit/src/secrets.ts
|
|
2004
2723
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
2005
2724
|
// ../kit/src/sessions.ts
|
|
2006
|
-
import { homedir as
|
|
2007
|
-
import { join as
|
|
2008
|
-
import
|
|
2725
|
+
import { homedir as homedir5 } from "os";
|
|
2726
|
+
import { join as join9 } from "path";
|
|
2727
|
+
import process24 from "process";
|
|
2009
2728
|
var {Glob } = globalThis.Bun;
|
|
2010
2729
|
var SESSION_FILES = new Glob("*.json");
|
|
2011
2730
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
2012
2731
|
async function sessionDirs() {
|
|
2013
|
-
const home =
|
|
2014
|
-
const dirs = new Set([
|
|
2015
|
-
if (
|
|
2016
|
-
dirs.add(
|
|
2732
|
+
const home = homedir5();
|
|
2733
|
+
const dirs = new Set([join9(home, ".claude", "sessions")]);
|
|
2734
|
+
if (process24.env.CLAUDE_CONFIG_DIR !== undefined)
|
|
2735
|
+
dirs.add(join9(process24.env.CLAUDE_CONFIG_DIR, "sessions"));
|
|
2017
2736
|
try {
|
|
2018
|
-
for await (const dir of ACCOUNT_DIRS.scan({ cwd:
|
|
2737
|
+
for await (const dir of ACCOUNT_DIRS.scan({ cwd: join9(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
|
|
2019
2738
|
dirs.add(dir);
|
|
2020
2739
|
} catch {}
|
|
2021
2740
|
return [...dirs];
|
|
@@ -2059,7 +2778,7 @@ async function liveSessions() {
|
|
|
2059
2778
|
}
|
|
2060
2779
|
async function currentSession(sessions) {
|
|
2061
2780
|
const byPid = new Map(sessions.map((session) => [session.pid, session]));
|
|
2062
|
-
let pid =
|
|
2781
|
+
let pid = process24.ppid;
|
|
2063
2782
|
for (let depth = 0;depth < 32 && pid > 1; depth++) {
|
|
2064
2783
|
const session = byPid.get(pid);
|
|
2065
2784
|
if (session !== undefined)
|
|
@@ -2071,8 +2790,18 @@ async function currentSession(sessions) {
|
|
|
2071
2790
|
}
|
|
2072
2791
|
return;
|
|
2073
2792
|
}
|
|
2793
|
+
|
|
2794
|
+
// ../kit/src/index.ts
|
|
2795
|
+
init_style();
|
|
2796
|
+
init_text2();
|
|
2797
|
+
init_theme();
|
|
2798
|
+
init_user_config();
|
|
2799
|
+
|
|
2074
2800
|
// ../kit/src/watch.ts
|
|
2075
|
-
|
|
2801
|
+
init_args();
|
|
2802
|
+
init_input();
|
|
2803
|
+
init_style();
|
|
2804
|
+
import process25 from "process";
|
|
2076
2805
|
import { format } from "util";
|
|
2077
2806
|
var CLEAR_SCREEN = "\x1B[H\x1B[2J";
|
|
2078
2807
|
var DEFAULT_SECONDS = 2;
|
|
@@ -2094,7 +2823,7 @@ function withoutWatch(args) {
|
|
|
2094
2823
|
}
|
|
2095
2824
|
return rest;
|
|
2096
2825
|
}
|
|
2097
|
-
async function watching(value, step, stream =
|
|
2826
|
+
async function watching(value, step, stream = process25.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
|
|
2098
2827
|
const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
|
|
2099
2828
|
if (!takesControlCodes(stream))
|
|
2100
2829
|
badUsage("--watch redraws the screen, so it needs a terminal");
|
|
@@ -2102,12 +2831,12 @@ async function watching(value, step, stream = process21.stdout, sleep = Bun.slee
|
|
|
2102
2831
|
for (let round = 0;round < rounds; round++) {
|
|
2103
2832
|
const held = [];
|
|
2104
2833
|
const { log, info } = console;
|
|
2105
|
-
const write =
|
|
2834
|
+
const write = process25.stdout.write.bind(process25.stdout);
|
|
2106
2835
|
const hold = (...parts) => void held.push(`${format(...parts)}
|
|
2107
2836
|
`);
|
|
2108
2837
|
console.log = hold;
|
|
2109
2838
|
console.info = hold;
|
|
2110
|
-
|
|
2839
|
+
process25.stdout.write = (text) => {
|
|
2111
2840
|
held.push(typeof text === "string" ? text : Buffer.from(text).toString());
|
|
2112
2841
|
return true;
|
|
2113
2842
|
};
|
|
@@ -2116,13 +2845,15 @@ async function watching(value, step, stream = process21.stdout, sleep = Bun.slee
|
|
|
2116
2845
|
} finally {
|
|
2117
2846
|
console.log = log;
|
|
2118
2847
|
console.info = info;
|
|
2119
|
-
|
|
2848
|
+
process25.stdout.write = write;
|
|
2120
2849
|
}
|
|
2121
2850
|
stream.write(`${CLEAR_SCREEN}${held.join("")}`);
|
|
2122
2851
|
await sleep(interval);
|
|
2123
2852
|
}
|
|
2124
2853
|
return code;
|
|
2125
2854
|
}
|
|
2855
|
+
// ../kit/src/workspace-root.ts
|
|
2856
|
+
init_user_config();
|
|
2126
2857
|
// src/args.ts
|
|
2127
2858
|
var repoOption = {
|
|
2128
2859
|
repo: { type: "string", short: "r", description: "owner/name of the repository, instead of the one origin points at" }
|
|
@@ -2294,9 +3025,9 @@ function holderSession(holder, sessions) {
|
|
|
2294
3025
|
}
|
|
2295
3026
|
|
|
2296
3027
|
// src/good.ts
|
|
2297
|
-
import
|
|
3028
|
+
import process27 from "process";
|
|
2298
3029
|
function good(text) {
|
|
2299
|
-
return role("ok",
|
|
3030
|
+
return role("ok", process27.stdout)(text);
|
|
2300
3031
|
}
|
|
2301
3032
|
|
|
2302
3033
|
// src/config.ts
|
|
@@ -2329,12 +3060,12 @@ async function loadSettings(home) {
|
|
|
2329
3060
|
}
|
|
2330
3061
|
|
|
2331
3062
|
// src/tea.ts
|
|
2332
|
-
import
|
|
3063
|
+
import process29 from "process";
|
|
2333
3064
|
|
|
2334
3065
|
// src/forge.ts
|
|
2335
|
-
import { homedir as
|
|
2336
|
-
import { join as
|
|
2337
|
-
import
|
|
3066
|
+
import { homedir as homedir6 } from "os";
|
|
3067
|
+
import { join as join10 } from "path";
|
|
3068
|
+
import process28 from "process";
|
|
2338
3069
|
|
|
2339
3070
|
// src/remote.ts
|
|
2340
3071
|
var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
|
|
@@ -2391,8 +3122,8 @@ function loginHosts(config) {
|
|
|
2391
3122
|
return hosts;
|
|
2392
3123
|
}
|
|
2393
3124
|
function teaConfigPath() {
|
|
2394
|
-
const base =
|
|
2395
|
-
return
|
|
3125
|
+
const base = process28.env.XDG_CONFIG_HOME;
|
|
3126
|
+
return join10(base !== undefined && base !== "" ? base : join10(homedir6(), ".config"), "tea", "config.yml");
|
|
2396
3127
|
}
|
|
2397
3128
|
async function readConfig() {
|
|
2398
3129
|
try {
|
|
@@ -2454,22 +3185,22 @@ function repoFlag(repo) {
|
|
|
2454
3185
|
return repo === undefined ? [] : ["--repo", repo];
|
|
2455
3186
|
}
|
|
2456
3187
|
function usesGt() {
|
|
2457
|
-
const PATH =
|
|
3188
|
+
const PATH = process29.env.PATH ?? "";
|
|
2458
3189
|
return Bun.which("tea", { PATH }) === null && Bun.which("gt", { PATH }) !== null;
|
|
2459
3190
|
}
|
|
2460
3191
|
var injected;
|
|
2461
3192
|
async function injectLogin(repo) {
|
|
2462
|
-
if (
|
|
3193
|
+
if (process29.env.GITEA_TOKEN !== undefined && process29.env.GITEA_TOKEN !== "")
|
|
2463
3194
|
return;
|
|
2464
3195
|
const login = await pickLogin(repo === undefined);
|
|
2465
3196
|
if (login === undefined)
|
|
2466
3197
|
return;
|
|
2467
3198
|
injected = login.token;
|
|
2468
|
-
|
|
2469
|
-
|
|
3199
|
+
process29.env.GITEA_TOKEN = login.token;
|
|
3200
|
+
process29.env.GITEA_CLI_HOST = login.url;
|
|
2470
3201
|
}
|
|
2471
3202
|
function scrub(text) {
|
|
2472
|
-
const token = injected ??
|
|
3203
|
+
const token = injected ?? process29.env.GITEA_TOKEN;
|
|
2473
3204
|
return token === undefined || token === "" ? text : text.replaceAll(token, "***");
|
|
2474
3205
|
}
|
|
2475
3206
|
function failureText(stdout, stderr, code) {
|
|
@@ -3025,7 +3756,7 @@ async function drop(args) {
|
|
|
3025
3756
|
}
|
|
3026
3757
|
|
|
3027
3758
|
// src/commands/ci.ts
|
|
3028
|
-
import
|
|
3759
|
+
import process30 from "process";
|
|
3029
3760
|
|
|
3030
3761
|
// src/git.ts
|
|
3031
3762
|
async function tagsAt(commit) {
|
|
@@ -3292,7 +4023,7 @@ async function ci2(args) {
|
|
|
3292
4023
|
return;
|
|
3293
4024
|
}
|
|
3294
4025
|
const json = values.json === true;
|
|
3295
|
-
const live = takesControlCodes(
|
|
4026
|
+
const live = takesControlCodes(process30.stderr) && takesControlCodes(process30.stdout) && !json && values.quiet !== true;
|
|
3296
4027
|
const runs = await waitForCi({
|
|
3297
4028
|
tool: "ft ci",
|
|
3298
4029
|
short,
|
|
@@ -3318,8 +4049,8 @@ async function ci2(args) {
|
|
|
3318
4049
|
return stall === undefined ? undefined : { message: `runs queued on ${short} are not moving: ${stall.reason}`, certain: stall.certain };
|
|
3319
4050
|
},
|
|
3320
4051
|
lines: (spinner, found, started) => [
|
|
3321
|
-
ciHeader(spinner, `CI on ${short}`, started,
|
|
3322
|
-
...(found ?? []).map((run) => ` ${runLine(run,
|
|
4052
|
+
ciHeader(spinner, `CI on ${short}`, started, process30.stderr),
|
|
4053
|
+
...(found ?? []).map((run) => ` ${runLine(run, process30.stderr, undefined, run.commit_sha.slice(0, 7))}`)
|
|
3323
4054
|
]
|
|
3324
4055
|
});
|
|
3325
4056
|
const status = overall(runs);
|
|
@@ -3336,7 +4067,7 @@ async function ci2(args) {
|
|
|
3336
4067
|
}
|
|
3337
4068
|
if (live) {
|
|
3338
4069
|
for (const run of runs)
|
|
3339
|
-
console.log(runLine(run,
|
|
4070
|
+
console.log(runLine(run, process30.stdout, undefined, run.commit_sha.slice(0, 7)));
|
|
3340
4071
|
}
|
|
3341
4072
|
if (status !== "failure") {
|
|
3342
4073
|
if (live)
|
|
@@ -3355,7 +4086,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
|
|
|
3355
4086
|
}
|
|
3356
4087
|
|
|
3357
4088
|
// src/commands/digest.ts
|
|
3358
|
-
import
|
|
4089
|
+
import process31 from "process";
|
|
3359
4090
|
var RUNS_SCANNED = 50;
|
|
3360
4091
|
var TITLE_WIDTH2 = 70;
|
|
3361
4092
|
var SHOWN = 8;
|
|
@@ -3405,7 +4136,7 @@ async function quietly(read) {
|
|
|
3405
4136
|
}
|
|
3406
4137
|
}
|
|
3407
4138
|
async function staleTodos() {
|
|
3408
|
-
const bin = Bun.which("src", { PATH:
|
|
4139
|
+
const bin = Bun.which("src", { PATH: process31.env.PATH ?? "" });
|
|
3409
4140
|
if (bin === null)
|
|
3410
4141
|
return [];
|
|
3411
4142
|
let found;
|
|
@@ -3427,8 +4158,8 @@ async function staleTodos() {
|
|
|
3427
4158
|
return [...byIssue.values()];
|
|
3428
4159
|
}
|
|
3429
4160
|
function claimLine(row, now) {
|
|
3430
|
-
const id = role("id",
|
|
3431
|
-
return [id(`#${row.number}`), row.holder, paint(
|
|
4161
|
+
const id = role("id", process31.stdout);
|
|
4162
|
+
return [id(`#${row.number}`), row.holder, paint(process31.stdout).dim(formatAge(row.since, now)), row.boxesTotal === 0 ? "" : `${row.boxesLeft}/${row.boxesTotal} left`, truncate(row.title, TITLE_WIDTH2)];
|
|
3432
4163
|
}
|
|
3433
4164
|
function capped2(lines) {
|
|
3434
4165
|
return lines.length > SHOWN ? [...lines.slice(0, SHOWN), `... ${lines.length - SHOWN} more`] : lines;
|
|
@@ -3439,13 +4170,13 @@ function renderDigest(digest, now = Date.now()) {
|
|
|
3439
4170
|
`) },
|
|
3440
4171
|
{ heading: "claimed, no live session here", tone: "warn", count: digest.away.length, lines: table(digest.away.map((row) => claimLine(row, now))).split(`
|
|
3441
4172
|
`) },
|
|
3442
|
-
{ heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status,
|
|
4173
|
+
{ heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status, process31.stdout)} (run ${run.id}) ${truncate(upTo(run.title, `
|
|
3443
4174
|
`), TITLE_WIDTH2)}`) },
|
|
3444
4175
|
{ heading: "unpushed commits", tone: "queued", count: digest.unpushed.length, lines: capped2(digest.unpushed) },
|
|
3445
|
-
{ heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path",
|
|
4176
|
+
{ heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path", process31.stdout)(file.path)}`)) },
|
|
3446
4177
|
{ heading: "stale TODO comments", tone: "skipped", count: digest.stale.length, lines: capped2(digest.stale.map((todo) => `${todo.issue} closed: ${todo.comments.map((each) => `${each.path}:${each.line}`).join(", ")}`)) }
|
|
3447
4178
|
].filter((each) => each.count > 0);
|
|
3448
|
-
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count,
|
|
4179
|
+
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count, process31.stdout, process31.env, tone)}
|
|
3449
4180
|
${lines.join(`
|
|
3450
4181
|
`).replace(LINE_START2, " ")}`).join(`
|
|
3451
4182
|
|
|
@@ -3531,7 +4262,7 @@ var tickUsage = `ft tick [<n>] <box>...
|
|
|
3531
4262
|
Ticks checklist boxes of issue <n>, each given by its number from \`ft issue\` or by text matching exactly one box, then posts the -m or -F comment.
|
|
3532
4263
|
With --closed, ticks instead every box opening with \`#<issue>\` whose issue is closed, as a release plan lists them.
|
|
3533
4264
|
|
|
3534
|
-
Without <n>
|
|
4265
|
+
Without <n> it takes the one open issue this session holds (\`ft take\`); a first argument that is a number is always the issue.`;
|
|
3535
4266
|
var tickExits = [[0, "it ticked the boxes"], [1, "Forgejo refuses"], [2, "a usage error or a box matching none or several"]];
|
|
3536
4267
|
var tickOptions = {
|
|
3537
4268
|
undo: { type: "boolean", short: "u", description: "untick them instead" },
|
|
@@ -3582,9 +4313,9 @@ ${tickUsage}`);
|
|
|
3582
4313
|
}
|
|
3583
4314
|
var fixedUsage = `ft fixed [<n>] [commit]...
|
|
3584
4315
|
|
|
3585
|
-
Comments "Fixed in <
|
|
3586
|
-
Without a commit it takes those on origin's default branch
|
|
3587
|
-
|
|
4316
|
+
Comments "Fixed in <a>, <b> and <c>: <subject>" on issue <n> and closes it.
|
|
4317
|
+
Without a commit it takes those on origin's default branch naming #<n> in their message, or HEAD when none does, and says which; without <n> it takes the one open issue this session holds (\`ft take\`).
|
|
4318
|
+
An issue with boxes left is refused unless --tick ticks them first, and every open issue listing \`- [ ] #<n>\` gets that line ticked.`;
|
|
3588
4319
|
var fixedExits = [[0, "it closed the issue"], [1, "the issue is already closed, has boxes left or Forgejo refuses"], [2, "a usage error"]];
|
|
3589
4320
|
var fixedOptions = {
|
|
3590
4321
|
message: { type: "string", short: "m", description: 'the line after "Fixed in <sha>:"' },
|
|
@@ -3786,7 +4517,7 @@ var editOptions = {
|
|
|
3786
4517
|
milestone: { type: "string", short: "m", description: "move the issue to this milestone, a title or an id; an empty value takes it out of its milestone" },
|
|
3787
4518
|
...repoOption
|
|
3788
4519
|
};
|
|
3789
|
-
async function
|
|
4520
|
+
async function edit2(args) {
|
|
3790
4521
|
const parsed = parse(args, editUsage, editOptions, { exits: editExits });
|
|
3791
4522
|
const { values, positionals } = parsed;
|
|
3792
4523
|
const number = issueNumber(positionals[0], editUsage);
|
|
@@ -3997,7 +4728,8 @@ ${await text(job)}`);
|
|
|
3997
4728
|
}
|
|
3998
4729
|
|
|
3999
4730
|
// src/commands/milestone.ts
|
|
4000
|
-
import
|
|
4731
|
+
import process32 from "process";
|
|
4732
|
+
init_text();
|
|
4001
4733
|
var TITLE_WIDTH3 = 60;
|
|
4002
4734
|
var LIST_LIMIT = 30;
|
|
4003
4735
|
var CONCURRENCY2 = 4;
|
|
@@ -4006,15 +4738,15 @@ function counts(milestone) {
|
|
|
4006
4738
|
}
|
|
4007
4739
|
function progressBar(milestone) {
|
|
4008
4740
|
const total = milestone.open_issues + milestone.closed_issues;
|
|
4009
|
-
return takesControlCodes(
|
|
4741
|
+
return takesControlCodes(process32.stdout) ? bar(total === 0 ? 0 : milestone.closed_issues / total, { width: 16 }) : "";
|
|
4010
4742
|
}
|
|
4011
4743
|
function milestoneCells(each, showState) {
|
|
4012
4744
|
const drawn = progressBar(each);
|
|
4013
4745
|
return [String(each.id), truncate(each.title, TITLE_WIDTH3), `${each.open_issues} open`, `${each.closed_issues} closed`, ...drawn === "" ? [] : [drawn], progress(each), dueDate(each) === "" ? "" : `due ${dueDate(each)}`, ...showState ? [each.state] : []];
|
|
4014
4746
|
}
|
|
4015
4747
|
async function printWithIssues(list, repo) {
|
|
4016
|
-
const colors = paint(
|
|
4017
|
-
const id = role("id",
|
|
4748
|
+
const colors = paint(process32.stdout);
|
|
4749
|
+
const id = role("id", process32.stdout);
|
|
4018
4750
|
const issuesOf = await pool(list, concurrencyOf(CONCURRENCY2), async (each) => Promise.all([openIssues(undefined, repo, each.id), closedIssues(each.id, repo)]));
|
|
4019
4751
|
const blocks = list.map((each, index) => {
|
|
4020
4752
|
const byNumber = (left, right) => left.number - right.number;
|
|
@@ -4025,7 +4757,7 @@ async function printWithIssues(list, repo) {
|
|
|
4025
4757
|
...open.map((issue) => ` ${id(`#${issue.number}`)} ${truncate(issue.title, TITLE_WIDTH3)}`),
|
|
4026
4758
|
...closed.map((issue) => colors.dim(` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)} (closed)`))
|
|
4027
4759
|
];
|
|
4028
|
-
return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined,
|
|
4760
|
+
return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined, process32.stdout, process32.env, "accent"), ...lines].join(`
|
|
4029
4761
|
`);
|
|
4030
4762
|
});
|
|
4031
4763
|
console.log(blocks.join(`
|
|
@@ -4113,7 +4845,7 @@ ${closeUsage2}`);
|
|
|
4113
4845
|
}
|
|
4114
4846
|
const open = await openIssues(undefined, values.repo, found.id);
|
|
4115
4847
|
if (open.length > 0 && values.force !== true)
|
|
4116
|
-
fail(`milestone ${found.title} has ${
|
|
4848
|
+
fail(`milestone ${found.title} has ${bo(open.length, "open issue")}:
|
|
4117
4849
|
${open.map((issue) => ` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)}`).join(`
|
|
4118
4850
|
`)}`, 1, `${runHint(`ft milestone close ${found.title} --force`, "close it with them open")}, or move them with \`ft edit <n> -m <milestone>\``);
|
|
4119
4851
|
await closeMilestone(found.id, values.repo);
|
|
@@ -4282,8 +5014,8 @@ function report2(plan, added, skipped) {
|
|
|
4282
5014
|
}
|
|
4283
5015
|
|
|
4284
5016
|
// src/commands/release.ts
|
|
4285
|
-
import { basename as basename3, join as
|
|
4286
|
-
import
|
|
5017
|
+
import { basename as basename3, join as join14 } from "path";
|
|
5018
|
+
import process34 from "process";
|
|
4287
5019
|
var {$: $2 } = globalThis.Bun;
|
|
4288
5020
|
|
|
4289
5021
|
// src/commands/watch.ts
|
|
@@ -4423,6 +5155,14 @@ async function watch2(args) {
|
|
|
4423
5155
|
|
|
4424
5156
|
// src/commands/release-checks.ts
|
|
4425
5157
|
var limits = { pushMs: 5 * 60000 };
|
|
5158
|
+
async function pushToOrigin(refspecs, onStart) {
|
|
5159
|
+
const prompts = askpass();
|
|
5160
|
+
try {
|
|
5161
|
+
return await runTool("git push", ["git", "push", ...refspecs], { timeoutMs: limits.pushMs, onStart, env: prompts?.env });
|
|
5162
|
+
} finally {
|
|
5163
|
+
prompts?.close();
|
|
5164
|
+
}
|
|
5165
|
+
}
|
|
4426
5166
|
var NO_RUN2 = 3 * 60000;
|
|
4427
5167
|
var RUNS_LOOKED_AT = 20;
|
|
4428
5168
|
async function alreadyPassed(sha) {
|
|
@@ -4439,7 +5179,7 @@ async function testsPass(sha, branch, timeout, json = false) {
|
|
|
4439
5179
|
const held = holdSignals();
|
|
4440
5180
|
let push;
|
|
4441
5181
|
try {
|
|
4442
|
-
push = await
|
|
5182
|
+
push = await pushToOrigin(["origin", `${sha}:refs/heads/${branch}`], (child) => held.forward(child));
|
|
4443
5183
|
} finally {
|
|
4444
5184
|
held.release();
|
|
4445
5185
|
}
|
|
@@ -4459,7 +5199,7 @@ ${push.stderr.trim()}`, 1);
|
|
|
4459
5199
|
|
|
4460
5200
|
// src/commands/release-many.ts
|
|
4461
5201
|
import { readdir } from "fs/promises";
|
|
4462
|
-
import { join as
|
|
5202
|
+
import { join as join11 } from "path";
|
|
4463
5203
|
|
|
4464
5204
|
// src/commands/release-version.ts
|
|
4465
5205
|
var LEVELS = new Set(["patch", "minor", "major", "prepatch", "preminor", "premajor", "prerelease"]);
|
|
@@ -4508,11 +5248,11 @@ function parseTargets(spec, level) {
|
|
|
4508
5248
|
});
|
|
4509
5249
|
}
|
|
4510
5250
|
async function publishable() {
|
|
4511
|
-
const root =
|
|
5251
|
+
const root = join11(await git(["rev-parse", "--show-toplevel"]), "packages");
|
|
4512
5252
|
const folders = (await readdir(root, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name).toSorted();
|
|
4513
5253
|
const found = [];
|
|
4514
5254
|
for (const folder of folders) {
|
|
4515
|
-
const file = Bun.file(
|
|
5255
|
+
const file = Bun.file(join11(root, folder, "package.json"));
|
|
4516
5256
|
if (await file.exists() && (await file.json()).private !== true)
|
|
4517
5257
|
found.push(folder);
|
|
4518
5258
|
}
|
|
@@ -4520,13 +5260,13 @@ async function publishable() {
|
|
|
4520
5260
|
}
|
|
4521
5261
|
|
|
4522
5262
|
// src/commands/release-plan.ts
|
|
4523
|
-
import { basename as basename2, join as
|
|
4524
|
-
import
|
|
5263
|
+
import { basename as basename2, join as join12, relative } from "path";
|
|
5264
|
+
import process33 from "process";
|
|
4525
5265
|
async function planOf({ level, dir, prefix }, registry) {
|
|
4526
|
-
const file = Bun.file(
|
|
5266
|
+
const file = Bun.file(join12(dir ?? ".", "package.json"));
|
|
4527
5267
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
4528
|
-
const name = pkg?.name ?? basename2(dir ??
|
|
4529
|
-
const where = dir === undefined ? "" : ` in ${relative(
|
|
5268
|
+
const name = pkg?.name ?? basename2(dir ?? process33.cwd());
|
|
5269
|
+
const where = dir === undefined ? "" : ` in ${relative(process33.cwd(), dir) || "."}`;
|
|
4530
5270
|
let version;
|
|
4531
5271
|
let bump;
|
|
4532
5272
|
if (level === undefined) {
|
|
@@ -4538,7 +5278,7 @@ async function planOf({ level, dir, prefix }, registry) {
|
|
|
4538
5278
|
console.log(`would release ${name} ${version}, tagged ${tag}`);
|
|
4539
5279
|
} else {
|
|
4540
5280
|
if (pkg?.version === undefined)
|
|
4541
|
-
fail(`no version in ${
|
|
5281
|
+
fail(`no version in ${join12(dir ?? ".", "package.json")}`);
|
|
4542
5282
|
version = nextVersion(pkg.version, level);
|
|
4543
5283
|
bump = dir === undefined ? `bun pm version ${level}, which commits and tags ${prefix}${version}` : `bun pm version ${level} --no-git-tag-version${where}, then commit it with bun.lock refreshed and tag ${prefix}${version}`;
|
|
4544
5284
|
console.log(`would release ${name} ${pkg.version} -> ${version}, tagged ${prefix}${version}`);
|
|
@@ -4565,25 +5305,26 @@ async function printPlan({ releases, branch, base, timeout, registry }) {
|
|
|
4565
5305
|
}
|
|
4566
5306
|
|
|
4567
5307
|
// src/commands/release-steps.ts
|
|
4568
|
-
import { join as
|
|
5308
|
+
import { join as join13, relative as relative2, resolve as resolve5 } from "path";
|
|
5309
|
+
init_text();
|
|
4569
5310
|
var {$ } = globalThis.Bun;
|
|
4570
5311
|
var registryWait = { tries: 12, poll: 5000 };
|
|
4571
5312
|
var REGISTRY_INFO_MS = 30000;
|
|
4572
5313
|
async function packageDir(value) {
|
|
4573
|
-
for (const dir of [resolve5(value),
|
|
4574
|
-
if (await Bun.file(
|
|
5314
|
+
for (const dir of [resolve5(value), join13(await git(["rev-parse", "--show-toplevel"]), "packages", value)]) {
|
|
5315
|
+
if (await Bun.file(join13(dir, "package.json")).exists())
|
|
4575
5316
|
return dir;
|
|
4576
5317
|
}
|
|
4577
5318
|
fail(`no package.json in ${value} nor in packages/${value}`);
|
|
4578
5319
|
}
|
|
4579
5320
|
async function commitPackageBump(dir, prefix) {
|
|
4580
|
-
const { version } = await Bun.file(
|
|
5321
|
+
const { version } = await Bun.file(join13(dir, "package.json")).json();
|
|
4581
5322
|
const root = await git(["rev-parse", "--show-toplevel"]);
|
|
4582
5323
|
const tag = `${prefix}${version}`;
|
|
4583
5324
|
const lock = await $`bun install --lockfile-only`.cwd(root).quiet().nothrow();
|
|
4584
5325
|
if (lock.exitCode !== 0)
|
|
4585
5326
|
fail(`bun install --lockfile-only after the bump: ${lock.stderr.toString().trim()}`);
|
|
4586
|
-
await git(["add",
|
|
5327
|
+
await git(["add", join13(dir, "package.json"), join13(root, "bun.lock")]);
|
|
4587
5328
|
await git(["commit", "-q", "-m", tag]);
|
|
4588
5329
|
await git(["tag", "-a", tag, "-m", tag]);
|
|
4589
5330
|
}
|
|
@@ -4607,11 +5348,11 @@ async function rollBack(preBump, dirs) {
|
|
|
4607
5348
|
try {
|
|
4608
5349
|
if (dirs.length > 0) {
|
|
4609
5350
|
const root = await git(["rev-parse", "--show-toplevel"]);
|
|
4610
|
-
const paths = [...dirs.map((dir) =>
|
|
5351
|
+
const paths = [...dirs.map((dir) => join13(dir, "package.json")), join13(root, "bun.lock")].map((path) => relative2(root, path));
|
|
4611
5352
|
const tracked = (await git(["ls-tree", "-r", "--full-tree", "--name-only", "HEAD", "--", ...paths])).split(`
|
|
4612
5353
|
`).filter((path) => path !== "");
|
|
4613
5354
|
if (tracked.length > 0)
|
|
4614
|
-
await git(["restore", "--source=HEAD", "--staged", "--worktree", "--", ...tracked.map((path) =>
|
|
5355
|
+
await git(["restore", "--source=HEAD", "--staged", "--worktree", "--", ...tracked.map((path) => join13(root, path))]);
|
|
4615
5356
|
}
|
|
4616
5357
|
for (const commit of (await git(["rev-list", `${preBump}..HEAD`])).split(`
|
|
4617
5358
|
`).filter(Boolean)) {
|
|
@@ -4630,7 +5371,7 @@ async function settleMilestone(version, tag, say = console.log) {
|
|
|
4630
5371
|
if (found === undefined)
|
|
4631
5372
|
return;
|
|
4632
5373
|
const [done, left] = await Promise.all([closedIssues(found.id), openIssues(undefined, undefined, found.id)]);
|
|
4633
|
-
say(`milestone ${found.title}: ${
|
|
5374
|
+
say(`milestone ${found.title}: ${bo(done.length, "closed issue")}${done.length === 0 ? "" : `
|
|
4634
5375
|
${done.map((issue) => ` #${issue.number} ${issue.title}`).join(`
|
|
4635
5376
|
`)}`}`);
|
|
4636
5377
|
if (left.length > 0)
|
|
@@ -4649,14 +5390,10 @@ ft release <level> -p <a,b:minor,...>
|
|
|
4649
5390
|
ft release <level> --all
|
|
4650
5391
|
ft release --tagged
|
|
4651
5392
|
|
|
4652
|
-
Cuts a release from the default branch:
|
|
4653
|
-
|
|
4654
|
-
--package releases
|
|
4655
|
-
|
|
4656
|
-
A refused or interrupted push drops the bump commits and their tags, so a retry starts clean; with --tagged the commit and tag are yours and stay.
|
|
4657
|
-
Once released, an open milestone titled like the version (\`1.2.0\`, \`v1.2.0\` or the tag) has its closed issues listed and is closed; a failure there only warns.
|
|
4658
|
-
--dry-run checks the same and prints the plan: the version bump, the tag, the pushes and the runs and registry it would wait for, changing nothing.
|
|
4659
|
-
--json prints {released, tag, package, version, status, runs, failedJobs, url} on stdout and the progress on stderr, an array of them with --package a,b or --all; it does not take --dry-run.`;
|
|
5393
|
+
Cuts a release from the default branch: waits for the runs on HEAD, bumps and tags with \`bun pm version\`, pushes, then waits for the runs and the registry.
|
|
5394
|
+
Failing tests stop it before anything is bumped or tagged, and a refused or interrupted push drops the bump commits and their tags; with --tagged the commit and tag are yours and stay.
|
|
5395
|
+
--package releases workspace packages tagged \`<folder>-v<version>\`, each with an optional level of its own (\`-p ft:minor,db\`), --all every published one, in one atomic push.
|
|
5396
|
+
Once released, an open milestone titled like the version has its closed issues listed and is closed; a failure there only warns.`;
|
|
4660
5397
|
var EXITS5 = [[0, "released or planned"], [1, "a run fails, origin refuses a push or the registry never serves the version"], [2, "a timeout, a stalled queue, a refusal before anything ran (another branch, uncommitted changes, origin ahead) or a usage error"]];
|
|
4661
5398
|
var options6 = {
|
|
4662
5399
|
tagged: { type: "boolean", description: "push the version commit and tag already at HEAD instead of bumping" },
|
|
@@ -4665,7 +5402,7 @@ var options6 = {
|
|
|
4665
5402
|
"no-registry": { type: "boolean", description: "do not wait for the registry to serve the new version" },
|
|
4666
5403
|
"dry-run": { type: "boolean", description: "print what the release would do, changing nothing" },
|
|
4667
5404
|
timeout: { type: "string", short: "t", description: "how long to wait for the runs (15m), a bare number in minutes" },
|
|
4668
|
-
json: jsonOption("
|
|
5405
|
+
json: jsonOption("{released, tag, package, version, status, runs, failedJobs, url} on stdout and the progress on stderr, an array with several packages; not with --dry-run")
|
|
4669
5406
|
};
|
|
4670
5407
|
async function release(args) {
|
|
4671
5408
|
const parsed = parse(args, usage6, options6, { exits: EXITS5 });
|
|
@@ -4733,7 +5470,7 @@ ${usage6}`);
|
|
|
4733
5470
|
const tags = bumped.map((each) => each.tag);
|
|
4734
5471
|
let push;
|
|
4735
5472
|
try {
|
|
4736
|
-
push = await
|
|
5473
|
+
push = await pushToOrigin(["--atomic", "origin", `HEAD:refs/heads/${branch}`, ...tags.map((tag) => `refs/tags/${tag}`)], (child) => held.forward(child));
|
|
4737
5474
|
} catch (error) {
|
|
4738
5475
|
isPushUnknown = true;
|
|
4739
5476
|
fail(`${error instanceof Error ? error.message : String(error)}, so ${tags.join(", ")} and ${tags.length === 1 ? "its commit are" : "their commits are"} kept: the push may have landed`, 2, tags.length === 1 ? `git ls-remote origin refs/tags/${tags[0]} tells; if it is there, ft release --tagged waits for its runs` : `git ls-remote --tags origin tells; if they are there, ft watch --after ${before} waits for their runs`);
|
|
@@ -4752,7 +5489,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4752
5489
|
}
|
|
4753
5490
|
const heads = new Set(bumped.map((each) => each.head));
|
|
4754
5491
|
const manifests = await Promise.all(bumped.map(async (each) => {
|
|
4755
|
-
const file = Bun.file(
|
|
5492
|
+
const file = Bun.file(join14(each.dir ?? ".", "package.json"));
|
|
4756
5493
|
return await file.exists() ? await file.json() : undefined;
|
|
4757
5494
|
}));
|
|
4758
5495
|
const released = new Set;
|
|
@@ -4771,7 +5508,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4771
5508
|
if (late !== undefined)
|
|
4772
5509
|
fail(`interrupted by ${late} after ${bumped.map((each) => each.tag).join(", ")} ${bumped.length === 1 ? "was pushed: its runs are" : "were pushed: their runs are"} not waited for`, exitCodeOf(null, late));
|
|
4773
5510
|
say(`pushed ${branch} and ${bumped.map((each) => each.tag).join(", ")}, waiting for their runs`);
|
|
4774
|
-
followed = await followRuns((runs) => runs.filter((run) => run.id > before && heads.has(run.commit_sha)), timeout, undefined, NO_RUN2, json ?
|
|
5511
|
+
followed = await followRuns((runs) => runs.filter((run) => run.id > before && heads.has(run.commit_sha)), timeout, undefined, NO_RUN2, json ? process34.stderr : process34.stdout, { json });
|
|
4775
5512
|
if (followed.code !== 0) {
|
|
4776
5513
|
report();
|
|
4777
5514
|
return followed.code;
|
|
@@ -4946,7 +5683,7 @@ async function runs(args) {
|
|
|
4946
5683
|
}
|
|
4947
5684
|
|
|
4948
5685
|
// src/cli.ts
|
|
4949
|
-
|
|
5686
|
+
process35.exitCode = await runCli({
|
|
4950
5687
|
name: "ft",
|
|
4951
5688
|
about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
|
|
4952
5689
|
replaces: "tea api calls piped through jq, and sleep loops waiting on CI",
|
|
@@ -4963,7 +5700,7 @@ process31.exitCode = await runCli({
|
|
|
4963
5700
|
drop: { run: drop, summary: "give back an issue this session took", group: "Issues and claims" },
|
|
4964
5701
|
issue: { run: issue, summary: "an issue's claim, description and numbered boxes, -c comments", group: "Issues and claims" },
|
|
4965
5702
|
new: { run: newIssue, summary: "create an issue from -t and a description file or stdin", group: "Issues and claims" },
|
|
4966
|
-
edit: { run:
|
|
5703
|
+
edit: { run: edit2, summary: "replace an issue's title or description, from a file or stdin", group: "Issues and claims" },
|
|
4967
5704
|
tick: { run: tick, summary: "tick checklist boxes of an issue, -m to comment too", group: "Issues and claims" },
|
|
4968
5705
|
comment: { run: commentOn, summary: "comment on an issue, from stdin when no text is given", group: "Issues and claims" },
|
|
4969
5706
|
fixed: { run: fixed, summary: 'comment "Fixed in <sha>" and close an issue', group: "Issues and claims" },
|