@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/j-cli.js
CHANGED
|
@@ -2,16 +2,37 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/j-cli.ts
|
|
5
|
-
import
|
|
5
|
+
import process22 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,16 +1294,16 @@ 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/j.ts
|
|
1253
|
-
import
|
|
1300
|
+
import process21 from "process";
|
|
1254
1301
|
|
|
1255
1302
|
// ../kit/src/picker.ts
|
|
1256
1303
|
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
1257
1304
|
import { homedir as homedir5 } from "os";
|
|
1258
1305
|
import { dirname as dirname4, join as join7 } from "path";
|
|
1259
|
-
import
|
|
1306
|
+
import process18 from "process";
|
|
1260
1307
|
|
|
1261
1308
|
// ../kit/src/picker/score.ts
|
|
1262
1309
|
var MATCH = 16;
|
|
@@ -1499,11 +1546,11 @@ function chosen(state) {
|
|
|
1499
1546
|
|
|
1500
1547
|
// ../kit/src/picker/terminal.ts
|
|
1501
1548
|
import { openSync as openSync2 } from "fs";
|
|
1502
|
-
import
|
|
1549
|
+
import process17 from "process";
|
|
1503
1550
|
import tty from "tty";
|
|
1504
1551
|
|
|
1505
1552
|
// ../kit/src/picker/preview.ts
|
|
1506
|
-
import
|
|
1553
|
+
import process16 from "process";
|
|
1507
1554
|
|
|
1508
1555
|
// ../kit/src/shell.ts
|
|
1509
1556
|
var SEPARATORS = new Set([`
|
|
@@ -1572,7 +1619,7 @@ async function runPreview(template, line, signal, hidden = []) {
|
|
|
1572
1619
|
${previewCommand(template, line, hidden)}`], { stdin: "ignore", stdout: "pipe", stderr: "ignore", detached: true });
|
|
1573
1620
|
const stop = () => {
|
|
1574
1621
|
try {
|
|
1575
|
-
|
|
1622
|
+
process16.kill(-proc.pid, "SIGKILL");
|
|
1576
1623
|
} catch {
|
|
1577
1624
|
proc.kill();
|
|
1578
1625
|
}
|
|
@@ -1703,7 +1750,7 @@ function openTerminal() {
|
|
|
1703
1750
|
} catch {
|
|
1704
1751
|
return fail("no terminal to read keys from (/dev/tty)");
|
|
1705
1752
|
}
|
|
1706
|
-
const out =
|
|
1753
|
+
const out = process17.stderr;
|
|
1707
1754
|
let resize;
|
|
1708
1755
|
return {
|
|
1709
1756
|
get columns() {
|
|
@@ -1846,9 +1893,9 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
1846
1893
|
const ended = new Promise((resolve) => {
|
|
1847
1894
|
finish = resolve;
|
|
1848
1895
|
});
|
|
1849
|
-
|
|
1896
|
+
process17.once("exit", restore);
|
|
1850
1897
|
for (const signal of SIGNALS2)
|
|
1851
|
-
|
|
1898
|
+
process17.once(signal, stop);
|
|
1852
1899
|
try {
|
|
1853
1900
|
terminal.write(PASTE_ON);
|
|
1854
1901
|
terminal.listen(onChunk, () => draw(true));
|
|
@@ -1861,8 +1908,8 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
1861
1908
|
await ended;
|
|
1862
1909
|
} finally {
|
|
1863
1910
|
for (const signal of SIGNALS2)
|
|
1864
|
-
|
|
1865
|
-
|
|
1911
|
+
process17.off(signal, stop);
|
|
1912
|
+
process17.off("exit", restore);
|
|
1866
1913
|
restore();
|
|
1867
1914
|
}
|
|
1868
1915
|
return state.done === "accept" ? { rows: chosen(state), key: state.key, query: state.query } : undefined;
|
|
@@ -1893,7 +1940,7 @@ function heightFor(count) {
|
|
|
1893
1940
|
return String(Math.max(15, Math.ceil((count + 4) / 0.6)));
|
|
1894
1941
|
}
|
|
1895
1942
|
function historyFile(name) {
|
|
1896
|
-
return join7(
|
|
1943
|
+
return join7(process18.env.XDG_CACHE_HOME ?? join7(homedir5(), ".cache"), name, "history.json");
|
|
1897
1944
|
}
|
|
1898
1945
|
function history(name) {
|
|
1899
1946
|
try {
|
|
@@ -1904,12 +1951,12 @@ function history(name) {
|
|
|
1904
1951
|
}
|
|
1905
1952
|
}
|
|
1906
1953
|
function runs(name) {
|
|
1907
|
-
return history(name)[
|
|
1954
|
+
return history(name)[process18.cwd()] ?? [];
|
|
1908
1955
|
}
|
|
1909
1956
|
function record(name, run) {
|
|
1910
1957
|
const all = history(name);
|
|
1911
1958
|
const file = historyFile(name);
|
|
1912
|
-
all[
|
|
1959
|
+
all[process18.cwd()] = [run, ...(all[process18.cwd()] ?? []).filter((earlier) => earlier.id !== run.id)].slice(0, REMEMBERED);
|
|
1913
1960
|
mkdirSync2(dirname4(file), { recursive: true });
|
|
1914
1961
|
writeFileSync(file, JSON.stringify(all));
|
|
1915
1962
|
}
|
|
@@ -1933,7 +1980,7 @@ function list(rows) {
|
|
|
1933
1980
|
}
|
|
1934
1981
|
|
|
1935
1982
|
// ../kit/src/prompt.ts
|
|
1936
|
-
import
|
|
1983
|
+
import process19 from "process";
|
|
1937
1984
|
var KEY_SEQUENCES2 = /\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|[\s\S]/giu;
|
|
1938
1985
|
var CONTROL3 = /^[\x00-\x1F\x7F]/;
|
|
1939
1986
|
var KEYS2 = { "\x1B[A": "up", "\x1BOA": "up", "\x1B[B": "down", "\x1BOB": "down", "\r": "enter", "\n": "enter", "\x03": "cancel", "\x1B": "cancel", "\x7F": "erase", "\b": "erase" };
|
|
@@ -1972,9 +2019,9 @@ async function input2(question, { default: fallback, mask = false, validate, ...
|
|
|
1972
2019
|
function answer(colors, question, state, picked) {
|
|
1973
2020
|
return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
|
|
1974
2021
|
}
|
|
1975
|
-
async function ask(question, { hint, terminal =
|
|
2022
|
+
async function ask(question, { hint, terminal = process19 }, render, press) {
|
|
1976
2023
|
const { stdin, stderr } = terminal;
|
|
1977
|
-
if (
|
|
2024
|
+
if (!isInteractive(terminal))
|
|
1978
2025
|
fail(`cannot ask "${question}" off a terminal`, 2, hint);
|
|
1979
2026
|
const colors = paint(stderr);
|
|
1980
2027
|
let drawn = 0;
|
|
@@ -2023,7 +2070,7 @@ async function ask(question, { hint, terminal = process18 }, render, press) {
|
|
|
2023
2070
|
}
|
|
2024
2071
|
|
|
2025
2072
|
// src/job-picker.ts
|
|
2026
|
-
import
|
|
2073
|
+
import process20 from "process";
|
|
2027
2074
|
|
|
2028
2075
|
// src/jobs.ts
|
|
2029
2076
|
import { existsSync as existsSync4, readdirSync, readFileSync as readFileSync4 } from "fs";
|
|
@@ -2441,7 +2488,7 @@ function labelled(entries) {
|
|
|
2441
2488
|
return new Set(entries.map((entry) => entry.tag)).size > 1;
|
|
2442
2489
|
}
|
|
2443
2490
|
function row(entry, labels, signed) {
|
|
2444
|
-
const colors = paint(
|
|
2491
|
+
const colors = paint(process20.stderr);
|
|
2445
2492
|
const keyed = entry.dir === "." ? entry.name : `${colors.dim(`${entry.dir}/`)}${entry.name}`;
|
|
2446
2493
|
return {
|
|
2447
2494
|
hidden: [entry.kind, entry.dir, entry.name, id(entry)],
|
|
@@ -2455,7 +2502,7 @@ async function pickJob(entries, narrowed = false) {
|
|
|
2455
2502
|
prompt: `${[...new Set(entries.map((entry) => entry.tag))].join("/")}> `,
|
|
2456
2503
|
searched: labels ? 2 : 1,
|
|
2457
2504
|
...narrowed ? { height: heightFor(entries.length) } : {},
|
|
2458
|
-
preview: `${
|
|
2505
|
+
preview: `${process20.execPath} ${process20.argv[1]} --show {1} {2} {3}`
|
|
2459
2506
|
});
|
|
2460
2507
|
return entries.find((candidate) => id(candidate) === picked?.hidden[3]);
|
|
2461
2508
|
}
|
|
@@ -2477,7 +2524,7 @@ function preview(kind, dir, name) {
|
|
|
2477
2524
|
const entry = readKind(kind, dir).find((candidate) => candidate.name === name);
|
|
2478
2525
|
if (entry === undefined)
|
|
2479
2526
|
return;
|
|
2480
|
-
const colors = paint(
|
|
2527
|
+
const colors = paint(process21.stdout);
|
|
2481
2528
|
console.log(`${colors.dim(`$ ${dir === "." ? "" : `env -C ${dir} `}`)}${colors.bold([...entry.runner, entry.name].join(" "))}
|
|
2482
2529
|
`);
|
|
2483
2530
|
if (entry.body !== undefined)
|
|
@@ -2503,7 +2550,7 @@ function listed2(found) {
|
|
|
2503
2550
|
}));
|
|
2504
2551
|
}
|
|
2505
2552
|
function table3(found) {
|
|
2506
|
-
const colors = paint(
|
|
2553
|
+
const colors = paint(process21.stdout);
|
|
2507
2554
|
const labels = labelled(found);
|
|
2508
2555
|
const rows = found.map((entry) => [...labels ? [entry.tag] : [], key(entry), signature(entry)]);
|
|
2509
2556
|
const widths = rows[0]?.map((_, column) => Math.max(...rows.map((cells) => cells[column].length))) ?? [];
|
|
@@ -2554,7 +2601,7 @@ async function j(argv) {
|
|
|
2554
2601
|
if (found.length === 0)
|
|
2555
2602
|
fail("nothing to run here: no recipe, target, script or task", 1);
|
|
2556
2603
|
const previous = runs("j");
|
|
2557
|
-
const interactive =
|
|
2604
|
+
const interactive = isInteractive() && parsed.values.json !== true;
|
|
2558
2605
|
let entry;
|
|
2559
2606
|
let words = given;
|
|
2560
2607
|
if (named === "-") {
|
|
@@ -2605,4 +2652,4 @@ async function j(argv) {
|
|
|
2605
2652
|
}
|
|
2606
2653
|
|
|
2607
2654
|
// src/j-cli.ts
|
|
2608
|
-
|
|
2655
|
+
process22.exitCode = await runMain({ name: "j", version, run: j });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-check",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"description": "check, fix and errs: run a repo's check, typecheck, lint and test steps or its fixers, inside its docker compose service when one mounts the folder, showing only what failed with each full output saved to a file, and turn tsc, eslint, bun test, vitest, playwright, phpunit, phpstan and php-cs-fixer logs into file:line:col errors.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"j": "$npm_execpath src/j-cli.ts"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@kaynooo/cli-kit": "0.
|
|
37
|
+
"@kaynooo/cli-kit": "0.22.0"
|
|
38
38
|
}
|
|
39
39
|
}
|