@kaynooo/cli-forgejo 0.30.2 → 0.30.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +941 -230
- package/package.json +6 -6
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,12 +595,18 @@ 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
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
576
612
|
}
|
|
@@ -607,7 +643,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
|
607
643
|
return [];
|
|
608
644
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
609
645
|
}
|
|
610
|
-
var MAX_INLINE_CHOICES = 24;
|
|
611
646
|
function optionRows(options, colors = paint(process8.stdout)) {
|
|
612
647
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
613
648
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
@@ -622,9 +657,16 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
622
657
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
623
658
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
624
659
|
}
|
|
660
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
661
|
+
var init_help = __esm(() => {
|
|
662
|
+
init_mode();
|
|
663
|
+
init_style();
|
|
664
|
+
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
665
|
+
USAGE_PREFIX = /^usage:\s*/i;
|
|
666
|
+
FULL_STOP = /\.$/;
|
|
667
|
+
});
|
|
625
668
|
|
|
626
669
|
// ../kit/src/text.ts
|
|
627
|
-
var ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
|
|
628
670
|
function stripAnsi(text) {
|
|
629
671
|
return text.replace(ANSI, "");
|
|
630
672
|
}
|
|
@@ -653,9 +695,13 @@ function closest(name, names) {
|
|
|
653
695
|
const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
|
|
654
696
|
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
655
697
|
}
|
|
698
|
+
var ANSI;
|
|
699
|
+
var init_text2 = __esm(() => {
|
|
700
|
+
ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
|
|
701
|
+
});
|
|
702
|
+
|
|
656
703
|
// ../kit/src/input.ts
|
|
657
704
|
import process9 from "process";
|
|
658
|
-
var WHOLE = /^\d+$/;
|
|
659
705
|
function wholeNumber(value, name, fallback, min = 1) {
|
|
660
706
|
if (value === undefined)
|
|
661
707
|
return fallback;
|
|
@@ -664,8 +710,6 @@ function wholeNumber(value, name, fallback, min = 1) {
|
|
|
664
710
|
badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
|
|
665
711
|
return number;
|
|
666
712
|
}
|
|
667
|
-
var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
668
|
-
var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
669
713
|
function duration(value, name, fallback, unit = "s") {
|
|
670
714
|
if (value === undefined)
|
|
671
715
|
return fallback;
|
|
@@ -686,44 +730,30 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
|
686
730
|
fail(`no file ${path}`);
|
|
687
731
|
return file.text();
|
|
688
732
|
}
|
|
733
|
+
var WHOLE, DURATION, UNIT_MS;
|
|
734
|
+
var init_input = __esm(() => {
|
|
735
|
+
init_args();
|
|
736
|
+
WHOLE = /^\d+$/;
|
|
737
|
+
DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
738
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
739
|
+
});
|
|
689
740
|
|
|
690
741
|
// ../kit/src/args.ts
|
|
691
|
-
|
|
742
|
+
import process10 from "process";
|
|
743
|
+
import { parseArgs } from "util";
|
|
692
744
|
function jsonOption(holds) {
|
|
693
745
|
return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
|
|
694
746
|
}
|
|
695
747
|
function copyOption(what) {
|
|
696
748
|
return { type: "boolean", description: `also copy ${what} to the clipboard` };
|
|
697
749
|
}
|
|
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
750
|
function fail(message, code = 2, hint) {
|
|
709
751
|
throw new Exit(message, code, hint);
|
|
710
752
|
}
|
|
711
|
-
|
|
712
|
-
class UsageError extends Exit {
|
|
713
|
-
constructor(message, hint) {
|
|
714
|
-
super(message, 2, hint);
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
753
|
function badUsage(message) {
|
|
718
754
|
throw new UsageError(message);
|
|
719
755
|
}
|
|
720
756
|
|
|
721
|
-
class HelpShown extends Exit {
|
|
722
|
-
constructor() {
|
|
723
|
-
super("help shown", 0);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
757
|
class Completing {
|
|
728
758
|
options;
|
|
729
759
|
positionals;
|
|
@@ -734,11 +764,6 @@ class Completing {
|
|
|
734
764
|
this.candidates = candidates;
|
|
735
765
|
}
|
|
736
766
|
}
|
|
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
767
|
function applyOutput(color, plain, env = process10.env) {
|
|
743
768
|
const when = plain === true ? "never" : color ?? "auto";
|
|
744
769
|
if (when === "auto")
|
|
@@ -892,7 +917,6 @@ function parseError(error) {
|
|
|
892
917
|
const message = upTo(error instanceof Error ? error.message : String(error), ". ");
|
|
893
918
|
return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
|
|
894
919
|
}
|
|
895
|
-
var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
896
920
|
function nearestOption(message, options, allowNegative) {
|
|
897
921
|
const typed = UNKNOWN_OPTION.exec(message)?.[1];
|
|
898
922
|
if (typed === undefined)
|
|
@@ -908,6 +932,488 @@ function nearestOption(message, options, allowNegative) {
|
|
|
908
932
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
909
933
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
910
934
|
}
|
|
935
|
+
var DASHES, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
936
|
+
var init_args = __esm(() => {
|
|
937
|
+
init_format();
|
|
938
|
+
init_help();
|
|
939
|
+
init_text2();
|
|
940
|
+
init_help();
|
|
941
|
+
init_input();
|
|
942
|
+
DASHES = /^-+/;
|
|
943
|
+
Exit = class Exit extends Error {
|
|
944
|
+
code;
|
|
945
|
+
hint;
|
|
946
|
+
constructor(message, code, hint) {
|
|
947
|
+
super(message);
|
|
948
|
+
this.code = code;
|
|
949
|
+
this.hint = hint;
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
UsageError = class UsageError extends Exit {
|
|
953
|
+
constructor(message, hint) {
|
|
954
|
+
super(message, 2, hint);
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
HelpShown = class HelpShown extends Exit {
|
|
958
|
+
constructor() {
|
|
959
|
+
super("help shown", 0);
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
completion = { active: false };
|
|
963
|
+
OUTPUT_OPTIONS = {
|
|
964
|
+
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
965
|
+
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
966
|
+
};
|
|
967
|
+
UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
968
|
+
});
|
|
969
|
+
|
|
970
|
+
// ../kit/src/folders.ts
|
|
971
|
+
import { homedir as homedir3 } from "os";
|
|
972
|
+
import { join as join4 } from "path";
|
|
973
|
+
import process16 from "process";
|
|
974
|
+
function cacheFolder({ home = homedir3(), env = process16.env } = {}) {
|
|
975
|
+
return env.XDG_CACHE_HOME ?? join4(home, ".cache");
|
|
976
|
+
}
|
|
977
|
+
var SKIPPED_FOLDERS;
|
|
978
|
+
var init_folders = __esm(() => {
|
|
979
|
+
init_user_config();
|
|
980
|
+
SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
// ../kit/src/answers.ts
|
|
984
|
+
import { mkdirSync, readFileSync as readFileSync4, writeFileSync } from "fs";
|
|
985
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
986
|
+
function answersFile() {
|
|
987
|
+
return join5(cacheFolder(), "kaynooo-cli", "answers.json");
|
|
988
|
+
}
|
|
989
|
+
function stored() {
|
|
990
|
+
try {
|
|
991
|
+
const parsed = JSON.parse(readFileSync4(answersFile(), "utf-8"));
|
|
992
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
993
|
+
return {};
|
|
994
|
+
return Object.fromEntries(Object.entries(parsed).filter((entry) => Array.isArray(entry[1]) && entry[1].every((answer) => typeof answer === "string")));
|
|
995
|
+
} catch {
|
|
996
|
+
return {};
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
function earlierAnswers(key) {
|
|
1000
|
+
return stored()[key] ?? [];
|
|
1001
|
+
}
|
|
1002
|
+
function rememberAnswer(key, answer) {
|
|
1003
|
+
const all = stored();
|
|
1004
|
+
const file = answersFile();
|
|
1005
|
+
all[key] = [answer, ...(all[key] ?? []).filter((earlier) => earlier !== answer)].slice(0, KEPT);
|
|
1006
|
+
try {
|
|
1007
|
+
mkdirSync(dirname2(file), { recursive: true });
|
|
1008
|
+
writeFileSync(file, JSON.stringify(all));
|
|
1009
|
+
} catch {}
|
|
1010
|
+
}
|
|
1011
|
+
var KEPT = 50;
|
|
1012
|
+
var init_answers = __esm(() => {
|
|
1013
|
+
init_folders();
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
// ../kit/src/job.ts
|
|
1017
|
+
import process17 from "process";
|
|
1018
|
+
function stopJob() {
|
|
1019
|
+
process17.kill(0, "SIGTSTP");
|
|
1020
|
+
}
|
|
1021
|
+
var init_job = () => {};
|
|
1022
|
+
|
|
1023
|
+
// ../kit/src/picker/line.ts
|
|
1024
|
+
function isEditKey(key) {
|
|
1025
|
+
return EDIT_KEYS.has(key);
|
|
1026
|
+
}
|
|
1027
|
+
function endsKills(key) {
|
|
1028
|
+
return typeof key !== "object" && !isEditKey(key);
|
|
1029
|
+
}
|
|
1030
|
+
function isWord(char) {
|
|
1031
|
+
return char !== undefined && WORD_CHARACTER.test(char);
|
|
1032
|
+
}
|
|
1033
|
+
function wordStart(chars, from) {
|
|
1034
|
+
let at = from;
|
|
1035
|
+
while (at > 0 && !isWord(chars[at - 1]))
|
|
1036
|
+
at--;
|
|
1037
|
+
while (at > 0 && isWord(chars[at - 1]))
|
|
1038
|
+
at--;
|
|
1039
|
+
return at;
|
|
1040
|
+
}
|
|
1041
|
+
function wordEnd(chars, from) {
|
|
1042
|
+
let at = from;
|
|
1043
|
+
while (at < chars.length && !isWord(chars[at]))
|
|
1044
|
+
at++;
|
|
1045
|
+
while (at < chars.length && isWord(chars[at]))
|
|
1046
|
+
at++;
|
|
1047
|
+
return at;
|
|
1048
|
+
}
|
|
1049
|
+
function spacedStart(chars, from) {
|
|
1050
|
+
let at = from;
|
|
1051
|
+
while (at > 0 && SPACE.test(chars[at - 1] ?? ""))
|
|
1052
|
+
at--;
|
|
1053
|
+
while (at > 0 && !SPACE.test(chars[at - 1] ?? ""))
|
|
1054
|
+
at--;
|
|
1055
|
+
return at;
|
|
1056
|
+
}
|
|
1057
|
+
function cut(chars, from, to) {
|
|
1058
|
+
return { text: [...chars.slice(0, from), ...chars.slice(to)].join(""), caret: from };
|
|
1059
|
+
}
|
|
1060
|
+
function insert(chars, at, text) {
|
|
1061
|
+
const typed = [...text];
|
|
1062
|
+
return { text: [...chars.slice(0, at), ...typed, ...chars.slice(at)].join(""), caret: at + typed.length };
|
|
1063
|
+
}
|
|
1064
|
+
function editLine(line, key) {
|
|
1065
|
+
const { killed = "", chained = false } = line;
|
|
1066
|
+
const chars = [...line.text];
|
|
1067
|
+
const at = Math.min(Math.max(line.caret, 0), chars.length);
|
|
1068
|
+
const edited = edit(chars, at, key, killed);
|
|
1069
|
+
if (typeof key === "object" || !BACKWARD_KILLS.has(key) && !FORWARD_KILLS.has(key))
|
|
1070
|
+
return line.killed === undefined ? edited : { ...edited, killed };
|
|
1071
|
+
const taken = chars.slice(edited.caret, edited.caret + chars.length - [...edited.text].length).join("");
|
|
1072
|
+
if (taken === "")
|
|
1073
|
+
return { ...edited, killed, chained };
|
|
1074
|
+
if (!chained)
|
|
1075
|
+
return { ...edited, killed: taken, chained: true };
|
|
1076
|
+
return { ...edited, killed: BACKWARD_KILLS.has(key) ? taken + killed : killed + taken, chained: true };
|
|
1077
|
+
}
|
|
1078
|
+
function edit(chars, at, key, killed) {
|
|
1079
|
+
const text = chars.join("");
|
|
1080
|
+
if (typeof key === "object")
|
|
1081
|
+
return insert(chars, at, key.text);
|
|
1082
|
+
switch (key) {
|
|
1083
|
+
case "left":
|
|
1084
|
+
return { text, caret: Math.max(at - 1, 0) };
|
|
1085
|
+
case "right":
|
|
1086
|
+
return { text, caret: Math.min(at + 1, chars.length) };
|
|
1087
|
+
case "wordleft":
|
|
1088
|
+
return { text, caret: wordStart(chars, at) };
|
|
1089
|
+
case "wordright":
|
|
1090
|
+
return { text, caret: wordEnd(chars, at) };
|
|
1091
|
+
case "linestart":
|
|
1092
|
+
return { text, caret: 0 };
|
|
1093
|
+
case "lineend":
|
|
1094
|
+
return { text, caret: chars.length };
|
|
1095
|
+
case "erase":
|
|
1096
|
+
return cut(chars, Math.max(at - 1, 0), at);
|
|
1097
|
+
case "delete":
|
|
1098
|
+
return cut(chars, at, Math.min(at + 1, chars.length));
|
|
1099
|
+
case "word":
|
|
1100
|
+
return cut(chars, spacedStart(chars, at), at);
|
|
1101
|
+
case "killword":
|
|
1102
|
+
return cut(chars, wordStart(chars, at), at);
|
|
1103
|
+
case "killnext":
|
|
1104
|
+
return cut(chars, at, wordEnd(chars, at));
|
|
1105
|
+
case "clear":
|
|
1106
|
+
return cut(chars, 0, at);
|
|
1107
|
+
case "killend":
|
|
1108
|
+
return cut(chars, at, chars.length);
|
|
1109
|
+
case "yank":
|
|
1110
|
+
return insert(chars, at, killed);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
function visible({ text, caret }, room) {
|
|
1114
|
+
const chars = [...text];
|
|
1115
|
+
const at = Math.min(Math.max(caret, 0), chars.length);
|
|
1116
|
+
const cells = at === chars.length ? [...chars, " "] : chars;
|
|
1117
|
+
const widths = cells.map((char) => Bun.stringWidth(char));
|
|
1118
|
+
const width = (from, to) => widths.slice(from, to).reduce((sum, size) => sum + size, 0);
|
|
1119
|
+
const fits = (from, to) => (from > 0 ? 1 : 0) + width(from, to) + (to < cells.length ? 1 : 0) <= room;
|
|
1120
|
+
let start = at;
|
|
1121
|
+
let end = at + 1;
|
|
1122
|
+
while (start > 0 && fits(start - 1, end))
|
|
1123
|
+
start--;
|
|
1124
|
+
while (end < cells.length && fits(start, end + 1))
|
|
1125
|
+
end++;
|
|
1126
|
+
const left = start > 0 ? "\u2026" : "";
|
|
1127
|
+
const right = end < cells.length ? "\u2026" : "";
|
|
1128
|
+
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) };
|
|
1129
|
+
}
|
|
1130
|
+
var EDIT_KEYS, BACKWARD_KILLS, FORWARD_KILLS, WORD_CHARACTER, SPACE;
|
|
1131
|
+
var init_line = __esm(() => {
|
|
1132
|
+
EDIT_KEYS = new Set(["left", "right", "wordleft", "wordright", "linestart", "lineend", "erase", "delete", "word", "killword", "killnext", "clear", "killend", "yank"]);
|
|
1133
|
+
BACKWARD_KILLS = new Set(["word", "killword", "clear"]);
|
|
1134
|
+
FORWARD_KILLS = new Set(["killnext", "killend"]);
|
|
1135
|
+
WORD_CHARACTER = /[\p{L}\p{N}_]/u;
|
|
1136
|
+
SPACE = /\s/;
|
|
1137
|
+
});
|
|
1138
|
+
|
|
1139
|
+
// ../kit/src/picker/score.ts
|
|
1140
|
+
var BOUNDARY_AFTER, NONE;
|
|
1141
|
+
var init_score = __esm(() => {
|
|
1142
|
+
BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
|
|
1143
|
+
NONE = Number.NEGATIVE_INFINITY;
|
|
1144
|
+
});
|
|
1145
|
+
|
|
1146
|
+
// ../kit/src/picker/state.ts
|
|
1147
|
+
function repeat(value, count) {
|
|
1148
|
+
return Array.from({ length: count }).fill(value);
|
|
1149
|
+
}
|
|
1150
|
+
function parseKeys(input, paste = { active: false }, ctrls = []) {
|
|
1151
|
+
const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
|
|
1152
|
+
return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
|
|
1153
|
+
const wheel = MOUSE.exec(sequence)?.[1];
|
|
1154
|
+
if (wheel !== undefined)
|
|
1155
|
+
return repeat(wheel === "64" ? "up" : "down", wheel === "64" || wheel === "65" ? WHEEL_LINES : 0);
|
|
1156
|
+
const named = codes.get(sequence);
|
|
1157
|
+
const key = named === undefined ? KEYS[sequence] : { ctrl: named };
|
|
1158
|
+
if (sequence === PASTE_START || sequence === PASTE_END) {
|
|
1159
|
+
paste.active = sequence === PASTE_START;
|
|
1160
|
+
return [];
|
|
1161
|
+
}
|
|
1162
|
+
if (paste.active && (sequence === "\r" || sequence === `
|
|
1163
|
+
`))
|
|
1164
|
+
return [];
|
|
1165
|
+
if (key !== undefined)
|
|
1166
|
+
return [key];
|
|
1167
|
+
return IS_CONTROL.test(sequence) || sequence.startsWith("\x1B") ? [] : [{ text: sequence }];
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
var IS_CONTROL, PASTE_START = "\x1B[200~", PASTE_END = "\x1B[201~", KEY_SEQUENCES, MOUSE, WHEEL_LINES = 3, KEYS;
|
|
1171
|
+
var init_state = __esm(() => {
|
|
1172
|
+
init_text2();
|
|
1173
|
+
init_line();
|
|
1174
|
+
init_score();
|
|
1175
|
+
IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
|
|
1176
|
+
KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
|
|
1177
|
+
MOUSE = /^\x1B\[<(\d+);\d+;\d+[a-z]$/i;
|
|
1178
|
+
KEYS = {
|
|
1179
|
+
"\x1B[A": "up",
|
|
1180
|
+
"\x1BOA": "up",
|
|
1181
|
+
"\x10": "up",
|
|
1182
|
+
"\x1B[B": "down",
|
|
1183
|
+
"\x1BOB": "down",
|
|
1184
|
+
"\x0E": "down",
|
|
1185
|
+
"\x1B[5~": "pageup",
|
|
1186
|
+
"\x1B[6~": "pagedown",
|
|
1187
|
+
"\x1B[H": "home",
|
|
1188
|
+
"\x1B[1~": "home",
|
|
1189
|
+
"\x1BOH": "home",
|
|
1190
|
+
"\x1B[F": "end",
|
|
1191
|
+
"\x1B[4~": "end",
|
|
1192
|
+
"\x1BOF": "end",
|
|
1193
|
+
"\r": "enter",
|
|
1194
|
+
"\n": "enter",
|
|
1195
|
+
"\x03": "cancel",
|
|
1196
|
+
"\x1B": "cancel",
|
|
1197
|
+
"\x1B[D": "left",
|
|
1198
|
+
"\x1BOD": "left",
|
|
1199
|
+
"\x1B[C": "right",
|
|
1200
|
+
"\x1BOC": "right",
|
|
1201
|
+
"\x1B[1;5D": "wordleft",
|
|
1202
|
+
"\x1B[1;3D": "wordleft",
|
|
1203
|
+
"\x1Bb": "wordleft",
|
|
1204
|
+
"\x1B[1;5C": "wordright",
|
|
1205
|
+
"\x1B[1;3C": "wordright",
|
|
1206
|
+
"\x1Bf": "wordright",
|
|
1207
|
+
"\x01": "linestart",
|
|
1208
|
+
"\x05": "lineend",
|
|
1209
|
+
"\x7F": "erase",
|
|
1210
|
+
"\x1B[3~": "delete",
|
|
1211
|
+
"\b": "killword",
|
|
1212
|
+
"\x1B\x7F": "killword",
|
|
1213
|
+
"\x1B[3;5~": "killnext",
|
|
1214
|
+
"\x1Bd": "killnext",
|
|
1215
|
+
"\x15": "clear",
|
|
1216
|
+
"\v": "killend",
|
|
1217
|
+
"\x17": "word",
|
|
1218
|
+
"\x19": "yank",
|
|
1219
|
+
"\x1A": "suspend",
|
|
1220
|
+
"\t": "tab",
|
|
1221
|
+
"\x1F": "help",
|
|
1222
|
+
"\x1BOP": "help",
|
|
1223
|
+
"\x1B[11~": "help"
|
|
1224
|
+
};
|
|
1225
|
+
});
|
|
1226
|
+
|
|
1227
|
+
// ../kit/src/redraw.ts
|
|
1228
|
+
function overwrite(lines, columns) {
|
|
1229
|
+
return lines.map((line) => textWidth(line) % columns === 0 ? `\x1B[2K${line}` : `${line}\x1B[K`).join(`
|
|
1230
|
+
`);
|
|
1231
|
+
}
|
|
1232
|
+
function rowsTaken(lines, columns) {
|
|
1233
|
+
return lines.reduce((rows, line) => rows + Math.max(1, Math.ceil(textWidth(line) / columns)), 0);
|
|
1234
|
+
}
|
|
1235
|
+
var SYNC_START = "\x1B[?2026h", SYNC_END = "\x1B[?2026l";
|
|
1236
|
+
var init_redraw = __esm(() => {
|
|
1237
|
+
init_format();
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
// ../kit/src/prompt.ts
|
|
1241
|
+
import process18 from "process";
|
|
1242
|
+
function readKeys(input, paste = { active: false }) {
|
|
1243
|
+
return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key) || isEditKey(key));
|
|
1244
|
+
}
|
|
1245
|
+
function roomAfter(question, columns) {
|
|
1246
|
+
return Math.max(columns - textWidth(`? ${question} `) % columns - 1, 1);
|
|
1247
|
+
}
|
|
1248
|
+
function withCaret(colors, line, room, dim = false) {
|
|
1249
|
+
const { before, at, after } = visible(line, room);
|
|
1250
|
+
const tone = dim ? colors.dim : (text) => text;
|
|
1251
|
+
return `${tone(before)}${at === undefined ? colors.dim("\u2588") : colors.inverse(at)}${tone(after)}`;
|
|
1252
|
+
}
|
|
1253
|
+
function sharedStart(texts) {
|
|
1254
|
+
const [first = [], ...rest] = texts.map((text) => [...text]);
|
|
1255
|
+
let length = first.length;
|
|
1256
|
+
for (const chars of rest) {
|
|
1257
|
+
const differs = chars.findIndex((char, index) => char !== first[index]);
|
|
1258
|
+
length = Math.min(length, differs === -1 ? chars.length : differs);
|
|
1259
|
+
}
|
|
1260
|
+
return first.slice(0, length).join("");
|
|
1261
|
+
}
|
|
1262
|
+
function listed2(colors, found, columns) {
|
|
1263
|
+
const shared = sharedStart(found);
|
|
1264
|
+
const cut = Math.max(shared.lastIndexOf("/"), shared.lastIndexOf(" ")) + 1;
|
|
1265
|
+
const names = found.slice(0, MAX_LISTED).map((each) => each.slice(cut));
|
|
1266
|
+
const more = found.length > MAX_LISTED ? ` \u2026 ${found.length - MAX_LISTED} more` : "";
|
|
1267
|
+
return ` ${colors.dim(truncate(names.join(" ") + more, Math.max(columns - 3, 1)))}`;
|
|
1268
|
+
}
|
|
1269
|
+
async function input2(question, { default: fallback, mask = false, validate, history, complete, ...settings } = {}) {
|
|
1270
|
+
let line = { text: "", caret: 0 };
|
|
1271
|
+
let invalid;
|
|
1272
|
+
let completions = [];
|
|
1273
|
+
const remembered = history === undefined || mask ? undefined : history;
|
|
1274
|
+
const earlier = remembered === undefined ? [] : earlierAnswers(remembered);
|
|
1275
|
+
let recalled = -1;
|
|
1276
|
+
let draft = line;
|
|
1277
|
+
const taken = () => line.text === "" ? fallback ?? "" : line.text;
|
|
1278
|
+
const shown = () => mask ? "*".repeat([...taken()].length) : taken();
|
|
1279
|
+
const accepted = await ask(question, settings, (colors, state, { columns }) => {
|
|
1280
|
+
if (state !== "asking")
|
|
1281
|
+
return [answer(colors, question, state, shown())];
|
|
1282
|
+
const typed = line.text === "" ? { text: shown(), caret: [...shown()].length } : { text: shown(), caret: line.caret };
|
|
1283
|
+
return [`${colors.cyan("?")} ${question} ${withCaret(colors, typed, roomAfter(question, columns), line.text === "")}`, ...invalid === undefined ? [] : [` ${colors.red(invalid)}`], ...completions.length > 1 ? [listed2(colors, completions, columns)] : []];
|
|
1284
|
+
}, (key) => {
|
|
1285
|
+
if (key === "cancel")
|
|
1286
|
+
return "cancel";
|
|
1287
|
+
invalid = undefined;
|
|
1288
|
+
completions = [];
|
|
1289
|
+
if (line.chained === true && endsKills(key))
|
|
1290
|
+
line = { ...line, chained: false };
|
|
1291
|
+
if (key === "tab") {
|
|
1292
|
+
const chars = [...line.text];
|
|
1293
|
+
const before = chars.slice(0, line.caret).join("");
|
|
1294
|
+
const found = complete?.(before) ?? [];
|
|
1295
|
+
const filled = sharedStart(found);
|
|
1296
|
+
if ([...filled].length > [...before].length)
|
|
1297
|
+
line = { ...line, text: filled + chars.slice(line.caret).join(""), caret: [...filled].length };
|
|
1298
|
+
else
|
|
1299
|
+
completions = found;
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
if (key === "enter") {
|
|
1303
|
+
invalid = validate?.(taken());
|
|
1304
|
+
return invalid === undefined ? "enter" : undefined;
|
|
1305
|
+
}
|
|
1306
|
+
if (key === "up" || key === "down") {
|
|
1307
|
+
const to = Math.min(Math.max(recalled + (key === "up" ? 1 : -1), -1), earlier.length - 1);
|
|
1308
|
+
if (recalled === -1)
|
|
1309
|
+
draft = line;
|
|
1310
|
+
recalled = to;
|
|
1311
|
+
const shown = to === -1 ? draft : { text: earlier[to], caret: [...earlier[to]].length };
|
|
1312
|
+
line = { ...shown, killed: line.killed ?? "" };
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
const edit = { home: "linestart", end: "lineend" }[key] ?? key;
|
|
1316
|
+
if (typeof edit === "object" || isEditKey(edit))
|
|
1317
|
+
line = editLine(line, edit);
|
|
1318
|
+
return;
|
|
1319
|
+
});
|
|
1320
|
+
if (!accepted)
|
|
1321
|
+
return;
|
|
1322
|
+
if (remembered !== undefined && taken() !== "")
|
|
1323
|
+
rememberAnswer(remembered, taken());
|
|
1324
|
+
return taken();
|
|
1325
|
+
}
|
|
1326
|
+
function answer(colors, question, state, picked) {
|
|
1327
|
+
return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
|
|
1328
|
+
}
|
|
1329
|
+
async function ask(question, { hint, terminal = process18 }, render, press) {
|
|
1330
|
+
const { stdin, stderr } = terminal;
|
|
1331
|
+
if (!isInteractive(terminal))
|
|
1332
|
+
fail(`cannot ask "${question}" off a terminal`, 2, hint);
|
|
1333
|
+
const colors = paint(stderr);
|
|
1334
|
+
let current = "asking";
|
|
1335
|
+
let outcome;
|
|
1336
|
+
const columns = () => stderr.columns || 80;
|
|
1337
|
+
const draw = (state, last = false) => {
|
|
1338
|
+
const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
|
|
1339
|
+
const rows = rowsTaken(frame, columns());
|
|
1340
|
+
stderr.write(`${SYNC_START}\r${overwrite(frame, columns())}\x1B[0J${last || rows < 2 ? "" : `\x1B[${rows - 1}A`}${last ? "" : "\r"}${SYNC_END}`);
|
|
1341
|
+
current = state;
|
|
1342
|
+
};
|
|
1343
|
+
const redraw = () => draw(current);
|
|
1344
|
+
const paste = { active: false };
|
|
1345
|
+
const stop = terminal.stop ?? (terminal === process18 ? stopJob : undefined);
|
|
1346
|
+
const suspend = () => {
|
|
1347
|
+
if (stop === undefined)
|
|
1348
|
+
return;
|
|
1349
|
+
stderr.write("\x1B[0J\x1B[?25h\x1B[?2004l");
|
|
1350
|
+
stdin.setRawMode(false);
|
|
1351
|
+
stop();
|
|
1352
|
+
stdin.setRawMode(true);
|
|
1353
|
+
stderr.write("\x1B[?25l\x1B[?2004h");
|
|
1354
|
+
};
|
|
1355
|
+
try {
|
|
1356
|
+
stderr.on?.("resize", redraw);
|
|
1357
|
+
stdin.setRawMode(true);
|
|
1358
|
+
stdin.resume();
|
|
1359
|
+
stderr.write("\x1B[?25l\x1B[?2004h");
|
|
1360
|
+
draw("asking");
|
|
1361
|
+
return await new Promise((resolve) => {
|
|
1362
|
+
function onData(data) {
|
|
1363
|
+
for (const key of readKeys(data.toString(), paste)) {
|
|
1364
|
+
if (key === "suspend") {
|
|
1365
|
+
suspend();
|
|
1366
|
+
continue;
|
|
1367
|
+
}
|
|
1368
|
+
const pressed = press(key);
|
|
1369
|
+
if (pressed !== undefined) {
|
|
1370
|
+
settle(pressed);
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
draw("asking");
|
|
1375
|
+
}
|
|
1376
|
+
function onEnd() {
|
|
1377
|
+
settle("cancel");
|
|
1378
|
+
}
|
|
1379
|
+
function settle(settled) {
|
|
1380
|
+
outcome = settled;
|
|
1381
|
+
stdin.off("data", onData);
|
|
1382
|
+
stdin.off("end", onEnd);
|
|
1383
|
+
resolve(settled === "enter");
|
|
1384
|
+
}
|
|
1385
|
+
stdin.on("data", onData);
|
|
1386
|
+
stdin.on("end", onEnd);
|
|
1387
|
+
});
|
|
1388
|
+
} finally {
|
|
1389
|
+
stderr.off?.("resize", redraw);
|
|
1390
|
+
draw(outcome ?? "cancel", true);
|
|
1391
|
+
stderr.write(`
|
|
1392
|
+
\x1B[?25h\x1B[?2004l`);
|
|
1393
|
+
stdin.setRawMode(false);
|
|
1394
|
+
stdin.pause();
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
var PROMPT_KEYS, MAX_LISTED = 12;
|
|
1398
|
+
var init_prompt = __esm(() => {
|
|
1399
|
+
init_answers();
|
|
1400
|
+
init_args();
|
|
1401
|
+
init_format();
|
|
1402
|
+
init_job();
|
|
1403
|
+
init_mode();
|
|
1404
|
+
init_line();
|
|
1405
|
+
init_state();
|
|
1406
|
+
init_redraw();
|
|
1407
|
+
init_style();
|
|
1408
|
+
PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "suspend", "tab"]);
|
|
1409
|
+
});
|
|
1410
|
+
|
|
1411
|
+
// src/cli.ts
|
|
1412
|
+
import process35 from "process";
|
|
1413
|
+
|
|
1414
|
+
// ../kit/src/index.ts
|
|
1415
|
+
init_args();
|
|
1416
|
+
|
|
911
1417
|
// ../kit/src/argv.ts
|
|
912
1418
|
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
913
1419
|
import { resolve as resolve3 } from "path";
|
|
@@ -933,6 +1439,10 @@ function scriptArgs(argv = process11.argv.slice(2), cmdline = commandLine(), scr
|
|
|
933
1439
|
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
934
1440
|
}
|
|
935
1441
|
// ../kit/src/chart.ts
|
|
1442
|
+
init_format();
|
|
1443
|
+
init_mode();
|
|
1444
|
+
init_style();
|
|
1445
|
+
init_theme();
|
|
936
1446
|
import process12 from "process";
|
|
937
1447
|
var FILLED = "\u2501";
|
|
938
1448
|
var EMPTY = "\u2500";
|
|
@@ -946,7 +1456,12 @@ function bar(ratio, { width = 20, stream = process12.stdout, env = process12.env
|
|
|
946
1456
|
const { theme } = activeTheme();
|
|
947
1457
|
return `${shaded(theme, colors, theme.glyphs.bar, filled, width, env)}${colors.dim(theme.glyphs.bar.repeat(width - filled))}`;
|
|
948
1458
|
}
|
|
1459
|
+
// ../kit/src/ci.ts
|
|
1460
|
+
init_args();
|
|
1461
|
+
init_format();
|
|
1462
|
+
|
|
949
1463
|
// ../kit/src/progress.ts
|
|
1464
|
+
init_format();
|
|
950
1465
|
import process14 from "process";
|
|
951
1466
|
|
|
952
1467
|
// ../kit/src/process.ts
|
|
@@ -1101,6 +1616,8 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
1101
1616
|
}
|
|
1102
1617
|
|
|
1103
1618
|
// ../kit/src/progress.ts
|
|
1619
|
+
init_style();
|
|
1620
|
+
init_theme();
|
|
1104
1621
|
var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
1105
1622
|
var FRAME_MS = 200;
|
|
1106
1623
|
var CLEAR_BELOW = "\r\x1B[J";
|
|
@@ -1117,10 +1634,14 @@ function liveRegion(render, stream = process14.stderr, env = process14.env) {
|
|
|
1117
1634
|
}, print: (text) => void stream.write(`${text}
|
|
1118
1635
|
`), stop: () => {
|
|
1119
1636
|
return;
|
|
1637
|
+
}, pause: () => () => {
|
|
1638
|
+
return;
|
|
1120
1639
|
} };
|
|
1121
1640
|
const write = stream.write.bind(stream);
|
|
1122
1641
|
let frame = 0;
|
|
1123
1642
|
let drawn = false;
|
|
1643
|
+
let paused = false;
|
|
1644
|
+
let stopped = false;
|
|
1124
1645
|
const columns = () => {
|
|
1125
1646
|
const now = stream.getWindowSize?.()[0] ?? stream.columns;
|
|
1126
1647
|
return now === undefined || now === 0 ? 80 : now;
|
|
@@ -1131,6 +1652,8 @@ function liveRegion(render, stream = process14.stderr, env = process14.env) {
|
|
|
1131
1652
|
drawn = false;
|
|
1132
1653
|
};
|
|
1133
1654
|
const draw = () => {
|
|
1655
|
+
if (paused)
|
|
1656
|
+
return;
|
|
1134
1657
|
const width = columns() - 1;
|
|
1135
1658
|
const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
|
|
1136
1659
|
const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
|
|
@@ -1142,16 +1665,17 @@ function liveRegion(render, stream = process14.stderr, env = process14.env) {
|
|
|
1142
1665
|
`)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
|
|
1143
1666
|
drawn = true;
|
|
1144
1667
|
};
|
|
1145
|
-
|
|
1668
|
+
let timer = setInterval(draw, FRAME_MS);
|
|
1146
1669
|
stream.on?.("resize", draw);
|
|
1147
|
-
|
|
1148
|
-
|
|
1670
|
+
let restore = interceptOutput(clear);
|
|
1671
|
+
let release = swallowInput();
|
|
1149
1672
|
const onExit = () => {
|
|
1150
1673
|
clear();
|
|
1151
1674
|
release();
|
|
1152
1675
|
};
|
|
1153
1676
|
const signals = holdSignals(stop);
|
|
1154
1677
|
function stop() {
|
|
1678
|
+
stopped = true;
|
|
1155
1679
|
clearInterval(timer);
|
|
1156
1680
|
stream.off?.("resize", draw);
|
|
1157
1681
|
clear();
|
|
@@ -1160,6 +1684,29 @@ function liveRegion(render, stream = process14.stderr, env = process14.env) {
|
|
|
1160
1684
|
process14.off("exit", onExit);
|
|
1161
1685
|
signals.release();
|
|
1162
1686
|
}
|
|
1687
|
+
function pause() {
|
|
1688
|
+
if (paused || stopped)
|
|
1689
|
+
return () => {
|
|
1690
|
+
return;
|
|
1691
|
+
};
|
|
1692
|
+
paused = true;
|
|
1693
|
+
clearInterval(timer);
|
|
1694
|
+
stream.off?.("resize", draw);
|
|
1695
|
+
clear();
|
|
1696
|
+
restore();
|
|
1697
|
+
release();
|
|
1698
|
+
return () => {
|
|
1699
|
+
if (!paused || stopped)
|
|
1700
|
+
return;
|
|
1701
|
+
paused = false;
|
|
1702
|
+
timer = setInterval(draw, FRAME_MS);
|
|
1703
|
+
timer.unref();
|
|
1704
|
+
stream.on?.("resize", draw);
|
|
1705
|
+
restore = interceptOutput(clear);
|
|
1706
|
+
release = swallowInput();
|
|
1707
|
+
draw();
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1163
1710
|
timer.unref();
|
|
1164
1711
|
process14.on("exit", onExit);
|
|
1165
1712
|
return {
|
|
@@ -1170,7 +1717,8 @@ function liveRegion(render, stream = process14.stderr, env = process14.env) {
|
|
|
1170
1717
|
`);
|
|
1171
1718
|
draw();
|
|
1172
1719
|
},
|
|
1173
|
-
stop
|
|
1720
|
+
stop,
|
|
1721
|
+
pause
|
|
1174
1722
|
};
|
|
1175
1723
|
}
|
|
1176
1724
|
function cutToWidth(line, width) {
|
|
@@ -1241,7 +1789,11 @@ function interceptOutput(clear) {
|
|
|
1241
1789
|
};
|
|
1242
1790
|
}
|
|
1243
1791
|
|
|
1792
|
+
// ../kit/src/ci.ts
|
|
1793
|
+
init_style();
|
|
1794
|
+
|
|
1244
1795
|
// ../kit/src/tool.ts
|
|
1796
|
+
init_format();
|
|
1245
1797
|
import process15 from "process";
|
|
1246
1798
|
var PERMANENT = /\bHTTP (?:401|403|404)\b|unauthorized|forbidden|not found|couldn't be found|token is required/i;
|
|
1247
1799
|
function cwdGone() {
|
|
@@ -1270,10 +1822,10 @@ function isPermanentFailure(error) {
|
|
|
1270
1822
|
return false;
|
|
1271
1823
|
return error instanceof SpawnError && error.missing || PERMANENT.test(error.message);
|
|
1272
1824
|
}
|
|
1273
|
-
async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
|
|
1825
|
+
async function runTool(label, argv, { timeoutMs, cwd, onStart, env } = {}) {
|
|
1274
1826
|
let ran;
|
|
1275
1827
|
try {
|
|
1276
|
-
ran = await runCommand(argv, { env: process15.env, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
|
|
1828
|
+
ran = await runCommand(argv, { env: { ...process15.env, ...env }, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
|
|
1277
1829
|
} catch (error) {
|
|
1278
1830
|
throw spawnFailure(label, error);
|
|
1279
1831
|
}
|
|
@@ -1365,9 +1917,120 @@ function ciHeader(spinner, label, startedAt, out) {
|
|
|
1365
1917
|
return `${spinner} ${label} ${paint(out).dim(formatElapsed(Date.now() - startedAt))}`;
|
|
1366
1918
|
}
|
|
1367
1919
|
// ../kit/src/cli.ts
|
|
1368
|
-
|
|
1369
|
-
import {
|
|
1370
|
-
import
|
|
1920
|
+
init_args();
|
|
1921
|
+
import { readFileSync as readFileSync5, realpathSync as realpathSync2 } from "fs";
|
|
1922
|
+
import { dirname as dirname4, join as join8 } from "path";
|
|
1923
|
+
import process22 from "process";
|
|
1924
|
+
|
|
1925
|
+
// ../kit/src/askpass.ts
|
|
1926
|
+
import { chmodSync, mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
1927
|
+
import { tmpdir } from "os";
|
|
1928
|
+
import { join as join6 } from "path";
|
|
1929
|
+
import process19 from "process";
|
|
1930
|
+
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1931
|
+
var ECHOED = /username|yes\/no/i;
|
|
1932
|
+
var quoted = (text) => `'${text.replaceAll("'", `'\\''`)}'`;
|
|
1933
|
+
function askpass(pause = () => () => {
|
|
1934
|
+
return;
|
|
1935
|
+
}) {
|
|
1936
|
+
if (process19.stdin.isTTY !== true || process19.stderr.isTTY !== true || process19.argv[1] === undefined)
|
|
1937
|
+
return;
|
|
1938
|
+
const dir = mkdtempSync(join6(tmpdir(), "kaynooo-askpass-"));
|
|
1939
|
+
const socketPath = join6(dir, "socket");
|
|
1940
|
+
const script = join6(dir, "askpass");
|
|
1941
|
+
let turn = Promise.resolve();
|
|
1942
|
+
const answer = async ({ prompt, notice }) => {
|
|
1943
|
+
const resume = pause();
|
|
1944
|
+
try {
|
|
1945
|
+
if (notice === true) {
|
|
1946
|
+
process19.stderr.write(`${prompt.trim()}
|
|
1947
|
+
`);
|
|
1948
|
+
return {};
|
|
1949
|
+
}
|
|
1950
|
+
await Promise.resolve().then(() => init_prompt());
|
|
1951
|
+
return { answer: await input2(prompt.trim(), { mask: !ECHOED.test(prompt) }) };
|
|
1952
|
+
} finally {
|
|
1953
|
+
resume();
|
|
1954
|
+
}
|
|
1955
|
+
};
|
|
1956
|
+
const respond = async (socket, request) => {
|
|
1957
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
1958
|
+
const previous = turn;
|
|
1959
|
+
let reply = {};
|
|
1960
|
+
turn = promise;
|
|
1961
|
+
await previous;
|
|
1962
|
+
try {
|
|
1963
|
+
reply = await answer(request);
|
|
1964
|
+
} catch {} finally {
|
|
1965
|
+
socket.end(`${JSON.stringify(reply)}
|
|
1966
|
+
`);
|
|
1967
|
+
resolve();
|
|
1968
|
+
}
|
|
1969
|
+
};
|
|
1970
|
+
const server = Bun.listen({
|
|
1971
|
+
unix: socketPath,
|
|
1972
|
+
socket: {
|
|
1973
|
+
open: (socket) => {
|
|
1974
|
+
socket.data = { buffered: "" };
|
|
1975
|
+
},
|
|
1976
|
+
data: (socket, chunk) => {
|
|
1977
|
+
const before = socket.data.buffered;
|
|
1978
|
+
socket.data.buffered += chunk.toString();
|
|
1979
|
+
if (before.includes(`
|
|
1980
|
+
`) || !socket.data.buffered.includes(`
|
|
1981
|
+
`))
|
|
1982
|
+
return;
|
|
1983
|
+
respond(socket, JSON.parse(socket.data.buffered));
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
writeFileSync2(script, `#!/bin/sh
|
|
1988
|
+
${SOCKET_VARIABLE}=${quoted(socketPath)} exec ${quoted(process19.execPath)} --no-env-file --config=/dev/null ${quoted(process19.argv[1])} "$@"
|
|
1989
|
+
`);
|
|
1990
|
+
chmodSync(script, 448);
|
|
1991
|
+
return {
|
|
1992
|
+
env: { GIT_ASKPASS: script, SSH_ASKPASS: script, SSH_ASKPASS_REQUIRE: "force" },
|
|
1993
|
+
close: () => {
|
|
1994
|
+
server.stop(true);
|
|
1995
|
+
rmSync(dir, { recursive: true, force: true });
|
|
1996
|
+
}
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1999
|
+
async function askpassClient(argv) {
|
|
2000
|
+
const socketPath = process19.env[SOCKET_VARIABLE];
|
|
2001
|
+
if (socketPath === undefined)
|
|
2002
|
+
return;
|
|
2003
|
+
const request = { prompt: argv[0] ?? "", ...process19.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
|
|
2004
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
2005
|
+
let received = "";
|
|
2006
|
+
try {
|
|
2007
|
+
await Bun.connect({
|
|
2008
|
+
unix: socketPath,
|
|
2009
|
+
socket: {
|
|
2010
|
+
open: (socket) => void socket.write(`${JSON.stringify(request)}
|
|
2011
|
+
`),
|
|
2012
|
+
data: (_, chunk) => {
|
|
2013
|
+
received += chunk.toString();
|
|
2014
|
+
},
|
|
2015
|
+
close: () => resolve(received),
|
|
2016
|
+
error: () => resolve("")
|
|
2017
|
+
}
|
|
2018
|
+
});
|
|
2019
|
+
} catch {
|
|
2020
|
+
return 1;
|
|
2021
|
+
}
|
|
2022
|
+
const reply = await promise;
|
|
2023
|
+
if (reply === "")
|
|
2024
|
+
return 1;
|
|
2025
|
+
const { answer } = JSON.parse(reply);
|
|
2026
|
+
if (request.notice === true)
|
|
2027
|
+
return 0;
|
|
2028
|
+
if (answer === undefined)
|
|
2029
|
+
return 1;
|
|
2030
|
+
process19.stdout.write(`${answer}
|
|
2031
|
+
`);
|
|
2032
|
+
return 0;
|
|
2033
|
+
}
|
|
1371
2034
|
|
|
1372
2035
|
// ../kit/src/completions.ts
|
|
1373
2036
|
var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
|
|
@@ -1430,28 +2093,34 @@ compdef __kaynooo_cli_complete ${bins.join(" ")}
|
|
|
1430
2093
|
}
|
|
1431
2094
|
|
|
1432
2095
|
// ../kit/src/notify.ts
|
|
1433
|
-
|
|
2096
|
+
init_format();
|
|
2097
|
+
init_mode();
|
|
2098
|
+
import process20 from "process";
|
|
1434
2099
|
var NOTIFY_AFTER_MS = 1e4;
|
|
1435
2100
|
var CANCELLED = 130;
|
|
1436
2101
|
function base64(text) {
|
|
1437
2102
|
return Buffer.from(text).toString("base64");
|
|
1438
2103
|
}
|
|
1439
|
-
function notification(title, body, env =
|
|
1440
|
-
const id = `kit${
|
|
2104
|
+
function notification(title, body, env = process20.env) {
|
|
2105
|
+
const id = `kit${process20.pid}`;
|
|
1441
2106
|
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
2107
|
return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
|
|
1443
2108
|
}
|
|
1444
|
-
function notifyEnd(command, code, ms, { stream =
|
|
2109
|
+
function notifyEnd(command, code, ms, { stream = process20.stderr, env = process20.env } = {}) {
|
|
1445
2110
|
if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
|
|
1446
2111
|
return;
|
|
1447
2112
|
stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
|
|
1448
2113
|
}
|
|
1449
2114
|
|
|
2115
|
+
// ../kit/src/cli.ts
|
|
2116
|
+
init_style();
|
|
2117
|
+
init_text2();
|
|
2118
|
+
|
|
1450
2119
|
// ../kit/src/usage.ts
|
|
1451
|
-
import { appendFileSync, mkdirSync } from "fs";
|
|
1452
|
-
import { homedir as
|
|
1453
|
-
import { dirname as
|
|
1454
|
-
import
|
|
2120
|
+
import { appendFileSync, mkdirSync as mkdirSync2 } from "fs";
|
|
2121
|
+
import { homedir as homedir4 } from "os";
|
|
2122
|
+
import { dirname as dirname3, isAbsolute, join as join7 } from "path";
|
|
2123
|
+
import process21 from "process";
|
|
1455
2124
|
|
|
1456
2125
|
// ../kit/src/logs.ts
|
|
1457
2126
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -1465,14 +2134,14 @@ var usageError;
|
|
|
1465
2134
|
function noteUsageError(message) {
|
|
1466
2135
|
usageError = message;
|
|
1467
2136
|
}
|
|
1468
|
-
function stateHome(env =
|
|
2137
|
+
function stateHome(env = process21.env) {
|
|
1469
2138
|
const dir = env.XDG_STATE_HOME;
|
|
1470
|
-
return dir !== undefined && isAbsolute(dir) ? dir :
|
|
2139
|
+
return dir !== undefined && isAbsolute(dir) ? dir : join7(homedir4(), ".local", "state");
|
|
1471
2140
|
}
|
|
1472
|
-
function usagePath(env =
|
|
1473
|
-
return
|
|
2141
|
+
function usagePath(env = process21.env) {
|
|
2142
|
+
return join7(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1474
2143
|
}
|
|
1475
|
-
function usageRecorded(env =
|
|
2144
|
+
function usageRecorded(env = process21.env) {
|
|
1476
2145
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1477
2146
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1478
2147
|
}
|
|
@@ -1486,12 +2155,12 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
1486
2155
|
usageError = undefined;
|
|
1487
2156
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1488
2157
|
}
|
|
1489
|
-
function recordUsage(entry, env =
|
|
2158
|
+
function recordUsage(entry, env = process21.env) {
|
|
1490
2159
|
if (!usageRecorded(env))
|
|
1491
2160
|
return;
|
|
1492
2161
|
try {
|
|
1493
2162
|
const path = usagePath(env);
|
|
1494
|
-
|
|
2163
|
+
mkdirSync2(dirname3(path), { recursive: true, mode: 448 });
|
|
1495
2164
|
appendFileSync(path, `${JSON.stringify(entry)}
|
|
1496
2165
|
`, { mode: 384 });
|
|
1497
2166
|
} catch {}
|
|
@@ -1580,8 +2249,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1580
2249
|
`);
|
|
1581
2250
|
}
|
|
1582
2251
|
function printError(prefix, message, hint, cause) {
|
|
1583
|
-
const colors = paint(
|
|
1584
|
-
const styled = takesControlCodes(
|
|
2252
|
+
const colors = paint(process22.stderr);
|
|
2253
|
+
const styled = takesControlCodes(process22.stderr);
|
|
1585
2254
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1586
2255
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1587
2256
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1591,8 +2260,8 @@ function runHint(command, effect) {
|
|
|
1591
2260
|
return `run \`${command}\`${effect === undefined ? "" : ` to ${effect}`}`;
|
|
1592
2261
|
}
|
|
1593
2262
|
function printHint(hint) {
|
|
1594
|
-
const colors = paint(
|
|
1595
|
-
console.error(` ${takesControlCodes(
|
|
2263
|
+
const colors = paint(process22.stderr);
|
|
2264
|
+
console.error(` ${takesControlCodes(process22.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
|
|
1596
2265
|
}
|
|
1597
2266
|
function printJsonError(message, hint, cause) {
|
|
1598
2267
|
console.error(JSON.stringify({ error: message, ...hint === undefined ? {} : { hint }, ...cause === undefined ? {} : { cause } }));
|
|
@@ -1631,11 +2300,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1631
2300
|
}
|
|
1632
2301
|
}
|
|
1633
2302
|
if (name === undefined && level.path.length > 1) {
|
|
1634
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
2303
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process22.stderr));
|
|
1635
2304
|
return 2;
|
|
1636
2305
|
}
|
|
1637
2306
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1638
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
2307
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process22.stdout));
|
|
1639
2308
|
return 0;
|
|
1640
2309
|
}
|
|
1641
2310
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1769,18 +2438,21 @@ function packageVersion(entry = Bun.main) {
|
|
|
1769
2438
|
try {
|
|
1770
2439
|
resolved = realpathSync2(entry);
|
|
1771
2440
|
} catch {}
|
|
1772
|
-
for (let dir =
|
|
2441
|
+
for (let dir = dirname4(resolved);; dir = dirname4(dir)) {
|
|
1773
2442
|
try {
|
|
1774
|
-
const { version } = JSON.parse(
|
|
2443
|
+
const { version } = JSON.parse(readFileSync5(join8(dir, "package.json"), "utf8"));
|
|
1775
2444
|
if (typeof version === "string")
|
|
1776
2445
|
return version;
|
|
1777
2446
|
} catch {}
|
|
1778
|
-
if (
|
|
2447
|
+
if (dirname4(dir) === dir)
|
|
1779
2448
|
return "0.0.0";
|
|
1780
2449
|
}
|
|
1781
2450
|
}
|
|
1782
2451
|
async function runCli(cli, argv = scriptArgs()) {
|
|
1783
2452
|
const version = cli.version ?? packageVersion();
|
|
2453
|
+
const answered = await askpassClient(argv);
|
|
2454
|
+
if (answered !== undefined)
|
|
2455
|
+
return answered;
|
|
1784
2456
|
if (argv[0] === COMPLETE)
|
|
1785
2457
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
1786
2458
|
if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
|
|
@@ -1811,7 +2483,12 @@ function commandPath(scope, argv) {
|
|
|
1811
2483
|
}
|
|
1812
2484
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1813
2485
|
}
|
|
2486
|
+
|
|
2487
|
+
// ../kit/src/index.ts
|
|
2488
|
+
init_config();
|
|
2489
|
+
|
|
1814
2490
|
// ../kit/src/excerpt.ts
|
|
2491
|
+
init_text2();
|
|
1815
2492
|
var BUN_CHECK_BLOCK = /<error file=[\s\S]*?<\/error>/g;
|
|
1816
2493
|
var BUN_CHECK_SOURCE = /<source>[\s\S]*?<\/source>\n?/g;
|
|
1817
2494
|
var BUN_CHECK_ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
@@ -1918,7 +2595,7 @@ function squeeze(lines) {
|
|
|
1918
2595
|
out.pop();
|
|
1919
2596
|
return out;
|
|
1920
2597
|
}
|
|
1921
|
-
function
|
|
2598
|
+
function cut2(shown) {
|
|
1922
2599
|
return shown.length > MAX_LINES ? [...shown.slice(0, MAX_LINES), `... ${shown.length - MAX_LINES} more lines`].join(`
|
|
1923
2600
|
`) : shown.join(`
|
|
1924
2601
|
`);
|
|
@@ -1928,13 +2605,17 @@ function recognised(lines, parsers) {
|
|
|
1928
2605
|
}
|
|
1929
2606
|
function toolExcerpt(lines) {
|
|
1930
2607
|
const found = recognised(lines.map((line) => stripAnsi(line)), TOOL_PARSERS);
|
|
1931
|
-
return found === undefined ? undefined :
|
|
2608
|
+
return found === undefined ? undefined : cut2(squeeze(found));
|
|
1932
2609
|
}
|
|
1933
|
-
|
|
1934
|
-
|
|
2610
|
+
|
|
2611
|
+
// ../kit/src/index.ts
|
|
2612
|
+
init_folders();
|
|
2613
|
+
init_format();
|
|
2614
|
+
|
|
1935
2615
|
// ../kit/src/git.ts
|
|
1936
|
-
|
|
1937
|
-
import
|
|
2616
|
+
init_args();
|
|
2617
|
+
import { basename, dirname as dirname5 } from "path";
|
|
2618
|
+
import process23 from "process";
|
|
1938
2619
|
var ORIGIN_PREFIX = /^origin\//;
|
|
1939
2620
|
var GIT_NETWORK_MS = 60000;
|
|
1940
2621
|
async function git(args, timeoutMs) {
|
|
@@ -1964,9 +2645,10 @@ async function defaultBranch() {
|
|
|
1964
2645
|
async function leaveWorktree() {
|
|
1965
2646
|
const common = await git(["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
1966
2647
|
if (basename(common) === ".git")
|
|
1967
|
-
|
|
2648
|
+
process23.chdir(dirname5(common));
|
|
1968
2649
|
}
|
|
1969
2650
|
// ../kit/src/limit.ts
|
|
2651
|
+
init_args();
|
|
1970
2652
|
function limitOptions(fallback) {
|
|
1971
2653
|
return {
|
|
1972
2654
|
limit: { type: "string", short: "n", description: `show at most this many rows, the rest counted (${fallback})` },
|
|
@@ -1987,6 +2669,10 @@ function capped(rows, limit) {
|
|
|
1987
2669
|
const more = rows.length - limit;
|
|
1988
2670
|
return more > 0 ? { shown: rows.slice(0, limit), footer: moreFooter(more) } : { shown: [...rows], footer: undefined };
|
|
1989
2671
|
}
|
|
2672
|
+
|
|
2673
|
+
// ../kit/src/index.ts
|
|
2674
|
+
init_mode();
|
|
2675
|
+
|
|
1990
2676
|
// ../kit/src/pool.ts
|
|
1991
2677
|
async function pool(items, limit, task) {
|
|
1992
2678
|
const results = Array.from({ length: items.length });
|
|
@@ -2000,22 +2686,25 @@ async function pool(items, limit, task) {
|
|
|
2000
2686
|
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
2001
2687
|
return results;
|
|
2002
2688
|
}
|
|
2689
|
+
// ../kit/src/report.ts
|
|
2690
|
+
init_style();
|
|
2691
|
+
init_text2();
|
|
2003
2692
|
// ../kit/src/secrets.ts
|
|
2004
2693
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
2005
2694
|
// ../kit/src/sessions.ts
|
|
2006
|
-
import { homedir as
|
|
2007
|
-
import { join as
|
|
2008
|
-
import
|
|
2695
|
+
import { homedir as homedir5 } from "os";
|
|
2696
|
+
import { join as join9 } from "path";
|
|
2697
|
+
import process24 from "process";
|
|
2009
2698
|
var {Glob } = globalThis.Bun;
|
|
2010
2699
|
var SESSION_FILES = new Glob("*.json");
|
|
2011
2700
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
2012
2701
|
async function sessionDirs() {
|
|
2013
|
-
const home =
|
|
2014
|
-
const dirs = new Set([
|
|
2015
|
-
if (
|
|
2016
|
-
dirs.add(
|
|
2702
|
+
const home = homedir5();
|
|
2703
|
+
const dirs = new Set([join9(home, ".claude", "sessions")]);
|
|
2704
|
+
if (process24.env.CLAUDE_CONFIG_DIR !== undefined)
|
|
2705
|
+
dirs.add(join9(process24.env.CLAUDE_CONFIG_DIR, "sessions"));
|
|
2017
2706
|
try {
|
|
2018
|
-
for await (const dir of ACCOUNT_DIRS.scan({ cwd:
|
|
2707
|
+
for await (const dir of ACCOUNT_DIRS.scan({ cwd: join9(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
|
|
2019
2708
|
dirs.add(dir);
|
|
2020
2709
|
} catch {}
|
|
2021
2710
|
return [...dirs];
|
|
@@ -2059,7 +2748,7 @@ async function liveSessions() {
|
|
|
2059
2748
|
}
|
|
2060
2749
|
async function currentSession(sessions) {
|
|
2061
2750
|
const byPid = new Map(sessions.map((session) => [session.pid, session]));
|
|
2062
|
-
let pid =
|
|
2751
|
+
let pid = process24.ppid;
|
|
2063
2752
|
for (let depth = 0;depth < 32 && pid > 1; depth++) {
|
|
2064
2753
|
const session = byPid.get(pid);
|
|
2065
2754
|
if (session !== undefined)
|
|
@@ -2071,8 +2760,18 @@ async function currentSession(sessions) {
|
|
|
2071
2760
|
}
|
|
2072
2761
|
return;
|
|
2073
2762
|
}
|
|
2763
|
+
|
|
2764
|
+
// ../kit/src/index.ts
|
|
2765
|
+
init_style();
|
|
2766
|
+
init_text2();
|
|
2767
|
+
init_theme();
|
|
2768
|
+
init_user_config();
|
|
2769
|
+
|
|
2074
2770
|
// ../kit/src/watch.ts
|
|
2075
|
-
|
|
2771
|
+
init_args();
|
|
2772
|
+
init_input();
|
|
2773
|
+
init_style();
|
|
2774
|
+
import process25 from "process";
|
|
2076
2775
|
import { format } from "util";
|
|
2077
2776
|
var CLEAR_SCREEN = "\x1B[H\x1B[2J";
|
|
2078
2777
|
var DEFAULT_SECONDS = 2;
|
|
@@ -2094,7 +2793,7 @@ function withoutWatch(args) {
|
|
|
2094
2793
|
}
|
|
2095
2794
|
return rest;
|
|
2096
2795
|
}
|
|
2097
|
-
async function watching(value, step, stream =
|
|
2796
|
+
async function watching(value, step, stream = process25.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
|
|
2098
2797
|
const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
|
|
2099
2798
|
if (!takesControlCodes(stream))
|
|
2100
2799
|
badUsage("--watch redraws the screen, so it needs a terminal");
|
|
@@ -2102,12 +2801,12 @@ async function watching(value, step, stream = process21.stdout, sleep = Bun.slee
|
|
|
2102
2801
|
for (let round = 0;round < rounds; round++) {
|
|
2103
2802
|
const held = [];
|
|
2104
2803
|
const { log, info } = console;
|
|
2105
|
-
const write =
|
|
2804
|
+
const write = process25.stdout.write.bind(process25.stdout);
|
|
2106
2805
|
const hold = (...parts) => void held.push(`${format(...parts)}
|
|
2107
2806
|
`);
|
|
2108
2807
|
console.log = hold;
|
|
2109
2808
|
console.info = hold;
|
|
2110
|
-
|
|
2809
|
+
process25.stdout.write = (text) => {
|
|
2111
2810
|
held.push(typeof text === "string" ? text : Buffer.from(text).toString());
|
|
2112
2811
|
return true;
|
|
2113
2812
|
};
|
|
@@ -2116,13 +2815,15 @@ async function watching(value, step, stream = process21.stdout, sleep = Bun.slee
|
|
|
2116
2815
|
} finally {
|
|
2117
2816
|
console.log = log;
|
|
2118
2817
|
console.info = info;
|
|
2119
|
-
|
|
2818
|
+
process25.stdout.write = write;
|
|
2120
2819
|
}
|
|
2121
2820
|
stream.write(`${CLEAR_SCREEN}${held.join("")}`);
|
|
2122
2821
|
await sleep(interval);
|
|
2123
2822
|
}
|
|
2124
2823
|
return code;
|
|
2125
2824
|
}
|
|
2825
|
+
// ../kit/src/workspace-root.ts
|
|
2826
|
+
init_user_config();
|
|
2126
2827
|
// src/args.ts
|
|
2127
2828
|
var repoOption = {
|
|
2128
2829
|
repo: { type: "string", short: "r", description: "owner/name of the repository, instead of the one origin points at" }
|
|
@@ -2294,9 +2995,9 @@ function holderSession(holder, sessions) {
|
|
|
2294
2995
|
}
|
|
2295
2996
|
|
|
2296
2997
|
// src/good.ts
|
|
2297
|
-
import
|
|
2998
|
+
import process27 from "process";
|
|
2298
2999
|
function good(text) {
|
|
2299
|
-
return role("ok",
|
|
3000
|
+
return role("ok", process27.stdout)(text);
|
|
2300
3001
|
}
|
|
2301
3002
|
|
|
2302
3003
|
// src/config.ts
|
|
@@ -2329,12 +3030,12 @@ async function loadSettings(home) {
|
|
|
2329
3030
|
}
|
|
2330
3031
|
|
|
2331
3032
|
// src/tea.ts
|
|
2332
|
-
import
|
|
3033
|
+
import process29 from "process";
|
|
2333
3034
|
|
|
2334
3035
|
// src/forge.ts
|
|
2335
|
-
import { homedir as
|
|
2336
|
-
import { join as
|
|
2337
|
-
import
|
|
3036
|
+
import { homedir as homedir6 } from "os";
|
|
3037
|
+
import { join as join10 } from "path";
|
|
3038
|
+
import process28 from "process";
|
|
2338
3039
|
|
|
2339
3040
|
// src/remote.ts
|
|
2340
3041
|
var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
|
|
@@ -2391,8 +3092,8 @@ function loginHosts(config) {
|
|
|
2391
3092
|
return hosts;
|
|
2392
3093
|
}
|
|
2393
3094
|
function teaConfigPath() {
|
|
2394
|
-
const base =
|
|
2395
|
-
return
|
|
3095
|
+
const base = process28.env.XDG_CONFIG_HOME;
|
|
3096
|
+
return join10(base !== undefined && base !== "" ? base : join10(homedir6(), ".config"), "tea", "config.yml");
|
|
2396
3097
|
}
|
|
2397
3098
|
async function readConfig() {
|
|
2398
3099
|
try {
|
|
@@ -2454,22 +3155,22 @@ function repoFlag(repo) {
|
|
|
2454
3155
|
return repo === undefined ? [] : ["--repo", repo];
|
|
2455
3156
|
}
|
|
2456
3157
|
function usesGt() {
|
|
2457
|
-
const PATH =
|
|
3158
|
+
const PATH = process29.env.PATH ?? "";
|
|
2458
3159
|
return Bun.which("tea", { PATH }) === null && Bun.which("gt", { PATH }) !== null;
|
|
2459
3160
|
}
|
|
2460
3161
|
var injected;
|
|
2461
3162
|
async function injectLogin(repo) {
|
|
2462
|
-
if (
|
|
3163
|
+
if (process29.env.GITEA_TOKEN !== undefined && process29.env.GITEA_TOKEN !== "")
|
|
2463
3164
|
return;
|
|
2464
3165
|
const login = await pickLogin(repo === undefined);
|
|
2465
3166
|
if (login === undefined)
|
|
2466
3167
|
return;
|
|
2467
3168
|
injected = login.token;
|
|
2468
|
-
|
|
2469
|
-
|
|
3169
|
+
process29.env.GITEA_TOKEN = login.token;
|
|
3170
|
+
process29.env.GITEA_CLI_HOST = login.url;
|
|
2470
3171
|
}
|
|
2471
3172
|
function scrub(text) {
|
|
2472
|
-
const token = injected ??
|
|
3173
|
+
const token = injected ?? process29.env.GITEA_TOKEN;
|
|
2473
3174
|
return token === undefined || token === "" ? text : text.replaceAll(token, "***");
|
|
2474
3175
|
}
|
|
2475
3176
|
function failureText(stdout, stderr, code) {
|
|
@@ -3025,7 +3726,7 @@ async function drop(args) {
|
|
|
3025
3726
|
}
|
|
3026
3727
|
|
|
3027
3728
|
// src/commands/ci.ts
|
|
3028
|
-
import
|
|
3729
|
+
import process30 from "process";
|
|
3029
3730
|
|
|
3030
3731
|
// src/git.ts
|
|
3031
3732
|
async function tagsAt(commit) {
|
|
@@ -3292,7 +3993,7 @@ async function ci2(args) {
|
|
|
3292
3993
|
return;
|
|
3293
3994
|
}
|
|
3294
3995
|
const json = values.json === true;
|
|
3295
|
-
const live = takesControlCodes(
|
|
3996
|
+
const live = takesControlCodes(process30.stderr) && takesControlCodes(process30.stdout) && !json && values.quiet !== true;
|
|
3296
3997
|
const runs = await waitForCi({
|
|
3297
3998
|
tool: "ft ci",
|
|
3298
3999
|
short,
|
|
@@ -3318,8 +4019,8 @@ async function ci2(args) {
|
|
|
3318
4019
|
return stall === undefined ? undefined : { message: `runs queued on ${short} are not moving: ${stall.reason}`, certain: stall.certain };
|
|
3319
4020
|
},
|
|
3320
4021
|
lines: (spinner, found, started) => [
|
|
3321
|
-
ciHeader(spinner, `CI on ${short}`, started,
|
|
3322
|
-
...(found ?? []).map((run) => ` ${runLine(run,
|
|
4022
|
+
ciHeader(spinner, `CI on ${short}`, started, process30.stderr),
|
|
4023
|
+
...(found ?? []).map((run) => ` ${runLine(run, process30.stderr, undefined, run.commit_sha.slice(0, 7))}`)
|
|
3323
4024
|
]
|
|
3324
4025
|
});
|
|
3325
4026
|
const status = overall(runs);
|
|
@@ -3336,7 +4037,7 @@ async function ci2(args) {
|
|
|
3336
4037
|
}
|
|
3337
4038
|
if (live) {
|
|
3338
4039
|
for (const run of runs)
|
|
3339
|
-
console.log(runLine(run,
|
|
4040
|
+
console.log(runLine(run, process30.stdout, undefined, run.commit_sha.slice(0, 7)));
|
|
3340
4041
|
}
|
|
3341
4042
|
if (status !== "failure") {
|
|
3342
4043
|
if (live)
|
|
@@ -3355,7 +4056,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
|
|
|
3355
4056
|
}
|
|
3356
4057
|
|
|
3357
4058
|
// src/commands/digest.ts
|
|
3358
|
-
import
|
|
4059
|
+
import process31 from "process";
|
|
3359
4060
|
var RUNS_SCANNED = 50;
|
|
3360
4061
|
var TITLE_WIDTH2 = 70;
|
|
3361
4062
|
var SHOWN = 8;
|
|
@@ -3405,12 +4106,12 @@ async function quietly(read) {
|
|
|
3405
4106
|
}
|
|
3406
4107
|
}
|
|
3407
4108
|
async function staleTodos() {
|
|
3408
|
-
const bin = Bun.which("
|
|
4109
|
+
const bin = Bun.which("src", { PATH: process31.env.PATH ?? "" });
|
|
3409
4110
|
if (bin === null)
|
|
3410
4111
|
return [];
|
|
3411
4112
|
let found;
|
|
3412
4113
|
try {
|
|
3413
|
-
const ran = await runCommand([bin, "--stale", "--json"]);
|
|
4114
|
+
const ran = await runCommand([bin, "todo-scan", "--stale", "--json"]);
|
|
3414
4115
|
found = JSON.parse(Buffer.concat(ran.chunks.filter((chunk) => chunk.stream === "stdout").map((chunk) => chunk.data)).toString());
|
|
3415
4116
|
} catch {
|
|
3416
4117
|
return [];
|
|
@@ -3427,8 +4128,8 @@ async function staleTodos() {
|
|
|
3427
4128
|
return [...byIssue.values()];
|
|
3428
4129
|
}
|
|
3429
4130
|
function claimLine(row, now) {
|
|
3430
|
-
const id = role("id",
|
|
3431
|
-
return [id(`#${row.number}`), row.holder, paint(
|
|
4131
|
+
const id = role("id", process31.stdout);
|
|
4132
|
+
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
4133
|
}
|
|
3433
4134
|
function capped2(lines) {
|
|
3434
4135
|
return lines.length > SHOWN ? [...lines.slice(0, SHOWN), `... ${lines.length - SHOWN} more`] : lines;
|
|
@@ -3439,13 +4140,13 @@ function renderDigest(digest, now = Date.now()) {
|
|
|
3439
4140
|
`) },
|
|
3440
4141
|
{ heading: "claimed, no live session here", tone: "warn", count: digest.away.length, lines: table(digest.away.map((row) => claimLine(row, now))).split(`
|
|
3441
4142
|
`) },
|
|
3442
|
-
{ heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status,
|
|
4143
|
+
{ 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
4144
|
`), TITLE_WIDTH2)}`) },
|
|
3444
4145
|
{ 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",
|
|
4146
|
+
{ heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path", process31.stdout)(file.path)}`)) },
|
|
3446
4147
|
{ 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
4148
|
].filter((each) => each.count > 0);
|
|
3448
|
-
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count,
|
|
4149
|
+
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count, process31.stdout, process31.env, tone)}
|
|
3449
4150
|
${lines.join(`
|
|
3450
4151
|
`).replace(LINE_START2, " ")}`).join(`
|
|
3451
4152
|
|
|
@@ -3786,7 +4487,7 @@ var editOptions = {
|
|
|
3786
4487
|
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
4488
|
...repoOption
|
|
3788
4489
|
};
|
|
3789
|
-
async function
|
|
4490
|
+
async function edit2(args) {
|
|
3790
4491
|
const parsed = parse(args, editUsage, editOptions, { exits: editExits });
|
|
3791
4492
|
const { values, positionals } = parsed;
|
|
3792
4493
|
const number = issueNumber(positionals[0], editUsage);
|
|
@@ -3997,7 +4698,8 @@ ${await text(job)}`);
|
|
|
3997
4698
|
}
|
|
3998
4699
|
|
|
3999
4700
|
// src/commands/milestone.ts
|
|
4000
|
-
import
|
|
4701
|
+
import process32 from "process";
|
|
4702
|
+
init_text();
|
|
4001
4703
|
var TITLE_WIDTH3 = 60;
|
|
4002
4704
|
var LIST_LIMIT = 30;
|
|
4003
4705
|
var CONCURRENCY2 = 4;
|
|
@@ -4006,15 +4708,15 @@ function counts(milestone) {
|
|
|
4006
4708
|
}
|
|
4007
4709
|
function progressBar(milestone) {
|
|
4008
4710
|
const total = milestone.open_issues + milestone.closed_issues;
|
|
4009
|
-
return takesControlCodes(
|
|
4711
|
+
return takesControlCodes(process32.stdout) ? bar(total === 0 ? 0 : milestone.closed_issues / total, { width: 16 }) : "";
|
|
4010
4712
|
}
|
|
4011
4713
|
function milestoneCells(each, showState) {
|
|
4012
4714
|
const drawn = progressBar(each);
|
|
4013
4715
|
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
4716
|
}
|
|
4015
4717
|
async function printWithIssues(list, repo) {
|
|
4016
|
-
const colors = paint(
|
|
4017
|
-
const id = role("id",
|
|
4718
|
+
const colors = paint(process32.stdout);
|
|
4719
|
+
const id = role("id", process32.stdout);
|
|
4018
4720
|
const issuesOf = await pool(list, concurrencyOf(CONCURRENCY2), async (each) => Promise.all([openIssues(undefined, repo, each.id), closedIssues(each.id, repo)]));
|
|
4019
4721
|
const blocks = list.map((each, index) => {
|
|
4020
4722
|
const byNumber = (left, right) => left.number - right.number;
|
|
@@ -4025,7 +4727,7 @@ async function printWithIssues(list, repo) {
|
|
|
4025
4727
|
...open.map((issue) => ` ${id(`#${issue.number}`)} ${truncate(issue.title, TITLE_WIDTH3)}`),
|
|
4026
4728
|
...closed.map((issue) => colors.dim(` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)} (closed)`))
|
|
4027
4729
|
];
|
|
4028
|
-
return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined,
|
|
4730
|
+
return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined, process32.stdout, process32.env, "accent"), ...lines].join(`
|
|
4029
4731
|
`);
|
|
4030
4732
|
});
|
|
4031
4733
|
console.log(blocks.join(`
|
|
@@ -4113,7 +4815,7 @@ ${closeUsage2}`);
|
|
|
4113
4815
|
}
|
|
4114
4816
|
const open = await openIssues(undefined, values.repo, found.id);
|
|
4115
4817
|
if (open.length > 0 && values.force !== true)
|
|
4116
|
-
fail(`milestone ${found.title} has ${
|
|
4818
|
+
fail(`milestone ${found.title} has ${bo(open.length, "open issue")}:
|
|
4117
4819
|
${open.map((issue) => ` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)}`).join(`
|
|
4118
4820
|
`)}`, 1, `${runHint(`ft milestone close ${found.title} --force`, "close it with them open")}, or move them with \`ft edit <n> -m <milestone>\``);
|
|
4119
4821
|
await closeMilestone(found.id, values.repo);
|
|
@@ -4282,8 +4984,8 @@ function report2(plan, added, skipped) {
|
|
|
4282
4984
|
}
|
|
4283
4985
|
|
|
4284
4986
|
// src/commands/release.ts
|
|
4285
|
-
import { basename as basename3, join as
|
|
4286
|
-
import
|
|
4987
|
+
import { basename as basename3, join as join14 } from "path";
|
|
4988
|
+
import process34 from "process";
|
|
4287
4989
|
var {$: $2 } = globalThis.Bun;
|
|
4288
4990
|
|
|
4289
4991
|
// src/commands/watch.ts
|
|
@@ -4423,6 +5125,14 @@ async function watch2(args) {
|
|
|
4423
5125
|
|
|
4424
5126
|
// src/commands/release-checks.ts
|
|
4425
5127
|
var limits = { pushMs: 5 * 60000 };
|
|
5128
|
+
async function pushToOrigin(refspecs, onStart) {
|
|
5129
|
+
const prompts = askpass();
|
|
5130
|
+
try {
|
|
5131
|
+
return await runTool("git push", ["git", "push", ...refspecs], { timeoutMs: limits.pushMs, onStart, env: prompts?.env });
|
|
5132
|
+
} finally {
|
|
5133
|
+
prompts?.close();
|
|
5134
|
+
}
|
|
5135
|
+
}
|
|
4426
5136
|
var NO_RUN2 = 3 * 60000;
|
|
4427
5137
|
var RUNS_LOOKED_AT = 20;
|
|
4428
5138
|
async function alreadyPassed(sha) {
|
|
@@ -4439,7 +5149,7 @@ async function testsPass(sha, branch, timeout, json = false) {
|
|
|
4439
5149
|
const held = holdSignals();
|
|
4440
5150
|
let push;
|
|
4441
5151
|
try {
|
|
4442
|
-
push = await
|
|
5152
|
+
push = await pushToOrigin(["origin", `${sha}:refs/heads/${branch}`], (child) => held.forward(child));
|
|
4443
5153
|
} finally {
|
|
4444
5154
|
held.release();
|
|
4445
5155
|
}
|
|
@@ -4459,7 +5169,7 @@ ${push.stderr.trim()}`, 1);
|
|
|
4459
5169
|
|
|
4460
5170
|
// src/commands/release-many.ts
|
|
4461
5171
|
import { readdir } from "fs/promises";
|
|
4462
|
-
import { join as
|
|
5172
|
+
import { join as join11 } from "path";
|
|
4463
5173
|
|
|
4464
5174
|
// src/commands/release-version.ts
|
|
4465
5175
|
var LEVELS = new Set(["patch", "minor", "major", "prepatch", "preminor", "premajor", "prerelease"]);
|
|
@@ -4508,11 +5218,11 @@ function parseTargets(spec, level) {
|
|
|
4508
5218
|
});
|
|
4509
5219
|
}
|
|
4510
5220
|
async function publishable() {
|
|
4511
|
-
const root =
|
|
5221
|
+
const root = join11(await git(["rev-parse", "--show-toplevel"]), "packages");
|
|
4512
5222
|
const folders = (await readdir(root, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name).toSorted();
|
|
4513
5223
|
const found = [];
|
|
4514
5224
|
for (const folder of folders) {
|
|
4515
|
-
const file = Bun.file(
|
|
5225
|
+
const file = Bun.file(join11(root, folder, "package.json"));
|
|
4516
5226
|
if (await file.exists() && (await file.json()).private !== true)
|
|
4517
5227
|
found.push(folder);
|
|
4518
5228
|
}
|
|
@@ -4520,13 +5230,13 @@ async function publishable() {
|
|
|
4520
5230
|
}
|
|
4521
5231
|
|
|
4522
5232
|
// src/commands/release-plan.ts
|
|
4523
|
-
import { basename as basename2, join as
|
|
4524
|
-
import
|
|
5233
|
+
import { basename as basename2, join as join12, relative } from "path";
|
|
5234
|
+
import process33 from "process";
|
|
4525
5235
|
async function planOf({ level, dir, prefix }, registry) {
|
|
4526
|
-
const file = Bun.file(
|
|
5236
|
+
const file = Bun.file(join12(dir ?? ".", "package.json"));
|
|
4527
5237
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
4528
|
-
const name = pkg?.name ?? basename2(dir ??
|
|
4529
|
-
const where = dir === undefined ? "" : ` in ${relative(
|
|
5238
|
+
const name = pkg?.name ?? basename2(dir ?? process33.cwd());
|
|
5239
|
+
const where = dir === undefined ? "" : ` in ${relative(process33.cwd(), dir) || "."}`;
|
|
4530
5240
|
let version;
|
|
4531
5241
|
let bump;
|
|
4532
5242
|
if (level === undefined) {
|
|
@@ -4538,7 +5248,7 @@ async function planOf({ level, dir, prefix }, registry) {
|
|
|
4538
5248
|
console.log(`would release ${name} ${version}, tagged ${tag}`);
|
|
4539
5249
|
} else {
|
|
4540
5250
|
if (pkg?.version === undefined)
|
|
4541
|
-
fail(`no version in ${
|
|
5251
|
+
fail(`no version in ${join12(dir ?? ".", "package.json")}`);
|
|
4542
5252
|
version = nextVersion(pkg.version, level);
|
|
4543
5253
|
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
5254
|
console.log(`would release ${name} ${pkg.version} -> ${version}, tagged ${prefix}${version}`);
|
|
@@ -4565,25 +5275,26 @@ async function printPlan({ releases, branch, base, timeout, registry }) {
|
|
|
4565
5275
|
}
|
|
4566
5276
|
|
|
4567
5277
|
// src/commands/release-steps.ts
|
|
4568
|
-
import { join as
|
|
5278
|
+
import { join as join13, relative as relative2, resolve as resolve5 } from "path";
|
|
5279
|
+
init_text();
|
|
4569
5280
|
var {$ } = globalThis.Bun;
|
|
4570
5281
|
var registryWait = { tries: 12, poll: 5000 };
|
|
4571
5282
|
var REGISTRY_INFO_MS = 30000;
|
|
4572
5283
|
async function packageDir(value) {
|
|
4573
|
-
for (const dir of [resolve5(value),
|
|
4574
|
-
if (await Bun.file(
|
|
5284
|
+
for (const dir of [resolve5(value), join13(await git(["rev-parse", "--show-toplevel"]), "packages", value)]) {
|
|
5285
|
+
if (await Bun.file(join13(dir, "package.json")).exists())
|
|
4575
5286
|
return dir;
|
|
4576
5287
|
}
|
|
4577
5288
|
fail(`no package.json in ${value} nor in packages/${value}`);
|
|
4578
5289
|
}
|
|
4579
5290
|
async function commitPackageBump(dir, prefix) {
|
|
4580
|
-
const { version } = await Bun.file(
|
|
5291
|
+
const { version } = await Bun.file(join13(dir, "package.json")).json();
|
|
4581
5292
|
const root = await git(["rev-parse", "--show-toplevel"]);
|
|
4582
5293
|
const tag = `${prefix}${version}`;
|
|
4583
5294
|
const lock = await $`bun install --lockfile-only`.cwd(root).quiet().nothrow();
|
|
4584
5295
|
if (lock.exitCode !== 0)
|
|
4585
5296
|
fail(`bun install --lockfile-only after the bump: ${lock.stderr.toString().trim()}`);
|
|
4586
|
-
await git(["add",
|
|
5297
|
+
await git(["add", join13(dir, "package.json"), join13(root, "bun.lock")]);
|
|
4587
5298
|
await git(["commit", "-q", "-m", tag]);
|
|
4588
5299
|
await git(["tag", "-a", tag, "-m", tag]);
|
|
4589
5300
|
}
|
|
@@ -4607,11 +5318,11 @@ async function rollBack(preBump, dirs) {
|
|
|
4607
5318
|
try {
|
|
4608
5319
|
if (dirs.length > 0) {
|
|
4609
5320
|
const root = await git(["rev-parse", "--show-toplevel"]);
|
|
4610
|
-
const paths = [...dirs.map((dir) =>
|
|
5321
|
+
const paths = [...dirs.map((dir) => join13(dir, "package.json")), join13(root, "bun.lock")].map((path) => relative2(root, path));
|
|
4611
5322
|
const tracked = (await git(["ls-tree", "-r", "--full-tree", "--name-only", "HEAD", "--", ...paths])).split(`
|
|
4612
5323
|
`).filter((path) => path !== "");
|
|
4613
5324
|
if (tracked.length > 0)
|
|
4614
|
-
await git(["restore", "--source=HEAD", "--staged", "--worktree", "--", ...tracked.map((path) =>
|
|
5325
|
+
await git(["restore", "--source=HEAD", "--staged", "--worktree", "--", ...tracked.map((path) => join13(root, path))]);
|
|
4615
5326
|
}
|
|
4616
5327
|
for (const commit of (await git(["rev-list", `${preBump}..HEAD`])).split(`
|
|
4617
5328
|
`).filter(Boolean)) {
|
|
@@ -4630,7 +5341,7 @@ async function settleMilestone(version, tag, say = console.log) {
|
|
|
4630
5341
|
if (found === undefined)
|
|
4631
5342
|
return;
|
|
4632
5343
|
const [done, left] = await Promise.all([closedIssues(found.id), openIssues(undefined, undefined, found.id)]);
|
|
4633
|
-
say(`milestone ${found.title}: ${
|
|
5344
|
+
say(`milestone ${found.title}: ${bo(done.length, "closed issue")}${done.length === 0 ? "" : `
|
|
4634
5345
|
${done.map((issue) => ` #${issue.number} ${issue.title}`).join(`
|
|
4635
5346
|
`)}`}`);
|
|
4636
5347
|
if (left.length > 0)
|
|
@@ -4733,7 +5444,7 @@ ${usage6}`);
|
|
|
4733
5444
|
const tags = bumped.map((each) => each.tag);
|
|
4734
5445
|
let push;
|
|
4735
5446
|
try {
|
|
4736
|
-
push = await
|
|
5447
|
+
push = await pushToOrigin(["--atomic", "origin", `HEAD:refs/heads/${branch}`, ...tags.map((tag) => `refs/tags/${tag}`)], (child) => held.forward(child));
|
|
4737
5448
|
} catch (error) {
|
|
4738
5449
|
isPushUnknown = true;
|
|
4739
5450
|
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 +5463,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4752
5463
|
}
|
|
4753
5464
|
const heads = new Set(bumped.map((each) => each.head));
|
|
4754
5465
|
const manifests = await Promise.all(bumped.map(async (each) => {
|
|
4755
|
-
const file = Bun.file(
|
|
5466
|
+
const file = Bun.file(join14(each.dir ?? ".", "package.json"));
|
|
4756
5467
|
return await file.exists() ? await file.json() : undefined;
|
|
4757
5468
|
}));
|
|
4758
5469
|
const released = new Set;
|
|
@@ -4771,7 +5482,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4771
5482
|
if (late !== undefined)
|
|
4772
5483
|
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
5484
|
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 ?
|
|
5485
|
+
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
5486
|
if (followed.code !== 0) {
|
|
4776
5487
|
report();
|
|
4777
5488
|
return followed.code;
|
|
@@ -4946,7 +5657,7 @@ async function runs(args) {
|
|
|
4946
5657
|
}
|
|
4947
5658
|
|
|
4948
5659
|
// src/cli.ts
|
|
4949
|
-
|
|
5660
|
+
process35.exitCode = await runCli({
|
|
4950
5661
|
name: "ft",
|
|
4951
5662
|
about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
|
|
4952
5663
|
replaces: "tea api calls piped through jq, and sleep loops waiting on CI",
|
|
@@ -4963,7 +5674,7 @@ process31.exitCode = await runCli({
|
|
|
4963
5674
|
drop: { run: drop, summary: "give back an issue this session took", group: "Issues and claims" },
|
|
4964
5675
|
issue: { run: issue, summary: "an issue's claim, description and numbered boxes, -c comments", group: "Issues and claims" },
|
|
4965
5676
|
new: { run: newIssue, summary: "create an issue from -t and a description file or stdin", group: "Issues and claims" },
|
|
4966
|
-
edit: { run:
|
|
5677
|
+
edit: { run: edit2, summary: "replace an issue's title or description, from a file or stdin", group: "Issues and claims" },
|
|
4967
5678
|
tick: { run: tick, summary: "tick checklist boxes of an issue, -m to comment too", group: "Issues and claims" },
|
|
4968
5679
|
comment: { run: commentOn, summary: "comment on an issue, from stdin when no text is given", group: "Issues and claims" },
|
|
4969
5680
|
fixed: { run: fixed, summary: 'comment "Fixed in <sha>" and close an issue', group: "Issues and claims" },
|