Skip to content

Commit b695f3c

Browse files
committed
fix(migration): re-pin vite-plus in force-override mode, fix lint/format/typo
PR #1588 CI failures: - Force-override mode (VP_FORCE_MIGRATE=1, set by test-vp-create.yml and ecosystem-ci) now re-pins any pre-existing vite-plus range to the local tgz path in monorepo workspace packages. Without this, pnpm reads the published vite-plus@0.1.21 metadata to resolve transitive deps including @voidzero-dev/vite-plus-test@0.1.21, which shadowed upstream vitest@4.1.5 at runtime and broke vp create monorepo tests. - typos CI: rename yarn-PnP to yarn Plug'n'Play (Pn→On false positive). - vp check: format packages/cli/build.ts shim-generation block. - Rename __dirname in install-failure-guard.spec.ts to satisfy eslint(no-underscore-dangle).
1 parent d4ba570 commit b695f3c

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

packages/cli/build.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,10 @@ async function syncTestPackageExports() {
367367
// ./test/browser/providers/<short> → e.g. ./test/browser/providers/playwright
368368
const pkgShortName = pkg.startsWith('@vitest/') ? pkg.slice('@vitest/'.length) : pkg;
369369
const surfaces = [
370-
{ cliPath: `./test/${pkgShortName}${providerSubPath}`, baseName: `${pkgShortName}${providerSubPath}` },
370+
{
371+
cliPath: `./test/${pkgShortName}${providerSubPath}`,
372+
baseName: `${pkgShortName}${providerSubPath}`,
373+
},
371374
{
372375
cliPath: `./test/browser/providers/${short}${providerSubPath}`,
373376
baseName: `browser/providers/${short}${providerSubPath}`,

packages/cli/src/migration/__tests__/install-failure-guard.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { fileURLToPath } from 'node:url';
44

55
import { describe, expect, it } from 'vitest';
66

7-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
8-
const binPath = path.resolve(__dirname, '..', 'bin.ts');
7+
const here = path.dirname(fileURLToPath(import.meta.url));
8+
const binPath = path.resolve(here, '..', 'bin.ts');
99

1010
/**
1111
* `runViteInstall` returns `{ status: 'failed', exitCode }` (it does not throw)

packages/cli/src/migration/migrator.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ function isLegacyWrapperSpec(value: string | undefined): boolean {
125125
* is dropped entirely. Returns true iff any entry was changed.
126126
*/
127127
function pruneLegacyWrapperAliases(record: Record<string, string> | undefined): boolean {
128-
if (!record) return false;
128+
if (!record) {
129+
return false;
130+
}
129131
let mutated = false;
130132
for (const key of Object.keys(record)) {
131133
if (isLegacyWrapperSpec(record[key])) {
@@ -1477,7 +1479,9 @@ function getYamlMapScalarStringValue(map: unknown, key: string): string | undefi
14771479
}
14781480

14791481
function pruneYamlMapLegacyWrapperAliases(map: unknown): void {
1480-
if (!(map instanceof YAMLMap)) return;
1482+
if (!(map instanceof YAMLMap)) {
1483+
return;
1484+
}
14811485
const stale: Array<{ key: Scalar<string>; fallback: string | undefined }> = [];
14821486
for (const item of map.items) {
14831487
const value = item.value instanceof Scalar ? item.value.value : undefined;
@@ -1835,6 +1839,19 @@ export function rewritePackageJson(
18351839
}
18361840
}
18371841
}
1842+
// Force-override mode (ecosystem CI / `vp create` E2E) must re-pin any
1843+
// pre-existing `vite-plus` range to the local tgz. Otherwise pnpm reads the
1844+
// published vite-plus metadata for transitive dep resolution (e.g.
1845+
// `@voidzero-dev/vite-plus-test`) even though the override replaces the
1846+
// vite-plus package itself, dragging the stale wrapper into node_modules.
1847+
if (isForceOverrideMode()) {
1848+
for (const { dependencies } of dependencyGroups) {
1849+
if (dependencies?.[VITE_PLUS_NAME]) {
1850+
dependencies[VITE_PLUS_NAME] = VITE_PLUS_VERSION;
1851+
needVitePlus = true;
1852+
}
1853+
}
1854+
}
18381855
// remove packages that are replaced with vite-plus
18391856
for (const name of REMOVE_PACKAGES) {
18401857
let wasRemoved = false;
@@ -1889,7 +1906,7 @@ export function rewritePackageJson(
18891906
// Add vitest to devDependencies when a remaining dependency likely
18901907
// peer-depends on vitest (e.g., vitest-browser-svelte). Vite-plus already
18911908
// bundles upstream vitest 4.1.5 as a direct dep, so the runtime resolution
1892-
// works without this — but strict pnpm / yarn-PnP refuse to expose a
1909+
// works without this — but strict pnpm / yarn Plug'n'Play refuse to expose a
18931910
// transitive `vitest` to satisfy a peer dep declared by a different
18941911
// direct dep. Adding `vitest` to the user's devDependencies pins the
18951912
// peer-dep target to the same upstream version vite-plus ships with.

0 commit comments

Comments
 (0)