@kaynooo/cli-check 0.14.0 → 0.16.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 +128 -80
- package/dist/errs-cli.js +120 -72
- package/dist/fix-cli.js +123 -75
- package/dist/j-cli.js +216 -103
- package/package.json +2 -2
package/dist/errs-cli.js
CHANGED
|
@@ -2,16 +2,37 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/errs-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
|
}
|
|
@@ -680,7 +727,6 @@ var DASHES = /^-+/;
|
|
|
680
727
|
function jsonOption(holds) {
|
|
681
728
|
return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
|
|
682
729
|
}
|
|
683
|
-
|
|
684
730
|
class Exit extends Error {
|
|
685
731
|
code;
|
|
686
732
|
hint;
|
|
@@ -724,7 +770,7 @@ var OUTPUT_OPTIONS = {
|
|
|
724
770
|
color: { type: "string", description: "auto (on a terminal alone), always or never" },
|
|
725
771
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
726
772
|
};
|
|
727
|
-
function applyOutput(color, plain, env =
|
|
773
|
+
function applyOutput(color, plain, env = process10.env) {
|
|
728
774
|
const when = plain === true ? "never" : color ?? "auto";
|
|
729
775
|
if (when === "auto")
|
|
730
776
|
return;
|
|
@@ -895,7 +941,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
895
941
|
}
|
|
896
942
|
// ../kit/src/process.ts
|
|
897
943
|
import { constants } from "os";
|
|
898
|
-
import
|
|
944
|
+
import process11 from "process";
|
|
899
945
|
var KILL_GRACE_MS = 2000;
|
|
900
946
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
901
947
|
function exitCodeOf(code, signal) {
|
|
@@ -917,7 +963,7 @@ function holdSignals(cleanup) {
|
|
|
917
963
|
},
|
|
918
964
|
release: () => {
|
|
919
965
|
for (const signal of SIGNALS)
|
|
920
|
-
|
|
966
|
+
process11.off(signal, onSignal);
|
|
921
967
|
}
|
|
922
968
|
};
|
|
923
969
|
function onSignal(signal) {
|
|
@@ -930,10 +976,10 @@ function holdSignals(cleanup) {
|
|
|
930
976
|
return;
|
|
931
977
|
held.release();
|
|
932
978
|
cleanup(signal);
|
|
933
|
-
|
|
979
|
+
process11.kill(process11.pid, signal);
|
|
934
980
|
}
|
|
935
981
|
for (const signal of SIGNALS)
|
|
936
|
-
|
|
982
|
+
process11.on(signal, onSignal);
|
|
937
983
|
return held;
|
|
938
984
|
}
|
|
939
985
|
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
@@ -947,7 +993,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
947
993
|
return;
|
|
948
994
|
try {
|
|
949
995
|
if (grouped)
|
|
950
|
-
|
|
996
|
+
process11.kill(-proc.pid, killing);
|
|
951
997
|
else
|
|
952
998
|
proc.kill(killing);
|
|
953
999
|
} catch {}
|
|
@@ -1023,31 +1069,31 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
|
1023
1069
|
// ../kit/src/cli.ts
|
|
1024
1070
|
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
1025
1071
|
import { dirname as dirname3, join as join6 } from "path";
|
|
1026
|
-
import
|
|
1072
|
+
import process14 from "process";
|
|
1027
1073
|
|
|
1028
1074
|
// ../kit/src/usage.ts
|
|
1029
1075
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1030
1076
|
import { homedir as homedir4 } from "os";
|
|
1031
1077
|
import { dirname as dirname2, isAbsolute, join as join5 } from "path";
|
|
1032
|
-
import
|
|
1078
|
+
import process13 from "process";
|
|
1033
1079
|
|
|
1034
1080
|
// ../kit/src/logs.ts
|
|
1035
1081
|
import { lstatSync, openSync } from "fs";
|
|
1036
1082
|
import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
|
|
1037
1083
|
import { homedir as homedir3, tmpdir } from "os";
|
|
1038
1084
|
import { join as join4 } from "path";
|
|
1039
|
-
import
|
|
1085
|
+
import process12 from "process";
|
|
1040
1086
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
1041
1087
|
var CLI_FOLDER = "kaynooo-cli";
|
|
1042
1088
|
function isPrivateDirectory(path) {
|
|
1043
1089
|
try {
|
|
1044
1090
|
const info = lstatSync(path, { throwIfNoEntry: false });
|
|
1045
|
-
return info !== undefined && info.isDirectory() && info.uid === (
|
|
1091
|
+
return info !== undefined && info.isDirectory() && info.uid === (process12.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
|
|
1046
1092
|
} catch {
|
|
1047
1093
|
return false;
|
|
1048
1094
|
}
|
|
1049
1095
|
}
|
|
1050
|
-
async function privateLogDirectory(name, env =
|
|
1096
|
+
async function privateLogDirectory(name, env = process12.env) {
|
|
1051
1097
|
const runtime = env.XDG_RUNTIME_DIR;
|
|
1052
1098
|
const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
|
|
1053
1099
|
const path = join4(base, name);
|
|
@@ -1087,14 +1133,14 @@ var usageError;
|
|
|
1087
1133
|
function noteUsageError(message) {
|
|
1088
1134
|
usageError = message;
|
|
1089
1135
|
}
|
|
1090
|
-
function stateHome(env =
|
|
1136
|
+
function stateHome(env = process13.env) {
|
|
1091
1137
|
const dir = env.XDG_STATE_HOME;
|
|
1092
1138
|
return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
|
|
1093
1139
|
}
|
|
1094
|
-
function usagePath(env =
|
|
1140
|
+
function usagePath(env = process13.env) {
|
|
1095
1141
|
return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1096
1142
|
}
|
|
1097
|
-
function usageRecorded(env =
|
|
1143
|
+
function usageRecorded(env = process13.env) {
|
|
1098
1144
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1099
1145
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1100
1146
|
}
|
|
@@ -1108,7 +1154,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
1108
1154
|
usageError = undefined;
|
|
1109
1155
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1110
1156
|
}
|
|
1111
|
-
function recordUsage(entry, env =
|
|
1157
|
+
function recordUsage(entry, env = process13.env) {
|
|
1112
1158
|
if (!usageRecorded(env))
|
|
1113
1159
|
return;
|
|
1114
1160
|
try {
|
|
@@ -1126,8 +1172,8 @@ var LEVEL_OPTIONS = {
|
|
|
1126
1172
|
};
|
|
1127
1173
|
var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
|
|
1128
1174
|
function printError(prefix, message, hint, cause) {
|
|
1129
|
-
const colors = paint(
|
|
1130
|
-
const styled = takesControlCodes(
|
|
1175
|
+
const colors = paint(process14.stderr);
|
|
1176
|
+
const styled = takesControlCodes(process14.stderr);
|
|
1131
1177
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1132
1178
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1133
1179
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1220,7 +1266,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1220
1266
|
return "0.0.0";
|
|
1221
1267
|
}
|
|
1222
1268
|
}
|
|
1223
|
-
async function runMain({ name, version, run, redact, usage }, argv =
|
|
1269
|
+
async function runMain({ name, version, run, redact, usage }, argv = process14.argv.slice(2)) {
|
|
1224
1270
|
if (argv[0] === COMPLETE)
|
|
1225
1271
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1226
1272
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
@@ -1240,6 +1286,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process13.a
|
|
|
1240
1286
|
}
|
|
1241
1287
|
return code;
|
|
1242
1288
|
}
|
|
1289
|
+
// ../kit/src/folders.ts
|
|
1290
|
+
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1243
1291
|
// ../kit/src/secrets.ts
|
|
1244
1292
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1245
1293
|
// ../kit/src/sessions.ts
|
|
@@ -1247,17 +1295,17 @@ var {Glob } = globalThis.Bun;
|
|
|
1247
1295
|
var SESSION_FILES = new Glob("*.json");
|
|
1248
1296
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1249
1297
|
// package.json
|
|
1250
|
-
var version = "0.
|
|
1298
|
+
var version = "0.16.0";
|
|
1251
1299
|
|
|
1252
1300
|
// src/errs.ts
|
|
1253
1301
|
import { relative as relative2 } from "path";
|
|
1254
|
-
import
|
|
1302
|
+
import process18 from "process";
|
|
1255
1303
|
|
|
1256
1304
|
// src/compose.ts
|
|
1257
1305
|
import { existsSync as existsSync3 } from "fs";
|
|
1258
1306
|
import { homedir as homedir5 } from "os";
|
|
1259
1307
|
import { basename, dirname as dirname4, join as join7, relative, resolve as resolve3 } from "path";
|
|
1260
|
-
import
|
|
1308
|
+
import process16 from "process";
|
|
1261
1309
|
|
|
1262
1310
|
// ../kit/src/shell.ts
|
|
1263
1311
|
var SEPARATORS = new Set([`
|
|
@@ -1350,7 +1398,7 @@ async function variables(composeDir) {
|
|
|
1350
1398
|
if (match !== null && !line.trimStart().startsWith("#"))
|
|
1351
1399
|
env[match[1] ?? ""] = (match[2] ?? "").trim().replace(QUOTED, "$2");
|
|
1352
1400
|
}
|
|
1353
|
-
for (const [key, value] of Object.entries(
|
|
1401
|
+
for (const [key, value] of Object.entries(process16.env)) {
|
|
1354
1402
|
if (value !== undefined)
|
|
1355
1403
|
env[key] = value;
|
|
1356
1404
|
}
|
|
@@ -1486,7 +1534,7 @@ async function place(dir, program, { service, host } = {}) {
|
|
|
1486
1534
|
fail(`--in ${service}: no compose project mounts ${dir}`);
|
|
1487
1535
|
return;
|
|
1488
1536
|
}
|
|
1489
|
-
if (Bun.which("docker", { PATH:
|
|
1537
|
+
if (Bun.which("docker", { PATH: process16.env.PATH ?? "" }) === null) {
|
|
1490
1538
|
if (service !== undefined)
|
|
1491
1539
|
fail(`--in ${service}: docker not found`);
|
|
1492
1540
|
if (!noticed.has(found.composeDir)) {
|
|
@@ -1538,7 +1586,7 @@ class Stack {
|
|
|
1538
1586
|
}
|
|
1539
1587
|
static async running(composeDir) {
|
|
1540
1588
|
try {
|
|
1541
|
-
const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env:
|
|
1589
|
+
const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process16.env, timeoutMs: PS_TIMEOUT_MS });
|
|
1542
1590
|
if (ran.code !== 0)
|
|
1543
1591
|
return `docker compose ps failed in ${composeDir}: ${ran.text.trim().split(`
|
|
1544
1592
|
`).at(-1) ?? `exit ${ran.code}`}`;
|
|
@@ -2198,14 +2246,14 @@ function parseErrors(output) {
|
|
|
2198
2246
|
// src/run.ts
|
|
2199
2247
|
import { mkdir as mkdir2, readdir as readdir2, stat as stat2, writeFile } from "fs/promises";
|
|
2200
2248
|
import { basename as basename2, join as join8 } from "path";
|
|
2201
|
-
import
|
|
2249
|
+
import process17 from "process";
|
|
2202
2250
|
var LOG_MAX_AGE_MS = 3 * 24 * 60 * 60 * 1000;
|
|
2203
2251
|
var RESULTS_FILE = "results.json";
|
|
2204
2252
|
var runPrefix = (cwd) => `${basename2(cwd)}-${Bun.hash(cwd).toString(36)}-`;
|
|
2205
2253
|
async function logDirectory(cwd) {
|
|
2206
2254
|
const root = await privateLogDirectory("check");
|
|
2207
2255
|
await sweepLogs(root, LOG_MAX_AGE_MS);
|
|
2208
|
-
const path = join8(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${
|
|
2256
|
+
const path = join8(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process17.pid}`);
|
|
2209
2257
|
await mkdir2(path, { mode: 448 });
|
|
2210
2258
|
return path;
|
|
2211
2259
|
}
|
|
@@ -2231,7 +2279,7 @@ async function lastFailed(cwd) {
|
|
|
2231
2279
|
async function saveLog(output) {
|
|
2232
2280
|
const root = await privateLogDirectory("errs");
|
|
2233
2281
|
await sweepLogs(root);
|
|
2234
|
-
const path = join8(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${
|
|
2282
|
+
const path = join8(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process17.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
|
|
2235
2283
|
await writeFile(path, output, { mode: 384, flag: "wx" });
|
|
2236
2284
|
return path;
|
|
2237
2285
|
}
|
|
@@ -2239,7 +2287,7 @@ async function runStep(command, cwd, logFile, { env = {}, timeoutMs, held } = {}
|
|
|
2239
2287
|
const started = Date.now();
|
|
2240
2288
|
const { code, text, timedOut } = await runCommand(["sh", "-c", `${command} 2>&1`], {
|
|
2241
2289
|
cwd,
|
|
2242
|
-
env: { ...
|
|
2290
|
+
env: { ...process17.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
|
|
2243
2291
|
...timeoutMs === undefined ? {} : { timeoutMs },
|
|
2244
2292
|
...held === undefined ? {} : { onStart: (child) => held.forward(child) }
|
|
2245
2293
|
});
|
|
@@ -2255,8 +2303,8 @@ function outcomeJson(name, command, logFile, outcome, service) {
|
|
|
2255
2303
|
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) } };
|
|
2256
2304
|
}
|
|
2257
2305
|
function printOutcome(name, width, command, logFile, outcome) {
|
|
2258
|
-
const colors = paint(
|
|
2259
|
-
const path = role("path",
|
|
2306
|
+
const colors = paint(process17.stdout);
|
|
2307
|
+
const path = role("path", process17.stdout);
|
|
2260
2308
|
const took = colors.dim(formatDuration(outcome.ms));
|
|
2261
2309
|
if (outcome.ok) {
|
|
2262
2310
|
console.log(`${colors.bold(colors.green("ok "))} ${name.padEnd(width)} ${took} ${path(logFile)}`);
|
|
@@ -2313,7 +2361,7 @@ async function readInput2(command, run, settings, cwd) {
|
|
|
2313
2361
|
const held = holdSignals();
|
|
2314
2362
|
let ran;
|
|
2315
2363
|
try {
|
|
2316
|
-
ran = await runCommand(placement === undefined ? command : argvIn(placement, command), { ...placement === undefined ? {} : { cwd: placement.composeDir }, env: { ...
|
|
2364
|
+
ran = await runCommand(placement === undefined ? command : argvIn(placement, command), { ...placement === undefined ? {} : { cwd: placement.composeDir }, env: { ...process18.env, NO_COLOR: "1", FORCE_COLOR: "0" }, onStart: (child) => held.forward(child) });
|
|
2317
2365
|
} catch (error) {
|
|
2318
2366
|
fail(`cannot run ${command[0]}: ${error instanceof Error ? error.message : String(error)}`);
|
|
2319
2367
|
} finally {
|
|
@@ -2321,7 +2369,7 @@ async function readInput2(command, run, settings, cwd) {
|
|
|
2321
2369
|
}
|
|
2322
2370
|
return { text: stripAnsi(ran.text), log: await saveLog(ran.output), code: ran.code };
|
|
2323
2371
|
}
|
|
2324
|
-
async function errs(args, cwd =
|
|
2372
|
+
async function errs(args, cwd = process18.cwd()) {
|
|
2325
2373
|
const first = args[0];
|
|
2326
2374
|
const bare = first !== undefined && !first.startsWith("-") && !await Bun.file(first).exists();
|
|
2327
2375
|
const parsed = parse(bare ? [] : args, usage2, options, { rest: true, replaces: "reading raw tsc, eslint, phpunit, phpstan or playwright logs, or grepping a test summary out of them", examples: [["errs -- bun run check", "the type errors of a run"], ["bun test 2>&1 | errs", "the failed tests from stdin"], ["errs -- vendor/bin/phpunit", "each failed PHP test with its file and line"]] });
|
|
@@ -2345,4 +2393,4 @@ ${usage2}`);
|
|
|
2345
2393
|
}
|
|
2346
2394
|
|
|
2347
2395
|
// src/errs-cli.ts
|
|
2348
|
-
|
|
2396
|
+
process19.exitCode = await runMain({ name: "errs", version, run: async (args) => errs(args) });
|