@kaynooo/cli-check 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/cli.js +496 -184
- package/dist/errs-cli.js +140 -75
- package/dist/fix-cli.js +221 -317
- package/dist/j-cli.js +158 -106
- package/package.json +2 -2
package/dist/j-cli.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
1
|
+
#!/usr/bin/env -S bun --no-env-file
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/j-cli.ts
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import process16 from "process";
|
|
7
6
|
// ../kit/src/args.ts
|
|
8
|
-
import
|
|
7
|
+
import process6 from "process";
|
|
9
8
|
import { parseArgs } from "util";
|
|
10
9
|
|
|
11
10
|
// ../kit/src/format.ts
|
|
12
|
-
import
|
|
11
|
+
import process3 from "process";
|
|
13
12
|
|
|
14
13
|
// ../kit/src/style.ts
|
|
15
|
-
import
|
|
14
|
+
import process2 from "process";
|
|
16
15
|
|
|
17
16
|
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
|
|
18
17
|
function x(s) {
|
|
@@ -282,20 +281,20 @@ var MARKS = {
|
|
|
282
281
|
problem: { symbol: "\u2717", word: "error:", paint: (colors) => colors.red },
|
|
283
282
|
note: { symbol: "\xB7", word: "note:", paint: (colors) => colors.dim }
|
|
284
283
|
};
|
|
285
|
-
function takesControlCodes(stream, env =
|
|
284
|
+
function takesControlCodes(stream, env = process2.env) {
|
|
286
285
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
|
|
287
286
|
}
|
|
288
|
-
function paint(stream, env =
|
|
287
|
+
function paint(stream, env = process2.env) {
|
|
289
288
|
return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
290
289
|
}
|
|
291
|
-
function marked(mark, text, stream, detail, env =
|
|
290
|
+
function marked(mark, text, stream, detail, env = process2.env) {
|
|
292
291
|
const colors = paint(stream, env);
|
|
293
292
|
const { symbol, word, paint: tint } = MARKS[mark];
|
|
294
293
|
const head = takesControlCodes(stream, env) ? tint(colors)(symbol) : word;
|
|
295
294
|
return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
|
|
296
295
|
}
|
|
297
296
|
function warn(text, detail) {
|
|
298
|
-
console.error(marked("warn", text,
|
|
297
|
+
console.error(marked("warn", text, process2.stderr, detail));
|
|
299
298
|
}
|
|
300
299
|
var STATUSES = {
|
|
301
300
|
passed: { symbol: "\u2713", words: ["passed", "success", "succeeded", "ok"], paint: (colors) => colors.green },
|
|
@@ -344,7 +343,7 @@ function table(rows, { cellWidth, header = false, align = [], fit } = {}) {
|
|
|
344
343
|
widths[index] = Math.max(widths[index] ?? 0, textWidth(cell));
|
|
345
344
|
}
|
|
346
345
|
const shown = fit === undefined ? cells : narrow(cells, widths, fit);
|
|
347
|
-
const colors = paint(
|
|
346
|
+
const colors = paint(process3.stdout);
|
|
348
347
|
const lines = shown.map((row) => row.map((cell, index) => {
|
|
349
348
|
const width = widths[index] ?? 0;
|
|
350
349
|
const gap = " ".repeat(Math.max(0, width - textWidth(cell)));
|
|
@@ -376,24 +375,30 @@ function printJson(value) {
|
|
|
376
375
|
}
|
|
377
376
|
|
|
378
377
|
// ../kit/src/help.ts
|
|
379
|
-
import
|
|
378
|
+
import process4 from "process";
|
|
380
379
|
var OPTIONAL = /\[[^\]]+\]/g;
|
|
381
380
|
var USAGE_PREFIX = /^usage:\s*/i;
|
|
382
381
|
var FULL_STOP = /\.$/;
|
|
383
|
-
function usageLine(usage, colors = paint(
|
|
382
|
+
function usageLine(usage, colors = paint(process4.stdout)) {
|
|
384
383
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
385
384
|
}
|
|
386
|
-
function helpText(usage, options, colors = paint(
|
|
387
|
-
return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exampleRows(examples, colors)].join(`
|
|
385
|
+
function helpText(usage, options, colors = paint(process4.stdout), { examples = [], replaces, exits = [] } = {}) {
|
|
386
|
+
return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
388
387
|
`);
|
|
389
388
|
}
|
|
390
|
-
function
|
|
389
|
+
function exitRows(exits, colors = paint(process4.stdout)) {
|
|
390
|
+
if (exits.length === 0)
|
|
391
|
+
return [];
|
|
392
|
+
const width = Math.max(...exits.map(([code]) => String(code).length));
|
|
393
|
+
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
394
|
+
}
|
|
395
|
+
function replacesRows(replaces, colors = paint(process4.stdout)) {
|
|
391
396
|
return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
392
397
|
}
|
|
393
|
-
function wantsHelpJson(env =
|
|
398
|
+
function wantsHelpJson(env = process4.env) {
|
|
394
399
|
return env.KIT_HELP === "json";
|
|
395
400
|
}
|
|
396
|
-
function description(usage, { examples = [], replaces } = {}) {
|
|
401
|
+
function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
397
402
|
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
398
403
|
`);
|
|
399
404
|
const first = lines[0];
|
|
@@ -404,15 +409,17 @@ function description(usage, { examples = [], replaces } = {}) {
|
|
|
404
409
|
synopsis: colon === -1 ? first : first.slice(0, colon),
|
|
405
410
|
summary: colon === -1 ? fallback : first.slice(colon + 2),
|
|
406
411
|
...replaces === undefined ? {} : { replaces },
|
|
407
|
-
examples: examples.map((example) => typeof example === "string" ? { line: example } : { line: example[0], note: example[1] })
|
|
412
|
+
examples: examples.map((example) => typeof example === "string" ? { line: example } : { line: example[0], note: example[1] }),
|
|
413
|
+
...exits === undefined ? {} : { exits: exits.map(([code, meaning]) => ({ code, meaning })) },
|
|
414
|
+
...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
|
|
408
415
|
};
|
|
409
416
|
}
|
|
410
|
-
function exampleRows(examples, colors = paint(
|
|
417
|
+
function exampleRows(examples, colors = paint(process4.stdout)) {
|
|
411
418
|
if (examples.length === 0)
|
|
412
419
|
return [];
|
|
413
420
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
414
421
|
}
|
|
415
|
-
function optionRows(options, colors = paint(
|
|
422
|
+
function optionRows(options, colors = paint(process4.stdout)) {
|
|
416
423
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
417
424
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
418
425
|
const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
|
|
@@ -447,7 +454,7 @@ function closest(name, names) {
|
|
|
447
454
|
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
448
455
|
}
|
|
449
456
|
// ../kit/src/input.ts
|
|
450
|
-
import
|
|
457
|
+
import process5 from "process";
|
|
451
458
|
var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
452
459
|
var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
453
460
|
function duration(value, name, fallback, unit = "s") {
|
|
@@ -461,7 +468,7 @@ function duration(value, name, fallback, unit = "s") {
|
|
|
461
468
|
}
|
|
462
469
|
async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
463
470
|
if (path === "-") {
|
|
464
|
-
if (
|
|
471
|
+
if (process5.stdin.isTTY)
|
|
465
472
|
fail(noStdin);
|
|
466
473
|
return Bun.stdin.text();
|
|
467
474
|
}
|
|
@@ -520,7 +527,7 @@ var OUTPUT_OPTIONS = {
|
|
|
520
527
|
color: { type: "string", description: "auto (on a terminal alone), always or never" },
|
|
521
528
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
522
529
|
};
|
|
523
|
-
function applyOutput(color, plain, env =
|
|
530
|
+
function applyOutput(color, plain, env = process6.env) {
|
|
524
531
|
const when = plain === true ? "never" : color ?? "auto";
|
|
525
532
|
if (when === "auto")
|
|
526
533
|
return;
|
|
@@ -543,7 +550,7 @@ function parse(args, usage, options, settings = {}) {
|
|
|
543
550
|
const { own, rest } = settings.trailing === true ? splitTrailing(args, all, settings.positionals?.length ?? 0) : splitRest(args, settings.rest === true);
|
|
544
551
|
let parsed;
|
|
545
552
|
try {
|
|
546
|
-
parsed = parseArgs({ args: joinDashValues(withBare(own, all), all), options: all, allowPositionals: true, allowNegative: settings.allowNegative === true, strict: true });
|
|
553
|
+
parsed = parseArgs({ args: joinDashValues(withBare(withAliases(own, all), all), all), options: all, allowPositionals: true, allowNegative: settings.allowNegative === true, strict: true });
|
|
547
554
|
} catch (error) {
|
|
548
555
|
const message = parseError(error);
|
|
549
556
|
throw new UsageError(message, nearestOption(message, all, settings.allowNegative === true));
|
|
@@ -551,7 +558,7 @@ function parse(args, usage, options, settings = {}) {
|
|
|
551
558
|
const values = parsed.values;
|
|
552
559
|
applyOutput("color" in output ? values.color : undefined, "plain" in output ? values.plain : undefined);
|
|
553
560
|
if (values.help === true) {
|
|
554
|
-
console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings)) : helpText(usage, listing, undefined, settings));
|
|
561
|
+
console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings, listing)) : helpText(usage, listing, undefined, settings));
|
|
555
562
|
throw new HelpShown;
|
|
556
563
|
}
|
|
557
564
|
checkChoices(parsed.values, all);
|
|
@@ -593,6 +600,18 @@ function listed(options, allowNegative) {
|
|
|
593
600
|
return [...option.description === undefined ? [] : [[name, option]], [`no-${name}`, { type: "boolean", description: option.negative }]];
|
|
594
601
|
}));
|
|
595
602
|
}
|
|
603
|
+
function withAliases(args, options) {
|
|
604
|
+
const named = new Map(Object.entries(options).flatMap(([name, { aliases = [] }]) => aliases.map((alias) => [`--${alias}`, `--${name}`])));
|
|
605
|
+
if (named.size === 0)
|
|
606
|
+
return args;
|
|
607
|
+
const separator = args.indexOf("--");
|
|
608
|
+
const own = separator === -1 ? args : args.slice(0, separator);
|
|
609
|
+
return [...own.map((arg) => {
|
|
610
|
+
const at = arg.indexOf("=");
|
|
611
|
+
const current = named.get(at === -1 ? arg : arg.slice(0, at));
|
|
612
|
+
return current === undefined ? arg : `${current}${at === -1 ? "" : arg.slice(at)}`;
|
|
613
|
+
}), ...separator === -1 ? [] : args.slice(separator)];
|
|
614
|
+
}
|
|
596
615
|
function withBare(args, options) {
|
|
597
616
|
const bare = new Map(Object.entries(options).flatMap(([name, { short, optional }]) => optional === undefined ? [] : [[`--${name}`, optional], ...short === undefined ? [] : [[`-${short}`, optional]]]));
|
|
598
617
|
if (bare.size === 0)
|
|
@@ -679,7 +698,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
679
698
|
}
|
|
680
699
|
// ../kit/src/process.ts
|
|
681
700
|
import { constants } from "os";
|
|
682
|
-
import
|
|
701
|
+
import process7 from "process";
|
|
683
702
|
var KILL_GRACE_MS = 2000;
|
|
684
703
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
685
704
|
function exitCodeOf(code, signal) {
|
|
@@ -701,7 +720,7 @@ function holdSignals(cleanup) {
|
|
|
701
720
|
},
|
|
702
721
|
release: () => {
|
|
703
722
|
for (const signal of SIGNALS)
|
|
704
|
-
|
|
723
|
+
process7.off(signal, onSignal);
|
|
705
724
|
}
|
|
706
725
|
};
|
|
707
726
|
function onSignal(signal) {
|
|
@@ -714,10 +733,10 @@ function holdSignals(cleanup) {
|
|
|
714
733
|
return;
|
|
715
734
|
held.release();
|
|
716
735
|
cleanup(signal);
|
|
717
|
-
|
|
736
|
+
process7.kill(process7.pid, signal);
|
|
718
737
|
}
|
|
719
738
|
for (const signal of SIGNALS)
|
|
720
|
-
|
|
739
|
+
process7.on(signal, onSignal);
|
|
721
740
|
return held;
|
|
722
741
|
}
|
|
723
742
|
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
@@ -731,7 +750,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
731
750
|
return;
|
|
732
751
|
try {
|
|
733
752
|
if (grouped)
|
|
734
|
-
|
|
753
|
+
process7.kill(-proc.pid, killing);
|
|
735
754
|
else
|
|
736
755
|
proc.kill(killing);
|
|
737
756
|
} catch {}
|
|
@@ -805,31 +824,33 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
|
|
|
805
824
|
var RESET_STYLE = `${ESC}[0m`;
|
|
806
825
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
807
826
|
// ../kit/src/cli.ts
|
|
808
|
-
import
|
|
827
|
+
import { readFileSync, realpathSync } from "fs";
|
|
828
|
+
import { dirname as dirname2, join as join3 } from "path";
|
|
829
|
+
import process10 from "process";
|
|
809
830
|
|
|
810
831
|
// ../kit/src/usage.ts
|
|
811
832
|
import { appendFileSync, mkdirSync } from "fs";
|
|
812
833
|
import { homedir as homedir2 } from "os";
|
|
813
834
|
import { dirname, isAbsolute, join as join2 } from "path";
|
|
814
|
-
import
|
|
835
|
+
import process9 from "process";
|
|
815
836
|
|
|
816
837
|
// ../kit/src/logs.ts
|
|
817
838
|
import { lstatSync, openSync } from "fs";
|
|
818
839
|
import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
|
|
819
840
|
import { homedir, tmpdir } from "os";
|
|
820
841
|
import { join } from "path";
|
|
821
|
-
import
|
|
842
|
+
import process8 from "process";
|
|
822
843
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
823
844
|
var CLI_FOLDER = "kaynooo-cli";
|
|
824
845
|
function isPrivateDirectory(path) {
|
|
825
846
|
try {
|
|
826
847
|
const info = lstatSync(path, { throwIfNoEntry: false });
|
|
827
|
-
return info !== undefined && info.isDirectory() && info.uid === (
|
|
848
|
+
return info !== undefined && info.isDirectory() && info.uid === (process8.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
|
|
828
849
|
} catch {
|
|
829
850
|
return false;
|
|
830
851
|
}
|
|
831
852
|
}
|
|
832
|
-
async function privateLogDirectory(name, env =
|
|
853
|
+
async function privateLogDirectory(name, env = process8.env) {
|
|
833
854
|
const runtime = env.XDG_RUNTIME_DIR;
|
|
834
855
|
const base = runtime === undefined || runtime === "" ? join(homedir(), ".cache", CLI_FOLDER) : join(runtime, CLI_FOLDER);
|
|
835
856
|
const path = join(base, name);
|
|
@@ -869,14 +890,14 @@ var usageError;
|
|
|
869
890
|
function noteUsageError(message) {
|
|
870
891
|
usageError = message;
|
|
871
892
|
}
|
|
872
|
-
function stateHome(env =
|
|
893
|
+
function stateHome(env = process9.env) {
|
|
873
894
|
const dir = env.XDG_STATE_HOME;
|
|
874
895
|
return dir !== undefined && isAbsolute(dir) ? dir : join2(homedir2(), ".local", "state");
|
|
875
896
|
}
|
|
876
|
-
function usagePath(env =
|
|
897
|
+
function usagePath(env = process9.env) {
|
|
877
898
|
return join2(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
878
899
|
}
|
|
879
|
-
function usageRecorded(env =
|
|
900
|
+
function usageRecorded(env = process9.env) {
|
|
880
901
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
881
902
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
882
903
|
}
|
|
@@ -890,7 +911,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
890
911
|
usageError = undefined;
|
|
891
912
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
892
913
|
}
|
|
893
|
-
function recordUsage(entry, env =
|
|
914
|
+
function recordUsage(entry, env = process9.env) {
|
|
894
915
|
if (!usageRecorded(env))
|
|
895
916
|
return;
|
|
896
917
|
try {
|
|
@@ -908,8 +929,8 @@ var LEVEL_OPTIONS = {
|
|
|
908
929
|
};
|
|
909
930
|
var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
|
|
910
931
|
function printError(prefix, message, hint, cause) {
|
|
911
|
-
const colors = paint(
|
|
912
|
-
const styled = takesControlCodes(
|
|
932
|
+
const colors = paint(process10.stderr);
|
|
933
|
+
const styled = takesControlCodes(process10.stderr);
|
|
913
934
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
914
935
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
915
936
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -991,11 +1012,22 @@ async function printCandidates(found) {
|
|
|
991
1012
|
console.log(line);
|
|
992
1013
|
return 0;
|
|
993
1014
|
}
|
|
994
|
-
|
|
1015
|
+
function packageVersion(entry = Bun.main) {
|
|
1016
|
+
for (let dir = dirname2(realpathSync(entry));; dir = dirname2(dir)) {
|
|
1017
|
+
try {
|
|
1018
|
+
const { version } = JSON.parse(readFileSync(join3(dir, "package.json"), "utf8"));
|
|
1019
|
+
if (typeof version === "string")
|
|
1020
|
+
return version;
|
|
1021
|
+
} catch {}
|
|
1022
|
+
if (dirname2(dir) === dir)
|
|
1023
|
+
return "0.0.0";
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
async function runMain({ name, version, run, redact, usage }, argv = process10.argv.slice(2)) {
|
|
995
1027
|
if (argv[0] === COMPLETE)
|
|
996
1028
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
997
1029
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
998
|
-
console.log(version);
|
|
1030
|
+
console.log(version ?? packageVersion());
|
|
999
1031
|
return 0;
|
|
1000
1032
|
}
|
|
1001
1033
|
let code;
|
|
@@ -1004,8 +1036,11 @@ async function runMain({ name, version, run, redact, usage }, argv = process9.ar
|
|
|
1004
1036
|
} catch (error) {
|
|
1005
1037
|
code = reportThrown(name, error, redact, wantsJson(argv));
|
|
1006
1038
|
}
|
|
1007
|
-
if (usage !== false)
|
|
1008
|
-
|
|
1039
|
+
if (usage !== false) {
|
|
1040
|
+
try {
|
|
1041
|
+
recordUsage(usageEntry(name, undefined, argv, code));
|
|
1042
|
+
} catch {}
|
|
1043
|
+
}
|
|
1009
1044
|
return code;
|
|
1010
1045
|
}
|
|
1011
1046
|
// ../kit/src/secrets.ts
|
|
@@ -1015,16 +1050,16 @@ var {Glob } = globalThis.Bun;
|
|
|
1015
1050
|
var SESSION_FILES = new Glob("*.json");
|
|
1016
1051
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1017
1052
|
// package.json
|
|
1018
|
-
var version = "0.
|
|
1053
|
+
var version = "0.12.1";
|
|
1019
1054
|
|
|
1020
1055
|
// src/j.ts
|
|
1021
|
-
import
|
|
1056
|
+
import process15 from "process";
|
|
1022
1057
|
|
|
1023
1058
|
// ../kit/src/fzf.ts
|
|
1024
|
-
import { existsSync, mkdirSync as mkdirSync2, readFileSync, writeFileSync } from "fs";
|
|
1059
|
+
import { existsSync, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
1025
1060
|
import { homedir as homedir3 } from "os";
|
|
1026
|
-
import { dirname as
|
|
1027
|
-
import
|
|
1061
|
+
import { dirname as dirname3, join as join4 } from "path";
|
|
1062
|
+
import process12 from "process";
|
|
1028
1063
|
var REMEMBERED = 20;
|
|
1029
1064
|
function table2(rows) {
|
|
1030
1065
|
const widths = rows[0]?.cells.map((_, index) => Math.max(...rows.map((row) => Bun.stringWidth(row.cells[index])))) ?? [];
|
|
@@ -1079,24 +1114,24 @@ function heightFor(count) {
|
|
|
1079
1114
|
return String(Math.max(15, Math.ceil((count + 4) / 0.6)));
|
|
1080
1115
|
}
|
|
1081
1116
|
function historyFile(name) {
|
|
1082
|
-
return
|
|
1117
|
+
return join4(process12.env.XDG_CACHE_HOME ?? join4(homedir3(), ".cache"), name, "history.json");
|
|
1083
1118
|
}
|
|
1084
1119
|
function history(name) {
|
|
1085
1120
|
try {
|
|
1086
1121
|
const file = historyFile(name);
|
|
1087
|
-
return existsSync(file) ? JSON.parse(
|
|
1122
|
+
return existsSync(file) ? JSON.parse(readFileSync2(file, "utf-8")) : {};
|
|
1088
1123
|
} catch {
|
|
1089
1124
|
return {};
|
|
1090
1125
|
}
|
|
1091
1126
|
}
|
|
1092
1127
|
function runs(name) {
|
|
1093
|
-
return history(name)[
|
|
1128
|
+
return history(name)[process12.cwd()] ?? [];
|
|
1094
1129
|
}
|
|
1095
1130
|
function record(name, run) {
|
|
1096
1131
|
const all = history(name);
|
|
1097
1132
|
const file = historyFile(name);
|
|
1098
|
-
all[
|
|
1099
|
-
mkdirSync2(
|
|
1133
|
+
all[process12.cwd()] = [run, ...(all[process12.cwd()] ?? []).filter((earlier) => earlier.id !== run.id)].slice(0, REMEMBERED);
|
|
1134
|
+
mkdirSync2(dirname3(file), { recursive: true });
|
|
1100
1135
|
writeFileSync(file, JSON.stringify(all));
|
|
1101
1136
|
}
|
|
1102
1137
|
function byRecency(items, previous, idOf) {
|
|
@@ -1119,7 +1154,7 @@ function list(rows) {
|
|
|
1119
1154
|
}
|
|
1120
1155
|
|
|
1121
1156
|
// ../kit/src/prompt.ts
|
|
1122
|
-
import
|
|
1157
|
+
import process13 from "process";
|
|
1123
1158
|
var KEY_SEQUENCES = /\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|[\s\S]/giu;
|
|
1124
1159
|
var CONTROL = /^[\x00-\x1F\x7F]/;
|
|
1125
1160
|
var KEYS = { "\x1B[A": "up", "\x1BOA": "up", "\x1B[B": "down", "\x1BOB": "down", "\r": "enter", "\n": "enter", "\x03": "cancel", "\x1B": "cancel", "\x7F": "erase", "\b": "erase" };
|
|
@@ -1158,7 +1193,7 @@ async function input2(question, { default: fallback, mask = false, validate, ...
|
|
|
1158
1193
|
function answer(colors, question, state, picked) {
|
|
1159
1194
|
return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
|
|
1160
1195
|
}
|
|
1161
|
-
async function ask(question, { hint, terminal =
|
|
1196
|
+
async function ask(question, { hint, terminal = process13 }, render, press) {
|
|
1162
1197
|
const { stdin, stderr } = terminal;
|
|
1163
1198
|
if (stdin.isTTY !== true || stderr.isTTY !== true)
|
|
1164
1199
|
fail(`cannot ask "${question}" off a terminal`, 2, hint);
|
|
@@ -1209,15 +1244,15 @@ async function ask(question, { hint, terminal = process12 }, render, press) {
|
|
|
1209
1244
|
}
|
|
1210
1245
|
|
|
1211
1246
|
// src/job-picker.ts
|
|
1212
|
-
import
|
|
1247
|
+
import process14 from "process";
|
|
1213
1248
|
|
|
1214
1249
|
// src/jobs.ts
|
|
1215
|
-
import { existsSync as existsSync2, readdirSync, readFileSync as
|
|
1216
|
-
import { dirname as
|
|
1250
|
+
import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync3 } from "fs";
|
|
1251
|
+
import { dirname as dirname4, join as join6, resolve as resolvePath } from "path";
|
|
1217
1252
|
|
|
1218
1253
|
// src/steps.ts
|
|
1219
1254
|
import { readdir as readdir2 } from "fs/promises";
|
|
1220
|
-
import { join as
|
|
1255
|
+
import { join as join5 } from "path";
|
|
1221
1256
|
var STEP_NAMES = ["check", "typecheck", "lint", "test"];
|
|
1222
1257
|
var TARGET = /^@?([\w-]+)(?:[ \t][^:=\n]*)?:(?!=)/gm;
|
|
1223
1258
|
var JUSTFILES = ["justfile", "Justfile", ".justfile"];
|
|
@@ -1229,7 +1264,7 @@ var PHPUNIT_CONFIGS = ["phpunit.xml", "phpunit.xml.dist", "phpunit.dist.xml"];
|
|
|
1229
1264
|
var SKIPPED = new Set(["node_modules", "vendor", "dist", "build", "var", "tmp", "coverage"]);
|
|
1230
1265
|
async function readFirst(dir, files) {
|
|
1231
1266
|
for (const file of files) {
|
|
1232
|
-
const handle = Bun.file(
|
|
1267
|
+
const handle = Bun.file(join5(dir, file));
|
|
1233
1268
|
if (await handle.exists())
|
|
1234
1269
|
return { file, text: await handle.text() };
|
|
1235
1270
|
}
|
|
@@ -1237,7 +1272,7 @@ async function readFirst(dir, files) {
|
|
|
1237
1272
|
}
|
|
1238
1273
|
async function read(dir, ...files) {
|
|
1239
1274
|
for (const file of files) {
|
|
1240
|
-
const handle = Bun.file(
|
|
1275
|
+
const handle = Bun.file(join5(dir, file));
|
|
1241
1276
|
if (await handle.exists())
|
|
1242
1277
|
return handle.text();
|
|
1243
1278
|
}
|
|
@@ -1248,7 +1283,7 @@ function scripts(file, text) {
|
|
|
1248
1283
|
const parsed = JSON.parse(text);
|
|
1249
1284
|
return parsed.scripts ?? {};
|
|
1250
1285
|
} catch {
|
|
1251
|
-
|
|
1286
|
+
fail(`${file} is not valid JSON`);
|
|
1252
1287
|
}
|
|
1253
1288
|
}
|
|
1254
1289
|
function targets(text) {
|
|
@@ -1297,7 +1332,7 @@ async function candidates(dir, bin) {
|
|
|
1297
1332
|
}
|
|
1298
1333
|
async function firstFile(dir, names) {
|
|
1299
1334
|
for (const name of names) {
|
|
1300
|
-
if (await Bun.file(
|
|
1335
|
+
if (await Bun.file(join5(dir, name)).exists())
|
|
1301
1336
|
return name;
|
|
1302
1337
|
}
|
|
1303
1338
|
return;
|
|
@@ -1324,9 +1359,9 @@ async function discoverProjects(dir) {
|
|
|
1324
1359
|
for (const entry of entries.toSorted((a, b) => a.name.localeCompare(b.name))) {
|
|
1325
1360
|
if (!entry.isDirectory() || entry.name.startsWith(".") || SKIPPED.has(entry.name))
|
|
1326
1361
|
continue;
|
|
1327
|
-
const steps = await discover(
|
|
1362
|
+
const steps = await discover(join5(dir, entry.name));
|
|
1328
1363
|
if (steps.length > 0)
|
|
1329
|
-
projects.push({ name: entry.name, dir:
|
|
1364
|
+
projects.push({ name: entry.name, dir: join5(dir, entry.name), steps });
|
|
1330
1365
|
}
|
|
1331
1366
|
return projects;
|
|
1332
1367
|
}
|
|
@@ -1369,12 +1404,12 @@ function list2(dir) {
|
|
|
1369
1404
|
}
|
|
1370
1405
|
}
|
|
1371
1406
|
function locate(dir, here, names) {
|
|
1372
|
-
for (let current = dir;; current =
|
|
1373
|
-
const found = names.find((name) => existsSync2(
|
|
1407
|
+
for (let current = dir;; current = join6(current, "..")) {
|
|
1408
|
+
const found = names.find((name) => existsSync2(join6(current, name)));
|
|
1374
1409
|
if (found !== undefined)
|
|
1375
|
-
return
|
|
1410
|
+
return join6(current, found);
|
|
1376
1411
|
const absolute = resolvePath(current);
|
|
1377
|
-
if (!here || existsSync2(
|
|
1412
|
+
if (!here || existsSync2(join6(current, ".git")) || dirname4(absolute) === absolute)
|
|
1378
1413
|
return;
|
|
1379
1414
|
}
|
|
1380
1415
|
}
|
|
@@ -1403,7 +1438,7 @@ function justFlags(dir, here) {
|
|
|
1403
1438
|
if (here)
|
|
1404
1439
|
return [];
|
|
1405
1440
|
const file = list2(dir).find((name) => JUSTFILE.test(name));
|
|
1406
|
-
return file === undefined ? undefined : ["--justfile",
|
|
1441
|
+
return file === undefined ? undefined : ["--justfile", join6(dir, file)];
|
|
1407
1442
|
}
|
|
1408
1443
|
function just(dir, here) {
|
|
1409
1444
|
const flags = justFlags(dir, here);
|
|
@@ -1429,7 +1464,7 @@ function targets2(source) {
|
|
|
1429
1464
|
continue;
|
|
1430
1465
|
}
|
|
1431
1466
|
const colon = rule.indexOf(":");
|
|
1432
|
-
const assignment = rule[colon + 1] === "=" || rule.slice(colon + 1).startsWith(":=");
|
|
1467
|
+
const assignment = rule[colon + 1] === "=" || rule.slice(colon + 1).startsWith(":=") || rule.slice(0, colon).includes("=");
|
|
1433
1468
|
if (colon === -1 || assignment) {
|
|
1434
1469
|
pending = null;
|
|
1435
1470
|
continue;
|
|
@@ -1452,7 +1487,7 @@ function show(source, target) {
|
|
|
1452
1487
|
const hash = line.indexOf("#");
|
|
1453
1488
|
const rule = hash === -1 ? line : line.slice(0, hash);
|
|
1454
1489
|
const colon = rule.indexOf(":");
|
|
1455
|
-
return colon !== -1 && rule[colon + 1] !== "=" && rule.slice(0, colon).trim().split(BLANKS).includes(target);
|
|
1490
|
+
return colon !== -1 && rule[colon + 1] !== "=" && !rule.slice(0, colon).includes("=") && rule.slice(0, colon).trim().split(BLANKS).includes(target);
|
|
1456
1491
|
});
|
|
1457
1492
|
if (start === -1)
|
|
1458
1493
|
return target;
|
|
@@ -1463,10 +1498,10 @@ function show(source, target) {
|
|
|
1463
1498
|
`).trimEnd();
|
|
1464
1499
|
}
|
|
1465
1500
|
function make(dir) {
|
|
1466
|
-
const file = MAKEFILES.find((name) => existsSync2(
|
|
1501
|
+
const file = MAKEFILES.find((name) => existsSync2(join6(dir, name)));
|
|
1467
1502
|
if (file === undefined)
|
|
1468
1503
|
return [];
|
|
1469
|
-
const source =
|
|
1504
|
+
const source = readFileSync3(join6(dir, file), "utf-8");
|
|
1470
1505
|
return build({ kind: "make", tag: "make", runner: ["make"], separated: false, dir }, targets2(source).map((target) => ({ ...target, body: show(source, target.name) })));
|
|
1471
1506
|
}
|
|
1472
1507
|
function manager(dir, manifest) {
|
|
@@ -1474,11 +1509,11 @@ function manager(dir, manifest) {
|
|
|
1474
1509
|
const known = LOCKFILES.find(([, name]) => name === declared);
|
|
1475
1510
|
if (known !== undefined)
|
|
1476
1511
|
return known[1];
|
|
1477
|
-
for (let current = resolvePath(dir);; current =
|
|
1478
|
-
const found = LOCKFILES.find(([file]) => existsSync2(
|
|
1512
|
+
for (let current = resolvePath(dir);; current = dirname4(current)) {
|
|
1513
|
+
const found = LOCKFILES.find(([file]) => existsSync2(join6(current, file)));
|
|
1479
1514
|
if (found !== undefined)
|
|
1480
1515
|
return found[1];
|
|
1481
|
-
if (
|
|
1516
|
+
if (dirname4(current) === current)
|
|
1482
1517
|
return "bun";
|
|
1483
1518
|
}
|
|
1484
1519
|
}
|
|
@@ -1489,38 +1524,38 @@ function packageScripts(dir, here) {
|
|
|
1489
1524
|
const file = locate(dir, here, ["package.json"]);
|
|
1490
1525
|
if (file === undefined)
|
|
1491
1526
|
return [];
|
|
1492
|
-
const manifest = JSON.parse(
|
|
1493
|
-
const tool = manager(
|
|
1527
|
+
const manifest = JSON.parse(readFileSync3(file, "utf-8"));
|
|
1528
|
+
const tool = manager(dirname4(file), manifest);
|
|
1494
1529
|
const items = Object.entries(table3(manifest.scripts)).map(([name, command]) => ({ name, body: text2(command) }));
|
|
1495
|
-
return build({ kind: "package", tag: tool, runner: [tool, "run"], separated: tool === "npm", dir:
|
|
1530
|
+
return build({ kind: "package", tag: tool, runner: [tool, "run"], separated: tool === "npm", dir: dirname4(file) }, items);
|
|
1496
1531
|
}
|
|
1497
1532
|
function composer(dir, here) {
|
|
1498
1533
|
const file = locate(dir, here, ["composer.json"]);
|
|
1499
1534
|
if (file === undefined)
|
|
1500
1535
|
return [];
|
|
1501
|
-
const manifest = JSON.parse(
|
|
1536
|
+
const manifest = JSON.parse(readFileSync3(file, "utf-8"));
|
|
1502
1537
|
const descriptions = table3(manifest["scripts-descriptions"]);
|
|
1503
1538
|
const items = Object.entries(table3(manifest.scripts)).map(([name, command]) => ({ name, doc: field(descriptions, name), body: text2(command) }));
|
|
1504
|
-
return build({ kind: "composer", tag: "composer", runner: ["composer", "run"], separated: true, dir:
|
|
1539
|
+
return build({ kind: "composer", tag: "composer", runner: ["composer", "run"], separated: true, dir: dirname4(file) }, items);
|
|
1505
1540
|
}
|
|
1506
1541
|
function deno(dir, here) {
|
|
1507
1542
|
const file = locate(dir, here, ["deno.json", "deno.jsonc"]);
|
|
1508
1543
|
if (file === undefined)
|
|
1509
1544
|
return [];
|
|
1510
|
-
const manifest = Bun.JSONC.parse(
|
|
1545
|
+
const manifest = Bun.JSONC.parse(readFileSync3(file, "utf-8"));
|
|
1511
1546
|
const items = Object.entries(table3(manifest.tasks)).map(([name, task]) => ({ name, doc: field(task, "description"), body: field(task, "command") ?? text2(task) }));
|
|
1512
|
-
return build({ kind: "deno", tag: "deno", runner: ["deno", "task"], separated: false, dir:
|
|
1547
|
+
return build({ kind: "deno", tag: "deno", runner: ["deno", "task"], separated: false, dir: dirname4(file) }, items);
|
|
1513
1548
|
}
|
|
1514
1549
|
function taskfile(dir, here) {
|
|
1515
1550
|
const file = locate(dir, here, TASKFILES);
|
|
1516
1551
|
if (file === undefined)
|
|
1517
1552
|
return [];
|
|
1518
|
-
const tasks = table3(Bun.YAML.parse(
|
|
1553
|
+
const tasks = table3(Bun.YAML.parse(readFileSync3(file, "utf-8"))?.tasks);
|
|
1519
1554
|
const items = Object.entries(tasks).filter(([, task]) => !(task !== null && typeof task === "object" && task.internal === true)).map(([name, task]) => ({ name, doc: field(task, "desc") ?? field(task, "summary"), body: text2(task) }));
|
|
1520
|
-
return build({ kind: "task", tag: "task", runner: ["task"], separated: true, dir:
|
|
1555
|
+
return build({ kind: "task", tag: "task", runner: ["task"], separated: true, dir: dirname4(file) }, items);
|
|
1521
1556
|
}
|
|
1522
1557
|
function mise(dir, here) {
|
|
1523
|
-
if (!has("mise") || !here && !MISE_FILES.some((name) => existsSync2(
|
|
1558
|
+
if (!has("mise") || !here && !MISE_FILES.some((name) => existsSync2(join6(dir, name))))
|
|
1524
1559
|
return [];
|
|
1525
1560
|
const proc = Bun.spawnSync(["mise", "tasks", "ls", "--json"], { cwd: dir, stderr: "pipe" });
|
|
1526
1561
|
if (!proc.success)
|
|
@@ -1534,15 +1569,15 @@ function pyproject(dir, here) {
|
|
|
1534
1569
|
const file = locate(dir, here, ["pyproject.toml"]);
|
|
1535
1570
|
if (file === undefined)
|
|
1536
1571
|
return [];
|
|
1537
|
-
const manifest = Bun.TOML.parse(
|
|
1572
|
+
const manifest = Bun.TOML.parse(readFileSync3(file, "utf-8"));
|
|
1538
1573
|
const tool = table3(manifest.tool);
|
|
1539
1574
|
const project = table3(manifest.project);
|
|
1540
|
-
const uv = locate(
|
|
1575
|
+
const uv = locate(dirname4(file), true, ["uv.lock"]) !== undefined;
|
|
1541
1576
|
const poe = Object.entries(table3(table3(tool.poe).tasks)).filter(([name]) => !name.startsWith("_")).map(([name, task]) => ({ name, doc: field(task, "help"), body: field(task, "cmd") ?? field(task, "shell") ?? text2(task) }));
|
|
1542
1577
|
const entryPoints = Object.entries(table3(project.scripts)).map(([name, target]) => ({ name, body: text2(target) }));
|
|
1543
1578
|
return [
|
|
1544
|
-
...build({ kind: "poe", tag: "poe", runner: uv ? ["uv", "run", "poe"] : ["poe"], separated: false, dir:
|
|
1545
|
-
...build({ kind: "uv", tag: "uv", runner: ["uv", "run"], separated: false, dir:
|
|
1579
|
+
...build({ kind: "poe", tag: "poe", runner: uv ? ["uv", "run", "poe"] : ["poe"], separated: false, dir: dirname4(file) }, poe),
|
|
1580
|
+
...build({ kind: "uv", tag: "uv", runner: ["uv", "run"], separated: false, dir: dirname4(file) }, entryPoints)
|
|
1546
1581
|
];
|
|
1547
1582
|
}
|
|
1548
1583
|
var READERS = [just, make, packageScripts, composer, deno, taskfile, mise, pyproject];
|
|
@@ -1557,20 +1592,37 @@ var READER_OF = {
|
|
|
1557
1592
|
poe: pyproject,
|
|
1558
1593
|
uv: pyproject
|
|
1559
1594
|
};
|
|
1595
|
+
var MANIFEST_OF = new Map([[just, "justfile"], [make, "Makefile"], [packageScripts, "package.json"], [composer, "composer.json"], [deno, "deno.json"], [taskfile, "Taskfile.yml"], [mise, "mise.toml"], [pyproject, "pyproject.toml"]]);
|
|
1596
|
+
function readOr(read, fallback) {
|
|
1597
|
+
try {
|
|
1598
|
+
return read();
|
|
1599
|
+
} catch {
|
|
1600
|
+
return fallback;
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1560
1603
|
function workspaces() {
|
|
1561
|
-
const manifest =
|
|
1604
|
+
const manifest = readOr(() => JSON.parse(readFileSync3("package.json", "utf-8")), {});
|
|
1562
1605
|
const declared = Array.isArray(manifest.workspaces) ? manifest.workspaces : table3(manifest.workspaces).packages;
|
|
1563
|
-
const pnpm =
|
|
1606
|
+
const pnpm = readOr(() => table3(Bun.YAML.parse(readFileSync3("pnpm-workspace.yaml", "utf-8"))).packages, undefined);
|
|
1564
1607
|
const patterns = [declared, pnpm].flatMap((value) => Array.isArray(value) ? value.filter((pattern) => typeof pattern === "string") : []);
|
|
1565
1608
|
const excluded = patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => new Bun.Glob(pattern.slice(1)));
|
|
1566
|
-
return patterns.filter((pattern) => !pattern.startsWith("!")).flatMap((pattern) => [...new Bun.Glob(`${pattern.replace(TRAILING_SLASHES, "")}/package.json`).scanSync({ cwd: "." })].map((file) =>
|
|
1609
|
+
return patterns.filter((pattern) => !pattern.startsWith("!")).flatMap((pattern) => [...new Bun.Glob(`${pattern.replace(TRAILING_SLASHES, "")}/package.json`).scanSync({ cwd: "." })].map((file) => dirname4(file))).filter((dir) => !dir.split("/").includes("node_modules") && !excluded.some((glob) => glob.match(dir)));
|
|
1567
1610
|
}
|
|
1568
1611
|
function folders() {
|
|
1569
1612
|
return [...new Set([...children(), ...workspaces()])].filter((dir) => dir !== ".");
|
|
1570
1613
|
}
|
|
1614
|
+
function guarded(reader, dir, here, isWarned = false) {
|
|
1615
|
+
try {
|
|
1616
|
+
return reader(dir, here);
|
|
1617
|
+
} catch (error) {
|
|
1618
|
+
if (isWarned)
|
|
1619
|
+
console.error(`j: skipped ${join6(dir, MANIFEST_OF.get(reader) ?? "a manifest")}, it does not parse (${error instanceof Error ? error.message : String(error)})`);
|
|
1620
|
+
return [];
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1571
1623
|
function everything() {
|
|
1572
|
-
const here = READERS.flatMap((reader) => reader
|
|
1573
|
-
const below = folders().flatMap((dir) => READERS.flatMap((reader) => reader
|
|
1624
|
+
const here = READERS.flatMap((reader) => guarded(reader, ".", true, true));
|
|
1625
|
+
const below = folders().flatMap((dir) => READERS.flatMap((reader) => guarded(reader, dir, false, true)));
|
|
1574
1626
|
const seen = new Set;
|
|
1575
1627
|
return [...here, ...below].filter((entry) => {
|
|
1576
1628
|
const id = `${entry.kind} ${entry.dir} ${entry.name}`;
|
|
@@ -1580,7 +1632,7 @@ function everything() {
|
|
|
1580
1632
|
});
|
|
1581
1633
|
}
|
|
1582
1634
|
function readKind(kind, dir) {
|
|
1583
|
-
return READER_OF[kind]
|
|
1635
|
+
return guarded(READER_OF[kind], dir, dir === ".").filter((entry) => entry.kind === kind);
|
|
1584
1636
|
}
|
|
1585
1637
|
function key(entry) {
|
|
1586
1638
|
return entry.dir === "." ? entry.name : `${entry.dir}/${entry.name}`;
|
|
@@ -1610,7 +1662,7 @@ function labelled(entries) {
|
|
|
1610
1662
|
return new Set(entries.map((entry) => entry.tag)).size > 1;
|
|
1611
1663
|
}
|
|
1612
1664
|
function row(entry, labels, signed) {
|
|
1613
|
-
const colors = paint(
|
|
1665
|
+
const colors = paint(process14.stderr);
|
|
1614
1666
|
const keyed = entry.dir === "." ? entry.name : `${colors.dim(`${entry.dir}/`)}${entry.name}`;
|
|
1615
1667
|
return {
|
|
1616
1668
|
hidden: [entry.kind, entry.dir, entry.name, id(entry)],
|
|
@@ -1624,7 +1676,7 @@ function pickJob(entries, narrowed = false) {
|
|
|
1624
1676
|
prompt: `${[...new Set(entries.map((entry) => entry.tag))].join("/")}> `,
|
|
1625
1677
|
searched: labels ? 2 : 1,
|
|
1626
1678
|
...narrowed ? { height: heightFor(entries.length) } : {},
|
|
1627
|
-
preview: `${
|
|
1679
|
+
preview: `${process14.execPath} ${process14.argv[1]} --show {1} {2} {3}`
|
|
1628
1680
|
});
|
|
1629
1681
|
return entries.find((candidate) => id(candidate) === picked?.hidden[3]);
|
|
1630
1682
|
}
|
|
@@ -1646,7 +1698,7 @@ function preview(kind, dir, name) {
|
|
|
1646
1698
|
const entry = readKind(kind, dir).find((candidate) => candidate.name === name);
|
|
1647
1699
|
if (entry === undefined)
|
|
1648
1700
|
return;
|
|
1649
|
-
const colors = paint(
|
|
1701
|
+
const colors = paint(process15.stdout);
|
|
1650
1702
|
console.log(`${colors.dim(`$ ${dir === "." ? "" : `env -C ${dir} `}`)}${colors.bold([...entry.runner, entry.name].join(" "))}
|
|
1651
1703
|
`);
|
|
1652
1704
|
if (entry.body !== undefined)
|
|
@@ -1672,7 +1724,7 @@ function listed2(found) {
|
|
|
1672
1724
|
}));
|
|
1673
1725
|
}
|
|
1674
1726
|
function table4(found) {
|
|
1675
|
-
const colors = paint(
|
|
1727
|
+
const colors = paint(process15.stdout);
|
|
1676
1728
|
const labels = labelled(found);
|
|
1677
1729
|
const rows = found.map((entry) => [...labels ? [entry.tag] : [], key(entry), signature(entry)]);
|
|
1678
1730
|
const widths = rows[0]?.map((_, column) => Math.max(...rows.map((cells) => cells[column].length))) ?? [];
|
|
@@ -1723,7 +1775,7 @@ async function j(argv) {
|
|
|
1723
1775
|
if (found.length === 0)
|
|
1724
1776
|
fail("nothing to run here: no recipe, target, script or task", 1);
|
|
1725
1777
|
const previous = runs("j");
|
|
1726
|
-
const interactive =
|
|
1778
|
+
const interactive = process15.stdin.isTTY && process15.stderr.isTTY && parsed.values.json !== true;
|
|
1727
1779
|
let entry;
|
|
1728
1780
|
let words = given;
|
|
1729
1781
|
if (named === "-") {
|
|
@@ -1776,4 +1828,4 @@ async function j(argv) {
|
|
|
1776
1828
|
}
|
|
1777
1829
|
|
|
1778
1830
|
// src/j-cli.ts
|
|
1779
|
-
|
|
1831
|
+
process16.exitCode = await runMain({ name: "j", version, run: j });
|