@kaynooo/cli-git 0.13.0 → 0.14.0
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 +15 -4
- package/dist/gb.js +183 -59
- package/dist/gc.js +159 -39
- package/dist/gp.js +1369 -0
- package/dist/gst.js +271 -63
- package/package.json +8 -6
package/dist/gc.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/gc.ts
|
|
5
|
-
import
|
|
5
|
+
import process16 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
7
|
import process9 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
@@ -10,6 +10,24 @@ import { parseArgs } from "util";
|
|
|
10
10
|
// ../kit/src/format.ts
|
|
11
11
|
import process7 from "process";
|
|
12
12
|
|
|
13
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
|
|
14
|
+
var N = new Map;
|
|
15
|
+
var Nt = /\s+\S*$/;
|
|
16
|
+
var Y = /\s/;
|
|
17
|
+
function ko(t, e, r = "...") {
|
|
18
|
+
let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
|
|
19
|
+
if (t.length <= e)
|
|
20
|
+
return t;
|
|
21
|
+
let l = Math.max(0, e), c = t.substring(0, Math.max(0, s ? l - n.length : l));
|
|
22
|
+
if (o && !Y.test(t[c.length] ?? " "))
|
|
23
|
+
c = c.replace(Nt, "") || c;
|
|
24
|
+
if (o)
|
|
25
|
+
c = c.trimEnd();
|
|
26
|
+
return s ? (c + n).slice(0, l) : c + n;
|
|
27
|
+
}
|
|
28
|
+
var 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));
|
|
29
|
+
var z = new Map;
|
|
30
|
+
|
|
13
31
|
// ../kit/src/mode.ts
|
|
14
32
|
import process2 from "process";
|
|
15
33
|
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
@@ -35,10 +53,10 @@ function isInteractive(streams = process2) {
|
|
|
35
53
|
import process6 from "process";
|
|
36
54
|
|
|
37
55
|
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
38
|
-
var
|
|
56
|
+
var G2 = /^[a-f0-9]+$/i;
|
|
39
57
|
function b(r) {
|
|
40
58
|
let e = r.startsWith("#") ? r.slice(1) : r;
|
|
41
|
-
if (!
|
|
59
|
+
if (!G2.test(e))
|
|
42
60
|
return [0, 0, 0];
|
|
43
61
|
if (e.length === 3 || e.length === 4)
|
|
44
62
|
return [Number.parseInt(e[0] + e[0], 16), Number.parseInt(e[1] + e[1], 16), Number.parseInt(e[2] + e[2], 16)];
|
|
@@ -46,7 +64,7 @@ function b(r) {
|
|
|
46
64
|
throw Error(`Invalid hex color length: ${e.length}`);
|
|
47
65
|
return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
|
|
48
66
|
}
|
|
49
|
-
var
|
|
67
|
+
var B2 = { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29], black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], gray: [90, 39], grey: [90, 39], blackBright: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39], bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49], rgb: (r, e, l, n = "fg") => [`${n === "fg" ? 38 : 48};2;${r};${e};${l}`, n === "fg" ? 39 : 49], hex: (r, e = "fg") => {
|
|
50
68
|
let [l, n, c] = b(r);
|
|
51
69
|
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
52
70
|
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
@@ -64,7 +82,7 @@ function f(r, e = []) {
|
|
|
64
82
|
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
65
83
|
let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
|
|
66
84
|
return new Proxy(c, { get(t, i) {
|
|
67
|
-
let a =
|
|
85
|
+
let a = B2[i];
|
|
68
86
|
if (Array.isArray(a)) {
|
|
69
87
|
let s = g.get(i);
|
|
70
88
|
if (s === undefined)
|
|
@@ -304,12 +322,22 @@ function activeTheme() {
|
|
|
304
322
|
}
|
|
305
323
|
|
|
306
324
|
// ../kit/src/style.ts
|
|
325
|
+
var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
|
|
307
326
|
function takesControlCodes(stream, env = process6.env) {
|
|
308
327
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
309
328
|
}
|
|
310
329
|
function paint(stream, env = process6.env) {
|
|
311
330
|
return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
312
331
|
}
|
|
332
|
+
function marked(mark, text, stream, detail, env = process6.env) {
|
|
333
|
+
const colors = paint(stream, env);
|
|
334
|
+
let head = MARK_WORDS[mark];
|
|
335
|
+
if (takesControlCodes(stream, env)) {
|
|
336
|
+
const { theme } = activeTheme();
|
|
337
|
+
head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
|
|
338
|
+
}
|
|
339
|
+
return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
|
|
340
|
+
}
|
|
313
341
|
function role(name, stream, env = process6.env) {
|
|
314
342
|
const colors = paint(stream, env);
|
|
315
343
|
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
@@ -324,11 +352,78 @@ var STATUS_WORDS = {
|
|
|
324
352
|
var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
325
353
|
|
|
326
354
|
// ../kit/src/format.ts
|
|
355
|
+
var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
|
|
356
|
+
function formatSeconds(total) {
|
|
357
|
+
let rest = Math.max(0, Math.round(total));
|
|
358
|
+
const amounts = UNITS.map(([unit, size]) => {
|
|
359
|
+
const amount = Math.floor(rest / size);
|
|
360
|
+
rest -= amount * size;
|
|
361
|
+
return `${amount}${unit}`;
|
|
362
|
+
});
|
|
363
|
+
const first = amounts.findIndex((amount) => !amount.startsWith("0"));
|
|
364
|
+
if (first === -1)
|
|
365
|
+
return "0s";
|
|
366
|
+
const next = amounts[first + 1];
|
|
367
|
+
return next === undefined || next.startsWith("0") ? amounts[first] ?? "0s" : `${amounts[first]} ${next}`;
|
|
368
|
+
}
|
|
327
369
|
function upTo(text, separator) {
|
|
328
370
|
const end = text.indexOf(separator);
|
|
329
371
|
return end === -1 ? text : text.slice(0, end);
|
|
330
372
|
}
|
|
373
|
+
function formatAge(date, now = Date.now()) {
|
|
374
|
+
const at = typeof date === "number" ? date : Date.parse(date);
|
|
375
|
+
if (Number.isNaN(at))
|
|
376
|
+
return "-";
|
|
377
|
+
const seconds = (now - at) / 1000;
|
|
378
|
+
return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
|
|
379
|
+
}
|
|
380
|
+
function truncate(text, width) {
|
|
381
|
+
return ko(text, width, { suffix: "\u2026", includeSuffix: true });
|
|
382
|
+
}
|
|
383
|
+
var LINE_BREAKS = /\s*\n\s*/g;
|
|
331
384
|
var ESCAPE = String.fromCharCode(27);
|
|
385
|
+
function textWidth(text) {
|
|
386
|
+
return Bun.stringWidth(text);
|
|
387
|
+
}
|
|
388
|
+
function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
|
|
389
|
+
const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
|
|
390
|
+
if (outputMode(stream, env) === "agent")
|
|
391
|
+
return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
|
|
392
|
+
`);
|
|
393
|
+
const widths = [];
|
|
394
|
+
for (const row of cells) {
|
|
395
|
+
for (const [index, cell] of row.entries())
|
|
396
|
+
widths[index] = Math.max(widths[index] ?? 0, textWidth(cell));
|
|
397
|
+
}
|
|
398
|
+
const shown = fit === undefined ? cells : narrow(cells, widths, fit);
|
|
399
|
+
const colors = paint(stream);
|
|
400
|
+
const lines = shown.map((row) => row.map((cell, index) => {
|
|
401
|
+
const width = widths[index] ?? 0;
|
|
402
|
+
const gap = " ".repeat(Math.max(0, width - textWidth(cell)));
|
|
403
|
+
if (align[index] === "right")
|
|
404
|
+
return `${gap}${cell}`;
|
|
405
|
+
return index === row.length - 1 ? cell : `${cell}${gap}`;
|
|
406
|
+
}).join(" ").trimEnd());
|
|
407
|
+
const rule = header && takesControlCodes(stream) && lines.length > 1 ? [colors.dim("\u2500".repeat(Math.max(...lines.map(textWidth))))] : [];
|
|
408
|
+
return lines.flatMap((line, index) => header && index === 0 ? [colors.bold(line), ...rule] : [line]).join(`
|
|
409
|
+
`);
|
|
410
|
+
}
|
|
411
|
+
function narrow(rows, widths, limit) {
|
|
412
|
+
const used = () => widths.reduce((sum, width) => sum + width, 0) + 2 * Math.max(0, widths.length - 1);
|
|
413
|
+
const cuttable = (index) => rows.every((row) => !(row[index] ?? "").includes(ESCAPE));
|
|
414
|
+
const floor = 8;
|
|
415
|
+
while (used() > limit) {
|
|
416
|
+
let widest = -1;
|
|
417
|
+
for (const [index, width] of widths.entries()) {
|
|
418
|
+
if (cuttable(index) && width > floor && width > (widths[widest] ?? 0))
|
|
419
|
+
widest = index;
|
|
420
|
+
}
|
|
421
|
+
if (widest === -1)
|
|
422
|
+
break;
|
|
423
|
+
widths[widest] = Math.max(floor, (widths[widest] ?? 0) - (used() - limit));
|
|
424
|
+
}
|
|
425
|
+
return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
|
|
426
|
+
}
|
|
332
427
|
function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
|
|
333
428
|
return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
|
|
334
429
|
}
|
|
@@ -651,9 +746,33 @@ function nearestOption(message, options, allowNegative) {
|
|
|
651
746
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
652
747
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
653
748
|
}
|
|
749
|
+
// ../kit/src/argv.ts
|
|
750
|
+
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
751
|
+
import { resolve as resolve3 } from "path";
|
|
752
|
+
import process10 from "process";
|
|
753
|
+
function commandLine() {
|
|
754
|
+
try {
|
|
755
|
+
return readFileSync2("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
|
|
756
|
+
} catch {
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
function realPath(word) {
|
|
761
|
+
try {
|
|
762
|
+
return realpathSync(resolve3(word));
|
|
763
|
+
} catch {
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), script = process10.argv[1]) {
|
|
768
|
+
const target = script === undefined ? undefined : realPath(script) ?? script;
|
|
769
|
+
const at = cmdline === undefined || target === undefined ? -1 : cmdline.findIndex((word, index) => index > 0 && (resolve3(word) === script || realPath(word) === target));
|
|
770
|
+
const after = at === -1 ? [] : cmdline.slice(at + 1);
|
|
771
|
+
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
772
|
+
}
|
|
654
773
|
// ../kit/src/process.ts
|
|
655
774
|
import { constants } from "os";
|
|
656
|
-
import
|
|
775
|
+
import process11 from "process";
|
|
657
776
|
var KILL_GRACE_MS = 2000;
|
|
658
777
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
659
778
|
function exitCodeOf(code, signal) {
|
|
@@ -675,7 +794,7 @@ function holdSignals(cleanup) {
|
|
|
675
794
|
},
|
|
676
795
|
release: () => {
|
|
677
796
|
for (const signal of SIGNALS)
|
|
678
|
-
|
|
797
|
+
process11.off(signal, onSignal);
|
|
679
798
|
}
|
|
680
799
|
};
|
|
681
800
|
function onSignal(signal) {
|
|
@@ -688,10 +807,10 @@ function holdSignals(cleanup) {
|
|
|
688
807
|
return;
|
|
689
808
|
held.release();
|
|
690
809
|
cleanup(signal);
|
|
691
|
-
|
|
810
|
+
process11.kill(process11.pid, signal);
|
|
692
811
|
}
|
|
693
812
|
for (const signal of SIGNALS)
|
|
694
|
-
|
|
813
|
+
process11.on(signal, onSignal);
|
|
695
814
|
return held;
|
|
696
815
|
}
|
|
697
816
|
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
@@ -705,7 +824,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
705
824
|
return;
|
|
706
825
|
try {
|
|
707
826
|
if (grouped)
|
|
708
|
-
|
|
827
|
+
process11.kill(-proc.pid, killing);
|
|
709
828
|
else
|
|
710
829
|
proc.kill(killing);
|
|
711
830
|
} catch {}
|
|
@@ -779,15 +898,15 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
|
|
|
779
898
|
var RESET_STYLE = `${ESC}[0m`;
|
|
780
899
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
781
900
|
// ../kit/src/cli.ts
|
|
782
|
-
import { readFileSync as
|
|
901
|
+
import { readFileSync as readFileSync3, realpathSync as realpathSync2 } from "fs";
|
|
783
902
|
import { dirname as dirname3, join as join5 } from "path";
|
|
784
|
-
import
|
|
903
|
+
import process13 from "process";
|
|
785
904
|
|
|
786
905
|
// ../kit/src/usage.ts
|
|
787
906
|
import { appendFileSync, mkdirSync } from "fs";
|
|
788
907
|
import { homedir as homedir3 } from "os";
|
|
789
908
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
790
|
-
import
|
|
909
|
+
import process12 from "process";
|
|
791
910
|
|
|
792
911
|
// ../kit/src/logs.ts
|
|
793
912
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -801,14 +920,14 @@ var usageError;
|
|
|
801
920
|
function noteUsageError(message) {
|
|
802
921
|
usageError = message;
|
|
803
922
|
}
|
|
804
|
-
function stateHome(env =
|
|
923
|
+
function stateHome(env = process12.env) {
|
|
805
924
|
const dir = env.XDG_STATE_HOME;
|
|
806
925
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
807
926
|
}
|
|
808
|
-
function usagePath(env =
|
|
927
|
+
function usagePath(env = process12.env) {
|
|
809
928
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
810
929
|
}
|
|
811
|
-
function usageRecorded(env =
|
|
930
|
+
function usageRecorded(env = process12.env) {
|
|
812
931
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
813
932
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
814
933
|
}
|
|
@@ -822,7 +941,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
822
941
|
usageError = undefined;
|
|
823
942
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
824
943
|
}
|
|
825
|
-
function recordUsage(entry, env =
|
|
944
|
+
function recordUsage(entry, env = process12.env) {
|
|
826
945
|
if (!usageRecorded(env))
|
|
827
946
|
return;
|
|
828
947
|
try {
|
|
@@ -840,8 +959,8 @@ var LEVEL_OPTIONS = {
|
|
|
840
959
|
};
|
|
841
960
|
var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
|
|
842
961
|
function printError(prefix, message, hint, cause) {
|
|
843
|
-
const colors = paint(
|
|
844
|
-
const styled = takesControlCodes(
|
|
962
|
+
const colors = paint(process13.stderr);
|
|
963
|
+
const styled = takesControlCodes(process13.stderr);
|
|
845
964
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
846
965
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
847
966
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -888,24 +1007,24 @@ function candidateLine(candidate) {
|
|
|
888
1007
|
}
|
|
889
1008
|
function positionalBeingTyped(before, { options, positionals }) {
|
|
890
1009
|
const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
|
|
891
|
-
|
|
1010
|
+
const typed = [];
|
|
892
1011
|
let at = 0;
|
|
893
1012
|
while (at < before.length) {
|
|
894
1013
|
const word = before[at];
|
|
895
1014
|
if (word === "--") {
|
|
896
|
-
|
|
1015
|
+
typed.push(...before.slice(at + 1));
|
|
897
1016
|
break;
|
|
898
1017
|
}
|
|
899
1018
|
if (!word.startsWith("-"))
|
|
900
|
-
|
|
1019
|
+
typed.push(word);
|
|
901
1020
|
else if (takesValue(word))
|
|
902
1021
|
at++;
|
|
903
1022
|
at++;
|
|
904
1023
|
}
|
|
905
1024
|
const last = positionals.at(-1);
|
|
906
|
-
if (
|
|
907
|
-
return positionals[
|
|
908
|
-
return last?.replace("]", "").endsWith("...") === true ? last : undefined;
|
|
1025
|
+
if (typed.length < positionals.length)
|
|
1026
|
+
return { name: positionals[typed.length], typed };
|
|
1027
|
+
return { name: last?.replace("]", "").endsWith("...") === true ? last : undefined, typed };
|
|
909
1028
|
}
|
|
910
1029
|
async function leafCandidates(run, words) {
|
|
911
1030
|
const completing = await completingOf(run);
|
|
@@ -913,12 +1032,12 @@ async function leafCandidates(run, words) {
|
|
|
913
1032
|
return Object.entries(completing.options).map(([name, option]) => option.description === undefined ? `--${name}` : `--${name} ${option.description}`);
|
|
914
1033
|
const flag = words.at(-2);
|
|
915
1034
|
const option = flag?.startsWith("-") === true ? Object.entries(completing.options).find(([name, { short }]) => flag === `--${name}` || flag === `-${short}`)?.[1] : undefined;
|
|
1035
|
+
const { name, typed } = positionalBeingTyped(words.slice(0, -1), completing);
|
|
916
1036
|
if (option?.type === "string") {
|
|
917
|
-
const values = option.choices === undefined ? await option.candidates?.() : option.choices;
|
|
1037
|
+
const values = option.choices === undefined ? await option.candidates?.(typed) : option.choices;
|
|
918
1038
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
919
1039
|
}
|
|
920
|
-
const
|
|
921
|
-
const values = name === undefined ? undefined : await completing.candidates[name]?.();
|
|
1040
|
+
const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
|
|
922
1041
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
923
1042
|
}
|
|
924
1043
|
async function printCandidates(found) {
|
|
@@ -927,9 +1046,9 @@ async function printCandidates(found) {
|
|
|
927
1046
|
return 0;
|
|
928
1047
|
}
|
|
929
1048
|
function packageVersion(entry = Bun.main) {
|
|
930
|
-
for (let dir = dirname3(
|
|
1049
|
+
for (let dir = dirname3(realpathSync2(entry));; dir = dirname3(dir)) {
|
|
931
1050
|
try {
|
|
932
|
-
const { version } = JSON.parse(
|
|
1051
|
+
const { version } = JSON.parse(readFileSync3(join5(dir, "package.json"), "utf8"));
|
|
933
1052
|
if (typeof version === "string")
|
|
934
1053
|
return version;
|
|
935
1054
|
} catch {}
|
|
@@ -937,7 +1056,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
937
1056
|
return "0.0.0";
|
|
938
1057
|
}
|
|
939
1058
|
}
|
|
940
|
-
async function runMain({ name, version, run, redact, usage }, argv =
|
|
1059
|
+
async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
|
|
941
1060
|
if (argv[0] === COMPLETE)
|
|
942
1061
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
943
1062
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
@@ -966,7 +1085,7 @@ var {Glob } = globalThis.Bun;
|
|
|
966
1085
|
var SESSION_FILES = new Glob("*.json");
|
|
967
1086
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
968
1087
|
// ../kit/src/watch.ts
|
|
969
|
-
import
|
|
1088
|
+
import process14 from "process";
|
|
970
1089
|
import { format } from "util";
|
|
971
1090
|
var CLEAR_SCREEN = "\x1B[H\x1B[2J";
|
|
972
1091
|
var DEFAULT_SECONDS = 2;
|
|
@@ -988,7 +1107,7 @@ function withoutWatch(args) {
|
|
|
988
1107
|
}
|
|
989
1108
|
return rest;
|
|
990
1109
|
}
|
|
991
|
-
async function watching(value, step, stream =
|
|
1110
|
+
async function watching(value, step, stream = process14.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
|
|
992
1111
|
const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
|
|
993
1112
|
if (!takesControlCodes(stream))
|
|
994
1113
|
badUsage("--watch redraws the screen, so it needs a terminal");
|
|
@@ -996,12 +1115,12 @@ async function watching(value, step, stream = process13.stdout, sleep = Bun.slee
|
|
|
996
1115
|
for (let round = 0;round < rounds; round++) {
|
|
997
1116
|
const held = [];
|
|
998
1117
|
const { log, info } = console;
|
|
999
|
-
const write =
|
|
1118
|
+
const write = process14.stdout.write.bind(process14.stdout);
|
|
1000
1119
|
const hold = (...parts) => void held.push(`${format(...parts)}
|
|
1001
1120
|
`);
|
|
1002
1121
|
console.log = hold;
|
|
1003
1122
|
console.info = hold;
|
|
1004
|
-
|
|
1123
|
+
process14.stdout.write = (text) => {
|
|
1005
1124
|
held.push(typeof text === "string" ? text : Buffer.from(text).toString());
|
|
1006
1125
|
return true;
|
|
1007
1126
|
};
|
|
@@ -1010,7 +1129,7 @@ async function watching(value, step, stream = process13.stdout, sleep = Bun.slee
|
|
|
1010
1129
|
} finally {
|
|
1011
1130
|
console.log = log;
|
|
1012
1131
|
console.info = info;
|
|
1013
|
-
|
|
1132
|
+
process14.stdout.write = write;
|
|
1014
1133
|
}
|
|
1015
1134
|
stream.write(`${CLEAR_SCREEN}${held.join("")}`);
|
|
1016
1135
|
await sleep(interval);
|
|
@@ -1084,11 +1203,12 @@ Exits 0 when it committed, 1 when the message is refused or git fails (nothing i
|
|
|
1084
1203
|
var OPTIONS = {
|
|
1085
1204
|
message: { type: "string", short: "m", multiple: true, description: "a line on what changed, at most two" },
|
|
1086
1205
|
ticket: { type: "string", multiple: true, description: "a ticket line, `#<n> - <title>` (`owner/repo#<n> - <title>` across repositories) copied verbatim from the ticket" },
|
|
1206
|
+
quiet: { type: "boolean", short: "q", description: "print nothing once committed, failures aside" },
|
|
1087
1207
|
json: jsonOption("{sha, subject, files: [{status, path, from?}]} of the commit")
|
|
1088
1208
|
};
|
|
1089
1209
|
var RENAME = /^[RC]\d*$/;
|
|
1090
1210
|
var NOT_A_REPOSITORY = /not a git repository/i;
|
|
1091
|
-
var LITERAL = { ...
|
|
1211
|
+
var LITERAL = { ...process16.env, GIT_LITERAL_PATHSPECS: "1" };
|
|
1092
1212
|
function messageOf(title, lines, tickets) {
|
|
1093
1213
|
return [title, lines.join(`
|
|
1094
1214
|
`), tickets.join(`
|
|
@@ -1177,7 +1297,7 @@ ${(commit.stderr + commit.stdout).trim()}`;
|
|
|
1177
1297
|
return RENAME.test(letter) ? { status: letter[0] ?? letter, path: to ?? from, from } : { status: letter, path: from };
|
|
1178
1298
|
});
|
|
1179
1299
|
printJson({ sha: (await checked(["rev-parse", "HEAD"])).trim(), subject: head.slice(head.indexOf(" ") + 1), files: changes });
|
|
1180
|
-
} else {
|
|
1300
|
+
} else if (values.quiet !== true) {
|
|
1181
1301
|
console.log([head, ...lines.filter(Boolean).map(fileLine)].join(`
|
|
1182
1302
|
`));
|
|
1183
1303
|
}
|
|
@@ -1186,4 +1306,4 @@ ${(commit.stderr + commit.stdout).trim()}`;
|
|
|
1186
1306
|
signals.release();
|
|
1187
1307
|
}
|
|
1188
1308
|
}
|
|
1189
|
-
|
|
1309
|
+
process16.exitCode = await runMain({ name: "gc", run: main });
|