@kaynooo/cli-git 0.10.1 → 0.11.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 CHANGED
@@ -331,13 +331,13 @@ function userConfigPath(bin, where = {}) {
331
331
  // ../kit/src/theme.ts
332
332
  var DEFAULT = {
333
333
  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" },
334
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
334
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
335
335
  accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
336
336
  bins: {}
337
337
  };
338
338
  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" };
339
339
  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" };
340
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
340
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
341
341
  var PRESETS = {
342
342
  default: {},
343
343
  "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
@@ -518,6 +518,21 @@ var STATUS_WORDS = {
518
518
  skipped: ["skipped", "cancelled", "canceled", "manual"]
519
519
  };
520
520
  var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
521
+ function header(bin, context, stream, env = process6.env) {
522
+ if (!takesControlCodes(stream, env))
523
+ return "";
524
+ const colors = paint(stream, env);
525
+ const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
526
+ const { theme } = activeTheme();
527
+ const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
528
+ const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
529
+ return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
530
+ }
531
+ function printHeader(bin, context, stream = process6.stdout, env = process6.env) {
532
+ const line = header(bin, context, stream, env);
533
+ if (line !== "")
534
+ console.log(line);
535
+ }
521
536
 
522
537
  // ../kit/src/format.ts
523
538
  function upTo(text, separator) {
@@ -1653,7 +1668,7 @@ function listLines(state, layout, theme) {
1653
1668
  const promptWidth = Bun.stringWidth(state.prompt);
1654
1669
  const query = fit(state.query, Math.max(1, layout.listWidth - promptWidth), identity);
1655
1670
  const place = state.matches.length > rows ? ` (${state.cursor + 1} of ${state.matches.length})` : "";
1656
- const count = fit(` ${state.matches.length}/${state.items.length}${place}${marks}`, layout.listWidth, theme.label);
1671
+ const count = fit(` ${state.matches.length}/${state.items.length}${place}${marks} ctrl-/ keys`, layout.listWidth, theme.label);
1657
1672
  const lines = [{ text: theme.accent(state.prompt) + query.text, width: promptWidth + query.width }, count, ...header];
1658
1673
  if (state.matches.length === 0)
1659
1674
  lines.push(fit(" no match", layout.listWidth, theme.label));
@@ -1661,7 +1676,7 @@ function listLines(state, layout, theme) {
1661
1676
  const current = top + offset === state.cursor;
1662
1677
  const pointer = current ? theme.accent("\u276F") : " ";
1663
1678
  const mark = state.multi ? `${state.marked.has(match.index) ? theme.id("\u25CF") : " "} ` : "";
1664
- const text = fit(state.items[match.index], layout.listWidth - prefixWidth, current ? theme.value : identity, theme.accent, new Set(match.positions), state.styles[match.index]);
1679
+ const text = fit(state.items[match.index], layout.listWidth - prefixWidth, current ? theme.value : identity, theme.match ?? theme.accent, new Set(match.positions), state.styles[match.index]);
1665
1680
  lines.push({ text: `${pointer} ${mark}${text.text}`, width: prefixWidth + text.width });
1666
1681
  }
1667
1682
  return lines;
@@ -1717,7 +1732,7 @@ function openTerminal() {
1717
1732
  get rows() {
1718
1733
  return out.rows || 24;
1719
1734
  },
1720
- theme: { accent: role("accent", out), label: role("label", out), value: role("value", out), id: role("id", out) },
1735
+ theme: { accent: role("accent", out), label: role("label", out), value: role("value", out), id: role("id", out), match: (text) => paint(out).underline(role("accent", out)(text)) },
1721
1736
  write: (text) => void out.write(text),
1722
1737
  listen(onChunk, onResize) {
1723
1738
  resize = onResize;
@@ -2076,7 +2091,7 @@ function load() {
2076
2091
  function isCurrent(named, current, found) {
2077
2092
  return current !== "" && (named === current || found.some((branch) => branch.remote && branch.name === named && localName(branch.name) === current));
2078
2093
  }
2079
- function header(found, current, failure = "") {
2094
+ function header2(found, current, failure = "") {
2080
2095
  const changed = read(["status", "--porcelain", "--untracked-files=no"]).split(`
2081
2096
  `).filter(Boolean).length;
2082
2097
  const here = found.find((branch) => !branch.remote && branch.name === current) ?? (current ? { name: current, upstream: "", track: "" } : undefined);
@@ -2087,7 +2102,7 @@ ${KEYS2}`;
2087
2102
  async function fetched() {
2088
2103
  const proc = Bun.spawn(["git", "fetch", "--all", "--prune", "--quiet"], { stdout: "ignore", stderr: "ignore" });
2089
2104
  const success = await proc.exited === 0;
2090
- return header(branches(base()), read(["branch", "--show-current"]), success ? "" : "fetch failed");
2105
+ return header2(branches(base()), read(["branch", "--show-current"]), success ? "" : "fetch failed");
2091
2106
  }
2092
2107
  function listed2(all) {
2093
2108
  list([
@@ -2169,7 +2184,7 @@ async function gb(args) {
2169
2184
  }
2170
2185
  const picked = await pick(all.map(row), {
2171
2186
  prompt: "gb> ",
2172
- header: header(found, current),
2187
+ header: header2(found, current),
2173
2188
  expect: ["ctrl-d", "ctrl-n"],
2174
2189
  searched: 1,
2175
2190
  preview: (fields) => preview(fields[0]),
package/dist/gc.js CHANGED
@@ -331,13 +331,13 @@ function userConfigPath(bin, where = {}) {
331
331
  // ../kit/src/theme.ts
332
332
  var DEFAULT = {
333
333
  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" },
334
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
334
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
335
335
  accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
336
336
  bins: {}
337
337
  };
338
338
  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" };
339
339
  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" };
340
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
340
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
341
341
  var PRESETS = {
342
342
  default: {},
343
343
  "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
@@ -518,6 +518,21 @@ var STATUS_WORDS = {
518
518
  skipped: ["skipped", "cancelled", "canceled", "manual"]
519
519
  };
520
520
  var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
521
+ function header(bin, context, stream, env = process6.env) {
522
+ if (!takesControlCodes(stream, env))
523
+ return "";
524
+ const colors = paint(stream, env);
525
+ const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
526
+ const { theme } = activeTheme();
527
+ const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
528
+ const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
529
+ return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
530
+ }
531
+ function printHeader(bin, context, stream = process6.stdout, env = process6.env) {
532
+ const line = header(bin, context, stream, env);
533
+ if (line !== "")
534
+ console.log(line);
535
+ }
521
536
 
522
537
  // ../kit/src/format.ts
523
538
  function upTo(text, separator) {
package/dist/gst.js CHANGED
@@ -331,13 +331,13 @@ function userConfigPath(bin, where = {}) {
331
331
  // ../kit/src/theme.ts
332
332
  var DEFAULT = {
333
333
  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" },
334
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
334
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
335
335
  accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
336
336
  bins: {}
337
337
  };
338
338
  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" };
339
339
  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" };
340
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
340
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
341
341
  var PRESETS = {
342
342
  default: {},
343
343
  "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
@@ -518,6 +518,21 @@ var STATUS_WORDS = {
518
518
  skipped: ["skipped", "cancelled", "canceled", "manual"]
519
519
  };
520
520
  var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
521
+ function header(bin, context, stream, env = process6.env) {
522
+ if (!takesControlCodes(stream, env))
523
+ return "";
524
+ const colors = paint(stream, env);
525
+ const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
526
+ const { theme } = activeTheme();
527
+ const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
528
+ const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
529
+ return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
530
+ }
531
+ function printHeader(bin, context, stream = process6.stdout, env = process6.env) {
532
+ const line = header(bin, context, stream, env);
533
+ if (line !== "")
534
+ console.log(line);
535
+ }
521
536
 
522
537
  // ../kit/src/format.ts
523
538
  function upTo(text, separator) {
@@ -1359,6 +1374,7 @@ ${USAGE}`);
1359
1374
  ...group("conflicted", status.conflicted.map((file) => paint(process16.stdout).red(file))),
1360
1375
  ...group("commits", commits.map(([commitSha = "", commitTitle = ""]) => `${role("id", process16.stdout)(commitSha)} ${commitTitle}`))
1361
1376
  ];
1377
+ printHeader("gst");
1362
1378
  console.log(lines.join(`
1363
1379
  `));
1364
1380
  return 0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-git",
3
3
  "type": "module",
4
- "version": "0.10.1",
4
+ "version": "0.11.0",
5
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",