Skip to content
Open
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,13 @@
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const project = createRequire(import.meta.url);
const cli = createRequire(project.resolve('vite-plus/package.json'));
const runner = createRequire(project.resolve('vitest'));
const core = cli.resolve('vite/package.json');

assert.equal(project('vite/package.json').name, '@voidzero-dev/vite-plus-core');
assert.equal(project.resolve('vite/package.json'), core);
assert.equal(runner.resolve('vite/package.json'), core);
assert.equal(project.resolve('vitest'), cli.resolve('vitest'));
console.log('The project and Vite+ share Vitest and Vite+ core');
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,41 @@ steps = [
["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"],
["vpt", "stat-file", "install-requested", "--assert", "missing"],
]

[[case]]
name = "unresolved_lint_config_retains_vitest_peer"
vp = "local"
local-registry = true
unset-env = ["VP_SKIP_INSTALL"]
comment = "A config that still throws after install keeps the upstream Vitest import and its Vite peer. Rerunning migration does not reinstall."
steps = [
{ argv = ["vpt", "json-edit", "package.json", "devDependencies.vitest", "5.1.1"], snapshot = false },
{ argv = ["vpt", "write-file", "vite.config.ts", "export default () => { throw new Error('missing project setting'); };\n"], snapshot = false },
{ argv = ["vpt", "write-file", ".pnpmfile.cjs", "require('node:fs').writeFileSync(require('node:path').join(__dirname, 'install-requested'), 'install');\nmodule.exports = {};\n"], snapshot = false },
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], snapshot = false },
["vpt", "print-file", "package.json"],
["vpt", "print-file", "unit.test.ts"],
["node", "check-vite-peer.mjs"],
{ argv = ["vpt", "cp", "pnpm-lock.yaml", "lockfile.before"], snapshot = false },
["vpt", "stat-file", "install-requested", "--assert", "file"],
{ argv = ["vpt", "rm", "install-requested"], snapshot = false },
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], snapshot = false },
["vpt", "stat-file", "install-requested", "--assert", "missing"],
["node", "-e", "const fs = require('node:fs'); require('node:assert/strict').deepEqual(fs.readFileSync('pnpm-lock.yaml'), fs.readFileSync('lockfile.before'));"],
]

[[case]]
name = "unresolved_lint_config_skip_install"
vp = "local"
local-registry = true
env = { VP_SKIP_INSTALL = "1" }
comment = "Skipping dependency installation still supplies the retained Vitest peer for a later pnpm install."
steps = [
{ argv = ["vpt", "json-edit", "package.json", "devDependencies.vitest", "5.1.1"], snapshot = false },
{ argv = ["vpt", "write-file", "vite.config.ts", "export default () => { throw new Error('missing project setting'); };\n"], snapshot = false },
{ argv = ["vp", "migrate", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], snapshot = false },
["vpt", "stat-file", "node_modules", "--assert", "missing"],
["vpt", "print-file", "package.json"],
{ argv = ["pnpm", "install", "--no-frozen-lockfile", "--ignore-scripts"], snapshot = false },
["node", "check-vite-peer.mjs"],
]
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ test("template", () => {});
"private": true,
"type": "module",
"devDependencies": {
"vite": "catalog:",
"vitest": "catalog:"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# unresolved_lint_config_retains_vitest_peer

A config that still throws after install keeps the upstream Vitest import and its Vite peer. Rerunning migration does not reinstall.

## `vpt json-edit package.json devDependencies.vitest 5.1.1`


## `vpt write-file vite.config.ts 'export default () => { throw new Error('\''missing project setting'\''); };
'`


## `vpt write-file .pnpmfile.cjs 'require('\''node:fs'\'').writeFileSync(require('\''node:path'\'').join(__dirname, '\''install-requested'\''), '\''install'\'');
module.exports = {};
'`


## `vp migrate --no-interactive --no-hooks --no-agent --no-editor`


## `vpt print-file package.json`

```
{
"devDependencies": {
"lint-policy": "file:./lint-policy",
"vite": "catalog:",
"vite-plus": "catalog:",
"vitest": "catalog:"
},
"name": "migration-import-rule-install",
"packageManager": "pnpm@12.11.2",
"private": true,
"scripts": {
"build": "vp build"
},
"type": "module"
}
```

## `vpt print-file unit.test.ts`

```
import { test } from 'vitest';
test('application', () => {});
```

## `node check-vite-peer.mjs`

```
The project and Vite+ share Vitest and Vite+ core
```

## `vpt cp pnpm-lock.yaml lockfile.before`


## `vpt stat-file install-requested --assert file`

```
install-requested: file
```

## `vpt rm install-requested`


## `vp migrate --no-interactive --no-hooks --no-agent --no-editor`


## `vpt stat-file install-requested --assert missing`

```
install-requested: missing
```

## `node -e 'const fs = require('\''node:fs'\''); require('\''node:assert/strict'\'').deepEqual(fs.readFileSync('\''pnpm-lock.yaml'\''), fs.readFileSync('\''lockfile.before'\''));'`

```
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# unresolved_lint_config_skip_install

Skipping dependency installation still supplies the retained Vitest peer for a later pnpm install.

## `vpt json-edit package.json devDependencies.vitest 5.1.1`


## `vpt write-file vite.config.ts 'export default () => { throw new Error('\''missing project setting'\''); };
'`


