@kaynooo/cli-check 0.18.1 → 0.18.2
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 +1 -1
- package/dist/cli.js +83 -57
- package/dist/errs-cli.js +73 -49
- package/dist/fix-cli.js +78 -52
- package/dist/j-cli.js +94 -68
- package/package.json +2 -2
package/dist/j-cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/j-cli.ts
|
|
5
|
-
import
|
|
5
|
+
import process23 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
7
|
import process10 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
@@ -780,9 +780,33 @@ function nearestOption(message, options, allowNegative) {
|
|
|
780
780
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
781
781
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
782
782
|
}
|
|
783
|
+
// ../kit/src/argv.ts
|
|
784
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
785
|
+
import { resolve as resolve3 } from "path";
|
|
786
|
+
import process11 from "process";
|
|
787
|
+
function commandLine() {
|
|
788
|
+
try {
|
|
789
|
+
return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
|
|
790
|
+
} catch {
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
function realPath(word) {
|
|
795
|
+
try {
|
|
796
|
+
return realpathSync(resolve3(word));
|
|
797
|
+
} catch {
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
function scriptArgs(argv = process11.argv.slice(2), cmdline = commandLine(), script = process11.argv[1]) {
|
|
802
|
+
const target = script === undefined ? undefined : realPath(script) ?? script;
|
|
803
|
+
const at = cmdline === undefined || target === undefined ? -1 : cmdline.findIndex((word, index) => index > 0 && (resolve3(word) === script || realPath(word) === target));
|
|
804
|
+
const after = at === -1 ? [] : cmdline.slice(at + 1);
|
|
805
|
+
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
806
|
+
}
|
|
783
807
|
// ../kit/src/process.ts
|
|
784
808
|
import { constants } from "os";
|
|
785
|
-
import
|
|
809
|
+
import process12 from "process";
|
|
786
810
|
var KILL_GRACE_MS = 2000;
|
|
787
811
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
788
812
|
function exitCodeOf(code, signal) {
|
|
@@ -804,7 +828,7 @@ function holdSignals(cleanup) {
|
|
|
804
828
|
},
|
|
805
829
|
release: () => {
|
|
806
830
|
for (const signal of SIGNALS)
|
|
807
|
-
|
|
831
|
+
process12.off(signal, onSignal);
|
|
808
832
|
}
|
|
809
833
|
};
|
|
810
834
|
function onSignal(signal) {
|
|
@@ -817,10 +841,10 @@ function holdSignals(cleanup) {
|
|
|
817
841
|
return;
|
|
818
842
|
held.release();
|
|
819
843
|
cleanup(signal);
|
|
820
|
-
|
|
844
|
+
process12.kill(process12.pid, signal);
|
|
821
845
|
}
|
|
822
846
|
for (const signal of SIGNALS)
|
|
823
|
-
|
|
847
|
+
process12.on(signal, onSignal);
|
|
824
848
|
return held;
|
|
825
849
|
}
|
|
826
850
|
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
@@ -834,7 +858,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
834
858
|
return;
|
|
835
859
|
try {
|
|
836
860
|
if (grouped)
|
|
837
|
-
|
|
861
|
+
process12.kill(-proc.pid, killing);
|
|
838
862
|
else
|
|
839
863
|
proc.kill(killing);
|
|
840
864
|
} catch {}
|
|
@@ -908,33 +932,33 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
|
|
|
908
932
|
var RESET_STYLE = `${ESC}[0m`;
|
|
909
933
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
910
934
|
// ../kit/src/cli.ts
|
|
911
|
-
import { readFileSync as
|
|
935
|
+
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
912
936
|
import { dirname as dirname3, join as join6 } from "path";
|
|
913
|
-
import
|
|
937
|
+
import process15 from "process";
|
|
914
938
|
|
|
915
939
|
// ../kit/src/usage.ts
|
|
916
940
|
import { appendFileSync, mkdirSync } from "fs";
|
|
917
941
|
import { homedir as homedir4 } from "os";
|
|
918
942
|
import { dirname as dirname2, isAbsolute, join as join5 } from "path";
|
|
919
|
-
import
|
|
943
|
+
import process14 from "process";
|
|
920
944
|
|
|
921
945
|
// ../kit/src/logs.ts
|
|
922
946
|
import { lstatSync, openSync } from "fs";
|
|
923
947
|
import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
|
|
924
948
|
import { homedir as homedir3, tmpdir } from "os";
|
|
925
949
|
import { join as join4 } from "path";
|
|
926
|
-
import
|
|
950
|
+
import process13 from "process";
|
|
927
951
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
928
952
|
var CLI_FOLDER = "kaynooo-cli";
|
|
929
953
|
function isPrivateDirectory(path) {
|
|
930
954
|
try {
|
|
931
955
|
const info = lstatSync(path, { throwIfNoEntry: false });
|
|
932
|
-
return info !== undefined && info.isDirectory() && info.uid === (
|
|
956
|
+
return info !== undefined && info.isDirectory() && info.uid === (process13.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
|
|
933
957
|
} catch {
|
|
934
958
|
return false;
|
|
935
959
|
}
|
|
936
960
|
}
|
|
937
|
-
async function privateLogDirectory(name, env =
|
|
961
|
+
async function privateLogDirectory(name, env = process13.env) {
|
|
938
962
|
const runtime = env.XDG_RUNTIME_DIR;
|
|
939
963
|
const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
|
|
940
964
|
const path = join4(base, name);
|
|
@@ -974,14 +998,14 @@ var usageError;
|
|
|
974
998
|
function noteUsageError(message) {
|
|
975
999
|
usageError = message;
|
|
976
1000
|
}
|
|
977
|
-
function stateHome(env =
|
|
1001
|
+
function stateHome(env = process14.env) {
|
|
978
1002
|
const dir = env.XDG_STATE_HOME;
|
|
979
1003
|
return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
|
|
980
1004
|
}
|
|
981
|
-
function usagePath(env =
|
|
1005
|
+
function usagePath(env = process14.env) {
|
|
982
1006
|
return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
983
1007
|
}
|
|
984
|
-
function usageRecorded(env =
|
|
1008
|
+
function usageRecorded(env = process14.env) {
|
|
985
1009
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
986
1010
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
987
1011
|
}
|
|
@@ -995,7 +1019,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
995
1019
|
usageError = undefined;
|
|
996
1020
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
997
1021
|
}
|
|
998
|
-
function recordUsage(entry, env =
|
|
1022
|
+
function recordUsage(entry, env = process14.env) {
|
|
999
1023
|
if (!usageRecorded(env))
|
|
1000
1024
|
return;
|
|
1001
1025
|
try {
|
|
@@ -1013,8 +1037,8 @@ var LEVEL_OPTIONS = {
|
|
|
1013
1037
|
};
|
|
1014
1038
|
var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
|
|
1015
1039
|
function printError(prefix, message, hint, cause) {
|
|
1016
|
-
const colors = paint(
|
|
1017
|
-
const styled = takesControlCodes(
|
|
1040
|
+
const colors = paint(process15.stderr);
|
|
1041
|
+
const styled = takesControlCodes(process15.stderr);
|
|
1018
1042
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1019
1043
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1020
1044
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1058,24 +1082,24 @@ function candidateLine(candidate) {
|
|
|
1058
1082
|
}
|
|
1059
1083
|
function positionalBeingTyped(before, { options, positionals }) {
|
|
1060
1084
|
const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
|
|
1061
|
-
|
|
1085
|
+
const typed = [];
|
|
1062
1086
|
let at = 0;
|
|
1063
1087
|
while (at < before.length) {
|
|
1064
1088
|
const word = before[at];
|
|
1065
1089
|
if (word === "--") {
|
|
1066
|
-
|
|
1090
|
+
typed.push(...before.slice(at + 1));
|
|
1067
1091
|
break;
|
|
1068
1092
|
}
|
|
1069
1093
|
if (!word.startsWith("-"))
|
|
1070
|
-
|
|
1094
|
+
typed.push(word);
|
|
1071
1095
|
else if (takesValue(word))
|
|
1072
1096
|
at++;
|
|
1073
1097
|
at++;
|
|
1074
1098
|
}
|
|
1075
1099
|
const last = positionals.at(-1);
|
|
1076
|
-
if (
|
|
1077
|
-
return positionals[
|
|
1078
|
-
return last?.replace("]", "").endsWith("...") === true ? last : undefined;
|
|
1100
|
+
if (typed.length < positionals.length)
|
|
1101
|
+
return { name: positionals[typed.length], typed };
|
|
1102
|
+
return { name: last?.replace("]", "").endsWith("...") === true ? last : undefined, typed };
|
|
1079
1103
|
}
|
|
1080
1104
|
async function leafCandidates(run, words) {
|
|
1081
1105
|
const completing = await completingOf(run);
|
|
@@ -1083,12 +1107,12 @@ async function leafCandidates(run, words) {
|
|
|
1083
1107
|
return Object.entries(completing.options).map(([name, option]) => option.description === undefined ? `--${name}` : `--${name} ${option.description}`);
|
|
1084
1108
|
const flag = words.at(-2);
|
|
1085
1109
|
const option = flag?.startsWith("-") === true ? Object.entries(completing.options).find(([name, { short }]) => flag === `--${name}` || flag === `-${short}`)?.[1] : undefined;
|
|
1110
|
+
const { name, typed } = positionalBeingTyped(words.slice(0, -1), completing);
|
|
1086
1111
|
if (option?.type === "string") {
|
|
1087
|
-
const values = option.choices === undefined ? await option.candidates?.() : option.choices;
|
|
1112
|
+
const values = option.choices === undefined ? await option.candidates?.(typed) : option.choices;
|
|
1088
1113
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1089
1114
|
}
|
|
1090
|
-
const
|
|
1091
|
-
const values = name === undefined ? undefined : await completing.candidates[name]?.();
|
|
1115
|
+
const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
|
|
1092
1116
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1093
1117
|
}
|
|
1094
1118
|
async function printCandidates(found) {
|
|
@@ -1097,9 +1121,9 @@ async function printCandidates(found) {
|
|
|
1097
1121
|
return 0;
|
|
1098
1122
|
}
|
|
1099
1123
|
function packageVersion(entry = Bun.main) {
|
|
1100
|
-
for (let dir = dirname3(
|
|
1124
|
+
for (let dir = dirname3(realpathSync2(entry));; dir = dirname3(dir)) {
|
|
1101
1125
|
try {
|
|
1102
|
-
const { version } = JSON.parse(
|
|
1126
|
+
const { version } = JSON.parse(readFileSync4(join6(dir, "package.json"), "utf8"));
|
|
1103
1127
|
if (typeof version === "string")
|
|
1104
1128
|
return version;
|
|
1105
1129
|
} catch {}
|
|
@@ -1107,7 +1131,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1107
1131
|
return "0.0.0";
|
|
1108
1132
|
}
|
|
1109
1133
|
}
|
|
1110
|
-
async function runMain({ name, version, run, redact, usage }, argv =
|
|
1134
|
+
async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
|
|
1111
1135
|
if (argv[0] === COMPLETE)
|
|
1112
1136
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1113
1137
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
@@ -1141,16 +1165,16 @@ var {Glob } = globalThis.Bun;
|
|
|
1141
1165
|
var SESSION_FILES = new Glob("*.json");
|
|
1142
1166
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1143
1167
|
// package.json
|
|
1144
|
-
var version = "0.18.
|
|
1168
|
+
var version = "0.18.2";
|
|
1145
1169
|
|
|
1146
1170
|
// src/j.ts
|
|
1147
|
-
import
|
|
1171
|
+
import process22 from "process";
|
|
1148
1172
|
|
|
1149
1173
|
// ../kit/src/picker.ts
|
|
1150
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as
|
|
1174
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync } from "fs";
|
|
1151
1175
|
import { homedir as homedir5 } from "os";
|
|
1152
1176
|
import { dirname as dirname4, join as join7 } from "path";
|
|
1153
|
-
import
|
|
1177
|
+
import process19 from "process";
|
|
1154
1178
|
|
|
1155
1179
|
// ../kit/src/picker/score.ts
|
|
1156
1180
|
var MATCH = 16;
|
|
@@ -1421,11 +1445,11 @@ function chosen(state) {
|
|
|
1421
1445
|
|
|
1422
1446
|
// ../kit/src/picker/terminal.ts
|
|
1423
1447
|
import { openSync as openSync2 } from "fs";
|
|
1424
|
-
import
|
|
1448
|
+
import process18 from "process";
|
|
1425
1449
|
import tty from "tty";
|
|
1426
1450
|
|
|
1427
1451
|
// ../kit/src/picker/preview.ts
|
|
1428
|
-
import
|
|
1452
|
+
import process17 from "process";
|
|
1429
1453
|
|
|
1430
1454
|
// ../kit/src/shell.ts
|
|
1431
1455
|
var SEPARATORS = new Set([`
|
|
@@ -1494,7 +1518,7 @@ async function runPreview(template, line, signal, hidden = []) {
|
|
|
1494
1518
|
${previewCommand(template, line, hidden)}`], { stdin: "ignore", stdout: "pipe", stderr: "ignore", detached: true });
|
|
1495
1519
|
const stop = () => {
|
|
1496
1520
|
try {
|
|
1497
|
-
|
|
1521
|
+
process17.kill(-proc.pid, "SIGKILL");
|
|
1498
1522
|
} catch {
|
|
1499
1523
|
proc.kill();
|
|
1500
1524
|
}
|
|
@@ -1642,7 +1666,7 @@ function openTerminal() {
|
|
|
1642
1666
|
return fail("no terminal to read keys from (/dev/tty)");
|
|
1643
1667
|
}
|
|
1644
1668
|
const keys = Bun.file("/dev/tty").stream().getReader();
|
|
1645
|
-
const out =
|
|
1669
|
+
const out = process18.stderr;
|
|
1646
1670
|
let resize;
|
|
1647
1671
|
async function read(onChunk) {
|
|
1648
1672
|
const decoder = new TextDecoder;
|
|
@@ -1816,9 +1840,9 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
1816
1840
|
const ended = new Promise((resolve) => {
|
|
1817
1841
|
finish = resolve;
|
|
1818
1842
|
});
|
|
1819
|
-
|
|
1843
|
+
process18.once("exit", restore);
|
|
1820
1844
|
for (const signal of SIGNALS2)
|
|
1821
|
-
|
|
1845
|
+
process18.once(signal, stop);
|
|
1822
1846
|
try {
|
|
1823
1847
|
terminal.write(`${PASTE_ON}${MOUSE_ON}`);
|
|
1824
1848
|
terminal.listen(onChunk, () => draw(true));
|
|
@@ -1831,8 +1855,8 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
1831
1855
|
await ended;
|
|
1832
1856
|
} finally {
|
|
1833
1857
|
for (const signal of SIGNALS2)
|
|
1834
|
-
|
|
1835
|
-
|
|
1858
|
+
process18.off(signal, stop);
|
|
1859
|
+
process18.off("exit", restore);
|
|
1836
1860
|
restore();
|
|
1837
1861
|
}
|
|
1838
1862
|
return state.done === "accept" ? { rows: chosen(state), key: state.key, query: state.query } : undefined;
|
|
@@ -1863,23 +1887,23 @@ function heightFor(count) {
|
|
|
1863
1887
|
return String(Math.max(15, Math.ceil((count + 4) / 0.6)));
|
|
1864
1888
|
}
|
|
1865
1889
|
function historyFile(name) {
|
|
1866
|
-
return join7(
|
|
1890
|
+
return join7(process19.env.XDG_CACHE_HOME ?? join7(homedir5(), ".cache"), name, "history.json");
|
|
1867
1891
|
}
|
|
1868
1892
|
function history(name) {
|
|
1869
1893
|
try {
|
|
1870
1894
|
const file = historyFile(name);
|
|
1871
|
-
return existsSync4(file) ? JSON.parse(
|
|
1895
|
+
return existsSync4(file) ? JSON.parse(readFileSync5(file, "utf-8")) : {};
|
|
1872
1896
|
} catch {
|
|
1873
1897
|
return {};
|
|
1874
1898
|
}
|
|
1875
1899
|
}
|
|
1876
1900
|
function runs(name) {
|
|
1877
|
-
return history(name)[
|
|
1901
|
+
return history(name)[process19.cwd()] ?? [];
|
|
1878
1902
|
}
|
|
1879
1903
|
function record(name, run) {
|
|
1880
1904
|
const all = history(name);
|
|
1881
1905
|
const file = historyFile(name);
|
|
1882
|
-
all[
|
|
1906
|
+
all[process19.cwd()] = [run, ...(all[process19.cwd()] ?? []).filter((earlier) => earlier.id !== run.id)].slice(0, REMEMBERED);
|
|
1883
1907
|
mkdirSync2(dirname4(file), { recursive: true });
|
|
1884
1908
|
writeFileSync(file, JSON.stringify(all));
|
|
1885
1909
|
}
|
|
@@ -1903,7 +1927,7 @@ function list(rows) {
|
|
|
1903
1927
|
}
|
|
1904
1928
|
|
|
1905
1929
|
// ../kit/src/prompt.ts
|
|
1906
|
-
import
|
|
1930
|
+
import process20 from "process";
|
|
1907
1931
|
var PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "erase"]);
|
|
1908
1932
|
function readKeys(input, paste = { active: false }) {
|
|
1909
1933
|
return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key));
|
|
@@ -1940,7 +1964,7 @@ async function input2(question, { default: fallback, mask = false, validate, ...
|
|
|
1940
1964
|
function answer(colors, question, state, picked) {
|
|
1941
1965
|
return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
|
|
1942
1966
|
}
|
|
1943
|
-
async function ask(question, { hint, terminal =
|
|
1967
|
+
async function ask(question, { hint, terminal = process20 }, render, press) {
|
|
1944
1968
|
const { stdin, stderr } = terminal;
|
|
1945
1969
|
if (!isInteractive(terminal))
|
|
1946
1970
|
fail(`cannot ask "${question}" off a terminal`, 2, hint);
|
|
@@ -1996,10 +2020,10 @@ async function ask(question, { hint, terminal = process19 }, render, press) {
|
|
|
1996
2020
|
}
|
|
1997
2021
|
|
|
1998
2022
|
// src/job-picker.ts
|
|
1999
|
-
import
|
|
2023
|
+
import process21 from "process";
|
|
2000
2024
|
|
|
2001
2025
|
// src/jobs.ts
|
|
2002
|
-
import { existsSync as existsSync5, readdirSync, readFileSync as
|
|
2026
|
+
import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync6 } from "fs";
|
|
2003
2027
|
import { dirname as dirname5, join as join9, resolve as resolvePath } from "path";
|
|
2004
2028
|
|
|
2005
2029
|
// src/steps.ts
|
|
@@ -2008,6 +2032,7 @@ import { join as join8 } from "path";
|
|
|
2008
2032
|
var STEP_NAMES = ["check", "typecheck", "lint", "test"];
|
|
2009
2033
|
var TARGET = /^@?([\w-]+)(?:[ \t][^:=\n]*)?:(?!=)/gm;
|
|
2010
2034
|
var JUSTFILES = ["justfile", "Justfile", ".justfile"];
|
|
2035
|
+
var TASK_RUNNERS = new Set(["Justfile", "Makefile"]);
|
|
2011
2036
|
var MAKEFILES = ["GNUmakefile", "makefile", "Makefile"];
|
|
2012
2037
|
var CS_FIXER_CONFIGS = [".php-cs-fixer.php", ".php-cs-fixer.dist.php"];
|
|
2013
2038
|
var JUST_TIMEOUT_MS = 1e4;
|
|
@@ -2119,8 +2144,9 @@ async function discoverProjects(dir) {
|
|
|
2119
2144
|
}
|
|
2120
2145
|
async function discover(dir) {
|
|
2121
2146
|
const found = await candidates(dir, "check");
|
|
2147
|
+
const runnerCheck = found.find((candidate) => candidate.name === "check" && TASK_RUNNERS.has(candidate.source));
|
|
2122
2148
|
return STEP_NAMES.flatMap((name) => {
|
|
2123
|
-
const step = found.find((candidate) => candidate.name === name);
|
|
2149
|
+
const step = name === "check" && runnerCheck !== undefined ? runnerCheck : found.find((candidate) => candidate.name === name);
|
|
2124
2150
|
return step === undefined ? [] : [step];
|
|
2125
2151
|
});
|
|
2126
2152
|
}
|
|
@@ -2253,7 +2279,7 @@ function make(dir) {
|
|
|
2253
2279
|
const file = MAKEFILES.find((name) => existsSync5(join9(dir, name)));
|
|
2254
2280
|
if (file === undefined)
|
|
2255
2281
|
return [];
|
|
2256
|
-
const source =
|
|
2282
|
+
const source = readFileSync6(join9(dir, file), "utf-8");
|
|
2257
2283
|
return build({ kind: "make", tag: "make", runner: ["make"], separated: false, dir }, targets2(source).map((target) => ({ ...target, body: show(source, target.name) })));
|
|
2258
2284
|
}
|
|
2259
2285
|
function manager(dir, manifest) {
|
|
@@ -2276,7 +2302,7 @@ function packageScripts(dir, here) {
|
|
|
2276
2302
|
const file = locate(dir, here, ["package.json"]);
|
|
2277
2303
|
if (file === undefined)
|
|
2278
2304
|
return [];
|
|
2279
|
-
const manifest = JSON.parse(
|
|
2305
|
+
const manifest = JSON.parse(readFileSync6(file, "utf-8"));
|
|
2280
2306
|
const tool = manager(dirname5(file), manifest);
|
|
2281
2307
|
const items = Object.entries(table2(manifest.scripts)).map(([name, command]) => ({ name, body: text2(command) }));
|
|
2282
2308
|
return build({ kind: "package", tag: tool, runner: [tool, "run"], separated: tool === "npm", dir: dirname5(file) }, items);
|
|
@@ -2285,7 +2311,7 @@ function composer(dir, here) {
|
|
|
2285
2311
|
const file = locate(dir, here, ["composer.json"]);
|
|
2286
2312
|
if (file === undefined)
|
|
2287
2313
|
return [];
|
|
2288
|
-
const manifest = JSON.parse(
|
|
2314
|
+
const manifest = JSON.parse(readFileSync6(file, "utf-8"));
|
|
2289
2315
|
const descriptions = table2(manifest["scripts-descriptions"]);
|
|
2290
2316
|
const items = Object.entries(table2(manifest.scripts)).map(([name, command]) => ({ name, doc: field(descriptions, name), body: text2(command) }));
|
|
2291
2317
|
return build({ kind: "composer", tag: "composer", runner: ["composer", "run"], separated: true, dir: dirname5(file) }, items);
|
|
@@ -2294,7 +2320,7 @@ function deno(dir, here) {
|
|
|
2294
2320
|
const file = locate(dir, here, ["deno.json", "deno.jsonc"]);
|
|
2295
2321
|
if (file === undefined)
|
|
2296
2322
|
return [];
|
|
2297
|
-
const manifest = Bun.JSONC.parse(
|
|
2323
|
+
const manifest = Bun.JSONC.parse(readFileSync6(file, "utf-8"));
|
|
2298
2324
|
const items = Object.entries(table2(manifest.tasks)).map(([name, task]) => ({ name, doc: field(task, "description"), body: field(task, "command") ?? text2(task) }));
|
|
2299
2325
|
return build({ kind: "deno", tag: "deno", runner: ["deno", "task"], separated: false, dir: dirname5(file) }, items);
|
|
2300
2326
|
}
|
|
@@ -2302,7 +2328,7 @@ function taskfile(dir, here) {
|
|
|
2302
2328
|
const file = locate(dir, here, TASKFILES);
|
|
2303
2329
|
if (file === undefined)
|
|
2304
2330
|
return [];
|
|
2305
|
-
const tasks = table2(Bun.YAML.parse(
|
|
2331
|
+
const tasks = table2(Bun.YAML.parse(readFileSync6(file, "utf-8"))?.tasks);
|
|
2306
2332
|
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) }));
|
|
2307
2333
|
return build({ kind: "task", tag: "task", runner: ["task"], separated: true, dir: dirname5(file) }, items);
|
|
2308
2334
|
}
|
|
@@ -2321,7 +2347,7 @@ function pyproject(dir, here) {
|
|
|
2321
2347
|
const file = locate(dir, here, ["pyproject.toml"]);
|
|
2322
2348
|
if (file === undefined)
|
|
2323
2349
|
return [];
|
|
2324
|
-
const manifest = Bun.TOML.parse(
|
|
2350
|
+
const manifest = Bun.TOML.parse(readFileSync6(file, "utf-8"));
|
|
2325
2351
|
const tool = table2(manifest.tool);
|
|
2326
2352
|
const project = table2(manifest.project);
|
|
2327
2353
|
const uv = locate(dirname5(file), true, ["uv.lock"]) !== undefined;
|
|
@@ -2353,9 +2379,9 @@ function readOr(read, fallback) {
|
|
|
2353
2379
|
}
|
|
2354
2380
|
}
|
|
2355
2381
|
function workspaces() {
|
|
2356
|
-
const manifest = readOr(() => JSON.parse(
|
|
2382
|
+
const manifest = readOr(() => JSON.parse(readFileSync6("package.json", "utf-8")), {});
|
|
2357
2383
|
const declared = Array.isArray(manifest.workspaces) ? manifest.workspaces : table2(manifest.workspaces).packages;
|
|
2358
|
-
const pnpm = readOr(() => table2(Bun.YAML.parse(
|
|
2384
|
+
const pnpm = readOr(() => table2(Bun.YAML.parse(readFileSync6("pnpm-workspace.yaml", "utf-8"))).packages, undefined);
|
|
2359
2385
|
const patterns = [declared, pnpm].flatMap((value) => Array.isArray(value) ? value.filter((pattern) => typeof pattern === "string") : []);
|
|
2360
2386
|
const excluded = patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => new Bun.Glob(pattern.slice(1)));
|
|
2361
2387
|
return patterns.filter((pattern) => !pattern.startsWith("!")).flatMap((pattern) => [...new Bun.Glob(`${pattern.replace(TRAILING_SLASHES, "")}/package.json`).scanSync({ cwd: "." })].map((file) => dirname5(file))).filter((dir) => !dir.split("/").includes("node_modules") && !excluded.some((glob) => glob.match(dir)));
|
|
@@ -2392,7 +2418,7 @@ function key(entry) {
|
|
|
2392
2418
|
function id(entry) {
|
|
2393
2419
|
return `${entry.tag}:${key(entry)}`;
|
|
2394
2420
|
}
|
|
2395
|
-
function
|
|
2421
|
+
function resolve4(entries, named) {
|
|
2396
2422
|
const qualified = QUALIFIED.exec(named);
|
|
2397
2423
|
const tagged = qualified && entries.some((entry) => entry.tag === qualified[1]) ? qualified : undefined;
|
|
2398
2424
|
const pool = tagged ? entries.filter((entry) => entry.tag === tagged[1]) : entries;
|
|
@@ -2401,7 +2427,7 @@ function resolve3(entries, named) {
|
|
|
2401
2427
|
return exact.length > 0 ? exact : pool.filter((entry) => entry.name === rest);
|
|
2402
2428
|
}
|
|
2403
2429
|
function shortest(entries, entry) {
|
|
2404
|
-
const found =
|
|
2430
|
+
const found = resolve4(entries, key(entry));
|
|
2405
2431
|
return found.length === 1 && found[0] === entry ? key(entry) : id(entry);
|
|
2406
2432
|
}
|
|
2407
2433
|
function signature(entry) {
|
|
@@ -2414,7 +2440,7 @@ function labelled(entries) {
|
|
|
2414
2440
|
return new Set(entries.map((entry) => entry.tag)).size > 1;
|
|
2415
2441
|
}
|
|
2416
2442
|
function row(entry, labels, signed) {
|
|
2417
|
-
const colors = paint(
|
|
2443
|
+
const colors = paint(process21.stderr);
|
|
2418
2444
|
const keyed = entry.dir === "." ? entry.name : `${colors.dim(`${entry.dir}/`)}${entry.name}`;
|
|
2419
2445
|
return {
|
|
2420
2446
|
hidden: [entry.kind, entry.dir, entry.name, id(entry)],
|
|
@@ -2428,7 +2454,7 @@ async function pickJob(entries, narrowed = false) {
|
|
|
2428
2454
|
prompt: `${[...new Set(entries.map((entry) => entry.tag))].join("/")}> `,
|
|
2429
2455
|
searched: labels ? 2 : 1,
|
|
2430
2456
|
...narrowed ? { height: heightFor(entries.length) } : {},
|
|
2431
|
-
preview: `${
|
|
2457
|
+
preview: `${process21.execPath} ${process21.argv[1]} --show {1} {2} {3}`
|
|
2432
2458
|
});
|
|
2433
2459
|
return entries.find((candidate) => id(candidate) === picked?.hidden[3]);
|
|
2434
2460
|
}
|
|
@@ -2450,7 +2476,7 @@ function preview(kind, dir, name) {
|
|
|
2450
2476
|
const entry = readKind(kind, dir).find((candidate) => candidate.name === name);
|
|
2451
2477
|
if (entry === undefined)
|
|
2452
2478
|
return;
|
|
2453
|
-
const colors = paint(
|
|
2479
|
+
const colors = paint(process22.stdout);
|
|
2454
2480
|
console.log(`${colors.dim(`$ ${dir === "." ? "" : `env -C ${dir} `}`)}${colors.bold([...entry.runner, entry.name].join(" "))}
|
|
2455
2481
|
`);
|
|
2456
2482
|
if (entry.body !== undefined)
|
|
@@ -2461,7 +2487,7 @@ function preview(kind, dir, name) {
|
|
|
2461
2487
|
function names(found) {
|
|
2462
2488
|
const described = (entry) => entry.doc === null || entry.doc === "" ? entry.tag : entry.doc;
|
|
2463
2489
|
return [...new Set(found.map(key))].flatMap((name) => {
|
|
2464
|
-
const same =
|
|
2490
|
+
const same = resolve4(found, name);
|
|
2465
2491
|
return same.length === 1 ? [[name, described(same[0])]] : [[name, same.map((entry) => entry.tag).join(", ")], ...same.map((entry) => [id(entry), described(entry)])];
|
|
2466
2492
|
});
|
|
2467
2493
|
}
|
|
@@ -2483,7 +2509,7 @@ function listed2(found) {
|
|
|
2483
2509
|
}));
|
|
2484
2510
|
}
|
|
2485
2511
|
function listing(found) {
|
|
2486
|
-
const colors = paint(
|
|
2512
|
+
const colors = paint(process22.stdout);
|
|
2487
2513
|
const labels = labelled(found);
|
|
2488
2514
|
return table(found.map((entry) => [...labels ? [entry.tag] : [], key(entry), signature(entry), colors.dim(entry.doc ?? "")]));
|
|
2489
2515
|
}
|
|
@@ -2553,7 +2579,7 @@ async function j2(argv) {
|
|
|
2553
2579
|
}
|
|
2554
2580
|
entry = await pickJob(byRecency(found, previous, id));
|
|
2555
2581
|
} else {
|
|
2556
|
-
const matching =
|
|
2582
|
+
const matching = resolve4(found, named);
|
|
2557
2583
|
if (matching.length === 0) {
|
|
2558
2584
|
const nearest = closest(named, found.map(key));
|
|
2559
2585
|
fail(`nothing named ${named}${nearest === undefined ? "" : `, did you mean ${nearest}?`}`, 1);
|
|
@@ -2583,4 +2609,4 @@ async function j2(argv) {
|
|
|
2583
2609
|
}
|
|
2584
2610
|
|
|
2585
2611
|
// src/j-cli.ts
|
|
2586
|
-
|
|
2612
|
+
process23.exitCode = await runMain({ name: "j", version, run: j2 });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-check",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.2",
|
|
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.38.1"
|
|
38
38
|
}
|
|
39
39
|
}
|