@kaynooo/cli-git 0.7.1 → 0.8.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/gst.js CHANGED
@@ -2,13 +2,13 @@
2
2
  // @bun
3
3
 
4
4
  // src/gst.ts
5
- import process9 from "process";
5
+ import process13 from "process";
6
6
  // ../kit/src/args.ts
7
- import process4 from "process";
7
+ import process7 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
10
  // ../kit/src/style.ts
11
- import process2 from "process";
11
+ import process5 from "process";
12
12
 
13
13
  // ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
14
14
  function x(s) {
@@ -271,21 +271,209 @@ function le(i = {}) {
271
271
  }
272
272
  var t = le();
273
273
 
274
+ // ../kit/src/theme.ts
275
+ import { existsSync as existsSync2, readFileSync, statSync } from "fs";
276
+ import { homedir as homedir2 } from "os";
277
+ import { join as join3, resolve as resolve2 } from "path";
278
+ import process4 from "process";
279
+
280
+ // ../kit/src/config.ts
281
+ import { existsSync } from "fs";
282
+ import { dirname, join, resolve } from "path";
283
+ import process2 from "process";
284
+ function findUp(names, from = process2.cwd(), stop = () => false) {
285
+ const wanted = typeof names === "string" ? [names] : names;
286
+ for (let dir = resolve(from);; dir = dirname(dir)) {
287
+ const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
288
+ if (found !== undefined)
289
+ return found;
290
+ if (stop(dir) || dirname(dir) === dir)
291
+ return;
292
+ }
293
+ }
294
+
295
+ // ../kit/src/user-config.ts
296
+ import { homedir } from "os";
297
+ import { join as join2 } from "path";
298
+ import process3 from "process";
299
+ function configBase(where = {}) {
300
+ const xdg = where.xdg ?? (where.home === undefined ? process3.env.XDG_CONFIG_HOME : undefined);
301
+ return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
302
+ }
303
+ function userConfigPath(bin, where = {}) {
304
+ return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
305
+ }
306
+
307
+ // ../kit/src/theme.ts
308
+ var DEFAULT = {
309
+ colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
310
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
311
+ accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
312
+ bins: {}
313
+ };
314
+ var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
315
+ var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
316
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
317
+ var PRESETS = {
318
+ default: {},
319
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
320
+ mono: { colors: MONO, accents: ["bold"] },
321
+ ascii: { glyphs: ASCII }
322
+ };
323
+ var STYLES = new Set(["bold", "dim", "italic", "underline", "inverse", "strikethrough", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray", "grey", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright"]);
324
+ var HEX = /^#[0-9a-f]{6}$/i;
325
+ var CONTROL = /\p{Cc}/u;
326
+ var MAX_FILE_BYTES = 64 * 1024;
327
+ var SPACES = /\s+/;
328
+ function isColorSpec(spec) {
329
+ if (typeof spec === "number")
330
+ return Number.isInteger(spec) && spec >= 0 && spec <= 255;
331
+ return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
332
+ }
333
+ function tinted(colors, spec) {
334
+ if (typeof spec === "number")
335
+ return colors.ansi256(spec);
336
+ return spec.trim().split(SPACES).reduce((chain, token) => HEX.test(token) ? chain.hex(token) : chain[token] ?? chain, colors);
337
+ }
338
+ function isRecord(value) {
339
+ return typeof value === "object" && value !== null && !Array.isArray(value);
340
+ }
341
+ function readThemeFile(path, warn) {
342
+ try {
343
+ const stat = statSync(path, { throwIfNoEntry: false });
344
+ if (stat === undefined)
345
+ return;
346
+ if (!stat.isFile() || stat.size > MAX_FILE_BYTES) {
347
+ warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
348
+ return;
349
+ }
350
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
351
+ if (isRecord(parsed))
352
+ return parsed;
353
+ warn(`${path} is not a JSON object, theme ignored`);
354
+ } catch (error) {
355
+ warn(`${path} does not parse (${error instanceof Error ? error.message : String(error)}), theme ignored`);
356
+ }
357
+ return;
358
+ }
359
+ function applyPreset(theme, name, warn, where) {
360
+ if (name === undefined)
361
+ return;
362
+ if (typeof name !== "string" || !Object.hasOwn(PRESETS, name)) {
363
+ warn(`${where}: no preset ${String(name)}, one of ${Object.keys(PRESETS).join(", ")}`);
364
+ return;
365
+ }
366
+ const preset = PRESETS[name];
367
+ Object.assign(theme.colors, preset.colors);
368
+ Object.assign(theme.glyphs, preset.glyphs);
369
+ if (preset.accents !== undefined)
370
+ theme.accents = [...preset.accents];
371
+ return name;
372
+ }
373
+ function applyFile(theme, file, where, warn) {
374
+ if (isRecord(file.colors)) {
375
+ for (const [key, value] of Object.entries(file.colors)) {
376
+ if (!Object.hasOwn(DEFAULT.colors, key))
377
+ warn(`${where}: no colour ${key}, one of ${Object.keys(DEFAULT.colors).join(", ")}`);
378
+ else if (!isColorSpec(value))
379
+ warn(`${where}: colour ${key} is not an ANSI name, \`#rrggbb\` or a number up to 255`);
380
+ else
381
+ theme.colors[key] = value;
382
+ }
383
+ }
384
+ if (isRecord(file.glyphs)) {
385
+ for (const [key, value] of Object.entries(file.glyphs)) {
386
+ if (!Object.hasOwn(DEFAULT.glyphs, key))
387
+ warn(`${where}: no glyph ${key}, one of ${Object.keys(DEFAULT.glyphs).join(", ")}`);
388
+ else if (typeof value !== "string" || CONTROL.test(value) || Bun.stringWidth(value) !== 1)
389
+ warn(`${where}: glyph ${key} must be one visible character wide, with no control character`);
390
+ else
391
+ theme.glyphs[key] = value;
392
+ }
393
+ }
394
+ if (Array.isArray(file.accents) && file.accents.length > 0 && file.accents.every(isColorSpec))
395
+ theme.accents = [...file.accents];
396
+ else if (file.accents !== undefined)
397
+ warn(`${where}: accents must be a non-empty list of colours`);
398
+ if (isRecord(file.bins)) {
399
+ for (const [bin, value] of Object.entries(file.bins)) {
400
+ if (isColorSpec(value))
401
+ theme.bins[bin] = value;
402
+ else
403
+ warn(`${where}: bin ${bin} has no valid colour`);
404
+ }
405
+ }
406
+ }
407
+ function endsWalk(home) {
408
+ return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
409
+ }
410
+ var warned = new Set;
411
+ function warnOnce(message) {
412
+ if (warned.has(message))
413
+ return;
414
+ warned.add(message);
415
+ console.error(`warning: theme ${message}`);
416
+ }
417
+ function isPath(chosen) {
418
+ return chosen.includes("/") || chosen.endsWith(".json");
419
+ }
420
+ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(), warn = warnOnce } = {}) {
421
+ const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
422
+ const sources = [];
423
+ const chosen = env.KIT_THEME ?? "";
424
+ const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
425
+ if (isPath(chosen))
426
+ wanted.push(resolve2(from, chosen));
427
+ const files = [];
428
+ for (const path of wanted) {
429
+ const file = path === undefined ? undefined : readThemeFile(path, warn);
430
+ if (path !== undefined && file !== undefined)
431
+ files.push({ path, file });
432
+ }
433
+ let preset = "default";
434
+ if (chosen !== "" && !isPath(chosen)) {
435
+ preset = applyPreset(theme, chosen, warn, "KIT_THEME") ?? preset;
436
+ } else {
437
+ const named = files.findLast(({ file }) => file.preset !== undefined);
438
+ if (named !== undefined)
439
+ preset = applyPreset(theme, named.file.preset, warn, named.path) ?? preset;
440
+ }
441
+ for (const { path, file } of files) {
442
+ applyFile(theme, file, path, warn);
443
+ sources.push(path);
444
+ }
445
+ return { theme, sources, preset };
446
+ }
447
+ var current;
448
+ var currentKey = "";
449
+ function activeTheme() {
450
+ const key = `${process4.cwd()}\x00${process4.env.KIT_THEME ?? ""}\x00${process4.env.XDG_CONFIG_HOME ?? ""}`;
451
+ if (current === undefined || key !== currentKey) {
452
+ current = loadTheme();
453
+ currentKey = key;
454
+ }
455
+ return current;
456
+ }
457
+
274
458
  // ../kit/src/style.ts
