@kaynooo/cli-check 0.21.2 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cli.js +25 -13
- package/dist/errs-cli.js +17 -6
- package/dist/j-cli.js +21 -9
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ check --json # [{name, command, in?, ok, ms, log, failed?}] once every step
|
|
|
19
19
|
|
|
20
20
|
## Steps
|
|
21
21
|
|
|
22
|
-
`check`, `typecheck`, `lint` and `test`, run in that order, from the first source that has each one, but for a Justfile or Makefile `check`, which wins over a script of that name: a task runner's check is the repo's whole validation and usually wraps the script, as `check: bun run check -p tsconfig.json` does.
|
|
22
|
+
`check`, `typecheck`, `lint`, `fmt` and `test`, run in that order, from the first source that has each one (`fmt` runs a `fmt:check` or `format:check` script, or a `fmt-check` or `format-check` recipe or target), but for a Justfile or Makefile `check`, which wins over a script of that name: a task runner's check is the repo's whole validation and usually wraps the script, as `check: bun run check -p tsconfig.json` does.
|
|
23
23
|
|
|
24
24
|
| Source | Command |
|
|
25
25
|
| --- | --- |
|
|
@@ -74,7 +74,7 @@ check --fix --in app # run the scripts in this compose service; --host force
|
|
|
74
74
|
check --fix --json # {fixers, changed}, a skipped fixer as {name, command, skipped}
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
The project's own `fix` script, recipe or target when it has one, else its `lint:fix` (or `lint-fix`) and `format` ones, found in the same sources as `check`'s steps. Then the formatters the folder's files call for:
|
|
77
|
+
The project's own `fix` script, recipe or target when it has one, else its `lint:fix` (or `lint-fix`) and `fmt` (or `format`) ones, found in the same sources as `check`'s steps. Then the formatters the folder's files call for:
|
|
78
78
|
|
|
79
79
|
| Fixer | When | Runs |
|
|
80
80
|
| --- | --- | --- |
|
package/dist/cli.js
CHANGED
|
@@ -617,11 +617,20 @@ var init_text2 = __esm(() => {
|
|
|
617
617
|
|
|
618
618
|
// ../kit/src/input.ts
|
|
619
619
|
import process9 from "process";
|
|
620
|
+
function durationMs(text, unit) {
|
|
621
|
+
if (BARE_DURATION.test(text))
|
|
622
|
+
return Number(text) * UNIT_MS[unit];
|
|
623
|
+
if (!DURATION.test(text))
|
|
624
|
+
return 0;
|
|
625
|
+
let ms = 0;
|
|
626
|
+
for (const [, amount, part] of text.matchAll(DURATION_PART))
|
|
627
|
+
ms += Number(amount) * UNIT_MS[part];
|
|
628
|
+
return ms;
|
|
629
|
+
}
|
|
620
630
|
function duration(value, name, fallback, unit = "s") {
|
|
621
631
|
if (value === undefined)
|
|
622
632
|
return fallback;
|
|
623
|
-
const
|
|
624
|
-
const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
|
|
633
|
+
const ms = durationMs(value.trim(), unit);
|
|
625
634
|
if (ms < 1)
|
|
626
635
|
badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
|
|
627
636
|
return ms;
|
|
@@ -637,11 +646,13 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
|
637
646
|
fail(`no file ${path}`);
|
|
638
647
|
return file.text();
|
|
639
648
|
}
|
|
640
|
-
var DURATION, UNIT_MS;
|
|
649
|
+
var BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
|
|
641
650
|
var init_input = __esm(() => {
|
|
642
651
|
init_args();
|
|
643
|
-
|
|
644
|
-
|
|
652
|
+
BARE_DURATION = /^\d+(?:\.\d+)?$/;
|
|
653
|
+
DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
|
|
654
|
+
DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
|
|
655
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
|
|
645
656
|
});
|
|
646
657
|
|
|
647
658
|
// ../kit/src/args.ts
|
|
@@ -1669,7 +1680,7 @@ init_style();
|
|
|
1669
1680
|
// ../kit/src/workspace-root.ts
|
|
1670
1681
|
init_user_config();
|
|
1671
1682
|
// package.json
|
|
1672
|
-
var version = "0.
|
|
1683
|
+
var version = "0.22.0";
|
|
1673
1684
|
|
|
1674
1685
|
// src/check.ts
|
|
1675
1686
|
import { writeFile as writeFile3 } from "fs/promises";
|
|
@@ -2071,7 +2082,8 @@ ${body}`;
|
|
|
2071
2082
|
// src/steps.ts
|
|
2072
2083
|
import { readdir as readdir2 } from "fs/promises";
|
|
2073
2084
|
import { join as join10 } from "path";
|
|
2074
|
-
var STEP_NAMES = ["check", "typecheck", "lint", "test"];
|
|
2085
|
+
var STEP_NAMES = ["check", "typecheck", "lint", "fmt", "test"];
|
|
2086
|
+
var STEP_SOURCES = { fmt: ["fmt:check", "format:check", "fmt-check", "format-check"] };
|
|
2075
2087
|
var TARGET2 = /^@?([\w-]+)(?:[ \t][^:=\n]*)?:(?!=)/gm;
|
|
2076
2088
|
var JUSTFILES = ["justfile", "Justfile", ".justfile"];
|
|
2077
2089
|
var TASK_RUNNERS = new Set(["Justfile", "Makefile"]);
|
|
@@ -2188,8 +2200,8 @@ async function discover(dir) {
|
|
|
2188
2200
|
const found = await candidates(dir, "check");
|
|
2189
2201
|
const runnerCheck = found.find((candidate) => candidate.name === "check" && TASK_RUNNERS.has(candidate.source));
|
|
2190
2202
|
return STEP_NAMES.flatMap((name) => {
|
|
2191
|
-
const step = name === "check" && runnerCheck !== undefined ? runnerCheck : found.find((candidate) => candidate.name ===
|
|
2192
|
-
return step === undefined ? [] : [step];
|
|
2203
|
+
const step = name === "check" && runnerCheck !== undefined ? runnerCheck : (STEP_SOURCES[name] ?? [name]).map((each) => found.find((candidate) => candidate.name === each)).find((each) => each !== undefined);
|
|
2204
|
+
return step === undefined ? [] : [{ ...step, name }];
|
|
2193
2205
|
});
|
|
2194
2206
|
}
|
|
2195
2207
|
|
|
@@ -2316,7 +2328,7 @@ async function projectFixers(dir) {
|
|
|
2316
2328
|
const all = named("fix");
|
|
2317
2329
|
if (all !== undefined)
|
|
2318
2330
|
return [all];
|
|
2319
|
-
return [named("lint:fix") ?? named("lint-fix"), named("format")].filter((step) => step !== undefined);
|
|
2331
|
+
return [named("lint:fix") ?? named("lint-fix"), named("fmt") ?? named("format")].filter((step) => step !== undefined);
|
|
2320
2332
|
}
|
|
2321
2333
|
async function toolFixers(dir) {
|
|
2322
2334
|
const fixers = [];
|
|
@@ -2385,7 +2397,7 @@ async function runFixers(values, cwd) {
|
|
|
2385
2397
|
fail("a fixer called check --fix again, which would recurse: give its script another command");
|
|
2386
2398
|
const found = await fixers(cwd);
|
|
2387
2399
|
if (found.length === 0)
|
|
2388
|
-
fail("nothing to fix here: no fix, lint:fix or format script, php-cs-fixer config, Makefile, Justfile, go.mod, Cargo.toml nor ruff config");
|
|
2400
|
+
fail("nothing to fix here: no fix, lint:fix, fmt or format script, php-cs-fixer config, Makefile, Justfile, go.mod, Cargo.toml nor ruff config");
|
|
2389
2401
|
const picked = pick(found, parsed.values.only, "fixer");
|
|
2390
2402
|
const placements = new Map;
|
|
2391
2403
|
for (const fixer of picked)
|
|
@@ -2525,10 +2537,10 @@ async function scriptText(dir, name) {
|
|
|
2525
2537
|
var usage2 = `check [--only <steps>] [--changed] [--failed] [--quiet] [--timeout <duration>] [--slot | --no-slot] [--parallel] [--in <service> | --host] [--list]
|
|
2526
2538
|
check --fix [--only <fixers>] [--timeout <duration>] [--in <service> | --host] [--list]
|
|
2527
2539
|
|
|
2528
|
-
Runs the repo's check, typecheck, lint and test steps, found in package.json scripts, composer.json, a Justfile, a Makefile or the PHP tools' configs; a folder with no steps runs its subfolders' (api/, client/).
|
|
2540
|
+
Runs the repo's check, typecheck, lint, fmt (its fmt:check or format:check script) and test steps, found in package.json scripts, composer.json, a Justfile, a Makefile or the PHP tools' configs; a folder with no steps runs its subfolders' (api/, client/).
|
|
2529
2541
|
A step runs inside the running compose service that mounts its folder and never starts one, and queues for a machine-wide slot when \`slot\` is installed.
|
|
2530
2542
|
A passing step prints one line, a failing one only what failed, and each step's full log is saved to the file its line ends with.
|
|
2531
|
-
With --fix, the project's fix, lint:fix and format scripts run instead, then the formatters its files call for (php-cs-fixer, \`just --fmt\`, go fmt, cargo fmt, ruff), and the files they changed are listed.`;
|
|
2543
|
+
With --fix, the project's fix, lint:fix and fmt or format scripts run instead, then the formatters its files call for (php-cs-fixer, \`just --fmt\`, go fmt, cargo fmt, ruff), and the files they changed are listed.`;
|
|
2532
2544
|
var EXITS = [[0, "every step passed"], [1, "one failed"], [2, "bad usage, no step is found or a step timed out"]];
|
|
2533
2545
|
function slotted(command) {
|
|
2534
2546
|
return `slot -- sh -c ${shellQuote(command)}`;
|
package/dist/errs-cli.js
CHANGED
|
@@ -617,11 +617,20 @@ var init_text2 = __esm(() => {
|
|
|
617
617
|
|
|
618
618
|
// ../kit/src/input.ts
|
|
619
619
|
import process9 from "process";
|
|
620
|
+
function durationMs(text, unit) {
|
|
621
|
+
if (BARE_DURATION.test(text))
|
|
622
|
+
return Number(text) * UNIT_MS[unit];
|
|
623
|
+
if (!DURATION.test(text))
|
|
624
|
+
return 0;
|
|
625
|
+
let ms = 0;
|
|
626
|
+
for (const [, amount, part] of text.matchAll(DURATION_PART))
|
|
627
|
+
ms += Number(amount) * UNIT_MS[part];
|
|
628
|
+
return ms;
|
|
629
|
+
}
|
|
620
630
|
function duration(value, name, fallback, unit = "s") {
|
|
621
631
|
if (value === undefined)
|
|
622
632
|
return fallback;
|
|
623
|
-
const
|
|
624
|
-
const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
|
|
633
|
+
const ms = durationMs(value.trim(), unit);
|
|
625
634
|
if (ms < 1)
|
|
626
635
|
badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
|
|
627
636
|
return ms;
|
|
@@ -637,11 +646,13 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
|
637
646
|
fail(`no file ${path}`);
|
|
638
647
|
return file.text();
|
|
639
648
|
}
|
|
640
|
-
var DURATION, UNIT_MS;
|
|
649
|
+
var BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
|
|
641
650
|
var init_input = __esm(() => {
|
|
642
651
|
init_args();
|
|
643
|
-
|
|
644
|
-
|
|
652
|
+
BARE_DURATION = /^\d+(?:\.\d+)?$/;
|
|
653
|
+
DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
|
|
654
|
+
DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
|
|
655
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
|
|
645
656
|
});
|
|
646
657
|
|
|
647
658
|
// ../kit/src/args.ts
|
|
@@ -1669,7 +1680,7 @@ init_style();
|
|
|
1669
1680
|
// ../kit/src/workspace-root.ts
|
|
1670
1681
|
init_user_config();
|
|
1671
1682
|
// package.json
|
|
1672
|
-
var version = "0.
|
|
1683
|
+
var version = "0.22.0";
|
|
1673
1684
|
|
|
1674
1685
|
// src/errs.ts
|
|
1675
1686
|
import { relative as relative2 } from "path";
|
package/dist/j-cli.js
CHANGED
|
@@ -617,11 +617,20 @@ var init_text2 = __esm(() => {
|
|
|
617
617
|
|
|
618
618
|
// ../kit/src/input.ts
|
|
619
619
|
import process9 from "process";
|
|
620
|
+
function durationMs(text, unit) {
|
|
621
|
+
if (BARE_DURATION.test(text))
|
|
622
|
+
return Number(text) * UNIT_MS[unit];
|
|
623
|
+
if (!DURATION.test(text))
|
|
624
|
+
return 0;
|
|
625
|
+
let ms = 0;
|
|
626
|
+
for (const [, amount, part] of text.matchAll(DURATION_PART))
|
|
627
|
+
ms += Number(amount) * UNIT_MS[part];
|
|
628
|
+
return ms;
|
|
629
|
+
}
|
|
620
630
|
function duration(value, name, fallback, unit = "s") {
|
|
621
631
|
if (value === undefined)
|
|
622
632
|
return fallback;
|
|
623
|
-
const
|
|
624
|
-
const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
|
|
633
|
+
const ms = durationMs(value.trim(), unit);
|
|
625
634
|
if (ms < 1)
|
|
626
635
|
badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
|
|
627
636
|
return ms;
|
|
@@ -637,11 +646,13 @@ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
|
637
646
|
fail(`no file ${path}`);
|
|
638
647
|
return file.text();
|
|
639
648
|
}
|
|
640
|
-
var DURATION, UNIT_MS;
|
|
649
|
+
var BARE_DURATION, DURATION, DURATION_PART, UNIT_MS;
|
|
641
650
|
var init_input = __esm(() => {
|
|
642
651
|
init_args();
|
|
643
|
-
|
|
644
|
-
|
|
652
|
+
BARE_DURATION = /^\d+(?:\.\d+)?$/;
|
|
653
|
+
DURATION = /^(?:\d+(?:\.\d+)?(?:ms|min|[smhd]))+$/;
|
|
654
|
+
DURATION_PART = /(\d+(?:\.\d+)?)(ms|min|[smhd])/g;
|
|
655
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, min: 60000, h: 3600000, d: 86400000 };
|
|
645
656
|
});
|
|
646
657
|
|
|
647
658
|
// ../kit/src/args.ts
|
|
@@ -2294,7 +2305,7 @@ init_style();
|
|
|
2294
2305
|
// ../kit/src/workspace-root.ts
|
|
2295
2306
|
init_user_config();
|
|
2296
2307
|
// package.json
|
|
2297
|
-
var version = "0.
|
|
2308
|
+
var version = "0.22.0";
|
|
2298
2309
|
|
|
2299
2310
|
// src/j.ts
|
|
2300
2311
|
import process26 from "process";
|
|
@@ -2855,7 +2866,8 @@ import { dirname as dirname6, join as join11, resolve as resolvePath } from "pat
|
|
|
2855
2866
|
// src/steps.ts
|
|
2856
2867
|
import { readdir as readdir2 } from "fs/promises";
|
|
2857
2868
|
import { join as join10 } from "path";
|
|
2858
|
-
var STEP_NAMES = ["check", "typecheck", "lint", "test"];
|
|
2869
|
+
var STEP_NAMES = ["check", "typecheck", "lint", "fmt", "test"];
|
|
2870
|
+
var STEP_SOURCES = { fmt: ["fmt:check", "format:check", "fmt-check", "format-check"] };
|
|
2859
2871
|
var TARGET = /^@?([\w-]+)(?:[ \t][^:=\n]*)?:(?!=)/gm;
|
|
2860
2872
|
var JUSTFILES = ["justfile", "Justfile", ".justfile"];
|
|
2861
2873
|
var TASK_RUNNERS = new Set(["Justfile", "Makefile"]);
|
|
@@ -2972,8 +2984,8 @@ async function discover(dir) {
|
|
|
2972
2984
|
const found = await candidates(dir, "check");
|
|
2973
2985
|
const runnerCheck = found.find((candidate) => candidate.name === "check" && TASK_RUNNERS.has(candidate.source));
|
|
2974
2986
|
return STEP_NAMES.flatMap((name) => {
|
|
2975
|
-
const step = name === "check" && runnerCheck !== undefined ? runnerCheck : found.find((candidate) => candidate.name ===
|
|
2976
|
-
return step === undefined ? [] : [step];
|
|
2987
|
+
const step = name === "check" && runnerCheck !== undefined ? runnerCheck : (STEP_SOURCES[name] ?? [name]).map((each) => found.find((candidate) => candidate.name === each)).find((each) => each !== undefined);
|
|
2988
|
+
return step === undefined ? [] : [{ ...step, name }];
|
|
2977
2989
|
});
|
|
2978
2990
|
}
|
|
2979
2991
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-check",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "check and errs: run a repo's check, typecheck, lint and test steps or, with --fix, its fixers, inside its docker compose service when one mounts the folder, showing only what failed with each full output saved to a file, and turn tsc, eslint, bun test, vitest, playwright, phpunit, phpstan and php-cs-fixer logs into file:line:col errors.",
|
|
4
|
+
"version": "0.22.0",
|
|
5
|
+
"description": "check and errs: run a repo's check, typecheck, lint, format check and test steps or, with --fix, its fixers, inside its docker compose service when one mounts the folder, showing only what failed with each full output saved to a file, and turn tsc, eslint, bun test, vitest, playwright, phpunit, phpstan and php-cs-fixer logs into file:line:col errors.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/Kayno0o/cli/tree/main/packages/check#readme",
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
"j": "$npm_execpath src/j-cli.ts"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@kaynooo/cli-kit": "0.46.
|
|
35
|
+
"@kaynooo/cli-kit": "0.46.2"
|
|
36
36
|
}
|
|
37
37
|
}
|