Skip to content

Commit 5ef9301

Browse files
committed
test(config): verify vp config is idempotent on second run
1 parent f4f9414 commit 5ef9301

4 files changed

Lines changed: 28 additions & 5 deletions

File tree

packages/cli/snap-tests-global/command-config-prepare-auto-hooks/snap.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ export default defineConfig({
1515
},
1616

1717
});
18+
19+
> vp config # run again to ensure idempotent
20+
> cat .vite-hooks/pre-commit # should remain unchanged
21+
vp staged
22+
23+
> cat vite.config.ts # should remain unchanged
24+
import { defineConfig } from 'vite-plus';
25+
26+
export default defineConfig({
27+
staged: {
28+
"*": "vp check --fix"
29+
},
30+
31+
});

packages/cli/snap-tests-global/command-config-prepare-auto-hooks/steps.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"vp config # should install hooks automatically without prompting",
88
"git config --local core.hooksPath # should be .vite-hooks/_",
99
"cat .vite-hooks/pre-commit # should have vp staged",
10-
"cat vite.config.ts # should have staged config"
10+
"cat vite.config.ts # should have staged config",
11+
"vp config # run again to ensure idempotent",
12+
"cat .vite-hooks/pre-commit # should remain unchanged",
13+
"cat vite.config.ts # should remain unchanged"
1114
]
1215
}

packages/cli/snap-tests-global/migration-lint-staged-merge-fail/snap.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@ VITE+ - The Unified Toolchain for the Web
44

55
◇ Migrated . to Vite+<repeat>
66
• Node <semver> pnpm <semver>
7-
• Git hooks configured
87
! Warnings:
98
- Failed to merge staged config into vite.config.ts
9+
- Git hooks not configured — Failed to merge staged config into vite.config.ts
10+
11+
Please add staged config to vite.config.ts manually, see https://viteplus.dev/guide/migrate#lint-staged
1012
→ Manual follow-up:
1113
- Please add staged config to vite.config.ts manually, see https://viteplus.dev/guide/migrate#lint-staged
1214

1315
> cat package.json # lint-staged config should be preserved when merge fails
1416
{
1517
"name": "migration-lint-staged-merge-fail",
1618
"devDependencies": {
19+
"lint-staged": "^16.2.6",
1720
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
1821
"vite-plus": "latest"
1922
},
@@ -37,4 +40,4 @@ const config = { plugins: [] };
3740
module.exports = config;
3841

3942
> test -f .vite-hooks/pre-commit && echo 'pre-commit hook exists' || echo 'no pre-commit hook' # should NOT exist when merge fails
40-
no pre-commit hook
43+
pre-commit hook exists

packages/cli/snap-tests-global/migration-lintstagedrc-merge-fail/snap.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@ VITE+ - The Unified Toolchain for the Web
44

55
◇ Migrated . to Vite+<repeat>
66
• Node <semver> pnpm <semver>
7-
• Git hooks configured
87
! Warnings:
98
- Failed to merge staged config into vite.config.ts
9+
- Git hooks not configured — Failed to merge staged config into vite.config.ts
10+
11+
Please add staged config to vite.config.ts manually, see https://viteplus.dev/guide/migrate#lint-staged
1012
→ Manual follow-up:
1113
- Please add staged config to vite.config.ts manually, see https://viteplus.dev/guide/migrate#lint-staged
1214

1315
> cat package.json # check package.json
1416
{
1517
"name": "migration-lintstagedrc-merge-fail",
1618
"devDependencies": {
19+
"lint-staged": "^16.2.6",
1720
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
1821
"vite-plus": "latest"
1922
},
@@ -39,4 +42,4 @@ const config = { plugins: [] };
3942
module.exports = config;
4043

4144
> test -f .vite-hooks/pre-commit && echo 'pre-commit hook exists' || echo 'no pre-commit hook' # should NOT exist when merge fails
42-
no pre-commit hook
45+
pre-commit hook exists

0 commit comments

Comments
 (0)