275
- function takesControlCodes(stream, env = process2.env) {
459
+ function takesControlCodes(stream, env = process5.env) {
276
460
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
277
461
  }
278
- function paint(stream, env = process2.env) {
462
+ function paint(stream, env = process5.env) {
279
463
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
280
464
  }
281
- var STATUSES = {
282
- passed: { symbol: "\u2713", words: ["passed", "success", "succeeded", "ok"], paint: (colors) => colors.green },
283
- failed: { symbol: "\u2717", words: ["failed", "failure", "error", "errored"], paint: (colors) => colors.red },
284
- running: { symbol: "\u25CF", words: ["running", "in_progress", "started"], paint: (colors) => colors.cyan },
285
- queued: { symbol: "\u25CB", words: ["queued", "waiting", "pending", "created", "blocked", "scheduled"], paint: (colors) => colors.yellow },
286
- skipped: { symbol: "-", words: ["skipped", "cancelled", "canceled", "manual"], paint: (colors) => colors.dim }
465
+ function role(name, stream, env = process5.env) {
466
+ const colors = paint(stream, env);
467
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
468
+ }
469
+ var STATUS_WORDS = {
470
+ passed: ["passed", "success", "succeeded", "ok"],
471
+ failed: ["failed", "failure", "error", "errored"],
472
+ running: ["running", "in_progress", "started"],
473
+ queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
474
+ skipped: ["skipped", "cancelled", "canceled", "manual"]
287
475
  };
288
- var STATUS_OF = new Map(Object.entries(STATUSES).flatMap(([status, { words }]) => words.map((word) => [word, status])));
476
+ var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
289
477
 
290
478
  // ../kit/src/format.ts
291
479
  function upTo(text, separator) {
@@ -298,27 +486,27 @@ function printJson(value) {
298
486
  }
299
487
 
300
488
  // ../kit/src/help.ts
301
- import process3 from "process";
489
+ import process6 from "process";
302
490
  var OPTIONAL = /\[[^\]]+\]/g;
303
491
  var USAGE_PREFIX = /^usage:\s*/i;
304
492
  var FULL_STOP = /\.$/;
305
- function usageLine(usage, colors = paint(process3.stdout)) {
493
+ function usageLine(usage, colors = paint(process6.stdout)) {
306
494
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
307
495
  }
308
- function helpText(usage, options, colors = paint(process3.stdout), { examples = [], replaces, exits = [] } = {}) {
496
+ function helpText(usage, options, colors = paint(process6.stdout), { examples = [], replaces, exits = [] } = {}) {
309
497
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
310
498
  `);
311
499
  }
312
- function exitRows(exits, colors = paint(process3.stdout)) {
500
+ function exitRows(exits, colors = paint(process6.stdout)) {
313
501
  if (exits.length === 0)
314
502
  return [];
315
503
  const width = Math.max(...exits.map(([code]) => String(code).length));
316
504
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
317
505
  }
318
- function replacesRows(replaces, colors = paint(process3.stdout)) {
506
+ function replacesRows(replaces, colors = paint(process6.stdout)) {
319
507
  return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
320
508
  }
321
- function wantsHelpJson(env = process3.env) {
509
+ function wantsHelpJson(env = process6.env) {
322
510
  return env.KIT_HELP === "json";
323
511
  }
324
512
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -337,12 +525,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
337
525
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
338
526
  };
339
527
  }
340
- function exampleRows(examples, colors = paint(process3.stdout)) {
528
+ function exampleRows(examples, colors = paint(process6.stdout)) {
341
529
  if (examples.length === 0)
342
530
  return [];
343
531
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
344
532
  }
345
- function optionRows(options, colors = paint(process3.stdout)) {
533
+ function optionRows(options, colors = paint(process6.stdout)) {
346
534
  const rows = Object.entries(options).map(([name, option]) => {
347
535
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
348
536
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -433,7 +621,7 @@ var OUTPUT_OPTIONS = {
433
621
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
434
622
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
435
623
  };
436
- function applyOutput(color, plain, env = process4.env) {
624
+ function applyOutput(color, plain, env = process7.env) {
437
625
  const when = plain === true ? "never" : color ?? "auto";
438
626
  if (when === "auto")
439
627
  return;
@@ -604,7 +792,7 @@ function nearestOption(message, options, allowNegative) {
604
792
  }
605
793
  // ../kit/src/process.ts
606
794
  import { constants } from "os";
607
- import process5 from "process";
795
+ import process8 from "process";
608
796
  var KILL_GRACE_MS = 2000;
609
797
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
610
798
  function exitCodeOf(code, signal) {
@@ -626,7 +814,7 @@ function holdSignals(cleanup) {
626
814
  },
627
815
  release: () => {
628
816
  for (const signal of SIGNALS)
629
- process5.off(signal, onSignal);
817
+ process8.off(signal, onSignal);
630
818
  }
631
819
  };
632
820
  function onSignal(signal) {
@@ -639,10 +827,10 @@ function holdSignals(cleanup) {
639
827
  return;
640
828
  held.release();
641
829
  cleanup(signal);
642
- process5.kill(process5.pid, signal);
830
+ process8.kill(process8.pid, signal);
643
831
  }
644
832
  for (const signal of SIGNALS)
645
- process5.on(signal, onSignal);
833
+ process8.on(signal, onSignal);
646
834
  return held;
647
835
  }
648
836
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -656,7 +844,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
656
844
  return;
657
845
  try {
658
846
  if (grouped)
659
- process5.kill(-proc.pid, killing);
847
+ process8.kill(-proc.pid, killing);
660
848
  else
661
849
  proc.kill(killing);
662
850
  } catch {}
@@ -730,15 +918,15 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
730
918
  var RESET_STYLE = `${ESC}[0m`;
731
919
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
732
920
  // ../kit/src/cli.ts
733
- import { readFileSync, realpathSync } from "fs";
734
- import { dirname as dirname2, join as join2 } from "path";
735
- import process7 from "process";
921
+ import { readFileSync as readFileSync2, realpathSync } from "fs";
922
+ import { dirname as dirname3, join as join5 } from "path";
923
+ import process10 from "process";
736
924
 
737
925
  // ../kit/src/usage.ts
738
926
  import { appendFileSync, mkdirSync } from "fs";
739
- import { homedir } from "os";
740
- import { dirname, isAbsolute, join } from "path";
741
- import process6 from "process";
927
+ import { homedir as homedir3 } from "os";
928
+ import { dirname as dirname2, isAbsolute, join as join4 } from "path";
929
+ import process9 from "process";
742
930
 
743
931
  // ../kit/src/logs.ts
744
932
  var DAY_MS = 24 * 60 * 60 * 1000;
@@ -752,14 +940,14 @@ var usageError;
752
940
  function noteUsageError(message) {
753
941
  usageError = message;
754
942
  }
755
- function stateHome(env = process6.env) {
943
+ function stateHome(env = process9.env) {
756
944
  const dir = env.XDG_STATE_HOME;
757
- return dir !== undefined && isAbsolute(dir) ? dir : join(homedir(), ".local", "state");
945
+ return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
758
946
  }
759
- function usagePath(env = process6.env) {
760
- return join(stateHome(env), CLI_FOLDER, "usage.jsonl");
947
+ function usagePath(env = process9.env) {
948
+ return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
761
949
  }
762
- function usageRecorded(env = process6.env) {
950
+ function usageRecorded(env = process9.env) {
763
951
  const off = env.KAYNOOO_CLI_NO_USAGE;
764
952
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
765
953
  }
@@ -773,12 +961,12 @@ function usageEntry(bin, command, argv, code, now = new Date) {
773
961
  usageError = undefined;
774
962
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
775
963
  }
776
- function recordUsage(entry, env = process6.env) {
964
+ function recordUsage(entry, env = process9.env) {
777
965
  if (!usageRecorded(env))
778
966
  return;
779
967
  try {
780
968
  const path = usagePath(env);
781
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
969
+ mkdirSync(dirname2(path), { recursive: true, mode: 448 });
782
970
  appendFileSync(path, `${JSON.stringify(entry)}
783
971
  `, { mode: 384 });
784
972
  } catch {}
@@ -791,8 +979,8 @@ var LEVEL_OPTIONS = {
791
979
  };
792
980
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
793
981
  function printError(prefix, message, hint, cause) {
794
- const colors = paint(process7.stderr);
795
- const styled = takesControlCodes(process7.stderr);
982
+ const colors = paint(process10.stderr);
983
+ const styled = takesControlCodes(process10.stderr);
796
984
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
797
985
  const under = (label, text, tint) => text === undefined ? "" : `
798
986
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -814,7 +1002,7 @@ function reportThrown(prefix, error, redact = (text) => text, json = false) {
814
1002
  const help = error instanceof UsageError ? `run ${prefix} --help for its options` : undefined;
815
1003
  const named = error instanceof Error && !(error instanceof Exit) && error.name !== "Error" ? `${error.name}: ${error.message}` : undefined;
816
1004
  const cause = error instanceof Error && error.cause instanceof Error ? redact(error.cause.message) : undefined;
817
- if (error instanceof UsageError)
1005
+ if (error instanceof Exit && error.code === 2)
818
1006
  noteUsageError(error.message);
819
1007
  const report = json ? printJsonError : (message, hint, causeText) => printError(prefix, message, hint, causeText);
820
1008
  report(redact(named ?? (error instanceof Error ? error.message : String(error))), error instanceof Exit ? error.hint ?? help : undefined, cause);
@@ -878,17 +1066,17 @@ async function printCandidates(found) {
878
1066
  return 0;
879
1067
  }
880
1068
  function packageVersion(entry = Bun.main) {
881
- for (let dir = dirname2(realpathSync(entry));; dir = dirname2(dir)) {
1069
+ for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
882
1070
  try {
883
- const { version } = JSON.parse(readFileSync(join2(dir, "package.json"), "utf8"));
1071
+ const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
884
1072
  if (typeof version === "string")
885
1073
  return version;
886
1074
  } catch {}
887
- if (dirname2(dir) === dir)
1075
+ if (dirname3(dir) === dir)
888
1076
  return "0.0.0";
889
1077
  }
890
1078
  }
891
- async function runMain({ name, version, run, redact, usage }, argv = process7.argv.slice(2)) {
1079
+ async function runMain({ name, version, run, redact, usage }, argv = process10.argv.slice(2)) {
892
1080
  if (argv[0] === COMPLETE)
893
1081
  return printCandidates(leafCandidates(run, argv.slice(1)));
894
1082
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -914,6 +1102,14 @@ var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "ses
914
1102
  var {Glob } = globalThis.Bun;
915
1103
  var SESSION_FILES = new Glob("*.json");
916
1104
  var ACCOUNT_DIRS = new Glob("*/sessions");
1105
+ // src/colour.ts
1106
+ import process12 from "process";
1107
+ function letter(status, stream = process12.stdout) {
1108
+ const colors = paint(stream);
1109
+ const tint = { A: colors.green, M: colors.yellow, D: colors.red, U: colors.red, R: colors.cyan, C: colors.cyan }[status] ?? colors.dim;
1110
+ return tint(status);
1111
+ }
1112
+
917
1113
  // src/git.ts
918
1114
  async function git2(args, env) {
919
1115
  const ran = await runCommand(["git", "--no-optional-locks", "-c", "core.quotePath=false", ...args], env === undefined ? {} : { env });
@@ -1002,10 +1198,10 @@ var OPTIONS = {
1002
1198
  json: jsonOption("{branch, oid, upstream, ahead, behind, head, staged, unstaged, untracked, conflicted, commits}")
1003
1199
  };
1004
1200
  function group(title, lines) {
1005
- return lines.length === 0 ? [] : [`${title}:`, ...lines.map((line) => ` ${line}`)];
1201
+ return lines.length === 0 ? [] : [paint(process13.stdout).bold(`${title}:`), ...lines.map((line) => ` ${line}`)];
1006
1202
  }
1007
1203
  function staged({ index, from, path }) {
1008
- return `${index} ${from === undefined ? "" : `${from} -> `}${path}`;
1204
+ return `${letter(index)} ${from === undefined ? "" : `${from} -> `}${path}`;
1009
1205
  }
1010
1206
  async function main(argv) {
1011
1207
  const parsed = parse(argv, USAGE, OPTIONS, { replaces: "git status --short and git log --oneline", examples: ["gst", ["gst --log 5", "with the last five commits"]] });
@@ -1044,13 +1240,13 @@ ${USAGE}`);
1044
1240
  const lines = [
1045
1241
  summary(status, head.code === 0 ? head.stdout : ""),
1046
1242
  ...group("staged", status.changes.filter((change) => change.index !== ".").map(staged)),
1047
- ...group("unstaged", status.changes.filter((change) => change.worktree !== ".").map((change) => `${change.worktree} ${change.path}`)),
1048
- ...group("untracked", status.untracked),
1049
- ...group("conflicted", status.conflicted),
1050
- ...group("commits", commits.map((parts) => parts.join(" ")))
1243
+ ...group("unstaged", status.changes.filter((change) => change.worktree !== ".").map((change) => `${letter(change.worktree)} ${change.path}`)),
1244
+ ...group("untracked", status.untracked.map((file) => paint(process13.stdout).dim(file))),
1245
+ ...group("conflicted", status.conflicted.map((file) => paint(process13.stdout).red(file))),
1246
+ ...group("commits", commits.map(([commitSha = "", commitTitle = ""]) => `${role("id", process13.stdout)(commitSha)} ${commitTitle}`))
1051
1247
  ];
1052
1248
  console.log(lines.join(`
1053
1249
  `));
1054
1250
  return 0;
1055
1251
  }
1056
- process9.exitCode = await runMain({ name: "gst", run: main });
1252
+ process13.exitCode = await runMain({ name: "gst", run: main });
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-git",
3
3
  "type": "module",
4
- "version": "0.7.1",
5
- "description": "gst, gc and gb: a repository's state in one call, a commit of exactly the paths given, its message checked before anything is staged, and a branch picked with fzf.",
4
+ "version": "0.8.0",
5
+ "description": "gst, gc and gb: a repository's state in one call, a commit of exactly the paths given, its message checked before anything is staged, and a branch picked.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
8
8
  "homepage": "https://git.kaynooo.fr/kaynooo/cli/src/branch/main/packages/git#readme",
@@ -44,6 +44,6 @@
44
44
  "gb": "$npm_execpath src/gb.ts"
45
45
  },
46
46
  "devDependencies": {
47
- "@kaynooo/cli-kit": "0.21.0"
47
+ "@kaynooo/cli-kit": "0.21.1"
48
48
  }
49
49
  }