@kaynooo/cli-check 0.18.3 → 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 +20 -10
- package/dist/errs-cli.js +22 -12
- package/dist/fix-cli.js +20 -10
- package/dist/j-cli.js +164 -36
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -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;
|
package/dist/errs-cli.js
CHANGED
|
@@ -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,10 +2204,10 @@ 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
|
-
--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.`;
|
|
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.`;
|
|
2201
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,
|
package/dist/fix-cli.js
CHANGED
|
@@ -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;
|
package/dist/j-cli.js
CHANGED
|
@@ -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);
|
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
|
}
|