@kaynooo/cli-check 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +103 -2
- package/dist/cli.js +2150 -0
- package/dist/errs-cli.js +2010 -0
- package/dist/fix-cli.js +2374 -0
- package/package.json +32 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kaynooo <contact@kaynooo.fr>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,104 @@
|
|
|
1
|
-
#
|
|
1
|
+
# check and fix
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`check` runs a repo's validation and `fix` its fixers, both showing only what failed, so a Claude Code session spends no tokens on passing output.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
bun install -g @kaynooo/cli-check
|
|
7
|
+
check # run every step found
|
|
8
|
+
check --list # print the steps and the commands that run them
|
|
9
|
+
check --only lint,test
|
|
10
|
+
check --timeout 5m # end a step still running after 5 minutes, exit 2
|
|
11
|
+
check --slot # queue each step behind the machine-wide slots of `slot` (@kaynooo/cli-wait)
|
|
12
|
+
check --in app # run every step in this compose service, whatever is detected
|
|
13
|
+
check --host # run on the host even when a compose service mounts the folder
|
|
14
|
+
check --json # [{name, command, in?, ok, ms, log, failed?}] once every step ran
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Steps
|
|
18
|
+
|
|
19
|
+
`check`, `typecheck`, `lint` and `test`, run in that order, from the first source that has each one:
|
|
20
|
+
|
|
21
|
+
| Source | Command |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| `package.json` scripts | `bun run <script>` |
|
|
24
|
+
| `composer.json` scripts | `composer run <script>` |
|
|
25
|
+
| `Justfile` recipes that need no argument (read from `just --dump --dump-format json`, private ones left out) | `just <recipe>` |
|
|
26
|
+
| `GNUmakefile`, `makefile` or `Makefile` targets, in the order make reads them | `make <target>` |
|
|
27
|
+
| `phpstan.neon`, `phpstan.neon.dist` or `phpstan.dist.neon`, when no source above has a `typecheck` | `vendor/bin/phpstan analyse --no-progress --memory-limit=1G` |
|
|
28
|
+
| `.php-cs-fixer.php` or `.php-cs-fixer.dist.php`, when no source above has a `lint` | `vendor/bin/php-cs-fixer fix --dry-run -v` (the fixers each file needs are named) |
|
|
29
|
+
| `phpunit.xml`, `phpunit.xml.dist` or `phpunit.dist.xml`, when no source above has a `test` | `vendor/bin/phpunit` |
|
|
30
|
+
|
|
31
|
+
Scripts always go through `bun run`, so a `check` script of `$npm_execpath check` runs Bun's type checker, and a script that calls this bin by name is skipped.
|
|
32
|
+
|
|
33
|
+
A folder with no step of its own but subfolders that have some (a root with `api/` and `client/`) runs each subfolder's steps, in alphabetical order, each line naming it: `api/lint`, `client/test`. `--only lint` picks `lint` in every one, and each step runs in its own subfolder. Only the folder's direct children are looked at, without hidden ones, `node_modules`, `vendor`, `dist`, `build`, `var`, `tmp` and `coverage`.
|
|
34
|
+
|
|
35
|
+
## In the compose service
|
|
36
|
+
|
|
37
|
+
Athome repos run their tools in a container, so `check`, `fix` and `errs -- <command>` run a step inside the docker compose service that bind-mounts its folder, instead of on the host. The project is the nearest `compose.yaml`, `compose.yml`, `docker-compose.yaml` or `docker-compose.yml` from the step's folder up to the repository root (the folder holding `.git`), with its `compose.override.*` merged in. A service qualifies when one of its bind mounts (`.:/app`, `./api:/var/www/html`, the long `type: bind` syntax, `${VAR:-default}` interpolated with the environment and the project's `.env`) holds the folder, a mount of a parent folder included; named volumes are ignored. The step runs `docker compose exec -T -w <path of the folder in the container> <service> sh -c '<command>'` from the project's folder, with `NO_COLOR=1 FORCE_COLOR=0` set, and the container path is the mount's target plus the folder's path under its source.
|
|
38
|
+
|
|
39
|
+
- The stack is only read: `docker compose ps --services --status running` is asked once per project, and a service that is down is never started. The step fails, naming the service and where its project lives, and the other steps go on; start the stack yourself, or pass `--host`.
|
|
40
|
+
- Several services mounting the folder (php and a worker): the one whose name, image or build names the step's tool wins (`bun` and `node` look for `bun` or `node`, `composer`, `php`, `phpunit`, `phpstan` and `vendor/bin/*` for `php`). When none or several stand out the call fails listing them and asks for `--in <service>`.
|
|
41
|
+
- `--in <service>` runs in that service, failing when it does not exist or does not mount the folder. `--host` runs on the host. Both together are a usage error.
|
|
42
|
+
- `check --list` has a column saying where each step runs, `host` or the service; `--json` adds `in` with the service name to a step that runs in one (`--list --json` as well).
|
|
43
|
+
- `COMPOSE_FILE` (in the environment or the project's `.env`) replaces the search for `compose.yaml`: the files it names, separated by `:` (`COMPOSE_PATH_SEPARATOR` if set) and read relative to the project folder, are merged in order. A file it names that does not exist fails the call, as `docker compose` would.
|
|
44
|
+
- No `docker` on the PATH (a devcontainer, CI): there is no container to reach, so the step runs on the host and stderr says `host, docker not found` once per project; `--in <service>` fails instead.
|
|
45
|
+
- A compose file that does not parse fails the call naming the file and the parse error, and points at `--host`; it never falls back to the host silently, even without docker.
|
|
46
|
+
- `--slot` queues the whole docker command. `--timeout` ends the `docker compose exec` client, which does not always end what it started inside the container.
|
|
47
|
+
- `fix` runs the project's scripts and `php-cs-fixer` in the service, and keeps its own formatters (`justfile`, `go`, `rust`, `python`, `makefile`) on the host. The recursion guard variable is passed into the container.
|
|
48
|
+
|
|
49
|
+
## Output
|
|
50
|
+
|
|
51
|
+
A passing step is one line: `ok lint 1.0s <log path>`. A failing step prints `FAIL`, its command and log path, then only what failed, recognised from the output: `bun test` (failed tests with their own output), `bun check`, tsc, tsgo and vue-tsc (plain and pretty), eslint and keslint (stylish), Vitest, Playwright, PHP CS Fixer (its dry-run listing without the diffs), PHPStan, PHPUnit, ParaTest (a crashed worker included) and Pest. Any other format shows the last 30 lines, and an excerpt is capped at 100 lines. Each step's full output is saved to `<run folder>/<step>.log`, for grep: one folder per run under `$XDG_RUNTIME_DIR/kaynooo-cli/check` (`~/.cache/kaynooo-cli/check` without it), only the user can enter it, files are mode 0600, and runs older than three days are removed. `--only` naming no step fails instead of passing silently.
|
|
52
|
+
|
|
53
|
+
SIGINT, SIGTERM and SIGHUP go to the running step's whole process group and `check` stops there. `--timeout` (`-t`, `30s`, `5m`) ends a step and everything it started.
|
|
54
|
+
|
|
55
|
+
Exit code 0 when every step passed, 1 when one failed, 2 on bad usage, when no step is found or when a step timed out.
|
|
56
|
+
|
|
57
|
+
## fix
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
fix # run every fixer that applies to this folder
|
|
61
|
+
fix --list # print them and their commands
|
|
62
|
+
fix --only lint:fix,justfile
|
|
63
|
+
fix --in app # run the scripts in this compose service; --host forces the host
|
|
64
|
+
fix --json # {fixers, changed}, a skipped fixer as {name, command, skipped}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
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:
|
|
68
|
+
|
|
69
|
+
| Fixer | When | Runs |
|
|
70
|
+
| --- | --- | --- |
|
|
71
|
+
| `php-cs-fixer` | `.php-cs-fixer.php` or `.php-cs-fixer.dist.php`, and no fixer script in `composer.json` | `vendor/bin/php-cs-fixer fix` |
|
|
72
|
+
| `makefile` | a Makefile | declares every command target `.PHONY` in one sorted line (a continued `.PHONY` line replaced whole, targets that are files or depend on files left out), collapses blank lines, writes only when the content changes |
|
|
73
|
+
| `justfile` | a Justfile | `just --justfile <file> --fmt` |
|
|
74
|
+
| `go` | `go.mod` | `go fmt ./... && go mod tidy` |
|
|
75
|
+
| `rust` | `Cargo.toml` | `cargo fmt` |
|
|
76
|
+
| `python` | `ruff.toml`, `.ruff.toml` or a `[tool.ruff]` section | `ruff check --fix . && ruff format .` |
|
|
77
|
+
|
|
78
|
+
It looks at the folder itself only, so each package of a monorepo gets its own run. A fixer whose binary is missing is skipped with a `skip` line. Lines and logs read like `check`'s, then the files the run changed are listed, leaving out those already dirty before it, when the folder is in a git repository. A script that calls `fix` again fails instead of recursing.
|
|
79
|
+
|
|
80
|
+
Exit code 0 when every fixer ran, 1 when one failed, 2 on bad usage or when nothing applies.
|
|
81
|
+
|
|
82
|
+
## errs
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
errs build.log # a log file, or - for stdin
|
|
86
|
+
tsgo -p . 2>&1 | errs
|
|
87
|
+
errs -- bun test # run a command, parse its output
|
|
88
|
+
errs --json -- keslint src # {errors, unrecognised, log?, code?}
|
|
89
|
+
errs --in app -- vendor/bin/phpunit # in this compose service; --host forces the host
|
|
90
|
+
```
|
|
91
|
+
|
|
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
|
+
|
|
94
|
+
| Tool | Read from | One error per |
|
|
95
|
+
| --- | --- | --- |
|
|
96
|
+
| `phpunit`, `paratest` (9 to 12, colours or not) | the "There was 1 error" and "There were 3 failures" listings | failed or errored test: `file:line: Class::test: message`, at the first file under its trace, an assertion diff cut to its changed lines. Risky tests, warnings, deprecations and notices are never counted |
|
|
97
|
+
| `phpstan` | the default table, `--error-format=raw` and `json` | message: `file:line: message (identifier)`, a wrapped table message joined, problems with no file at line 0 |
|
|
98
|
+
| `php-cs-fixer` | `fix --dry-run` (`-v` names the fixers, `--diff` is skipped) | file: `file:0:0: style issues to fix (fixer, fixer)` |
|
|
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
|
+
| `vitest` | the default and verbose reporters | failed test, or suite that failed to load, at its first `file:line:col` frame |
|
|
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`, `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
|
+
|
|
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.
|