@kaynooo/cli-git 0.8.0 → 0.10.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/dist/gb.js +231 -62
- package/dist/gc.js +156 -47
- package/dist/gst.js +164 -52
- package/package.json +2 -2
package/dist/gc.js
CHANGED
|
@@ -2,13 +2,37 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/gc.ts
|
|
5
|
-
import
|
|
5
|
+
import process15 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
|
-
import
|
|
7
|
+
import process9 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
9
9
|
|
|
10
|
+
// ../kit/src/format.ts
|
|
11
|
+
import process7 from "process";
|
|
12
|
+
|
|
13
|
+
// ../kit/src/mode.ts
|
|
14
|
+
import process2 from "process";
|
|
15
|
+
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
16
|
+
var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
17
|
+
function isSet(value) {
|
|
18
|
+
return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
19
|
+
}
|
|
20
|
+
function outputMode(stream = process2.stdout, env = process2.env) {
|
|
21
|
+
const chosen = env.KIT_MODE;
|
|
22
|
+
if (chosen !== undefined && MODES.has(chosen))
|
|
23
|
+
return chosen;
|
|
24
|
+
if (AGENT_VARIABLES.some((name) => isSet(env[name])))
|
|
25
|
+
return "agent";
|
|
26
|
+
if (stream.isTTY === true)
|
|
27
|
+
return "terminal";
|
|
28
|
+
return isSet(env.CI) ? "ci" : "pipe";
|
|
29
|
+
}
|
|
30
|
+
function isInteractive(streams = process2) {
|
|
31
|
+
return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
|
|
32
|
+
}
|
|
33
|
+
|
|
10
34
|
// ../kit/src/style.ts
|
|
11
|
-
import
|
|
35
|
+
import process6 from "process";
|
|
12
36
|
|
|
13
37
|
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
|
|
14
38
|
function x(s) {
|
|
@@ -275,13 +299,13 @@ var t = le();
|
|
|
275
299
|
import { existsSync as existsSync2, readFileSync, statSync } from "fs";
|
|
276
300
|
import { homedir as homedir2 } from "os";
|
|
277
301
|
import { join as join3, resolve as resolve2 } from "path";
|
|
278
|
-
import
|
|
302
|
+
import process5 from "process";
|
|
279
303
|
|
|
280
304
|
// ../kit/src/config.ts
|
|
281
305
|
import { existsSync } from "fs";
|
|
282
306
|
import { dirname, join, resolve } from "path";
|
|
283
|
-
import
|
|
284
|
-
function findUp(names, from =
|
|
307
|
+
import process3 from "process";
|
|
308
|
+
function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
285
309
|
const wanted = typeof names === "string" ? [names] : names;
|
|
286
310
|
for (let dir = resolve(from);; dir = dirname(dir)) {
|
|
287
311
|
const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
|
|
@@ -295,9 +319,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
|
|
|
295
319
|
// ../kit/src/user-config.ts
|
|
296
320
|
import { homedir } from "os";
|
|
297
321
|
import { join as join2 } from "path";
|
|
298
|
-
import
|
|
322
|
+
import process4 from "process";
|
|
299
323
|
function configBase(where = {}) {
|
|
300
|
-
const xdg = where.xdg ?? (where.home === undefined ?
|
|
324
|
+
const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
|
|
301
325
|
return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
|
|
302
326
|
}
|
|
303
327
|
function userConfigPath(bin, where = {}) {
|
|
@@ -330,10 +354,30 @@ function isColorSpec(spec) {
|
|
|
330
354
|
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
331
355
|
return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
|
|
332
356
|
}
|
|
333
|
-
|
|
357
|
+
var CUBE = [0, 95, 135, 175, 215, 255];
|
|
358
|
+
function cubeLevel(channel) {
|
|
359
|
+
return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
|
|
360
|
+
}
|
|
361
|
+
function nearest256(hex) {
|
|
362
|
+
const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
|
|
363
|
+
const levels = rgb.map(cubeLevel);
|
|
364
|
+
const cube = levels.map((level) => CUBE[level]);
|
|
365
|
+
const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
|
|
366
|
+
const greyValue = 8 + grey * 10;
|
|
367
|
+
const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
|
|
368
|
+
return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
|
|
369
|
+
}
|
|
370
|
+
function hasTrueColor(env) {
|
|
371
|
+
return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
|
|
372
|
+
}
|
|
373
|
+
function tinted(colors, spec, env = process5.env) {
|
|
334
374
|
if (typeof spec === "number")
|
|
335
375
|
return colors.ansi256(spec);
|
|
336
|
-
return spec.trim().split(SPACES).reduce((chain, token) =>
|
|
376
|
+
return spec.trim().split(SPACES).reduce((chain, token) => {
|
|
377
|
+
if (HEX.test(token))
|
|
378
|
+
return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
|
|
379
|
+
return chain[token] ?? chain;
|
|
380
|
+
}, colors);
|
|
337
381
|
}
|
|
338
382
|
function isRecord(value) {
|
|
339
383
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -417,7 +461,7 @@ function warnOnce(message) {
|
|
|
417
461
|
function isPath(chosen) {
|
|
418
462
|
return chosen.includes("/") || chosen.endsWith(".json");
|
|
419
463
|
}
|
|
420
|
-
function loadTheme({ env =
|
|
464
|
+
function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
|
|
421
465
|
const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
|
|
422
466
|
const sources = [];
|
|
423
467
|
const chosen = env.KIT_THEME ?? "";
|
|
@@ -447,7 +491,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
|
|
|
447
491
|
var current;
|
|
448
492
|
var currentKey = "";
|
|
449
493
|
function activeTheme() {
|
|
450
|
-
const key = `${
|
|
494
|
+
const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
|
|
451
495
|
if (current === undefined || key !== currentKey) {
|
|
452
496
|
current = loadTheme();
|
|
453
497
|
currentKey = key;
|
|
@@ -456,20 +500,20 @@ function activeTheme() {
|
|
|
456
500
|
}
|
|
457
501
|
|
|
458
502
|
// ../kit/src/style.ts
|
|
459
|
-
function takesControlCodes(stream, env =
|
|
460
|
-
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
|
|
503
|
+
function takesControlCodes(stream, env = process6.env) {
|
|
504
|
+
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
461
505
|
}
|
|
462
|
-
function paint(stream, env =
|
|
506
|
+
function paint(stream, env = process6.env) {
|
|
463
507
|
return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
464
508
|
}
|
|
465
|
-
function role(name, stream, env =
|
|
509
|
+
function role(name, stream, env = process6.env) {
|
|
466
510
|
const colors = paint(stream, env);
|
|
467
|
-
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
|
|
511
|
+
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
468
512
|
}
|
|
469
513
|
var STATUS_WORDS = {
|
|
470
514
|
passed: ["passed", "success", "succeeded", "ok"],
|
|
471
515
|
failed: ["failed", "failure", "error", "errored"],
|
|
472
|
-
running: ["running", "in_progress", "started"],
|
|
516
|
+
running: ["running", "in_progress", "started", "holding"],
|
|
473
517
|
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
474
518
|
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
475
519
|
};
|
|
@@ -481,32 +525,35 @@ function upTo(text, separator) {
|
|
|
481
525
|
return end === -1 ? text : text.slice(0, end);
|
|
482
526
|
}
|
|
483
527
|
var ESCAPE = String.fromCharCode(27);
|
|
528
|
+
function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
|
|
529
|
+
return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
|
|
530
|
+
}
|
|
484
531
|
function printJson(value) {
|
|
485
|
-
console.log(
|
|
532
|
+
console.log(jsonText(value));
|
|
486
533
|
}
|
|
487
534
|
|
|
488
535
|
// ../kit/src/help.ts
|
|
489
|
-
import
|
|
536
|
+
import process8 from "process";
|
|
490
537
|
var OPTIONAL = /\[[^\]]+\]/g;
|
|
491
538
|
var USAGE_PREFIX = /^usage:\s*/i;
|
|
492
539
|
var FULL_STOP = /\.$/;
|
|
493
|
-
function usageLine(usage, colors = paint(
|
|
540
|
+
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
494
541
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
495
542
|
}
|
|
496
|
-
function helpText(usage, options, colors = paint(
|
|
543
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
|
|
497
544
|
return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
498
545
|
`);
|
|
499
546
|
}
|
|
500
|
-
function exitRows(exits, colors = paint(
|
|
547
|
+
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
501
548
|
if (exits.length === 0)
|
|
502
549
|
return [];
|
|
503
550
|
const width = Math.max(...exits.map(([code]) => String(code).length));
|
|
504
551
|
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
505
552
|
}
|
|
506
|
-
function replacesRows(replaces, colors = paint(
|
|
507
|
-
return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
553
|
+
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
554
|
+
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
508
555
|
}
|
|
509
|
-
function wantsHelpJson(env =
|
|
556
|
+
function wantsHelpJson(env = process8.env) {
|
|
510
557
|
return env.KIT_HELP === "json";
|
|
511
558
|
}
|
|
512
559
|
function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
@@ -525,12 +572,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
|
525
572
|
...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
|
|
526
573
|
};
|
|
527
574
|
}
|
|
528
|
-
function exampleRows(examples, colors = paint(
|
|
529
|
-
if (examples.length === 0)
|
|
575
|
+
function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
576
|
+
if (examples.length === 0 || outputMode() === "agent")
|
|
530
577
|
return [];
|
|
531
578
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
532
579
|
}
|
|
533
|
-
function optionRows(options, colors = paint(
|
|
580
|
+
function optionRows(options, colors = paint(process8.stdout)) {
|
|
534
581
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
535
582
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
536
583
|
const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
|
|
@@ -571,13 +618,23 @@ function wholeNumber(value, name, fallback, min = 1) {
|
|
|
571
618
|
badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
|
|
572
619
|
return number;
|
|
573
620
|
}
|
|
621
|
+
var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
622
|
+
var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
623
|
+
function duration(value, name, fallback, unit = "s") {
|
|
624
|
+
if (value === undefined)
|
|
625
|
+
return fallback;
|
|
626
|
+
const match = DURATION.exec(value.trim());
|
|
627
|
+
const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
|
|
628
|
+
if (ms < 1)
|
|
629
|
+
badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
|
|
630
|
+
return ms;
|
|
631
|
+
}
|
|
574
632
|
|
|
575
633
|
// ../kit/src/args.ts
|
|
576
634
|
var DASHES = /^-+/;
|
|
577
635
|
function jsonOption(holds) {
|
|
578
636
|
return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
|
|
579
637
|
}
|
|
580
|
-
|
|
581
638
|
class Exit extends Error {
|
|
582
639
|
code;
|
|
583
640
|
hint;
|
|
@@ -621,7 +678,7 @@ var OUTPUT_OPTIONS = {
|
|
|
621
678
|
color: { type: "string", description: "auto (on a terminal alone), always or never" },
|
|
622
679
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
623
680
|
};
|
|
624
|
-
function applyOutput(color, plain, env =
|
|
681
|
+
function applyOutput(color, plain, env = process9.env) {
|
|
625
682
|
const when = plain === true ? "never" : color ?? "auto";
|
|
626
683
|
if (when === "auto")
|
|
627
684
|
return;
|
|
@@ -792,7 +849,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
792
849
|
}
|
|
793
850
|
// ../kit/src/process.ts
|
|
794
851
|
import { constants } from "os";
|
|
795
|
-
import
|
|
852
|
+
import process10 from "process";
|
|
796
853
|
var KILL_GRACE_MS = 2000;
|
|
797
854
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
798
855
|
function exitCodeOf(code, signal) {
|
|
@@ -814,7 +871,7 @@ function holdSignals(cleanup) {
|
|
|
814
871
|
},
|
|
815
872
|
release: () => {
|
|
816
873
|
for (const signal of SIGNALS)
|
|
817
|
-
|
|
874
|
+
process10.off(signal, onSignal);
|
|
818
875
|
}
|
|
819
876
|
};
|
|
820
877
|
function onSignal(signal) {
|
|
@@ -827,10 +884,10 @@ function holdSignals(cleanup) {
|
|
|
827
884
|
return;
|
|
828
885
|
held.release();
|
|
829
886
|
cleanup(signal);
|
|
830
|
-
|
|
887
|
+
process10.kill(process10.pid, signal);
|
|
831
888
|
}
|
|
832
889
|
for (const signal of SIGNALS)
|
|
833
|
-
|
|
890
|
+
process10.on(signal, onSignal);
|
|
834
891
|
return held;
|
|
835
892
|
}
|
|
836
893
|
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
@@ -844,7 +901,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
844
901
|
return;
|
|
845
902
|
try {
|
|
846
903
|
if (grouped)
|
|
847
|
-
|
|
904
|
+
process10.kill(-proc.pid, killing);
|
|
848
905
|
else
|
|
849
906
|
proc.kill(killing);
|
|
850
907
|
} catch {}
|
|
@@ -920,13 +977,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
|
920
977
|
// ../kit/src/cli.ts
|
|
921
978
|
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
922
979
|
import { dirname as dirname3, join as join5 } from "path";
|
|
923
|
-
import
|
|
980
|
+
import process12 from "process";
|
|
924
981
|
|
|
925
982
|
// ../kit/src/usage.ts
|
|
926
983
|
import { appendFileSync, mkdirSync } from "fs";
|
|
927
984
|
import { homedir as homedir3 } from "os";
|
|
928
985
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
929
|
-
import
|
|
986
|
+
import process11 from "process";
|
|
930
987
|
|
|
931
988
|
// ../kit/src/logs.ts
|
|
932
989
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -940,14 +997,14 @@ var usageError;
|
|
|
940
997
|
function noteUsageError(message) {
|
|
941
998
|
usageError = message;
|
|
942
999
|
}
|
|
943
|
-
function stateHome(env =
|
|
1000
|
+
function stateHome(env = process11.env) {
|
|
944
1001
|
const dir = env.XDG_STATE_HOME;
|
|
945
1002
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
946
1003
|
}
|
|
947
|
-
function usagePath(env =
|
|
1004
|
+
function usagePath(env = process11.env) {
|
|
948
1005
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
949
1006
|
}
|
|
950
|
-
function usageRecorded(env =
|
|
1007
|
+
function usageRecorded(env = process11.env) {
|
|
951
1008
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
952
1009
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
953
1010
|
}
|
|
@@ -961,7 +1018,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
961
1018
|
usageError = undefined;
|
|
962
1019
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
963
1020
|
}
|
|
964
|
-
function recordUsage(entry, env =
|
|
1021
|
+
function recordUsage(entry, env = process11.env) {
|
|
965
1022
|
if (!usageRecorded(env))
|
|
966
1023
|
return;
|
|
967
1024
|
try {
|
|
@@ -979,8 +1036,8 @@ var LEVEL_OPTIONS = {
|
|
|
979
1036
|
};
|
|
980
1037
|
var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
|
|
981
1038
|
function printError(prefix, message, hint, cause) {
|
|
982
|
-
const colors = paint(
|
|
983
|
-
const styled = takesControlCodes(
|
|
1039
|
+
const colors = paint(process12.stderr);
|
|
1040
|
+
const styled = takesControlCodes(process12.stderr);
|
|
984
1041
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
985
1042
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
986
1043
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1076,7 +1133,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1076
1133
|
return "0.0.0";
|
|
1077
1134
|
}
|
|
1078
1135
|
}
|
|
1079
|
-
async function runMain({ name, version, run, redact, usage }, argv =
|
|
1136
|
+
async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
|
|
1080
1137
|
if (argv[0] === COMPLETE)
|
|
1081
1138
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1082
1139
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
@@ -1102,6 +1159,58 @@ var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "ses
|
|
|
1102
1159
|
var {Glob } = globalThis.Bun;
|
|
1103
1160
|
var SESSION_FILES = new Glob("*.json");
|
|
1104
1161
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1162
|
+
// ../kit/src/watch.ts
|
|
1163
|
+
import process13 from "process";
|
|
1164
|
+
import { format } from "util";
|
|
1165
|
+
var CLEAR_SCREEN = "\x1B[H\x1B[2J";
|
|
1166
|
+
var DEFAULT_SECONDS = 2;
|
|
1167
|
+
var ATTACHED_SHORT = /^-w./;
|
|
1168
|
+
var INTERVAL = /^\d+(?:\.\d+)?(?:ms|[smh])?$/;
|
|
1169
|
+
function watchOption(what) {
|
|
1170
|
+
return { type: "string", short: "w", optional: { bare: "", accepts: INTERVAL }, description: `redraw ${what} every 2s, or every interval given (500ms, 5s), until ctrl-c` };
|
|
1171
|
+
}
|
|
1172
|
+
function withoutWatch(args) {
|
|
1173
|
+
const rest = [];
|
|
1174
|
+
for (let at = 0;at < args.length; at++) {
|
|
1175
|
+
const arg = args[at];
|
|
1176
|
+
if (arg === "--watch" || arg === "-w") {
|
|
1177
|
+
if (args[at + 1] !== undefined && INTERVAL.test(args[at + 1]))
|
|
1178
|
+
at++;
|
|
1179
|
+
} else if (!arg.startsWith("--watch=") && !ATTACHED_SHORT.test(arg)) {
|
|
1180
|
+
rest.push(arg);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
return rest;
|
|
1184
|
+
}
|
|
1185
|
+
async function watching(value, step, stream = process13.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
|
|
1186
|
+
const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
|
|
1187
|
+
if (!takesControlCodes(stream))
|
|
1188
|
+
badUsage("--watch redraws the screen, so it needs a terminal");
|
|
1189
|
+
let code = 0;
|
|
1190
|
+
for (let round = 0;round < rounds; round++) {
|
|
1191
|
+
const held = [];
|
|
1192
|
+
const { log, info } = console;
|
|
1193
|
+
const write = process13.stdout.write.bind(process13.stdout);
|
|
1194
|
+
const hold = (...parts) => void held.push(`${format(...parts)}
|
|
1195
|
+
`);
|
|
1196
|
+
console.log = hold;
|
|
1197
|
+
console.info = hold;
|
|
1198
|
+
process13.stdout.write = (text) => {
|
|
1199
|
+
held.push(typeof text === "string" ? text : Buffer.from(text).toString());
|
|
1200
|
+
return true;
|
|
1201
|
+
};
|
|
1202
|
+
try {
|
|
1203
|
+
code = await step();
|
|
1204
|
+
} finally {
|
|
1205
|
+
console.log = log;
|
|
1206
|
+
console.info = info;
|
|
1207
|
+
process13.stdout.write = write;
|
|
1208
|
+
}
|
|
1209
|
+
stream.write(`${CLEAR_SCREEN}${held.join("")}`);
|
|
1210
|
+
await sleep(interval);
|
|
1211
|
+
}
|
|
1212
|
+
return code;
|
|
1213
|
+
}
|
|
1105
1214
|
// src/git.ts
|
|
1106
1215
|
async function git2(args, env) {
|
|
1107
1216
|
const ran = await runCommand(["git", "--no-optional-locks", "-c", "core.quotePath=false", ...args], env === undefined ? {} : { env });
|
|
@@ -1173,7 +1282,7 @@ var OPTIONS = {
|
|
|
1173
1282
|
};
|
|
1174
1283
|
var RENAME = /^[RC]\d*$/;
|
|
1175
1284
|
var NOT_A_REPOSITORY = /not a git repository/i;
|
|
1176
|
-
var LITERAL = { ...
|
|
1285
|
+
var LITERAL = { ...process15.env, GIT_LITERAL_PATHSPECS: "1" };
|
|
1177
1286
|
function messageOf(title, lines, tickets) {
|
|
1178
1287
|
return [title, lines.join(`
|
|
1179
1288
|
`), tickets.join(`
|
|
@@ -1271,4 +1380,4 @@ ${(commit.stderr + commit.stdout).trim()}`;
|
|
|
1271
1380
|
signals.release();
|
|
1272
1381
|
}
|
|
1273
1382
|
}
|
|
1274
|
-
|
|
1383
|
+
process15.exitCode = await runMain({ name: "gc", run: main });
|