@kaynooo/cli-check 0.8.0 → 0.9.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 +223 -21
- package/dist/errs-cli.js +225 -23
- package/dist/fix-cli.js +223 -21
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ errs --json -- keslint src # {errors, unrecognised, log?, code?}
|
|
|
89
89
|
errs --in app -- vendor/bin/phpunit # in this compose service; --host forces the host
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
Turns tsc, tsgo and vue-tsc (plain and pretty), bun check, eslint and keslint (stylish), bun test, vitest, playwright, phpunit, paratest, phpstan
|
|
92
|
+
Turns tsc, tsgo and vue-tsc (plain and pretty), bun check, eslint and keslint (stylish), bun test, vitest, playwright, phpunit, paratest, phpstan, php-cs-fixer, go (build and vet), cargo (rustc), ruff (concise and full) and pytest logs into one `file:line:col: message (rule)` line per error, so a session reads the failures without the log. A failed bun test reads `file:line:col: <test name>: <assertion> (expected X, received Y)`, located at the first stack frame of its error, and an eslint warning is prefixed `warning:`. Absolute paths under the current folder are printed relative.
|
|
93
93
|
|
|
94
94
|
| Tool | Read from | One error per |
|
|
95
95
|
| --- | --- | --- |
|
|
@@ -99,6 +99,6 @@ Turns tsc, tsgo and vue-tsc (plain and pretty), bun check, eslint and keslint (s
|
|
|
99
99
|
| `playwright` | the list and line reporters | failed test: the spec file and line of the first stack frame, the first error line and `expected X, received Y`. A test that passed on retry is flaky and not reported |
|
|
100
100
|
| `vitest` | the default and verbose reporters | failed test, or suite that failed to load, at its first `file:line:col` frame |
|
|
101
101
|
|
|
102
|
-
`--json` prints `{errors: [{tool, file, line, column, rule?, severity, message, test?}], unrecognised, log?, code?}`, `tool` one of `tsc`, `eslint`, `bun check`, `bun test`, `vitest`, `playwright`, `phpunit`, `phpstan
|
|
102
|
+
`--json` prints `{errors: [{tool, file, line, column, rule?, severity, message, test?}], unrecognised, log?, code?}`, `tool` one of `tsc`, `eslint`, `bun check`, `bun test`, `vitest`, `playwright`, `phpunit`, `phpstan`, `php-cs-fixer`, `go`, `cargo`, `ruff` or `pytest`. Lines no format recognised are never dropped silently: their count goes to stderr, with the path of the full log. A command run after `--` has its whole output saved with the same log writer as `out`, and `log` is that file (the file given when a log is read, nothing for stdin). A first argument that is neither an option nor an existing file starts the command, so the `--` is optional. A command runs in the compose service mounting the current folder like a `check` step does (see above), `--in` and `--host` applying only to a command; a service that is down exits 1 with the service named.
|
|
103
103
|
|
|
104
104
|
Exit code 0 when no error was found and the command, if any, passed, 1 when errors were found or the command failed, 2 on bad usage.
|
package/dist/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import process2 from "process";
|
|
|
14
14
|
// ../kit/src/style.ts
|
|
15
15
|
import process from "process";
|
|
16
16
|
|
|
17
|
-
// ../../node_modules/.bun/@kaynooo+utils@2.31.
|
|
17
|
+
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
|
|
18
18
|
function x(s) {
|
|
19
19
|
let r = s.startsWith("#") ? s.slice(1).toLowerCase() : s.toLowerCase();
|
|
20
20
|
if (!/^[a-f0-9]+$/.test(r))
|
|
@@ -234,7 +234,7 @@ class e {
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
// ../../node_modules/.bun/@kaynooo+utils@2.31.
|
|
237
|
+
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-y1msbssb.js
|
|
238
238
|
var r = 39;
|
|
239
239
|
var o = 49;
|
|
240
240
|
var f2 = "\x1B[";
|
|
@@ -433,8 +433,12 @@ class HelpShown extends Exit {
|
|
|
433
433
|
|
|
434
434
|
class Completing {
|
|
435
435
|
options;
|
|
436
|
-
|
|
436
|
+
positionals;
|
|
437
|
+
candidates;
|
|
438
|
+
constructor(options, positionals = [], candidates = {}) {
|
|
437
439
|
this.options = options;
|
|
440
|
+
this.positionals = positionals;
|
|
441
|
+
this.candidates = candidates;
|
|
438
442
|
}
|
|
439
443
|
}
|
|
440
444
|
var completion = { active: false };
|
|
@@ -477,8 +481,10 @@ function exampleRows(examples, colors = paint(process3.stdout)) {
|
|
|
477
481
|
function optionRows(options, colors = paint(process3.stdout)) {
|
|
478
482
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
479
483
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
480
|
-
const
|
|
481
|
-
|
|
484
|
+
const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
|
|
485
|
+
const placeholder = option.optional === undefined ? named : `[${named}]`;
|
|
486
|
+
const value = option.type === "string" ? ` ${colors.dim(placeholder)}` : "";
|
|
487
|
+
return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: option.description ?? "" };
|
|
482
488
|
});
|
|
483
489
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
484
490
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
@@ -504,14 +510,13 @@ function applyOutput(color, plain, env = process3.env) {
|
|
|
504
510
|
function parse(args, usage, options, settings = {}) {
|
|
505
511
|
const output = Object.fromEntries(Object.entries(OUTPUT_OPTIONS).filter(([name]) => !(name in options)));
|
|
506
512
|
const all = { ...options, ...output, help: { type: "boolean", short: "h", description: "show this help" } };
|
|
513
|
+
const listing = listed(all, settings.allowNegative === true);
|
|
507
514
|
if (completion.active)
|
|
508
|
-
throw new Completing(
|
|
509
|
-
const
|
|
510
|
-
const own = separator === -1 ? args : args.slice(0, separator);
|
|
511
|
-
const rest = separator === -1 ? undefined : args.slice(separator + 1);
|
|
515
|
+
throw new Completing(listing, settings.positionals, settings.candidates);
|
|
516
|
+
const { own, rest } = settings.trailing === true ? splitTrailing(args, all, settings.positionals?.length ?? 0) : splitRest(args, settings.rest === true);
|
|
512
517
|
let parsed;
|
|
513
518
|
try {
|
|
514
|
-
parsed = parseArgs({ args: joinDashValues(own, all), options: all, allowPositionals: true, allowNegative: settings.allowNegative === true, strict: true });
|
|
519
|
+
parsed = parseArgs({ args: joinDashValues(withBare(own, all), all), options: all, allowPositionals: true, allowNegative: settings.allowNegative === true, strict: true });
|
|
515
520
|
} catch (error) {
|
|
516
521
|
const message = parseError(error);
|
|
517
522
|
throw new UsageError(message, nearestOption(message, all, settings.allowNegative === true));
|
|
@@ -519,12 +524,84 @@ function parse(args, usage, options, settings = {}) {
|
|
|
519
524
|
const values = parsed.values;
|
|
520
525
|
applyOutput("color" in output ? values.color : undefined, "plain" in output ? values.plain : undefined);
|
|
521
526
|
if (values.help === true) {
|
|
522
|
-
console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings)) : helpText(usage,
|
|
527
|
+
console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings)) : helpText(usage, listing, undefined, settings));
|
|
523
528
|
throw new HelpShown;
|
|
524
529
|
}
|
|
530
|
+
checkChoices(parsed.values, all);
|
|
531
|
+
checkConflicts(parsed.values, all);
|
|
525
532
|
if (settings.positionals !== undefined)
|
|
526
533
|
checkPositionals(parsed.positionals, settings.positionals);
|
|
527
|
-
return { ...parsed, positionals: parsed.positionals, rest };
|
|
534
|
+
return { ...parsed, values: parsed.values, positionals: parsed.positionals, rest };
|
|
535
|
+
}
|
|
536
|
+
function splitRest(args, passes) {
|
|
537
|
+
const separator = passes ? args.indexOf("--") : -1;
|
|
538
|
+
return { own: separator === -1 ? args : args.slice(0, separator), rest: separator === -1 ? undefined : args.slice(separator + 1) };
|
|
539
|
+
}
|
|
540
|
+
function splitTrailing(args, options, count) {
|
|
541
|
+
const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
|
|
542
|
+
let seen = 0;
|
|
543
|
+
if (count === 0)
|
|
544
|
+
return { own: args, rest: undefined };
|
|
545
|
+
for (let at = 0;at < args.length; at++) {
|
|
546
|
+
const word = args[at];
|
|
547
|
+
if (word === "--")
|
|
548
|
+
break;
|
|
549
|
+
if (word.startsWith("-")) {
|
|
550
|
+
if (takesValue(word))
|
|
551
|
+
at++;
|
|
552
|
+
continue;
|
|
553
|
+
}
|
|
554
|
+
seen++;
|
|
555
|
+
if (seen === count)
|
|
556
|
+
return { own: args.slice(0, at + 1), rest: args.slice(at + 1) };
|
|
557
|
+
}
|
|
558
|
+
return { own: args, rest: undefined };
|
|
559
|
+
}
|
|
560
|
+
function listed(options, allowNegative) {
|
|
561
|
+
if (!allowNegative)
|
|
562
|
+
return options;
|
|
563
|
+
return Object.fromEntries(Object.entries(options).flatMap(([name, option]) => {
|
|
564
|
+
if (option.type !== "boolean" || option.negative === undefined)
|
|
565
|
+
return [[name, option]];
|
|
566
|
+
return [...option.description === undefined ? [] : [[name, option]], [`no-${name}`, { type: "boolean", description: option.negative }]];
|
|
567
|
+
}));
|
|
568
|
+
}
|
|
569
|
+
function withBare(args, options) {
|
|
570
|
+
const bare = new Map(Object.entries(options).flatMap(([name, { short, optional }]) => optional === undefined ? [] : [[`--${name}`, optional], ...short === undefined ? [] : [[`-${short}`, optional]]]));
|
|
571
|
+
if (bare.size === 0)
|
|
572
|
+
return args;
|
|
573
|
+
const separator = args.indexOf("--");
|
|
574
|
+
const own = separator === -1 ? args : args.slice(0, separator);
|
|
575
|
+
return [...own.flatMap((arg, index) => {
|
|
576
|
+
const optional = bare.get(arg);
|
|
577
|
+
const next = own[index + 1];
|
|
578
|
+
const value = next !== undefined && (optional?.accepts === undefined ? !next.startsWith("-") : optional.accepts.test(next));
|
|
579
|
+
return optional === undefined || value ? [arg] : [arg, optional.bare];
|
|
580
|
+
}), ...separator === -1 ? [] : args.slice(separator)];
|
|
581
|
+
}
|
|
582
|
+
function checkConflicts(values, options) {
|
|
583
|
+
const given = (name) => values[name] !== undefined && values[name] !== false;
|
|
584
|
+
for (const [name, { conflicts = [] }] of Object.entries(options)) {
|
|
585
|
+
const other = given(name) ? conflicts.find(given) : undefined;
|
|
586
|
+
if (other !== undefined)
|
|
587
|
+
badUsage(`--${name} cannot be used with --${other}`);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
function checkChoices(values, options) {
|
|
591
|
+
for (const [name, option] of Object.entries(options)) {
|
|
592
|
+
if (option.choices === undefined)
|
|
593
|
+
continue;
|
|
594
|
+
const given = values[name];
|
|
595
|
+
for (const value of Array.isArray(given) ? given : [given]) {
|
|
596
|
+
if (typeof value === "string")
|
|
597
|
+
oneOf(value, name, option.choices);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
function oneOf(value, name, choices) {
|
|
602
|
+
if (!choices.includes(value))
|
|
603
|
+
badUsage(`${name.startsWith("<") ? name : `--${name}`} takes one of ${choices.join(", ")}, not ${value}`);
|
|
604
|
+
return value;
|
|
528
605
|
}
|
|
529
606
|
function checkPositionals(given, names) {
|
|
530
607
|
const variadic = names.at(-1)?.replace("]", "").endsWith("...") === true;
|
|
@@ -756,22 +833,55 @@ function reportThrown(prefix, error, redact = (text) => text, json = false) {
|
|
|
756
833
|
}
|
|
757
834
|
var COMPLETE = "__complete";
|
|
758
835
|
var FILES = "__files__";
|
|
759
|
-
async function
|
|
836
|
+
async function completingOf(run) {
|
|
760
837
|
completion.active = true;
|
|
761
838
|
try {
|
|
762
839
|
await run([]);
|
|
763
840
|
} catch (error) {
|
|
764
841
|
if (error instanceof Completing)
|
|
765
|
-
return error
|
|
842
|
+
return error;
|
|
766
843
|
} finally {
|
|
767
844
|
completion.active = false;
|
|
768
845
|
}
|
|
769
|
-
return {};
|
|
846
|
+
return new Completing({});
|
|
847
|
+
}
|
|
848
|
+
function candidateLine(candidate) {
|
|
849
|
+
return typeof candidate === "string" ? candidate : candidate.join("\t");
|
|
850
|
+
}
|
|
851
|
+
function positionalBeingTyped(before, { options, positionals }) {
|
|
852
|
+
const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
|
|
853
|
+
let index = 0;
|
|
854
|
+
let at = 0;
|
|
855
|
+
while (at < before.length) {
|
|
856
|
+
const word = before[at];
|
|
857
|
+
if (word === "--") {
|
|
858
|
+
index += before.length - at - 1;
|
|
859
|
+
break;
|
|
860
|
+
}
|
|
861
|
+
if (!word.startsWith("-"))
|
|
862
|
+
index++;
|
|
863
|
+
else if (takesValue(word))
|
|
864
|
+
at++;
|
|
865
|
+
at++;
|
|
866
|
+
}
|
|
867
|
+
const last = positionals.at(-1);
|
|
868
|
+
if (index < positionals.length)
|
|
869
|
+
return positionals[index];
|
|
870
|
+
return last?.replace("]", "").endsWith("...") === true ? last : undefined;
|
|
770
871
|
}
|
|
771
872
|
async function leafCandidates(run, words) {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
873
|
+
const completing = await completingOf(run);
|
|
874
|
+
if ((words.at(-1) ?? "").startsWith("-"))
|
|
875
|
+
return Object.entries(completing.options).map(([name, option]) => option.description === undefined ? `--${name}` : `--${name} ${option.description}`);
|
|
876
|
+
const flag = words.at(-2);
|
|
877
|
+
const option = flag?.startsWith("-") === true ? Object.entries(completing.options).find(([name, { short }]) => flag === `--${name}` || flag === `-${short}`)?.[1] : undefined;
|
|
878
|
+
if (option?.type === "string") {
|
|
879
|
+
const values = option.choices === undefined ? await option.candidates?.() : option.choices;
|
|
880
|
+
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
881
|
+
}
|
|
882
|
+
const name = positionalBeingTyped(words.slice(0, -1), completing);
|
|
883
|
+
const values = name === undefined ? undefined : await completing.candidates[name]?.();
|
|
884
|
+
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
775
885
|
}
|
|
776
886
|
async function printCandidates(found) {
|
|
777
887
|
for (const line of await found)
|
|
@@ -845,7 +955,7 @@ var {Glob } = globalThis.Bun;
|
|
|
845
955
|
var SESSION_FILES = new Glob("*.json");
|
|
846
956
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
847
957
|
// package.json
|
|
848
|
-
var version = "0.
|
|
958
|
+
var version = "0.9.0";
|
|
849
959
|
|
|
850
960
|
// src/check.ts
|
|
851
961
|
import { join as join5 } from "path";
|
|
@@ -1571,9 +1681,24 @@ var BUN_TEST_EXPECTED = /^Expected: (.*)$/;
|
|
|
1571
1681
|
var BUN_TEST_RECEIVED = /^Received: (.*)$/;
|
|
1572
1682
|
var BUN_TEST_FRAME = /^\s+at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
|
|
1573
1683
|
var BUN_TEST_FILE = /^\S+\.test\.[jt]sx?:$/;
|
|
1684
|
+
var GO_ERROR = /^\s*(?:vet: )?(\S+\.go):(\d+):(?:(\d+):)? (.+)$/;
|
|
1685
|
+
var GO_NOISE = /^# \S+(?: \[\S+\])?$/;
|
|
1686
|
+
var ARROW = /^\s*--> (.+?):(\d+):(\d+)$/;
|
|
1687
|
+
var CARGO_HEADER = /^(error|warning)(?:\[(\w+)\])?: (.*)$/;
|
|
1688
|
+
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)/;
|
|
1689
|
+
var RUFF_CONCISE = /^(\S+\.pyi?):(\d+):(\d+): ([A-Z]+\d+) (?:\[\*\] )?(.*)$/;
|
|
1690
|
+
var RUFF_HEADER = /^([A-Z]{1,5}\d{1,4}) (?:\[\*\] )?(.+)$/;
|
|
1691
|
+
var RUFF_NOISE = /^(?:Found \d+ errors?\.|\[\*\] \d+ fixable|No fixes available|All checks passed|help: |\s*(?:\|\s*)?$)/;
|
|
1692
|
+
var PYTEST_LOCATION = /^(\S+\.py):(\d+): (\S.*)$/;
|
|
1693
|
+
var PYTEST_E_LINE = /^E {3}(.*)$/;
|
|
1694
|
+
var PYTEST_BANNER = /^={3,} (.*?) ={3,}$/;
|
|
1695
|
+
var PYTEST_FAILURES = new Set(["FAILURES", "ERRORS"]);
|
|
1696
|
+
var PYTEST_SUMMARY_LINE = /^(?:FAILED|ERROR) \S/;
|
|
1697
|
+
var PYTEST_EXCEPTION_END = /[\s:]/;
|
|
1698
|
+
var PYTEST_NOISE = /^(?:platform |rootdir: |collected |plugins: |configfile: |cachedir: |\S+\.pyi? [.FEsxXR]+ +\[ *\d+%\]$|\S+\.py:\d+: $)/;
|
|
1574
1699
|
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)/;
|
|
1575
1700
|
function isNoise(line) {
|
|
1576
|
-
return line.trim() === "" || [NOISE, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_SUMMARY, ESLINT_SUMMARY, BOUNDARY, BASH_ECHO, ...PHP_NOISE, ...E2E_NOISE].some((pattern) => pattern.test(line));
|
|
1701
|
+
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));
|
|
1577
1702
|
}
|
|
1578
1703
|
var collectBunCheck = (lines, used) => {
|
|
1579
1704
|
const errors = [];
|
|
@@ -1670,7 +1795,84 @@ var collectEslint = (lines, used) => {
|
|
|
1670
1795
|
}
|
|
1671
1796
|
return errors;
|
|
1672
1797
|
};
|
|
1673
|
-
var
|
|
1798
|
+
var collectGo = (lines, used) => {
|
|
1799
|
+
const errors = [];
|
|
1800
|
+
for (const [index, line] of lines.entries()) {
|
|
1801
|
+
const match = used.has(index) ? null : GO_ERROR.exec(line);
|
|
1802
|
+
if (match === null)
|
|
1803
|
+
continue;
|
|
1804
|
+
errors.push({ tool: "go", file: match[1] ?? "", line: Number(match[2]), column: Number(match[3] ?? 0), severity: "error", message: match[4] ?? "" });
|
|
1805
|
+
used.add(index);
|
|
1806
|
+
}
|
|
1807
|
+
return errors;
|
|
1808
|
+
};
|
|
1809
|
+
var collectArrowed = (lines, used) => {
|
|
1810
|
+
const errors = [];
|
|
1811
|
+
for (const [index, line] of lines.entries()) {
|
|
1812
|
+
const arrow = used.has(index) || index === 0 ? null : ARROW.exec(line);
|
|
1813
|
+
const header = arrow === null ? null : lines[index - 1] ?? "";
|
|
1814
|
+
const cargo = header === null ? null : CARGO_HEADER.exec(header);
|
|
1815
|
+
const ruff = header === null || cargo !== null ? null : RUFF_HEADER.exec(header);
|
|
1816
|
+
if (arrow === null || cargo === null && ruff === null || used.has(index - 1))
|
|
1817
|
+
continue;
|
|
1818
|
+
const [, file, row, column] = arrow;
|
|
1819
|
+
const fields = { file: file ?? "", line: Number(row), column: Number(column) };
|
|
1820
|
+
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] ?? "" });
|
|
1821
|
+
used.add(index - 1);
|
|
1822
|
+
used.add(index);
|
|
1823
|
+
for (let frame = index + 1;frame < lines.length && (lines[frame] ?? "").trim() !== ""; frame++) {
|
|
1824
|
+
if (CARGO_HEADER.test(lines[frame] ?? "") || RUFF_HEADER.test(lines[frame] ?? ""))
|
|
1825
|
+
break;
|
|
1826
|
+
used.add(frame);
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
return errors;
|
|
1830
|
+
};
|
|
1831
|
+
var collectRuff = (lines, used) => {
|
|
1832
|
+
const errors = [];
|
|
1833
|
+
for (const [index, line] of lines.entries()) {
|
|
1834
|
+
const match = used.has(index) ? null : RUFF_CONCISE.exec(line);
|
|
1835
|
+
if (match === null)
|
|
1836
|
+
continue;
|
|
1837
|
+
errors.push({ tool: "ruff", file: match[1] ?? "", line: Number(match[2]), column: Number(match[3]), rule: match[4], severity: "error", message: match[5] ?? "" });
|
|
1838
|
+
used.add(index);
|
|
1839
|
+
}
|
|
1840
|
+
return errors;
|
|
1841
|
+
};
|
|
1842
|
+
var collectPytest = (lines, used) => {
|
|
1843
|
+
const errors = [];
|
|
1844
|
+
const title = (line) => PYTEST_BANNER.exec(line ?? "")?.[1];
|
|
1845
|
+
const start = lines.findIndex((line) => PYTEST_FAILURES.has(title(line) ?? ""));
|
|
1846
|
+
if (start === -1)
|
|
1847
|
+
return errors;
|
|
1848
|
+
const end = lines.findIndex((line, index) => index > start && title(line) !== undefined && !PYTEST_FAILURES.has(title(line) ?? ""));
|
|
1849
|
+
const stop = end === -1 ? lines.length : end;
|
|
1850
|
+
let message = [];
|
|
1851
|
+
for (let index = start;index < stop; index++) {
|
|
1852
|
+
const line = lines[index] ?? "";
|
|
1853
|
+
const failure = PYTEST_E_LINE.exec(line);
|
|
1854
|
+
if (failure !== null) {
|
|
1855
|
+
message.push((failure[1] ?? "").trim());
|
|
1856
|
+
} else {
|
|
1857
|
+
const location = PYTEST_LOCATION.exec(line);
|
|
1858
|
+
if (location !== null) {
|
|
1859
|
+
const [exception = ""] = (location[3] ?? "").split(PYTEST_EXCEPTION_END);
|
|
1860
|
+
const first = message[0] ?? "";
|
|
1861
|
+
const text = first === "" || first.startsWith(exception) ? first || (location[3] ?? "") : `${location[3] ?? ""}: ${first}`;
|
|
1862
|
+
errors.push({ tool: "pytest", file: location[1] ?? "", line: Number(location[2]), column: 0, severity: "error", message: text });
|
|
1863
|
+
}
|
|
1864
|
+
if (line.trim() !== "")
|
|
1865
|
+
message = [];
|
|
1866
|
+
}
|
|
1867
|
+
used.add(index);
|
|
1868
|
+
}
|
|
1869
|
+
for (let index = stop;index < lines.length; index++) {
|
|
1870
|
+
if (PYTEST_SUMMARY_LINE.test(lines[index] ?? ""))
|
|
1871
|
+
used.add(index);
|
|
1872
|
+
}
|
|
1873
|
+
return errors;
|
|
1874
|
+
};
|
|
1875
|
+
var COLLECTORS = [collectBunCheck, collectBunTest, collectVitest, collectPlaywright, collectPhpunit, collectPhpstan, collectCsFixer, collectPytest, collectArrowed, collectRuff, collectGo, collectTsc, collectEslint];
|
|
1674
1876
|
function parseErrors(output) {
|
|
1675
1877
|
const lines = stripAnsi(output).split(`
|
|
1676
1878
|
`);
|
package/dist/errs-cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import process2 from "process";
|
|
|
14
14
|
// ../kit/src/style.ts
|
|
15
15
|
import process from "process";
|
|
16
16
|
|
|
17
|
-
// ../../node_modules/.bun/@kaynooo+utils@2.31.
|
|
17
|
+
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
|
|
18
18
|
function x(s) {
|
|
19
19
|
let r = s.startsWith("#") ? s.slice(1).toLowerCase() : s.toLowerCase();
|
|
20
20
|
if (!/^[a-f0-9]+$/.test(r))
|
|
@@ -234,7 +234,7 @@ class e {
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
// ../../node_modules/.bun/@kaynooo+utils@2.31.
|
|
237
|
+
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-y1msbssb.js
|
|
238
238
|
var r = 39;
|
|
239
239
|
var o = 49;
|
|
240
240
|
var f2 = "\x1B[";
|
|
@@ -433,8 +433,12 @@ class HelpShown extends Exit {
|
|
|
433
433
|
|
|
434
434
|
class Completing {
|
|
435
435
|
options;
|
|
436
|
-
|
|
436
|
+
positionals;
|
|
437
|
+
candidates;
|
|
438
|
+
constructor(options, positionals = [], candidates = {}) {
|
|
437
439
|
this.options = options;
|
|
440
|
+
this.positionals = positionals;
|
|
441
|
+
this.candidates = candidates;
|
|
438
442
|
}
|
|
439
443
|
}
|
|
440
444
|
var completion = { active: false };
|
|
@@ -477,8 +481,10 @@ function exampleRows(examples, colors = paint(process3.stdout)) {
|
|
|
477
481
|
function optionRows(options, colors = paint(process3.stdout)) {
|
|
478
482
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
479
483
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
480
|
-
const
|
|
481
|
-
|
|
484
|
+
const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
|
|
485
|
+
const placeholder = option.optional === undefined ? named : `[${named}]`;
|
|
486
|
+
const value = option.type === "string" ? ` ${colors.dim(placeholder)}` : "";
|
|
487
|
+
return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: option.description ?? "" };
|
|
482
488
|
});
|
|
483
489
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
484
490
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
@@ -504,14 +510,13 @@ function applyOutput(color, plain, env = process3.env) {
|
|
|
504
510
|
function parse(args, usage, options, settings = {}) {
|
|
505
511
|
const output = Object.fromEntries(Object.entries(OUTPUT_OPTIONS).filter(([name]) => !(name in options)));
|
|
506
512
|
const all = { ...options, ...output, help: { type: "boolean", short: "h", description: "show this help" } };
|
|
513
|
+
const listing = listed(all, settings.allowNegative === true);
|
|
507
514
|
if (completion.active)
|
|
508
|
-
throw new Completing(
|
|
509
|
-
const
|
|
510
|
-
const own = separator === -1 ? args : args.slice(0, separator);
|
|
511
|
-
const rest = separator === -1 ? undefined : args.slice(separator + 1);
|
|
515
|
+
throw new Completing(listing, settings.positionals, settings.candidates);
|
|
516
|
+
const { own, rest } = settings.trailing === true ? splitTrailing(args, all, settings.positionals?.length ?? 0) : splitRest(args, settings.rest === true);
|
|
512
517
|
let parsed;
|
|
513
518
|
try {
|
|
514
|
-
parsed = parseArgs({ args: joinDashValues(own, all), options: all, allowPositionals: true, allowNegative: settings.allowNegative === true, strict: true });
|
|
519
|
+
parsed = parseArgs({ args: joinDashValues(withBare(own, all), all), options: all, allowPositionals: true, allowNegative: settings.allowNegative === true, strict: true });
|
|
515
520
|
} catch (error) {
|
|
516
521
|
const message = parseError(error);
|
|
517
522
|
throw new UsageError(message, nearestOption(message, all, settings.allowNegative === true));
|
|
@@ -519,12 +524,84 @@ function parse(args, usage, options, settings = {}) {
|
|
|
519
524
|
const values = parsed.values;
|
|
520
525
|
applyOutput("color" in output ? values.color : undefined, "plain" in output ? values.plain : undefined);
|
|
521
526
|
if (values.help === true) {
|
|
522
|
-
console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings)) : helpText(usage,
|
|
527
|
+
console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings)) : helpText(usage, listing, undefined, settings));
|
|
523
528
|
throw new HelpShown;
|
|
524
529
|
}
|
|
530
|
+
checkChoices(parsed.values, all);
|
|
531
|
+
checkConflicts(parsed.values, all);
|
|
525
532
|
if (settings.positionals !== undefined)
|
|
526
533
|
checkPositionals(parsed.positionals, settings.positionals);
|
|
527
|
-
return { ...parsed, positionals: parsed.positionals, rest };
|
|
534
|
+
return { ...parsed, values: parsed.values, positionals: parsed.positionals, rest };
|
|
535
|
+
}
|
|
536
|
+
function splitRest(args, passes) {
|
|
537
|
+
const separator = passes ? args.indexOf("--") : -1;
|
|
538
|
+
return { own: separator === -1 ? args : args.slice(0, separator), rest: separator === -1 ? undefined : args.slice(separator + 1) };
|
|
539
|
+
}
|
|
540
|
+
function splitTrailing(args, options, count) {
|
|
541
|
+
const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
|
|
542
|
+
let seen = 0;
|
|
543
|
+
if (count === 0)
|
|
544
|
+
return { own: args, rest: undefined };
|
|
545
|
+
for (let at = 0;at < args.length; at++) {
|
|
546
|
+
const word = args[at];
|
|
547
|
+
if (word === "--")
|
|
548
|
+
break;
|
|
549
|
+
if (word.startsWith("-")) {
|
|
550
|
+
if (takesValue(word))
|
|
551
|
+
at++;
|
|
552
|
+
continue;
|
|
553
|
+
}
|
|
554
|
+
seen++;
|
|
555
|
+
if (seen === count)
|
|
556
|
+
return { own: args.slice(0, at + 1), rest: args.slice(at + 1) };
|
|
557
|
+
}
|
|
558
|
+
return { own: args, rest: undefined };
|
|
559
|
+
}
|
|
560
|
+
function listed(options, allowNegative) {
|
|
561
|
+
if (!allowNegative)
|
|
562
|
+
return options;
|
|
563
|
+
return Object.fromEntries(Object.entries(options).flatMap(([name, option]) => {
|
|
564
|
+
if (option.type !== "boolean" || option.negative === undefined)
|
|
565
|
+
return [[name, option]];
|
|
566
|
+
return [...option.description === undefined ? [] : [[name, option]], [`no-${name}`, { type: "boolean", description: option.negative }]];
|
|
567
|
+
}));
|
|
568
|
+
}
|
|
569
|
+
function withBare(args, options) {
|
|
570
|
+
const bare = new Map(Object.entries(options).flatMap(([name, { short, optional }]) => optional === undefined ? [] : [[`--${name}`, optional], ...short === undefined ? [] : [[`-${short}`, optional]]]));
|
|
571
|
+
if (bare.size === 0)
|
|
572
|
+
return args;
|
|
573
|
+
const separator = args.indexOf("--");
|
|
574
|
+
const own = separator === -1 ? args : args.slice(0, separator);
|
|
575
|
+
return [...own.flatMap((arg, index) => {
|
|
576
|
+
const optional = bare.get(arg);
|
|
577
|
+
const next = own[index + 1];
|
|
578
|
+
const value = next !== undefined && (optional?.accepts === undefined ? !next.startsWith("-") : optional.accepts.test(next));
|
|
579
|
+
return optional === undefined || value ? [arg] : [arg, optional.bare];
|
|
580
|
+
}), ...separator === -1 ? [] : args.slice(separator)];
|
|
581
|
+
}
|
|
582
|
+
function checkConflicts(values, options) {
|
|
583
|
+
const given = (name) => values[name] !== undefined && values[name] !== false;
|
|
584
|
+
for (const [name, { conflicts = [] }] of Object.entries(options)) {
|
|
585
|
+
const other = given(name) ? conflicts.find(given) : undefined;
|
|
586
|
+
if (other !== undefined)
|
|
587
|
+
badUsage(`--${name} cannot be used with --${other}`);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
function checkChoices(values, options) {
|
|
591
|
+
for (const [name, option] of Object.entries(options)) {
|
|
592
|
+
if (option.choices === undefined)
|
|
593
|
+
continue;
|
|
594
|
+
const given = values[name];
|
|
595
|
+
for (const value of Array.isArray(given) ? given : [given]) {
|
|
596
|
+
if (typeof value === "string")
|
|
597
|
+
oneOf(value, name, option.choices);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
function oneOf(value, name, choices) {
|
|
602
|
+
if (!choices.includes(value))
|
|
603
|
+
badUsage(`${name.startsWith("<") ? name : `--${name}`} takes one of ${choices.join(", ")}, not ${value}`);
|
|
604
|
+
return value;
|
|
528
605
|
}
|
|
529
606
|
function checkPositionals(given, names) {
|
|
530
607
|
const variadic = names.at(-1)?.replace("]", "").endsWith("...") === true;
|
|
@@ -756,22 +833,55 @@ function reportThrown(prefix, error, redact = (text) => text, json = false) {
|
|
|
756
833
|
}
|
|
757
834
|
var COMPLETE = "__complete";
|
|
758
835
|
var FILES = "__files__";
|
|
759
|
-
async function
|
|
836
|
+
async function completingOf(run) {
|
|
760
837
|
completion.active = true;
|
|
761
838
|
try {
|
|
762
839
|
await run([]);
|
|
763
840
|
} catch (error) {
|
|
764
841
|
if (error instanceof Completing)
|
|
765
|
-
return error
|
|
842
|
+
return error;
|
|
766
843
|
} finally {
|
|
767
844
|
completion.active = false;
|
|
768
845
|
}
|
|
769
|
-
return {};
|
|
846
|
+
return new Completing({});
|
|
847
|
+
}
|
|
848
|
+
function candidateLine(candidate) {
|
|
849
|
+
return typeof candidate === "string" ? candidate : candidate.join("\t");
|
|
850
|
+
}
|
|
851
|
+
function positionalBeingTyped(before, { options, positionals }) {
|
|
852
|
+
const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
|
|
853
|
+
let index = 0;
|
|
854
|
+
let at = 0;
|
|
855
|
+
while (at < before.length) {
|
|
856
|
+
const word = before[at];
|
|
857
|
+
if (word === "--") {
|
|
858
|
+
index += before.length - at - 1;
|
|
859
|
+
break;
|
|
860
|
+
}
|
|
861
|
+
if (!word.startsWith("-"))
|
|
862
|
+
index++;
|
|
863
|
+
else if (takesValue(word))
|
|
864
|
+
at++;
|
|
865
|
+
at++;
|
|
866
|
+
}
|
|
867
|
+
const last = positionals.at(-1);
|
|
868
|
+
if (index < positionals.length)
|
|
869
|
+
return positionals[index];
|
|
870
|
+
return last?.replace("]", "").endsWith("...") === true ? last : undefined;
|
|
770
871
|
}
|
|
771
872
|
async function leafCandidates(run, words) {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
873
|
+
const completing = await completingOf(run);
|
|
874
|
+
if ((words.at(-1) ?? "").startsWith("-"))
|
|
875
|
+
return Object.entries(completing.options).map(([name, option]) => option.description === undefined ? `--${name}` : `--${name} ${option.description}`);
|
|
876
|
+
const flag = words.at(-2);
|
|
877
|
+
const option = flag?.startsWith("-") === true ? Object.entries(completing.options).find(([name, { short }]) => flag === `--${name}` || flag === `-${short}`)?.[1] : undefined;
|
|
878
|
+
if (option?.type === "string") {
|
|
879
|
+
const values = option.choices === undefined ? await option.candidates?.() : option.choices;
|
|
880
|
+
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
881
|
+
}
|
|
882
|
+
const name = positionalBeingTyped(words.slice(0, -1), completing);
|
|
883
|
+
const values = name === undefined ? undefined : await completing.candidates[name]?.();
|
|
884
|
+
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
775
885
|
}
|
|
776
886
|
async function printCandidates(found) {
|
|
777
887
|
for (const line of await found)
|
|
@@ -845,7 +955,7 @@ var {Glob } = globalThis.Bun;
|
|
|
845
955
|
var SESSION_FILES = new Glob("*.json");
|
|
846
956
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
847
957
|
// package.json
|
|
848
|
-
var version = "0.
|
|
958
|
+
var version = "0.9.0";
|
|
849
959
|
|
|
850
960
|
// src/errs.ts
|
|
851
961
|
import { relative as relative2 } from "path";
|
|
@@ -1568,9 +1678,24 @@ var BUN_TEST_EXPECTED = /^Expected: (.*)$/;
|
|
|
1568
1678
|
var BUN_TEST_RECEIVED = /^Received: (.*)$/;
|
|
1569
1679
|
var BUN_TEST_FRAME = /^\s+at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
|
|
1570
1680
|
var BUN_TEST_FILE = /^\S+\.test\.[jt]sx?:$/;
|
|
1681
|
+
var GO_ERROR = /^\s*(?:vet: )?(\S+\.go):(\d+):(?:(\d+):)? (.+)$/;
|
|
1682
|
+
var GO_NOISE = /^# \S+(?: \[\S+\])?$/;
|
|
1683
|
+
var ARROW = /^\s*--> (.+?):(\d+):(\d+)$/;
|
|
1684
|
+
var CARGO_HEADER = /^(error|warning)(?:\[(\w+)\])?: (.*)$/;
|
|
1685
|
+
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)/;
|
|
1686
|
+
var RUFF_CONCISE = /^(\S+\.pyi?):(\d+):(\d+): ([A-Z]+\d+) (?:\[\*\] )?(.*)$/;
|
|
1687
|
+
var RUFF_HEADER = /^([A-Z]{1,5}\d{1,4}) (?:\[\*\] )?(.+)$/;
|
|
1688
|
+
var RUFF_NOISE = /^(?:Found \d+ errors?\.|\[\*\] \d+ fixable|No fixes available|All checks passed|help: |\s*(?:\|\s*)?$)/;
|
|
1689
|
+
var PYTEST_LOCATION = /^(\S+\.py):(\d+): (\S.*)$/;
|
|
1690
|
+
var PYTEST_E_LINE = /^E {3}(.*)$/;
|
|
1691
|
+
var PYTEST_BANNER = /^={3,} (.*?) ={3,}$/;
|
|
1692
|
+
var PYTEST_FAILURES = new Set(["FAILURES", "ERRORS"]);
|
|
1693
|
+
var PYTEST_SUMMARY_LINE = /^(?:FAILED|ERROR) \S/;
|
|
1694
|
+
var PYTEST_EXCEPTION_END = /[\s:]/;
|
|
1695
|
+
var PYTEST_NOISE = /^(?:platform |rootdir: |collected |plugins: |configfile: |cachedir: |\S+\.pyi? [.FEsxXR]+ +\[ *\d+%\]$|\S+\.py:\d+: $)/;
|
|
1571
1696
|
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)/;
|
|
1572
1697
|
function isNoise(line) {
|
|
1573
|
-
return line.trim() === "" || [NOISE, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_SUMMARY, ESLINT_SUMMARY, BOUNDARY, BASH_ECHO, ...PHP_NOISE, ...E2E_NOISE].some((pattern) => pattern.test(line));
|
|
1698
|
+
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));
|
|
1574
1699
|
}
|
|
1575
1700
|
var collectBunCheck = (lines, used) => {
|
|
1576
1701
|
const errors = [];
|
|
@@ -1667,7 +1792,84 @@ var collectEslint = (lines, used) => {
|
|
|
1667
1792
|
}
|
|
1668
1793
|
return errors;
|
|
1669
1794
|
};
|
|
1670
|
-
var
|
|
1795
|
+
var collectGo = (lines, used) => {
|
|
1796
|
+
const errors = [];
|
|
1797
|
+
for (const [index, line] of lines.entries()) {
|
|
1798
|
+
const match = used.has(index) ? null : GO_ERROR.exec(line);
|
|
1799
|
+
if (match === null)
|
|
1800
|
+
continue;
|
|
1801
|
+
errors.push({ tool: "go", file: match[1] ?? "", line: Number(match[2]), column: Number(match[3] ?? 0), severity: "error", message: match[4] ?? "" });
|
|
1802
|
+
used.add(index);
|
|
1803
|
+
}
|
|
1804
|
+
return errors;
|
|
1805
|
+
};
|
|
1806
|
+
var collectArrowed = (lines, used) => {
|
|
1807
|
+
const errors = [];
|
|
1808
|
+
for (const [index, line] of lines.entries()) {
|
|
1809
|
+
const arrow = used.has(index) || index === 0 ? null : ARROW.exec(line);
|
|
1810
|
+
const header = arrow === null ? null : lines[index - 1] ?? "";
|
|
1811
|
+
const cargo = header === null ? null : CARGO_HEADER.exec(header);
|
|
1812
|
+
const ruff = header === null || cargo !== null ? null : RUFF_HEADER.exec(header);
|
|
1813
|
+
if (arrow === null || cargo === null && ruff === null || used.has(index - 1))
|
|
1814
|
+
continue;
|
|
1815
|
+
const [, file, row, column] = arrow;
|
|
1816
|
+
const fields = { file: file ?? "", line: Number(row), column: Number(column) };
|
|
1817
|
+
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] ?? "" });
|
|
1818
|
+
used.add(index - 1);
|
|
1819
|
+
used.add(index);
|
|
1820
|
+
for (let frame = index + 1;frame < lines.length && (lines[frame] ?? "").trim() !== ""; frame++) {
|
|
1821
|
+
if (CARGO_HEADER.test(lines[frame] ?? "") || RUFF_HEADER.test(lines[frame] ?? ""))
|
|
1822
|
+
break;
|
|
1823
|
+
used.add(frame);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
return errors;
|
|
1827
|
+
};
|
|
1828
|
+
var collectRuff = (lines, used) => {
|
|
1829
|
+
const errors = [];
|
|
1830
|
+
for (const [index, line] of lines.entries()) {
|
|
1831
|
+
const match = used.has(index) ? null : RUFF_CONCISE.exec(line);
|
|
1832
|
+
if (match === null)
|
|
1833
|
+
continue;
|
|
1834
|
+
errors.push({ tool: "ruff", file: match[1] ?? "", line: Number(match[2]), column: Number(match[3]), rule: match[4], severity: "error", message: match[5] ?? "" });
|
|
1835
|
+
used.add(index);
|
|
1836
|
+
}
|
|
1837
|
+
return errors;
|
|
1838
|
+
};
|
|
1839
|
+
var collectPytest = (lines, used) => {
|
|
1840
|
+
const errors = [];
|
|
1841
|
+
const title = (line) => PYTEST_BANNER.exec(line ?? "")?.[1];
|
|
1842
|
+
const start = lines.findIndex((line) => PYTEST_FAILURES.has(title(line) ?? ""));
|
|
1843
|
+
if (start === -1)
|
|
1844
|
+
return errors;
|
|
1845
|
+
const end = lines.findIndex((line, index) => index > start && title(line) !== undefined && !PYTEST_FAILURES.has(title(line) ?? ""));
|
|
1846
|
+
const stop = end === -1 ? lines.length : end;
|
|
1847
|
+
let message = [];
|
|
1848
|
+
for (let index = start;index < stop; index++) {
|
|
1849
|
+
const line = lines[index] ?? "";
|
|
1850
|
+
const failure = PYTEST_E_LINE.exec(line);
|
|
1851
|
+
if (failure !== null) {
|
|
1852
|
+
message.push((failure[1] ?? "").trim());
|
|
1853
|
+
} else {
|
|
1854
|
+
const location = PYTEST_LOCATION.exec(line);
|
|
1855
|
+
if (location !== null) {
|
|
1856
|
+
const [exception = ""] = (location[3] ?? "").split(PYTEST_EXCEPTION_END);
|
|
1857
|
+
const first = message[0] ?? "";
|
|
1858
|
+
const text = first === "" || first.startsWith(exception) ? first || (location[3] ?? "") : `${location[3] ?? ""}: ${first}`;
|
|
1859
|
+
errors.push({ tool: "pytest", file: location[1] ?? "", line: Number(location[2]), column: 0, severity: "error", message: text });
|
|
1860
|
+
}
|
|
1861
|
+
if (line.trim() !== "")
|
|
1862
|
+
message = [];
|
|
1863
|
+
}
|
|
1864
|
+
used.add(index);
|
|
1865
|
+
}
|
|
1866
|
+
for (let index = stop;index < lines.length; index++) {
|
|
1867
|
+
if (PYTEST_SUMMARY_LINE.test(lines[index] ?? ""))
|
|
1868
|
+
used.add(index);
|
|
1869
|
+
}
|
|
1870
|
+
return errors;
|
|
1871
|
+
};
|
|
1872
|
+
var COLLECTORS = [collectBunCheck, collectBunTest, collectVitest, collectPlaywright, collectPhpunit, collectPhpstan, collectCsFixer, collectPytest, collectArrowed, collectRuff, collectGo, collectTsc, collectEslint];
|
|
1671
1873
|
function parseErrors(output) {
|
|
1672
1874
|
const lines = stripAnsi(output).split(`
|
|
1673
1875
|
`);
|
|
@@ -1736,11 +1938,11 @@ var usage = `errs [options] [log]
|
|
|
1736
1938
|
errs [options] -- <command> [args...]
|
|
1737
1939
|
errs --in <service> | --host -- <command> [args...]
|
|
1738
1940
|
|
|
1739
|
-
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)
|
|
1941
|
+
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 --.
|
|
1740
1942
|
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.
|
|
1741
1943
|
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.
|
|
1742
1944
|
Exits 0 when no error was found and the command, if any, passed, 1 when errors were found or the command failed, 2 on a usage error.
|
|
1743
|
-
--json prints {errors: [{tool, file, line, column, rule, severity, message, test?}], unrecognised, log?, code?}, tool one of tsc, eslint, bun check, bun test, vitest, playwright, phpunit, phpstan, php-cs-fixer.`;
|
|
1945
|
+
--json prints {errors: [{tool, file, line, column, rule, severity, message, test?}], unrecognised, log?, code?}, tool one of tsc, eslint, bun check, bun test, vitest, playwright, phpunit, phpstan, php-cs-fixer, go, cargo, ruff, pytest.`;
|
|
1744
1946
|
var options = {
|
|
1745
1947
|
...placeOptions,
|
|
1746
1948
|
json: jsonOption()
|
package/dist/fix-cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import process2 from "process";
|
|
|
14
14
|
// ../kit/src/style.ts
|
|
15
15
|
import process from "process";
|
|
16
16
|
|
|
17
|
-
// ../../node_modules/.bun/@kaynooo+utils@2.31.
|
|
17
|
+
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
|
|
18
18
|
function x(s) {
|
|
19
19
|
let r = s.startsWith("#") ? s.slice(1).toLowerCase() : s.toLowerCase();
|
|
20
20
|
if (!/^[a-f0-9]+$/.test(r))
|
|
@@ -234,7 +234,7 @@ class e {
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
// ../../node_modules/.bun/@kaynooo+utils@2.31.
|
|
237
|
+
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-y1msbssb.js
|
|
238
238
|
var r = 39;
|
|
239
239
|
var o = 49;
|
|
240
240
|
var f2 = "\x1B[";
|
|
@@ -433,8 +433,12 @@ class HelpShown extends Exit {
|
|
|
433
433
|
|
|
434
434
|
class Completing {
|
|
435
435
|
options;
|
|
436
|
-
|
|
436
|
+
positionals;
|
|
437
|
+
candidates;
|
|
438
|
+
constructor(options, positionals = [], candidates = {}) {
|
|
437
439
|
this.options = options;
|
|
440
|
+
this.positionals = positionals;
|
|
441
|
+
this.candidates = candidates;
|
|
438
442
|
}
|
|
439
443
|
}
|
|
440
444
|
var completion = { active: false };
|
|
@@ -477,8 +481,10 @@ function exampleRows(examples, colors = paint(process3.stdout)) {
|
|
|
477
481
|
function optionRows(options, colors = paint(process3.stdout)) {
|
|
478
482
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
479
483
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
480
|
-
const
|
|
481
|
-
|
|
484
|
+
const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
|
|
485
|
+
const placeholder = option.optional === undefined ? named : `[${named}]`;
|
|
486
|
+
const value = option.type === "string" ? ` ${colors.dim(placeholder)}` : "";
|
|
487
|
+
return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: option.description ?? "" };
|
|
482
488
|
});
|
|
483
489
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
484
490
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
@@ -504,14 +510,13 @@ function applyOutput(color, plain, env = process3.env) {
|
|
|
504
510
|
function parse(args, usage, options, settings = {}) {
|
|
505
511
|
const output = Object.fromEntries(Object.entries(OUTPUT_OPTIONS).filter(([name]) => !(name in options)));
|
|
506
512
|
const all = { ...options, ...output, help: { type: "boolean", short: "h", description: "show this help" } };
|
|
513
|
+
const listing = listed(all, settings.allowNegative === true);
|
|
507
514
|
if (completion.active)
|
|
508
|
-
throw new Completing(
|
|
509
|
-
const
|
|
510
|
-
const own = separator === -1 ? args : args.slice(0, separator);
|
|
511
|
-
const rest = separator === -1 ? undefined : args.slice(separator + 1);
|
|
515
|
+
throw new Completing(listing, settings.positionals, settings.candidates);
|
|
516
|
+
const { own, rest } = settings.trailing === true ? splitTrailing(args, all, settings.positionals?.length ?? 0) : splitRest(args, settings.rest === true);
|
|
512
517
|
let parsed;
|
|
513
518
|
try {
|
|
514
|
-
parsed = parseArgs({ args: joinDashValues(own, all), options: all, allowPositionals: true, allowNegative: settings.allowNegative === true, strict: true });
|
|
519
|
+
parsed = parseArgs({ args: joinDashValues(withBare(own, all), all), options: all, allowPositionals: true, allowNegative: settings.allowNegative === true, strict: true });
|
|
515
520
|
} catch (error) {
|
|
516
521
|
const message = parseError(error);
|
|
517
522
|
throw new UsageError(message, nearestOption(message, all, settings.allowNegative === true));
|
|
@@ -519,12 +524,84 @@ function parse(args, usage, options, settings = {}) {
|
|
|
519
524
|
const values = parsed.values;
|
|
520
525
|
applyOutput("color" in output ? values.color : undefined, "plain" in output ? values.plain : undefined);
|
|
521
526
|
if (values.help === true) {
|
|
522
|
-
console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings)) : helpText(usage,
|
|
527
|
+
console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings)) : helpText(usage, listing, undefined, settings));
|
|
523
528
|
throw new HelpShown;
|
|
524
529
|
}
|
|
530
|
+
checkChoices(parsed.values, all);
|
|
531
|
+
checkConflicts(parsed.values, all);
|
|
525
532
|
if (settings.positionals !== undefined)
|
|
526
533
|
checkPositionals(parsed.positionals, settings.positionals);
|
|
527
|
-
return { ...parsed, positionals: parsed.positionals, rest };
|
|
534
|
+
return { ...parsed, values: parsed.values, positionals: parsed.positionals, rest };
|
|
535
|
+
}
|
|
536
|
+
function splitRest(args, passes) {
|
|
537
|
+
const separator = passes ? args.indexOf("--") : -1;
|
|
538
|
+
return { own: separator === -1 ? args : args.slice(0, separator), rest: separator === -1 ? undefined : args.slice(separator + 1) };
|
|
539
|
+
}
|
|
540
|
+
function splitTrailing(args, options, count) {
|
|
541
|
+
const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
|
|
542
|
+
let seen = 0;
|
|
543
|
+
if (count === 0)
|
|
544
|
+
return { own: args, rest: undefined };
|
|
545
|
+
for (let at = 0;at < args.length; at++) {
|
|
546
|
+
const word = args[at];
|
|
547
|
+
if (word === "--")
|
|
548
|
+
break;
|
|
549
|
+
if (word.startsWith("-")) {
|
|
550
|
+
if (takesValue(word))
|
|
551
|
+
at++;
|
|
552
|
+
continue;
|
|
553
|
+
}
|
|
554
|
+
seen++;
|
|
555
|
+
if (seen === count)
|
|
556
|
+
return { own: args.slice(0, at + 1), rest: args.slice(at + 1) };
|
|
557
|
+
}
|
|
558
|
+
return { own: args, rest: undefined };
|
|
559
|
+
}
|
|
560
|
+
function listed(options, allowNegative) {
|
|
561
|
+
if (!allowNegative)
|
|
562
|
+
return options;
|
|
563
|
+
return Object.fromEntries(Object.entries(options).flatMap(([name, option]) => {
|
|
564
|
+
if (option.type !== "boolean" || option.negative === undefined)
|
|
565
|
+
return [[name, option]];
|
|
566
|
+
return [...option.description === undefined ? [] : [[name, option]], [`no-${name}`, { type: "boolean", description: option.negative }]];
|
|
567
|
+
}));
|
|
568
|
+
}
|
|
569
|
+
function withBare(args, options) {
|
|
570
|
+
const bare = new Map(Object.entries(options).flatMap(([name, { short, optional }]) => optional === undefined ? [] : [[`--${name}`, optional], ...short === undefined ? [] : [[`-${short}`, optional]]]));
|
|
571
|
+
if (bare.size === 0)
|
|
572
|
+
return args;
|
|
573
|
+
const separator = args.indexOf("--");
|
|
574
|
+
const own = separator === -1 ? args : args.slice(0, separator);
|
|
575
|
+
return [...own.flatMap((arg, index) => {
|
|
576
|
+
const optional = bare.get(arg);
|
|
577
|
+
const next = own[index + 1];
|
|
578
|
+
const value = next !== undefined && (optional?.accepts === undefined ? !next.startsWith("-") : optional.accepts.test(next));
|
|
579
|
+
return optional === undefined || value ? [arg] : [arg, optional.bare];
|
|
580
|
+
}), ...separator === -1 ? [] : args.slice(separator)];
|
|
581
|
+
}
|
|
582
|
+
function checkConflicts(values, options) {
|
|
583
|
+
const given = (name) => values[name] !== undefined && values[name] !== false;
|
|
584
|
+
for (const [name, { conflicts = [] }] of Object.entries(options)) {
|
|
585
|
+
const other = given(name) ? conflicts.find(given) : undefined;
|
|
586
|
+
if (other !== undefined)
|
|
587
|
+
badUsage(`--${name} cannot be used with --${other}`);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
function checkChoices(values, options) {
|
|
591
|
+
for (const [name, option] of Object.entries(options)) {
|
|
592
|
+
if (option.choices === undefined)
|
|
593
|
+
continue;
|
|
594
|
+
const given = values[name];
|
|
595
|
+
for (const value of Array.isArray(given) ? given : [given]) {
|
|
596
|
+
if (typeof value === "string")
|
|
597
|
+
oneOf(value, name, option.choices);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
function oneOf(value, name, choices) {
|
|
602
|
+
if (!choices.includes(value))
|
|
603
|
+
badUsage(`${name.startsWith("<") ? name : `--${name}`} takes one of ${choices.join(", ")}, not ${value}`);
|
|
604
|
+
return value;
|
|
528
605
|
}
|
|
529
606
|
function checkPositionals(given, names) {
|
|
530
607
|
const variadic = names.at(-1)?.replace("]", "").endsWith("...") === true;
|
|
@@ -756,22 +833,55 @@ function reportThrown(prefix, error, redact = (text) => text, json = false) {
|
|
|
756
833
|
}
|
|
757
834
|
var COMPLETE = "__complete";
|
|
758
835
|
var FILES = "__files__";
|
|
759
|
-
async function
|
|
836
|
+
async function completingOf(run) {
|
|
760
837
|
completion.active = true;
|
|
761
838
|
try {
|
|
762
839
|
await run([]);
|
|
763
840
|
} catch (error) {
|
|
764
841
|
if (error instanceof Completing)
|
|
765
|
-
return error
|
|
842
|
+
return error;
|
|
766
843
|
} finally {
|
|
767
844
|
completion.active = false;
|
|
768
845
|
}
|
|
769
|
-
return {};
|
|
846
|
+
return new Completing({});
|
|
847
|
+
}
|
|
848
|
+
function candidateLine(candidate) {
|
|
849
|
+
return typeof candidate === "string" ? candidate : candidate.join("\t");
|
|
850
|
+
}
|
|
851
|
+
function positionalBeingTyped(before, { options, positionals }) {
|
|
852
|
+
const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
|
|
853
|
+
let index = 0;
|
|
854
|
+
let at = 0;
|
|
855
|
+
while (at < before.length) {
|
|
856
|
+
const word = before[at];
|
|
857
|
+
if (word === "--") {
|
|
858
|
+
index += before.length - at - 1;
|
|
859
|
+
break;
|
|
860
|
+
}
|
|
861
|
+
if (!word.startsWith("-"))
|
|
862
|
+
index++;
|
|
863
|
+
else if (takesValue(word))
|
|
864
|
+
at++;
|
|
865
|
+
at++;
|
|
866
|
+
}
|
|
867
|
+
const last = positionals.at(-1);
|
|
868
|
+
if (index < positionals.length)
|
|
869
|
+
return positionals[index];
|
|
870
|
+
return last?.replace("]", "").endsWith("...") === true ? last : undefined;
|
|
770
871
|
}
|
|
771
872
|
async function leafCandidates(run, words) {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
873
|
+
const completing = await completingOf(run);
|
|
874
|
+
if ((words.at(-1) ?? "").startsWith("-"))
|
|
875
|
+
return Object.entries(completing.options).map(([name, option]) => option.description === undefined ? `--${name}` : `--${name} ${option.description}`);
|
|
876
|
+
const flag = words.at(-2);
|
|
877
|
+
const option = flag?.startsWith("-") === true ? Object.entries(completing.options).find(([name, { short }]) => flag === `--${name}` || flag === `-${short}`)?.[1] : undefined;
|
|
878
|
+
if (option?.type === "string") {
|
|
879
|
+
const values = option.choices === undefined ? await option.candidates?.() : option.choices;
|
|
880
|
+
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
881
|
+
}
|
|
882
|
+
const name = positionalBeingTyped(words.slice(0, -1), completing);
|
|
883
|
+
const values = name === undefined ? undefined : await completing.candidates[name]?.();
|
|
884
|
+
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
775
885
|
}
|
|
776
886
|
async function printCandidates(found) {
|
|
777
887
|
for (const line of await found)
|
|
@@ -845,7 +955,7 @@ var {Glob } = globalThis.Bun;
|
|
|
845
955
|
var SESSION_FILES = new Glob("*.json");
|
|
846
956
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
847
957
|
// package.json
|
|
848
|
-
var version = "0.
|
|
958
|
+
var version = "0.9.0";
|
|
849
959
|
|
|
850
960
|
// src/fix.ts
|
|
851
961
|
import { existsSync as existsSync2, statSync } from "fs";
|
|
@@ -1600,9 +1710,24 @@ var BUN_TEST_EXPECTED = /^Expected: (.*)$/;
|
|
|
1600
1710
|
var BUN_TEST_RECEIVED = /^Received: (.*)$/;
|
|
1601
1711
|
var BUN_TEST_FRAME = /^\s+at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
|
|
1602
1712
|
var BUN_TEST_FILE = /^\S+\.test\.[jt]sx?:$/;
|
|
1713
|
+
var GO_ERROR = /^\s*(?:vet: )?(\S+\.go):(\d+):(?:(\d+):)? (.+)$/;
|
|
1714
|
+
var GO_NOISE = /^# \S+(?: \[\S+\])?$/;
|
|
1715
|
+
var ARROW = /^\s*--> (.+?):(\d+):(\d+)$/;
|
|
1716
|
+
var CARGO_HEADER = /^(error|warning)(?:\[(\w+)\])?: (.*)$/;
|
|
1717
|
+
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)/;
|
|
1718
|
+
var RUFF_CONCISE = /^(\S+\.pyi?):(\d+):(\d+): ([A-Z]+\d+) (?:\[\*\] )?(.*)$/;
|
|
1719
|
+
var RUFF_HEADER = /^([A-Z]{1,5}\d{1,4}) (?:\[\*\] )?(.+)$/;
|
|
1720
|
+
var RUFF_NOISE = /^(?:Found \d+ errors?\.|\[\*\] \d+ fixable|No fixes available|All checks passed|help: |\s*(?:\|\s*)?$)/;
|
|
1721
|
+
var PYTEST_LOCATION = /^(\S+\.py):(\d+): (\S.*)$/;
|
|
1722
|
+
var PYTEST_E_LINE = /^E {3}(.*)$/;
|
|
1723
|
+
var PYTEST_BANNER = /^={3,} (.*?) ={3,}$/;
|
|
1724
|
+
var PYTEST_FAILURES = new Set(["FAILURES", "ERRORS"]);
|
|
1725
|
+
var PYTEST_SUMMARY_LINE = /^(?:FAILED|ERROR) \S/;
|
|
1726
|
+
var PYTEST_EXCEPTION_END = /[\s:]/;
|
|
1727
|
+
var PYTEST_NOISE = /^(?:platform |rootdir: |collected |plugins: |configfile: |cachedir: |\S+\.pyi? [.FEsxXR]+ +\[ *\d+%\]$|\S+\.py:\d+: $)/;
|
|
1603
1728
|
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)/;
|
|
1604
1729
|
function isNoise(line) {
|
|
1605
|
-
return line.trim() === "" || [NOISE, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_SUMMARY, ESLINT_SUMMARY, BOUNDARY, BASH_ECHO, ...PHP_NOISE, ...E2E_NOISE].some((pattern) => pattern.test(line));
|
|
1730
|
+
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));
|
|
1606
1731
|
}
|
|
1607
1732
|
var collectBunCheck = (lines, used) => {
|
|
1608
1733
|
const errors = [];
|
|
@@ -1699,7 +1824,84 @@ var collectEslint = (lines, used) => {
|
|
|
1699
1824
|
}
|
|
1700
1825
|
return errors;
|
|
1701
1826
|
};
|
|
1702
|
-
var
|
|
1827
|
+
var collectGo = (lines, used) => {
|
|
1828
|
+
const errors = [];
|
|
1829
|
+
for (const [index, line] of lines.entries()) {
|
|
1830
|
+
const match = used.has(index) ? null : GO_ERROR.exec(line);
|
|
1831
|
+
if (match === null)
|
|
1832
|
+
continue;
|
|
1833
|
+
errors.push({ tool: "go", file: match[1] ?? "", line: Number(match[2]), column: Number(match[3] ?? 0), severity: "error", message: match[4] ?? "" });
|
|
1834
|
+
used.add(index);
|
|
1835
|
+
}
|
|
1836
|
+
return errors;
|
|
1837
|
+
};
|
|
1838
|
+
var collectArrowed = (lines, used) => {
|
|
1839
|
+
const errors = [];
|
|
1840
|
+
for (const [index, line] of lines.entries()) {
|
|
1841
|
+
const arrow = used.has(index) || index === 0 ? null : ARROW.exec(line);
|
|
1842
|
+
const header = arrow === null ? null : lines[index - 1] ?? "";
|
|
1843
|
+
const cargo = header === null ? null : CARGO_HEADER.exec(header);
|
|
1844
|
+
const ruff = header === null || cargo !== null ? null : RUFF_HEADER.exec(header);
|
|
1845
|
+
if (arrow === null || cargo === null && ruff === null || used.has(index - 1))
|
|
1846
|
+
continue;
|
|
1847
|
+
const [, file, row, column] = arrow;
|
|
1848
|
+
const fields = { file: file ?? "", line: Number(row), column: Number(column) };
|
|
1849
|
+
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] ?? "" });
|
|
1850
|
+
used.add(index - 1);
|
|
1851
|
+
used.add(index);
|
|
1852
|
+
for (let frame = index + 1;frame < lines.length && (lines[frame] ?? "").trim() !== ""; frame++) {
|
|
1853
|
+
if (CARGO_HEADER.test(lines[frame] ?? "") || RUFF_HEADER.test(lines[frame] ?? ""))
|
|
1854
|
+
break;
|
|
1855
|
+
used.add(frame);
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
return errors;
|
|
1859
|
+
};
|
|
1860
|
+
var collectRuff = (lines, used) => {
|
|
1861
|
+
const errors = [];
|
|
1862
|
+
for (const [index, line] of lines.entries()) {
|
|
1863
|
+
const match = used.has(index) ? null : RUFF_CONCISE.exec(line);
|
|
1864
|
+
if (match === null)
|
|
1865
|
+
continue;
|
|
1866
|
+
errors.push({ tool: "ruff", file: match[1] ?? "", line: Number(match[2]), column: Number(match[3]), rule: match[4], severity: "error", message: match[5] ?? "" });
|
|
1867
|
+
used.add(index);
|
|
1868
|
+
}
|
|
1869
|
+
return errors;
|
|
1870
|
+
};
|
|
1871
|
+
var collectPytest = (lines, used) => {
|
|
1872
|
+
const errors = [];
|
|
1873
|
+
const title = (line) => PYTEST_BANNER.exec(line ?? "")?.[1];
|
|
1874
|
+
const start = lines.findIndex((line) => PYTEST_FAILURES.has(title(line) ?? ""));
|
|
1875
|
+
if (start === -1)
|
|
1876
|
+
return errors;
|
|
1877
|
+
const end = lines.findIndex((line, index) => index > start && title(line) !== undefined && !PYTEST_FAILURES.has(title(line) ?? ""));
|
|
1878
|
+
const stop = end === -1 ? lines.length : end;
|
|
1879
|
+
let message = [];
|
|
1880
|
+
for (let index = start;index < stop; index++) {
|
|
1881
|
+
const line = lines[index] ?? "";
|
|
1882
|
+
const failure = PYTEST_E_LINE.exec(line);
|
|
1883
|
+
if (failure !== null) {
|
|
1884
|
+
message.push((failure[1] ?? "").trim());
|
|
1885
|
+
} else {
|
|
1886
|
+
const location = PYTEST_LOCATION.exec(line);
|
|
1887
|
+
if (location !== null) {
|
|
1888
|
+
const [exception = ""] = (location[3] ?? "").split(PYTEST_EXCEPTION_END);
|
|
1889
|
+
const first = message[0] ?? "";
|
|
1890
|
+
const text = first === "" || first.startsWith(exception) ? first || (location[3] ?? "") : `${location[3] ?? ""}: ${first}`;
|
|
1891
|
+
errors.push({ tool: "pytest", file: location[1] ?? "", line: Number(location[2]), column: 0, severity: "error", message: text });
|
|
1892
|
+
}
|
|
1893
|
+
if (line.trim() !== "")
|
|
1894
|
+
message = [];
|
|
1895
|
+
}
|
|
1896
|
+
used.add(index);
|
|
1897
|
+
}
|
|
1898
|
+
for (let index = stop;index < lines.length; index++) {
|
|
1899
|
+
if (PYTEST_SUMMARY_LINE.test(lines[index] ?? ""))
|
|
1900
|
+
used.add(index);
|
|
1901
|
+
}
|
|
1902
|
+
return errors;
|
|
1903
|
+
};
|
|
1904
|
+
var COLLECTORS = [collectBunCheck, collectBunTest, collectVitest, collectPlaywright, collectPhpunit, collectPhpstan, collectCsFixer, collectPytest, collectArrowed, collectRuff, collectGo, collectTsc, collectEslint];
|
|
1703
1905
|
function parseErrors(output) {
|
|
1704
1906
|
const lines = stripAnsi(output).split(`
|
|
1705
1907
|
`);
|
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.9.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",
|
|
@@ -29,6 +29,6 @@
|
|
|
29
29
|
"build": "$npm_execpath build src/cli.ts src/fix-cli.ts src/errs-cli.ts --target bun --outdir dist"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@kaynooo/cli-kit": "0.
|
|
32
|
+
"@kaynooo/cli-kit": "0.19.0"
|
|
33
33
|
}
|
|
34
34
|
}
|