Add ts dev lint domains + ts dev install-hooks - #733
Conversation
fcff9ed to
30f2cc1
Compare
Port the pure-Rust URL-host linter (`ts dev lint domains`) and the
pre-commit hook installer (`ts dev install-hooks`) onto main's
restructured CLI. Both are cross-host (all git access via gitoxide, no
`git` subprocess) and register as siblings of the macOS-only
`ts dev proxy`.
Adapt to main's layout:
- Move the feature under `src/commands/dev/{lint,install_hooks}` and add
the `Lint` / `InstallHooks` variants to `DevCommand`, replacing the
prior empty-enum handling.
- Reintroduce a small `CliError` (`Io`, `Json`, `EnvironmentError`,
`ViolationsFound`) plus `output::write_{stdout,stderr}_line` /
`write_json`; `output` becomes cross-host while `info` / `warn` stay
macOS-only.
- Map the linter's results to the exit contract (0 clean, 1 violations,
2 environment error) in `commands::dev::run`.
- Scope `error-stack` / `derive_more` cross-host and add `gix` /
`gix-config`; add `assert_cmd` / `predicates` / `temp-env` dev-deps.
The former `serve` subcommand is not restored — main replaced it with
`ts dev proxy` independently of this work.
30f2cc1 to
b0b6bd5
Compare
Pin a fixed `user.name` / `user.email` in the repo-local config of the git fixtures. `create_and_checkout_branch` writes a ref through `repo.reference(...)`, whose reflog needs a committer identity; CI machines have no ambient identity, so both `changed_vs` tests failed with `CreateOrUpdateRefLog(MissingCommitter)`. Developer machines passed only because they inherited a global git identity. Repair the "Resolved by the Phase 2 spike" list in the design spec. Its sub-bullets were glued onto preceding lines and its inline code spans were split across line breaks, so prettier re-indented the block deeper on every run and never converged, failing `format-docs`.
ChristianPavilonis
left a comment
There was a problem hiding this comment.
Automated Review:
Summary
Reviewed the domain-lint and hook-installation changes. I found one confirmed self-exclusion defect, submitted inline.
Findings by priority
- P1: 1 inline finding.
CI
All currently reported PR checks are passing. git diff --check is clean.
Existing Reviews
No existing submitted reviews were returned when checked; this review does not duplicate prior feedback.
|
|
||
| /// The linter's own source file — excluded so its allowlist | ||
| /// constants and doc comments cannot self-flag. | ||
| const SELF_PATH: &str = "crates/trusted-server-cli/src/dev/lint/domains.rs"; |
There was a problem hiding this comment.
P1 – Correct the self-exclusion path
SELF_PATH omits the commands/ path component, so the component-aware Path::ends_with check cannot match this file's actual repository path. Consequently full, changed-vs-ref, staged, and explicit scans can report the linter's own intentionally disallowed-host fixtures; the installed staged hook can then reject commits that modify this source file. The regression test currently constructs the same incorrect src/dev/lint layout, so it does not cover the real path.
| const SELF_PATH: &str = "crates/trusted-server-cli/src/dev/lint/domains.rs"; | |
| const SELF_PATH: &str = "crates/trusted-server-cli/src/commands/dev/lint/domains.rs"; |
Summary
ts dev lint domains— a pure-Rust source/config/docs linter that flags non-allowlisted URL hosts in four modes (--staged,--changed-vs <ref>, full-repo, explicit paths). All git operations go through gitoxide (no shelling out togit).ts dev install-hooks— installs a managedpre-commithook that runsts dev lint domains --staged, with foreigncore.hooksPathpreflight, unmanaged-clobber refusal, and--forcewith timestamped backup.ts devleaf into a subcommand group:ts dev servepreserves the prior surface;lintandinstall-hooksare siblings.Stacked on #669 — base branch is
feature/ts-cli. Merge that PR first.Design
Allowlists:
EXACT_HOSTS,SUBDOMAIN_HOSTS,REFERENCE_HOSTS, plus RFC 2606 reserved TLDs. Suppression marker:// allow-domain: host(and#,<!--,*comment forms). Scanned extensions cover Rust, TS/JS, configs, Markdown, CSS, HTML, env files, and Dockerfiles. Exit codes: 0 clean, 1 violations, 2 environment error, 130 cancelled.Test plan
cargo fmt --all -- --checkcargo clippy --workspace --exclude trusted-server-cli --all-targets --all-features -- -D warningscargo clippy --package trusted-server-cli --target <host> --all-targets -- -D warningscargo test --package trusted-server-cli --target <host>— 132 tests passcd crates/js/lib && npx vitest run— 291 tests passcd crates/js/lib && npm run formatcd docs && npm run formatcargo test --workspace --exclude trusted-server-cli— one pre-existing failure on the base (test_env_var_roundtrip_normalizes_integration_types) reproduces onorigin/feature/ts-cliwith zero files touched intrusted-server-core/on this branch; not a regression from this work.