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
6 changes: 0 additions & 6 deletions .github/scripts/__tests__/upgrade-deps-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,3 @@ test('selects the highest stable version from the supported major', () => {
test('returns undefined when the supported major has no stable release', () => {
expect(findLatestStableVersionForMajor(['4.2.0-beta.1', '5.0.0'], 4)).toBeUndefined();
});

test('keeps Vitest upgrades on v5 after the migration', () => {
expect(
findLatestStableVersionForMajor(['4.1.11', '5.0.0', '5.1.0', '5.2.0-beta.1', '6.0.0'], 5),
).toBe('5.1.0');
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ steps = [
{ argv = ["vpt", "print-file", "package.json"], continue-on-failure = true },
{ argv = ["vp", "up", "testnpm2", "--latest"], comment = "should update to absolute latest version" },
{ argv = ["vpt", "print-file", "package.json"], continue-on-failure = true },
{ argv = ["vpt", "json-edit", "package.json", "packageManager", "bun@1.3.14"], snapshot = false },
{ argv = ["vp", "update", "--prod"], comment = "Reject production dependency selection before Bun 1.4.", continue-on-failure = true },
{ argv = ["vp", "update", "--no-optional"], comment = "Reject optional dependency exclusion before Bun 1.4.", continue-on-failure = true },
{ argv = ["vp", "update", "--recursive"], comment = "Reject recursive updates before Bun 1.4.", continue-on-failure = true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ installed testnpm2@1.0.1
}
```

## `vpt json-edit package.json packageManager bun@1.3.14`


## `vp update --prod`

Reject production dependency selection before Bun 1.4.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "core-module-identity",
"private": true,
"type": "module",
"packageManager": "bun@1.4.2",
"packageManager": "bun@1.4.0",
"devDependencies": {
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
"vite-plus": "latest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ vp = "local"
local-registry = true
unset-env = ["VP_SKIP_INSTALL", "CI"]
steps = [
{ argv = ["vpt", "json-edit", "package.json", "packageManager", "bun@1.4.3"], snapshot = false },
{ argv = ["vpt", "json-edit", "package.json", "packageManager", "bun@1.4.0"], snapshot = false },
{ argv = ["vp", "create", "vite:generator", "--no-interactive", "--directory", "tools/my-generator", "--no-agent", "--no-editor"], snapshot = false, timeout = 120000 },
{ argv = ["vpt", "print-file", "tools/my-generator/package.json"] },
{ argv = ["vp", "install"], snapshot = false, timeout = 120000 },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# create_generator_bun_no_catalog

## `vpt json-edit package.json packageManager bun@1.4.3`
## `vpt json-edit package.json packageManager bun@1.4.0`


## `vp create vite:generator --no-interactive --directory tools/my-generator --no-agent --no-editor`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"vite": "^8.0.16",
"vitest": "^4.1.8"
},
"packageManager": "bun@1.3.14"
"packageManager": "bun@1.3.11"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"vite": "^8.0.16",
"vitest": "^4.1.8"
},
"packageManager": "bun@1.3.14"
"packageManager": "bun@1.3.11"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"vite": "^8.0.16",
"vitest": "^4.1.8"
},
"packageManager": "bun@1.3.14"
"packageManager": "bun@1.3.11"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "pm-pkg-bun",
"version": "1.0.0",
"packageManager": "bun@1.2.19"
"packageManager": "bun@1.3.11"
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
```
{
"name": "pm-pkg-bun",
"packageManager": "bun@1.2.19",
"packageManager": "bun@1.3.11",
"private": true,
"scripts": {},
"version": "1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
```
{
"name": "pm-pkg-bun",
"packageManager": "bun@1.2.19",
"packageManager": "bun@1.3.11",
"private": true,
"scripts": {},
"version": "1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"version": "1.0.0",
"private": true,
"license": "MIT",
"packageManager": "bun@1.3.14"
"packageManager": "bun@1.3.11"
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ verify the rejected command did not update the version
"version": "1.0.2-beta.0",
"private": true,
"license": "MIT",
"packageManager": "bun@1.3.14"
"packageManager": "bun@1.3.11"
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
name = "shim_versions_are_independent"
vp = "global"
skip-platforms = ["windows"]
env = { VP_PACKAGE_MANAGER = "pnpm@10.19.0", VP_NPM_VERSION = "10.9.4", VP_PNPM_VERSION = "10.20.0", VP_YARN_VERSION = "1.22.22", VP_BUN_VERSION = "1.2.0", npm_config_manage_package_manager_versions = "false" }
env = { VP_PACKAGE_MANAGER = "pnpm@10.19.0", VP_NPM_VERSION = "10.9.4", VP_PNPM_VERSION = "10.20.0", VP_YARN_VERSION = "1.22.22", VP_BUN_VERSION = "1.3.11", npm_config_manage_package_manager_versions = "false" }
steps = [
["node", "check.cjs", "npm", "10.9.4"],
["node", "check.cjs", "npx", "10.9.4"],
["node", "check.cjs", "pnpm", "10.20.0"],
["node", "check.cjs", "yarn", "1.22.22"],
["node", "check.cjs", "yarnpkg", "1.22.22"],
["node", "check.cjs", "bun", "1.2.0"],
["node", "check.cjs", "bun", "1.3.11"],
{ argv = ["node", "check.cjs", "vp", "10.19.0"], comment = "Shim overrides do not override vp install's selected version" },
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ yarn uses the expected version
yarnpkg uses the expected version
```

## `node check.cjs bun 1.2.0`
## `node check.cjs bun 1.3.11`

```
bun uses the expected version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ local-registry = true
skip-platforms = ["windows"]
steps = [
{ argv = ["vp", "env", "default", "pnpm@10.18.0"], snapshot = false },
{ argv = ["vp", "env", "default", "bun@1.2.0"], snapshot = false },
{ argv = ["vp", "env", "default", "bun@1.3.11"], snapshot = false },
{ argv = ["vpt", "print-file", "$VP_HOME/config.json"], comment = "pnpm and Bun defaults are persisted independently" },
{ argv = ["node", "-e", "const {execFileSync}=require('node:child_process');const pnpm=execFileSync('pnpm',['--version'],{encoding:'utf8'}).trim();const bun=execFileSync('bun',['--version'],{encoding:'utf8'}).trim();if(pnpm!=='10.18.0'||bun!=='1.2.0')throw new Error(`expected pnpm 10.18.0 and bun 1.2.0, got pnpm ${pnpm} and bun ${bun}`);console.log('direct shims use independent defaults')"], comment = "direct package-manager shims use their own configured versions" },
{ argv = ["node", "-e", "const {execFileSync}=require('node:child_process');const pnpm=execFileSync('pnpm',['--version'],{encoding:'utf8'}).trim();const bun=execFileSync('bun',['--version'],{encoding:'utf8'}).trim();if(pnpm!=='10.18.0'||bun!=='1.3.11')throw new Error(`expected pnpm 10.18.0 and bun 1.3.11, got pnpm ${pnpm} and bun ${bun}`);console.log('direct shims use independent defaults')"], comment = "direct package-manager shims use their own configured versions" },
]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Package-manager defaults are per family so changing Bun cannot silently replace
## `vp env default pnpm@10.18.0`


## `vp env default bun@1.2.0`
## `vp env default bun@1.3.11`


## `vpt print-file $VP_HOME/config.json`
Expand All @@ -15,7 +15,7 @@ pnpm and Bun defaults are persisted independently
```
{
"defaultPackageManagerVersions": {
"bun": "1.2.0",
"bun": "1.3.11",
"pnpm": "10.18.0"
},
"packageManagerShimModes": {
Expand All @@ -27,7 +27,7 @@ pnpm and Bun defaults are persisted independently
}
```

## `node -e 'const {execFileSync}=require('\''node:child_process'\'');const pnpm=execFileSync('\''pnpm'\'',['\''--version'\''],{encoding:'\''utf8'\''}).trim();const bun=execFileSync('\''bun'\'',['\''--version'\''],{encoding:'\''utf8'\''}).trim();if(pnpm'\!'=='\''10.18.0'\''||bun'\!'=='\''1.2.0'\'')throw new Error(`expected pnpm 10.18.0 and bun 1.2.0, got pnpm ${pnpm} and bun ${bun}`);console.log('\''direct shims use independent defaults'\'')'`
## `node -e 'const {execFileSync}=require('\''node:child_process'\'');const pnpm=execFileSync('\''pnpm'\'',['\''--version'\''],{encoding:'\''utf8'\''}).trim();const bun=execFileSync('\''bun'\'',['\''--version'\''],{encoding:'\''utf8'\''}).trim();if(pnpm'\!'=='\''10.18.0'\''||bun'\!'=='\''1.3.11'\'')throw new Error(`expected pnpm 10.18.0 and bun 1.3.11, got pnpm ${pnpm} and bun ${bun}`);console.log('\''direct shims use independent defaults'\'')'`

direct package-manager shims use their own configured versions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"devEngines": {
"packageManager": {
"name": "bun",
"version": "1.3.14",
"version": "1.3.11",
"onFail": "download"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Boundary coverage with Vite+'s real managed Bun distribution. The narrow #2317
fix does not emulate Bun's lifecycle environment, so both values stay undefined.
"""
steps = [
{ argv = ["vpt", "json-edit", "package.json", "packageManager", "bun@1.3.14"], snapshot = false },
{ argv = ["vpt", "json-edit", "package.json", "packageManager", "bun@1.3.11"], snapshot = false },
{ argv = ["bun", "--version"], comment = "Execute the pinned Bun binary", timeout = 120000 },
{ argv = ["vp", "run", "check-env"] },
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
Boundary coverage with Vite+'s real managed Bun distribution. The narrow #2317
fix does not emulate Bun's lifecycle environment, so both values stay undefined.

## `vpt json-edit package.json packageManager bun@1.3.14`
## `vpt json-edit package.json packageManager bun@1.3.11`


## `bun --version`

Execute the pinned Bun binary

```
1.3.14
1.3.11
```

## `vp run check-env`
Expand Down
10 changes: 10 additions & 0 deletions crates/vp_shared/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ fn build_with(
if !follow_redirects {
builder = builder.redirect(reqwest::redirect::Policy::none());
}
// Each `#[tokio::test]` runs on its own runtime, but this client is shared by
// the whole test binary. An idle connection belongs to the runtime that opened
// it, and httpmock reuses server ports across tests, so another test can send
// on it just as that runtime shuts down. The request then fails with "runtime
// dropped the dispatch task" after the server has counted it, and the retry
// counts it again.
#[cfg(feature = "test-utils")]
{
builder = builder.pool_max_idle_per_host(0);
}
builder.build()
}

Expand Down
96 changes: 49 additions & 47 deletions packages/cli/src/__tests__/define-config-plugins.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';

Expand Down Expand Up @@ -47,6 +47,8 @@ describe('defineConfig project plugin injection', () => {
expect(pluginName(result.plugins[2])).toBe(COVERAGE_GUARD_PLUGIN_NAME);
expect(pluginName(result.plugins[3])).toBe(CACHE_PATHS_PLUGIN_NAME);
expect(pluginName(result.plugins[4])).toBe('user-existing-root-plugin');
expect((result.plugins[0] as Plugin).enforce).toBe('pre');
expect((result.plugins[1] as Plugin).enforce).toBe('pre');
});

it('injects resolver + auto-inline plugins into an inline-object project entry, preserving existing plugins', () => {
Expand Down Expand Up @@ -275,19 +277,6 @@ describe('computeAutoInlineList', () => {
});
});

describe('defineConfig auto-inline deps plugin registration', () => {
it('registers the auto-inline plugin in the root plugins array with enforce:pre and configResolved', () => {
const result = defineConfig({}) as { plugins: unknown[] };
const plugin = result.plugins.find(
(p): p is Record<string, unknown> =>
!!p && typeof p === 'object' && (p as { name?: unknown }).name === AUTO_INLINE_PLUGIN_NAME,
);
expect(plugin).toBeDefined();
expect(plugin?.enforce).toBe('pre');
expect(typeof plugin?.configResolved).toBe('function');
});
});

/**
* Build injectable deps for {@link checkCoverageProviderVersion}: only the
* packages in `installed` resolve, and reading their package.json returns the
Expand Down Expand Up @@ -432,16 +421,6 @@ describe('defineConfig vitest cache paths plugin', () => {
taskClientMocks.ignoreOutput.mockClear();
});

it('registers the cache-paths plugin with a configureVitest hook', () => {
const result = defineConfig({}) as { plugins: unknown[] };
const plugin = result.plugins.find(
(p): p is Record<string, unknown> =>
!!p && typeof p === 'object' && (p as { name?: unknown }).name === CACHE_PATHS_PLUGIN_NAME,
);
expect(plugin).toBeDefined();
expect(typeof plugin?.configureVitest).toBe('function');
});

it('ignores the results cache dir, the default fs module cache, and per-project overrides', () => {
// Anchor searchForWorkspaceRoot at a known directory: a package.json
// without workspace markers makes the probe root itself the workspace root.
Expand Down Expand Up @@ -596,31 +575,54 @@ function getCoverageGuard(): { configureVitest: (ctx: unknown) => void } {
return plugin;
}

describe('defineConfig coverage version guard plugin registration', () => {
it('registers the coverage guard plugin with a configureVitest hook', () => {
const result = defineConfig({}) as { plugins: unknown[] };
const plugin = result.plugins.find(
(p): p is Record<string, unknown> =>
!!p &&
typeof p === 'object' &&
(p as { name?: unknown }).name === COVERAGE_GUARD_PLUGIN_NAME,
);
expect(plugin).toBeDefined();
expect(typeof plugin?.configureVitest).toBe('function');
});
/** Creates a project root whose installed `@vitest/coverage-v8` is skewed from the bundled runner. */
function makeSkewedCoverageRoot(): string {
const root = mkdtempSync(join(tmpdir(), 'vp-coverage-skew-'));
const providerDir = join(root, 'node_modules/@vitest/coverage-v8');
mkdirSync(providerDir, { recursive: true });
writeFileSync(join(root, 'package.json'), '{"name":"probe","private":true}\n');
writeFileSync(
join(providerDir, 'package.json'),
'{"name":"@vitest/coverage-v8","version":"4.1.8"}\n',
);
return root;
}

describe('defineConfig coverage version guard plugin', () => {
it('configureVitest is a no-op when the runner coverage is off (startup path)', () => {
const guard = getCoverageGuard();
// The hook short-circuits before any resolution when coverage is disabled,
// so a non-existent root is fine.
expect(() =>
guard.configureVitest({
vitest: {
config: { root: '/project', coverage: { enabled: false } },
enableCoverage: async () => {},
},
}),
).not.toThrow();
const root = makeSkewedCoverageRoot();
try {
const guard = getCoverageGuard();
// The installed provider is skewed, so only the disabled-coverage check keeps this from throwing.
expect(() =>
guard.configureVitest({
vitest: {
config: { root, coverage: { enabled: false } },
enableCoverage: async () => {},
},
}),
).not.toThrow();
} finally {
rmSync(root, { recursive: true, force: true });
}
});

it('rejects a skewed provider on the late enableCoverage path without delegating', async () => {
const root = makeSkewedCoverageRoot();
try {
const guard = getCoverageGuard();
const original = vi.fn(async () => {});
const vitest = {
config: { root, coverage: { enabled: false, provider: 'v8' } },
enableCoverage: original,
};
// Coverage is off at startup, so only the wrapped `enableCoverage` can catch the skew.
guard.configureVitest({ vitest });
await expect(vitest.enableCoverage()).rejects.toThrow(/@vitest\/coverage-v8@4\.1\.8/);
expect(original).not.toHaveBeenCalled();
} finally {
rmSync(root, { recursive: true, force: true });
}
});

it('wraps the shared vitest.enableCoverage so the late path runs the check, and still delegates', async () => {
Expand Down
22 changes: 2 additions & 20 deletions packages/cli/src/__tests__/define-config-test-field.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { describe, expect, it } from 'vitest';
import { describe, it } from 'vitest';

import {
configDefaults,
coverageConfigDefaults,
defineConfig,
loadConfigFromFile,
mergeConfig,
} from '../index.js';
import { defineConfig } from '../index.js';

describe('defineConfig test field typing', () => {
it('accepts test config without TS error', () => {
Expand All @@ -30,16 +24,4 @@ describe('defineConfig test field typing', () => {
});
void cfg;
});

it('re-exports shared and vitest-specific names without star-export conflicts', () => {
expect(typeof defineConfig).toBe('function');
expect(typeof mergeConfig).toBe('function');
expect(typeof loadConfigFromFile).toBe('function');
expect(typeof configDefaults).toBe('object');
expect(typeof coverageConfigDefaults).toBe('object');

const merged = mergeConfig({ test: { globals: true } }, { test: { environment: 'node' } });
expect(merged.test.globals).toBe(true);
expect(merged.test.environment).toBe('node');
});
});
Loading
Loading