Skip to content

Commit 6b036e8

Browse files
wyf027fengmk2
andauthored
feat: allow vp config opt-outs (#1842)
## Summary - add `vp config --no-hooks` to skip hook installation - add `vp config --no-agent` to skip existing coding agent instruction updates - document the new opt-out flags alongside `--hooks-only` and `VITE_GIT_HOOKS=0` Closes #1311. ## Verification - `pnpm exec oxfmt --check packages/cli/src/config/bin.ts docs/guide/commit-hooks.md` - static source/docs assertion for the new config flags - `mri` parsing assertion for `--no-hooks`, `--no-agent`, and `--hooks-only` Could not run `pnpm -F vite-plus test packages/cli/src/config/__tests__/hooks.spec.ts` in this checkout because the local install does not expose the `vitest` binary. --------- Co-authored-by: MK (fengmk2) <fengmk2@gmail.com>
1 parent 740319f commit 6b036e8

22 files changed

Lines changed: 131 additions & 11 deletions

File tree

docs/guide/commit-hooks.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,17 @@ If you use [`vp create`](/guide/create) or [`vp migrate`](/guide/migrate), Vite+
2222
```bash
2323
vp config
2424
vp config --hooks-dir .vite-hooks
25+
vp config --no-hooks
26+
vp config --no-agent
2527
```
2628

29+
Use `--no-hooks` when you want `vp config` to leave existing Git hook setup unchanged. Use
30+
`--no-agent` when you want it to skip updates to existing coding agent instruction files. You
31+
can pass both flags when you want `vp config` to skip both setup steps.
32+
33+
You can also set `VITE_GIT_HOOKS=0` to disable hook installation from lifecycle scripts such as
34+
`prepare` or `postinstall`.
35+
2736
### `vp staged`
2837

2938
`vp staged` runs staged-file checks using the `staged` config from `vite.config.ts`. If you set up Vite+ to handle your commit hooks, it will automatically run when you commit your local changes.

packages/cli/snap-tests-global/command-config-custom-dir-hook-path/snap.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
> git init
2-
> vp config --hooks-only --hooks-dir .config/husky
2+
> vp config --no-agent --hooks-dir .config/husky
33
> mkdir -p node_modules/.bin && printf '#!/usr/bin/env sh\necho hook-path-ok' > node_modules/.bin/test-hook-cmd && chmod +x node_modules/.bin/test-hook-cmd
44
> mkdir -p .config/husky && printf 'test-hook-cmd\n' > .config/husky/pre-commit
55
> echo test > file.txt && git add file.txt

packages/cli/snap-tests-global/command-config-custom-dir-hook-path/steps.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"commands": [
33
{ "command": "git init", "ignoreOutput": true },
4-
{ "command": "vp config --hooks-only --hooks-dir .config/husky", "ignoreOutput": true },
4+
{ "command": "vp config --no-agent --hooks-dir .config/husky", "ignoreOutput": true },
55
{
66
"command": "mkdir -p node_modules/.bin && printf '#!/usr/bin/env sh\\necho hook-path-ok' > node_modules/.bin/test-hook-cmd && chmod +x node_modules/.bin/test-hook-cmd",
77
"ignoreOutput": true

packages/cli/snap-tests-global/command-config-help/snap.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Configure Vite+ for the current project (hooks + agent integration).
55

66
Options:
77
--hooks-dir <path> Custom hooks directory (default: .vite-hooks)
8+
--no-hooks Skip hook installation
9+
--no-agent Skip updating coding agent instructions
810
-h, --help Show this help message
911

1012
Environment:
@@ -20,6 +22,8 @@ Configure Vite+ for the current project (hooks + agent integration).
2022

2123
Options:
2224
--hooks-dir <path> Custom hooks directory (default: .vite-hooks)
25+
--no-hooks Skip hook installation
26+
--no-agent Skip updating coding agent instructions
2327
-h, --help Show this help message
2428

2529
Environment:
@@ -35,6 +39,8 @@ Configure Vite+ for the current project (hooks + agent integration).
3539

3640
Options:
3741
--hooks-dir <path> Custom hooks directory (default: .vite-hooks)
42+
--no-hooks Skip hook installation
43+
--no-agent Skip updating coding agent instructions
3844
-h, --help Show this help message
3945

4046
Environment:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# My Project
2+
3+
Custom instructions here.
4+
5+
<!--VITE PLUS START-->
6+
7+
OUTDATED CONTENT THAT SHOULD NOT BE REPLACED
8+
9+
<!--VITE PLUS END-->
10+
11+
More custom content below.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "command-config-no-agent"
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
> git init
2+
> vp config --no-agent # should install hooks but skip agent instruction updates
3+
> git config --local core.hooksPath # should be .vite-hooks/_
4+
.vite-hooks/_
5+
6+
> grep -q 'OUTDATED CONTENT' AGENTS.md && echo 'agent unchanged' || echo 'ERROR: agent updated' # should not update agent instructions
7+
agent unchanged
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"commands": [
3+
{ "command": "git init", "ignoreOutput": true },
4+
"vp config --no-agent # should install hooks but skip agent instruction updates",
5+
"git config --local core.hooksPath # should be .vite-hooks/_",
6+
"grep -q 'OUTDATED CONTENT' AGENTS.md && echo 'agent unchanged' || echo 'ERROR: agent updated' # should not update agent instructions"
7+
]
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'vite-plus';
2+
3+
export default defineConfig({
4+
staged: {
5+
'*': 'vp check --fix',
6+
},
7+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# My Project
2+
3+
Custom instructions here.
4+
5+
<!--VITE PLUS START-->
6+
7+
OUTDATED CONTENT THAT SHOULD NOT BE REPLACED
8+
9+
<!--VITE PLUS END-->
10+
11+
More custom content below.

0 commit comments

Comments
 (0)