@kaynooo/cli-check 0.21.1 → 0.22.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/README.md +2 -2
- package/dist/cli.js +91 -29
- package/dist/errs-cli.js +134 -32
- package/dist/j-cli.js +100 -38
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ check --json # [{name, command, in?, ok, ms, log, failed?}] once every step
|
|
|
19
19
|
|
|
20
20
|
## Steps
|
|
21
21
|
|
|
22
|
-
`check`, `typecheck`, `lint` and `test`, run in that order, from the first source that has each one, but for a Justfile or Makefile `check`, which wins over a script of that name: a task runner's check is the repo's whole validation and usually wraps the script, as `check: bun run check -p tsconfig.json` does.
|
|
22
|
+
`check`, `typecheck`, `lint`, `fmt` and `test`, run in that order, from the first source that has each one (`fmt` runs a `fmt:check` or `format:check` script, or a `fmt-check` or `format-check` recipe or target), but for a Justfile or Makefile `check`, which wins over a script of that name: a task runner's check is the repo's whole validation and usually wraps the script, as `check: bun run check -p tsconfig.json` does.
|
|
23
23
|
|
|
24
24
|
| Source | Command |
|
|
25
25
|
| --- | --- |
|
|
@@ -74,7 +74,7 @@ check --fix --in app # run the scripts in this compose service; --host force
|
|
|
74
74
|
check --fix --json # {fixers, changed}, a skipped fixer as {name, command, skipped}
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
The project's own `fix` script, recipe or target when it has one, else its `lint:fix` (or `lint-fix`) and `format` ones, found in the same sources as `check`'s steps. Then the formatters the folder's files call for:
|
|
77
|
+
The project's own `fix` script, recipe or target when it has one, else its `lint:fix` (or `lint-fix`) and `fmt` (or `format`) ones, found in the same sources as `check`'s steps. Then the formatters the folder's files call for:
|
|
78
78
|
|
|
79
79
|
| Fixer | When | Runs |
|
|
80
80
|
| --- | --- | --- |
|
package/dist/cli.js
CHANGED
|
@@ -146,11 +146,14 @@ var init_config = __esm(() => {
|
|
|
146
146
|
// ../kit/src/user-config.ts
|
|
147
147
|
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
148
148
|
import { homedir } from "os";
|
|
149
|
-
import { join as join2 } from "path";
|
|
149
|
+
import { isAbsolute, join as join2 } from "path";
|
|
150
150
|
import process4 from "process";
|
|
151
|
+
function xdgFolder(value, fallback) {
|
|
152
|
+
return value !== undefined && isAbsolute(value) ? value : fallback;
|
|
153
|
+
}
|
|
151
154
|
function configBase(where = {}) {
|
|
152
155
|
const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
|
|
153
|
-
return xdg
|
|
156
|
+
return xdgFolder(xdg, join2(where.home ?? homedir(), ".config"));
|
|
154
157
|
}
|
|
155
158
|
function userConfigPath(bin, where = {}) {
|
|
156
159
|
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
@@ -614,11 +617,20 @@ var init_text2 = __esm(() => {
|
|
|
614
617
|
|
|
615
618
|
// ../kit/src/input.ts
|
|
616
619
|
import process9 from "process";
|
|
620
|
+
function durationMs(text, unit) {
|
|
621
|
+
if (BARE_DURATION.test(text))
|
|
622
|
+
return Number(text) * UNIT_MS[unit];
|
|
623
|
+
if (!DURATION.test(text))
|
|
624
|
+
return 0;
|
|
625
|
+
let ms = 0;
|
|
626
|
+
for (const [, amount, part] of text.matchAll(DURATION_PART))
|
|
627
|
+
ms += Number(amount) * UNIT_MS[part];
|
|
628
|
+
return ms;
|
|
629
|
+
}
|
|
617
630
|
function duration(value, name, fallback, unit = "s") {
|
|
618
631
|
if (value === undefined)
|
|
619
632
|
return fallback;
|
|
620
|
-
const
|
|
621
|
-
const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
|
|
633
|
+
const ms = durationMs(value.trim(), unit);
|
|
622
634
|
if (ms < 1)
|
|
623
635
|
badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
|
|
624
636
|
return ms;
|
|
@@ -634,11 +646,13 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
|
634
646
|
fail(`no file ${path}`);
|
|
635
647
|
return file.text();
|
|
636
648
|
}
|
|
637
|
-
var DURATION, UNIT_MS;
|
|
649
|
+
var BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
|
|
638
650
|
var init_input = __esm(() => {
|
|
639
651
|
init_args();
|
|
640
|
-
|
|
641
|
-
|
|
652
|
+
BARE_DURATION = /^\d+(?:\.\d+)?$/;
|
|
653
|
+
DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
|
|
654
|
+
DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
|
|
655
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
|
|
642
656
|
});
|
|
643
657
|
|
|
644
658
|
// ../kit/src/args.ts
|
|
@@ -884,7 +898,7 @@ function ignoredFolders(extra = [], where = {}) {
|
|
|
884
898
|
return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
|
|
885
899
|
}
|
|
886
900
|
function cacheFolder({ home = homedir5(), env = process18.env } = {}) {
|
|
887
|
-
return env.XDG_CACHE_HOME
|
|
901
|
+
return xdgFolder(env.XDG_CACHE_HOME, join7(home, ".cache"));
|
|
888
902
|
}
|
|
889
903
|
var SKIPPED_FOLDERS;
|
|
890
904
|
var init_folders = __esm(() => {
|
|
@@ -935,10 +949,12 @@ init_format();
|
|
|
935
949
|
init_format();
|
|
936
950
|
|
|
937
951
|
// ../kit/src/process.ts
|
|
952
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
938
953
|
import { constants } from "os";
|
|
939
954
|
import process12 from "process";
|
|
940
955
|
var KILL_GRACE_MS = 2000;
|
|
941
956
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
957
|
+
var GROUP_SIGNALS = new Set(["SIGINT", "SIGHUP"]);
|
|
942
958
|
function exitCodeOf(code, signal) {
|
|
943
959
|
if (code !== null)
|
|
944
960
|
return code;
|
|
@@ -946,6 +962,21 @@ function exitCodeOf(code, signal) {
|
|
|
946
962
|
return 128 + signal;
|
|
947
963
|
return signal === null ? 129 : 128 + constants.signals[signal];
|
|
948
964
|
}
|
|
965
|
+
function groupsOf(pid) {
|
|
966
|
+
try {
|
|
967
|
+
const stat = readFileSync4(`/proc/${pid}/stat`, "utf8");
|
|
968
|
+
const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
|
|
969
|
+
return { group: Number(fields[2]), foreground: Number(fields[5]) };
|
|
970
|
+
} catch {
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
function heardTheTerminal(child) {
|
|
975
|
+
if (child.pid === undefined)
|
|
976
|
+
return false;
|
|
977
|
+
const own = groupsOf("self");
|
|
978
|
+
return own !== undefined && own.group === own.foreground && groupsOf(child.pid)?.group === own.group;
|
|
979
|
+
}
|
|
949
980
|
function holdSignals(cleanup) {
|
|
950
981
|
let received;
|
|
951
982
|
let child;
|
|
@@ -964,7 +995,8 @@ function holdSignals(cleanup) {
|
|
|
964
995
|
function onSignal(signal) {
|
|
965
996
|
received = signal;
|
|
966
997
|
if (child !== undefined) {
|
|
967
|
-
|
|
998
|
+
if (!GROUP_SIGNALS.has(signal) || !heardTheTerminal(child))
|
|
999
|
+
child.kill(signal);
|
|
968
1000
|
return;
|
|
969
1001
|
}
|
|
970
1002
|
if (cleanup === undefined)
|
|
@@ -1020,12 +1052,19 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs,
|
|
|
1020
1052
|
stop();
|
|
1021
1053
|
continue;
|
|
1022
1054
|
}
|
|
1055
|
+
if (state.truncated)
|
|
1056
|
+
continue;
|
|
1057
|
+
let kept = data;
|
|
1023
1058
|
if (state.kept + data.length > maxBytes) {
|
|
1059
|
+
let cut = maxBytes - state.kept;
|
|
1060
|
+
while (cut > 0 && ((data[cut] ?? 0) & 192) === 128)
|
|
1061
|
+
cut--;
|
|
1062
|
+
kept = data.subarray(0, cut);
|
|
1024
1063
|
state.truncated = true;
|
|
1025
|
-
continue;
|
|
1026
1064
|
}
|
|
1027
|
-
state.kept +=
|
|
1028
|
-
|
|
1065
|
+
state.kept += kept.length;
|
|
1066
|
+
if (kept.length > 0)
|
|
1067
|
+
chunks.push({ stream: name, data: kept });
|
|
1029
1068
|
}
|
|
1030
1069
|
};
|
|
1031
1070
|
try {
|
|
@@ -1042,6 +1081,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs,
|
|
|
1042
1081
|
const joined = () => Buffer.concat(chunks.map(({ data }) => data));
|
|
1043
1082
|
let output;
|
|
1044
1083
|
let text;
|
|
1084
|
+
let stdout;
|
|
1045
1085
|
return {
|
|
1046
1086
|
code: exitCodeOf(proc.exitCode, proc.signalCode),
|
|
1047
1087
|
chunks,
|
|
@@ -1052,6 +1092,9 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs,
|
|
|
1052
1092
|
},
|
|
1053
1093
|
get text() {
|
|
1054
1094
|
return text ??= (output ??= joined()).toString();
|
|
1095
|
+
},
|
|
1096
|
+
get stdout() {
|
|
1097
|
+
return stdout ??= Buffer.concat(chunks.filter((chunk) => chunk.stream === "stdout").map((chunk) => chunk.data)).toString();
|
|
1055
1098
|
}
|
|
1056
1099
|
};
|
|
1057
1100
|
}
|
|
@@ -1071,7 +1114,7 @@ init_style();
|
|
|
1071
1114
|
init_format();
|
|
1072
1115
|
// ../kit/src/cli.ts
|
|
1073
1116
|
init_args();
|
|
1074
|
-
import { readFileSync as
|
|
1117
|
+
import { readFileSync as readFileSync5, realpathSync as realpathSync2 } from "fs";
|
|
1075
1118
|
import { dirname as dirname3, join as join6 } from "path";
|
|
1076
1119
|
import process17 from "process";
|
|
1077
1120
|
|
|
@@ -1201,10 +1244,11 @@ init_text2();
|
|
|
1201
1244
|
// ../kit/src/usage.ts
|
|
1202
1245
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1203
1246
|
import { homedir as homedir4 } from "os";
|
|
1204
|
-
import { dirname as dirname2,
|
|
1247
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
1205
1248
|
import process16 from "process";
|
|
1206
1249
|
|
|
1207
1250
|
// ../kit/src/logs.ts
|
|
1251
|
+
init_user_config();
|
|
1208
1252
|
import { lstatSync, openSync } from "fs";
|
|
1209
1253
|
import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
|
|
1210
1254
|
import { homedir as homedir3, tmpdir } from "os";
|
|
@@ -1221,9 +1265,7 @@ function isPrivateDirectory(path) {
|
|
|
1221
1265
|
}
|
|
1222
1266
|
}
|
|
1223
1267
|
async function privateLogDirectory(name, env = process15.env) {
|
|
1224
|
-
const
|
|
1225
|
-
const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
|
|
1226
|
-
const path = join4(base, name);
|
|
1268
|
+
const path = join4(xdgFolder(env.XDG_RUNTIME_DIR, join4(homedir3(), ".cache")), CLI_FOLDER, name);
|
|
1227
1269
|
try {
|
|
1228
1270
|
await mkdir(path, { recursive: true, mode: 448 });
|
|
1229
1271
|
if (isPrivateDirectory(path))
|
|
@@ -1253,6 +1295,7 @@ async function sweepLogs(dir, maxAgeMs = DAY_MS, now = Date.now()) {
|
|
|
1253
1295
|
}
|
|
1254
1296
|
|
|
1255
1297
|
// ../kit/src/usage.ts
|
|
1298
|
+
init_user_config();
|
|
1256
1299
|
var UNKNOWN_OPTION2 = /unknown option '(--[a-z][a-z0-9-]*)[=']/;
|
|
1257
1300
|
var FLAG_NAME = /^(?:--[a-z][a-z0-9-]*|-[a-zA-Z])$/;
|
|
1258
1301
|
var LONGEST_NAME = 40;
|
|
@@ -1261,8 +1304,7 @@ function noteUsageError(message) {
|
|
|
1261
1304
|
usageError = message;
|
|
1262
1305
|
}
|
|
1263
1306
|
function stateHome(env = process16.env) {
|
|
1264
|
-
|
|
1265
|
-
return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
|
|
1307
|
+
return xdgFolder(env.XDG_STATE_HOME, join5(homedir4(), ".local", "state"));
|
|
1266
1308
|
}
|
|
1267
1309
|
function usagePath(env = process16.env) {
|
|
1268
1310
|
return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
@@ -1406,7 +1448,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1406
1448
|
} catch {}
|
|
1407
1449
|
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1408
1450
|
try {
|
|
1409
|
-
const { version } = JSON.parse(
|
|
1451
|
+
const { version } = JSON.parse(readFileSync5(join6(dir, "package.json"), "utf8"));
|
|
1410
1452
|
if (typeof version === "string")
|
|
1411
1453
|
return version;
|
|
1412
1454
|
} catch {}
|
|
@@ -1619,6 +1661,7 @@ init_style();
|
|
|
1619
1661
|
init_text2();
|
|
1620
1662
|
// ../kit/src/secrets.ts
|
|
1621
1663
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1664
|
+
var NOT_PASSWORDS = new Set(["compass", "encompass", "bypass", "overpass", "underpass", "surpass", "trespass"]);
|
|
1622
1665
|
// ../kit/src/sessions.ts
|
|
1623
1666
|
var {Glob } = globalThis.Bun;
|
|
1624
1667
|
var SESSION_FILES = new Glob("*.json");
|
|
@@ -1637,7 +1680,7 @@ init_style();
|
|
|
1637
1680
|
// ../kit/src/workspace-root.ts
|
|
1638
1681
|
init_user_config();
|
|
1639
1682
|
// package.json
|
|
1640
|
-
var version = "0.
|
|
1683
|
+
var version = "0.22.0";
|
|
1641
1684
|
|
|
1642
1685
|
// src/check.ts
|
|
1643
1686
|
import { writeFile as writeFile3 } from "fs/promises";
|
|
@@ -1653,6 +1696,7 @@ var COMMENT_PREFIXES = new Set([";", "&", "|", "(", ")"]);
|
|
|
1653
1696
|
var SAFE_WORD = /^[\w@%+=:,./-]+$/;
|
|
1654
1697
|
var DOUBLE_QUOTED_ESCAPES = new Set(["$", "`", '"', "\\"]);
|
|
1655
1698
|
var KEYWORDS = new Set(["then", "do", "else", "if", "elif", "while", "until", "!", "{", "}"]);
|
|
1699
|
+
var FISH_COMBINERS = new Set(["and", "or", "not"]);
|
|
1656
1700
|
var SHELLS = new Set(["sh", "bash", "zsh", "dash", "ash", "ksh", "fish", "csh", "tcsh", "nu", "xonsh", "elvish", "pwsh", "powershell"]);
|
|
1657
1701
|
var SCANNED_PROGRAMS = new Set(["su", "runuser", "flock"]);
|
|
1658
1702
|
var COMMAND_STRING_PROGRAMS = new Set([...SHELLS, ...SCANNED_PROGRAMS]);
|
|
@@ -1664,6 +1708,7 @@ var FIND_EXEC = new Set(["-exec", "-execdir", "-ok", "-okdir"]);
|
|
|
1664
1708
|
function wrapper(short = "", long = [], operands = 0, runsString = false) {
|
|
1665
1709
|
return { short, long, operands, runsString };
|
|
1666
1710
|
}
|
|
1711
|
+
var RUNNER = { ...wrapper(), afterDashes: true };
|
|
1667
1712
|
var WRAPPERS = new Map([
|
|
1668
1713
|
["command", wrapper()],
|
|
1669
1714
|
["builtin", wrapper()],
|
|
@@ -1685,7 +1730,23 @@ var WRAPPERS = new Map([
|
|
|
1685
1730
|
["parallel", wrapper("jnNSaIPlLdTsC", ["--jobs", "--max-args", "--max-replace-args", "--sshlogin", "--arg-file", "--delimiter", "--colsep"], 0, true)],
|
|
1686
1731
|
["unbuffer", wrapper()],
|
|
1687
1732
|
["systemd-run", wrapper("puEMH", ["--property", "--unit", "--description", "--slice", "--setenv", "--machine", "--host", "--uid", "--gid", "--working-directory", "--nice", "--service-type"])],
|
|
1688
|
-
["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])]
|
|
1733
|
+
["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])],
|
|
1734
|
+
["strace", wrapper("abeEIoOpPsSuUX", ["--trace", "--output", "--attach", "--string-limit", "--user", "--env", "--columns", "--trace-path", "--signal", "--status", "--summary-sort-by", "--summary-columns", "--const-print-style", "--interruptible", "--detach-on"])],
|
|
1735
|
+
["ltrace", wrapper("aeFlnopsuxX", ["--output", "--user", "--library", "--config", "--align", "--indent"])],
|
|
1736
|
+
["taskset", wrapper("", [], 1)],
|
|
1737
|
+
["fakeroot", wrapper("lsib", ["--lib", "--faked"])],
|
|
1738
|
+
["sshpass", wrapper("pfdP")],
|
|
1739
|
+
["coproc", wrapper()],
|
|
1740
|
+
["proxychains", wrapper("f")],
|
|
1741
|
+
["proxychains4", wrapper("f")],
|
|
1742
|
+
["torsocks", wrapper("upaP", ["--user", "--pass", "--address", "--port"])],
|
|
1743
|
+
["chrt", wrapper("TPD", ["--sched-runtime", "--sched-period", "--sched-deadline"], 1)],
|
|
1744
|
+
["unshare", wrapper("SGRw", ["--setuid", "--setgid", "--root", "--wd", "--map-user", "--map-group", "--map-users", "--map-groups", "--propagation", "--setgroups"])],
|
|
1745
|
+
["nsenter", wrapper("tSG", ["--target", "--setuid", "--setgid"])],
|
|
1746
|
+
["out", RUNNER],
|
|
1747
|
+
["slot", RUNNER],
|
|
1748
|
+
["waitfor", RUNNER],
|
|
1749
|
+
["base", RUNNER]
|
|
1689
1750
|
]);
|
|
1690
1751
|
function shellQuote(word) {
|
|
1691
1752
|
return SAFE_WORD.test(word) && !word.startsWith("=") ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
@@ -2021,7 +2082,8 @@ ${body}`;
|
|
|
2021
2082
|
// src/steps.ts
|
|
2022
2083
|
import { readdir as readdir2 } from "fs/promises";
|
|
2023
2084
|
import { join as join10 } from "path";
|
|
2024
|
-
var STEP_NAMES = ["check", "typecheck", "lint", "test"];
|
|
2085
|
+
var STEP_NAMES = ["check", "typecheck", "lint", "fmt", "test"];
|
|
2086
|
+
var STEP_SOURCES = { fmt: ["fmt:check", "format:check", "fmt-check", "format-check"] };
|
|
2025
2087
|
var TARGET2 = /^@?([\w-]+)(?:[ \t][^:=\n]*)?:(?!=)/gm;
|
|
2026
2088
|
var JUSTFILES = ["justfile", "Justfile", ".justfile"];
|
|
2027
2089
|
var TASK_RUNNERS = new Set(["Justfile", "Makefile"]);
|
|
@@ -2138,8 +2200,8 @@ async function discover(dir) {
|
|
|
2138
2200
|
const found = await candidates(dir, "check");
|
|
2139
2201
|
const runnerCheck = found.find((candidate) => candidate.name === "check" && TASK_RUNNERS.has(candidate.source));
|
|
2140
2202
|
return STEP_NAMES.flatMap((name) => {
|
|
2141
|
-
const step = name === "check" && runnerCheck !== undefined ? runnerCheck : found.find((candidate) => candidate.name ===
|
|
2142
|
-
return step === undefined ? [] : [step];
|
|
2203
|
+
const step = name === "check" && runnerCheck !== undefined ? runnerCheck : (STEP_SOURCES[name] ?? [name]).map((each) => found.find((candidate) => candidate.name === each)).find((each) => each !== undefined);
|
|
2204
|
+
return step === undefined ? [] : [{ ...step, name }];
|
|
2143
2205
|
});
|
|
2144
2206
|
}
|
|
2145
2207
|
|
|
@@ -2266,7 +2328,7 @@ async function projectFixers(dir) {
|
|
|
2266
2328
|
const all = named("fix");
|
|
2267
2329
|
if (all !== undefined)
|
|
2268
2330
|
return [all];
|
|
2269
|
-
return [named("lint:fix") ?? named("lint-fix"), named("format")].filter((step) => step !== undefined);
|
|
2331
|
+
return [named("lint:fix") ?? named("lint-fix"), named("fmt") ?? named("format")].filter((step) => step !== undefined);
|
|
2270
2332
|
}
|
|
2271
2333
|
async function toolFixers(dir) {
|
|
2272
2334
|
const fixers = [];
|
|
@@ -2335,7 +2397,7 @@ async function runFixers(values, cwd) {
|
|
|
2335
2397
|
fail("a fixer called check --fix again, which would recurse: give its script another command");
|
|
2336
2398
|
const found = await fixers(cwd);
|
|
2337
2399
|
if (found.length === 0)
|
|
2338
|
-
fail("nothing to fix here: no fix, lint:fix or format script, php-cs-fixer config, Makefile, Justfile, go.mod, Cargo.toml nor ruff config");
|
|
2400
|
+
fail("nothing to fix here: no fix, lint:fix, fmt or format script, php-cs-fixer config, Makefile, Justfile, go.mod, Cargo.toml nor ruff config");
|
|
2339
2401
|
const picked = pick(found, parsed.values.only, "fixer");
|
|
2340
2402
|
const placements = new Map;
|
|
2341
2403
|
for (const fixer of picked)
|
|
@@ -2475,10 +2537,10 @@ async function scriptText(dir, name) {
|
|
|
2475
2537
|
var usage2 = `check [--only <steps>] [--changed] [--failed] [--quiet] [--timeout <duration>] [--slot | --no-slot] [--parallel] [--in <service> | --host] [--list]
|
|
2476
2538
|
check --fix [--only <fixers>] [--timeout <duration>] [--in <service> | --host] [--list]
|
|
2477
2539
|
|
|
2478
|
-
Runs the repo's check, typecheck, lint and test steps, found in package.json scripts, composer.json, a Justfile, a Makefile or the PHP tools' configs; a folder with no steps runs its subfolders' (api/, client/).
|
|
2540
|
+
Runs the repo's check, typecheck, lint, fmt (its fmt:check or format:check script) and test steps, found in package.json scripts, composer.json, a Justfile, a Makefile or the PHP tools' configs; a folder with no steps runs its subfolders' (api/, client/).
|
|
2479
2541
|
A step runs inside the running compose service that mounts its folder and never starts one, and queues for a machine-wide slot when \`slot\` is installed.
|
|
2480
2542
|
A passing step prints one line, a failing one only what failed, and each step's full log is saved to the file its line ends with.
|
|
2481
|
-
With --fix, the project's fix, lint:fix and format scripts run instead, then the formatters its files call for (php-cs-fixer, \`just --fmt\`, go fmt, cargo fmt, ruff), and the files they changed are listed.`;
|
|
2543
|
+
With --fix, the project's fix, lint:fix and fmt or format scripts run instead, then the formatters its files call for (php-cs-fixer, \`just --fmt\`, go fmt, cargo fmt, ruff), and the files they changed are listed.`;
|
|
2482
2544
|
var EXITS = [[0, "every step passed"], [1, "one failed"], [2, "bad usage, no step is found or a step timed out"]];
|
|
2483
2545
|
function slotted(command) {
|
|
2484
2546
|
return `slot -- sh -c ${shellQuote(command)}`;
|
package/dist/errs-cli.js
CHANGED
|
@@ -146,11 +146,14 @@ var init_config = __esm(() => {
|
|
|
146
146
|
// ../kit/src/user-config.ts
|
|
147
147
|
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
148
148
|
import { homedir } from "os";
|
|
149
|
-
import { join as join2 } from "path";
|
|
149
|
+
import { isAbsolute, join as join2 } from "path";
|
|
150
150
|
import process4 from "process";
|
|
151
|
+
function xdgFolder(value, fallback) {
|
|
152
|
+
return value !== undefined && isAbsolute(value) ? value : fallback;
|
|
153
|
+
}
|
|
151
154
|
function configBase(where = {}) {
|
|
152
155
|
const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
|
|
153
|
-
return xdg
|
|
156
|
+
return xdgFolder(xdg, join2(where.home ?? homedir(), ".config"));
|
|
154
157
|
}
|
|
155
158
|
function userConfigPath(bin, where = {}) {
|
|
156
159
|
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
@@ -614,11 +617,20 @@ var init_text2 = __esm(() => {
|
|
|
614
617
|
|
|
615
618
|
// ../kit/src/input.ts
|
|
616
619
|
import process9 from "process";
|
|
620
|
+
function durationMs(text, unit) {
|
|
621
|
+
if (BARE_DURATION.test(text))
|
|
622
|
+
return Number(text) * UNIT_MS[unit];
|
|
623
|
+
if (!DURATION.test(text))
|
|
624
|
+
return 0;
|
|
625
|
+
let ms = 0;
|
|
626
|
+
for (const [, amount, part] of text.matchAll(DURATION_PART))
|
|
627
|
+
ms += Number(amount) * UNIT_MS[part];
|
|
628
|
+
return ms;
|
|
629
|
+
}
|
|
617
630
|
function duration(value, name, fallback, unit = "s") {
|
|
618
631
|
if (value === undefined)
|
|
619
632
|
return fallback;
|
|
620
|
-
const
|
|
621
|
-
const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
|
|
633
|
+
const ms = durationMs(value.trim(), unit);
|
|
622
634
|
if (ms < 1)
|
|
623
635
|
badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
|
|
624
636
|
return ms;
|
|
@@ -634,11 +646,13 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
|
634
646
|
fail(`no file ${path}`);
|
|
635
647
|
return file.text();
|
|
636
648
|
}
|
|
637
|
-
var DURATION, UNIT_MS;
|
|
649
|
+
var BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
|
|
638
650
|
var init_input = __esm(() => {
|
|
639
651
|
init_args();
|
|
640
|
-
|
|
641
|
-
|
|
652
|
+
BARE_DURATION = /^\d+(?:\.\d+)?$/;
|
|
653
|
+
DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
|
|
654
|
+
DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
|
|
655
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
|
|
642
656
|
});
|
|
643
657
|
|
|
644
658
|
// ../kit/src/args.ts
|
|
@@ -884,7 +898,7 @@ function ignoredFolders(extra = [], where = {}) {
|
|
|
884
898
|
return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
|
|
885
899
|
}
|
|
886
900
|
function cacheFolder({ home = homedir5(), env = process18.env } = {}) {
|
|
887
|
-
return env.XDG_CACHE_HOME
|
|
901
|
+
return xdgFolder(env.XDG_CACHE_HOME, join7(home, ".cache"));
|
|
888
902
|
}
|
|
889
903
|
var SKIPPED_FOLDERS;
|
|
890
904
|
var init_folders = __esm(() => {
|
|
@@ -935,10 +949,12 @@ init_format();
|
|
|
935
949
|
init_format();
|
|
936
950
|
|
|
937
951
|
// ../kit/src/process.ts
|
|
952
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
938
953
|
import { constants } from "os";
|
|
939
954
|
import process12 from "process";
|
|
940
955
|
var KILL_GRACE_MS = 2000;
|
|
941
956
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
957
|
+
var GROUP_SIGNALS = new Set(["SIGINT", "SIGHUP"]);
|
|
942
958
|
function exitCodeOf(code, signal) {
|
|
943
959
|
if (code !== null)
|
|
944
960
|
return code;
|
|
@@ -946,6 +962,21 @@ function exitCodeOf(code, signal) {
|
|
|
946
962
|
return 128 + signal;
|
|
947
963
|
return signal === null ? 129 : 128 + constants.signals[signal];
|
|
948
964
|
}
|
|
965
|
+
function groupsOf(pid) {
|
|
966
|
+
try {
|
|
967
|
+
const stat = readFileSync4(`/proc/${pid}/stat`, "utf8");
|
|
968
|
+
const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
|
|
969
|
+
return { group: Number(fields[2]), foreground: Number(fields[5]) };
|
|
970
|
+
} catch {
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
function heardTheTerminal(child) {
|
|
975
|
+
if (child.pid === undefined)
|
|
976
|
+
return false;
|
|
977
|
+
const own = groupsOf("self");
|
|
978
|
+
return own !== undefined && own.group === own.foreground && groupsOf(child.pid)?.group === own.group;
|
|
979
|
+
}
|
|
949
980
|
function holdSignals(cleanup) {
|
|
950
981
|
let received;
|
|
951
982
|
let child;
|
|
@@ -964,7 +995,8 @@ function holdSignals(cleanup) {
|
|
|
964
995
|
function onSignal(signal) {
|
|
965
996
|
received = signal;
|
|
966
997
|
if (child !== undefined) {
|
|
967
|
-
|
|
998
|
+
if (!GROUP_SIGNALS.has(signal) || !heardTheTerminal(child))
|
|
999
|
+
child.kill(signal);
|
|
968
1000
|
return;
|
|
969
1001
|
}
|
|
970
1002
|
if (cleanup === undefined)
|
|
@@ -1020,12 +1052,19 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs,
|
|
|
1020
1052
|
stop();
|
|
1021
1053
|
continue;
|
|
1022
1054
|
}
|
|
1055
|
+
if (state.truncated)
|
|
1056
|
+
continue;
|
|
1057
|
+
let kept = data;
|
|
1023
1058
|
if (state.kept + data.length > maxBytes) {
|
|
1059
|
+
let cut = maxBytes - state.kept;
|
|
1060
|
+
while (cut > 0 && ((data[cut] ?? 0) & 192) === 128)
|
|
1061
|
+
cut--;
|
|
1062
|
+
kept = data.subarray(0, cut);
|
|
1024
1063
|
state.truncated = true;
|
|
1025
|
-
continue;
|
|
1026
1064
|
}
|
|
1027
|
-
state.kept +=
|
|
1028
|
-
|
|
1065
|
+
state.kept += kept.length;
|
|
1066
|
+
if (kept.length > 0)
|
|
1067
|
+
chunks.push({ stream: name, data: kept });
|
|
1029
1068
|
}
|
|
1030
1069
|
};
|
|
1031
1070
|
try {
|
|
@@ -1042,6 +1081,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs,
|
|
|
1042
1081
|
const joined = () => Buffer.concat(chunks.map(({ data }) => data));
|
|
1043
1082
|
let output;
|
|
1044
1083
|
let text;
|
|
1084
|
+
let stdout;
|
|
1045
1085
|
return {
|
|
1046
1086
|
code: exitCodeOf(proc.exitCode, proc.signalCode),
|
|
1047
1087
|
chunks,
|
|
@@ -1052,6 +1092,9 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs,
|
|
|
1052
1092
|
},
|
|
1053
1093
|
get text() {
|
|
1054
1094
|
return text ??= (output ??= joined()).toString();
|
|
1095
|
+
},
|
|
1096
|
+
get stdout() {
|
|
1097
|
+
return stdout ??= Buffer.concat(chunks.filter((chunk) => chunk.stream === "stdout").map((chunk) => chunk.data)).toString();
|
|
1055
1098
|
}
|
|
1056
1099
|
};
|
|
1057
1100
|
}
|
|
@@ -1071,7 +1114,7 @@ init_style();
|
|
|
1071
1114
|
init_format();
|
|
1072
1115
|
// ../kit/src/cli.ts
|
|
1073
1116
|
init_args();
|
|
1074
|
-
import { readFileSync as
|
|
1117
|
+
import { readFileSync as readFileSync5, realpathSync as realpathSync2 } from "fs";
|
|
1075
1118
|
import { dirname as dirname3, join as join6 } from "path";
|
|
1076
1119
|
import process17 from "process";
|
|
1077
1120
|
|
|
@@ -1201,10 +1244,11 @@ init_text2();
|
|
|
1201
1244
|
// ../kit/src/usage.ts
|
|
1202
1245
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1203
1246
|
import { homedir as homedir4 } from "os";
|
|
1204
|
-
import { dirname as dirname2,
|
|
1247
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
1205
1248
|
import process16 from "process";
|
|
1206
1249
|
|
|
1207
1250
|
// ../kit/src/logs.ts
|
|
1251
|
+
init_user_config();
|
|
1208
1252
|
import { lstatSync, openSync } from "fs";
|
|
1209
1253
|
import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
|
|
1210
1254
|
import { homedir as homedir3, tmpdir } from "os";
|
|
@@ -1221,9 +1265,7 @@ function isPrivateDirectory(path) {
|
|
|
1221
1265
|
}
|
|
1222
1266
|
}
|
|
1223
1267
|
async function privateLogDirectory(name, env = process15.env) {
|
|
1224
|
-
const
|
|
1225
|
-
const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
|
|
1226
|
-
const path = join4(base, name);
|
|
1268
|
+
const path = join4(xdgFolder(env.XDG_RUNTIME_DIR, join4(homedir3(), ".cache")), CLI_FOLDER, name);
|
|
1227
1269
|
try {
|
|
1228
1270
|
await mkdir(path, { recursive: true, mode: 448 });
|
|
1229
1271
|
if (isPrivateDirectory(path))
|
|
@@ -1253,6 +1295,7 @@ async function sweepLogs(dir, maxAgeMs = DAY_MS, now = Date.now()) {
|
|
|
1253
1295
|
}
|
|
1254
1296
|
|
|
1255
1297
|
// ../kit/src/usage.ts
|
|
1298
|
+
init_user_config();
|
|
1256
1299
|
var UNKNOWN_OPTION2 = /unknown option '(--[a-z][a-z0-9-]*)[=']/;
|
|
1257
1300
|
var FLAG_NAME = /^(?:--[a-z][a-z0-9-]*|-[a-zA-Z])$/;
|
|
1258
1301
|
var LONGEST_NAME = 40;
|
|
@@ -1261,8 +1304,7 @@ function noteUsageError(message) {
|
|
|
1261
1304
|
usageError = message;
|
|
1262
1305
|
}
|
|
1263
1306
|
function stateHome(env = process16.env) {
|
|
1264
|
-
|
|
1265
|
-
return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
|
|
1307
|
+
return xdgFolder(env.XDG_STATE_HOME, join5(homedir4(), ".local", "state"));
|
|
1266
1308
|
}
|
|
1267
1309
|
function usagePath(env = process16.env) {
|
|
1268
1310
|
return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
@@ -1406,7 +1448,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1406
1448
|
} catch {}
|
|
1407
1449
|
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1408
1450
|
try {
|
|
1409
|
-
const { version } = JSON.parse(
|
|
1451
|
+
const { version } = JSON.parse(readFileSync5(join6(dir, "package.json"), "utf8"));
|
|
1410
1452
|
if (typeof version === "string")
|
|
1411
1453
|
return version;
|
|
1412
1454
|
} catch {}
|
|
@@ -1619,6 +1661,7 @@ init_style();
|
|
|
1619
1661
|
init_text2();
|
|
1620
1662
|
// ../kit/src/secrets.ts
|
|
1621
1663
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1664
|
+
var NOT_PASSWORDS = new Set(["compass", "encompass", "bypass", "overpass", "underpass", "surpass", "trespass"]);
|
|
1622
1665
|
// ../kit/src/sessions.ts
|
|
1623
1666
|
var {Glob } = globalThis.Bun;
|
|
1624
1667
|
var SESSION_FILES = new Glob("*.json");
|
|
@@ -1637,7 +1680,7 @@ init_style();
|
|
|
1637
1680
|
// ../kit/src/workspace-root.ts
|
|
1638
1681
|
init_user_config();
|
|
1639
1682
|
// package.json
|
|
1640
|
-
var version = "0.
|
|
1683
|
+
var version = "0.22.0";
|
|
1641
1684
|
|
|
1642
1685
|
// src/errs.ts
|
|
1643
1686
|
import { relative as relative2 } from "path";
|
|
@@ -1658,6 +1701,7 @@ var COMMENT_PREFIXES = new Set([";", "&", "|", "(", ")"]);
|
|
|
1658
1701
|
var SAFE_WORD = /^[\w@%+=:,./-]+$/;
|
|
1659
1702
|
var DOUBLE_QUOTED_ESCAPES = new Set(["$", "`", '"', "\\"]);
|
|
1660
1703
|
var KEYWORDS = new Set(["then", "do", "else", "if", "elif", "while", "until", "!", "{", "}"]);
|
|
1704
|
+
var FISH_COMBINERS = new Set(["and", "or", "not"]);
|
|
1661
1705
|
var SHELLS = new Set(["sh", "bash", "zsh", "dash", "ash", "ksh", "fish", "csh", "tcsh", "nu", "xonsh", "elvish", "pwsh", "powershell"]);
|
|
1662
1706
|
var SCANNED_PROGRAMS = new Set(["su", "runuser", "flock"]);
|
|
1663
1707
|
var COMMAND_STRING_PROGRAMS = new Set([...SHELLS, ...SCANNED_PROGRAMS]);
|
|
@@ -1669,6 +1713,7 @@ var FIND_EXEC = new Set(["-exec", "-execdir", "-ok", "-okdir"]);
|
|
|
1669
1713
|
function wrapper(short = "", long = [], operands = 0, runsString = false) {
|
|
1670
1714
|
return { short, long, operands, runsString };
|
|
1671
1715
|
}
|
|
1716
|
+
var RUNNER = { ...wrapper(), afterDashes: true };
|
|
1672
1717
|
var WRAPPERS = new Map([
|
|
1673
1718
|
["command", wrapper()],
|
|
1674
1719
|
["builtin", wrapper()],
|
|
@@ -1690,7 +1735,23 @@ var WRAPPERS = new Map([
|
|
|
1690
1735
|
["parallel", wrapper("jnNSaIPlLdTsC", ["--jobs", "--max-args", "--max-replace-args", "--sshlogin", "--arg-file", "--delimiter", "--colsep"], 0, true)],
|
|
1691
1736
|
["unbuffer", wrapper()],
|
|
1692
1737
|
["systemd-run", wrapper("puEMH", ["--property", "--unit", "--description", "--slice", "--setenv", "--machine", "--host", "--uid", "--gid", "--working-directory", "--nice", "--service-type"])],
|
|
1693
|
-
["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])]
|
|
1738
|
+
["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])],
|
|
1739
|
+
["strace", wrapper("abeEIoOpPsSuUX", ["--trace", "--output", "--attach", "--string-limit", "--user", "--env", "--columns", "--trace-path", "--signal", "--status", "--summary-sort-by", "--summary-columns", "--const-print-style", "--interruptible", "--detach-on"])],
|
|
1740
|
+
["ltrace", wrapper("aeFlnopsuxX", ["--output", "--user", "--library", "--config", "--align", "--indent"])],
|
|
1741
|
+
["taskset", wrapper("", [], 1)],
|
|
1742
|
+
["fakeroot", wrapper("lsib", ["--lib", "--faked"])],
|
|
1743
|
+
["sshpass", wrapper("pfdP")],
|
|
1744
|
+
["coproc", wrapper()],
|
|
1745
|
+
["proxychains", wrapper("f")],
|
|
1746
|
+
["proxychains4", wrapper("f")],
|
|
1747
|
+
["torsocks", wrapper("upaP", ["--user", "--pass", "--address", "--port"])],
|
|
1748
|
+
["chrt", wrapper("TPD", ["--sched-runtime", "--sched-period", "--sched-deadline"], 1)],
|
|
1749
|
+
["unshare", wrapper("SGRw", ["--setuid", "--setgid", "--root", "--wd", "--map-user", "--map-group", "--map-users", "--map-groups", "--propagation", "--setgroups"])],
|
|
1750
|
+
["nsenter", wrapper("tSG", ["--target", "--setuid", "--setgid"])],
|
|
1751
|
+
["out", RUNNER],
|
|
1752
|
+
["slot", RUNNER],
|
|
1753
|
+
["waitfor", RUNNER],
|
|
1754
|
+
["base", RUNNER]
|
|
1694
1755
|
]);
|
|
1695
1756
|
function shellQuote(word) {
|
|
1696
1757
|
return SAFE_WORD.test(word) && !word.startsWith("=") ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
@@ -2217,6 +2278,7 @@ var TSC_PRETTY_ERROR = /^(.+?):(\d+):(\d+) - error (TS\d+): (.*)$/;
|
|
|
2217
2278
|
var TSC_SOURCE_LINE = /^\d+ /;
|
|
2218
2279
|
var ESLINT_FIELDS = /^ +(\d+):(\d+) +(error|warning) +(\S.*)$/;
|
|
2219
2280
|
var ESLINT_RULE = / {2,}(\S+)$/;
|
|
2281
|
+
var ESLINT_FILE = /^(?:\/|~\/|\.{1,2}[/\\]|[a-z]:\\)|^[^\s/\\]+[/\\]\S*$/i;
|
|
2220
2282
|
var BUN_TEST_EXPECTED = /^Expected: (.*)$/;
|
|
2221
2283
|
var BUN_TEST_RECEIVED = /^Received: (.*)$/;
|
|
2222
2284
|
var BUN_TEST_FRAME = /^\s+at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
|
|
@@ -2226,6 +2288,7 @@ var GO_LINTER = /^(.*\S)\s+\(([a-z][\w-]*)\)$/;
|
|
|
2226
2288
|
var GO_NOISE = /^# \S+(?: \[\S+\])?$/;
|
|
2227
2289
|
var ARROW = /^\s*--> (.+?):(\d+):(\d+)$/;
|
|
2228
2290
|
var CARGO_HEADER = /^(error|warning)(?:\[([\w-]+)\])?: (.*)$/;
|
|
2291
|
+
var LINE_BREAK = /\r?\n/;
|
|
2229
2292
|
var CONTINUATION = /^\s+\S/;
|
|
2230
2293
|
var MAX_CONTINUATION = 20;
|
|
2231
2294
|
var KAY_SUMMARY = /^(?:\d+ errors?(?:, \d+ warnings?)?|\d+ warnings?)(?:, failing under --deny-warnings)?$|^checked with /;
|
|
@@ -2239,7 +2302,9 @@ var PYTEST_BANNER = /^={3,} (.*?) ={3,}$/;
|
|
|
2239
2302
|
var PYTEST_FAILURES = new Set(["FAILURES", "ERRORS"]);
|
|
2240
2303
|
var PYTEST_SUMMARY_LINE = /^(?:FAILED|ERROR) \S/;
|
|
2241
2304
|
var PYTEST_FRAME = /^in \S/;
|
|
2242
|
-
var PYTEST_SECTION = /^_{3,} .* _{3,}$/;
|
|
2305
|
+
var PYTEST_SECTION = /^_{3,} (.*) _{3,}$/;
|
|
2306
|
+
var PYTEST_SUMMARY = /^(?:FAILED|ERROR) ([^\s:]+?\.py)(?:::(.*)| - (.*))?$/;
|
|
2307
|
+
var PYTEST_ERROR_SECTION = /^ERROR (?:at (?:setup|teardown) of |collecting )/;
|
|
2243
2308
|
var PYTEST_EXCEPTION_END = /[\s:]/;
|
|
2244
2309
|
var PYTEST_NOISE = /^(?:platform |rootdir: |collected |plugins: |configfile: |cachedir: |\S+\.pyi? [.FEsxXR]+ +\[ *\d+%\]$|\S+\.py:\d+: $)/;
|
|
2245
2310
|
var GENERIC_LINE = /^(\S[^:]*):(\d+)(?::(\d+))?: (?:fatal )?(error|warning|note): (.*)$/;
|
|
@@ -2268,14 +2333,12 @@ var collectBunCheck = (lines, used) => {
|
|
|
2268
2333
|
var collectBunTest = (lines, used) => {
|
|
2269
2334
|
const errors = [];
|
|
2270
2335
|
const seen = new Set;
|
|
2336
|
+
const names = new Set;
|
|
2271
2337
|
for (const [index, line] of lines.entries()) {
|
|
2272
2338
|
if (!line.startsWith("(fail) "))
|
|
2273
2339
|
continue;
|
|
2274
2340
|
used.add(index);
|
|
2275
2341
|
const test = line.slice("(fail) ".length).replace(DURATION3, "");
|
|
2276
|
-
if (seen.has(test))
|
|
2277
|
-
continue;
|
|
2278
|
-
seen.add(test);
|
|
2279
2342
|
const start = lines.findLastIndex((text, at) => at < index && BOUNDARY2.test(text)) + 1;
|
|
2280
2343
|
const block = lines.slice(start, index);
|
|
2281
2344
|
const failure = block.findIndex((text) => text.startsWith("error:"));
|
|
@@ -2283,6 +2346,11 @@ var collectBunTest = (lines, used) => {
|
|
|
2283
2346
|
used.add(at);
|
|
2284
2347
|
const frame = block.slice(Math.max(failure, 0)).map((text) => BUN_TEST_FRAME.exec(text)).find((match) => match !== null);
|
|
2285
2348
|
const header = lines.slice(0, index).findLast((text) => BUN_TEST_FILE.test(text));
|
|
2349
|
+
const key = `${header ?? ""}\x00${test}`;
|
|
2350
|
+
if (seen.has(key) || failure === -1 && names.has(test))
|
|
2351
|
+
continue;
|
|
2352
|
+
seen.add(key);
|
|
2353
|
+
names.add(test);
|
|
2286
2354
|
const expected = block.map((text) => BUN_TEST_EXPECTED.exec(text)?.[1]).find((text) => text !== undefined);
|
|
2287
2355
|
const received = block.map((text) => BUN_TEST_RECEIVED.exec(text)?.[1]).find((text) => text !== undefined);
|
|
2288
2356
|
const reason = failure === -1 ? "failed" : (block[failure] ?? "").slice("error:".length).trim();
|
|
@@ -2337,7 +2405,7 @@ var collectEslint = (lines, used) => {
|
|
|
2337
2405
|
errors.push({ tool: "eslint", file: (lines[file] ?? "").trim(), line: Number(match[1]), column: Number(match[2]), rule: rule?.[1], severity: match[3] === "warning" ? "warning" : "error", message: rule === null ? text : text.slice(0, rule.index) });
|
|
2338
2406
|
used.add(index);
|
|
2339
2407
|
used.add(file);
|
|
2340
|
-
} else if (!isNoise(line)) {
|
|
2408
|
+
} else if (!isNoise(line) && !line.includes(": ") && ESLINT_FILE.test(line.trimEnd())) {
|
|
2341
2409
|
file = index;
|
|
2342
2410
|
}
|
|
2343
2411
|
}
|
|
@@ -2397,6 +2465,14 @@ var collectRuff = (lines, used) => {
|
|
|
2397
2465
|
};
|
|
2398
2466
|
var collectPytest = (lines, used) => {
|
|
2399
2467
|
const errors = [];
|
|
2468
|
+
const silent = new Map;
|
|
2469
|
+
let section;
|
|
2470
|
+
const closeSection = () => {
|
|
2471
|
+
if (section === undefined || errors.length !== section.errors)
|
|
2472
|
+
return;
|
|
2473
|
+
const key = section.title.replace(PYTEST_ERROR_SECTION, "");
|
|
2474
|
+
silent.set(key, (silent.get(key) ?? 0) + 1);
|
|
2475
|
+
};
|
|
2400
2476
|
const title = (line) => PYTEST_BANNER.exec(line ?? "")?.[1];
|
|
2401
2477
|
const start = lines.findIndex((line) => PYTEST_FAILURES.has(title(line) ?? ""));
|
|
2402
2478
|
if (start === -1)
|
|
@@ -2424,8 +2500,12 @@ var collectPytest = (lines, used) => {
|
|
|
2424
2500
|
const text = first === "" || first.startsWith(exception) ? first || (location[3] ?? "") : `${location[3] ?? ""}: ${first}`;
|
|
2425
2501
|
errors.push({ tool: "pytest", file: location[1] ?? "", line: Number(location[2]), column: 0, severity: "error", message: text });
|
|
2426
2502
|
}
|
|
2427
|
-
|
|
2503
|
+
const opened = PYTEST_SECTION.exec(line);
|
|
2504
|
+
if (opened !== null) {
|
|
2428
2505
|
frame = undefined;
|
|
2506
|
+
closeSection();
|
|
2507
|
+
section = { title: opened[1] ?? "", errors: errors.length };
|
|
2508
|
+
}
|
|
2429
2509
|
if (line.trim() !== "")
|
|
2430
2510
|
message = [];
|
|
2431
2511
|
}
|
|
@@ -2433,12 +2513,35 @@ var collectPytest = (lines, used) => {
|
|
|
2433
2513
|
}
|
|
2434
2514
|
if (frame !== undefined && message.length > 0)
|
|
2435
2515
|
errors.push({ tool: "pytest", ...frame, column: 0, severity: "error", message: message[0] ?? "" });
|
|
2516
|
+
closeSection();
|
|
2436
2517
|
for (let index = stop;index < lines.length; index++) {
|
|
2437
|
-
if (PYTEST_SUMMARY_LINE.test(lines[index] ?? ""))
|
|
2438
|
-
|
|
2518
|
+
if (!PYTEST_SUMMARY_LINE.test(lines[index] ?? ""))
|
|
2519
|
+
continue;
|
|
2520
|
+
used.add(index);
|
|
2521
|
+
const [, file = "", rest, fileReason] = PYTEST_SUMMARY.exec(lines[index] ?? "") ?? [];
|
|
2522
|
+
const parts = summaryParts(file, rest, fileReason, silent);
|
|
2523
|
+
if (parts === undefined)
|
|
2524
|
+
continue;
|
|
2525
|
+
const { key, name, reason } = parts;
|
|
2526
|
+
const left = silent.get(key) ?? 0;
|
|
2527
|
+
silent.set(key, left - 1);
|
|
2528
|
+
errors.push({ tool: "pytest", file, line: 0, column: 0, severity: "error", message: reason ?? "failed", test: name === undefined ? file : `${file}::${name}` });
|
|
2439
2529
|
}
|
|
2440
2530
|
return errors;
|
|
2441
2531
|
};
|
|
2532
|
+
function summaryParts(file, rest, fileReason, silent) {
|
|
2533
|
+
const keyOf = (name) => name === undefined ? file : name.replaceAll("::", ".");
|
|
2534
|
+
const candidates = [];
|
|
2535
|
+
if (rest === undefined) {
|
|
2536
|
+
candidates.push({ name: undefined, reason: fileReason });
|
|
2537
|
+
} else {
|
|
2538
|
+
for (let at = rest.indexOf(" - ");at !== -1; at = rest.indexOf(" - ", at + 1))
|
|
2539
|
+
candidates.push({ name: rest.slice(0, at), reason: rest.slice(at + 3) });
|
|
2540
|
+
candidates.push({ name: rest, reason: undefined });
|
|
2541
|
+
}
|
|
2542
|
+
const found = candidates.find((candidate) => (silent.get(keyOf(candidate.name)) ?? 0) > 0);
|
|
2543
|
+
return found === undefined ? undefined : { key: keyOf(found.name), ...found };
|
|
2544
|
+
}
|
|
2442
2545
|
var collectGeneric = (lines, used) => {
|
|
2443
2546
|
const errors = [];
|
|
2444
2547
|
for (const [index, line] of lines.entries()) {
|
|
@@ -2457,8 +2560,7 @@ var collectGeneric = (lines, used) => {
|
|
|
2457
2560
|
};
|
|
2458
2561
|
var COLLECTORS = [collectBunCheck, collectBunTest, collectVitest, collectPlaywright, collectPhpunit, collectPhpstan, collectCsFixer, collectPytest, collectArrowed, collectRuff, collectGo, collectTsc, collectEslint, collectGeneric];
|
|
2459
2562
|
function parseErrors(output) {
|
|
2460
|
-
const lines = stripAnsi(output).split(
|
|
2461
|
-
`);
|
|
2563
|
+
const lines = stripAnsi(output).split(LINE_BREAK);
|
|
2462
2564
|
if (BASH_ECHO2.test(lines[0] ?? ""))
|
|
2463
2565
|
lines.shift();
|
|
2464
2566
|
const used = new Set;
|
package/dist/j-cli.js
CHANGED
|
@@ -146,11 +146,14 @@ var init_config = __esm(() => {
|
|
|
146
146
|
// ../kit/src/user-config.ts
|
|
147
147
|
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
148
148
|
import { homedir } from "os";
|
|
149
|
-
import { join as join2 } from "path";
|
|
149
|
+
import { isAbsolute, join as join2 } from "path";
|
|
150
150
|
import process4 from "process";
|
|
151
|
+
function xdgFolder(value, fallback) {
|
|
152
|
+
return value !== undefined && isAbsolute(value) ? value : fallback;
|
|
153
|
+
}
|
|
151
154
|
function configBase(where = {}) {
|
|
152
155
|
const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
|
|
153
|
-
return xdg
|
|
156
|
+
return xdgFolder(xdg, join2(where.home ?? homedir(), ".config"));
|
|
154
157
|
}
|
|
155
158
|
function userConfigPath(bin, where = {}) {
|
|
156
159
|
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
@@ -614,11 +617,20 @@ var init_text2 = __esm(() => {
|
|
|
614
617
|
|
|
615
618
|
// ../kit/src/input.ts
|
|
616
619
|
import process9 from "process";
|
|
620
|
+
function durationMs(text, unit) {
|
|
621
|
+
if (BARE_DURATION.test(text))
|
|
622
|
+
return Number(text) * UNIT_MS[unit];
|
|
623
|
+
if (!DURATION.test(text))
|
|
624
|
+
return 0;
|
|
625
|
+
let ms = 0;
|
|
626
|
+
for (const [, amount, part] of text.matchAll(DURATION_PART))
|
|
627
|
+
ms += Number(amount) * UNIT_MS[part];
|
|
628
|
+
return ms;
|
|
629
|
+
}
|
|
617
630
|
function duration(value, name, fallback, unit = "s") {
|
|
618
631
|
if (value === undefined)
|
|
619
632
|
return fallback;
|
|
620
|
-
const
|
|
621
|
-
const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
|
|
633
|
+
const ms = durationMs(value.trim(), unit);
|
|
622
634
|
if (ms < 1)
|
|
623
635
|
badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
|
|
624
636
|
return ms;
|
|
@@ -634,11 +646,13 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
|
634
646
|
fail(`no file ${path}`);
|
|
635
647
|
return file.text();
|
|
636
648
|
}
|
|
637
|
-
var DURATION, UNIT_MS;
|
|
649
|
+
var BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
|
|
638
650
|
var init_input = __esm(() => {
|
|
639
651
|
init_args();
|
|
640
|
-
|
|
641
|
-
|
|
652
|
+
BARE_DURATION = /^\d+(?:\.\d+)?$/;
|
|
653
|
+
DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
|
|
654
|
+
DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
|
|
655
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
|
|
642
656
|
});
|
|
643
657
|
|
|
644
658
|
// ../kit/src/args.ts
|
|
@@ -884,7 +898,7 @@ function ignoredFolders(extra = [], where = {}) {
|
|
|
884
898
|
return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
|
|
885
899
|
}
|
|
886
900
|
function cacheFolder({ home = homedir5(), env = process18.env } = {}) {
|
|
887
|
-
return env.XDG_CACHE_HOME
|
|
901
|
+
return xdgFolder(env.XDG_CACHE_HOME, join7(home, ".cache"));
|
|
888
902
|
}
|
|
889
903
|
var SKIPPED_FOLDERS;
|
|
890
904
|
var init_folders = __esm(() => {
|
|
@@ -1314,14 +1328,14 @@ var init_redraw = __esm(() => {
|
|
|
1314
1328
|
});
|
|
1315
1329
|
|
|
1316
1330
|
// ../kit/src/answers.ts
|
|
1317
|
-
import { mkdirSync as mkdirSync3, readFileSync as
|
|
1331
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync7, writeFileSync as writeFileSync2 } from "fs";
|
|
1318
1332
|
import { dirname as dirname5, join as join9 } from "path";
|
|
1319
1333
|
function answersFile() {
|
|
1320
1334
|
return join9(cacheFolder(), "kaynooo-cli", "answers.json");
|
|
1321
1335
|
}
|
|
1322
1336
|
function stored() {
|
|
1323
1337
|
try {
|
|
1324
|
-
const parsed = JSON.parse(
|
|
1338
|
+
const parsed = JSON.parse(readFileSync7(answersFile(), "utf-8"));
|
|
1325
1339
|
if (typeof parsed !== "object" || parsed === null)
|
|
1326
1340
|
return {};
|
|
1327
1341
|
return Object.fromEntries(Object.entries(parsed).filter((entry) => Array.isArray(entry[1]) && entry[1].every((answer) => typeof answer === "string")));
|
|
@@ -1560,10 +1574,12 @@ init_format();
|
|
|
1560
1574
|
init_format();
|
|
1561
1575
|
|
|
1562
1576
|
// ../kit/src/process.ts
|
|
1577
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
1563
1578
|
import { constants } from "os";
|
|
1564
1579
|
import process12 from "process";
|
|
1565
1580
|
var KILL_GRACE_MS = 2000;
|
|
1566
1581
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
1582
|
+
var GROUP_SIGNALS = new Set(["SIGINT", "SIGHUP"]);
|
|
1567
1583
|
function exitCodeOf(code, signal) {
|
|
1568
1584
|
if (code !== null)
|
|
1569
1585
|
return code;
|
|
@@ -1571,6 +1587,21 @@ function exitCodeOf(code, signal) {
|
|
|
1571
1587
|
return 128 + signal;
|
|
1572
1588
|
return signal === null ? 129 : 128 + constants.signals[signal];
|
|
1573
1589
|
}
|
|
1590
|
+
function groupsOf(pid) {
|
|
1591
|
+
try {
|
|
1592
|
+
const stat = readFileSync4(`/proc/${pid}/stat`, "utf8");
|
|
1593
|
+
const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
|
|
1594
|
+
return { group: Number(fields[2]), foreground: Number(fields[5]) };
|
|
1595
|
+
} catch {
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
function heardTheTerminal(child) {
|
|
1600
|
+
if (child.pid === undefined)
|
|
1601
|
+
return false;
|
|
1602
|
+
const own = groupsOf("self");
|
|
1603
|
+
return own !== undefined && own.group === own.foreground && groupsOf(child.pid)?.group === own.group;
|
|
1604
|
+
}
|
|
1574
1605
|
function holdSignals(cleanup) {
|
|
1575
1606
|
let received;
|
|
1576
1607
|
let child;
|
|
@@ -1589,7 +1620,8 @@ function holdSignals(cleanup) {
|
|
|
1589
1620
|
function onSignal(signal) {
|
|
1590
1621
|
received = signal;
|
|
1591
1622
|
if (child !== undefined) {
|
|
1592
|
-
|
|
1623
|
+
if (!GROUP_SIGNALS.has(signal) || !heardTheTerminal(child))
|
|
1624
|
+
child.kill(signal);
|
|
1593
1625
|
return;
|
|
1594
1626
|
}
|
|
1595
1627
|
if (cleanup === undefined)
|
|
@@ -1645,12 +1677,19 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs,
|
|
|
1645
1677
|
stop();
|
|
1646
1678
|
continue;
|
|
1647
1679
|
}
|
|
1680
|
+
if (state.truncated)
|
|
1681
|
+
continue;
|
|
1682
|
+
let kept = data;
|
|
1648
1683
|
if (state.kept + data.length > maxBytes) {
|
|
1684
|
+
let cut = maxBytes - state.kept;
|
|
1685
|
+
while (cut > 0 && ((data[cut] ?? 0) & 192) === 128)
|
|
1686
|
+
cut--;
|
|
1687
|
+
kept = data.subarray(0, cut);
|
|
1649
1688
|
state.truncated = true;
|
|
1650
|
-
continue;
|
|
1651
1689
|
}
|
|
1652
|
-
state.kept +=
|
|
1653
|
-
|
|
1690
|
+
state.kept += kept.length;
|
|
1691
|
+
if (kept.length > 0)
|
|
1692
|
+
chunks.push({ stream: name, data: kept });
|
|
1654
1693
|
}
|
|
1655
1694
|
};
|
|
1656
1695
|
try {
|
|
@@ -1667,6 +1706,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs,
|
|
|
1667
1706
|
const joined = () => Buffer.concat(chunks.map(({ data }) => data));
|
|
1668
1707
|
let output;
|
|
1669
1708
|
let text;
|
|
1709
|
+
let stdout;
|
|
1670
1710
|
return {
|
|
1671
1711
|
code: exitCodeOf(proc.exitCode, proc.signalCode),
|
|
1672
1712
|
chunks,
|
|
@@ -1677,6 +1717,9 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs,
|
|
|
1677
1717
|
},
|
|
1678
1718
|
get text() {
|
|
1679
1719
|
return text ??= (output ??= joined()).toString();
|
|
1720
|
+
},
|
|
1721
|
+
get stdout() {
|
|
1722
|
+
return stdout ??= Buffer.concat(chunks.filter((chunk) => chunk.stream === "stdout").map((chunk) => chunk.data)).toString();
|
|
1680
1723
|
}
|
|
1681
1724
|
};
|
|
1682
1725
|
}
|
|
@@ -1696,7 +1739,7 @@ init_style();
|
|
|
1696
1739
|
init_format();
|
|
1697
1740
|
// ../kit/src/cli.ts
|
|
1698
1741
|
init_args();
|
|
1699
|
-
import { readFileSync as
|
|
1742
|
+
import { readFileSync as readFileSync5, realpathSync as realpathSync2 } from "fs";
|
|
1700
1743
|
import { dirname as dirname3, join as join6 } from "path";
|
|
1701
1744
|
import process17 from "process";
|
|
1702
1745
|
|
|
@@ -1826,10 +1869,11 @@ init_text2();
|
|
|
1826
1869
|
// ../kit/src/usage.ts
|
|
1827
1870
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1828
1871
|
import { homedir as homedir4 } from "os";
|
|
1829
|
-
import { dirname as dirname2,
|
|
1872
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
1830
1873
|
import process16 from "process";
|
|
1831
1874
|
|
|
1832
1875
|
// ../kit/src/logs.ts
|
|
1876
|
+
init_user_config();
|
|
1833
1877
|
import { lstatSync, openSync } from "fs";
|
|
1834
1878
|
import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
|
|
1835
1879
|
import { homedir as homedir3, tmpdir } from "os";
|
|
@@ -1846,9 +1890,7 @@ function isPrivateDirectory(path) {
|
|
|
1846
1890
|
}
|
|
1847
1891
|
}
|
|
1848
1892
|
async function privateLogDirectory(name, env = process15.env) {
|
|
1849
|
-
const
|
|
1850
|
-
const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
|
|
1851
|
-
const path = join4(base, name);
|
|
1893
|
+
const path = join4(xdgFolder(env.XDG_RUNTIME_DIR, join4(homedir3(), ".cache")), CLI_FOLDER, name);
|
|
1852
1894
|
try {
|
|
1853
1895
|
await mkdir(path, { recursive: true, mode: 448 });
|
|
1854
1896
|
if (isPrivateDirectory(path))
|
|
@@ -1878,6 +1920,7 @@ async function sweepLogs(dir, maxAgeMs = DAY_MS, now = Date.now()) {
|
|
|
1878
1920
|
}
|
|
1879
1921
|
|
|
1880
1922
|
// ../kit/src/usage.ts
|
|
1923
|
+
init_user_config();
|
|
1881
1924
|
var UNKNOWN_OPTION2 = /unknown option '(--[a-z][a-z0-9-]*)[=']/;
|
|
1882
1925
|
var FLAG_NAME = /^(?:--[a-z][a-z0-9-]*|-[a-zA-Z])$/;
|
|
1883
1926
|
var LONGEST_NAME = 40;
|
|
@@ -1886,8 +1929,7 @@ function noteUsageError(message) {
|
|
|
1886
1929
|
usageError = message;
|
|
1887
1930
|
}
|
|
1888
1931
|
function stateHome(env = process16.env) {
|
|
1889
|
-
|
|
1890
|
-
return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
|
|
1932
|
+
return xdgFolder(env.XDG_STATE_HOME, join5(homedir4(), ".local", "state"));
|
|
1891
1933
|
}
|
|
1892
1934
|
function usagePath(env = process16.env) {
|
|
1893
1935
|
return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
@@ -2031,7 +2073,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
2031
2073
|
} catch {}
|
|
2032
2074
|
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
2033
2075
|
try {
|
|
2034
|
-
const { version } = JSON.parse(
|
|
2076
|
+
const { version } = JSON.parse(readFileSync5(join6(dir, "package.json"), "utf8"));
|
|
2035
2077
|
if (typeof version === "string")
|
|
2036
2078
|
return version;
|
|
2037
2079
|
} catch {}
|
|
@@ -2244,6 +2286,7 @@ init_style();
|
|
|
2244
2286
|
init_text2();
|
|
2245
2287
|
// ../kit/src/secrets.ts
|
|
2246
2288
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
2289
|
+
var NOT_PASSWORDS = new Set(["compass", "encompass", "bypass", "overpass", "underpass", "surpass", "trespass"]);
|
|
2247
2290
|
// ../kit/src/sessions.ts
|
|
2248
2291
|
var {Glob } = globalThis.Bun;
|
|
2249
2292
|
var SESSION_FILES = new Glob("*.json");
|
|
@@ -2262,7 +2305,7 @@ init_style();
|
|
|
2262
2305
|
// ../kit/src/workspace-root.ts
|
|
2263
2306
|
init_user_config();
|
|
2264
2307
|
// package.json
|
|
2265
|
-
var version = "0.
|
|
2308
|
+
var version = "0.22.0";
|
|
2266
2309
|
|
|
2267
2310
|
// src/j.ts
|
|
2268
2311
|
import process26 from "process";
|
|
@@ -2270,7 +2313,7 @@ import process26 from "process";
|
|
|
2270
2313
|
// ../kit/src/picker.ts
|
|
2271
2314
|
init_folders();
|
|
2272
2315
|
init_state();
|
|
2273
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as
|
|
2316
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync6, writeFileSync } from "fs";
|
|
2274
2317
|
import { dirname as dirname4, join as join8 } from "path";
|
|
2275
2318
|
import process23 from "process";
|
|
2276
2319
|
|
|
@@ -2295,6 +2338,7 @@ var COMMENT_PREFIXES = new Set([";", "&", "|", "(", ")"]);
|
|
|
2295
2338
|
var SAFE_WORD = /^[\w@%+=:,./-]+$/;
|
|
2296
2339
|
var DOUBLE_QUOTED_ESCAPES = new Set(["$", "`", '"', "\\"]);
|
|
2297
2340
|
var KEYWORDS = new Set(["then", "do", "else", "if", "elif", "while", "until", "!", "{", "}"]);
|
|
2341
|
+
var FISH_COMBINERS = new Set(["and", "or", "not"]);
|
|
2298
2342
|
var SHELLS = new Set(["sh", "bash", "zsh", "dash", "ash", "ksh", "fish", "csh", "tcsh", "nu", "xonsh", "elvish", "pwsh", "powershell"]);
|
|
2299
2343
|
var SCANNED_PROGRAMS = new Set(["su", "runuser", "flock"]);
|
|
2300
2344
|
var COMMAND_STRING_PROGRAMS = new Set([...SHELLS, ...SCANNED_PROGRAMS]);
|
|
@@ -2306,6 +2350,7 @@ var FIND_EXEC = new Set(["-exec", "-execdir", "-ok", "-okdir"]);
|
|
|
2306
2350
|
function wrapper(short = "", long = [], operands = 0, runsString = false) {
|
|
2307
2351
|
return { short, long, operands, runsString };
|
|
2308
2352
|
}
|
|
2353
|
+
var RUNNER = { ...wrapper(), afterDashes: true };
|
|
2309
2354
|
var WRAPPERS = new Map([
|
|
2310
2355
|
["command", wrapper()],
|
|
2311
2356
|
["builtin", wrapper()],
|
|
@@ -2327,7 +2372,23 @@ var WRAPPERS = new Map([
|
|
|
2327
2372
|
["parallel", wrapper("jnNSaIPlLdTsC", ["--jobs", "--max-args", "--max-replace-args", "--sshlogin", "--arg-file", "--delimiter", "--colsep"], 0, true)],
|
|
2328
2373
|
["unbuffer", wrapper()],
|
|
2329
2374
|
["systemd-run", wrapper("puEMH", ["--property", "--unit", "--description", "--slice", "--setenv", "--machine", "--host", "--uid", "--gid", "--working-directory", "--nice", "--service-type"])],
|
|
2330
|
-
["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])]
|
|
2375
|
+
["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])],
|
|
2376
|
+
["strace", wrapper("abeEIoOpPsSuUX", ["--trace", "--output", "--attach", "--string-limit", "--user", "--env", "--columns", "--trace-path", "--signal", "--status", "--summary-sort-by", "--summary-columns", "--const-print-style", "--interruptible", "--detach-on"])],
|
|
2377
|
+
["ltrace", wrapper("aeFlnopsuxX", ["--output", "--user", "--library", "--config", "--align", "--indent"])],
|
|
2378
|
+
["taskset", wrapper("", [], 1)],
|
|
2379
|
+
["fakeroot", wrapper("lsib", ["--lib", "--faked"])],
|
|
2380
|
+
["sshpass", wrapper("pfdP")],
|
|
2381
|
+
["coproc", wrapper()],
|
|
2382
|
+
["proxychains", wrapper("f")],
|
|
2383
|
+
["proxychains4", wrapper("f")],
|
|
2384
|
+
["torsocks", wrapper("upaP", ["--user", "--pass", "--address", "--port"])],
|
|
2385
|
+
["chrt", wrapper("TPD", ["--sched-runtime", "--sched-period", "--sched-deadline"], 1)],
|
|
2386
|
+
["unshare", wrapper("SGRw", ["--setuid", "--setgid", "--root", "--wd", "--map-user", "--map-group", "--map-users", "--map-groups", "--propagation", "--setgroups"])],
|
|
2387
|
+
["nsenter", wrapper("tSG", ["--target", "--setuid", "--setgid"])],
|
|
2388
|
+
["out", RUNNER],
|
|
2389
|
+
["slot", RUNNER],
|
|
2390
|
+
["waitfor", RUNNER],
|
|
2391
|
+
["base", RUNNER]
|
|
2331
2392
|
]);
|
|
2332
2393
|
function shellQuote(word) {
|
|
2333
2394
|
return SAFE_WORD.test(word) && !word.startsWith("=") ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
@@ -2758,7 +2819,7 @@ function historyFile(name) {
|
|
|
2758
2819
|
function history(name) {
|
|
2759
2820
|
try {
|
|
2760
2821
|
const file = historyFile(name);
|
|
2761
|
-
return existsSync4(file) ? JSON.parse(
|
|
2822
|
+
return existsSync4(file) ? JSON.parse(readFileSync6(file, "utf-8")) : {};
|
|
2762
2823
|
} catch {
|
|
2763
2824
|
return {};
|
|
2764
2825
|
}
|
|
@@ -2799,13 +2860,14 @@ init_prompt();
|
|
|
2799
2860
|
import process25 from "process";
|
|
2800
2861
|
|
|
2801
2862
|
// src/jobs.ts
|
|
2802
|
-
import { existsSync as existsSync5, readdirSync, readFileSync as
|
|
2863
|
+
import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync8 } from "fs";
|
|
2803
2864
|
import { dirname as dirname6, join as join11, resolve as resolvePath } from "path";
|
|
2804
2865
|
|
|
2805
2866
|
// src/steps.ts
|
|
2806
2867
|
import { readdir as readdir2 } from "fs/promises";
|
|
2807
2868
|
import { join as join10 } from "path";
|
|
2808
|
-
var STEP_NAMES = ["check", "typecheck", "lint", "test"];
|
|
2869
|
+
var STEP_NAMES = ["check", "typecheck", "lint", "fmt", "test"];
|
|
2870
|
+
var STEP_SOURCES = { fmt: ["fmt:check", "format:check", "fmt-check", "format-check"] };
|
|
2809
2871
|
var TARGET = /^@?([\w-]+)(?:[ \t][^:=\n]*)?:(?!=)/gm;
|
|
2810
2872
|
var JUSTFILES = ["justfile", "Justfile", ".justfile"];
|
|
2811
2873
|
var TASK_RUNNERS = new Set(["Justfile", "Makefile"]);
|
|
@@ -2922,8 +2984,8 @@ async function discover(dir) {
|
|
|
2922
2984
|
const found = await candidates(dir, "check");
|
|
2923
2985
|
const runnerCheck = found.find((candidate) => candidate.name === "check" && TASK_RUNNERS.has(candidate.source));
|
|
2924
2986
|
return STEP_NAMES.flatMap((name) => {
|
|
2925
|
-
const step = name === "check" && runnerCheck !== undefined ? runnerCheck : found.find((candidate) => candidate.name ===
|
|
2926
|
-
return step === undefined ? [] : [step];
|
|
2987
|
+
const step = name === "check" && runnerCheck !== undefined ? runnerCheck : (STEP_SOURCES[name] ?? [name]).map((each) => found.find((candidate) => candidate.name === each)).find((each) => each !== undefined);
|
|
2988
|
+
return step === undefined ? [] : [{ ...step, name }];
|
|
2927
2989
|
});
|
|
2928
2990
|
}
|
|
2929
2991
|
|
|
@@ -3055,7 +3117,7 @@ function make(dir) {
|
|
|
3055
3117
|
const file = MAKEFILES.find((name) => existsSync5(join11(dir, name)));
|
|
3056
3118
|
if (file === undefined)
|
|
3057
3119
|
return [];
|
|
3058
|
-
const source =
|
|
3120
|
+
const source = readFileSync8(join11(dir, file), "utf-8");
|
|
3059
3121
|
return build({ kind: "make", tag: "make", runner: ["make"], separated: false, dir }, targets2(source).map((target) => ({ ...target, body: show(source, target.name) })));
|
|
3060
3122
|
}
|
|
3061
3123
|
function manager(dir, manifest) {
|
|
@@ -3078,7 +3140,7 @@ function packageScripts(dir, here) {
|
|
|
3078
3140
|
const file = locate(dir, here, ["package.json"]);
|
|
3079
3141
|
if (file === undefined)
|
|
3080
3142
|
return [];
|
|
3081
|
-
const manifest = JSON.parse(
|
|
3143
|
+
const manifest = JSON.parse(readFileSync8(file, "utf-8"));
|
|
3082
3144
|
const tool = manager(dirname6(file), manifest);
|
|
3083
3145
|
const items = Object.entries(table2(manifest.scripts)).map(([name, command]) => ({ name, body: text2(command) }));
|
|
3084
3146
|
return build({ kind: "package", tag: tool, runner: [tool, "run"], separated: tool === "npm", dir: dirname6(file) }, items);
|
|
@@ -3087,7 +3149,7 @@ function composer(dir, here) {
|
|
|
3087
3149
|
const file = locate(dir, here, ["composer.json"]);
|
|
3088
3150
|
if (file === undefined)
|
|
3089
3151
|
return [];
|
|
3090
|
-
const manifest = JSON.parse(
|
|
3152
|
+
const manifest = JSON.parse(readFileSync8(file, "utf-8"));
|
|
3091
3153
|
const descriptions = table2(manifest["scripts-descriptions"]);
|
|
3092
3154
|
const items = Object.entries(table2(manifest.scripts)).map(([name, command]) => ({ name, doc: field(descriptions, name), body: text2(command) }));
|
|
3093
3155
|
return build({ kind: "composer", tag: "composer", runner: ["composer", "run"], separated: true, dir: dirname6(file) }, items);
|
|
@@ -3096,7 +3158,7 @@ function deno(dir, here) {
|
|
|
3096
3158
|
const file = locate(dir, here, ["deno.json", "deno.jsonc"]);
|
|
3097
3159
|
if (file === undefined)
|
|
3098
3160
|
return [];
|
|
3099
|
-
const manifest = Bun.JSONC.parse(
|
|
3161
|
+
const manifest = Bun.JSONC.parse(readFileSync8(file, "utf-8"));
|
|
3100
3162
|
const items = Object.entries(table2(manifest.tasks)).map(([name, task]) => ({ name, doc: field(task, "description"), body: field(task, "command") ?? text2(task) }));
|
|
3101
3163
|
return build({ kind: "deno", tag: "deno", runner: ["deno", "task"], separated: false, dir: dirname6(file) }, items);
|
|
3102
3164
|
}
|
|
@@ -3104,7 +3166,7 @@ function taskfile(dir, here) {
|
|
|
3104
3166
|
const file = locate(dir, here, TASKFILES);
|
|
3105
3167
|
if (file === undefined)
|
|
3106
3168
|
return [];
|
|
3107
|
-
const tasks = table2(Bun.YAML.parse(
|
|
3169
|
+
const tasks = table2(Bun.YAML.parse(readFileSync8(file, "utf-8"))?.tasks);
|
|
3108
3170
|
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) }));
|
|
3109
3171
|
return build({ kind: "task", tag: "task", runner: ["task"], separated: true, dir: dirname6(file) }, items);
|
|
3110
3172
|
}
|
|
@@ -3123,7 +3185,7 @@ function pyproject(dir, here) {
|
|
|
3123
3185
|
const file = locate(dir, here, ["pyproject.toml"]);
|
|
3124
3186
|
if (file === undefined)
|
|
3125
3187
|
return [];
|
|
3126
|
-
const manifest = Bun.TOML.parse(
|
|
3188
|
+
const manifest = Bun.TOML.parse(readFileSync8(file, "utf-8"));
|
|
3127
3189
|
const tool = table2(manifest.tool);
|
|
3128
3190
|
const project = table2(manifest.project);
|
|
3129
3191
|
const uv = locate(dirname6(file), true, ["uv.lock"]) !== undefined;
|
|
@@ -3155,9 +3217,9 @@ function readOr(read, fallback) {
|
|
|
3155
3217
|
}
|
|
3156
3218
|
}
|
|
3157
3219
|
function workspaces() {
|
|
3158
|
-
const manifest = readOr(() => JSON.parse(
|
|
3220
|
+
const manifest = readOr(() => JSON.parse(readFileSync8("package.json", "utf-8")), {});
|
|
3159
3221
|
const declared = Array.isArray(manifest.workspaces) ? manifest.workspaces : table2(manifest.workspaces).packages;
|
|
3160
|
-
const pnpm = readOr(() => table2(Bun.YAML.parse(
|
|
3222
|
+
const pnpm = readOr(() => table2(Bun.YAML.parse(readFileSync8("pnpm-workspace.yaml", "utf-8"))).packages, undefined);
|
|
3161
3223
|
const patterns = [declared, pnpm].flatMap((value) => Array.isArray(value) ? value.filter((pattern) => typeof pattern === "string") : []);
|
|
3162
3224
|
const excluded = patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => new Bun.Glob(pattern.slice(1)));
|
|
3163
3225
|
return patterns.filter((pattern) => !pattern.startsWith("!")).flatMap((pattern) => [...new Bun.Glob(`${pattern.replace(TRAILING_SLASHES, "")}/package.json`).scanSync({ cwd: "." })].map((file) => dirname6(file))).filter((dir) => !dir.split("/").includes("node_modules") && !excluded.some((glob) => glob.match(dir)));
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-check",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "check and errs: run a repo's check, typecheck, lint and test steps or, with --fix, 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.",
|
|
4
|
+
"version": "0.22.0",
|
|
5
|
+
"description": "check and errs: run a repo's check, typecheck, lint, format check and test steps or, with --fix, 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",
|
|
8
8
|
"homepage": "https://github.com/Kayno0o/cli/tree/main/packages/check#readme",
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
"j": "$npm_execpath src/j-cli.ts"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@kaynooo/cli-kit": "0.
|
|
35
|
+
"@kaynooo/cli-kit": "0.46.2"
|
|
36
36
|
}
|
|
37
37
|
}
|