## `vp migrate --no-interactive --no-hooks --no-agent --no-editor`


## `vpt stat-file node_modules --assert missing`

```
node_modules: missing
```

## `vpt print-file package.json`

```
{
"devDependencies": {
"lint-policy": "file:./lint-policy",
"vite": "catalog:",
"vite-plus": "catalog:",
"vitest": "catalog:"
},
"name": "migration-import-rule-install",
"packageManager": "pnpm@12.11.2",
"private": true,
"scripts": {
"build": "vp build"
},
"type": "module"
}
```

## `pnpm install --no-frozen-lockfile --ignore-scripts`


## `node check-vite-peer.mjs`

```
The project and Vite+ share Vitest and Vite+ core
```
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { test } from 'vitest';
test('starter', () => {});
{
"devDependencies": {
"vite": "catalog:",
"vitest": "catalog:",
"vite-plus": "catalog:"
},
Expand All @@ -73,6 +74,7 @@ export { page };
"devDependencies": {
"@vitest/browser": "catalog:",
"@vitest/browser-preview": "catalog:",
"vite": "catalog:",
"vitest": "catalog:",
"vite-plus": "catalog:"
},
Expand All @@ -93,6 +95,7 @@ import 'vite-plus/test/browser-preview';
export { page };
{
"devDependencies": {
"vite": "catalog:",
"vitest": "catalog:",
"vite-plus": "catalog:"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test('starter', () => {});
"private": true,
"type": "module",
"devDependencies": {
"vite": "catalog:",
"vitest": "catalog:",
"vite-plus": "catalog:"
}
Expand Down Expand Up @@ -102,6 +103,7 @@ This project is already using Vite+! Happy coding!
"private": true,
"type": "module",
"devDependencies": {
"vite": "catalog:",
"vitest": "catalog:",
"vite-plus": "catalog:"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ vitest pinned at the root even though vite-plus is injected first
"prepare": "vp config"
},
"devDependencies": {
"vite": "catalog:",
"vitest-browser-svelte": "^2.1.0",
"vite-plus": "catalog:",
"vitest": "catalog:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@ for (const directory of ['.', 'packages/utils', 'packages/app']) {
const manifest = project('./package.json');
const cliPath = project.resolve('vite-plus/package.json');
const cli = createRequire(cliPath);
const vitestPath = cli.resolve('vitest/package.json');
const vitestPath = cli.resolve('vitest');
const vitest = createRequire(vitestPath);
const vitePath = cli.resolve('vite/package.json');

// #1932: Vitest must not bind to an auto-installed upstream Vite, or to a
// separate core instance, when its consumer has no direct Vite dependency.
assert.equal(vitest.resolve('vite/package.json'), vitePath);
assert.equal(cli('vite/package.json').name, '@voidzero-dev/vite-plus-core');
if (directory === 'packages/app') {
assert.ok(manifest.devDependencies.vite, 'preserve the existing Vite dependency');
const usesVitestUi = manifest.devDependencies['@vitest/ui'] !== undefined;
if (usesVitestUi) {
assert.ok(manifest.devDependencies.vitest);
assert.equal(project.resolve('vitest'), vitestPath);
}
if (directory === 'packages/utils' && usesVitestUi) {
assert.equal(manifest.peerDependencies.vite, '^7');
assert.equal(manifest.devDependencies.vite, undefined);
assert.equal(project.resolve('vite/package.json'), vitePath);
} else if (directory === 'packages/app' || usesVitestUi) {
assert.ok(manifest.devDependencies.vite);
assert.equal(project.resolve('vite/package.json'), vitePath);
} else {
assert.equal(manifest.devDependencies.vite, undefined, `${directory} needs no direct Vite`);
Expand All @@ -28,5 +37,4 @@ for (const directory of ['.', 'packages/utils', 'packages/app']) {
for (const [name, paths] of Object.entries(instances)) {
assert.equal(paths.size, 1, `${name} must have one instance across the workspace`);
}
console.log('Root and utils have no direct Vite; app keeps its declared Vite');
console.log('All packages share one Vite+, bundled Vite, and Vitest instance');
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
name = "pnpm_peer_identity_and_test_cache"
vp = "global"
local-registry = true
comment = "Regression for #1932: a root and utility package without direct Vite must share the app's core and Vitest instances, and test tasks must cache."
comment = "The root's direct Vitest and the utility package's bundled Vitest must share the app's core and runner, and test tasks must cache."
steps = [
{ argv = ["vpt", "json-edit", "package.json", "devDependencies.@vitest/ui", "5.1.1"], snapshot = false },
{ argv = ["vp", "migrate", "--full", "--no-interactive", "--no-hooks", "--no-agent", "--no-editor"], snapshot = false },
{ argv = ["vp", "install", "--ignore-scripts"], snapshot = false },
["node", "check-identity.mjs"],
Expand All @@ -17,14 +18,34 @@ vp = "global"
# Dependency installation is slow on Linux CI.
skip-platforms = ["linux"]
local-registry = true
comment = "The existing-Vite+ upgrade path must also preserve dependency identity and caching without injecting Vite, including on pnpm 10."
comment = "The pnpm 10 upgrade preserves the utility package's public Vite peer range and runs its direct Vitest with the same core and runner as Vite+."
steps = [
{ argv = ["vpt", "json-edit", "package.json", "packageManager", "pnpm@10.33.0"], snapshot = false },
{ argv = ["vpt", "json-edit", "packages/utils/package.json", "peerDependencies.vite", "^7"], snapshot = false },
{ argv = ["vpt", "json-edit", "packages/utils/package.json", "devDependencies.@vitest/ui", "5.1.1"], snapshot = false },
{ argv = ["vp", "migrate", "--no-interactive"], snapshot = false },
{ argv = ["vp", "install", "--ignore-scripts"], snapshot = false },
["node", "check-identity.mjs"],
{ argv = ["vp", "run", "test"], cwd = "packages/utils", comment = "First run populates the test cache." },
{ argv = ["vp", "run", "test"], cwd = "packages/utils", comment = "Second run must hit the cache." },
{ argv = ["vp", "migrate", "--no-interactive"], snapshot = false },
{ argv = ["node", "check-identity.mjs"], comment = "Repeated migration must not inject Vite either." },
{ argv = ["node", "check-identity.mjs"], comment = "Repeated migration preserves the public peer range and the installed runner identity." },
]

[[case]]
name = "pnpm_optional_vite_peer_without_auto_install"
vp = "global"
local-registry = true
comment = "A workspace member with an optional public Vite peer resolves the same Vite and Vitest as Vite+ with automatic peer installation disabled."
steps = [
{ argv = ["vpt", "json-edit", "package.json", "packageManager", "pnpm@10.33.0"], snapshot = false },
{ argv = ["vpt", "replace-file-content", "pnpm-workspace.yaml", "autoInstallPeers: true", "autoInstallPeers: false\nresolvePeersFromWorkspaceRoot: false"], snapshot = false },
{ argv = ["vpt", "json-edit", "packages/utils/package.json", "peerDependencies.vite", "^7"], snapshot = false },
{ argv = ["vpt", "json-edit", "packages/utils/package.json", "peerDependenciesMeta.vite.optional", "true"], snapshot = false },
{ argv = ["vpt", "json-edit", "packages/utils/package.json", "devDependencies.@vitest/ui", "5.1.1"], snapshot = false },
{ argv = ["vp", "migrate", "--no-interactive"], snapshot = false },
{ argv = ["vp", "install", "--ignore-scripts"], snapshot = false },
["vpt", "grep-file", "pnpm-lock.yaml", "autoInstallPeers: false"],
["vpt", "print-file", "packages/utils/package.json"],
["node", "check-identity.mjs"],
]
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# pnpm10_upgrade_peer_identity_and_test_cache

The existing-Vite+ upgrade path must also preserve dependency identity and caching without injecting Vite, including on pnpm 10.
The pnpm 10 upgrade preserves the utility package's public Vite peer range and runs its direct Vitest with the same core and runner as Vite+.

## `vpt json-edit package.json packageManager pnpm@10.33.0`


## `vpt json-edit packages/utils/package.json peerDependencies.vite ^7`


## `vpt json-edit packages/utils/package.json devDependencies.@vitest/ui 5.1.1`


## `vp migrate --no-interactive`


Expand All @@ -14,7 +20,6 @@ The existing-Vite+ upgrade path must also preserve dependency identity and cachi
## `node check-identity.mjs`

```
Root and utils have no direct Vite; app keeps its declared Vite
All packages share one Vite+, bundled Vite, and Vitest instance
```

Expand Down Expand Up @@ -64,9 +69,8 @@ vp run: cache hit, <duration> saved.

## `node check-identity.mjs`

Repeated migration must not inject Vite either.
Repeated migration preserves the public peer range and the installed runner identity.

```
Root and utils have no direct Vite; app keeps its declared Vite
All packages share one Vite+, bundled Vite, and Vitest instance
```
Loading