@kaynooo/cli-pkg 0.16.0 → 0.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cli.js +450 -127
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -38,8 +38,8 @@ var init_advisory = __esm(() => {
|
|
|
38
38
|
SEVERITIES = ["low", "moderate", "high", "critical"];
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
// ../../node_modules/.bun/@kaynooo+utils@3.
|
|
42
|
-
function
|
|
41
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rkhsft4a.js
|
|
42
|
+
function G(t, e, { plural: r, zero: n = "singular" } = {}) {
|
|
43
43
|
if (e === 1 || e === 0 && n === "singular")
|
|
44
44
|
return t;
|
|
45
45
|
if (r !== undefined)
|
|
@@ -52,10 +52,10 @@ function K(t, e, { plural: r, zero: n = "singular" } = {}) {
|
|
|
52
52
|
return `${t.slice(0, -1)}ves`;
|
|
53
53
|
return Gt.test(t) ? `${t.slice(0, -2)}ves` : `${t}s`;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
return `${t} ${
|
|
55
|
+
function bo(t, e, { zero: r = "plural", ...n } = {}) {
|
|
56
|
+
return `${t} ${G(e, t, { ...n, zero: r })}`;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function Ao(t, e, r = "...") {
|
|
59
59
|
let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
|
|
60
60
|
if (t.length <= e)
|
|
61
61
|
return t;
|
|
@@ -66,8 +66,8 @@ function ko(t, e, r = "...") {
|
|
|
66
66
|
c = c.trimEnd();
|
|
67
67
|
return s ? (c + n).slice(0, l) : c + n;
|
|
68
68
|
}
|
|
69
|
-
var ct, N, Ot, Gt, Nt, Y, be,
|
|
70
|
-
var
|
|
69
|
+
var ct, N, Ot, Gt, Nt, Y, be, W;
|
|
70
|
+
var init_chunk_rkhsft4a = __esm(() => {
|
|
71
71
|
ct = /[aeiou]y$/;
|
|
72
72
|
N = new Map;
|
|
73
73
|
Ot = /(?:leaf|loaf|thief|wolf|half|calf|elf|sheaf|scarf|dwarf|hoof|wharf)$/;
|
|
@@ -75,12 +75,12 @@ var init_chunk_rxztfxgv = __esm(() => {
|
|
|
75
75
|
Nt = /\s+\S*$/;
|
|
76
76
|
Y = /\s/;
|
|
77
77
|
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));
|
|
78
|
-
|
|
78
|
+
W = new Map;
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
// ../../node_modules/.bun/@kaynooo+utils@3.
|
|
81
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/text.js
|
|
82
82
|
var init_text = __esm(() => {
|
|
83
|
-
|
|
83
|
+
init_chunk_rkhsft4a();
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
// ../kit/src/mode.ts
|
|
@@ -107,7 +107,7 @@ var init_mode = __esm(() => {
|
|
|
107
107
|
AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
-
// ../../node_modules/.bun/@kaynooo+utils@3.
|
|
110
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
111
111
|
function b(r) {
|
|
112
112
|
let e = r.startsWith("#") ? r.slice(1) : r;
|
|
113
113
|
if (!G2.test(e))
|
|
@@ -131,7 +131,7 @@ function f(r, e = []) {
|
|
|
131
131
|
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
132
132
|
let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
|
|
133
133
|
return new Proxy(c, { get(t, i) {
|
|
134
|
-
let a =
|
|
134
|
+
let a = B[i];
|
|
135
135
|
if (Array.isArray(a)) {
|
|
136
136
|
let s = g.get(i);
|
|
137
137
|
if (s === undefined)
|
|
@@ -154,10 +154,10 @@ function f(r, e = []) {
|
|
|
154
154
|
function Fe(r = {}) {
|
|
155
155
|
return f(r);
|
|
156
156
|
}
|
|
157
|
-
var G2,
|
|
157
|
+
var G2, B, h, o;
|
|
158
158
|
var init_chunk_x450vn3m = __esm(() => {
|
|
159
159
|
G2 = /^[a-f0-9]+$/i;
|
|
160
|
-
|
|
160
|
+
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") => {
|
|
161
161
|
let [l, n, c] = b(r);
|
|
162
162
|
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
163
163
|
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
@@ -165,7 +165,7 @@ var init_chunk_x450vn3m = __esm(() => {
|
|
|
165
165
|
o = Fe();
|
|
166
166
|
});
|
|
167
167
|
|
|
168
|
-
// ../../node_modules/.bun/@kaynooo+utils@3.
|
|
168
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/tools/colors.js
|
|
169
169
|
var init_colors = __esm(() => {
|
|
170
170
|
init_chunk_x450vn3m();
|
|
171
171
|
});
|
|
@@ -191,11 +191,14 @@ var init_config = __esm(() => {
|
|
|
191
191
|
// ../kit/src/user-config.ts
|
|
192
192
|
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
193
193
|
import { homedir } from "os";
|
|
194
|
-
import { join as join2 } from "path";
|
|
194
|
+
import { isAbsolute, join as join2 } from "path";
|
|
195
195
|
import process4 from "process";
|
|
196
|
+
function xdgFolder(value, fallback) {
|
|
197
|
+
return value !== undefined && isAbsolute(value) ? value : fallback;
|
|
198
|
+
}
|
|
196
199
|
function configBase(where = {}) {
|
|
197
200
|
const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
|
|
198
|
-
return xdg
|
|
201
|
+
return xdgFolder(xdg, join2(where.home ?? homedir(), ".config"));
|
|
199
202
|
}
|
|
200
203
|
function userConfigPath(bin, where = {}) {
|
|
201
204
|
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
@@ -225,6 +228,37 @@ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } fr
|
|
|
225
228
|
import { homedir as homedir2 } from "os";
|
|
226
229
|
import { join as join3, resolve as resolve2 } from "path";
|
|
227
230
|
import process5 from "process";
|
|
231
|
+
function toLinear(channel) {
|
|
232
|
+
const value = channel / 255;
|
|
233
|
+
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
234
|
+
}
|
|
235
|
+
function toOklab(hex) {
|
|
236
|
+
const [r, g, b] = [1, 3, 5].map((at) => toLinear(Number.parseInt(hex.slice(at, at + 2), 16)));
|
|
237
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
238
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
239
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
240
|
+
return [0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s];
|
|
241
|
+
}
|
|
242
|
+
function fromOklab([lightness, a, b]) {
|
|
243
|
+
const l = (lightness + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
244
|
+
const m = (lightness - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
245
|
+
const s = (lightness - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
246
|
+
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];
|
|
247
|
+
return `#${channels.map((channel) => fromLinear(channel).toString(16).padStart(2, "0")).join("")}`;
|
|
248
|
+
}
|
|
249
|
+
function gradientAt(theme, ratio) {
|
|
250
|
+
if (theme.gradient === undefined)
|
|
251
|
+
return;
|
|
252
|
+
const key = theme.gradient.join();
|
|
253
|
+
let ends = ENDS.get(key);
|
|
254
|
+
if (ends === undefined) {
|
|
255
|
+
ends = [toOklab(theme.gradient[0]), toOklab(theme.gradient[1])];
|
|
256
|
+
ENDS.set(key, ends);
|
|
257
|
+
}
|
|
258
|
+
const at = Math.min(1, Math.max(0, ratio));
|
|
259
|
+
const [from, to] = ends;
|
|
260
|
+
return fromOklab(from.map((start, index) => start + (to[index] - start) * at));
|
|
261
|
+
}
|
|
228
262
|
function isColorSpec(spec) {
|
|
229
263
|
if (typeof spec === "number")
|
|
230
264
|
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
@@ -254,6 +288,9 @@ function tinted(colors, spec, env = process5.env) {
|
|
|
254
288
|
return chain[token] ?? chain;
|
|
255
289
|
}, colors);
|
|
256
290
|
}
|
|
291
|
+
function shaded(theme, colors, glyph, cells, width, env = process5.env) {
|
|
292
|
+
return Array.from({ length: cells }, (_, index) => tinted(colors, gradientAt(theme, width <= 1 ? 0 : index / (width - 1)) ?? theme.colors.accent, env)(glyph)).join("");
|
|
293
|
+
}
|
|
257
294
|
function isRecord(value) {
|
|
258
295
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
259
296
|
}
|
|
@@ -378,7 +415,7 @@ function activeTheme() {
|
|
|
378
415
|
}
|
|
379
416
|
return current;
|
|
380
417
|
}
|
|
381
|
-
var ENDS, DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
|
|
418
|
+
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 = "";
|
|
382
419
|
var init_theme = __esm(() => {
|
|
383
420
|
init_config();
|
|
384
421
|
init_user_config();
|
|
@@ -490,7 +527,7 @@ function formatAge(date, now = Date.now()) {
|
|
|
490
527
|
return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
|
|
491
528
|
}
|
|
492
529
|
function truncate(text, width) {
|
|
493
|
-
return
|
|
530
|
+
return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
|
|
494
531
|
}
|
|
495
532
|
function textWidth(text) {
|
|
496
533
|
return Bun.stringWidth(text);
|
|
@@ -553,7 +590,27 @@ var init_format = __esm(() => {
|
|
|
553
590
|
// ../kit/src/help.ts
|
|
554
591
|
import process8 from "process";
|
|
555
592
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
556
|
-
|
|
593
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
594
|
+
`);
|
|
595
|
+
const blank = lines.indexOf("");
|
|
596
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
597
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
598
|
+
const colon = synopses[0].indexOf(": ");
|
|
599
|
+
const inline = synopses[0].slice(colon + 2);
|
|
600
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
601
|
+
if (colon !== -1)
|
|
602
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
603
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
604
|
+
`)}`;
|
|
605
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
606
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
607
|
+
return [head, ...lead, ...rest].join(`
|
|
608
|
+
`);
|
|
609
|
+
}
|
|
610
|
+
function prose(line, colors) {
|
|
611
|
+
if (colors.cyan("x") === "x")
|
|
612
|
+
return line;
|
|
613
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
557
614
|
}
|
|
558
615
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
559
616
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -602,13 +659,14 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
602
659
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
603
660
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
604
661
|
}
|
|
605
|
-
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
662
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
606
663
|
var init_help = __esm(() => {
|
|
607
664
|
init_mode();
|
|
608
665
|
init_style();
|
|
609
666
|
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
610
667
|
USAGE_PREFIX = /^usage:\s*/i;
|
|
611
668
|
FULL_STOP = /\.$/;
|
|
669
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
612
670
|
});
|
|
613
671
|
|
|
614
672
|
// ../kit/src/text.ts
|
|
@@ -873,7 +931,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
873
931
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
874
932
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
875
933
|
}
|
|
876
|
-
var DASHES, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
934
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
877
935
|
var init_args = __esm(() => {
|
|
878
936
|
init_format();
|
|
879
937
|
init_help();
|
|
@@ -881,14 +939,21 @@ var init_args = __esm(() => {
|
|
|
881
939
|
init_help();
|
|
882
940
|
init_input();
|
|
883
941
|
DASHES = /^-+/;
|
|
942
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
884
943
|
Exit = class Exit extends Error {
|
|
885
944
|
code;
|
|
886
945
|
hint;
|
|
946
|
+
[EXIT] = true;
|
|
887
947
|
constructor(message, code, hint) {
|
|
888
948
|
super(message);
|
|
889
949
|
this.code = code;
|
|
890
950
|
this.hint = hint;
|
|
891
951
|
}
|
|
952
|
+
static [Symbol.hasInstance](value) {
|
|
953
|
+
if (this !== Exit)
|
|
954
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
955
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
956
|
+
}
|
|
892
957
|
};
|
|
893
958
|
UsageError = class UsageError extends Exit {
|
|
894
959
|
constructor(message, hint) {
|
|
@@ -902,7 +967,7 @@ var init_args = __esm(() => {
|
|
|
902
967
|
};
|
|
903
968
|
completion = { active: false };
|
|
904
969
|
OUTPUT_OPTIONS = {
|
|
905
|
-
color: { type: "string", description: "auto (on a terminal alone
|
|
970
|
+
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
906
971
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
907
972
|
};
|
|
908
973
|
UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
@@ -943,6 +1008,7 @@ var init_chart = __esm(() => {
|
|
|
943
1008
|
});
|
|
944
1009
|
|
|
945
1010
|
// ../kit/src/process.ts
|
|
1011
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
946
1012
|
import { constants } from "os";
|
|
947
1013
|
import process12 from "process";
|
|
948
1014
|
function exitCodeOf(code, signal) {
|
|
@@ -952,6 +1018,21 @@ function exitCodeOf(code, signal) {
|
|
|
952
1018
|
return 128 + signal;
|
|
953
1019
|
return signal === null ? 129 : 128 + constants.signals[signal];
|
|
954
1020
|
}
|
|
1021
|
+
function groupsOf(pid) {
|
|
1022
|
+
try {
|
|
1023
|
+
const stat = readFileSync4(`/proc/${pid}/stat`, "utf8");
|
|
1024
|
+
const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
|
|
1025
|
+
return { group: Number(fields[2]), foreground: Number(fields[5]) };
|
|
1026
|
+
} catch {
|
|
1027
|
+
return;
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
function heardTheTerminal(child) {
|
|
1031
|
+
if (child.pid === undefined)
|
|
1032
|
+
return false;
|
|
1033
|
+
const own = groupsOf("self");
|
|
1034
|
+
return own !== undefined && own.group === own.foreground && groupsOf(child.pid)?.group === own.group;
|
|
1035
|
+
}
|
|
955
1036
|
function holdSignals(cleanup) {
|
|
956
1037
|
let received;
|
|
957
1038
|
let child;
|
|
@@ -970,7 +1051,8 @@ function holdSignals(cleanup) {
|
|
|
970
1051
|
function onSignal(signal) {
|
|
971
1052
|
received = signal;
|
|
972
1053
|
if (child !== undefined) {
|
|
973
|
-
|
|
1054
|
+
if (!GROUP_SIGNALS.has(signal) || !heardTheTerminal(child))
|
|
1055
|
+
child.kill(signal);
|
|
974
1056
|
return;
|
|
975
1057
|
}
|
|
976
1058
|
if (cleanup === undefined)
|
|
@@ -983,10 +1065,10 @@ function holdSignals(cleanup) {
|
|
|
983
1065
|
process12.on(signal, onSignal);
|
|
984
1066
|
return held;
|
|
985
1067
|
}
|
|
986
|
-
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
1068
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
987
1069
|
const chunks = [];
|
|
988
1070
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
989
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1071
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
990
1072
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
991
1073
|
const timers = [];
|
|
992
1074
|
const killGroup = (killing) => {
|
|
@@ -1026,12 +1108,19 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
1026
1108
|
stop();
|
|
1027
1109
|
continue;
|
|
1028
1110
|
}
|
|
1111
|
+
if (state.truncated)
|
|
1112
|
+
continue;
|
|
1113
|
+
let kept = data;
|
|
1029
1114
|
if (state.kept + data.length > maxBytes) {
|
|
1115
|
+
let cut = maxBytes - state.kept;
|
|
1116
|
+
while (cut > 0 && ((data[cut] ?? 0) & 192) === 128)
|
|
1117
|
+
cut--;
|
|
1118
|
+
kept = data.subarray(0, cut);
|
|
1030
1119
|
state.truncated = true;
|
|
1031
|
-
continue;
|
|
1032
1120
|
}
|
|
1033
|
-
state.kept +=
|
|
1034
|
-
|
|
1121
|
+
state.kept += kept.length;
|
|
1122
|
+
if (kept.length > 0)
|
|
1123
|
+
chunks.push({ stream: name, data: kept });
|
|
1035
1124
|
}
|
|
1036
1125
|
};
|
|
1037
1126
|
try {
|
|
@@ -1048,6 +1137,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
1048
1137
|
const joined = () => Buffer.concat(chunks.map(({ data }) => data));
|
|
1049
1138
|
let output;
|
|
1050
1139
|
let text;
|
|
1140
|
+
let stdout;
|
|
1051
1141
|
return {
|
|
1052
1142
|
code: exitCodeOf(proc.exitCode, proc.signalCode),
|
|
1053
1143
|
chunks,
|
|
@@ -1058,12 +1148,16 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
1058
1148
|
},
|
|
1059
1149
|
get text() {
|
|
1060
1150
|
return text ??= (output ??= joined()).toString();
|
|
1151
|
+
},
|
|
1152
|
+
get stdout() {
|
|
1153
|
+
return stdout ??= Buffer.concat(chunks.filter((chunk) => chunk.stream === "stdout").map((chunk) => chunk.data)).toString();
|
|
1061
1154
|
}
|
|
1062
1155
|
};
|
|
1063
1156
|
}
|
|
1064
|
-
var KILL_GRACE_MS = 2000, SIGNALS;
|
|
1157
|
+
var KILL_GRACE_MS = 2000, SIGNALS, GROUP_SIGNALS;
|
|
1065
1158
|
var init_process = __esm(() => {
|
|
1066
1159
|
SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
1160
|
+
GROUP_SIGNALS = new Set(["SIGINT", "SIGHUP"]);
|
|
1067
1161
|
});
|
|
1068
1162
|
|
|
1069
1163
|
// ../kit/src/progress.ts
|
|
@@ -1075,10 +1169,14 @@ function liveRegion(render, stream = process13.stderr, env = process13.env) {
|
|
|
1075
1169
|
}, print: (text) => void stream.write(`${text}
|
|
1076
1170
|
`), stop: () => {
|
|
1077
1171
|
return;
|
|
1172
|
+
}, pause: () => () => {
|
|
1173
|
+
return;
|
|
1078
1174
|
} };
|
|
1079
1175
|
const write = stream.write.bind(stream);
|
|
1080
1176
|
let frame = 0;
|
|
1081
1177
|
let drawn = false;
|
|
1178
|
+
let paused = false;
|
|
1179
|
+
let stopped = false;
|
|
1082
1180
|
const columns = () => {
|
|
1083
1181
|
const now = stream.getWindowSize?.()[0] ?? stream.columns;
|
|
1084
1182
|
return now === undefined || now === 0 ? 80 : now;
|
|
@@ -1089,6 +1187,8 @@ function liveRegion(render, stream = process13.stderr, env = process13.env) {
|
|
|
1089
1187
|
drawn = false;
|
|
1090
1188
|
};
|
|
1091
1189
|
const draw = () => {
|
|
1190
|
+
if (paused)
|
|
1191
|
+
return;
|
|
1092
1192
|
const width = columns() - 1;
|
|
1093
1193
|
const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
|
|
1094
1194
|
const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
|
|
@@ -1100,16 +1200,17 @@ function liveRegion(render, stream = process13.stderr, env = process13.env) {
|
|
|
1100
1200
|
`)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
|
|
1101
1201
|
drawn = true;
|
|
1102
1202
|
};
|
|
1103
|
-
|
|
1203
|
+
let timer = setInterval(draw, FRAME_MS);
|
|
1104
1204
|
stream.on?.("resize", draw);
|
|
1105
|
-
|
|
1106
|
-
|
|
1205
|
+
let restore = interceptOutput(clear);
|
|
1206
|
+
let release = swallowInput();
|
|
1107
1207
|
const onExit = () => {
|
|
1108
1208
|
clear();
|
|
1109
1209
|
release();
|
|
1110
1210
|
};
|
|
1111
1211
|
const signals = holdSignals(stop);
|
|
1112
1212
|
function stop() {
|
|
1213
|
+
stopped = true;
|
|
1113
1214
|
clearInterval(timer);
|
|
1114
1215
|
stream.off?.("resize", draw);
|
|
1115
1216
|
clear();
|
|
@@ -1118,6 +1219,29 @@ function liveRegion(render, stream = process13.stderr, env = process13.env) {
|
|
|
1118
1219
|
process13.off("exit", onExit);
|
|
1119
1220
|
signals.release();
|
|
1120
1221
|
}
|
|
1222
|
+
function pause() {
|
|
1223
|
+
if (paused || stopped)
|
|
1224
|
+
return () => {
|
|
1225
|
+
return;
|
|
1226
|
+
};
|
|
1227
|
+
paused = true;
|
|
1228
|
+
clearInterval(timer);
|
|
1229
|
+
stream.off?.("resize", draw);
|
|
1230
|
+
clear();
|
|
1231
|
+
restore();
|
|
1232
|
+
release();
|
|
1233
|
+
return () => {
|
|
1234
|
+
if (!paused || stopped)
|
|
1235
|
+
return;
|
|
1236
|
+
paused = false;
|
|
1237
|
+
timer = setInterval(draw, FRAME_MS);
|
|
1238
|
+
timer.unref();
|
|
1239
|
+
stream.on?.("resize", draw);
|
|
1240
|
+
restore = interceptOutput(clear);
|
|
1241
|
+
release = swallowInput();
|
|
1242
|
+
draw();
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1121
1245
|
timer.unref();
|
|
1122
1246
|
process13.on("exit", onExit);
|
|
1123
1247
|
return {
|
|
@@ -1128,9 +1252,54 @@ function liveRegion(render, stream = process13.stderr, env = process13.env) {
|
|
|
1128
1252
|
`);
|
|
1129
1253
|
draw();
|
|
1130
1254
|
},
|
|
1131
|
-
stop
|
|
1255
|
+
stop,
|
|
1256
|
+
pause
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
function progressLine(stream = process13.stderr, env = process13.env) {
|
|
1260
|
+
const colors = paint(stream, env);
|
|
1261
|
+
const write = stream.write.bind(stream);
|
|
1262
|
+
const begun = performance.now();
|
|
1263
|
+
let started = begun;
|
|
1264
|
+
let current;
|
|
1265
|
+
const region = liveRegion((spinner) => current === undefined ? [] : [tintedParts(progressParts(current, spinner, performance.now() - started), colors)], stream, env);
|
|
1266
|
+
const end = (line) => {
|
|
1267
|
+
region.stop();
|
|
1268
|
+
write(`${line}
|
|
1269
|
+
`);
|
|
1270
|
+
};
|
|
1271
|
+
return {
|
|
1272
|
+
update: (progress) => {
|
|
1273
|
+
const step = current?.step;
|
|
1274
|
+
current = progress;
|
|
1275
|
+
if (progress.step !== step) {
|
|
1276
|
+
started = performance.now();
|
|
1277
|
+
region.redraw();
|
|
1278
|
+
}
|
|
1279
|
+
},
|
|
1280
|
+
stop: region.stop,
|
|
1281
|
+
pause: region.pause,
|
|
1282
|
+
done: (text) => end(marked("ok", text, stream, formatDuration(performance.now() - begun), env)),
|
|
1283
|
+
failed: (text) => end(marked("problem", text, stream, undefined, env))
|
|
1132
1284
|
};
|
|
1133
1285
|
}
|
|
1286
|
+
function progressParts({ step, done, total, unit }, spinner, ms) {
|
|
1287
|
+
const { theme } = activeTheme();
|
|
1288
|
+
const parts = [{ text: spinner, tint: (colors) => tinted(colors, theme.colors.accent) }, { text: ` ${step}`, tint: () => plain }];
|
|
1289
|
+
if (total !== undefined && total > 0) {
|
|
1290
|
+
const counted = Math.min(done ?? 0, total);
|
|
1291
|
+
const filled = Math.round(counted / total * BAR_WIDTH);
|
|
1292
|
+
parts.push({ text: " ", tint: () => plain }, { text: theme.glyphs.bar.repeat(filled), tint: (colors) => () => shaded(theme, colors, theme.glyphs.bar, filled, BAR_WIDTH) }, { text: theme.glyphs.bar.repeat(BAR_WIDTH - filled), tint: (colors) => colors.dim }, { text: ` ${counted}/${total}${unit === undefined ? "" : ` ${unit}`}`, tint: (colors) => colors.dim });
|
|
1293
|
+
}
|
|
1294
|
+
parts.push({ text: ` ${formatElapsed(ms)}`, tint: (colors) => colors.dim });
|
|
1295
|
+
return parts;
|
|
1296
|
+
}
|
|
1297
|
+
function plain(text) {
|
|
1298
|
+
return text;
|
|
1299
|
+
}
|
|
1300
|
+
function tintedParts(parts, colors) {
|
|
1301
|
+
return parts.map(({ text, tint }) => tint(colors)(text)).join("");
|
|
1302
|
+
}
|
|
1134
1303
|
function cutToWidth(line, width) {
|
|
1135
1304
|
if (Bun.stringWidth(line) <= width)
|
|
1136
1305
|
return line;
|
|
@@ -1198,7 +1367,7 @@ function interceptOutput(clear) {
|
|
|
1198
1367
|
}
|
|
1199
1368
|
};
|
|
1200
1369
|
}
|
|
1201
|
-
var FRAMES, FRAME_MS = 200, CLEAR_BELOW = "\r\x1B[J", ESC, ESCAPE_CODE, RESET_STYLE, CTRL_C = 3, CLOSE_LINK, CONSOLE_METHODS;
|
|
1370
|
+
var FRAMES, FRAME_MS = 200, BAR_WIDTH = 20, CLEAR_BELOW = "\r\x1B[J", ESC, ESCAPE_CODE, RESET_STYLE, CTRL_C = 3, CLOSE_LINK, CONSOLE_METHODS;
|
|
1202
1371
|
var init_progress = __esm(() => {
|
|
1203
1372
|
init_format();
|
|
1204
1373
|
init_process();
|
|
@@ -1227,17 +1396,117 @@ var init_ci = __esm(() => {
|
|
|
1227
1396
|
init_tool();
|
|
1228
1397
|
});
|
|
1229
1398
|
|
|
1230
|
-
// ../kit/src/
|
|
1399
|
+
// ../kit/src/askpass.ts
|
|
1231
1400
|
import process14 from "process";
|
|
1401
|
+
async function askpassClient(argv) {
|
|
1402
|
+
const socketPath = process14.env[SOCKET_VARIABLE];
|
|
1403
|
+
if (socketPath === undefined)
|
|
1404
|
+
return;
|
|
1405
|
+
const request = { prompt: argv[0] ?? "", ...process14.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
|
|
1406
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
1407
|
+
let received = "";
|
|
1408
|
+
try {
|
|
1409
|
+
await Bun.connect({
|
|
1410
|
+
unix: socketPath,
|
|
1411
|
+
socket: {
|
|
1412
|
+
open: (socket) => void socket.write(`${JSON.stringify(request)}
|
|
1413
|
+
`),
|
|
1414
|
+
data: (_, chunk) => {
|
|
1415
|
+
received += chunk.toString();
|
|
1416
|
+
},
|
|
1417
|
+
close: () => resolve(received),
|
|
1418
|
+
error: () => resolve("")
|
|
1419
|
+
}
|
|
1420
|
+
});
|
|
1421
|
+
} catch {
|
|
1422
|
+
return 1;
|
|
1423
|
+
}
|
|
1424
|
+
const reply = await promise;
|
|
1425
|
+
if (reply === "")
|
|
1426
|
+
return 1;
|
|
1427
|
+
const { answer } = JSON.parse(reply);
|
|
1428
|
+
if (request.notice === true)
|
|
1429
|
+
return 0;
|
|
1430
|
+
if (answer === undefined)
|
|
1431
|
+
return 1;
|
|
1432
|
+
process14.stdout.write(`${answer}
|
|
1433
|
+
`);
|
|
1434
|
+
return 0;
|
|
1435
|
+
}
|
|
1436
|
+
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1437
|
+
var init_askpass = () => {};
|
|
1438
|
+
|
|
1439
|
+
// ../kit/src/completions.ts
|
|
1440
|
+
function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
|
|
1441
|
+
if (shell === "fish")
|
|
1442
|
+
return `${header}
|
|
1443
|
+
${FISH_FUNCTION}
|
|
1444
|
+
${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
|
|
1445
|
+
`).join("")}`;
|
|
1446
|
+
if (shell === "bash")
|
|
1447
|
+
return `${header}
|
|
1448
|
+
${BASH_FUNCTION}
|
|
1449
|
+
complete -F __kaynooo_cli_complete ${bins.join(" ")}
|
|
1450
|
+
`;
|
|
1451
|
+
return `${header}
|
|
1452
|
+
${ZSH_FUNCTION}
|
|
1453
|
+
compdef __kaynooo_cli_complete ${bins.join(" ")}
|
|
1454
|
+
`;
|
|
1455
|
+
}
|
|
1456
|
+
var COMPLETION_SHELLS, FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
|
|
1457
|
+
set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
|
|
1458
|
+
set -l current (commandline -ct)
|
|
1459
|
+
for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
|
|
1460
|
+
if test "$line" = __files__
|
|
1461
|
+
__fish_complete_path $current
|
|
1462
|
+
else
|
|
1463
|
+
echo $line
|
|
1464
|
+
end
|
|
1465
|
+
end
|
|
1466
|
+
end`, BASH_FUNCTION = `__kaynooo_cli_complete() {
|
|
1467
|
+
local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
|
|
1468
|
+
local -a lines
|
|
1469
|
+
COMPREPLY=()
|
|
1470
|
+
lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
|
|
1471
|
+
for line in "\${lines[@]}"; do
|
|
1472
|
+
if [[ $line == __files__ ]]; then
|
|
1473
|
+
COMPREPLY+=($(compgen -f -- "$cur"))
|
|
1474
|
+
else
|
|
1475
|
+
words+="\${line%%$'\\t'*}"$'\\n'
|
|
1476
|
+
fi
|
|
1477
|
+
done
|
|
1478
|
+
COMPREPLY+=($(compgen -W "$words" -- "$cur"))
|
|
1479
|
+
}`, ZSH_FUNCTION = `__kaynooo_cli_complete() {
|
|
1480
|
+
local line
|
|
1481
|
+
local -a described plain
|
|
1482
|
+
for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
|
|
1483
|
+
if [[ $line == __files__ ]]; then
|
|
1484
|
+
_files
|
|
1485
|
+
elif [[ $line == *$'\\t'* ]]; then
|
|
1486
|
+
described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
|
|
1487
|
+
else
|
|
1488
|
+
plain+=("$line")
|
|
1489
|
+
fi
|
|
1490
|
+
done
|
|
1491
|
+
(( \${#described} )) && _describe -V value described
|
|
1492
|
+
(( \${#plain} )) && compadd -- "\${plain[@]}"
|
|
1493
|
+
return 0
|
|
1494
|
+
}`;
|
|
1495
|
+
var init_completions = __esm(() => {
|
|
1496
|
+
COMPLETION_SHELLS = ["fish", "bash", "zsh"];
|
|
1497
|
+
});
|
|
1498
|
+
|
|
1499
|
+
// ../kit/src/notify.ts
|
|
1500
|
+
import process15 from "process";
|
|
1232
1501
|
function base64(text) {
|
|
1233
1502
|
return Buffer.from(text).toString("base64");
|
|
1234
1503
|
}
|
|
1235
|
-
function notification(title, body, env =
|
|
1236
|
-
const id = `kit${
|
|
1504
|
+
function notification(title, body, env = process15.env) {
|
|
1505
|
+
const id = `kit${process15.pid}`;
|
|
1237
1506
|
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\\`];
|
|
1238
1507
|
return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
|
|
1239
1508
|
}
|
|
1240
|
-
function notifyEnd(command, code, ms, { stream =
|
|
1509
|
+
function notifyEnd(command, code, ms, { stream = process15.stderr, env = process15.env } = {}) {
|
|
1241
1510
|
if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
|
|
1242
1511
|
return;
|
|
1243
1512
|
stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
|
|
@@ -1251,25 +1520,25 @@ var init_notify = __esm(() => {
|
|
|
1251
1520
|
// ../kit/src/logs.ts
|
|
1252
1521
|
var DAY_MS, CLI_FOLDER = "kaynooo-cli";
|
|
1253
1522
|
var init_logs = __esm(() => {
|
|
1523
|
+
init_user_config();
|
|
1254
1524
|
DAY_MS = 24 * 60 * 60 * 1000;
|
|
1255
1525
|
});
|
|
1256
1526
|
|
|
1257
1527
|
// ../kit/src/usage.ts
|
|
1258
1528
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1259
1529
|
import { homedir as homedir3 } from "os";
|
|
1260
|
-
import { dirname as dirname2,
|
|
1261
|
-
import
|
|
1530
|
+
import { dirname as dirname2, join as join4 } from "path";
|
|
1531
|
+
import process16 from "process";
|
|
1262
1532
|
function noteUsageError(message) {
|
|
1263
1533
|
usageError = message;
|
|
1264
1534
|
}
|
|
1265
|
-
function stateHome(env =
|
|
1266
|
-
|
|
1267
|
-
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
1535
|
+
function stateHome(env = process16.env) {
|
|
1536
|
+
return xdgFolder(env.XDG_STATE_HOME, join4(homedir3(), ".local", "state"));
|
|
1268
1537
|
}
|
|
1269
|
-
function usagePath(env =
|
|
1538
|
+
function usagePath(env = process16.env) {
|
|
1270
1539
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1271
1540
|
}
|
|
1272
|
-
function usageRecorded(env =
|
|
1541
|
+
function usageRecorded(env = process16.env) {
|
|
1273
1542
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1274
1543
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1275
1544
|
}
|
|
@@ -1278,12 +1547,12 @@ function flagNames(argv) {
|
|
|
1278
1547
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
1279
1548
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
1280
1549
|
}
|
|
1281
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
1550
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
1282
1551
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
1283
1552
|
usageError = undefined;
|
|
1284
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1553
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
1285
1554
|
}
|
|
1286
|
-
function recordUsage(entry, env =
|
|
1555
|
+
function recordUsage(entry, env = process16.env) {
|
|
1287
1556
|
if (!usageRecorded(env))
|
|
1288
1557
|
return;
|
|
1289
1558
|
try {
|
|
@@ -1296,14 +1565,15 @@ function recordUsage(entry, env = process15.env) {
|
|
|
1296
1565
|
var UNKNOWN_OPTION2, FLAG_NAME, LONGEST_NAME = 40, usageError;
|
|
1297
1566
|
var init_usage = __esm(() => {
|
|
1298
1567
|
init_logs();
|
|
1568
|
+
init_user_config();
|
|
1299
1569
|
UNKNOWN_OPTION2 = /unknown option '(--[a-z][a-z0-9-]*)[=']/;
|
|
1300
1570
|
FLAG_NAME = /^(?:--[a-z][a-z0-9-]*|-[a-zA-Z])$/;
|
|
1301
1571
|
});
|
|
1302
1572
|
|
|
1303
1573
|
// ../kit/src/cli.ts
|
|
1304
|
-
import { readFileSync as
|
|
1574
|
+
import { readFileSync as readFileSync5, realpathSync as realpathSync2 } from "fs";
|
|
1305
1575
|
import { dirname as dirname3, join as join5 } from "path";
|
|
1306
|
-
import
|
|
1576
|
+
import process17 from "process";
|
|
1307
1577
|
async function commandRows(all, colors) {
|
|
1308
1578
|
const commands = shown(all);
|
|
1309
1579
|
const width = Math.max(0, ...Object.keys(commands).map((name) => name.length));
|
|
@@ -1338,6 +1608,10 @@ function takeOutputFlags(argv) {
|
|
|
1338
1608
|
async function resolveSummary(summary) {
|
|
1339
1609
|
return typeof summary === "string" ? summary : summary();
|
|
1340
1610
|
}
|
|
1611
|
+
function lookup({ commands, aliases }, word) {
|
|
1612
|
+
const name = aliases !== undefined && Object.hasOwn(aliases, word) ? aliases[word] ?? word : word;
|
|
1613
|
+
return Object.hasOwn(commands, name) ? commands[name] : undefined;
|
|
1614
|
+
}
|
|
1341
1615
|
function scopeOf(commands, extra, aliases) {
|
|
1342
1616
|
return { commands: typeof commands === "function" ? {} : commands, lazy: [...typeof commands === "function" ? [commands] : [], ...extra === undefined ? [] : [extra]], aliases };
|
|
1343
1617
|
}
|
|
@@ -1377,8 +1651,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1377
1651
|
`);
|
|
1378
1652
|
}
|
|
1379
1653
|
function printError(prefix, message, hint, cause) {
|
|
1380
|
-
const colors = paint(
|
|
1381
|
-
const styled = takesControlCodes(
|
|
1654
|
+
const colors = paint(process17.stderr);
|
|
1655
|
+
const styled = takesControlCodes(process17.stderr);
|
|
1382
1656
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1383
1657
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1384
1658
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1421,23 +1695,23 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1421
1695
|
}
|
|
1422
1696
|
}
|
|
1423
1697
|
if (name === undefined && level.path.length > 1) {
|
|
1424
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1698
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process17.stderr));
|
|
1425
1699
|
return 2;
|
|
1426
1700
|
}
|
|
1427
1701
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1428
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1702
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process17.stdout));
|
|
1429
1703
|
return 0;
|
|
1430
1704
|
}
|
|
1431
1705
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
1432
1706
|
console.log(version);
|
|
1433
1707
|
return 0;
|
|
1434
1708
|
}
|
|
1435
|
-
let command = level
|
|
1709
|
+
let command = lookup(level, name);
|
|
1436
1710
|
let rest = args;
|
|
1437
1711
|
let ran = name;
|
|
1438
1712
|
if (command === undefined && level.lazy.length > 0) {
|
|
1439
1713
|
level = await expand(level, [...level.path.slice(1), ...argv]);
|
|
1440
|
-
command = level
|
|
1714
|
+
command = lookup(level, name);
|
|
1441
1715
|
}
|
|
1442
1716
|
if (command === undefined && level.defaultCommand !== undefined) {
|
|
1443
1717
|
command = level.commands[level.defaultCommand];
|
|
@@ -1515,18 +1789,19 @@ async function leafCandidates(run, words) {
|
|
|
1515
1789
|
async function candidates(scope, defaultCommand, words, before = []) {
|
|
1516
1790
|
const [word = "", ...rest] = words;
|
|
1517
1791
|
const listing = rest.length === 0 && !word.startsWith("-");
|
|
1518
|
-
let { commands
|
|
1519
|
-
let command =
|
|
1792
|
+
let { commands } = scope;
|
|
1793
|
+
let command = lookup(scope, word);
|
|
1520
1794
|
if (listing || command === undefined) {
|
|
1521
|
-
|
|
1522
|
-
|
|
1795
|
+
const expanded = await expand(scope, [...before, ...words]);
|
|
1796
|
+
commands = expanded.commands;
|
|
1797
|
+
command = lookup(expanded, word);
|
|
1523
1798
|
}
|
|
1524
1799
|
if (listing) {
|
|
1525
1800
|
const own = await Promise.all(Object.entries(shown(commands)).map(async ([name, { summary }]) => `${name} ${await resolveSummary(summary)}`));
|
|
1526
1801
|
const fallback = defaultCommand === undefined ? undefined : commands[defaultCommand];
|
|
1527
1802
|
const values = fallback !== undefined && "run" in fallback ? await leafCandidates(fallback.run, [word]) : [];
|
|
1528
1803
|
const valueOf = (line) => line.slice(0, line.includes("\t") ? line.indexOf("\t") : undefined);
|
|
1529
|
-
return [...own, ...values.filter((line) => line !== FILES && !(valueOf(line)
|
|
1804
|
+
return [...own, ...values.filter((line) => line !== FILES && !Object.hasOwn(commands, valueOf(line)))];
|
|
1530
1805
|
}
|
|
1531
1806
|
if (command === undefined) {
|
|
1532
1807
|
const fallback = defaultCommand === undefined ? undefined : commands[defaultCommand];
|
|
@@ -1534,6 +1809,18 @@ async function candidates(scope, defaultCommand, words, before = []) {
|
|
|
1534
1809
|
}
|
|
1535
1810
|
return "commands" in command ? candidates(scopeOf(command.commands, command.extraCommands, command.aliases), undefined, rest, [...before, word]) : leafCandidates(command.run, rest);
|
|
1536
1811
|
}
|
|
1812
|
+
function flagValue([flag = "", ...rest]) {
|
|
1813
|
+
return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
|
|
1814
|
+
}
|
|
1815
|
+
function printCompletionScript(name, args) {
|
|
1816
|
+
const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
|
|
1817
|
+
if (shell === undefined || args.length !== 1) {
|
|
1818
|
+
printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
|
|
1819
|
+
return 2;
|
|
1820
|
+
}
|
|
1821
|
+
console.log(completionScript(shell, [name]).trimEnd());
|
|
1822
|
+
return 0;
|
|
1823
|
+
}
|
|
1537
1824
|
async function printCandidates(found) {
|
|
1538
1825
|
for (const line of await found)
|
|
1539
1826
|
console.log(line);
|
|
@@ -1546,7 +1833,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1546
1833
|
} catch {}
|
|
1547
1834
|
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1548
1835
|
try {
|
|
1549
|
-
const { version } = JSON.parse(
|
|
1836
|
+
const { version } = JSON.parse(readFileSync5(join5(dir, "package.json"), "utf8"));
|
|
1550
1837
|
if (typeof version === "string")
|
|
1551
1838
|
return version;
|
|
1552
1839
|
} catch {}
|
|
@@ -1556,15 +1843,20 @@ function packageVersion(entry = Bun.main) {
|
|
|
1556
1843
|
}
|
|
1557
1844
|
async function runCli(cli, argv = scriptArgs()) {
|
|
1558
1845
|
const version = cli.version ?? packageVersion();
|
|
1846
|
+
const answered = await askpassClient(argv);
|
|
1847
|
+
if (answered !== undefined)
|
|
1848
|
+
return answered;
|
|
1559
1849
|
if (argv[0] === COMPLETE)
|
|
1560
1850
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
1851
|
+
if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
|
|
1852
|
+
return printCompletionScript(cli.name, flagValue(argv));
|
|
1561
1853
|
const started = performance.now();
|
|
1562
1854
|
const code = await dispatch({ path: [cli.name], header: (colors, about) => `${colors.bold(cli.name)} ${colors.dim(version)} ${about}`, summary: cli.about, ...scopeOf(cli.commands, cli.extraCommands, cli.aliases), defaultCommand: cli.defaultCommand, runBare: cli.runBare === true, examples: cli.examples, replaces: cli.replaces }, argv, { version, redact: cli.redact });
|
|
1563
1855
|
const command = commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv);
|
|
1564
1856
|
notifyEnd(command === undefined ? cli.name : `${cli.name} ${command}`, code, performance.now() - started);
|
|
1565
1857
|
if (cli.usage !== false) {
|
|
1566
1858
|
try {
|
|
1567
|
-
recordUsage(usageEntry(cli.name, command, argv, code));
|
|
1859
|
+
recordUsage(usageEntry(cli.name, command, argv, code, { ms: performance.now() - started }));
|
|
1568
1860
|
} catch {}
|
|
1569
1861
|
}
|
|
1570
1862
|
return code;
|
|
@@ -1573,8 +1865,7 @@ function commandPath(scope, argv) {
|
|
|
1573
1865
|
const path = [];
|
|
1574
1866
|
let level = scope;
|
|
1575
1867
|
for (const word of argv.filter((each) => !each.startsWith("-"))) {
|
|
1576
|
-
const
|
|
1577
|
-
const command = Object.hasOwn(level.commands, name) ? level.commands[name] : undefined;
|
|
1868
|
+
const command = lookup(level, word);
|
|
1578
1869
|
if (command === undefined)
|
|
1579
1870
|
break;
|
|
1580
1871
|
path.push(word);
|
|
@@ -1584,10 +1875,12 @@ function commandPath(scope, argv) {
|
|
|
1584
1875
|
}
|
|
1585
1876
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1586
1877
|
}
|
|
1587
|
-
var LEVEL_OPTIONS, TOP_OPTIONS, COMPLETE = "__complete", FILES = "__files__";
|
|
1878
|
+
var LEVEL_OPTIONS, TOP_OPTIONS, COMPLETE = "__complete", FILES = "__files__", COMPLETIONS = "--completions";
|
|
1588
1879
|
var init_cli = __esm(() => {
|
|
1589
1880
|
init_args();
|
|
1590
1881
|
init_argv();
|
|
1882
|
+
init_askpass();
|
|
1883
|
+
init_completions();
|
|
1591
1884
|
init_notify();
|
|
1592
1885
|
init_style();
|
|
1593
1886
|
init_text2();
|
|
@@ -1596,7 +1889,11 @@ var init_cli = __esm(() => {
|
|
|
1596
1889
|
...OUTPUT_OPTIONS,
|
|
1597
1890
|
help: { type: "boolean", short: "h", description: "show this help" }
|
|
1598
1891
|
};
|
|
1599
|
-
TOP_OPTIONS = {
|
|
1892
|
+
TOP_OPTIONS = {
|
|
1893
|
+
...LEVEL_OPTIONS,
|
|
1894
|
+
version: { type: "boolean", short: "v", description: "print the version" },
|
|
1895
|
+
completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
|
|
1896
|
+
};
|
|
1600
1897
|
});
|
|
1601
1898
|
// ../kit/src/excerpt.ts
|
|
1602
1899
|
var init_excerpt = __esm(() => {
|
|
@@ -1647,19 +1944,20 @@ var init_limit = __esm(() => {
|
|
|
1647
1944
|
});
|
|
1648
1945
|
|
|
1649
1946
|
// ../kit/src/pool.ts
|
|
1650
|
-
async function pool(items, limit, task) {
|
|
1947
|
+
async function pool(items, limit, task, onDone) {
|
|
1651
1948
|
const results = Array.from({ length: items.length });
|
|
1652
1949
|
let next = 0;
|
|
1950
|
+
let done = 0;
|
|
1653
1951
|
async function worker() {
|
|
1654
1952
|
while (next < items.length) {
|
|
1655
1953
|
const index = next++;
|
|
1656
1954
|
results[index] = await task(items[index]);
|
|
1955
|
+
onDone?.(++done, items.length);
|
|
1657
1956
|
}
|
|
1658
1957
|
}
|
|
1659
1958
|
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
1660
1959
|
return results;
|
|
1661
1960
|
}
|
|
1662
|
-
|
|
1663
1961
|
// ../kit/src/report.ts
|
|
1664
1962
|
var init_report = __esm(() => {
|
|
1665
1963
|
init_cli();
|
|
@@ -1668,9 +1966,10 @@ var init_report = __esm(() => {
|
|
|
1668
1966
|
});
|
|
1669
1967
|
|
|
1670
1968
|
// ../kit/src/secrets.ts
|
|
1671
|
-
var SECRET_WORDS;
|
|
1969
|
+
var SECRET_WORDS, NOT_PASSWORDS;
|
|
1672
1970
|
var init_secrets = __esm(() => {
|
|
1673
1971
|
SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1972
|
+
NOT_PASSWORDS = new Set(["compass", "encompass", "bypass", "overpass", "underpass", "surpass", "trespass"]);
|
|
1674
1973
|
});
|
|
1675
1974
|
|
|
1676
1975
|
// ../kit/src/sessions.ts
|
|
@@ -1694,7 +1993,7 @@ var init_watch = __esm(() => {
|
|
|
1694
1993
|
// ../kit/src/workspace-root.ts
|
|
1695
1994
|
import { homedir as homedir4 } from "os";
|
|
1696
1995
|
import { dirname as dirname4, join as join6, resolve as resolve4 } from "path";
|
|
1697
|
-
import
|
|
1996
|
+
import process18 from "process";
|
|
1698
1997
|
function expandHome(path, home) {
|
|
1699
1998
|
if (path === "~")
|
|
1700
1999
|
return home;
|
|
@@ -1704,7 +2003,7 @@ function configured(env, home) {
|
|
|
1704
2003
|
const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
|
|
1705
2004
|
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
1706
2005
|
}
|
|
1707
|
-
function workspaceRoot({ given, env =
|
|
2006
|
+
function workspaceRoot({ given, env = process18.env, home = homedir4() } = {}) {
|
|
1708
2007
|
const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
|
|
1709
2008
|
return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
|
|
1710
2009
|
}
|
|
@@ -1721,6 +2020,7 @@ var init_src = __esm(() => {
|
|
|
1721
2020
|
init_chart();
|
|
1722
2021
|
init_ci();
|
|
1723
2022
|
init_cli();
|
|
2023
|
+
init_completions();
|
|
1724
2024
|
init_config();
|
|
1725
2025
|
init_folders();
|
|
1726
2026
|
init_format();
|
|
@@ -2375,7 +2675,7 @@ function squash(name) {
|
|
|
2375
2675
|
return name.toLowerCase().replace(SEPARATORS, "");
|
|
2376
2676
|
}
|
|
2377
2677
|
function resemblance(name, popular) {
|
|
2378
|
-
if (scopeOf2(
|
|
2678
|
+
if (scopeOf2(popular) === "" && scopeOf2(name) !== "" && baseName(name) === popular && popular.length >= MIN_LENGTH)
|
|
2379
2679
|
return `${popular} under another scope`;
|
|
2380
2680
|
if (squash(name) === squash(popular))
|
|
2381
2681
|
return `${popular} spelled with other separators or case`;
|
|
@@ -2491,7 +2791,7 @@ function ageDays(published, now) {
|
|
|
2491
2791
|
return Number.isNaN(at) ? undefined : (now - at) / DAY;
|
|
2492
2792
|
}
|
|
2493
2793
|
function daysAgo(age) {
|
|
2494
|
-
return age < 1 ? "less than a day" :
|
|
2794
|
+
return age < 1 ? "less than a day" : bo(Math.floor(age), "day");
|
|
2495
2795
|
}
|
|
2496
2796
|
function installScriptsOf(version) {
|
|
2497
2797
|
return Object.fromEntries(INSTALL_SCRIPTS.flatMap((name) => version?.scripts?.[name] === undefined ? [] : [[name, version.scripts[name]]]));
|
|
@@ -2513,7 +2813,8 @@ function publisherWarnings(packument, version) {
|
|
|
2513
2813
|
return warnings;
|
|
2514
2814
|
const by = current._npmUser?.name;
|
|
2515
2815
|
const before = previous._npmUser?.name;
|
|
2516
|
-
|
|
2816
|
+
const toTrusted = current._npmUser?.trustedPublisher !== undefined && previous._npmUser?.trustedPublisher === undefined;
|
|
2817
|
+
if (by !== undefined && before !== undefined && by !== before && !toTrusted)
|
|
2517
2818
|
warnings.push(`${version} was published by ${by}, ${previous.version} by ${before}`);
|
|
2518
2819
|
if (previous.dist?.attestations !== undefined && current.dist?.attestations === undefined)
|
|
2519
2820
|
warnings.push(`${version} has no provenance attestation, ${previous.version} had one`);
|
|
@@ -2601,7 +2902,7 @@ var init_analyze = __esm(() => {
|
|
|
2601
2902
|
// src/config.ts
|
|
2602
2903
|
import { homedir as homedir5 } from "os";
|
|
2603
2904
|
import { dirname as dirname5, join as join7 } from "path";
|
|
2604
|
-
import
|
|
2905
|
+
import process20 from "process";
|
|
2605
2906
|
function expand2(value, env) {
|
|
2606
2907
|
let missing = false;
|
|
2607
2908
|
const expanded = value.replace(ENV_REFERENCE, (_, braced, bare) => {
|
|
@@ -2690,7 +2991,7 @@ async function readIfThere(path) {
|
|
|
2690
2991
|
const file = Bun.file(path);
|
|
2691
2992
|
return await file.exists() ? file.text() : undefined;
|
|
2692
2993
|
}
|
|
2693
|
-
async function loadConfigs(cwd =
|
|
2994
|
+
async function loadConfigs(cwd = process20.cwd(), env = process20.env, home = homedir5()) {
|
|
2694
2995
|
const directories = [];
|
|
2695
2996
|
for (let dir = cwd;!directories.includes(dir); dir = dirname5(dir))
|
|
2696
2997
|
directories.push(dir);
|
|
@@ -2723,7 +3024,7 @@ function parseSettings(text) {
|
|
|
2723
3024
|
settings.concurrency = raw.concurrency;
|
|
2724
3025
|
return settings;
|
|
2725
3026
|
}
|
|
2726
|
-
async function loadSettings(cwd =
|
|
3027
|
+
async function loadSettings(cwd = process20.cwd(), home) {
|
|
2727
3028
|
const files = [];
|
|
2728
3029
|
for (let dir = cwd;!files.includes(join7(dir, SETTINGS_FILE)); dir = dirname5(dir))
|
|
2729
3030
|
files.push(join7(dir, SETTINGS_FILE));
|
|
@@ -2759,7 +3060,7 @@ var init_config2 = __esm(() => {
|
|
|
2759
3060
|
function wrapper(short = "", long = [], operands = 0, runsString = false) {
|
|
2760
3061
|
return { short, long, operands, runsString };
|
|
2761
3062
|
}
|
|
2762
|
-
var SEPARATORS2, PLAIN_BREAKERS, GLOB_CHARS, COMMENT_PREFIXES, DOUBLE_QUOTED_ESCAPES, KEYWORDS, SHELLS, SCANNED_PROGRAMS, COMMAND_STRING_PROGRAMS, POWERSHELL, SHELL_VALUE_OPTIONS, FISH_VALUE_OPTIONS, PRINTERS, FIND_EXEC, WRAPPERS;
|
|
3063
|
+
var SEPARATORS2, PLAIN_BREAKERS, GLOB_CHARS, COMMENT_PREFIXES, DOUBLE_QUOTED_ESCAPES, KEYWORDS, FISH_COMBINERS, SHELLS, SCANNED_PROGRAMS, COMMAND_STRING_PROGRAMS, POWERSHELL, SHELL_VALUE_OPTIONS, FISH_VALUE_OPTIONS, PRINTERS, FIND_EXEC, RUNNER, WRAPPERS;
|
|
2763
3064
|
var init_shell = __esm(() => {
|
|
2764
3065
|
SEPARATORS2 = new Set([`
|
|
2765
3066
|
`, ";", "|"]);
|
|
@@ -2768,6 +3069,7 @@ var init_shell = __esm(() => {
|
|
|
2768
3069
|
COMMENT_PREFIXES = new Set([";", "&", "|", "(", ")"]);
|
|
2769
3070
|
DOUBLE_QUOTED_ESCAPES = new Set(["$", "`", '"', "\\"]);
|
|
2770
3071
|
KEYWORDS = new Set(["then", "do", "else", "if", "elif", "while", "until", "!", "{", "}"]);
|
|
3072
|
+
FISH_COMBINERS = new Set(["and", "or", "not"]);
|
|
2771
3073
|
SHELLS = new Set(["sh", "bash", "zsh", "dash", "ash", "ksh", "fish", "csh", "tcsh", "nu", "xonsh", "elvish", "pwsh", "powershell"]);
|
|
2772
3074
|
SCANNED_PROGRAMS = new Set(["su", "runuser", "flock"]);
|
|
2773
3075
|
COMMAND_STRING_PROGRAMS = new Set([...SHELLS, ...SCANNED_PROGRAMS]);
|
|
@@ -2776,6 +3078,7 @@ var init_shell = __esm(() => {
|
|
|
2776
3078
|
FISH_VALUE_OPTIONS = new Set(["-C", "--init-command"]);
|
|
2777
3079
|
PRINTERS = new Set(["echo", "printf"]);
|
|
2778
3080
|
FIND_EXEC = new Set(["-exec", "-execdir", "-ok", "-okdir"]);
|
|
3081
|
+
RUNNER = { ...wrapper(), afterDashes: true };
|
|
2779
3082
|
WRAPPERS = new Map([
|
|
2780
3083
|
["command", wrapper()],
|
|
2781
3084
|
["builtin", wrapper()],
|
|
@@ -2797,7 +3100,23 @@ var init_shell = __esm(() => {
|
|
|
2797
3100
|
["parallel", wrapper("jnNSaIPlLdTsC", ["--jobs", "--max-args", "--max-replace-args", "--sshlogin", "--arg-file", "--delimiter", "--colsep"], 0, true)],
|
|
2798
3101
|
["unbuffer", wrapper()],
|
|
2799
3102
|
["systemd-run", wrapper("puEMH", ["--property", "--unit", "--description", "--slice", "--setenv", "--machine", "--host", "--uid", "--gid", "--working-directory", "--nice", "--service-type"])],
|
|
2800
|
-
["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])]
|
|
3103
|
+
["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])],
|
|
3104
|
+
["strace", wrapper("abeEIoOpPsSuUX", ["--trace", "--output", "--attach", "--string-limit", "--user", "--env", "--columns", "--trace-path", "--signal", "--status", "--summary-sort-by", "--summary-columns", "--const-print-style", "--interruptible", "--detach-on"])],
|
|
3105
|
+
["ltrace", wrapper("aeFlnopsuxX", ["--output", "--user", "--library", "--config", "--align", "--indent"])],
|
|
3106
|
+
["taskset", wrapper("", [], 1)],
|
|
3107
|
+
["fakeroot", wrapper("lsib", ["--lib", "--faked"])],
|
|
3108
|
+
["sshpass", wrapper("pfdP")],
|
|
3109
|
+
["coproc", wrapper()],
|
|
3110
|
+
["proxychains", wrapper("f")],
|
|
3111
|
+
["proxychains4", wrapper("f")],
|
|
3112
|
+
["torsocks", wrapper("upaP", ["--user", "--pass", "--address", "--port"])],
|
|
3113
|
+
["chrt", wrapper("TPD", ["--sched-runtime", "--sched-period", "--sched-deadline"], 1)],
|
|
3114
|
+
["unshare", wrapper("SGRw", ["--setuid", "--setgid", "--root", "--wd", "--map-user", "--map-group", "--map-users", "--map-groups", "--propagation", "--setgroups"])],
|
|
3115
|
+
["nsenter", wrapper("tSG", ["--target", "--setuid", "--setgid"])],
|
|
3116
|
+
["out", RUNNER],
|
|
3117
|
+
["slot", RUNNER],
|
|
3118
|
+
["waitfor", RUNNER],
|
|
3119
|
+
["base", RUNNER]
|
|
2801
3120
|
]);
|
|
2802
3121
|
});
|
|
2803
3122
|
|
|
@@ -2805,7 +3124,7 @@ var init_shell = __esm(() => {
|
|
|
2805
3124
|
function actions(byAction) {
|
|
2806
3125
|
return new Map(Object.entries(byAction).flatMap(([action, names]) => names.map((name) => [name, action])));
|
|
2807
3126
|
}
|
|
2808
|
-
var LOCKFILES, ACTIONS, OPTION_FLAGS, DIR_FLAGS, VALUE_FLAGS;
|
|
3127
|
+
var LOCKFILES, NPM_INSTALLS, NPM_TEST_INSTALLS, ACTIONS, OPTION_FLAGS, DIR_FLAGS, VALUE_FLAGS;
|
|
2809
3128
|
var init_pin = __esm(() => {
|
|
2810
3129
|
init_shell();
|
|
2811
3130
|
LOCKFILES = [
|
|
@@ -2815,17 +3134,19 @@ var init_pin = __esm(() => {
|
|
|
2815
3134
|
["yarn.lock", "yarn"],
|
|
2816
3135
|
["package-lock.json", "npm"]
|
|
2817
3136
|
];
|
|
3137
|
+
NPM_INSTALLS = ["install", "i", "in", "ins", "inst", "insta", "instal", "isnt", "isnta", "isntal", "isntall"];
|
|
3138
|
+
NPM_TEST_INSTALLS = ["it", "install-test", "cit", "clean-install-test", "install-ci-test"];
|
|
2818
3139
|
ACTIONS = {
|
|
2819
3140
|
bun: actions({ install: ["install", "i"], add: ["add", "a"], remove: ["remove", "rm"], update: ["update"] }),
|
|
2820
3141
|
pnpm: actions({ install: ["install", "i"], add: ["add"], remove: ["remove", "rm"], update: ["update", "up"] }),
|
|
2821
3142
|
yarn: new Map([...actions({ install: ["", "install"], add: ["add"], remove: ["remove"], update: ["upgrade"] }), ["upgrade-interactive", null], ["import", null]]),
|
|
2822
|
-
npm: actions({
|
|
2823
|
-
install:
|
|
3143
|
+
npm: new Map([...actions({
|
|
3144
|
+
install: NPM_INSTALLS,
|
|
2824
3145
|
add: ["add"],
|
|
2825
3146
|
frozen: ["ci", "clean-install", "ic", "install-clean", "isntall-clean"],
|
|
2826
3147
|
remove: ["uninstall", "unlink", "remove", "rm", "r", "un"],
|
|
2827
3148
|
update: ["update", "u", "up", "upgrade", "udpate"]
|
|
2828
|
-
})
|
|
3149
|
+
}), ...NPM_TEST_INSTALLS.map((name) => [name, null])])
|
|
2829
3150
|
};
|
|
2830
3151
|
OPTION_FLAGS = new Map([
|
|
2831
3152
|
["-D", "dev"],
|
|
@@ -2840,7 +3161,7 @@ var init_pin = __esm(() => {
|
|
|
2840
3161
|
});
|
|
2841
3162
|
|
|
2842
3163
|
// src/consumers.ts
|
|
2843
|
-
import { existsSync as existsSync4, readdirSync, readFileSync as
|
|
3164
|
+
import { existsSync as existsSync4, readdirSync, readFileSync as readFileSync6 } from "fs";
|
|
2844
3165
|
import { dirname as dirname6, join as join8, relative } from "path";
|
|
2845
3166
|
function packageFiles(dir, depth, found, ignored = ignoredFolders()) {
|
|
2846
3167
|
let entries;
|
|
@@ -2868,7 +3189,7 @@ function managerFor(dir, root) {
|
|
|
2868
3189
|
}
|
|
2869
3190
|
function readManifest(path) {
|
|
2870
3191
|
try {
|
|
2871
|
-
return JSON.parse(
|
|
3192
|
+
return JSON.parse(readFileSync6(path, "utf8"));
|
|
2872
3193
|
} catch {
|
|
2873
3194
|
return;
|
|
2874
3195
|
}
|
|
@@ -3022,11 +3343,9 @@ ${usage2}` : `${values.from} has no registry dependency to check`);
|
|
|
3022
3343
|
}
|
|
3023
3344
|
var usage2 = `pkg [check] <name>[@version]... | --from <package.json> | -
|
|
3024
3345
|
|
|
3025
|
-
Checks npm packages before they are added:
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
A \`.pkgrc.json\` (or ~/.config/kaynooo-cli/pkg.json) with \`licenses\` (SPDX ids) refuses a licence outside the list or a missing one, and \`blockSeverity\` (low, moderate, high, critical; high when unset) refuses a version with an advisory at that level or above.`, EXITS, options, WORDS;
|
|
3346
|
+
Checks npm packages before they are added: the name exists, the newest version at least two weeks old, downloads, licence, install scripts, a near miss of a popular name, and a changed publisher or lost provenance attestation.
|
|
3347
|
+
Names come from the arguments, from a package.json with --from, or from stdin.
|
|
3348
|
+
A \`.pkgrc.json\` with \`licenses\` refuses a licence outside the list, and \`blockSeverity\` a version with an advisory at that level or above.`, EXITS, options, WORDS;
|
|
3030
3349
|
var init_check = __esm(() => {
|
|
3031
3350
|
init_src();
|
|
3032
3351
|
init_advisories();
|
|
@@ -3114,7 +3433,7 @@ __export(exports_audit, {
|
|
|
3114
3433
|
audit: () => audit
|
|
3115
3434
|
});
|
|
3116
3435
|
import { join as join9, resolve as resolve6 } from "path";
|
|
3117
|
-
import
|
|
3436
|
+
import process21 from "process";
|
|
3118
3437
|
function hasFinding(audited) {
|
|
3119
3438
|
return audited.blocked || audited.warnings.length > 0 || audited.advisories.length > 0;
|
|
3120
3439
|
}
|
|
@@ -3130,7 +3449,8 @@ async function auditPackages(packages, context) {
|
|
|
3130
3449
|
const registry = registryFor(name, context.configs);
|
|
3131
3450
|
const input = { spec: { name, request: version }, packument: await lookup(name, registry), registry: new URL(registry.url).host, now: context.now, minAgeDays: context.minAgeDays, licenses: context.settings.licenses };
|
|
3132
3451
|
return { name, version, registry, input, safe: analyze(input).safe?.version };
|
|
3133
|
-
});
|
|
3452
|
+
}, (done, total) => context.onProgress?.({ step: "looking up", done, total, unit: "packages" }));
|
|
3453
|
+
context.onProgress?.({ step: "reading the advisories" });
|
|
3134
3454
|
const registries = new Map;
|
|
3135
3455
|
for (const { name, version, registry, safe } of looked) {
|
|
3136
3456
|
const group = registries.get(registry.url) ?? { registry, versions: {} };
|
|
@@ -3154,7 +3474,7 @@ async function auditPackages(packages, context) {
|
|
|
3154
3474
|
});
|
|
3155
3475
|
return { audited, unavailable };
|
|
3156
3476
|
}
|
|
3157
|
-
function renderAudit(findings, total, stream =
|
|
3477
|
+
function renderAudit(findings, total, stream = process21.stdout, env = process21.env) {
|
|
3158
3478
|
const id = role("id", stream, env);
|
|
3159
3479
|
const label = role("label", stream, env);
|
|
3160
3480
|
const warning = role("warn", stream, env);
|
|
@@ -3172,10 +3492,8 @@ function renderAudit(findings, total, stream = process20.stdout, env = process20
|
|
|
3172
3492
|
}
|
|
3173
3493
|
async function audit(args) {
|
|
3174
3494
|
const { values, positionals: [asked] } = parse(args, usage3, options2, { positionals: ["[dir]"], exits: EXITS2 });
|
|
3175
|
-
const level = values
|
|
3176
|
-
|
|
3177
|
-
fail(`--level takes ${SEVERITIES.join(", ")}, not ${level}`);
|
|
3178
|
-
const dir = resolve6(asked ?? process20.cwd());
|
|
3495
|
+
const { level } = values;
|
|
3496
|
+
const dir = resolve6(asked ?? process21.cwd());
|
|
3179
3497
|
const lock = Bun.file(join9(dir, "bun.lock"));
|
|
3180
3498
|
if (!await lock.exists())
|
|
3181
3499
|
fail(`no bun.lock in ${dir}`);
|
|
@@ -3190,7 +3508,14 @@ async function audit(args) {
|
|
|
3190
3508
|
level,
|
|
3191
3509
|
ignore: values.ignore ?? []
|
|
3192
3510
|
};
|
|
3193
|
-
const
|
|
3511
|
+
const progress = progressLine();
|
|
3512
|
+
let result;
|
|
3513
|
+
try {
|
|
3514
|
+
result = await auditPackages(packages, { ...context, onProgress: progress.update });
|
|
3515
|
+
} finally {
|
|
3516
|
+
progress.stop();
|
|
3517
|
+
}
|
|
3518
|
+
const { audited, unavailable } = result;
|
|
3194
3519
|
const findings = audited.filter(hasFinding);
|
|
3195
3520
|
if (values.json === true)
|
|
3196
3521
|
printJson(findings);
|
|
@@ -3204,11 +3529,11 @@ async function audit(args) {
|
|
|
3204
3529
|
}
|
|
3205
3530
|
var usage3 = `pkg audit [dir]
|
|
3206
3531
|
|
|
3207
|
-
Reads the bun.lock
|
|
3208
|
-
|
|
3209
|
-
Reach for it to vet one repository in depth; \`audit\` sweeps many repositories for advisories only, and shares --level, --prod and --ignore.`, EXITS2, options2, BATCH = 8, HIGH_SEVERITIES;
|
|
3532
|
+
Reads the bun.lock of the folder and runs on every registry package it pins the checks \`pkg check\` runs before an add, and lists the known advisories of each version, with the GHSA, the severity and the fixed version.
|
|
3533
|
+
Reach for it to vet one repository in depth; \`audit\` sweeps many repositories for advisories only.`, EXITS2, options2, BATCH = 8, HIGH_SEVERITIES;
|
|
3210
3534
|
var init_audit = __esm(() => {
|
|
3211
3535
|
init_src();
|
|
3536
|
+
init_progress();
|
|
3212
3537
|
init_advisories();
|
|
3213
3538
|
init_analyze();
|
|
3214
3539
|
init_config2();
|
|
@@ -3218,7 +3543,7 @@ var init_audit = __esm(() => {
|
|
|
3218
3543
|
options2 = {
|
|
3219
3544
|
json: jsonOption("[{name, version, license, blocked, warnings, advisories}] for the packages with a finding"),
|
|
3220
3545
|
"min-age": { type: "string", description: `days a version must be old (${DEFAULT_MIN_AGE_DAYS}, or the minAge setting)` },
|
|
3221
|
-
level: { type: "string", description: "lowest advisory severity listed and failing
|
|
3546
|
+
level: { type: "string", choices: SEVERITIES, default: "moderate", description: "lowest advisory severity listed and failing (moderate)" },
|
|
3222
3547
|
prod: { type: "boolean", description: "only the packages a production dependency or an optional one of a workspace reaches" },
|
|
3223
3548
|
ignore: { type: "string", multiple: true, description: "an advisory skipped by GHSA or numeric id, repeatable" }
|
|
3224
3549
|
};
|
|
@@ -3284,7 +3609,7 @@ async function outdatedCommand(args) {
|
|
|
3284
3609
|
}
|
|
3285
3610
|
var usage4 = `pkg outdated [dir]
|
|
3286
3611
|
|
|
3287
|
-
Lists the dependencies of the package.json
|
|
3612
|
+
Lists the dependencies of the package.json of the folder that have a newer version safe to take: the highest stable one at least --min-age days old, the \`safe\` of \`pkg check\`.
|
|
3288
3613
|
It reads only the registry's metadata, no advisories, and changes nothing: \`bun add --exact name@version\` adopts a row.`, EXITS3, OUTDATED_LIMIT = 50, BATCH2 = 8, FIRST_VERSION, DOT, options3;
|
|
3289
3614
|
var init_outdated = __esm(() => {
|
|
3290
3615
|
init_src();
|
|
@@ -3309,9 +3634,9 @@ var init_answers = __esm(() => {
|
|
|
3309
3634
|
});
|
|
3310
3635
|
|
|
3311
3636
|
// ../kit/src/job.ts
|
|
3312
|
-
import
|
|
3637
|
+
import process22 from "process";
|
|
3313
3638
|
function stopJob() {
|
|
3314
|
-
|
|
3639
|
+
process22.kill(0, "SIGTSTP");
|
|
3315
3640
|
}
|
|
3316
3641
|
var init_job = () => {};
|
|
3317
3642
|
|
|
@@ -3533,7 +3858,7 @@ var init_redraw = __esm(() => {
|
|
|
3533
3858
|
});
|
|
3534
3859
|
|
|
3535
3860
|
// ../kit/src/prompt.ts
|
|
3536
|
-
import
|
|
3861
|
+
import process23 from "process";
|
|
3537
3862
|
function readKeys(input, paste = { active: false }) {
|
|
3538
3863
|
return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key) || isEditKey(key));
|
|
3539
3864
|
}
|
|
@@ -3661,7 +3986,7 @@ function asking(colors, question, typed, keys) {
|
|
|
3661
3986
|
function answer(colors, question, state, picked) {
|
|
3662
3987
|
return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
|
|
3663
3988
|
}
|
|
3664
|
-
async function ask(question, { hint, terminal =
|
|
3989
|
+
async function ask(question, { hint, terminal = process23 }, render, press) {
|
|
3665
3990
|
const { stdin, stderr } = terminal;
|
|
3666
3991
|
if (!isInteractive(terminal))
|
|
3667
3992
|
fail(`cannot ask "${question}" off a terminal`, 2, hint);
|
|
@@ -3677,7 +4002,7 @@ async function ask(question, { hint, terminal = process22 }, render, press) {
|
|
|
3677
4002
|
};
|
|
3678
4003
|
const redraw = () => draw(current);
|
|
3679
4004
|
const paste = { active: false };
|
|
3680
|
-
const stop = terminal.stop ?? (terminal ===
|
|
4005
|
+
const stop = terminal.stop ?? (terminal === process23 ? stopJob : undefined);
|
|
3681
4006
|
const suspend = () => {
|
|
3682
4007
|
if (stop === undefined)
|
|
3683
4008
|
return;
|
|
@@ -3745,7 +4070,7 @@ var init_prompt = __esm(() => {
|
|
|
3745
4070
|
});
|
|
3746
4071
|
|
|
3747
4072
|
// src/excluded.ts
|
|
3748
|
-
import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as
|
|
4073
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync7, writeFileSync } from "fs";
|
|
3749
4074
|
import { dirname as dirname7 } from "path";
|
|
3750
4075
|
function excludedPath(home) {
|
|
3751
4076
|
return userConfigPath("pkg-excluded", { home });
|
|
@@ -3755,7 +4080,7 @@ function loadExcluded(home) {
|
|
|
3755
4080
|
if (!existsSync6(path))
|
|
3756
4081
|
return {};
|
|
3757
4082
|
try {
|
|
3758
|
-
const raw = JSON.parse(
|
|
4083
|
+
const raw = JSON.parse(readFileSync7(path, "utf8"));
|
|
3759
4084
|
const excluded = {};
|
|
3760
4085
|
for (const [name, dirs] of Object.entries(raw)) {
|
|
3761
4086
|
if (Array.isArray(dirs))
|
|
@@ -3791,7 +4116,7 @@ __export(exports_bump, {
|
|
|
3791
4116
|
});
|
|
3792
4117
|
import { existsSync as existsSync7 } from "fs";
|
|
3793
4118
|
import { basename, dirname as dirname8, join as join11, relative as relative2 } from "path";
|
|
3794
|
-
async function
|
|
4119
|
+
async function lookup2(name, registry, fetcher) {
|
|
3795
4120
|
try {
|
|
3796
4121
|
return { packument: await fetchPackument(name, registry, fetcher) };
|
|
3797
4122
|
} catch (error) {
|
|
@@ -3812,7 +4137,7 @@ async function servedVersion(name, version, settings) {
|
|
|
3812
4137
|
let lastError = "";
|
|
3813
4138
|
try {
|
|
3814
4139
|
for (;; ) {
|
|
3815
|
-
const looked = await
|
|
4140
|
+
const looked = await lookup2(name, registry, settings.fetcher);
|
|
3816
4141
|
if ("error" in looked) {
|
|
3817
4142
|
lastError = looked.error;
|
|
3818
4143
|
} else {
|
|
@@ -3895,10 +4220,10 @@ async function bumpConsumers(name, version, settings) {
|
|
|
3895
4220
|
const similar = similarDependencies(name, settings.root);
|
|
3896
4221
|
note(`nothing under ${settings.root} depends on ${name}`, similar.length === 0 ? undefined : `did you mean ${similar.join(", ")}`);
|
|
3897
4222
|
} else if (left > 0) {
|
|
3898
|
-
note(`${
|
|
4223
|
+
note(`${bo(left, "folder")} left out by --only or --except`);
|
|
3899
4224
|
}
|
|
3900
4225
|
if (declined.size > 0)
|
|
3901
|
-
note(`${
|
|
4226
|
+
note(`${bo(declined.size, "folder")} left out by your choice`);
|
|
3902
4227
|
if (local > 0)
|
|
3903
4228
|
note(`${local} non-registry dependenc${local === 1 ? "y" : "ies"} (workspace:, file:, git, URL, alias, catalog:)`, "left as they are");
|
|
3904
4229
|
for (const consumer of consumers) {
|
|
@@ -3959,7 +4284,7 @@ async function choosePlan(name, version, settings, chooser = terminalChooser, ho
|
|
|
3959
4284
|
const chosen = plans.filter((plan) => picked.has(plan.dir));
|
|
3960
4285
|
for (const plan of chosen)
|
|
3961
4286
|
note("plan", plan.line);
|
|
3962
|
-
if (chosen.length === 0 || await chooser.confirm(`bump ${name} to ${version} in ${
|
|
4287
|
+
if (chosen.length === 0 || await chooser.confirm(`bump ${name} to ${version} in ${bo(chosen.length, "folder")}?`) !== true)
|
|
3963
4288
|
return { chosen: [], declined: plans.map((plan) => plan.dir) };
|
|
3964
4289
|
const declined = plans.filter((plan) => !picked.has(plan.dir)).map((plan) => plan.dir);
|
|
3965
4290
|
saveExcluded(name, [...excluded].filter((dir) => !plans.some((plan) => plan.dir === dir)).concat(declined), home);
|
|
@@ -3994,12 +4319,10 @@ async function bump(args) {
|
|
|
3994
4319
|
}
|
|
3995
4320
|
var usage5 = `pkg bump <name> [version]
|
|
3996
4321
|
|
|
3997
|
-
Waits until the registry serves the version
|
|
3998
|
-
A version
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
On a terminal with no --only or --except, a checklist asks which consumers to bump (those left out last time are unchecked, and what is unchecked is remembered in ~/.config/kaynooo-cli/pkg-excluded.json), then the plan is printed and confirmed; --yes skips both, as a pipe or --dry-run does.
|
|
4002
|
-
With --all-consumers a folder whose package.json or lockfile already has uncommitted changes is left alone, and each folder whose install went through then runs its own \`check\` (the check bin) and is committed with \`gc 'chore(deps): bump <name> to <version>' -- package.json <lockfile>\` only when that passes; a failing one is left uncommitted and listed in the summary with the skipped ones, and nothing is ever pushed.`, EXITS4, ROOT_OPTION, options4, POLL = 5000, terminalChooser;
|
|
4322
|
+
Waits until the registry serves the version, vets it as \`pkg check\` does, then runs \`bun add --exact --no-cache\` in each folder under --root whose package.json depends on the package, the kind of dependency kept; a version the vetting blocks is refused before any folder is touched, unless --force is given.
|
|
4323
|
+
A dependency that is not a registry version (\`workspace:\`, \`link:\`, \`file:\`, git, a URL, \`catalog:\`), a peer range, a folder already on the version and one whose lockfile pins another manager are left as they are, each said so.
|
|
4324
|
+
On a terminal with no --only or --except, a checklist asks which consumers to bump, then the plan is printed and confirmed.
|
|
4325
|
+
With --all-consumers, a folder with uncommitted changes in its package.json or lockfile is left alone, and each folder whose install went through runs its own \`check\` and is committed with \`gc\` only when that passes; nothing is ever pushed.`, EXITS4, ROOT_OPTION, options4, POLL = 5000, terminalChooser;
|
|
4003
4326
|
var init_bump = __esm(() => {
|
|
4004
4327
|
init_src();
|
|
4005
4328
|
init_progress();
|
|
@@ -4102,7 +4425,7 @@ var exports_manager = {};
|
|
|
4102
4425
|
__export(exports_manager, {
|
|
4103
4426
|
manager: () => manager
|
|
4104
4427
|
});
|
|
4105
|
-
import
|
|
4428
|
+
import process24 from "process";
|
|
4106
4429
|
function manager(args) {
|
|
4107
4430
|
const { values, positionals } = parse(args, usage7, options6, {
|
|
4108
4431
|
exits: EXITS6,
|
|
@@ -4112,7 +4435,7 @@ function manager(args) {
|
|
|
4112
4435
|
examples: ["pkg manager dev", ["pkg manager exec", "bunx, npx, pnpm dlx... for this folder"]]
|
|
4113
4436
|
});
|
|
4114
4437
|
const action = oneOf(positionals[0] ?? "", "<action>", ACTIONS2);
|
|
4115
|
-
const found = detectManager(
|
|
4438
|
+
const found = detectManager(process24.cwd());
|
|
4116
4439
|
const command = commandFor(action, found);
|
|
4117
4440
|
if (values.json === true)
|
|
4118
4441
|
printJson({ manager: found, action, command });
|
|
@@ -4134,8 +4457,8 @@ var init_manager2 = __esm(() => {
|
|
|
4134
4457
|
|
|
4135
4458
|
// src/cli.ts
|
|
4136
4459
|
init_src();
|
|
4137
|
-
import
|
|
4138
|
-
|
|
4460
|
+
import process25 from "process";
|
|
4461
|
+
process25.exitCode = await runCli({
|
|
4139
4462
|
name: "pkg",
|
|
4140
4463
|
about: "checks npm packages before they are added, and moves a lib's consumers onto a new release",
|
|
4141
4464
|
replaces: "bun add on trust, and a bun info and sleep loop then a bun add per consumer",
|