@kaynooo/cli-guard 0.7.2 → 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 +3 -0
- package/dist/cli.js +741 -317
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -14,16 +14,19 @@ guard check --json --cwd "$PWD" - < command.txt
|
|
|
14
14
|
| --- | --- | --- |
|
|
15
15
|
| `remote` | `ssh`, `scp`, `sftp`, `mosh`, `rsync` to a host, `DOCKER_HOST=ssh://`, `docker -H ssh://` | `src/remote.ts` |
|
|
16
16
|
| `git` | `git stash` (pointing at `proof`, `base`, a commit first or `git worktree add`), `git add -A`/`.`/`-u`, `git commit -a` in any flag cluster, `git push` the user did not ask for, `git push --tags` without `--atomic` | `src/git.ts` |
|
|
17
|
+
| `destructive` | `git reset --hard`, discarding the whole tree (`checkout -- .`, `checkout -f`, `restore .`, `switch -f`), `git clean -f`, a force push (`--force`, `-f`, `--mirror`, `+refspec`; `--force-with-lease` passes), `git branch -D`, a `git rebase` (`--continue` and `--abort` pass), `filter-branch`, `rm -r` on `/`, `~`, `$HOME`, `.`, `..`, `*` or a top-level directory, a download piped into a shell (`curl ... \| sh`, `bash <(curl ...)`); each refusal names the safe route: a commit with `gc` first, `base`, `git worktree add`, `--force-with-lease` | `src/destructive.ts` |
|
|
17
18
|
| `commit` | a commit message breaking the format: no Conventional Commit title, a trailer, a body over two lines, a bullet list, a hard wrap; `-m`, `-F <file>` and `-F -` with a heredoc are read; the refusal spells the rule out and points at `gc` | `src/commit.ts`, the validator in `@kaynooo/cli-git` |
|
|
18
19
|
| `sql` | a SQL client, console or dump tool fed a write (INSERT, UPDATE, DELETE, DDL, migrations, fixtures) outside a test database | `@kaynooo/cli-db` (`src/clients.ts`, `src/guard.ts`) |
|
|
19
20
|
| `env` | a command reading, writing or printing an env file or the whole environment; `guard path` refuses a file tool opening one | `@kaynooo/cli-env` (`src/guard.ts`) |
|
|
20
21
|
| `package-manager` | an install with another manager than the nearest lockfile pins, when it cannot be translated | `@kaynooo/cli-pkg` (`src/pin.ts`) |
|
|
22
|
+
| `pkg` | on the hook only, an install `pkg check` refuses or cannot check, pointing at `pkg <name>` before adding it | `@kaynooo/cli-pkg` |
|
|
21
23
|
| `edit` | when `sub` is installed, a `sed -i` and a python, bun or node script replacing text in a file (`-c`, `-e` or a heredoc), handing over the `sub` command doing the same where its `s` commands or `.replace(...)` calls take literals | `src/replace.ts` |
|
|
22
24
|
|
|
23
25
|
Every rule reads the command with one shell parser (`packages/kit/src/shell.ts`): quotes, heredoc bodies (text, never commands), `env`/`sudo`/`command` wrappers and subshells.
|
|
24
26
|
|
|
25
27
|
## Behaviour
|
|
26
28
|
|
|
29
|
+
- `guard rules [--json]` lists every rule with what it refuses, its route and where it runs. A test checks that `guard check` and `guard hook` give the same refusals for a corpus of commands.
|
|
27
30
|
- `guard check <command>` takes the command as one argument, or from stdin with `-` or when none is given; `--cwd` is the directory it runs in, for the files and lockfiles the rules read.
|
|
28
31
|
- Clean: nothing printed, exit 0. Broken: one `<rule>: <route>` line per broken rule, exit 1.
|
|
29
32
|
- Some rules rewrite rather than refuse: an install with the wrong manager runs with the pinned one, and a noisy test, lint or build run goes through `out` when it is installed (`--no-wrap` to skip). The text output says `runs as: <command>` and why.
|