@kaynooo/cli-git 0.7.1 → 0.9.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/README.md +2 -2
- package/dist/gb.js +934 -119
- package/dist/gc.js +287 -52
- package/dist/gst.js +300 -57
- package/package.json +3 -3
package/dist/gc.js
CHANGED
|
@@ -2,13 +2,37 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/gc.ts
|
|
5
|
-
import
|
|
5
|
+
import process14 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
|
-
import
|
|
7
|
+
import process9 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
9
9
|
|
|
10
|
-
// ../kit/src/
|
|
10
|
+
// ../kit/src/format.ts
|
|
11
|
+
import process7 from "process";
|
|
12
|
+
|
|
13
|
+
// ../kit/src/mode.ts
|
|
11
14
|
import process2 from "process";
|
|
15
|
+
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
16
|
+
var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
17
|
+
function isSet(value) {
|
|
18
|
+
return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
19
|
+
}
|
|
20
|
+
function outputMode(stream = process2.stdout, env = process2.env) {
|
|
21
|
+
const chosen = env.KIT_MODE;
|
|
22
|
+
if (chosen !== undefined && MODES.has(chosen))
|
|
23
|
+
return chosen;
|
|
24
|
+
if (AGENT_VARIABLES.some((name) => isSet(env[name])))
|
|
25
|
+
return "agent";
|
|
26
|
+
if (stream.isTTY === true)
|
|
27
|
+
return "terminal";
|
|
28
|
+
return isSet(env.CI) ? "ci" : "pipe";
|
|
29
|
+
}
|
|
30
|
+
function isInteractive(streams = process2) {
|
|
31
|
+
return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ../kit/src/style.ts
|
|
35
|
+
import process6 from "process";
|
|
12
36
|
|
|
13
37
|
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
|
|
14
38
|
function x(s) {
|
|
@@ -271,21 +295,229 @@ function le(i = {}) {
|
|
|
271
295
|
}
|
|
272
296
|
var t = le();
|
|
273
297
|
|
|
298
|
+
// ../kit/src/theme.ts
|
|
299
|
+
import { existsSync as existsSync2, readFileSync, statSync } from "fs";
|
|
300
|
+
import { homedir as homedir2 } from "os";
|
|
301
|
+
import { join as join3, resolve as resolve2 } from "path";
|
|
302
|
+
import process5 from "process";
|
|
303
|
+
|
|
304
|
+
// ../kit/src/config.ts
|
|
305
|
+
import { existsSync } from "fs";
|
|
306
|
+
import { dirname, join, resolve } from "path";
|
|
307
|
+
import process3 from "process";
|
|
308
|
+
function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
309
|
+
const wanted = typeof names === "string" ? [names] : names;
|
|
310
|
+
for (let dir = resolve(from);; dir = dirname(dir)) {
|
|
311
|
+
const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
|
|
312
|
+
if (found !== undefined)
|
|
313
|
+
return found;
|
|
314
|
+
if (stop(dir) || dirname(dir) === dir)
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// ../kit/src/user-config.ts
|
|
320
|
+
import { homedir } from "os";
|
|
321
|
+
import { join as join2 } from "path";
|
|
322
|
+
import process4 from "process";
|
|
323
|
+
function configBase(where = {}) {
|
|
324
|
+
const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
|
|
325
|
+
return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
|
|
326
|
+
}
|
|
327
|
+
function userConfigPath(bin, where = {}) {
|
|
328
|
+
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// ../kit/src/theme.ts
|
|
332
|
+
var DEFAULT = {
|
|
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" },
|
|
335
|
+
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
336
|
+
bins: {}
|
|
337
|
+
};
|
|
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
|
+
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: "#" };
|
|
341
|
+
var PRESETS = {
|
|
342
|
+
default: {},
|
|
343
|
+
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
|
|
344
|
+
mono: { colors: MONO, accents: ["bold"] },
|
|
345
|
+
ascii: { glyphs: ASCII }
|
|
346
|
+
};
|
|
347
|
+
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"]);
|
|
348
|
+
var HEX = /^#[0-9a-f]{6}$/i;
|
|
349
|
+
var CONTROL = /\p{Cc}/u;
|
|
350
|
+
var MAX_FILE_BYTES = 64 * 1024;
|
|
351
|
+
var SPACES = /\s+/;
|
|
352
|
+
function isColorSpec(spec) {
|
|
353
|
+
if (typeof spec === "number")
|
|
354
|
+
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
355
|
+
return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
|
|
356
|
+
}
|
|
357
|
+
var CUBE = [0, 95, 135, 175, 215, 255];
|
|
358
|
+
function cubeLevel(channel) {
|
|
359
|
+
return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
|
|
360
|
+
}
|
|
361
|
+
function nearest256(hex) {
|
|
362
|
+
const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
|
|
363
|
+
const levels = rgb.map(cubeLevel);
|
|
364
|
+
const cube = levels.map((level) => CUBE[level]);
|
|
365
|
+
const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
|
|
366
|
+
const greyValue = 8 + grey * 10;
|
|
367
|
+
const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
|
|
368
|
+
return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
|
|
369
|
+
}
|
|
370
|
+
function hasTrueColor(env) {
|
|
371
|
+
return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
|
|
372
|
+
}
|
|
373
|
+
function tinted(colors, spec, env = process5.env) {
|
|
374
|
+
if (typeof spec === "number")
|
|
375
|
+
return colors.ansi256(spec);
|
|
376
|
+
return spec.trim().split(SPACES).reduce((chain, token) => {
|
|
377
|
+
if (HEX.test(token))
|
|
378
|
+
return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
|
|
379
|
+
return chain[token] ?? chain;
|
|
380
|
+
}, colors);
|
|
381
|
+
}
|
|
382
|
+
function isRecord(value) {
|
|
383
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
384
|
+
}
|
|
385
|
+
function readThemeFile(path, warn) {
|
|
386
|
+
try {
|
|
387
|
+
const stat = statSync(path, { throwIfNoEntry: false });
|
|
388
|
+
if (stat === undefined)
|
|
389
|
+
return;
|
|
390
|
+
if (!stat.isFile() || stat.size > MAX_FILE_BYTES) {
|
|
391
|
+
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
395
|
+
if (isRecord(parsed))
|
|
396
|
+
return parsed;
|
|
397
|
+
warn(`${path} is not a JSON object, theme ignored`);
|
|
398
|
+
} catch (error) {
|
|
399
|
+
warn(`${path} does not parse (${error instanceof Error ? error.message : String(error)}), theme ignored`);
|
|
400
|
+
}
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
function applyPreset(theme, name, warn, where) {
|
|
404
|
+
if (name === undefined)
|
|
405
|
+
return;
|
|
406
|
+
if (typeof name !== "string" || !Object.hasOwn(PRESETS, name)) {
|
|
407
|
+
warn(`${where}: no preset ${String(name)}, one of ${Object.keys(PRESETS).join(", ")}`);
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
const preset = PRESETS[name];
|
|
411
|
+
Object.assign(theme.colors, preset.colors);
|
|
412
|
+
Object.assign(theme.glyphs, preset.glyphs);
|
|
413
|
+
if (preset.accents !== undefined)
|
|
414
|
+
theme.accents = [...preset.accents];
|
|
415
|
+
return name;
|
|
416
|
+
}
|
|
417
|
+
function applyFile(theme, file, where, warn) {
|
|
418
|
+
if (isRecord(file.colors)) {
|
|
419
|
+
for (const [key, value] of Object.entries(file.colors)) {
|
|
420
|
+
if (!Object.hasOwn(DEFAULT.colors, key))
|
|
421
|
+
warn(`${where}: no colour ${key}, one of ${Object.keys(DEFAULT.colors).join(", ")}`);
|
|
422
|
+
else if (!isColorSpec(value))
|
|
423
|
+
warn(`${where}: colour ${key} is not an ANSI name, \`#rrggbb\` or a number up to 255`);
|
|
424
|
+
else
|
|
425
|
+
theme.colors[key] = value;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (isRecord(file.glyphs)) {
|
|
429
|
+
for (const [key, value] of Object.entries(file.glyphs)) {
|
|
430
|
+
if (!Object.hasOwn(DEFAULT.glyphs, key))
|
|
431
|
+
warn(`${where}: no glyph ${key}, one of ${Object.keys(DEFAULT.glyphs).join(", ")}`);
|
|
432
|
+
else if (typeof value !== "string" || CONTROL.test(value) || Bun.stringWidth(value) !== 1)
|
|
433
|
+
warn(`${where}: glyph ${key} must be one visible character wide, with no control character`);
|
|
434
|
+
else
|
|
435
|
+
theme.glyphs[key] = value;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (Array.isArray(file.accents) && file.accents.length > 0 && file.accents.every(isColorSpec))
|
|
439
|
+
theme.accents = [...file.accents];
|
|
440
|
+
else if (file.accents !== undefined)
|
|
441
|
+
warn(`${where}: accents must be a non-empty list of colours`);
|
|
442
|
+
if (isRecord(file.bins)) {
|
|
443
|
+
for (const [bin, value] of Object.entries(file.bins)) {
|
|
444
|
+
if (isColorSpec(value))
|
|
445
|
+
theme.bins[bin] = value;
|
|
446
|
+
else
|
|
447
|
+
warn(`${where}: bin ${bin} has no valid colour`);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
function endsWalk(home) {
|
|
452
|
+
return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
|
|
453
|
+
}
|
|
454
|
+
var warned = new Set;
|
|
455
|
+
function warnOnce(message) {
|
|
456
|
+
if (warned.has(message))
|
|
457
|
+
return;
|
|
458
|
+
warned.add(message);
|
|
459
|
+
console.error(`warning: theme ${message}`);
|
|
460
|
+
}
|
|
461
|
+
function isPath(chosen) {
|
|
462
|
+
return chosen.includes("/") || chosen.endsWith(".json");
|
|
463
|
+
}
|
|
464
|
+
function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
|
|
465
|
+
const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
|
|
466
|
+
const sources = [];
|
|
467
|
+
const chosen = env.KIT_THEME ?? "";
|
|
468
|
+
const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
|
|
469
|
+
if (isPath(chosen))
|
|
470
|
+
wanted.push(resolve2(from, chosen));
|
|
471
|
+
const files = [];
|
|
472
|
+
for (const path of wanted) {
|
|
473
|
+
const file = path === undefined ? undefined : readThemeFile(path, warn);
|
|
474
|
+
if (path !== undefined && file !== undefined)
|
|
475
|
+
files.push({ path, file });
|
|
476
|
+
}
|
|
477
|
+
let preset = "default";
|
|
478
|
+
if (chosen !== "" && !isPath(chosen)) {
|
|
479
|
+
preset = applyPreset(theme, chosen, warn, "KIT_THEME") ?? preset;
|
|
480
|
+
} else {
|
|
481
|
+
const named = files.findLast(({ file }) => file.preset !== undefined);
|
|
482
|
+
if (named !== undefined)
|
|
483
|
+
preset = applyPreset(theme, named.file.preset, warn, named.path) ?? preset;
|
|
484
|
+
}
|
|
485
|
+
for (const { path, file } of files) {
|
|
486
|
+
applyFile(theme, file, path, warn);
|
|
487
|
+
sources.push(path);
|
|
488
|
+
}
|
|
489
|
+
return { theme, sources, preset };
|
|
490
|
+
}
|
|
491
|
+
var current;
|
|
492
|
+
var currentKey = "";
|
|
493
|
+
function activeTheme() {
|
|
494
|
+
const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
|
|
495
|
+
if (current === undefined || key !== currentKey) {
|
|
496
|
+
current = loadTheme();
|
|
497
|
+
currentKey = key;
|
|
498
|
+
}
|
|
499
|
+
return current;
|
|
500
|
+
}
|
|
501
|
+
|
|
274
502
|
// ../kit/src/style.ts
|
|
275
|
-
function takesControlCodes(stream, env =
|
|
276
|
-
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
|
|
503
|
+
function takesControlCodes(stream, env = process6.env) {
|
|
504
|
+
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
277
505
|
}
|
|
278
|
-
function paint(stream, env =
|
|
506
|
+
function paint(stream, env = process6.env) {
|
|
279
507
|
return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
280
508
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
509
|
+
function role(name, stream, env = process6.env) {
|
|
510
|
+
const colors = paint(stream, env);
|
|
511
|
+
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
512
|
+
}
|
|
513
|
+
var STATUS_WORDS = {
|
|
514
|
+
passed: ["passed", "success", "succeeded", "ok"],
|
|
515
|
+
failed: ["failed", "failure", "error", "errored"],
|
|
516
|
+
running: ["running", "in_progress", "started", "holding"],
|
|
517
|
+
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
518
|
+
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
287
519
|
};
|
|
288
|
-
var STATUS_OF = new Map(Object.entries(
|
|
520
|
+
var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
289
521
|
|
|
290
522
|
// ../kit/src/format.ts
|
|
291
523
|
function upTo(text, separator) {
|
|
@@ -293,32 +525,35 @@ function upTo(text, separator) {
|
|
|
293
525
|
return end === -1 ? text : text.slice(0, end);
|
|
294
526
|
}
|
|
295
527
|
var ESCAPE = String.fromCharCode(27);
|
|
528
|
+
function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
|
|
529
|
+
return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
|
|
530
|
+
}
|
|
296
531
|
function printJson(value) {
|
|
297
|
-
console.log(
|
|
532
|
+
console.log(jsonText(value));
|
|
298
533
|
}
|
|
299
534
|
|
|
300
535
|
// ../kit/src/help.ts
|
|
301
|
-
import
|
|
536
|
+
import process8 from "process";
|
|
302
537
|
var OPTIONAL = /\[[^\]]+\]/g;
|
|
303
538
|
var USAGE_PREFIX = /^usage:\s*/i;
|
|
304
539
|
var FULL_STOP = /\.$/;
|
|
305
|
-
function usageLine(usage, colors = paint(
|
|
540
|
+
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
306
541
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
307
542
|
}
|
|
308
|
-
function helpText(usage, options, colors = paint(
|
|
543
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
|
|
309
544
|
return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
310
545
|
`);
|
|
311
546
|
}
|
|
312
|
-
function exitRows(exits, colors = paint(
|
|
547
|
+
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
313
548
|
if (exits.length === 0)
|
|
314
549
|
return [];
|
|
315
550
|
const width = Math.max(...exits.map(([code]) => String(code).length));
|
|
316
551
|
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
317
552
|
}
|
|
318
|
-
function replacesRows(replaces, colors = paint(
|
|
319
|
-
return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
553
|
+
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
554
|
+
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
320
555
|
}
|
|
321
|
-
function wantsHelpJson(env =
|
|
556
|
+
function wantsHelpJson(env = process8.env) {
|
|
322
557
|
return env.KIT_HELP === "json";
|
|
323
558
|
}
|
|
324
559
|
function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
@@ -337,12 +572,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
|
337
572
|
...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
|
|
338
573
|
};
|
|
339
574
|
}
|
|
340
|
-
function exampleRows(examples, colors = paint(
|
|
341
|
-
if (examples.length === 0)
|
|
575
|
+
function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
576
|
+
if (examples.length === 0 || outputMode() === "agent")
|
|
342
577
|
return [];
|
|
343
578
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
344
579
|
}
|
|
345
|
-
function optionRows(options, colors = paint(
|
|
580
|
+
function optionRows(options, colors = paint(process8.stdout)) {
|
|
346
581
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
347
582
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
348
583
|
const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
|
|
@@ -433,7 +668,7 @@ var OUTPUT_OPTIONS = {
|
|
|
433
668
|
color: { type: "string", description: "auto (on a terminal alone), always or never" },
|
|
434
669
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
435
670
|
};
|
|
436
|
-
function applyOutput(color, plain, env =
|
|
671
|
+
function applyOutput(color, plain, env = process9.env) {
|
|
437
672
|
const when = plain === true ? "never" : color ?? "auto";
|
|
438
673
|
if (when === "auto")
|
|
439
674
|
return;
|
|
@@ -604,7 +839,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
604
839
|
}
|
|
605
840
|
// ../kit/src/process.ts
|
|
606
841
|
import { constants } from "os";
|
|
607
|
-
import
|
|
842
|
+
import process10 from "process";
|
|
608
843
|
var KILL_GRACE_MS = 2000;
|
|
609
844
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
610
845
|
function exitCodeOf(code, signal) {
|
|
@@ -626,7 +861,7 @@ function holdSignals(cleanup) {
|
|
|
626
861
|
},
|
|
627
862
|
release: () => {
|
|
628
863
|
for (const signal of SIGNALS)
|
|
629
|
-
|
|
864
|
+
process10.off(signal, onSignal);
|
|
630
865
|
}
|
|
631
866
|
};
|
|
632
867
|
function onSignal(signal) {
|
|
@@ -639,10 +874,10 @@ function holdSignals(cleanup) {
|
|
|
639
874
|
return;
|
|
640
875
|
held.release();
|
|
641
876
|
cleanup(signal);
|
|
642
|
-
|
|
877
|
+
process10.kill(process10.pid, signal);
|
|
643
878
|
}
|
|
644
879
|
for (const signal of SIGNALS)
|
|
645
|
-
|
|
880
|
+
process10.on(signal, onSignal);
|
|
646
881
|
return held;
|
|
647
882
|
}
|
|
648
883
|
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
@@ -656,7 +891,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
656
891
|
return;
|
|
657
892
|
try {
|
|
658
893
|
if (grouped)
|
|
659
|
-
|
|
894
|
+
process10.kill(-proc.pid, killing);
|
|
660
895
|
else
|
|
661
896
|
proc.kill(killing);
|
|
662
897
|
} catch {}
|
|
@@ -730,15 +965,15 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
|
|
|
730
965
|
var RESET_STYLE = `${ESC}[0m`;
|
|
731
966
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
732
967
|
// ../kit/src/cli.ts
|
|
733
|
-
import { readFileSync, realpathSync } from "fs";
|
|
734
|
-
import { dirname as
|
|
735
|
-
import
|
|
968
|
+
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
969
|
+
import { dirname as dirname3, join as join5 } from "path";
|
|
970
|
+
import process12 from "process";
|
|
736
971
|
|
|
737
972
|
// ../kit/src/usage.ts
|
|
738
973
|
import { appendFileSync, mkdirSync } from "fs";
|
|
739
|
-
import { homedir } from "os";
|
|
740
|
-
import { dirname, isAbsolute, join } from "path";
|
|
741
|
-
import
|
|
974
|
+
import { homedir as homedir3 } from "os";
|
|
975
|
+
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
976
|
+
import process11 from "process";
|
|
742
977
|
|
|
743
978
|
// ../kit/src/logs.ts
|
|
744
979
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -752,14 +987,14 @@ var usageError;
|
|
|
752
987
|
function noteUsageError(message) {
|
|
753
988
|
usageError = message;
|
|
754
989
|
}
|
|
755
|
-
function stateHome(env =
|
|
990
|
+
function stateHome(env = process11.env) {
|
|
756
991
|
const dir = env.XDG_STATE_HOME;
|
|
757
|
-
return dir !== undefined && isAbsolute(dir) ? dir :
|
|
992
|
+
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
758
993
|
}
|
|
759
|
-
function usagePath(env =
|
|
760
|
-
return
|
|
994
|
+
function usagePath(env = process11.env) {
|
|
995
|
+
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
761
996
|
}
|
|
762
|
-
function usageRecorded(env =
|
|
997
|
+
function usageRecorded(env = process11.env) {
|
|
763
998
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
764
999
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
765
1000
|
}
|
|
@@ -773,12 +1008,12 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
773
1008
|
usageError = undefined;
|
|
774
1009
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
775
1010
|
}
|
|
776
|
-
function recordUsage(entry, env =
|
|
1011
|
+
function recordUsage(entry, env = process11.env) {
|
|
777
1012
|
if (!usageRecorded(env))
|
|
778
1013
|
return;
|
|
779
1014
|
try {
|
|
780
1015
|
const path = usagePath(env);
|
|
781
|
-
mkdirSync(
|
|
1016
|
+
mkdirSync(dirname2(path), { recursive: true, mode: 448 });
|
|
782
1017
|
appendFileSync(path, `${JSON.stringify(entry)}
|
|
783
1018
|
`, { mode: 384 });
|
|
784
1019
|
} catch {}
|
|
@@ -791,8 +1026,8 @@ var LEVEL_OPTIONS = {
|
|
|
791
1026
|
};
|
|
792
1027
|
var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
|
|
793
1028
|
function printError(prefix, message, hint, cause) {
|
|
794
|
-
const colors = paint(
|
|
795
|
-
const styled = takesControlCodes(
|
|
1029
|
+
const colors = paint(process12.stderr);
|
|
1030
|
+
const styled = takesControlCodes(process12.stderr);
|
|
796
1031
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
797
1032
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
798
1033
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -814,7 +1049,7 @@ function reportThrown(prefix, error, redact = (text) => text, json = false) {
|
|
|
814
1049
|
const help = error instanceof UsageError ? `run ${prefix} --help for its options` : undefined;
|
|
815
1050
|
const named = error instanceof Error && !(error instanceof Exit) && error.name !== "Error" ? `${error.name}: ${error.message}` : undefined;
|
|
816
1051
|
const cause = error instanceof Error && error.cause instanceof Error ? redact(error.cause.message) : undefined;
|
|
817
|
-
if (error instanceof
|
|
1052
|
+
if (error instanceof Exit && error.code === 2)
|
|
818
1053
|
noteUsageError(error.message);
|
|
819
1054
|
const report = json ? printJsonError : (message, hint, causeText) => printError(prefix, message, hint, causeText);
|
|
820
1055
|
report(redact(named ?? (error instanceof Error ? error.message : String(error))), error instanceof Exit ? error.hint ?? help : undefined, cause);
|
|
@@ -878,17 +1113,17 @@ async function printCandidates(found) {
|
|
|
878
1113
|
return 0;
|
|
879
1114
|
}
|
|
880
1115
|
function packageVersion(entry = Bun.main) {
|
|
881
|
-
for (let dir =
|
|
1116
|
+
for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
|
|
882
1117
|
try {
|
|
883
|
-
const { version } = JSON.parse(
|
|
1118
|
+
const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
|
|
884
1119
|
if (typeof version === "string")
|
|
885
1120
|
return version;
|
|
886
1121
|
} catch {}
|
|
887
|
-
if (
|
|
1122
|
+
if (dirname3(dir) === dir)
|
|
888
1123
|
return "0.0.0";
|
|
889
1124
|
}
|
|
890
1125
|
}
|
|
891
|
-
async function runMain({ name, version, run, redact, usage }, argv =
|
|
1126
|
+
async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
|
|
892
1127
|
if (argv[0] === COMPLETE)
|
|
893
1128
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
894
1129
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
@@ -985,7 +1220,7 @@ var OPTIONS = {
|
|
|
985
1220
|
};
|
|
986
1221
|
var RENAME = /^[RC]\d*$/;
|
|
987
1222
|
var NOT_A_REPOSITORY = /not a git repository/i;
|
|
988
|
-
var LITERAL = { ...
|
|
1223
|
+
var LITERAL = { ...process14.env, GIT_LITERAL_PATHSPECS: "1" };
|
|
989
1224
|
function messageOf(title, lines, tickets) {
|
|
990
1225
|
return [title, lines.join(`
|
|
991
1226
|
`), tickets.join(`
|
|
@@ -1083,4 +1318,4 @@ ${(commit.stderr + commit.stdout).trim()}`;
|
|
|
1083
1318
|
signals.release();
|
|
1084
1319
|
}
|
|
1085
1320
|
}
|
|
1086
|
-
|
|
1321
|
+
process14.exitCode = await runMain({ name: "gc", run: main });
|