@kaynooo/cli-check 0.14.0 → 0.15.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/cli.js +125 -78
- package/dist/errs-cli.js +118 -71
- package/dist/fix-cli.js +120 -73
- package/dist/j-cli.js +127 -80
- package/package.json +2 -2
package/dist/fix-cli.js
CHANGED
|
@@ -2,16 +2,37 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/fix-cli.ts
|
|
5
|
-
import
|
|
5
|
+
import process19 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
|
-
import
|
|
7
|
+
import process10 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
9
9
|
|
|
10
10
|
// ../kit/src/format.ts
|
|
11
|
-
import
|
|
11
|
+
import process7 from "process";
|
|
12
|
+
|
|
13
|
+
// ../kit/src/mode.ts
|
|
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
|
+
}
|
|
12
33
|
|
|
13
34
|
// ../kit/src/style.ts
|
|
14
|
-
import
|
|
35
|
+
import process6 from "process";
|
|
15
36
|
|
|
16
37
|
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
|
|
17
38
|
function x(s) {
|
|
@@ -278,13 +299,13 @@ var t = le();
|
|
|
278
299
|
import { existsSync as existsSync2, readFileSync, statSync } from "fs";
|
|
279
300
|
import { homedir as homedir2 } from "os";
|
|
280
301
|
import { join as join3, resolve as resolve2 } from "path";
|
|
281
|
-
import
|
|
302
|
+
import process5 from "process";
|
|
282
303
|
|
|
283
304
|
// ../kit/src/config.ts
|
|
284
305
|
import { existsSync } from "fs";
|
|
285
306
|
import { dirname, join, resolve } from "path";
|
|
286
|
-
import
|
|
287
|
-
function findUp(names, from =
|
|
307
|
+
import process3 from "process";
|
|
308
|
+
function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
288
309
|
const wanted = typeof names === "string" ? [names] : names;
|
|
289
310
|
for (let dir = resolve(from);; dir = dirname(dir)) {
|
|
290
311
|
const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
|
|
@@ -298,9 +319,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
|
|
|
298
319
|
// ../kit/src/user-config.ts
|
|
299
320
|
import { homedir } from "os";
|
|
300
321
|
import { join as join2 } from "path";
|
|
301
|
-
import
|
|
322
|
+
import process4 from "process";
|
|
302
323
|
function configBase(where = {}) {
|
|
303
|
-
const xdg = where.xdg ?? (where.home === undefined ?
|
|
324
|
+
const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
|
|
304
325
|
return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
|
|
305
326
|
}
|
|
306
327
|
function userConfigPath(bin, where = {}) {
|
|
@@ -333,10 +354,30 @@ function isColorSpec(spec) {
|
|
|
333
354
|
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
334
355
|
return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
|
|
335
356
|
}
|
|
336
|
-
|
|
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) {
|
|
337
374
|
if (typeof spec === "number")
|
|
338
375
|
return colors.ansi256(spec);
|
|
339
|
-
return spec.trim().split(SPACES).reduce((chain, token) =>
|
|
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);
|
|
340
381
|
}
|
|
341
382
|
function isRecord(value) {
|
|
342
383
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -420,7 +461,7 @@ function warnOnce(message) {
|
|
|
420
461
|
function isPath(chosen) {
|
|
421
462
|
return chosen.includes("/") || chosen.endsWith(".json");
|
|
422
463
|
}
|
|
423
|
-
function loadTheme({ env =
|
|
464
|
+
function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
|
|
424
465
|
const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
|
|
425
466
|
const sources = [];
|
|
426
467
|
const chosen = env.KIT_THEME ?? "";
|
|
@@ -450,7 +491,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
|
|
|
450
491
|
var current;
|
|
451
492
|
var currentKey = "";
|
|
452
493
|
function activeTheme() {
|
|
453
|
-
const key = `${
|
|
494
|
+
const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
|
|
454
495
|
if (current === undefined || key !== currentKey) {
|
|
455
496
|
current = loadTheme();
|
|
456
497
|
currentKey = key;
|
|
@@ -460,44 +501,44 @@ function activeTheme() {
|
|
|
460
501
|
|
|
461
502
|
// ../kit/src/style.ts
|
|
462
503
|
var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
|
|
463
|
-
function takesControlCodes(stream, env =
|
|
464
|
-
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
|
|
504
|
+
function takesControlCodes(stream, env = process6.env) {
|
|
505
|
+
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
465
506
|
}
|
|
466
|
-
function paint(stream, env =
|
|
507
|
+
function paint(stream, env = process6.env) {
|
|
467
508
|
return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
468
509
|
}
|
|
469
|
-
function marked(mark, text, stream, detail, env =
|
|
510
|
+
function marked(mark, text, stream, detail, env = process6.env) {
|
|
470
511
|
const colors = paint(stream, env);
|
|
471
512
|
let head = MARK_WORDS[mark];
|
|
472
513
|
if (takesControlCodes(stream, env)) {
|
|
473
514
|
const { theme } = activeTheme();
|
|
474
|
-
head = tinted(colors.bold, theme.colors[mark])(theme.glyphs[mark]);
|
|
515
|
+
head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
|
|
475
516
|
}
|
|
476
517
|
return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
|
|
477
518
|
}
|
|
478
519
|
function warn(text, detail) {
|
|
479
|
-
console.error(marked("warn", text,
|
|
520
|
+
console.error(marked("warn", text, process6.stderr, detail));
|
|
480
521
|
}
|
|
481
|
-
function role(name, stream, env =
|
|
522
|
+
function role(name, stream, env = process6.env) {
|
|
482
523
|
const colors = paint(stream, env);
|
|
483
|
-
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
|
|
524
|
+
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
484
525
|
}
|
|
485
526
|
var STATUS_WORDS = {
|
|
486
527
|
passed: ["passed", "success", "succeeded", "ok"],
|
|
487
528
|
failed: ["failed", "failure", "error", "errored"],
|
|
488
|
-
running: ["running", "in_progress", "started"],
|
|
529
|
+
running: ["running", "in_progress", "started", "holding"],
|
|
489
530
|
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
490
531
|
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
491
532
|
};
|
|
492
533
|
var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
493
|
-
function header(bin, context, stream, env =
|
|
534
|
+
function header(bin, context, stream, env = process6.env) {
|
|
494
535
|
if (!takesControlCodes(stream, env))
|
|
495
536
|
return "";
|
|
496
537
|
const colors = paint(stream, env);
|
|
497
538
|
const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
|
|
498
539
|
const { theme } = activeTheme();
|
|
499
540
|
const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
|
|
500
|
-
const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec);
|
|
541
|
+
const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
|
|
501
542
|
return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
|
|
502
543
|
}
|
|
503
544
|
|
|
@@ -531,8 +572,11 @@ var ESCAPE = String.fromCharCode(27);
|
|
|
531
572
|
function textWidth(text) {
|
|
532
573
|
return Bun.stringWidth(text);
|
|
533
574
|
}
|
|
534
|
-
function table(rows, { cellWidth, header = false, align = [], fit, stream =
|
|
575
|
+
function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
|
|
535
576
|
const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
|
|
577
|
+
if (outputMode(stream, env) === "agent")
|
|
578
|
+
return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
|
|
579
|
+
`);
|
|
536
580
|
const widths = [];
|
|
537
581
|
for (const row of cells) {
|
|
538
582
|
for (const [index, cell] of row.entries())
|
|
@@ -567,32 +611,35 @@ function narrow(rows, widths, limit) {
|
|
|
567
611
|
}
|
|
568
612
|
return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
|
|
569
613
|
}
|
|
614
|
+
function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
|
|
615
|
+
return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
|
|
616
|
+
}
|
|
570
617
|
function printJson(value) {
|
|
571
|
-
console.log(
|
|
618
|
+
console.log(jsonText(value));
|
|
572
619
|
}
|
|
573
620
|
|
|
574
621
|
// ../kit/src/help.ts
|
|
575
|
-
import
|
|
622
|
+
import process8 from "process";
|
|
576
623
|
var OPTIONAL = /\[[^\]]+\]/g;
|
|
577
624
|
var USAGE_PREFIX = /^usage:\s*/i;
|
|
578
625
|
var FULL_STOP = /\.$/;
|
|
579
|
-
function usageLine(usage, colors = paint(
|
|
626
|
+
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
580
627
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
581
628
|
}
|
|
582
|
-
function helpText(usage, options, colors = paint(
|
|
629
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
|
|
583
630
|
return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
584
631
|
`);
|
|
585
632
|
}
|
|
586
|
-
function exitRows(exits, colors = paint(
|
|
633
|
+
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
587
634
|
if (exits.length === 0)
|
|
588
635
|
return [];
|
|
589
636
|
const width = Math.max(...exits.map(([code]) => String(code).length));
|
|
590
637
|
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
591
638
|
}
|
|
592
|
-
function replacesRows(replaces, colors = paint(
|
|
593
|
-
return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
639
|
+
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
640
|
+
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
594
641
|
}
|
|
595
|
-
function wantsHelpJson(env =
|
|
642
|
+
function wantsHelpJson(env = process8.env) {
|
|
596
643
|
return env.KIT_HELP === "json";
|
|
597
644
|
}
|
|
598
645
|
function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
@@ -611,12 +658,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
|
611
658
|
...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
|
|
612
659
|
};
|
|
613
660
|
}
|
|
614
|
-
function exampleRows(examples, colors = paint(
|
|
615
|
-
if (examples.length === 0)
|
|
661
|
+
function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
662
|
+
if (examples.length === 0 || outputMode() === "agent")
|
|
616
663
|
return [];
|
|
617
664
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
618
665
|
}
|
|
619
|
-
function optionRows(options, colors = paint(
|
|
666
|
+
function optionRows(options, colors = paint(process8.stdout)) {
|
|
620
667
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
621
668
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
622
669
|
const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
|
|
@@ -651,7 +698,7 @@ function closest(name, names) {
|
|
|
651
698
|
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
652
699
|
}
|
|
653
700
|
// ../kit/src/input.ts
|
|
654
|
-
import
|
|
701
|
+
import process9 from "process";
|
|
655
702
|
var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
656
703
|
var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
657
704
|
function duration(value, name, fallback, unit = "s") {
|
|
@@ -665,7 +712,7 @@ function duration(value, name, fallback, unit = "s") {
|
|
|
665
712
|
}
|
|
666
713
|
async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
667
714
|
if (path === "-") {
|
|
668
|
-
if (
|
|
715
|
+
if (process9.stdin.isTTY)
|
|
669
716
|
fail(noStdin);
|
|
670
717
|
return Bun.stdin.text();
|
|
671
718
|
}
|
|
@@ -724,7 +771,7 @@ var OUTPUT_OPTIONS = {
|
|
|
724
771
|
color: { type: "string", description: "auto (on a terminal alone), always or never" },
|
|
725
772
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
726
773
|
};
|
|
727
|
-
function applyOutput(color, plain, env =
|
|
774
|
+
function applyOutput(color, plain, env = process10.env) {
|
|
728
775
|
const when = plain === true ? "never" : color ?? "auto";
|
|
729
776
|
if (when === "auto")
|
|
730
777
|
return;
|
|
@@ -895,7 +942,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
895
942
|
}
|
|
896
943
|
// ../kit/src/process.ts
|
|
897
944
|
import { constants } from "os";
|
|
898
|
-
import
|
|
945
|
+
import process11 from "process";
|
|
899
946
|
var KILL_GRACE_MS = 2000;
|
|
900
947
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
901
948
|
function exitCodeOf(code, signal) {
|
|
@@ -917,7 +964,7 @@ function holdSignals(cleanup) {
|
|
|
917
964
|
},
|
|
918
965
|
release: () => {
|
|
919
966
|
for (const signal of SIGNALS)
|
|
920
|
-
|
|
967
|
+
process11.off(signal, onSignal);
|
|
921
968
|
}
|
|
922
969
|
};
|
|
923
970
|
function onSignal(signal) {
|
|
@@ -930,10 +977,10 @@ function holdSignals(cleanup) {
|
|
|
930
977
|
return;
|
|
931
978
|
held.release();
|
|
932
979
|
cleanup(signal);
|
|
933
|
-
|
|
980
|
+
process11.kill(process11.pid, signal);
|
|
934
981
|
}
|
|
935
982
|
for (const signal of SIGNALS)
|
|
936
|
-
|
|
983
|
+
process11.on(signal, onSignal);
|
|
937
984
|
return held;
|
|
938
985
|
}
|
|
939
986
|
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
@@ -947,7 +994,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
947
994
|
return;
|
|
948
995
|
try {
|
|
949
996
|
if (grouped)
|
|
950
|
-
|
|
997
|
+
process11.kill(-proc.pid, killing);
|
|
951
998
|
else
|
|
952
999
|
proc.kill(killing);
|
|
953
1000
|
} catch {}
|
|
@@ -1023,31 +1070,31 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
|
1023
1070
|
// ../kit/src/cli.ts
|
|
1024
1071
|
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
1025
1072
|
import { dirname as dirname3, join as join6 } from "path";
|
|
1026
|
-
import
|
|
1073
|
+
import process14 from "process";
|
|
1027
1074
|
|
|
1028
1075
|
// ../kit/src/usage.ts
|
|
1029
1076
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1030
1077
|
import { homedir as homedir4 } from "os";
|
|
1031
1078
|
import { dirname as dirname2, isAbsolute, join as join5 } from "path";
|
|
1032
|
-
import
|
|
1079
|
+
import process13 from "process";
|
|
1033
1080
|
|
|
1034
1081
|
// ../kit/src/logs.ts
|
|
1035
1082
|
import { lstatSync, openSync } from "fs";
|
|
1036
1083
|
import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
|
|
1037
1084
|
import { homedir as homedir3, tmpdir } from "os";
|
|
1038
1085
|
import { join as join4 } from "path";
|
|
1039
|
-
import
|
|
1086
|
+
import process12 from "process";
|
|
1040
1087
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
1041
1088
|
var CLI_FOLDER = "kaynooo-cli";
|
|
1042
1089
|
function isPrivateDirectory(path) {
|
|
1043
1090
|
try {
|
|
1044
1091
|
const info = lstatSync(path, { throwIfNoEntry: false });
|
|
1045
|
-
return info !== undefined && info.isDirectory() && info.uid === (
|
|
1092
|
+
return info !== undefined && info.isDirectory() && info.uid === (process12.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
|
|
1046
1093
|
} catch {
|
|
1047
1094
|
return false;
|
|
1048
1095
|
}
|
|
1049
1096
|
}
|
|
1050
|
-
async function privateLogDirectory(name, env =
|
|
1097
|
+
async function privateLogDirectory(name, env = process12.env) {
|
|
1051
1098
|
const runtime = env.XDG_RUNTIME_DIR;
|
|
1052
1099
|
const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
|
|
1053
1100
|
const path = join4(base, name);
|
|
@@ -1087,14 +1134,14 @@ var usageError;
|
|
|
1087
1134
|
function noteUsageError(message) {
|
|
1088
1135
|
usageError = message;
|
|
1089
1136
|
}
|
|
1090
|
-
function stateHome(env =
|
|
1137
|
+
function stateHome(env = process13.env) {
|
|
1091
1138
|
const dir = env.XDG_STATE_HOME;
|
|
1092
1139
|
return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
|
|
1093
1140
|
}
|
|
1094
|
-
function usagePath(env =
|
|
1141
|
+
function usagePath(env = process13.env) {
|
|
1095
1142
|
return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1096
1143
|
}
|
|
1097
|
-
function usageRecorded(env =
|
|
1144
|
+
function usageRecorded(env = process13.env) {
|
|
1098
1145
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1099
1146
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1100
1147
|
}
|
|
@@ -1108,7 +1155,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
1108
1155
|
usageError = undefined;
|
|
1109
1156
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1110
1157
|
}
|
|
1111
|
-
function recordUsage(entry, env =
|
|
1158
|
+
function recordUsage(entry, env = process13.env) {
|
|
1112
1159
|
if (!usageRecorded(env))
|
|
1113
1160
|
return;
|
|
1114
1161
|
try {
|
|
@@ -1126,8 +1173,8 @@ var LEVEL_OPTIONS = {
|
|
|
1126
1173
|
};
|
|
1127
1174
|
var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
|
|
1128
1175
|
function printError(prefix, message, hint, cause) {
|
|
1129
|
-
const colors = paint(
|
|
1130
|
-
const styled = takesControlCodes(
|
|
1176
|
+
const colors = paint(process14.stderr);
|
|
1177
|
+
const styled = takesControlCodes(process14.stderr);
|
|
1131
1178
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1132
1179
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1133
1180
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1220,7 +1267,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1220
1267
|
return "0.0.0";
|
|
1221
1268
|
}
|
|
1222
1269
|
}
|
|
1223
|
-
async function runMain({ name, version, run, redact, usage }, argv =
|
|
1270
|
+
async function runMain({ name, version, run, redact, usage }, argv = process14.argv.slice(2)) {
|
|
1224
1271
|
if (argv[0] === COMPLETE)
|
|
1225
1272
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1226
1273
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
@@ -1247,13 +1294,13 @@ var {Glob } = globalThis.Bun;
|
|
|
1247
1294
|
var SESSION_FILES = new Glob("*.json");
|
|
1248
1295
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1249
1296
|
// package.json
|
|
1250
|
-
var version = "0.
|
|
1297
|
+
var version = "0.15.0";
|
|
1251
1298
|
|
|
1252
1299
|
// src/fix.ts
|
|
1253
1300
|
import { existsSync as existsSync4, statSync as statSync2 } from "fs";
|
|
1254
1301
|
import { rename, writeFile as writeFile2 } from "fs/promises";
|
|
1255
1302
|
import { join as join11 } from "path";
|
|
1256
|
-
import
|
|
1303
|
+
import process18 from "process";
|
|
1257
1304
|
|
|
1258
1305
|
// src/changes.ts
|
|
1259
1306
|
import { stat as stat2 } from "fs/promises";
|
|
@@ -1282,7 +1329,7 @@ function changedFiles(before, after) {
|
|
|
1282
1329
|
import { existsSync as existsSync3 } from "fs";
|
|
1283
1330
|
import { homedir as homedir5 } from "os";
|
|
1284
1331
|
import { basename, dirname as dirname4, join as join8, relative, resolve as resolve3 } from "path";
|
|
1285
|
-
import
|
|
1332
|
+
import process16 from "process";
|
|
1286
1333
|
|
|
1287
1334
|
// ../kit/src/shell.ts
|
|
1288
1335
|
var SEPARATORS = new Set([`
|
|
@@ -1375,7 +1422,7 @@ async function variables(composeDir) {
|
|
|
1375
1422
|
if (match !== null && !line.trimStart().startsWith("#"))
|
|
1376
1423
|
env[match[1] ?? ""] = (match[2] ?? "").trim().replace(QUOTED, "$2");
|
|
1377
1424
|
}
|
|
1378
|
-
for (const [key, value] of Object.entries(
|
|
1425
|
+
for (const [key, value] of Object.entries(process16.env)) {
|
|
1379
1426
|
if (value !== undefined)
|
|
1380
1427
|
env[key] = value;
|
|
1381
1428
|
}
|
|
@@ -1511,7 +1558,7 @@ async function place(dir, program, { service, host } = {}) {
|
|
|
1511
1558
|
fail(`--in ${service}: no compose project mounts ${dir}`);
|
|
1512
1559
|
return;
|
|
1513
1560
|
}
|
|
1514
|
-
if (Bun.which("docker", { PATH:
|
|
1561
|
+
if (Bun.which("docker", { PATH: process16.env.PATH ?? "" }) === null) {
|
|
1515
1562
|
if (service !== undefined)
|
|
1516
1563
|
fail(`--in ${service}: docker not found`);
|
|
1517
1564
|
if (!noticed.has(found.composeDir)) {
|
|
@@ -1563,7 +1610,7 @@ class Stack {
|
|
|
1563
1610
|
}
|
|
1564
1611
|
static async running(composeDir) {
|
|
1565
1612
|
try {
|
|
1566
|
-
const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env:
|
|
1613
|
+
const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process16.env, timeoutMs: PS_TIMEOUT_MS });
|
|
1567
1614
|
if (ran.code !== 0)
|
|
1568
1615
|
return `docker compose ps failed in ${composeDir}: ${ran.text.trim().split(`
|
|
1569
1616
|
`).at(-1) ?? `exit ${ran.code}`}`;
|
|
@@ -1779,7 +1826,7 @@ function pick(steps, only, noun = "step") {
|
|
|
1779
1826
|
// src/run.ts
|
|
1780
1827
|
import { mkdir as mkdir2, readdir as readdir3, stat as stat3, writeFile } from "fs/promises";
|
|
1781
1828
|
import { basename as basename2, join as join10 } from "path";
|
|
1782
|
-
import
|
|
1829
|
+
import process17 from "process";
|
|
1783
1830
|
|
|
1784
1831
|
// src/e2e.ts
|
|
1785
1832
|
var E2E_NOISE = [
|
|
@@ -2414,7 +2461,7 @@ var runPrefix = (cwd) => `${basename2(cwd)}-${Bun.hash(cwd).toString(36)}-`;
|
|
|
2414
2461
|
async function logDirectory(cwd) {
|
|
2415
2462
|
const root = await privateLogDirectory("check");
|
|
2416
2463
|
await sweepLogs(root, LOG_MAX_AGE_MS);
|
|
2417
|
-
const path = join10(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${
|
|
2464
|
+
const path = join10(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process17.pid}`);
|
|
2418
2465
|
await mkdir2(path, { mode: 448 });
|
|
2419
2466
|
return path;
|
|
2420
2467
|
}
|
|
@@ -2440,7 +2487,7 @@ async function lastFailed(cwd) {
|
|
|
2440
2487
|
async function saveLog(output) {
|
|
2441
2488
|
const root = await privateLogDirectory("errs");
|
|
2442
2489
|
await sweepLogs(root);
|
|
2443
|
-
const path = join10(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${
|
|
2490
|
+
const path = join10(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process17.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
|
|
2444
2491
|
await writeFile(path, output, { mode: 384, flag: "wx" });
|
|
2445
2492
|
return path;
|
|
2446
2493
|
}
|
|
@@ -2448,7 +2495,7 @@ async function runStep(command, cwd, logFile, { env = {}, timeoutMs, held } = {}
|
|
|
2448
2495
|
const started = Date.now();
|
|
2449
2496
|
const { code, text, timedOut } = await runCommand(["sh", "-c", `${command} 2>&1`], {
|
|
2450
2497
|
cwd,
|
|
2451
|
-
env: { ...
|
|
2498
|
+
env: { ...process17.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
|
|
2452
2499
|
...timeoutMs === undefined ? {} : { timeoutMs },
|
|
2453
2500
|
...held === undefined ? {} : { onStart: (child) => held.forward(child) }
|
|
2454
2501
|
});
|
|
@@ -2464,8 +2511,8 @@ function outcomeJson(name, command, logFile, outcome, service) {
|
|
|
2464
2511
|
return { name, command, ...service === undefined ? {} : { in: service }, ok: outcome.ok, ms: outcome.ms, log: logFile, ...outcome.timedOut === true ? { timedOut: true } : {}, ...outcome.ok ? {} : { failed: failureExcerpt(outcome.output) } };
|
|
2465
2512
|
}
|
|
2466
2513
|
function printOutcome(name, width, command, logFile, outcome) {
|
|
2467
|
-
const colors = paint(
|
|
2468
|
-
const path = role("path",
|
|
2514
|
+
const colors = paint(process17.stdout);
|
|
2515
|
+
const path = role("path", process17.stdout);
|
|
2469
2516
|
const took = colors.dim(formatDuration(outcome.ms));
|
|
2470
2517
|
if (outcome.ok) {
|
|
2471
2518
|
console.log(`${colors.bold(colors.green("ok "))} ${name.padEnd(width)} ${took} ${path(logFile)}`);
|
|
@@ -2496,7 +2543,7 @@ var RUFF_CONFIGS = ["ruff.toml", ".ruff.toml"];
|
|
|
2496
2543
|
var RUFF_SECTION = /^\[tool\.ruff/m;
|
|
2497
2544
|
var MAX_CHANGED = 30;
|
|
2498
2545
|
async function replaceFile(path, content) {
|
|
2499
|
-
const temporary = `${path}.${
|
|
2546
|
+
const temporary = `${path}.${process18.pid}.tmp`;
|
|
2500
2547
|
await writeFile2(temporary, content, { mode: statSync2(path).mode & 511 });
|
|
2501
2548
|
await rename(temporary, path);
|
|
2502
2549
|
}
|
|
@@ -2568,14 +2615,14 @@ function printChanged(changed) {
|
|
|
2568
2615
|
if (changed.length > MAX_CHANGED)
|
|
2569
2616
|
console.log(` and ${changed.length - MAX_CHANGED} more`);
|
|
2570
2617
|
}
|
|
2571
|
-
async function fix(args, cwd =
|
|
2618
|
+
async function fix(args, cwd = process18.cwd()) {
|
|
2572
2619
|
const parsed = parse(args, fixUsage, fixOptions, { replaces: "running each fixer and formatter by hand, or docker compose exec <service> bun run lint:fix", examples: ["fix", ["fix --list", "the fixers it would run"]] });
|
|
2573
2620
|
return runFixers(parsed.values, cwd);
|
|
2574
2621
|
}
|
|
2575
2622
|
async function runFixers(values, cwd) {
|
|
2576
2623
|
const parsed = { values };
|
|
2577
2624
|
const settings = placeSettings(values);
|
|
2578
|
-
if (
|
|
2625
|
+
if (process18.env[RUNNING] !== undefined)
|
|
2579
2626
|
fail("a fixer called fix again, which would recurse: give its script another command");
|
|
2580
2627
|
const found = await fixers(cwd);
|
|
2581
2628
|
if (found.length === 0)
|
|
@@ -2609,7 +2656,7 @@ async function runFixers(values, cwd) {
|
|
|
2609
2656
|
break;
|
|
2610
2657
|
if (missing(fixer)) {
|
|
2611
2658
|
if (!json)
|
|
2612
|
-
console.log(`${paint(
|
|
2659
|
+
console.log(`${paint(process18.stdout).yellow("skip ")} ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
|
|
2613
2660
|
ran.push({ name: fixer.name, command: fixer.command, skipped: `${fixer.requires} is not installed` });
|
|
2614
2661
|
continue;
|
|
2615
2662
|
}
|
|
@@ -2642,4 +2689,4 @@ async function runFixers(values, cwd) {
|
|
|
2642
2689
|
}
|
|
2643
2690
|
|
|
2644
2691
|
// src/fix-cli.ts
|
|
2645
|
-
|
|
2692
|
+
process19.exitCode = await runMain({ name: "fix", version, run: async (args) => fix(args) });
|