@kaynooo/cli-git 0.10.0 → 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 +42 -14
- package/dist/gc.js +19 -2
- package/dist/gst.js +20 -2
- package/package.json +2 -2
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) {
|
|
@@ -1153,6 +1168,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process12.a
|
|
|
1153
1168
|
}
|
|
1154
1169
|
return code;
|
|
1155
1170
|
}
|
|
1171
|
+
// ../kit/src/folders.ts
|
|
1172
|
+
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1156
1173
|
// ../kit/src/secrets.ts
|
|
1157
1174
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1158
1175
|
// ../kit/src/sessions.ts
|
|
@@ -1651,7 +1668,7 @@ function listLines(state, layout, theme) {
|
|
|
1651
1668
|
const promptWidth = Bun.stringWidth(state.prompt);
|
|
1652
1669
|
const query = fit(state.query, Math.max(1, layout.listWidth - promptWidth), identity);
|
|
1653
1670
|
const place = state.matches.length > rows ? ` (${state.cursor + 1} of ${state.matches.length})` : "";
|
|
1654
|
-
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);
|
|
1655
1672
|
const lines = [{ text: theme.accent(state.prompt) + query.text, width: promptWidth + query.width }, count, ...header];
|
|
1656
1673
|
if (state.matches.length === 0)
|
|
1657
1674
|
lines.push(fit(" no match", layout.listWidth, theme.label));
|
|
@@ -1659,7 +1676,7 @@ function listLines(state, layout, theme) {
|
|
|
1659
1676
|
const current = top + offset === state.cursor;
|
|
1660
1677
|
const pointer = current ? theme.accent("\u276F") : " ";
|
|
1661
1678
|
const mark = state.multi ? `${state.marked.has(match.index) ? theme.id("\u25CF") : " "} ` : "";
|
|
1662
|
-
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]);
|
|
1663
1680
|
lines.push({ text: `${pointer} ${mark}${text.text}`, width: prefixWidth + text.width });
|
|
1664
1681
|
}
|
|
1665
1682
|
return lines;
|
|
@@ -1690,14 +1707,24 @@ function up(lines) {
|
|
|
1690
1707
|
return lines > 0 ? `\x1B[${lines}A` : "";
|
|
1691
1708
|
}
|
|
1692
1709
|
function openTerminal() {
|
|
1693
|
-
let
|
|
1710
|
+
let mode;
|
|
1694
1711
|
try {
|
|
1695
|
-
|
|
1712
|
+
mode = new tty.ReadStream(openSync("/dev/tty", "r"));
|
|
1696
1713
|
} catch {
|
|
1697
1714
|
return fail("no terminal to read keys from (/dev/tty)");
|
|
1698
1715
|
}
|
|
1716
|
+
const keys = Bun.file("/dev/tty").stream().getReader();
|
|
1699
1717
|
const out = process16.stderr;
|
|
1700
1718
|
let resize;
|
|
1719
|
+
async function read(onChunk) {
|
|
1720
|
+
const decoder = new TextDecoder;
|
|
1721
|
+
try {
|
|
1722
|
+
for (let chunk = await keys.read();!chunk.done; chunk = await keys.read())
|
|
1723
|
+
onChunk(decoder.decode(chunk.value, { stream: true }));
|
|
1724
|
+
} catch {
|
|
1725
|
+
onChunk("\x03");
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1701
1728
|
return {
|
|
1702
1729
|
get columns() {
|
|
1703
1730
|
return out.columns || 80;
|
|
@@ -1705,21 +1732,22 @@ function openTerminal() {
|
|
|
1705
1732
|
get rows() {
|
|
1706
1733
|
return out.rows || 24;
|
|
1707
1734
|
},
|
|
1708
|
-
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)) },
|
|
1709
1736
|
write: (text) => void out.write(text),
|
|
1710
1737
|
listen(onChunk, onResize) {
|
|
1711
1738
|
resize = onResize;
|
|
1712
|
-
|
|
1739
|
+
mode.setRawMode(true);
|
|
1713
1740
|
out.on("resize", onResize);
|
|
1714
|
-
|
|
1741
|
+
read(onChunk);
|
|
1715
1742
|
},
|
|
1716
1743
|
close() {
|
|
1717
1744
|
if (resize !== undefined)
|
|
1718
1745
|
out.off("resize", resize);
|
|
1719
1746
|
try {
|
|
1720
|
-
|
|
1747
|
+
mode.setRawMode(false);
|
|
1721
1748
|
} finally {
|
|
1722
|
-
|
|
1749
|
+
mode.destroy();
|
|
1750
|
+
keys.cancel();
|
|
1723
1751
|
}
|
|
1724
1752
|
}
|
|
1725
1753
|
};
|
|
@@ -2063,7 +2091,7 @@ function load() {
|
|
|
2063
2091
|
function isCurrent(named, current, found) {
|
|
2064
2092
|
return current !== "" && (named === current || found.some((branch) => branch.remote && branch.name === named && localName(branch.name) === current));
|
|
2065
2093
|
}
|
|
2066
|
-
function
|
|
2094
|
+
function header2(found, current, failure = "") {
|
|
2067
2095
|
const changed = read(["status", "--porcelain", "--untracked-files=no"]).split(`
|
|
2068
2096
|
`).filter(Boolean).length;
|
|
2069
2097
|
const here = found.find((branch) => !branch.remote && branch.name === current) ?? (current ? { name: current, upstream: "", track: "" } : undefined);
|
|
@@ -2074,7 +2102,7 @@ ${KEYS2}`;
|
|
|
2074
2102
|
async function fetched() {
|
|
2075
2103
|
const proc = Bun.spawn(["git", "fetch", "--all", "--prune", "--quiet"], { stdout: "ignore", stderr: "ignore" });
|
|
2076
2104
|
const success = await proc.exited === 0;
|
|
2077
|
-
return
|
|
2105
|
+
return header2(branches(base()), read(["branch", "--show-current"]), success ? "" : "fetch failed");
|
|
2078
2106
|
}
|
|
2079
2107
|
function listed2(all) {
|
|
2080
2108
|
list([
|
|
@@ -2156,7 +2184,7 @@ async function gb(args) {
|
|
|
2156
2184
|
}
|
|
2157
2185
|
const picked = await pick(all.map(row), {
|
|
2158
2186
|
prompt: "gb> ",
|
|
2159
|
-
header:
|
|
2187
|
+
header: header2(found, current),
|
|
2160
2188
|
expect: ["ctrl-d", "ctrl-n"],
|
|
2161
2189
|
searched: 1,
|
|
2162
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) {
|
|
@@ -1153,6 +1168,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process12.a
|
|
|
1153
1168
|
}
|
|
1154
1169
|
return code;
|
|
1155
1170
|
}
|
|
1171
|
+
// ../kit/src/folders.ts
|
|
1172
|
+
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1156
1173
|
// ../kit/src/secrets.ts
|
|
1157
1174
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1158
1175
|
// ../kit/src/sessions.ts
|
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) {
|
|
@@ -1153,6 +1168,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process12.a
|
|
|
1153
1168
|
}
|
|
1154
1169
|
return code;
|
|
1155
1170
|
}
|
|
1171
|
+
// ../kit/src/folders.ts
|
|
1172
|
+
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1156
1173
|
// ../kit/src/secrets.ts
|
|
1157
1174
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1158
1175
|
// ../kit/src/sessions.ts
|
|
@@ -1357,6 +1374,7 @@ ${USAGE}`);
|
|
|
1357
1374
|
...group("conflicted", status.conflicted.map((file) => paint(process16.stdout).red(file))),
|
|
1358
1375
|
...group("commits", commits.map(([commitSha = "", commitTitle = ""]) => `${role("id", process16.stdout)(commitSha)} ${commitTitle}`))
|
|
1359
1376
|
];
|
|
1377
|
+
printHeader("gst");
|
|
1360
1378
|
console.log(lines.join(`
|
|
1361
1379
|
`));
|
|
1362
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.
|
|
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",
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
"gb": "$npm_execpath src/gb.ts"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@kaynooo/cli-kit": "0.
|
|
47
|
+
"@kaynooo/cli-kit": "0.27.1"
|
|
48
48
|
}
|
|
49
49
|
}
|