@kaynooo/cli-git 0.14.0 → 0.15.1
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 +302 -43
- package/dist/gc.js +290 -31
- package/dist/gcl.js +1662 -0
- package/dist/gd.js +1642 -0
- package/dist/gf.js +1624 -0
- package/dist/gp.js +320 -52
- package/dist/gst.js +322 -49
- package/dist/gu.js +1484 -0
- package/package.json +14 -6
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,9 +140,59 @@ 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
|
|
163
|
+
function toLinear(channel) {
|
|
164
|
+
const value = channel / 255;
|
|
165
|
+
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
166
|
+
}
|
|
167
|
+
var fromLinear = (value) => Math.round(255 * Math.min(1, Math.max(0, value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055)));
|
|
168
|
+
function toOklab(hex) {
|
|
169
|
+
const [r, g, b] = [1, 3, 5].map((at) => toLinear(Number.parseInt(hex.slice(at, at + 2), 16)));
|
|
170
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
171
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
172
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
173
|
+
return [0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s];
|
|
174
|
+
}
|
|
175
|
+
function fromOklab([lightness, a, b]) {
|
|
176
|
+
const l = (lightness + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
177
|
+
const m = (lightness - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
178
|
+
const s = (lightness - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
179
|
+
const channels = [4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s];
|
|
180
|
+
return `#${channels.map((channel) => fromLinear(channel).toString(16).padStart(2, "0")).join("")}`;
|
|
181
|
+
}
|
|
144
182
|
var ENDS = new Map;
|
|
183
|
+
function gradientAt(theme, ratio) {
|
|
184
|
+
if (theme.gradient === undefined)
|
|
185
|
+
return;
|
|
186
|
+
const key = theme.gradient.join();
|
|
187
|
+
let ends = ENDS.get(key);
|
|
188
|
+
if (ends === undefined) {
|
|
189
|
+
ends = [toOklab(theme.gradient[0]), toOklab(theme.gradient[1])];
|
|
190
|
+
ENDS.set(key, ends);
|
|
191
|
+
}
|
|
192
|
+
const at = Math.min(1, Math.max(0, ratio));
|
|
193
|
+
const [from, to] = ends;
|
|
194
|
+
return fromOklab(from.map((start, index) => start + (to[index] - start) * at));
|
|
195
|
+
}
|
|
145
196
|
var DEFAULT = {
|
|
146
197
|
colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", plan: "magenta", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
|
|
147
198
|
glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", plan: "\u25C7", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D", open: "\u2022", leaf: "\xB7", guide: "\u2502" },
|
|
@@ -193,6 +244,9 @@ function tinted(colors, spec, env = process5.env) {
|
|
|
193
244
|
return chain[token] ?? chain;
|
|
194
245
|
}, colors);
|
|
195
246
|
}
|
|
247
|
+
function shaded(theme, colors, glyph, cells, width, env = process5.env) {
|
|
248
|
+
return Array.from({ length: cells }, (_, index) => tinted(colors, gradientAt(theme, width <= 1 ? 0 : index / (width - 1)) ?? theme.colors.accent, env)(glyph)).join("");
|
|
249
|
+
}
|
|
196
250
|
function isRecord(value) {
|
|
197
251
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
198
252
|
}
|
|
@@ -205,7 +259,7 @@ function readThemeFile(path, warn) {
|
|
|
205
259
|
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
206
260
|
return;
|
|
207
261
|
}
|
|
208
|
-
const parsed = JSON.parse(
|
|
262
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
209
263
|
if (isRecord(parsed))
|
|
210
264
|
return parsed;
|
|
211
265
|
warn(`${path} is not a JSON object, theme ignored`);
|
|
@@ -271,7 +325,7 @@ function applyFile(theme, file, where, warn) {
|
|
|
271
325
|
}
|
|
272
326
|
}
|
|
273
327
|
function endsWalk(home) {
|
|
274
|
-
return (dir) => dir === resolve2(home) ||
|
|
328
|
+
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
275
329
|
}
|
|
276
330
|
var warned = new Set;
|
|
277
331
|
function warnOnce(message) {
|
|
@@ -366,6 +420,12 @@ function formatSeconds(total) {
|
|
|
366
420
|
const next = amounts[first + 1];
|
|
367
421
|
return next === undefined || next.startsWith("0") ? amounts[first] ?? "0s" : `${amounts[first]} ${next}`;
|
|
368
422
|
}
|
|
423
|
+
function formatDuration(ms) {
|
|
424
|
+
return ms < 60000 ? `${(Math.max(0, ms) / 1000).toFixed(1)}s` : formatSeconds(ms / 1000);
|
|
425
|
+
}
|
|
426
|
+
function formatElapsed(ms) {
|
|
427
|
+
return formatSeconds(Math.floor(Math.max(0, ms) / 1000));
|
|
428
|
+
}
|
|
369
429
|
function upTo(text, separator) {
|
|
370
430
|
const end = text.indexOf(separator);
|
|
371
431
|
return end === -1 ? text : text.slice(0, end);
|
|
@@ -439,18 +499,14 @@ var FULL_STOP = /\.$/;
|
|
|
439
499
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
440
500
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
441
501
|
}
|
|
442
|
-
function helpText(usage, options, colors = paint(process8.stdout), { examples = [],
|
|
443
|
-
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(`
|
|
444
504
|
`);
|
|
445
505
|
}
|
|
446
506
|
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
447
507
|
if (exits.length === 0)
|
|
448
508
|
return [];
|
|
449
|
-
|
|
450
|
-
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
451
|
-
}
|
|
452
|
-
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
453
|
-
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(", ")}`];
|
|
454
510
|
}
|
|
455
511
|
function wantsHelpJson(env = process8.env) {
|
|
456
512
|
return env.KIT_HELP === "json";
|
|
@@ -747,12 +803,12 @@ function nearestOption(message, options, allowNegative) {
|
|
|
747
803
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
748
804
|
}
|
|
749
805
|
// ../kit/src/argv.ts
|
|
750
|
-
import { readFileSync as
|
|
806
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
751
807
|
import { resolve as resolve3 } from "path";
|
|
752
808
|
import process10 from "process";
|
|
753
809
|
function commandLine() {
|
|
754
810
|
try {
|
|
755
|
-
return
|
|
811
|
+
return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
|
|
756
812
|
} catch {
|
|
757
813
|
return;
|
|
758
814
|
}
|
|
@@ -770,6 +826,9 @@ function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), scr
|
|
|
770
826
|
const after = at === -1 ? [] : cmdline.slice(at + 1);
|
|
771
827
|
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
772
828
|
}
|
|
829
|
+
// ../kit/src/progress.ts
|
|
830
|
+
import process12 from "process";
|
|
831
|
+
|
|
773
832
|
// ../kit/src/process.ts
|
|
774
833
|
import { constants } from "os";
|
|
775
834
|
import process11 from "process";
|
|
@@ -893,20 +952,199 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
893
952
|
}
|
|
894
953
|
|
|
895
954
|
// ../kit/src/progress.ts
|
|
955
|
+
var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
956
|
+
var FRAME_MS = 200;
|
|
957
|
+
var BAR_WIDTH = 20;
|
|
958
|
+
var CLEAR_BELOW = "\r\x1B[J";
|
|
896
959
|
var ESC = String.fromCharCode(27);
|
|
897
960
|
var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
|
|
898
961
|
var RESET_STYLE = `${ESC}[0m`;
|
|
962
|
+
var CTRL_C = 3;
|
|
899
963
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
964
|
+
var CONSOLE_METHODS = ["log", "info", "warn", "error", "debug", "dir", "dirxml", "table", "trace", "group", "groupCollapsed", "count", "timeEnd", "timeLog", "assert"];
|
|
965
|
+
function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
966
|
+
if (!takesControlCodes(stream, env))
|
|
967
|
+
return { redraw: () => {
|
|
968
|
+
return;
|
|
969
|
+
}, print: (text) => void stream.write(`${text}
|
|
970
|
+
`), stop: () => {
|
|
971
|
+
return;
|
|
972
|
+
} };
|
|
973
|
+
const write = stream.write.bind(stream);
|
|
974
|
+
let frame = 0;
|
|
975
|
+
let drawn = false;
|
|
976
|
+
const columns = () => {
|
|
977
|
+
const now = stream.getWindowSize?.()[0] ?? stream.columns;
|
|
978
|
+
return now === undefined || now === 0 ? 80 : now;
|
|
979
|
+
};
|
|
980
|
+
const clear = () => {
|
|
981
|
+
if (drawn)
|
|
982
|
+
write(CLEAR_BELOW);
|
|
983
|
+
drawn = false;
|
|
984
|
+
};
|
|
985
|
+
const draw = () => {
|
|
986
|
+
const width = columns() - 1;
|
|
987
|
+
const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
|
|
988
|
+
const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
|
|
989
|
+
if (lines.length === 0) {
|
|
990
|
+
clear();
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
write(`${CLEAR_BELOW}${lines.join(`
|
|
994
|
+
`)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
|
|
995
|
+
drawn = true;
|
|
996
|
+
};
|
|
997
|
+
const timer = setInterval(draw, FRAME_MS);
|
|
998
|
+
stream.on?.("resize", draw);
|
|
999
|
+
const restore = interceptOutput(clear);
|
|
1000
|
+
const release = swallowInput();
|
|
1001
|
+
const onExit = () => {
|
|
1002
|
+
clear();
|
|
1003
|
+
release();
|
|
1004
|
+
};
|
|
1005
|
+
const signals = holdSignals(stop);
|
|
1006
|
+
function stop() {
|
|
1007
|
+
clearInterval(timer);
|
|
1008
|
+
stream.off?.("resize", draw);
|
|
1009
|
+
clear();
|
|
1010
|
+
restore();
|
|
1011
|
+
release();
|
|
1012
|
+
process12.off("exit", onExit);
|
|
1013
|
+
signals.release();
|
|
1014
|
+
}
|
|
1015
|
+
timer.unref();
|
|
1016
|
+
process12.on("exit", onExit);
|
|
1017
|
+
return {
|
|
1018
|
+
redraw: draw,
|
|
1019
|
+
print: (text) => {
|
|
1020
|
+
clear();
|
|
1021
|
+
write(`${text}
|
|
1022
|
+
`);
|
|
1023
|
+
draw();
|
|
1024
|
+
},
|
|
1025
|
+
stop
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
function progressLine(stream = process12.stderr, env = process12.env) {
|
|
1029
|
+
const colors = paint(stream, env);
|
|
1030
|
+
const write = stream.write.bind(stream);
|
|
1031
|
+
const begun = performance.now();
|
|
1032
|
+
let started = begun;
|
|
1033
|
+
let current;
|
|
1034
|
+
const region = liveRegion((spinner) => current === undefined ? [] : [tintedParts(progressParts(current, spinner, performance.now() - started), colors)], stream, env);
|
|
1035
|
+
const end = (line) => {
|
|
1036
|
+
region.stop();
|
|
1037
|
+
write(`${line}
|
|
1038
|
+
`);
|
|
1039
|
+
};
|
|
1040
|
+
return {
|
|
1041
|
+
update: (progress) => {
|
|
1042
|
+
const step = current?.step;
|
|
1043
|
+
current = progress;
|
|
1044
|
+
if (progress.step !== step) {
|
|
1045
|
+
started = performance.now();
|
|
1046
|
+
region.redraw();
|
|
1047
|
+
}
|
|
1048
|
+
},
|
|
1049
|
+
stop: region.stop,
|
|
1050
|
+
done: (text) => end(marked("ok", text, stream, formatDuration(performance.now() - begun), env)),
|
|
1051
|
+
failed: (text) => end(marked("problem", text, stream, undefined, env))
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
function progressParts({ step, done, total, unit }, spinner, ms) {
|
|
1055
|
+
const { theme } = activeTheme();
|
|
1056
|
+
const parts = [{ text: spinner, tint: (colors) => tinted(colors, theme.colors.accent) }, { text: ` ${step}`, tint: () => plain }];
|
|
1057
|
+
if (total !== undefined && total > 0) {
|
|
1058
|
+
const counted = Math.min(done ?? 0, total);
|
|
1059
|
+
const filled = Math.round(counted / total * BAR_WIDTH);
|
|
1060
|
+
parts.push({ text: " ", tint: () => plain }, { text: theme.glyphs.bar.repeat(filled), tint: (colors) => () => shaded(theme, colors, theme.glyphs.bar, filled, BAR_WIDTH) }, { text: theme.glyphs.bar.repeat(BAR_WIDTH - filled), tint: (colors) => colors.dim }, { text: ` ${counted}/${total}${unit === undefined ? "" : ` ${unit}`}`, tint: (colors) => colors.dim });
|
|
1061
|
+
}
|
|
1062
|
+
parts.push({ text: ` ${formatElapsed(ms)}`, tint: (colors) => colors.dim });
|
|
1063
|
+
return parts;
|
|
1064
|
+
}
|
|
1065
|
+
function plain(text) {
|
|
1066
|
+
return text;
|
|
1067
|
+
}
|
|
1068
|
+
function tintedParts(parts, colors) {
|
|
1069
|
+
return parts.map(({ text, tint }) => tint(colors)(text)).join("");
|
|
1070
|
+
}
|
|
1071
|
+
function cutToWidth(line, width) {
|
|
1072
|
+
if (Bun.stringWidth(line) <= width)
|
|
1073
|
+
return line;
|
|
1074
|
+
let room = width;
|
|
1075
|
+
let kept = "";
|
|
1076
|
+
let index = 0;
|
|
1077
|
+
let linked = false;
|
|
1078
|
+
while (index < line.length) {
|
|
1079
|
+
ESCAPE_CODE.lastIndex = index;
|
|
1080
|
+
const escape = ESCAPE_CODE.exec(line);
|
|
1081
|
+
if (escape !== null) {
|
|
1082
|
+
kept += escape[0];
|
|
1083
|
+
linked ||= escape[0].startsWith(`${ESC}]`);
|
|
1084
|
+
index = ESCAPE_CODE.lastIndex;
|
|
1085
|
+
continue;
|
|
1086
|
+
}
|
|
1087
|
+
const char = String.fromCodePoint(line.codePointAt(index));
|
|
1088
|
+
const columns = Bun.stringWidth(char);
|
|
1089
|
+
if (columns > room)
|
|
1090
|
+
break;
|
|
1091
|
+
kept += char;
|
|
1092
|
+
room -= columns;
|
|
1093
|
+
index += char.length;
|
|
1094
|
+
}
|
|
1095
|
+
return `${kept}${RESET_STYLE}${linked ? CLOSE_LINK : ""}`;
|
|
1096
|
+
}
|
|
1097
|
+
function swallowInput() {
|
|
1098
|
+
const input = process12.stdin;
|
|
1099
|
+
if (!input.isTTY)
|
|
1100
|
+
return () => {
|
|
1101
|
+
return;
|
|
1102
|
+
};
|
|
1103
|
+
const onData = (data) => {
|
|
1104
|
+
if (data.includes(CTRL_C))
|
|
1105
|
+
process12.kill(process12.pid, "SIGINT");
|
|
1106
|
+
};
|
|
1107
|
+
input.setRawMode(true);
|
|
1108
|
+
input.on("data", onData);
|
|
1109
|
+
input.resume();
|
|
1110
|
+
let released = false;
|
|
1111
|
+
return () => {
|
|
1112
|
+
if (released)
|
|
1113
|
+
return;
|
|
1114
|
+
released = true;
|
|
1115
|
+
input.off("data", onData);
|
|
1116
|
+
input.pause();
|
|
1117
|
+
input.setRawMode(false);
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
function interceptOutput(clear) {
|
|
1121
|
+
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process12.stdout, "write"], [process12.stderr, "write"]];
|
|
1122
|
+
const wrapped = targets.map(([target, name]) => {
|
|
1123
|
+
const original = Reflect.get(target, name);
|
|
1124
|
+
const wrapper = (...args) => {
|
|
1125
|
+
clear();
|
|
1126
|
+
return original.apply(target, args);
|
|
1127
|
+
};
|
|
1128
|
+
Reflect.set(target, name, wrapper);
|
|
1129
|
+
return { target, name, original, wrapper };
|
|
1130
|
+
});
|
|
1131
|
+
return () => {
|
|
1132
|
+
for (const { target, name, original, wrapper } of wrapped) {
|
|
1133
|
+
if (Reflect.get(target, name) === wrapper)
|
|
1134
|
+
Reflect.set(target, name, original);
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
900
1138
|
// ../kit/src/cli.ts
|
|
901
|
-
import { readFileSync as
|
|
1139
|
+
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
902
1140
|
import { dirname as dirname3, join as join5 } from "path";
|
|
903
|
-
import
|
|
1141
|
+
import process14 from "process";
|
|
904
1142
|
|
|
905
1143
|
// ../kit/src/usage.ts
|
|
906
1144
|
import { appendFileSync, mkdirSync } from "fs";
|
|
907
1145
|
import { homedir as homedir3 } from "os";
|
|
908
1146
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
909
|
-
import
|
|
1147
|
+
import process13 from "process";
|
|
910
1148
|
|
|
911
1149
|
// ../kit/src/logs.ts
|
|
912
1150
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -920,14 +1158,14 @@ var usageError;
|
|
|
920
1158
|
function noteUsageError(message) {
|
|
921
1159
|
usageError = message;
|
|
922
1160
|
}
|
|
923
|
-
function stateHome(env =
|
|
1161
|
+
function stateHome(env = process13.env) {
|
|
924
1162
|
const dir = env.XDG_STATE_HOME;
|
|
925
1163
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
926
1164
|
}
|
|
927
|
-
function usagePath(env =
|
|
1165
|
+
function usagePath(env = process13.env) {
|
|
928
1166
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
929
1167
|
}
|
|
930
|
-
function usageRecorded(env =
|
|
1168
|
+
function usageRecorded(env = process13.env) {
|
|
931
1169
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
932
1170
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
933
1171
|
}
|
|
@@ -941,7 +1179,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
941
1179
|
usageError = undefined;
|
|
942
1180
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
943
1181
|
}
|
|
944
|
-
function recordUsage(entry, env =
|
|
1182
|
+
function recordUsage(entry, env = process13.env) {
|
|
945
1183
|
if (!usageRecorded(env))
|
|
946
1184
|
return;
|
|
947
1185
|
try {
|
|
@@ -959,8 +1197,8 @@ var LEVEL_OPTIONS = {
|
|
|
959
1197
|
};
|
|
960
1198
|
var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
|
|
961
1199
|
function printError(prefix, message, hint, cause) {
|
|
962
|
-
const colors = paint(
|
|
963
|
-
const styled = takesControlCodes(
|
|
1200
|
+
const colors = paint(process14.stderr);
|
|
1201
|
+
const styled = takesControlCodes(process14.stderr);
|
|
964
1202
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
965
1203
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
966
1204
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1046,9 +1284,13 @@ async function printCandidates(found) {
|
|
|
1046
1284
|
return 0;
|
|
1047
1285
|
}
|
|
1048
1286
|
function packageVersion(entry = Bun.main) {
|
|
1049
|
-
|
|
1287
|
+
let resolved = entry;
|
|
1288
|
+
try {
|
|
1289
|
+
resolved = realpathSync2(entry);
|
|
1290
|
+
} catch {}
|
|
1291
|
+
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1050
1292
|
try {
|
|
1051
|
-
const { version } = JSON.parse(
|
|
1293
|
+
const { version } = JSON.parse(readFileSync4(join5(dir, "package.json"), "utf8"));
|
|
1052
1294
|
if (typeof version === "string")
|
|
1053
1295
|
return version;
|
|
1054
1296
|
} catch {}
|
|
@@ -1085,7 +1327,7 @@ var {Glob } = globalThis.Bun;
|
|
|
1085
1327
|
var SESSION_FILES = new Glob("*.json");
|
|
1086
1328
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1087
1329
|
// ../kit/src/watch.ts
|
|
1088
|
-
import
|
|
1330
|
+
import process15 from "process";
|
|
1089
1331
|
import { format } from "util";
|
|
1090
1332
|
var CLEAR_SCREEN = "\x1B[H\x1B[2J";
|
|
1091
1333
|
var DEFAULT_SECONDS = 2;
|
|
@@ -1107,7 +1349,7 @@ function withoutWatch(args) {
|
|
|
1107
1349
|
}
|
|
1108
1350
|
return rest;
|
|
1109
1351
|
}
|
|
1110
|
-
async function watching(value, step, stream =
|
|
1352
|
+
async function watching(value, step, stream = process15.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
|
|
1111
1353
|
const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
|
|
1112
1354
|
if (!takesControlCodes(stream))
|
|
1113
1355
|
badUsage("--watch redraws the screen, so it needs a terminal");
|
|
@@ -1115,12 +1357,12 @@ async function watching(value, step, stream = process14.stdout, sleep = Bun.slee
|
|
|
1115
1357
|
for (let round = 0;round < rounds; round++) {
|
|
1116
1358
|
const held = [];
|
|
1117
1359
|
const { log, info } = console;
|
|
1118
|
-
const write =
|
|
1360
|
+
const write = process15.stdout.write.bind(process15.stdout);
|
|
1119
1361
|
const hold = (...parts) => void held.push(`${format(...parts)}
|
|
1120
1362
|
`);
|
|
1121
1363
|
console.log = hold;
|
|
1122
1364
|
console.info = hold;
|
|
1123
|
-
|
|
1365
|
+
process15.stdout.write = (text) => {
|
|
1124
1366
|
held.push(typeof text === "string" ? text : Buffer.from(text).toString());
|
|
1125
1367
|
return true;
|
|
1126
1368
|
};
|
|
@@ -1129,13 +1371,30 @@ async function watching(value, step, stream = process14.stdout, sleep = Bun.slee
|
|
|
1129
1371
|
} finally {
|
|
1130
1372
|
console.log = log;
|
|
1131
1373
|
console.info = info;
|
|
1132
|
-
|
|
1374
|
+
process15.stdout.write = write;
|
|
1133
1375
|
}
|
|
1134
1376
|
stream.write(`${CLEAR_SCREEN}${held.join("")}`);
|
|
1135
1377
|
await sleep(interval);
|
|
1136
1378
|
}
|
|
1137
1379
|
return code;
|
|
1138
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
|
+
}
|
|
1139
1398
|
// src/git.ts
|
|
1140
1399
|
async function git2(args, env) {
|
|
1141
1400
|
const ran = await runCommand(["git", "--no-optional-locks", "-c", "core.quotePath=false", ...args], env === undefined ? {} : { env });
|
|
@@ -1208,7 +1467,7 @@ var OPTIONS = {
|
|
|
1208
1467
|
};
|
|
1209
1468
|
var RENAME = /^[RC]\d*$/;
|
|
1210
1469
|
var NOT_A_REPOSITORY = /not a git repository/i;
|
|
1211
|
-
var LITERAL = { ...
|
|
1470
|
+
var LITERAL = { ...process18.env, GIT_LITERAL_PATHSPECS: "1" };
|
|
1212
1471
|
function messageOf(title, lines, tickets) {
|
|
1213
1472
|
return [title, lines.join(`
|
|
1214
1473
|
`), tickets.join(`
|
|
@@ -1306,4 +1565,4 @@ ${(commit.stderr + commit.stdout).trim()}`;
|
|
|
1306
1565
|
signals.release();
|
|
1307
1566
|
}
|
|
1308
1567
|
}
|
|
1309
|
-
|
|
1568
|
+
process18.exitCode = await runMain({ name: "gc", run: main });
|