@kaynooo/cli-check 0.18.2 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +32 -22
- package/dist/errs-cli.js +32 -22
- package/dist/fix-cli.js +30 -20
- package/dist/j-cli.js +175 -47
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -467,18 +467,14 @@ var FULL_STOP = /\.$/;
|
|
|
467
467
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
468
468
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
469
469
|
}
|
|
470
|
-
function helpText(usage, options, colors = paint(process8.stdout), { examples = [],
|
|
471
|
-
return [usageLine(usage, colors),
|
|
470
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
471
|
+
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
472
472
|
`);
|
|
473
473
|
}
|
|
474
474
|
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
475
475
|
if (exits.length === 0)
|
|
476
476
|
return [];
|
|
477
|
-
|
|
478
|
-
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
479
|
-
}
|
|
480
|
-
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
481
|
-
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
477
|
+
return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
|
|
482
478
|
}
|
|
483
479
|
function wantsHelpJson(env = process8.env) {
|
|
484
480
|
return env.KIT_HELP === "json";
|
|
@@ -1121,7 +1117,11 @@ async function printCandidates(found) {
|
|
|
1121
1117
|
return 0;
|
|
1122
1118
|
}
|
|
1123
1119
|
function packageVersion(entry = Bun.main) {
|
|
1124
|
-
|
|
1120
|
+
let resolved = entry;
|
|
1121
|
+
try {
|
|
1122
|
+
resolved = realpathSync2(entry);
|
|
1123
|
+
} catch {}
|
|
1124
|
+
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1125
1125
|
try {
|
|
1126
1126
|
const { version } = JSON.parse(readFileSync4(join6(dir, "package.json"), "utf8"));
|
|
1127
1127
|
if (typeof version === "string")
|
|
@@ -1165,7 +1165,7 @@ var {Glob } = globalThis.Bun;
|
|
|
1165
1165
|
var SESSION_FILES = new Glob("*.json");
|
|
1166
1166
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1167
1167
|
// package.json
|
|
1168
|
-
var version = "0.
|
|
1168
|
+
var version = "0.19.0";
|
|
1169
1169
|
|
|
1170
1170
|
// src/check.ts
|
|
1171
1171
|
import { writeFile as writeFile3 } from "fs/promises";
|
|
@@ -2118,7 +2118,10 @@ var BUN_TEST_FILE = /^\S+\.test\.[jt]sx?:$/;
|
|
|
2118
2118
|
var GO_ERROR = /^\s*(?:vet: )?(\S+\.go):(\d+):(?:(\d+):)? (.+)$/;
|
|
2119
2119
|
var GO_NOISE = /^# \S+(?: \[\S+\])?$/;
|
|
2120
2120
|
var ARROW = /^\s*--> (.+?):(\d+):(\d+)$/;
|
|
2121
|
-
var CARGO_HEADER = /^(error|warning)(?:\[(\w+)\])?: (.*)$/;
|
|
2121
|
+
var CARGO_HEADER = /^(error|warning)(?:\[([\w-]+)\])?: (.*)$/;
|
|
2122
|
+
var CONTINUATION2 = /^\s+\S/;
|
|
2123
|
+
var MAX_CONTINUATION = 20;
|
|
2124
|
+
var KAY_SUMMARY = /^(?:\d+ errors?(?:, \d+ warnings?)?|\d+ warnings?)(?:, failing under --deny-warnings)?$|^checked with /;
|
|
2122
2125
|
var CARGO_NOISE = /^(?:\s+(?:Compiling|Finished|Checking|Fresh|Running|Blocking) |error: (?:aborting due to|could not compile)|warning: .* generated \d+ warnings?|Some errors have detailed explanations|For more information about (?:this|an) error|To learn more, run the command again)/;
|
|
2123
2126
|
var RUFF_CONCISE = /^(\S+\.pyi?):(\d+):(\d+): ([A-Z]+\d+) (?:\[\*\] )?(.*)$/;
|
|
2124
2127
|
var RUFF_HEADER = /^([A-Z]{1,5}\d{1,4}) (?:\[\*\] )?(.+)$/;
|
|
@@ -2134,7 +2137,7 @@ var PYTEST_EXCEPTION_END = /[\s:]/;
|
|
|
2134
2137
|
var PYTEST_NOISE = /^(?:platform |rootdir: |collected |plugins: |configfile: |cachedir: |\S+\.pyi? [.FEsxXR]+ +\[ *\d+%\]$|\S+\.py:\d+: $)/;
|
|
2135
2138
|
var NOISE = /^(?:bun test v|Errors {2}Files$|Ran \d+ tests?|note: |\s*\d+ expect\(\) calls|\s+\d+\s+\S+:\d+$|\s*\d+ errors? and \d+ warnings? potentially fixable)/;
|
|
2136
2139
|
function isNoise(line) {
|
|
2137
|
-
return line.trim() === "" || [NOISE, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_SUMMARY, ESLINT_SUMMARY, BOUNDARY, BASH_ECHO, GO_NOISE, CARGO_NOISE, RUFF_NOISE, PYTEST_NOISE, PYTEST_BANNER, ...PHP_NOISE, ...E2E_NOISE].some((pattern) => pattern.test(line));
|
|
2140
|
+
return line.trim() === "" || [NOISE, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_SUMMARY, ESLINT_SUMMARY, BOUNDARY, BASH_ECHO, GO_NOISE, CARGO_NOISE, KAY_SUMMARY, RUFF_NOISE, PYTEST_NOISE, PYTEST_BANNER, ...PHP_NOISE, ...E2E_NOISE].some((pattern) => pattern.test(line));
|
|
2138
2141
|
}
|
|
2139
2142
|
var collectBunCheck = (lines, used) => {
|
|
2140
2143
|
const errors = [];
|
|
@@ -2242,20 +2245,27 @@ var collectGo = (lines, used) => {
|
|
|
2242
2245
|
}
|
|
2243
2246
|
return errors;
|
|
2244
2247
|
};
|
|
2248
|
+
function headerAbove(lines, arrow, used) {
|
|
2249
|
+
let at = arrow - 1;
|
|
2250
|
+
while (at > 0 && arrow - at <= MAX_CONTINUATION && !used.has(at) && CONTINUATION2.test(lines[at] ?? "") && !ARROW.test(lines[at] ?? ""))
|
|
2251
|
+
at--;
|
|
2252
|
+
return at;
|
|
2253
|
+
}
|
|
2245
2254
|
var collectArrowed = (lines, used) => {
|
|
2246
2255
|
const errors = [];
|
|
2247
2256
|
for (const [index, line] of lines.entries()) {
|
|
2248
2257
|
const arrow = used.has(index) || index === 0 ? null : ARROW.exec(line);
|
|
2249
|
-
const
|
|
2258
|
+
const at = arrow === null ? -1 : headerAbove(lines, index, used);
|
|
2259
|
+
const header = at === -1 ? null : lines[at] ?? "";
|
|
2250
2260
|
const cargo = header === null ? null : CARGO_HEADER.exec(header);
|
|
2251
2261
|
const ruff = header === null || cargo !== null ? null : RUFF_HEADER.exec(header);
|
|
2252
|
-
if (arrow === null || cargo === null && ruff === null || used.has(
|
|
2262
|
+
if (arrow === null || cargo === null && ruff === null || used.has(at))
|
|
2253
2263
|
continue;
|
|
2254
|
-
const [, file, row, column] = arrow;
|
|
2255
|
-
const fields = { file
|
|
2256
|
-
errors.push(cargo === null ? { tool: "ruff", ...fields, rule: ruff?.[1], severity: "error", message: ruff?.[2] ?? "" } : { tool: "cargo", ...fields, rule: cargo[2], severity: cargo[1] === "warning" ? "warning" : "error", message: cargo[3] ?? "" });
|
|
2257
|
-
|
|
2258
|
-
|
|
2264
|
+
const [, file = "", row, column] = arrow;
|
|
2265
|
+
const fields = { file, line: Number(row), column: Number(column) };
|
|
2266
|
+
errors.push(cargo === null ? { tool: "ruff", ...fields, rule: ruff?.[1], severity: "error", message: ruff?.[2] ?? "" } : { tool: file.endsWith(".rs") ? "cargo" : "kay check", ...fields, rule: cargo[2], severity: cargo[1] === "warning" ? "warning" : "error", message: cargo[3] ?? "" });
|
|
2267
|
+
for (let taken = at;taken <= index; taken++)
|
|
2268
|
+
used.add(taken);
|
|
2259
2269
|
for (let frame = index + 1;frame < lines.length && (lines[frame] ?? "").trim() !== ""; frame++) {
|
|
2260
2270
|
if (CARGO_HEADER.test(lines[frame] ?? "") || RUFF_HEADER.test(lines[frame] ?? ""))
|
|
2261
2271
|
break;
|
|
@@ -2412,8 +2422,8 @@ It looks at the folder itself only, so each package of a monorepo gets its own r
|
|
|
2412
2422
|
A script or php-cs-fixer runs inside the docker compose service that bind-mounts the folder (found in compose.yml, compose.yaml or docker-compose.yml, up to the repository root), at the matching path; a service that is down is never started, the fixer fails naming it. The formatters run on the host. --in picks the service, --host forces the host.
|
|
2413
2423
|
Prints one line per fixer, what a failing one said, then the files the run changed. Each fixer's full output is saved to the file whose path ends its line.
|
|
2414
2424
|
A fixer still running after --timeout is ended with everything it started, but not what it started inside a container.
|
|
2415
|
-
Exits 0 when every fixer ran or was skipped for a missing binary, 1 when one failed, 2 on bad usage, when nothing applies or when a fixer timed out.
|
|
2416
2425
|
--json prints {fixers: [{name, command, in?, ok, ms, log, failed?} or {name, command, skipped}], changed} once every fixer ran, changed null outside a git repository.`;
|
|
2426
|
+
var EXITS = [[0, "every fixer ran or was skipped for a missing binary"], [1, "one failed"], [2, "bad usage, nothing applies or a fixer timed out"]];
|
|
2417
2427
|
var RUNNING = "KAYNOOO_CLI_FIX";
|
|
2418
2428
|
var JUSTFILES2 = ["justfile", "Justfile", ".justfile"];
|
|
2419
2429
|
var RUFF_CONFIGS = ["ruff.toml", ".ruff.toml"];
|
|
@@ -2493,7 +2503,7 @@ function printChanged(changed) {
|
|
|
2493
2503
|
console.log(` and ${changed.length - MAX_CHANGED} more`);
|
|
2494
2504
|
}
|
|
2495
2505
|
async function fix(args, cwd = process19.cwd()) {
|
|
2496
|
-
const parsed = parse(args, fixUsage, fixOptions, { replaces: "running each fixer and formatter by hand, or docker compose exec <service> bun run lint:fix", examples: ["fix", ["fix --list", "the fixers it would run"]] });
|
|
2506
|
+
const parsed = parse(args, fixUsage, fixOptions, { exits: EXITS, replaces: "running each fixer and formatter by hand, or docker compose exec <service> bun run lint:fix", examples: ["fix", ["fix --list", "the fixers it would run"]] });
|
|
2497
2507
|
return runFixers(parsed.values, cwd);
|
|
2498
2508
|
}
|
|
2499
2509
|
async function runFixers(values, cwd) {
|
|
@@ -2652,8 +2662,8 @@ With --quiet, passing steps print nothing, and a fully passing run prints nothin
|
|
|
2652
2662
|
A step still running after --timeout is ended with everything it started, but not what it started inside a container.
|
|
2653
2663
|
With --failed, only the steps that failed in the last run of this folder run again, read from that run's folder of logs; when no last run failed, it says so and exits 2.
|
|
2654
2664
|
With --fix, the folder's fixers and formatters run instead of the steps, exactly as the \`fix\` bin does (it is the alias of \`check --fix\`): its own scripts, php-cs-fixer, just --fmt, go fmt, cargo fmt, ruff and the Makefile's .PHONY targets, then the files the run changed are listed. --only then names fixers, as --list prints them; --changed, --failed and --slot do not apply.
|
|
2655
|
-
Exits 0 when every step passed, 1 when one failed, 2 on bad usage, when no step is found or when a step timed out.
|
|
2656
2665
|
--json prints [{name, command, in?, ok, ms, log, failed?}] once every step ran, --list --json [{name, command, source, in?}], in the compose service the step ran in; with --fix the shape \`fix --json\` prints.`;
|
|
2666
|
+
var EXITS2 = [[0, "every step passed"], [1, "one failed"], [2, "bad usage, no step is found or a step timed out"]];
|
|
2657
2667
|
function slotted(command) {
|
|
2658
2668
|
return `slot -- sh -c ${shellQuote(command)}`;
|
|
2659
2669
|
}
|
|
@@ -2689,7 +2699,7 @@ function summaryLine(outcomes) {
|
|
|
2689
2699
|
return parts.join(colors.dim(" \xB7 "));
|
|
2690
2700
|
}
|
|
2691
2701
|
async function check(args, cwd = process20.cwd()) {
|
|
2692
|
-
const parsed = parse(args, usage2, options, { replaces: "chaining docker compose exec <service> bun run check | tail, lint and test by hand, or bun run check && bun run lint && bun run test read through tail", examples: ["check", ["check --only lint,test", "two of the steps"], ["check --in app", "every step inside the app service"]] });
|
|
2702
|
+
const parsed = parse(args, usage2, options, { exits: EXITS2, replaces: "chaining docker compose exec <service> bun run check | tail, lint and test by hand, or bun run check && bun run lint && bun run test read through tail", examples: ["check", ["check --only lint,test", "two of the steps"], ["check --in app", "every step inside the app service"]] });
|
|
2693
2703
|
const settings = placeSettings(parsed.values);
|
|
2694
2704
|
if (parsed.values.fix === true) {
|
|
2695
2705
|
for (const flag of ["changed", "failed", "slot"]) {
|
package/dist/errs-cli.js
CHANGED
|
@@ -467,18 +467,14 @@ var FULL_STOP = /\.$/;
|
|
|
467
467
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
468
468
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
469
469
|
}
|
|
470
|
-
function helpText(usage, options, colors = paint(process8.stdout), { examples = [],
|
|
471
|
-
return [usageLine(usage, colors),
|
|
470
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
471
|
+
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
472
472
|
`);
|
|
473
473
|
}
|
|
474
474
|
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
475
475
|
if (exits.length === 0)
|
|
476
476
|
return [];
|
|
477
|
-
|
|
478
|
-
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
479
|
-
}
|
|
480
|
-
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
481
|
-
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
477
|
+
return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
|
|
482
478
|
}
|
|
483
479
|
function wantsHelpJson(env = process8.env) {
|
|
484
480
|
return env.KIT_HELP === "json";
|
|
@@ -1121,7 +1117,11 @@ async function printCandidates(found) {
|
|
|
1121
1117
|
return 0;
|
|
1122
1118
|
}
|
|
1123
1119
|
function packageVersion(entry = Bun.main) {
|
|
1124
|
-
|
|
1120
|
+
let resolved = entry;
|
|
1121
|
+
try {
|
|
1122
|
+
resolved = realpathSync2(entry);
|
|
1123
|
+
} catch {}
|
|
1124
|
+
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1125
1125
|
try {
|
|
1126
1126
|
const { version } = JSON.parse(readFileSync4(join6(dir, "package.json"), "utf8"));
|
|
1127
1127
|
if (typeof version === "string")
|
|
@@ -1165,7 +1165,7 @@ var {Glob } = globalThis.Bun;
|
|
|
1165
1165
|
var SESSION_FILES = new Glob("*.json");
|
|
1166
1166
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1167
1167
|
// package.json
|
|
1168
|
-
var version = "0.
|
|
1168
|
+
var version = "0.19.0";
|
|
1169
1169
|
|
|
1170
1170
|
// src/errs.ts
|
|
1171
1171
|
import { relative as relative2 } from "path";
|
|
@@ -1900,7 +1900,10 @@ var BUN_TEST_FILE = /^\S+\.test\.[jt]sx?:$/;
|
|
|
1900
1900
|
var GO_ERROR = /^\s*(?:vet: )?(\S+\.go):(\d+):(?:(\d+):)? (.+)$/;
|
|
1901
1901
|
var GO_NOISE = /^# \S+(?: \[\S+\])?$/;
|
|
1902
1902
|
var ARROW = /^\s*--> (.+?):(\d+):(\d+)$/;
|
|
1903
|
-
var CARGO_HEADER = /^(error|warning)(?:\[(\w+)\])?: (.*)$/;
|
|
1903
|
+
var CARGO_HEADER = /^(error|warning)(?:\[([\w-]+)\])?: (.*)$/;
|
|
1904
|
+
var CONTINUATION = /^\s+\S/;
|
|
1905
|
+
var MAX_CONTINUATION = 20;
|
|
1906
|
+
var KAY_SUMMARY = /^(?:\d+ errors?(?:, \d+ warnings?)?|\d+ warnings?)(?:, failing under --deny-warnings)?$|^checked with /;
|
|
1904
1907
|
var CARGO_NOISE = /^(?:\s+(?:Compiling|Finished|Checking|Fresh|Running|Blocking) |error: (?:aborting due to|could not compile)|warning: .* generated \d+ warnings?|Some errors have detailed explanations|For more information about (?:this|an) error|To learn more, run the command again)/;
|
|
1905
1908
|
var RUFF_CONCISE = /^(\S+\.pyi?):(\d+):(\d+): ([A-Z]+\d+) (?:\[\*\] )?(.*)$/;
|
|
1906
1909
|
var RUFF_HEADER = /^([A-Z]{1,5}\d{1,4}) (?:\[\*\] )?(.+)$/;
|
|
@@ -1916,7 +1919,7 @@ var PYTEST_EXCEPTION_END = /[\s:]/;
|
|
|
1916
1919
|
var PYTEST_NOISE = /^(?:platform |rootdir: |collected |plugins: |configfile: |cachedir: |\S+\.pyi? [.FEsxXR]+ +\[ *\d+%\]$|\S+\.py:\d+: $)/;
|
|
1917
1920
|
var NOISE = /^(?:bun test v|Errors {2}Files$|Ran \d+ tests?|note: |\s*\d+ expect\(\) calls|\s+\d+\s+\S+:\d+$|\s*\d+ errors? and \d+ warnings? potentially fixable)/;
|
|
1918
1921
|
function isNoise(line) {
|
|
1919
|
-
return line.trim() === "" || [NOISE, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_SUMMARY, ESLINT_SUMMARY, BOUNDARY, BASH_ECHO, GO_NOISE, CARGO_NOISE, RUFF_NOISE, PYTEST_NOISE, PYTEST_BANNER, ...PHP_NOISE, ...E2E_NOISE].some((pattern) => pattern.test(line));
|
|
1922
|
+
return line.trim() === "" || [NOISE, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_SUMMARY, ESLINT_SUMMARY, BOUNDARY, BASH_ECHO, GO_NOISE, CARGO_NOISE, KAY_SUMMARY, RUFF_NOISE, PYTEST_NOISE, PYTEST_BANNER, ...PHP_NOISE, ...E2E_NOISE].some((pattern) => pattern.test(line));
|
|
1920
1923
|
}
|
|
1921
1924
|
var collectBunCheck = (lines, used) => {
|
|
1922
1925
|
const errors = [];
|
|
@@ -2024,20 +2027,27 @@ var collectGo = (lines, used) => {
|
|
|
2024
2027
|
}
|
|
2025
2028
|
return errors;
|
|
2026
2029
|
};
|
|
2030
|
+
function headerAbove(lines, arrow, used) {
|
|
2031
|
+
let at = arrow - 1;
|
|
2032
|
+
while (at > 0 && arrow - at <= MAX_CONTINUATION && !used.has(at) && CONTINUATION.test(lines[at] ?? "") && !ARROW.test(lines[at] ?? ""))
|
|
2033
|
+
at--;
|
|
2034
|
+
return at;
|
|
2035
|
+
}
|
|
2027
2036
|
var collectArrowed = (lines, used) => {
|
|
2028
2037
|
const errors = [];
|
|
2029
2038
|
for (const [index, line] of lines.entries()) {
|
|
2030
2039
|
const arrow = used.has(index) || index === 0 ? null : ARROW.exec(line);
|
|
2031
|
-
const
|
|
2040
|
+
const at = arrow === null ? -1 : headerAbove(lines, index, used);
|
|
2041
|
+
const header = at === -1 ? null : lines[at] ?? "";
|
|
2032
2042
|
const cargo = header === null ? null : CARGO_HEADER.exec(header);
|
|
2033
2043
|
const ruff = header === null || cargo !== null ? null : RUFF_HEADER.exec(header);
|
|
2034
|
-
if (arrow === null || cargo === null && ruff === null || used.has(
|
|
2044
|
+
if (arrow === null || cargo === null && ruff === null || used.has(at))
|
|
2035
2045
|
continue;
|
|
2036
|
-
const [, file, row, column] = arrow;
|
|
2037
|
-
const fields = { file
|
|
2038
|
-
errors.push(cargo === null ? { tool: "ruff", ...fields, rule: ruff?.[1], severity: "error", message: ruff?.[2] ?? "" } : { tool: "cargo", ...fields, rule: cargo[2], severity: cargo[1] === "warning" ? "warning" : "error", message: cargo[3] ?? "" });
|
|
2039
|
-
|
|
2040
|
-
|
|
2046
|
+
const [, file = "", row, column] = arrow;
|
|
2047
|
+
const fields = { file, line: Number(row), column: Number(column) };
|
|
2048
|
+
errors.push(cargo === null ? { tool: "ruff", ...fields, rule: ruff?.[1], severity: "error", message: ruff?.[2] ?? "" } : { tool: file.endsWith(".rs") ? "cargo" : "kay check", ...fields, rule: cargo[2], severity: cargo[1] === "warning" ? "warning" : "error", message: cargo[3] ?? "" });
|
|
2049
|
+
for (let taken = at;taken <= index; taken++)
|
|
2050
|
+
used.add(taken);
|
|
2041
2051
|
for (let frame = index + 1;frame < lines.length && (lines[frame] ?? "").trim() !== ""; frame++) {
|
|
2042
2052
|
if (CARGO_HEADER.test(lines[frame] ?? "") || RUFF_HEADER.test(lines[frame] ?? ""))
|
|
2043
2053
|
break;
|
|
@@ -2194,11 +2204,11 @@ var usage2 = `errs [options] [log]
|
|
|
2194
2204
|
errs [options] -- <command> [args...]
|
|
2195
2205
|
errs --in <service> | --host -- <command> [args...]
|
|
2196
2206
|
|
|
2197
|
-
Prints one \`file:line:col: message (rule)\` line per error found in a tsc, tsgo, vue-tsc, bun check, eslint, keslint, bun test, vitest, playwright (list and line reporters), phpunit, paratest, phpstan (table, raw and json), php-cs-fixer, go (build, vet), cargo (rustc), ruff (concise and full) or pytest log, read from the file given, from stdin (no argument or -), or from the output of the command run after --.
|
|
2207
|
+
Prints one \`file:line:col: message (rule)\` line per error found in a tsc, tsgo, vue-tsc, bun check, kay check, eslint, keslint, bun test, vitest, playwright (list and line reporters), phpunit, paratest, phpstan (table, raw and json), php-cs-fixer, go (build, vet), cargo (rustc), ruff (concise and full) or pytest log, read from the file given, from stdin (no argument or -), or from the output of the command run after --.
|
|
2198
2208
|
The lines no format recognised are counted on stderr, never dropped silently, and a command's full output is saved to a log file whose path is printed with that count.
|
|
2199
2209
|
A command runs inside the docker compose service that bind-mounts the current folder (found in compose.yml, compose.yaml or docker-compose.yml, up to the repository root), at the matching path, with its output read here; a service that is down is never started, the call fails naming it. --in picks the service, --host forces the host.
|
|
2200
|
-
|
|
2201
|
-
|
|
2210
|
+
--json prints {errors: [{tool, file, line, column, rule, severity, message, test?}], unrecognised, log?, code?}, tool one of tsc, eslint, bun check, kay check, bun test, vitest, playwright, phpunit, phpstan, php-cs-fixer, go, cargo, ruff, pytest.`;
|
|
2211
|
+
var EXITS = [[0, "no error was found and the command, if any, passed"], [1, "errors were found or the command failed"], [2, "a usage error"]];
|
|
2202
2212
|
var options = {
|
|
2203
2213
|
...placeOptions,
|
|
2204
2214
|
json: jsonOption()
|
|
@@ -2242,7 +2252,7 @@ async function readInput2(command, run, settings, cwd) {
|
|
|
2242
2252
|
async function errs(args, cwd = process19.cwd()) {
|
|
2243
2253
|
const first = args[0];
|
|
2244
2254
|
const bare = first !== undefined && !first.startsWith("-") && !await Bun.file(first).exists();
|
|
2245
|
-
const parsed = parse(bare ? [] : args, usage2, options, { rest: true, replaces: "reading raw tsc, eslint, phpunit, phpstan or playwright logs, or grepping a test summary out of them", examples: [["errs -- bun run check", "the type errors of a run"], ["bun test 2>&1 | errs", "the failed tests from stdin"], ["errs -- vendor/bin/phpunit", "each failed PHP test with its file and line"]] });
|
|
2255
|
+
const parsed = parse(bare ? [] : args, usage2, options, { exits: EXITS, rest: true, replaces: "reading raw tsc, eslint, phpunit, phpstan or playwright logs, or grepping a test summary out of them", examples: [["errs -- bun run check", "the type errors of a run"], ["bun test 2>&1 | errs", "the failed tests from stdin"], ["errs -- vendor/bin/phpunit", "each failed PHP test with its file and line"]] });
|
|
2246
2256
|
if (parsed.positionals.length > 1)
|
|
2247
2257
|
fail(`give one log, or a command after --
|
|
2248
2258
|
|
package/dist/fix-cli.js
CHANGED
|
@@ -467,18 +467,14 @@ var FULL_STOP = /\.$/;
|
|
|
467
467
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
468
468
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
469
469
|
}
|
|
470
|
-
function helpText(usage, options, colors = paint(process8.stdout), { examples = [],
|
|
471
|
-
return [usageLine(usage, colors),
|
|
470
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
471
|
+
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
472
472
|
`);
|
|
473
473
|
}
|
|
474
474
|
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
475
475
|
if (exits.length === 0)
|
|
476
476
|
return [];
|
|
477
|
-
|
|
478
|
-
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
479
|
-
}
|
|
480
|
-
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
481
|
-
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
477
|
+
return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
|
|
482
478
|
}
|
|
483
479
|
function wantsHelpJson(env = process8.env) {
|
|
484
480
|
return env.KIT_HELP === "json";
|
|
@@ -1121,7 +1117,11 @@ async function printCandidates(found) {
|
|
|
1121
1117
|
return 0;
|
|
1122
1118
|
}
|
|
1123
1119
|
function packageVersion(entry = Bun.main) {
|
|
1124
|
-
|
|
1120
|
+
let resolved = entry;
|
|
1121
|
+
try {
|
|
1122
|
+
resolved = realpathSync2(entry);
|
|
1123
|
+
} catch {}
|
|
1124
|
+
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1125
1125
|
try {
|
|
1126
1126
|
const { version } = JSON.parse(readFileSync4(join6(dir, "package.json"), "utf8"));
|
|
1127
1127
|
if (typeof version === "string")
|
|
@@ -1165,7 +1165,7 @@ var {Glob } = globalThis.Bun;
|
|
|
1165
1165
|
var SESSION_FILES = new Glob("*.json");
|
|
1166
1166
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1167
1167
|
// package.json
|
|
1168
|
-
var version = "0.
|
|
1168
|
+
var version = "0.19.0";
|
|
1169
1169
|
|
|
1170
1170
|
// src/fix.ts
|
|
1171
1171
|
import { existsSync as existsSync5, statSync as statSync2 } from "fs";
|
|
@@ -2115,7 +2115,10 @@ var BUN_TEST_FILE = /^\S+\.test\.[jt]sx?:$/;
|
|
|
2115
2115
|
var GO_ERROR = /^\s*(?:vet: )?(\S+\.go):(\d+):(?:(\d+):)? (.+)$/;
|
|
2116
2116
|
var GO_NOISE = /^# \S+(?: \[\S+\])?$/;
|
|
2117
2117
|
var ARROW = /^\s*--> (.+?):(\d+):(\d+)$/;
|
|
2118
|
-
var CARGO_HEADER = /^(error|warning)(?:\[(\w+)\])?: (.*)$/;
|
|
2118
|
+
var CARGO_HEADER = /^(error|warning)(?:\[([\w-]+)\])?: (.*)$/;
|
|
2119
|
+
var CONTINUATION2 = /^\s+\S/;
|
|
2120
|
+
var MAX_CONTINUATION = 20;
|
|
2121
|
+
var KAY_SUMMARY = /^(?:\d+ errors?(?:, \d+ warnings?)?|\d+ warnings?)(?:, failing under --deny-warnings)?$|^checked with /;
|
|
2119
2122
|
var CARGO_NOISE = /^(?:\s+(?:Compiling|Finished|Checking|Fresh|Running|Blocking) |error: (?:aborting due to|could not compile)|warning: .* generated \d+ warnings?|Some errors have detailed explanations|For more information about (?:this|an) error|To learn more, run the command again)/;
|
|
2120
2123
|
var RUFF_CONCISE = /^(\S+\.pyi?):(\d+):(\d+): ([A-Z]+\d+) (?:\[\*\] )?(.*)$/;
|
|
2121
2124
|
var RUFF_HEADER = /^([A-Z]{1,5}\d{1,4}) (?:\[\*\] )?(.+)$/;
|
|
@@ -2131,7 +2134,7 @@ var PYTEST_EXCEPTION_END = /[\s:]/;
|
|
|
2131
2134
|
var PYTEST_NOISE = /^(?:platform |rootdir: |collected |plugins: |configfile: |cachedir: |\S+\.pyi? [.FEsxXR]+ +\[ *\d+%\]$|\S+\.py:\d+: $)/;
|
|
2132
2135
|
var NOISE = /^(?:bun test v|Errors {2}Files$|Ran \d+ tests?|note: |\s*\d+ expect\(\) calls|\s+\d+\s+\S+:\d+$|\s*\d+ errors? and \d+ warnings? potentially fixable)/;
|
|
2133
2136
|
function isNoise(line) {
|
|
2134
|
-
return line.trim() === "" || [NOISE, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_SUMMARY, ESLINT_SUMMARY, BOUNDARY, BASH_ECHO, GO_NOISE, CARGO_NOISE, RUFF_NOISE, PYTEST_NOISE, PYTEST_BANNER, ...PHP_NOISE, ...E2E_NOISE].some((pattern) => pattern.test(line));
|
|
2137
|
+
return line.trim() === "" || [NOISE, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_SUMMARY, ESLINT_SUMMARY, BOUNDARY, BASH_ECHO, GO_NOISE, CARGO_NOISE, KAY_SUMMARY, RUFF_NOISE, PYTEST_NOISE, PYTEST_BANNER, ...PHP_NOISE, ...E2E_NOISE].some((pattern) => pattern.test(line));
|
|
2135
2138
|
}
|
|
2136
2139
|
var collectBunCheck = (lines, used) => {
|
|
2137
2140
|
const errors = [];
|
|
@@ -2239,20 +2242,27 @@ var collectGo = (lines, used) => {
|
|
|
2239
2242
|
}
|
|
2240
2243
|
return errors;
|
|
2241
2244
|
};
|
|
2245
|
+
function headerAbove(lines, arrow, used) {
|
|
2246
|
+
let at = arrow - 1;
|
|
2247
|
+
while (at > 0 && arrow - at <= MAX_CONTINUATION && !used.has(at) && CONTINUATION2.test(lines[at] ?? "") && !ARROW.test(lines[at] ?? ""))
|
|
2248
|
+
at--;
|
|
2249
|
+
return at;
|
|
2250
|
+
}
|
|
2242
2251
|
var collectArrowed = (lines, used) => {
|
|
2243
2252
|
const errors = [];
|
|
2244
2253
|
for (const [index, line] of lines.entries()) {
|
|
2245
2254
|
const arrow = used.has(index) || index === 0 ? null : ARROW.exec(line);
|
|
2246
|
-
const
|
|
2255
|
+
const at = arrow === null ? -1 : headerAbove(lines, index, used);
|
|
2256
|
+
const header = at === -1 ? null : lines[at] ?? "";
|
|
2247
2257
|
const cargo = header === null ? null : CARGO_HEADER.exec(header);
|
|
2248
2258
|
const ruff = header === null || cargo !== null ? null : RUFF_HEADER.exec(header);
|
|
2249
|
-
if (arrow === null || cargo === null && ruff === null || used.has(
|
|
2259
|
+
if (arrow === null || cargo === null && ruff === null || used.has(at))
|
|
2250
2260
|
continue;
|
|
2251
|
-
const [, file, row, column] = arrow;
|
|
2252
|
-
const fields = { file
|
|
2253
|
-
errors.push(cargo === null ? { tool: "ruff", ...fields, rule: ruff?.[1], severity: "error", message: ruff?.[2] ?? "" } : { tool: "cargo", ...fields, rule: cargo[2], severity: cargo[1] === "warning" ? "warning" : "error", message: cargo[3] ?? "" });
|
|
2254
|
-
|
|
2255
|
-
|
|
2261
|
+
const [, file = "", row, column] = arrow;
|
|
2262
|
+
const fields = { file, line: Number(row), column: Number(column) };
|
|
2263
|
+
errors.push(cargo === null ? { tool: "ruff", ...fields, rule: ruff?.[1], severity: "error", message: ruff?.[2] ?? "" } : { tool: file.endsWith(".rs") ? "cargo" : "kay check", ...fields, rule: cargo[2], severity: cargo[1] === "warning" ? "warning" : "error", message: cargo[3] ?? "" });
|
|
2264
|
+
for (let taken = at;taken <= index; taken++)
|
|
2265
|
+
used.add(taken);
|
|
2256
2266
|
for (let frame = index + 1;frame < lines.length && (lines[frame] ?? "").trim() !== ""; frame++) {
|
|
2257
2267
|
if (CARGO_HEADER.test(lines[frame] ?? "") || RUFF_HEADER.test(lines[frame] ?? ""))
|
|
2258
2268
|
break;
|
|
@@ -2409,8 +2419,8 @@ It looks at the folder itself only, so each package of a monorepo gets its own r
|
|
|
2409
2419
|
A script or php-cs-fixer runs inside the docker compose service that bind-mounts the folder (found in compose.yml, compose.yaml or docker-compose.yml, up to the repository root), at the matching path; a service that is down is never started, the fixer fails naming it. The formatters run on the host. --in picks the service, --host forces the host.
|
|
2410
2420
|
Prints one line per fixer, what a failing one said, then the files the run changed. Each fixer's full output is saved to the file whose path ends its line.
|
|
2411
2421
|
A fixer still running after --timeout is ended with everything it started, but not what it started inside a container.
|
|
2412
|
-
Exits 0 when every fixer ran or was skipped for a missing binary, 1 when one failed, 2 on bad usage, when nothing applies or when a fixer timed out.
|
|
2413
2422
|
--json prints {fixers: [{name, command, in?, ok, ms, log, failed?} or {name, command, skipped}], changed} once every fixer ran, changed null outside a git repository.`;
|
|
2423
|
+
var EXITS = [[0, "every fixer ran or was skipped for a missing binary"], [1, "one failed"], [2, "bad usage, nothing applies or a fixer timed out"]];
|
|
2414
2424
|
var RUNNING = "KAYNOOO_CLI_FIX";
|
|
2415
2425
|
var JUSTFILES2 = ["justfile", "Justfile", ".justfile"];
|
|
2416
2426
|
var RUFF_CONFIGS = ["ruff.toml", ".ruff.toml"];
|
|
@@ -2490,7 +2500,7 @@ function printChanged(changed) {
|
|
|
2490
2500
|
console.log(` and ${changed.length - MAX_CHANGED} more`);
|
|
2491
2501
|
}
|
|
2492
2502
|
async function fix(args, cwd = process19.cwd()) {
|
|
2493
|
-
const parsed = parse(args, fixUsage, fixOptions, { replaces: "running each fixer and formatter by hand, or docker compose exec <service> bun run lint:fix", examples: ["fix", ["fix --list", "the fixers it would run"]] });
|
|
2503
|
+
const parsed = parse(args, fixUsage, fixOptions, { exits: EXITS, replaces: "running each fixer and formatter by hand, or docker compose exec <service> bun run lint:fix", examples: ["fix", ["fix --list", "the fixers it would run"]] });
|
|
2494
2504
|
return runFixers(parsed.values, cwd);
|
|
2495
2505
|
}
|
|
2496
2506
|
async function runFixers(values, cwd) {
|
package/dist/j-cli.js
CHANGED
|
@@ -467,18 +467,14 @@ var FULL_STOP = /\.$/;
|
|
|
467
467
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
468
468
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
469
469
|
}
|
|
470
|
-
function helpText(usage, options, colors = paint(process8.stdout), { examples = [],
|
|
471
|
-
return [usageLine(usage, colors),
|
|
470
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
471
|
+
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
472
472
|
`);
|
|
473
473
|
}
|
|
474
474
|
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
475
475
|
if (exits.length === 0)
|
|
476
476
|
return [];
|
|
477
|
-
|
|
478
|
-
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
479
|
-
}
|
|
480
|
-
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
481
|
-
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
477
|
+
return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
|
|
482
478
|
}
|
|
483
479
|
function wantsHelpJson(env = process8.env) {
|
|
484
480
|
return env.KIT_HELP === "json";
|
|
@@ -1121,7 +1117,11 @@ async function printCandidates(found) {
|
|
|
1121
1117
|
return 0;
|
|
1122
1118
|
}
|
|
1123
1119
|
function packageVersion(entry = Bun.main) {
|
|
1124
|
-
|
|
1120
|
+
let resolved = entry;
|
|
1121
|
+
try {
|
|
1122
|
+
resolved = realpathSync2(entry);
|
|
1123
|
+
} catch {}
|
|
1124
|
+
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1125
1125
|
try {
|
|
1126
1126
|
const { version } = JSON.parse(readFileSync4(join6(dir, "package.json"), "utf8"));
|
|
1127
1127
|
if (typeof version === "string")
|
|
@@ -1165,7 +1165,7 @@ var {Glob } = globalThis.Bun;
|
|
|
1165
1165
|
var SESSION_FILES = new Glob("*.json");
|
|
1166
1166
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1167
1167
|
// package.json
|
|
1168
|
-
var version = "0.
|
|
1168
|
+
var version = "0.19.0";
|
|
1169
1169
|
|
|
1170
1170
|
// src/j.ts
|
|
1171
1171
|
import process22 from "process";
|
|
@@ -1176,6 +1176,97 @@ import { homedir as homedir5 } from "os";
|
|
|
1176
1176
|
import { dirname as dirname4, join as join7 } from "path";
|
|
1177
1177
|
import process19 from "process";
|
|
1178
1178
|
|
|
1179
|
+
// ../kit/src/picker/line.ts
|
|
1180
|
+
var EDIT_KEYS = new Set(["left", "right", "wordleft", "wordright", "linestart", "lineend", "erase", "delete", "word", "killword", "killnext", "clear", "killend"]);
|
|
1181
|
+
function isEditKey(key) {
|
|
1182
|
+
return EDIT_KEYS.has(key);
|
|
1183
|
+
}
|
|
1184
|
+
var WORD_CHARACTER = /[\p{L}\p{N}_]/u;
|
|
1185
|
+
var SPACE = /\s/;
|
|
1186
|
+
function isWord(char) {
|
|
1187
|
+
return char !== undefined && WORD_CHARACTER.test(char);
|
|
1188
|
+
}
|
|
1189
|
+
function wordStart(chars, from) {
|
|
1190
|
+
let at = from;
|
|
1191
|
+
while (at > 0 && !isWord(chars[at - 1]))
|
|
1192
|
+
at--;
|
|
1193
|
+
while (at > 0 && isWord(chars[at - 1]))
|
|
1194
|
+
at--;
|
|
1195
|
+
return at;
|
|
1196
|
+
}
|
|
1197
|
+
function wordEnd(chars, from) {
|
|
1198
|
+
let at = from;
|
|
1199
|
+
while (at < chars.length && !isWord(chars[at]))
|
|
1200
|
+
at++;
|
|
1201
|
+
while (at < chars.length && isWord(chars[at]))
|
|
1202
|
+
at++;
|
|
1203
|
+
return at;
|
|
1204
|
+
}
|
|
1205
|
+
function spacedStart(chars, from) {
|
|
1206
|
+
let at = from;
|
|
1207
|
+
while (at > 0 && SPACE.test(chars[at - 1] ?? ""))
|
|
1208
|
+
at--;
|
|
1209
|
+
while (at > 0 && !SPACE.test(chars[at - 1] ?? ""))
|
|
1210
|
+
at--;
|
|
1211
|
+
return at;
|
|
1212
|
+
}
|
|
1213
|
+
function cut(chars, from, to) {
|
|
1214
|
+
return { text: [...chars.slice(0, from), ...chars.slice(to)].join(""), caret: from };
|
|
1215
|
+
}
|
|
1216
|
+
function editLine({ text, caret }, key) {
|
|
1217
|
+
const chars = [...text];
|
|
1218
|
+
const at = Math.min(Math.max(caret, 0), chars.length);
|
|
1219
|
+
if (typeof key === "object") {
|
|
1220
|
+
const typed = [...key.text];
|
|
1221
|
+
return { text: [...chars.slice(0, at), ...typed, ...chars.slice(at)].join(""), caret: at + typed.length };
|
|
1222
|
+
}
|
|
1223
|
+
switch (key) {
|
|
1224
|
+
case "left":
|
|
1225
|
+
return { text, caret: Math.max(at - 1, 0) };
|
|
1226
|
+
case "right":
|
|
1227
|
+
return { text, caret: Math.min(at + 1, chars.length) };
|
|
1228
|
+
case "wordleft":
|
|
1229
|
+
return { text, caret: wordStart(chars, at) };
|
|
1230
|
+
case "wordright":
|
|
1231
|
+
return { text, caret: wordEnd(chars, at) };
|
|
1232
|
+
case "linestart":
|
|
1233
|
+
return { text, caret: 0 };
|
|
1234
|
+
case "lineend":
|
|
1235
|
+
return { text, caret: chars.length };
|
|
1236
|
+
case "erase":
|
|
1237
|
+
return cut(chars, Math.max(at - 1, 0), at);
|
|
1238
|
+
case "delete":
|
|
1239
|
+
return cut(chars, at, Math.min(at + 1, chars.length));
|
|
1240
|
+
case "word":
|
|
1241
|
+
return cut(chars, spacedStart(chars, at), at);
|
|
1242
|
+
case "killword":
|
|
1243
|
+
return cut(chars, wordStart(chars, at), at);
|
|
1244
|
+
case "killnext":
|
|
1245
|
+
return cut(chars, at, wordEnd(chars, at));
|
|
1246
|
+
case "clear":
|
|
1247
|
+
return cut(chars, 0, at);
|
|
1248
|
+
case "killend":
|
|
1249
|
+
return cut(chars, at, chars.length);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
function visible({ text, caret }, room) {
|
|
1253
|
+
const chars = [...text];
|
|
1254
|
+
const at = Math.min(Math.max(caret, 0), chars.length);
|
|
1255
|
+
const cells = at === chars.length ? [...chars, " "] : chars;
|
|
1256
|
+
const widths = cells.map((char) => Bun.stringWidth(char));
|
|
1257
|
+
const width = (from, to) => widths.slice(from, to).reduce((sum, size) => sum + size, 0);
|
|
1258
|
+
const fits = (from, to) => (from > 0 ? 1 : 0) + width(from, to) + (to < cells.length ? 1 : 0) <= room;
|
|
1259
|
+
let start = at;
|
|
1260
|
+
let end = at + 1;
|
|
1261
|
+
while (start > 0 && fits(start - 1, end))
|
|
1262
|
+
start--;
|
|
1263
|
+
while (end < cells.length && fits(start, end + 1))
|
|
1264
|
+
end++;
|
|
1265
|
+
const left = start > 0 ? "\u2026" : "";
|
|
1266
|
+
const right = end < cells.length ? "\u2026" : "";
|
|
1267
|
+
return { before: left + chars.slice(start, at).join(""), at: chars[at], after: chars.slice(at + 1, end).join("") + right, column: left.length + width(start, at) };
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1179
1270
|
// ../kit/src/picker/score.ts
|
|
1180
1271
|
var MATCH = 16;
|
|
1181
1272
|
var CONSECUTIVE = 12;
|
|
@@ -1268,7 +1359,6 @@ var RESET = /^\x1B\[0?m$/;
|
|
|
1268
1359
|
var COLUMN_GAP = 2;
|
|
1269
1360
|
var PASTE_START = "\x1B[200~";
|
|
1270
1361
|
var PASTE_END = "\x1B[201~";
|
|
1271
|
-
var LAST_WORD = /\S*\s*$/;
|
|
1272
1362
|
var KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
|
|
1273
1363
|
var MOUSE = /^\x1B\[<(\d+);\d+;\d+[a-z]$/i;
|
|
1274
1364
|
var WHEEL_LINES = 3;
|
|
@@ -1291,9 +1381,26 @@ var KEYS = {
|
|
|
1291
1381
|
"\n": "enter",
|
|
1292
1382
|
"\x03": "cancel",
|
|
1293
1383
|
"\x1B": "cancel",
|
|
1384
|
+
"\x1B[D": "left",
|
|
1385
|
+
"\x1BOD": "left",
|
|
1386
|
+
"\x1B[C": "right",
|
|
1387
|
+
"\x1BOC": "right",
|
|
1388
|
+
"\x1B[1;5D": "wordleft",
|
|
1389
|
+
"\x1B[1;3D": "wordleft",
|
|
1390
|
+
"\x1Bb": "wordleft",
|
|
1391
|
+
"\x1B[1;5C": "wordright",
|
|
1392
|
+
"\x1B[1;3C": "wordright",
|
|
1393
|
+
"\x1Bf": "wordright",
|
|
1394
|
+
"\x01": "linestart",
|
|
1395
|
+
"\x05": "lineend",
|
|
1294
1396
|
"\x7F": "erase",
|
|
1295
|
-
"\
|
|
1397
|
+
"\x1B[3~": "delete",
|
|
1398
|
+
"\b": "killword",
|
|
1399
|
+
"\x1B\x7F": "killword",
|
|
1400
|
+
"\x1B[3;5~": "killnext",
|
|
1401
|
+
"\x1Bd": "killnext",
|
|
1296
1402
|
"\x15": "clear",
|
|
1403
|
+
"\v": "killend",
|
|
1297
1404
|
"\x17": "word",
|
|
1298
1405
|
"\t": "tab",
|
|
1299
1406
|
"\x1F": "help",
|
|
@@ -1371,7 +1478,7 @@ function parseKeys(input, paste = { active: false }, ctrls = []) {
|
|
|
1371
1478
|
});
|
|
1372
1479
|
}
|
|
1373
1480
|
function createState(rows, { multi = false, prompt = "> ", query = "", header = "", expect = [], searched = Number.POSITIVE_INFINITY } = {}) {
|
|
1374
|
-
const state = { rows: [], items: [], styles: [], searchable: [], searched, header, expect, key: "", status: "", query, matches: [], cursor: 0, help: false, page: 10, marked: new Set, multi, prompt, done: undefined };
|
|
1481
|
+
const state = { rows: [], items: [], styles: [], searchable: [], searched, header, expect, key: "", status: "", query, caret: [...query].length, matches: [], cursor: 0, help: false, page: 10, marked: new Set, multi, prompt, done: undefined };
|
|
1375
1482
|
return withRows(state, rows);
|
|
1376
1483
|
}
|
|
1377
1484
|
function withRows(state, rows, header = state.header) {
|
|
@@ -1381,8 +1488,9 @@ function withRows(state, rows, header = state.header) {
|
|
|
1381
1488
|
const matches = rank(state.query, searchable);
|
|
1382
1489
|
return { ...state, rows: cells, items: laid.map((row) => row.text), styles: laid.map((row) => row.styles), searchable, header, matches, cursor: Math.max(0, Math.min(matches.length - 1, state.cursor)), marked: new Set };
|
|
1383
1490
|
}
|
|
1384
|
-
function withQuery(state,
|
|
1385
|
-
|
|
1491
|
+
function withQuery(state, key) {
|
|
1492
|
+
const { text, caret } = editLine({ text: state.query, caret: state.caret }, key);
|
|
1493
|
+
return text === state.query ? { ...state, caret } : { ...state, query: text, caret, matches: rank(text, state.searchable), cursor: 0 };
|
|
1386
1494
|
}
|
|
1387
1495
|
function move(state, by) {
|
|
1388
1496
|
return { ...state, cursor: Math.max(0, Math.min(state.matches.length - 1, state.cursor + by)) };
|
|
@@ -1397,9 +1505,11 @@ function press(state, key) {
|
|
|
1397
1505
|
return { ...state, help: false };
|
|
1398
1506
|
if (typeof key === "object") {
|
|
1399
1507
|
if ("text" in key)
|
|
1400
|
-
return withQuery(state,
|
|
1508
|
+
return withQuery(state, key);
|
|
1401
1509
|
return state.expect.includes(key.ctrl) ? { ...state, done: "accept", key: key.ctrl } : state;
|
|
1402
1510
|
}
|
|
1511
|
+
if (isEditKey(key))
|
|
1512
|
+
return withQuery(state, key);
|
|
1403
1513
|
switch (key) {
|
|
1404
1514
|
case "up":
|
|
1405
1515
|
return move(state, -1);
|
|
@@ -1417,12 +1527,6 @@ function press(state, key) {
|
|
|
1417
1527
|
return { ...state, done: "cancel" };
|
|
1418
1528
|
case "help":
|
|
1419
1529
|
return { ...state, help: true };
|
|
1420
|
-
case "erase":
|
|
1421
|
-
return withQuery(state, [...state.query].slice(0, -1).join(""));
|
|
1422
|
-
case "clear":
|
|
1423
|
-
return withQuery(state, "");
|
|
1424
|
-
case "word":
|
|
1425
|
-
return withQuery(state, state.query.replace(LAST_WORD, ""));
|
|
1426
1530
|
case "enter":
|
|
1427
1531
|
return state.matches.length === 0 && state.marked.size === 0 ? state : { ...state, done: "accept" };
|
|
1428
1532
|
case "tab": {
|
|
@@ -1448,6 +1552,17 @@ import { openSync as openSync2 } from "fs";
|
|
|
1448
1552
|
import process18 from "process";
|
|
1449
1553
|
import tty from "tty";
|
|
1450
1554
|
|
|
1555
|
+
// ../kit/src/redraw.ts
|
|
1556
|
+
var SYNC_START = "\x1B[?2026h";
|
|
1557
|
+
var SYNC_END = "\x1B[?2026l";
|
|
1558
|
+
function overwrite(lines, columns) {
|
|
1559
|
+
return lines.map((line) => textWidth(line) % columns === 0 ? `\x1B[2K${line}` : `${line}\x1B[K`).join(`
|
|
1560
|
+
`);
|
|
1561
|
+
}
|
|
1562
|
+
function rowsTaken(lines, columns) {
|
|
1563
|
+
return lines.reduce((rows, line) => rows + Math.max(1, Math.ceil(textWidth(line) / columns)), 0);
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1451
1566
|
// ../kit/src/picker/preview.ts
|
|
1452
1567
|
import process17 from "process";
|
|
1453
1568
|
|
|
@@ -1593,13 +1708,19 @@ function fitStyled(line, width, plain = identity) {
|
|
|
1593
1708
|
const { text, styles } = styled(line);
|
|
1594
1709
|
return fit(text, width, plain, plain, new Set, styles);
|
|
1595
1710
|
}
|
|
1596
|
-
function
|
|
1597
|
-
return
|
|
1711
|
+
function queryShown(state, layout) {
|
|
1712
|
+
return visible({ text: state.query, caret: state.caret }, Math.max(1, layout.listWidth - Bun.stringWidth(state.prompt)));
|
|
1713
|
+
}
|
|
1714
|
+
function caretCell(state, layout) {
|
|
1715
|
+
const shown = queryShown(state, layout);
|
|
1716
|
+
return { column: Math.min(layout.listWidth, Bun.stringWidth(state.prompt) + shown.column + 1), char: shown.at ?? " " };
|
|
1598
1717
|
}
|
|
1599
1718
|
function helpLines(state, layout, theme) {
|
|
1600
1719
|
const lines = [
|
|
1601
1720
|
"type to filter, up, down, ctrl-p, ctrl-n, pgup, pgdn, home, end, the wheel move",
|
|
1602
|
-
|
|
1721
|
+
"left, right, ctrl-a, ctrl-e move in the query, ctrl or alt with left or right by a word",
|
|
1722
|
+
"ctrl-w or ctrl-backspace erase a word, ctrl-u back to the start, ctrl-k to the end, del ahead",
|
|
1723
|
+
`enter picks${state.multi ? ", tab marks" : ""}, esc or ctrl-c cancels`,
|
|
1603
1724
|
...state.expect.length > 0 ? [`${state.expect.join(", ")} end the pick as this command asks`] : []
|
|
1604
1725
|
];
|
|
1605
1726
|
const title = "keys, any key closes this help";
|
|
@@ -1615,7 +1736,9 @@ function listLines(state, layout, theme) {
|
|
|
1615
1736
|
const top = Math.max(0, Math.min(state.cursor - Math.floor(rows / 2), state.matches.length - rows));
|
|
1616
1737
|
const marks = (state.marked.size > 0 ? ` (${state.marked.size} marked)` : "") + (state.status === "" ? "" : ` ${state.status}`);
|
|
1617
1738
|
const promptWidth = Bun.stringWidth(state.prompt);
|
|
1618
|
-
const
|
|
1739
|
+
const shown = queryShown(state, layout);
|
|
1740
|
+
const text = `${shown.before}${shown.at ?? ""}${shown.after}`;
|
|
1741
|
+
const query = { text, width: Bun.stringWidth(text) };
|
|
1619
1742
|
const place = state.matches.length > rows ? ` (${state.cursor + 1} of ${state.matches.length})` : "";
|
|
1620
1743
|
const count = fit(` ${state.matches.length}/${state.items.length}${place}${marks} ctrl-/ keys`, layout.listWidth, theme.label);
|
|
1621
1744
|
const lines = [{ text: theme.accent(state.prompt) + query.text, width: promptWidth + query.width }, count, ...header];
|
|
@@ -1648,7 +1771,8 @@ var ESCAPE_WAIT_MS = 30;
|
|
|
1648
1771
|
var OPEN = { ctrl: "open" };
|
|
1649
1772
|
var HIDE_CURSOR = "\x1B[?25l";
|
|
1650
1773
|
var SHOW_CURSOR = "\x1B[?25h";
|
|
1651
|
-
var
|
|
1774
|
+
var REVERSE = "\x1B[7m";
|
|
1775
|
+
var REVERSE_END = "\x1B[27m";
|
|
1652
1776
|
var PASTE_ON = "\x1B[?2004h";
|
|
1653
1777
|
var PASTE_OFF = "\x1B[?2004l";
|
|
1654
1778
|
var MOUSE_ON = "\x1B[?1000h\x1B[?1006h";
|
|
@@ -1719,14 +1843,14 @@ async function select(rows, settings, terminal = openTerminal()) {
|
|
|
1719
1843
|
if (restored)
|
|
1720
1844
|
return;
|
|
1721
1845
|
const layout = layoutFor({ columns: terminal.columns, rows: terminal.rows }, settings.height, settings.preview !== undefined, settings.previewPosition);
|
|
1722
|
-
let frame = HIDE_CURSOR;
|
|
1846
|
+
let frame = SYNC_START + HIDE_CURSOR;
|
|
1723
1847
|
if (reserved !== layout.height || clear) {
|
|
1724
1848
|
frame += CLEAR_BELOW + `
|
|
1725
1849
|
`.repeat(layout.height - 1) + up(layout.height - 1);
|
|
1726
1850
|
reserved = layout.height;
|
|
1727
1851
|
}
|
|
1728
|
-
|
|
1729
|
-
|
|
1852
|
+
const caret = caretCell(state, layout);
|
|
1853
|
+
frame += `\r${overwrite(render(state, layout, theme, preview), terminal.columns)}${up(layout.height - 1)}\r\x1B[${caret.column}G${REVERSE}${caret.char}${REVERSE_END}\r${SYNC_END}`;
|
|
1730
1854
|
terminal.write(frame);
|
|
1731
1855
|
}
|
|
1732
1856
|
function pageSize() {
|
|
@@ -1928,23 +2052,28 @@ function list(rows) {
|
|
|
1928
2052
|
|
|
1929
2053
|
// ../kit/src/prompt.ts
|
|
1930
2054
|
import process20 from "process";
|
|
1931
|
-
var PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel"
|
|
2055
|
+
var PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel"]);
|
|
1932
2056
|
function readKeys(input, paste = { active: false }) {
|
|
1933
|
-
return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key));
|
|
2057
|
+
return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key) || isEditKey(key));
|
|
2058
|
+
}
|
|
2059
|
+
function roomAfter(question, columns) {
|
|
2060
|
+
return Math.max(columns - textWidth(`? ${question} `) % columns - 1, 1);
|
|
2061
|
+
}
|
|
2062
|
+
function withCaret(colors, line, room, dim = false) {
|
|
2063
|
+
const { before, at, after } = visible(line, room);
|
|
2064
|
+
const tone = dim ? colors.dim : (text) => text;
|
|
2065
|
+
return `${tone(before)}${at === undefined ? colors.dim("\u2588") : colors.inverse(at)}${tone(after)}`;
|
|
1934
2066
|
}
|
|
1935
2067
|
async function input2(question, { default: fallback, mask = false, validate, ...settings } = {}) {
|
|
1936
|
-
let
|
|
2068
|
+
let line = { text: "", caret: 0 };
|
|
1937
2069
|
let invalid;
|
|
1938
|
-
const taken = () =>
|
|
2070
|
+
const taken = () => line.text === "" ? fallback ?? "" : line.text;
|
|
1939
2071
|
const shown = () => mask ? "*".repeat([...taken()].length) : taken();
|
|
1940
2072
|
const accepted = await ask(question, settings, (colors, state, { columns }) => {
|
|
1941
2073
|
if (state !== "asking")
|
|
1942
2074
|
return [answer(colors, question, state, shown())];
|
|
1943
|
-
const
|
|
1944
|
-
|
|
1945
|
-
const tail = characters.length > room ? `\u2026${characters.slice(1 - room).join("")}` : shown();
|
|
1946
|
-
const typed = value === "" ? colors.dim(tail) : tail;
|
|
1947
|
-
return [`${colors.cyan("?")} ${question} ${typed}${colors.dim("\u2588")}`, ...invalid === undefined ? [] : [` ${colors.red(invalid)}`]];
|
|
2075
|
+
const typed = line.text === "" ? { text: shown(), caret: [...shown()].length } : { text: shown(), caret: line.caret };
|
|
2076
|
+
return [`${colors.cyan("?")} ${question} ${withCaret(colors, typed, roomAfter(question, columns), line.text === "")}`, ...invalid === undefined ? [] : [` ${colors.red(invalid)}`]];
|
|
1948
2077
|
}, (key) => {
|
|
1949
2078
|
if (key === "cancel")
|
|
1950
2079
|
return "cancel";
|
|
@@ -1953,10 +2082,9 @@ async function input2(question, { default: fallback, mask = false, validate, ...
|
|
|
1953
2082
|
invalid = validate?.(taken());
|
|
1954
2083
|
return invalid === undefined ? "enter" : undefined;
|
|
1955
2084
|
}
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
value += key.text;
|
|
2085
|
+
const edit = { home: "linestart", end: "lineend" }[key] ?? key;
|
|
2086
|
+
if (typeof edit === "object" || isEditKey(edit))
|
|
2087
|
+
line = editLine(line, edit);
|
|
1960
2088
|
return;
|
|
1961
2089
|
});
|
|
1962
2090
|
return accepted ? taken() : undefined;
|
|
@@ -1974,8 +2102,8 @@ async function ask(question, { hint, terminal = process20 }, render, press) {
|
|
|
1974
2102
|
const columns = () => stderr.columns || 80;
|
|
1975
2103
|
const draw = (state, last = false) => {
|
|
1976
2104
|
const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
|
|
1977
|
-
|
|
1978
|
-
|
|
2105
|
+
const rows = rowsTaken(frame, columns());
|
|
2106
|
+
stderr.write(`${SYNC_START}\r${overwrite(frame, columns())}\x1B[0J${last || rows < 2 ? "" : `\x1B[${rows - 1}A`}${last ? "" : "\r"}${SYNC_END}`);
|
|
1979
2107
|
current = state;
|
|
1980
2108
|
};
|
|
1981
2109
|
const redraw = () => draw(current);
|
|
@@ -2466,9 +2594,8 @@ j -
|
|
|
2466
2594
|
Without a name, picks a recipe, target, script or task of this folder, its parents and its child folders when a terminal is attached, and runs it. The ones run last come first, per folder. Without a terminal it lists them instead.
|
|
2467
2595
|
\`j -\` runs the last one again with the same arguments, \`j <name> [args...]\` runs without the picker, the words after the name filling the parameters in order and the required ones left being asked for.
|
|
2468
2596
|
The sources are a Justfile, a Makefile, the scripts of a package.json (through its package manager), composer.json scripts, deno tasks, a Taskfile, mise tasks and a pyproject (poe tasks and entry points).
|
|
2469
|
-
A name is the key behind the folder it runs from, \`api/test\`, bare for this folder. A name several entries share offers them, unless it comes qualified by its runner: \`just:check\`, \`bun:api/test
|
|
2470
|
-
|
|
2471
|
-
Exits with the code of the command it ran, 1 when there is nothing to run here or nothing by that name.`;
|
|
2597
|
+
A name is the key behind the folder it runs from, \`api/test\`, bare for this folder. A name several entries share offers them, unless it comes qualified by its runner: \`just:check\`, \`bun:api/test\`.`;
|
|
2598
|
+
var EXITS = [["its own", "the code of the command it ran"], [1, "there is nothing to run here or nothing by that name"]];
|
|
2472
2599
|
var options = {
|
|
2473
2600
|
json: jsonOption("[{ id, key, runner, dir, name, doc, parameters }]")
|
|
2474
2601
|
};
|
|
@@ -2546,6 +2673,7 @@ async function j2(argv) {
|
|
|
2546
2673
|
const args = emitting ? argv.slice(1) : argv;
|
|
2547
2674
|
const last = args[0] === "-";
|
|
2548
2675
|
const parsed = last ? { values: {}, positionals: ["-"], rest: args.slice(1) } : parse(args, usage2, options, {
|
|
2676
|
+
exits: EXITS,
|
|
2549
2677
|
positionals: ["[name]"],
|
|
2550
2678
|
candidates: { "[name]": completions },
|
|
2551
2679
|
trailing: true,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-check",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.19.0",
|
|
5
5
|
"description": "check, fix and errs: run a repo's check, typecheck, lint and test steps or its fixers, inside its docker compose service when one mounts the folder, showing only what failed with each full output saved to a file, and turn tsc, eslint, bun test, vitest, playwright, phpunit, phpstan and php-cs-fixer logs into file:line:col errors.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"j": "$npm_execpath src/j-cli.ts"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@kaynooo/cli-kit": "0.
|
|
37
|
+
"@kaynooo/cli-kit": "0.39.0"
|
|
38
38
|
}
|
|
39
39
|
}
|