You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: update vp config RFC for postinstall and staged config changes
Update all sections to reflect that vp config now recognizes both
prepare and postinstall lifecycle events, and skips the interactive
prompt when staged config already exists in vite.config.ts.
Copy file name to clipboardExpand all lines: rfcs/config-and-staged-commands.md
+27-23Lines changed: 27 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## Summary
4
4
5
-
Add `vp config` and `vp staged` as built-in commands. `vp config` is a `prepare`-lifecycle command that installs git hook shims (husky-compatible reimplementation, not a bundled dependency). `vp staged` bundles lint-staged and reads config from the `staged` key in `vite.config.ts`. Projects get a zero-config pre-commit hook that runs `vp check --fix` on staged files — no extra devDependencies needed.
5
+
Add `vp config` and `vp staged` as built-in commands. `vp config` is a lifecycle command (`prepare` or `postinstall`) that installs git hook shims (husky-compatible reimplementation, not a bundled dependency). `vp staged` bundles lint-staged and reads config from the `staged` key in `vite.config.ts`. Projects get a zero-config pre-commit hook that runs `vp check --fix` on staged files — no extra devDependencies needed.
`vp config` is the command that runs on every `npm install` via the `prepare` script. It reinstalls hook shims — it does **not** create the `staged` config or the pre-commit hook file. Those are created by `vp create`/`vp migrate`.
60
+
`vp config` is the command that runs on every `npm install` via the `prepare`or `postinstall`script. It reinstalls hook shims — it does **not** create the `staged` config or the pre-commit hook file. Those are created by `vp create`/`vp migrate`.
61
61
62
62
```json
63
63
{ "scripts": { "prepare": "vp config" } }
64
+
// or
65
+
{ "scripts": { "postinstall": "vp config" } }
64
66
```
65
67
66
-
When `npm_lifecycle_event=prepare` (set by npm/pnpm/yarn during `npm install`), agent setup is skipped automatically — only hooks are reinstalled.
68
+
When running from a lifecycle script (`npm_lifecycle_event` is `prepare` or `postinstall`), hooks are installed automatically without prompting.
For users who want to set up hooks manually, four steps are required:
71
73
72
-
1.**Add prepare script** to `package.json`:
74
+
1.**Add lifecycle script** to `package.json`:
73
75
```json
74
76
{ "scripts": { "prepare": "vp config" } }
75
77
```
78
+
Or use `postinstall` if `prepare` is not suitable for your project.
76
79
2.**Add staged config** to `vite.config.ts`:
77
80
```typescript
78
81
exportdefaultdefineConfig({
@@ -105,9 +108,10 @@ Behavior:
105
108
6. Exits 0 and skips hooks if `VITE_GIT_HOOKS=0` or `HUSKY=0` environment variable is set (backwards compatible)
106
109
7. Exits 0 and skips hooks if `.git` directory doesn't exist (safe during `npm install` in consumer projects)
107
110
8. Exits 1 on real errors (git command not found, `git config` failed)
108
-
9. Agent update runs uniformly in all modes (`prepare`, interactive, non-interactive). New agent file creation is handled by `vp create`/`vp migrate`.
109
-
10. Interactive mode: prompts on first run for hooks setup
110
-
11. Non-interactive mode: sets up hooks by default
111
+
9. Agent update runs uniformly in all modes (lifecycle script, interactive, non-interactive). New agent file creation is handled by `vp create`/`vp migrate`.
112
+
10. Lifecycle script mode (`prepare`/`postinstall`): sets up hooks automatically without prompting
113
+
11. Interactive mode: prompts on first run — unless the project already has `staged` config in `vite.config.ts` (which implies prior opt-in)
114
+
12. Non-interactive mode: sets up hooks by default
111
115
112
116
### `vp staged`
113
117
@@ -275,12 +279,12 @@ Husky <9.0.0 is not supported by auto migration — `vp migrate` detects unsuppo
0 commit comments