feat(cli): add vp hooks command for managing Git hooks (#2219) - #2341
feat(cli): add vp hooks command for managing Git hooks (#2219)#2341dennybiasiolli wants to merge 11 commits into
vp hooks command for managing Git hooks (#2219)#2341Conversation
✅ Deploy Preview for viteplus-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
9ac52bd to
db4b05e
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1d530ca12
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
d1d530c to
f96ecef
Compare
|
Rebased on top of the |
Implement pure hook lifecycle helpers on top of install(): user preference persistence (local git config), safe per-scope core.hooksPath unset, and status reporting. Teach install() and vp config to honor a disable preference and resolve the last-used hooks directory. Cover lifecycle, foreign path, worktree, stored custom dir, and unsafe-tree cases in unit tests; update the config help snapshot for the remembered hooks-dir default.
Add the hooks bin entry and register it from bin.ts so local vp can run setup/disable/enable/status. Bundle the entry with tsdown, document it in the CLI package build notes, and add a PTY lifecycle fixture for setup/status/disable/enable plus prepare-style config skip after disable.
Delegate hooks from the Rust global CLI to the JS implementation, and list the command in global help, the interactive picker, and the local NAPI help surface. Update top-level help snapshots and add vp hooks --help coverage for local and global flavors.
Add setup/disable/enable/status to the commit-hooks guide with a quick start, and point create, migrate, troubleshooting, and the guide index at the new commands so users can discover and operate them easily.
Keep enable/disable/status as the public surface. enable installs or refreshes the dispatcher and clears a disable preference.
Resolve relative and absolute hooksPath spellings against the git worktree root (via realpath) before deciding ownership, so disable and install do not treat /repo/.vite-hooks/_ as a foreign path.
f96ecef to
c088f14
Compare
Persist the setup-time git prefix with the hooks directory so enable, disable, status, and vp config resolve the same dispatcher from a nested cwd instead of treating root .vite-hooks/_ as foreign.
disable now always walks local and worktree scopes instead of only the effective value, so a foreign worktree path cannot leave a stale local Vite+ hooksPath behind after the dispatcher is removed.
git config --unset exits 5 when a key has multiple values, which we treated as success. Use --unset-all for the disable preference and scoped core.hooksPath so enable cannot leave a stale disabled state.
Positional directories and unknown flags were ignored, so `vp hooks disable .custom-hooks` could tear down the default dispatcher. Fail fast and point at --hooks-dir instead.
c088f14 to
ca54fec
Compare
Closes #2219
Adds a dedicated
vp hookscommand so users can manage the Vite+ Git hookdispatcher without following the manual steps from the commit-hooks guide:
vp hooks setup— install or refresh the dispatcher (core.hooksPath+<dir>/_)vp hooks disable— tear down the dispatcher and persist the decision in localgit config so
prepare/vp configdo not reinstall itvp hooks enable— re-enable after disable (same as setup)vp hooks status— show preference,core.hooksPath, dispatcher, and project hooksProject-owned hooks (e.g.
.vite-hooks/pre-commit),stagedconfig, andpackage.jsonlifecycle scripts are left alone. Custom directories work via--hooks-dirand are remembered in local git config for later commands andvp config.Why
#2219: once hooks are set up there was no first-class way to remove them, so people
had to hand-edit
core.hooksPathand delete.vite-hooks/_. Maintainers preferreda
vp hookssurface (setup/disable/enable/status) over avp config --uninstall-hooksflag, with the disable decision persisted.Disclaimer: assisted by Grok 4.5 (xAI) while implementing and reviewing this change.