Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo project-owned commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo project-owned pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "migration-existing-vite-hooks",
"packageManager": "pnpm@12.11.2",
"scripts": {
"prepare": "echo vp config --no-hooks"
},
"devDependencies": {
"vite-plus": "latest"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[case]]
name = "migration_existing_vite_hooks"
vp = "global"
steps = [
{ argv = ["git", "init"], snapshot = false },
{ argv = ["pnpm", "--version"], snapshot = false },
{ argv = ["vp", "migrate", "--full", "--no-agent", "--no-editor"], comment = "Complete the existing hook setup without prompting, replacing project hooks, or changing echo arguments." },
{ argv = ["vpt", "print-file", "package.json", ".vite-hooks/pre-commit", ".vite-hooks/commit-msg"] },
{ argv = ["git", "config", "--local", "core.hooksPath"] },
{ argv = ["vpt", "stat-file", ".vite-hooks/_/h", "--assert", "file"] },
{ argv = ["vp", "migrate", "--full", "--no-agent", "--no-editor"], comment = "A complete hook setup is detected and skipped without prompting on the next migration." },
{ argv = ["vpt", "print-file", "package.json", ".vite-hooks/pre-commit", ".vite-hooks/commit-msg"] },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# migration_existing_vite_hooks

## `git init`


## `pnpm --version`


## `vp migrate --full --no-agent --no-editor`

Complete the existing hook setup without prompting, replacing project hooks, or changing echo arguments.

```
VITE+ - The Unified Toolchain for the Web

◇ Updated . to Vite+ <version>
• Node <version> pnpm <version>
• Dependencies:
vite-plus latest → <version>
vite → <version>
• Git hooks configured
• Package manager settings configured
```

## `vpt print-file package.json .vite-hooks/pre-commit .vite-hooks/commit-msg`

```
{
"name": "migration-existing-vite-hooks",
"packageManager": "pnpm@12.11.2",
"scripts": {
"prepare": "vp config && echo vp config --no-hooks"
},
"devDependencies": {
"vite-plus": "catalog:"
}
}
echo project-owned pre-commit
echo project-owned commit-msg
```

## `git config --local core.hooksPath`

```
.vite-hooks/_
```

## `vpt stat-file .vite-hooks/_/h --assert file`

```
.vite-hooks/_/h: file
```

## `vp migrate --full --no-agent --no-editor`

A complete hook setup is detected and skipped without prompting on the next migration.

```
VITE+ - The Unified Toolchain for the Web

This project is already using Vite+! Happy coding!
```

## `vpt print-file package.json .vite-hooks/pre-commit .vite-hooks/commit-msg`

```
{
"name": "migration-existing-vite-hooks",
"packageManager": "pnpm@12.11.2",
"scripts": {
"prepare": "vp config && echo vp config --no-hooks"
},
"devDependencies": {
"vite-plus": "catalog:"
}
}
echo project-owned pre-commit
echo project-owned commit-msg
```
5 changes: 4 additions & 1 deletion packages/cli/src/config/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ c=$?
exit $c`;
}

/** The per-hook stub written to `<dir>/_/<hook>`; it sources the `h` dispatcher. */
export const HOOK_STUB_SCRIPT = '#!/usr/bin/env sh\n. "$(dirname "$0")/h"';

export interface InstallResult {
message: string;
isError: boolean;
Expand Down Expand Up @@ -569,7 +572,7 @@ export function install(dir?: string, options: InstallOptions = {}): InstallResu
writeFileSync(internal('h'), hookScript(location.dir), { mode: 0o755 });
chmodSync(internal('h'), 0o755);
for (const hook of SUPPORTED_GIT_HOOK_NAMES) {
writeFileSync(internal(hook), `#!/usr/bin/env sh\n. "$(dirname "$0")/h"`, { mode: 0o755 });
writeFileSync(internal(hook), HOOK_STUB_SCRIPT, { mode: 0o755 });
chmodSync(internal(hook), 0o755);
}
if (!gitConfigLocalHas('core.hooksPath', location.target)) {
Expand Down
Loading
Loading