@kaynooo/cli-git 0.15.0 → 0.15.2
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 +34 -1
- package/dist/gb.js +73 -30
- package/dist/gc.js +54 -18
- package/dist/gcl.js +1662 -0
- package/dist/gd.js +1642 -0
- package/dist/gf.js +1624 -0
- package/dist/gp.js +79 -38
- package/dist/gst.js +86 -36
- package/dist/gu.js +1484 -0
- package/package.json +14 -6
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# gst, gc, gb and
|
|
1
|
+
# gst, gc, gb, gp, gf, gcl, gd and gu
|
|
2
2
|
|
|
3
3
|
Git for Claude Code, where a session would otherwise chain `git status --short` and `git log --oneline` to read the state, or `git add <paths> && git status && git commit -m ...` to commit and have the commit bounced over its message.
|
|
4
4
|
|
|
@@ -42,6 +42,39 @@ Prints one line with the branch, its upstream and how far ahead and behind it is
|
|
|
42
42
|
- Hidden flags for wrappers: `--emit` (with any of the above) prints the command as lines for a shell function to run, `--list` the rows as JSON for term, `--names` the branches with their last commit for shell completions, `--show <branch>` the preview and `--fetch` what ctrl-r runs.
|
|
43
43
|
- Exit codes: the git command's, 1 when no branch is picked or found, 2 outside a repository.
|
|
44
44
|
|
|
45
|
+
## gf
|
|
46
|
+
|
|
47
|
+
`gf [dir]...` fetches with prune, then fast-forwards the current branch onto its upstream, and prints what came in (`main <- origin/main, 2 commits`). `--repos` (`-r`) does every repository `gst --repos` lists; `--no-pull` fetches only and says how far behind the branch is.
|
|
48
|
+
|
|
49
|
+
- It never merges or rebases: a branch that has diverged, or a working tree the fast-forward would overwrite, is refused and left as it was, with git's reason.
|
|
50
|
+
- A detached HEAD, a branch with no upstream and one whose upstream is gone are fetched only, saying so.
|
|
51
|
+
- `--json` prints `{path, branch, upstream, commits, outcome, reason?}` per repository, `outcome` being `updated`, `current`, `fetched`, `skipped` or `refused`.
|
|
52
|
+
- Exit codes: 0 every repository was fetched, and fast-forwarded when it could be, 1 a fetch failed, a branch diverged or a fast-forward was refused, 2 outside a repository or a usage error.
|
|
53
|
+
|
|
54
|
+
## gcl
|
|
55
|
+
|
|
56
|
+
`gcl <repo> [dir]` clones into `<workspace>/<name>` (the workspace `cli config` reports) or into `dir`, and prints the path on stdout, so `cd (gcl kaynooo/cli)` lands in it. `<repo>` is a URL, an scp-style address, a local path or `owner/name`, read as `https://git.kaynooo.fr/owner/name.git`; the `forge` key of `~/.config/kaynooo-cli/config.json` names another host.
|
|
57
|
+
|
|
58
|
+
- A folder that already holds the repository is not cloned again: it is fetched and fast-forwarded as `gf` does. A folder holding anything else is refused, exit 1.
|
|
59
|
+
- `--json` prints `{url, path, branch, head, outcome}`, `outcome` being `cloned` or `existing`.
|
|
60
|
+
|
|
61
|
+
## gd
|
|
62
|
+
|
|
63
|
+
`gd [path]...` lists the tracked files that changed with their added and removed lines, staged apart from unstaged; untracked files are `gst`'s. With paths, or `--patch` (`-p`), it prints the patch instead, through `view --diff` on a terminal when `view` is installed.
|
|
64
|
+
|
|
65
|
+
- `--staged` (`-s`) keeps what is staged; `--ref <rev>` compares the working tree to a commit, branch or tag, and `--ref a..b` two commits.
|
|
66
|
+
- `--json` prints `[{title, files: [{path, added, removed}]}]`, the counts being null for a binary file.
|
|
67
|
+
- Exit codes: 0, 1 git refused (an unknown ref), 2 outside a repository or a usage error.
|
|
68
|
+
|
|
69
|
+
## gu
|
|
70
|
+
|
|
71
|
+
`gu <path>...` undoes changes and keeps what it takes away.
|
|
72
|
+
|
|
73
|
+
- By default it discards the unstaged changes of the paths, after saving them as a patch in the git folder (`gu/<time>.patch`); `git apply` puts them back. Without a path it is a usage error, never "everything".
|
|
74
|
+
- `--staged` unstages the paths, the working tree untouched.
|
|
75
|
+
- `--commit` undoes the last commit, its changes left staged (the commit stays in the reflog). It refuses a commit the upstream already holds, a merge and the first commit.
|
|
76
|
+
- Exit codes: 0, 1 a path with no change or a commit refused, 2 a usage error or outside a repository.
|
|
77
|
+
|
|
45
78
|
## Library
|
|
46
79
|
|
|
47
80
|
`@kaynooo/cli-git/message` exports `commitMessageViolation(message)`, the rule a message breaks as the sentence to show or null, and the rule sentences, for the guard that checks a `git commit` typed by hand.
|
package/dist/gb.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/gb.ts
|
|
5
|
-
import
|
|
5
|
+
import process21 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
7
|
import process9 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
@@ -108,7 +108,7 @@ function Fe(r = {}) {
|
|
|
108
108
|
var o = Fe();
|
|
109
109
|
|
|
110
110
|
// ../kit/src/theme.ts
|
|
111
|
-
import { existsSync as
|
|
111
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
112
112
|
import { homedir as homedir2 } from "os";
|
|
113
113
|
import { join as join3, resolve as resolve2 } from "path";
|
|
114
114
|
import process5 from "process";
|
|
@@ -129,6 +129,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
// ../kit/src/user-config.ts
|
|
132
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
132
133
|
import { homedir } from "os";
|
|
133
134
|
import { join as join2 } from "path";
|
|
134
135
|
import process4 from "process";
|
|
@@ -139,6 +140,24 @@ function configBase(where = {}) {
|
|
|
139
140
|
function userConfigPath(bin, where = {}) {
|
|
140
141
|
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
141
142
|
}
|
|
143
|
+
function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
144
|
+
const current = userConfigPath(bin, where);
|
|
145
|
+
if (existsSync2(current))
|
|
146
|
+
return current;
|
|
147
|
+
const base = configBase(where);
|
|
148
|
+
return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
|
|
149
|
+
}
|
|
150
|
+
function readUserConfig(bin, where = {}, legacy = []) {
|
|
151
|
+
const path = userConfigReadPath(bin, legacy, where);
|
|
152
|
+
if (!existsSync2(path))
|
|
153
|
+
return {};
|
|
154
|
+
try {
|
|
155
|
+
const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
|
|
156
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
157
|
+
} catch {
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
142
161
|
|
|
143
162
|
// ../kit/src/theme.ts
|
|
144
163
|
function toLinear(channel) {
|
|
@@ -240,7 +259,7 @@ function readThemeFile(path, warn) {
|
|
|
240
259
|
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
241
260
|
return;
|
|
242
261
|
}
|
|
243
|
-
const parsed = JSON.parse(
|
|
262
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
244
263
|
if (isRecord(parsed))
|
|
245
264
|
return parsed;
|
|
246
265
|
warn(`${path} is not a JSON object, theme ignored`);
|
|
@@ -306,7 +325,7 @@ function applyFile(theme, file, where, warn) {
|
|
|
306
325
|
}
|
|
307
326
|
}
|
|
308
327
|
function endsWalk(home) {
|
|
309
|
-
return (dir) => dir === resolve2(home) ||
|
|
328
|
+
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
310
329
|
}
|
|
311
330
|
var warned = new Set;
|
|
312
331
|
function warnOnce(message) {
|
|
@@ -480,18 +499,14 @@ var FULL_STOP = /\.$/;
|
|
|
480
499
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
481
500
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
482
501
|
}
|
|
483
|
-
function helpText(usage, options, colors = paint(process8.stdout), { examples = [],
|
|
484
|
-
return [usageLine(usage, colors),
|
|
502
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
503
|
+
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
485
504
|
`);
|
|
486
505
|
}
|
|
487
506
|
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
488
507
|
if (exits.length === 0)
|
|
489
508
|
return [];
|
|
490
|
-
|
|
491
|
-
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
492
|
-
}
|
|
493
|
-
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
494
|
-
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
509
|
+
return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
|
|
495
510
|
}
|
|
496
511
|
function wantsHelpJson(env = process8.env) {
|
|
497
512
|
return env.KIT_HELP === "json";
|
|
@@ -788,12 +803,12 @@ function nearestOption(message, options, allowNegative) {
|
|
|
788
803
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
789
804
|
}
|
|
790
805
|
// ../kit/src/argv.ts
|
|
791
|
-
import { readFileSync as
|
|
806
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
792
807
|
import { resolve as resolve3 } from "path";
|
|
793
808
|
import process10 from "process";
|
|
794
809
|
function commandLine() {
|
|
795
810
|
try {
|
|
796
|
-
return
|
|
811
|
+
return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
|
|
797
812
|
} catch {
|
|
798
813
|
return;
|
|
799
814
|
}
|
|
@@ -1121,7 +1136,7 @@ function interceptOutput(clear) {
|
|
|
1121
1136
|
};
|
|
1122
1137
|
}
|
|
1123
1138
|
// ../kit/src/cli.ts
|
|
1124
|
-
import { readFileSync as
|
|
1139
|
+
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
1125
1140
|
import { dirname as dirname3, join as join5 } from "path";
|
|
1126
1141
|
import process14 from "process";
|
|
1127
1142
|
|
|
@@ -1269,9 +1284,13 @@ async function printCandidates(found) {
|
|
|
1269
1284
|
return 0;
|
|
1270
1285
|
}
|
|
1271
1286
|
function packageVersion(entry = Bun.main) {
|
|
1272
|
-
|
|
1287
|
+
let resolved = entry;
|
|
1288
|
+
try {
|
|
1289
|
+
resolved = realpathSync2(entry);
|
|
1290
|
+
} catch {}
|
|
1291
|
+
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1273
1292
|
try {
|
|
1274
|
-
const { version } = JSON.parse(
|
|
1293
|
+
const { version } = JSON.parse(readFileSync4(join5(dir, "package.json"), "utf8"));
|
|
1275
1294
|
if (typeof version === "string")
|
|
1276
1295
|
return version;
|
|
1277
1296
|
} catch {}
|
|
@@ -1359,9 +1378,26 @@ async function watching(value, step, stream = process15.stdout, sleep = Bun.slee
|
|
|
1359
1378
|
}
|
|
1360
1379
|
return code;
|
|
1361
1380
|
}
|
|
1381
|
+
// ../kit/src/workspace-root.ts
|
|
1382
|
+
import { homedir as homedir4 } from "os";
|
|
1383
|
+
import { dirname as dirname4, join as join6, resolve as resolve4 } from "path";
|
|
1384
|
+
import process16 from "process";
|
|
1385
|
+
function expandHome(path, home) {
|
|
1386
|
+
if (path === "~")
|
|
1387
|
+
return home;
|
|
1388
|
+
return path.startsWith("~/") ? join6(home, path.slice(2)) : path;
|
|
1389
|
+
}
|
|
1390
|
+
function configured(env, home) {
|
|
1391
|
+
const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
|
|
1392
|
+
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
1393
|
+
}
|
|
1394
|
+
function workspaceRoot({ given, env = process16.env, home = homedir4() } = {}) {
|
|
1395
|
+
const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
|
|
1396
|
+
return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
|
|
1397
|
+
}
|
|
1362
1398
|
// src/branch.ts
|
|
1363
1399
|
import { basename } from "path";
|
|
1364
|
-
import
|
|
1400
|
+
import process20 from "process";
|
|
1365
1401
|
|
|
1366
1402
|
// ../kit/src/picker/score.ts
|
|
1367
1403
|
var MATCH = 16;
|
|
@@ -1632,11 +1668,19 @@ function chosen(state) {
|
|
|
1632
1668
|
|
|
1633
1669
|
// ../kit/src/picker/terminal.ts
|
|
1634
1670
|
import { openSync } from "fs";
|
|
1635
|
-
import
|
|
1671
|
+
import process19 from "process";
|
|
1636
1672
|
import tty from "tty";
|
|
1637
1673
|
|
|
1674
|
+
// ../kit/src/redraw.ts
|
|
1675
|
+
var SYNC_START = "\x1B[?2026h";
|
|
1676
|
+
var SYNC_END = "\x1B[?2026l";
|
|
1677
|
+
function overwrite(lines, columns) {
|
|
1678
|
+
return lines.map((line) => textWidth(line) < columns ? `${line}\x1B[K` : `\x1B[2K${line}`).join(`
|
|
1679
|
+
`);
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1638
1682
|
// ../kit/src/picker/preview.ts
|
|
1639
|
-
import
|
|
1683
|
+
import process18 from "process";
|
|
1640
1684
|
|
|
1641
1685
|
// ../kit/src/shell.ts
|
|
1642
1686
|
var SEPARATORS = new Set([`
|
|
@@ -1705,7 +1749,7 @@ async function runPreview(template, line, signal, hidden = []) {
|
|
|
1705
1749
|
${previewCommand(template, line, hidden)}`], { stdin: "ignore", stdout: "pipe", stderr: "ignore", detached: true });
|
|
1706
1750
|
const stop = () => {
|
|
1707
1751
|
try {
|
|
1708
|
-
|
|
1752
|
+
process18.kill(-proc.pid, "SIGKILL");
|
|
1709
1753
|
} catch {
|
|
1710
1754
|
proc.kill();
|
|
1711
1755
|
}
|
|
@@ -1853,7 +1897,7 @@ function openTerminal() {
|
|
|
1853
1897
|
return fail("no terminal to read keys from (/dev/tty)");
|
|
1854
1898
|
}
|
|
1855
1899
|
const keys = Bun.file("/dev/tty").stream().getReader();
|
|
1856
|
-
const out =
|
|
1900
|
+
const out = process19.stderr;
|
|
1857
1901
|
let resize;
|
|
1858
1902
|
async function read(onChunk) {
|
|
1859
1903
|
const decoder = new TextDecoder;
|
|
@@ -1906,14 +1950,13 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
1906
1950
|
if (restored)
|
|
1907
1951
|
return;
|
|
1908
1952
|
const layout = layoutFor({ columns: terminal.columns, rows: terminal.rows }, settings.height, settings.preview !== undefined, settings.previewPosition);
|
|
1909
|
-
let frame = HIDE_CURSOR;
|
|
1953
|
+
let frame = SYNC_START + HIDE_CURSOR;
|
|
1910
1954
|
if (reserved !== layout.height || clear) {
|
|
1911
1955
|
frame += CLEAR_BELOW2 + `
|
|
1912
1956
|
`.repeat(layout.height - 1) + up(layout.height - 1);
|
|
1913
1957
|
reserved = layout.height;
|
|
1914
1958
|
}
|
|
1915
|
-
frame += `\r${render(state, layout, theme, preview).
|
|
1916
|
-
`)}${up(layout.height - 1)}\r\x1B[${caretColumn(state, layout)}G${CARET}\r`;
|
|
1959
|
+
frame += `\r${overwrite(render(state, layout, theme, preview), terminal.columns)}${up(layout.height - 1)}\r\x1B[${caretColumn(state, layout)}G${CARET}\r${SYNC_END}`;
|
|
1917
1960
|
terminal.write(frame);
|
|
1918
1961
|
}
|
|
1919
1962
|
function pageSize() {
|
|
@@ -2027,9 +2070,9 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
2027
2070
|
const ended = new Promise((resolve) => {
|
|
2028
2071
|
finish = resolve;
|
|
2029
2072
|
});
|
|
2030
|
-
|
|
2073
|
+
process19.once("exit", restore);
|
|
2031
2074
|
for (const signal of SIGNALS2)
|
|
2032
|
-
|
|
2075
|
+
process19.once(signal, stop);
|
|
2033
2076
|
try {
|
|
2034
2077
|
terminal.write(`${PASTE_ON}${MOUSE_ON}`);
|
|
2035
2078
|
terminal.listen(onChunk, () => draw(true));
|
|
@@ -2042,8 +2085,8 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
2042
2085
|
await ended;
|
|
2043
2086
|
} finally {
|
|
2044
2087
|
for (const signal of SIGNALS2)
|
|
2045
|
-
|
|
2046
|
-
|
|
2088
|
+
process19.off(signal, stop);
|
|
2089
|
+
process19.off("exit", restore);
|
|
2047
2090
|
restore();
|
|
2048
2091
|
}
|
|
2049
2092
|
return state.done === "accept" ? { rows: chosen(state), key: state.key, query: state.query } : undefined;
|
|
@@ -2314,7 +2357,7 @@ async function gb(args) {
|
|
|
2314
2357
|
if (parsed.values.json === true)
|
|
2315
2358
|
printJson(all);
|
|
2316
2359
|
else
|
|
2317
|
-
console.log(table2(all.map(row)).map((line) => takesControlCodes(
|
|
2360
|
+
console.log(table2(all.map(row)).map((line) => takesControlCodes(process20.stdout) ? line : Bun.stripANSI(line)).join(`
|
|
2318
2361
|
`));
|
|
2319
2362
|
return 0;
|
|
2320
2363
|
}
|
|
@@ -2371,4 +2414,4 @@ async function finish(command, typed, emitting) {
|
|
|
2371
2414
|
}
|
|
2372
2415
|
|
|
2373
2416
|
// src/gb.ts
|
|
2374
|
-
|
|
2417
|
+
process21.exitCode = await runMain({ name: "gb", run: gb });
|
package/dist/gc.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/gc.ts
|
|
5
|
-
import
|
|
5
|
+
import process18 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
7
|
import process9 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
@@ -108,7 +108,7 @@ function Fe(r = {}) {
|
|
|
108
108
|
var o = Fe();
|
|
109
109
|
|
|
110
110
|
// ../kit/src/theme.ts
|
|
111
|
-
import { existsSync as
|
|
111
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
112
112
|
import { homedir as homedir2 } from "os";
|
|
113
113
|
import { join as join3, resolve as resolve2 } from "path";
|
|
114
114
|
import process5 from "process";
|
|
@@ -129,6 +129,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
// ../kit/src/user-config.ts
|
|
132
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
132
133
|
import { homedir } from "os";
|
|
133
134
|
import { join as join2 } from "path";
|
|
134
135
|
import process4 from "process";
|
|
@@ -139,6 +140,24 @@ function configBase(where = {}) {
|
|
|
139
140
|
function userConfigPath(bin, where = {}) {
|
|
140
141
|
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
141
142
|
}
|
|
143
|
+
function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
144
|
+
const current = userConfigPath(bin, where);
|
|
145
|
+
if (existsSync2(current))
|
|
146
|
+
return current;
|
|
147
|
+
const base = configBase(where);
|
|
148
|
+
return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
|
|
149
|
+
}
|
|
150
|
+
function readUserConfig(bin, where = {}, legacy = []) {
|
|
151
|
+
const path = userConfigReadPath(bin, legacy, where);
|
|
152
|
+
if (!existsSync2(path))
|
|
153
|
+
return {};
|
|
154
|
+
try {
|
|
155
|
+
const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
|
|
156
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
157
|
+
} catch {
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
142
161
|
|
|
143
162
|
// ../kit/src/theme.ts
|
|
144
163
|
function toLinear(channel) {
|
|
@@ -240,7 +259,7 @@ function readThemeFile(path, warn) {
|
|
|
240
259
|
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
241
260
|
return;
|
|
242
261
|
}
|
|
243
|
-
const parsed = JSON.parse(
|
|
262
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
244
263
|
if (isRecord(parsed))
|
|
245
264
|
return parsed;
|
|
246
265
|
warn(`${path} is not a JSON object, theme ignored`);
|
|
@@ -306,7 +325,7 @@ function applyFile(theme, file, where, warn) {
|
|
|
306
325
|
}
|
|
307
326
|
}
|
|
308
327
|
function endsWalk(home) {
|
|
309
|
-
return (dir) => dir === resolve2(home) ||
|
|
328
|
+
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
310
329
|
}
|
|
311
330
|
var warned = new Set;
|
|
312
331
|
function warnOnce(message) {
|
|
@@ -480,18 +499,14 @@ var FULL_STOP = /\.$/;
|
|
|
480
499
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
481
500
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
482
501
|
}
|
|
483
|
-
function helpText(usage, options, colors = paint(process8.stdout), { examples = [],
|
|
484
|
-
return [usageLine(usage, colors),
|
|
502
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
503
|
+
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
485
504
|
`);
|
|
486
505
|
}
|
|
487
506
|
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
488
507
|
if (exits.length === 0)
|
|
489
508
|
return [];
|
|
490
|
-
|
|
491
|
-
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
492
|
-
}
|
|
493
|
-
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
494
|
-
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
509
|
+
return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
|
|
495
510
|
}
|
|
496
511
|
function wantsHelpJson(env = process8.env) {
|
|
497
512
|
return env.KIT_HELP === "json";
|
|
@@ -788,12 +803,12 @@ function nearestOption(message, options, allowNegative) {
|
|
|
788
803
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
789
804
|
}
|
|
790
805
|
// ../kit/src/argv.ts
|
|
791
|
-
import { readFileSync as
|
|
806
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
792
807
|
import { resolve as resolve3 } from "path";
|
|
793
808
|
import process10 from "process";
|
|
794
809
|
function commandLine() {
|
|
795
810
|
try {
|
|
796
|
-
return
|
|
811
|
+
return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
|
|
797
812
|
} catch {
|
|
798
813
|
return;
|
|
799
814
|
}
|
|
@@ -1121,7 +1136,7 @@ function interceptOutput(clear) {
|
|
|
1121
1136
|
};
|
|
1122
1137
|
}
|
|
1123
1138
|
// ../kit/src/cli.ts
|
|
1124
|
-
import { readFileSync as
|
|
1139
|
+
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
1125
1140
|
import { dirname as dirname3, join as join5 } from "path";
|
|
1126
1141
|
import process14 from "process";
|
|
1127
1142
|
|
|
@@ -1269,9 +1284,13 @@ async function printCandidates(found) {
|
|
|
1269
1284
|
return 0;
|
|
1270
1285
|
}
|
|
1271
1286
|
function packageVersion(entry = Bun.main) {
|
|
1272
|
-
|
|
1287
|
+
let resolved = entry;
|
|
1288
|
+
try {
|
|
1289
|
+
resolved = realpathSync2(entry);
|
|
1290
|
+
} catch {}
|
|
1291
|
+
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1273
1292
|
try {
|
|
1274
|
-
const { version } = JSON.parse(
|
|
1293
|
+
const { version } = JSON.parse(readFileSync4(join5(dir, "package.json"), "utf8"));
|
|
1275
1294
|
if (typeof version === "string")
|
|
1276
1295
|
return version;
|
|
1277
1296
|
} catch {}
|
|
@@ -1359,6 +1378,23 @@ async function watching(value, step, stream = process15.stdout, sleep = Bun.slee
|
|
|
1359
1378
|
}
|
|
1360
1379
|
return code;
|
|
1361
1380
|
}
|
|
1381
|
+
// ../kit/src/workspace-root.ts
|
|
1382
|
+
import { homedir as homedir4 } from "os";
|
|
1383
|
+
import { dirname as dirname4, join as join6, resolve as resolve4 } from "path";
|
|
1384
|
+
import process16 from "process";
|
|
1385
|
+
function expandHome(path, home) {
|
|
1386
|
+
if (path === "~")
|
|
1387
|
+
return home;
|
|
1388
|
+
return path.startsWith("~/") ? join6(home, path.slice(2)) : path;
|
|
1389
|
+
}
|
|
1390
|
+
function configured(env, home) {
|
|
1391
|
+
const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
|
|
1392
|
+
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
1393
|
+
}
|
|
1394
|
+
function workspaceRoot({ given, env = process16.env, home = homedir4() } = {}) {
|
|
1395
|
+
const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
|
|
1396
|
+
return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
|
|
1397
|
+
}
|
|
1362
1398
|
// src/git.ts
|
|
1363
1399
|
async function git2(args, env) {
|
|
1364
1400
|
const ran = await runCommand(["git", "--no-optional-locks", "-c", "core.quotePath=false", ...args], env === undefined ? {} : { env });
|
|
@@ -1431,7 +1467,7 @@ var OPTIONS = {
|
|
|
1431
1467
|
};
|
|
1432
1468
|
var RENAME = /^[RC]\d*$/;
|
|
1433
1469
|
var NOT_A_REPOSITORY = /not a git repository/i;
|
|
1434
|
-
var LITERAL = { ...
|
|
1470
|
+
var LITERAL = { ...process18.env, GIT_LITERAL_PATHSPECS: "1" };
|
|
1435
1471
|
function messageOf(title, lines, tickets) {
|
|
1436
1472
|
return [title, lines.join(`
|
|
1437
1473
|
`), tickets.join(`
|
|
@@ -1529,4 +1565,4 @@ ${(commit.stderr + commit.stdout).trim()}`;
|
|
|
1529
1565
|
signals.release();
|
|
1530
1566
|
}
|
|
1531
1567
|
}
|
|
1532
|
-
|
|
1568
|
+
process18.exitCode = await runMain({ name: "gc", run: main });
|