Skip to content

Commit d0cbcb5

Browse files
committed
test: apply cleanup review to the local registry change
- extract the shared pack preflight+invocation into packages/tools/src/pack-local-vite-plus.ts, used by both the snap harness and local-npm-registry.ts --pack (was two hand-synced copies) - localVitePlusPackages fixtures get a 120s default command timeout in the harness instead of a pasted "timeout": 120000 on every wrapped command; steps.json env is optional now and empty env blocks are gone - drop the dead SNAP_CASES_DIR env (its last consumer left with .shared/) - serve packuments without a parse/stringify round trip and read local tarballs asynchronously so large responses do not stall in-flight proxied requests - tool local-npm-registry spawns the script by path instead of importing it under a spliced argv, so tool-launched servers match --ps/--kill - key the ecosystem release-age gate exception on resolutionMode: time-based in the project's workspace yaml instead of the dify project name - derive the expected e2e version from the packed tgz (vitePlusTgzVersion in ecosystem-ci/paths.ts) for both patch-project and verify-install, dropping the unused VP_EXPECTED_VERSION knob and the hardcoded 0.0.0 - document why the registry's upstream resolution deliberately ignores registry env vars
1 parent 858412c commit d0cbcb5

20 files changed

Lines changed: 176 additions & 219 deletions

File tree

.github/workflows/e2e-test.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,13 @@ jobs:
111111
mkdir -p tmp/tgz
112112
# patch-project.ts serves these tgz through a local npm registry
113113
# (packages/tools/src/local-npm-registry.ts), so `vp migrate` pins
114-
# and installs them like a real release. Pin both packages to 0.0.0
115-
# so a correctly installed local build is always distinguishable
116-
# from any published version (verify-install.ts asserts it), even on
117-
# a release commit that leaves packages/{core,cli} at a published
118-
# version. The bun-only vite alias tgz that the old file:-override
119-
# flow needed (bun peer-dep strictness, oven-sh/bun#8406) is gone:
120-
# through the registry, bun installs the standard
121-
# `vite -> npm:@voidzero-dev/vite-plus-core@<version>` alias.
114+
# and installs them like a real release, with every package manager
115+
# (including bun) resolving the standard
116+
# `vite -> npm:@voidzero-dev/vite-plus-core@<version>` alias. Pin
117+
# both packages to 0.0.0 so a correctly installed local build is
118+
# always distinguishable from any published version
119+
# (verify-install.ts asserts it), even on a release commit that
120+
# leaves packages/{core,cli} at a published version.
122121
(cd packages/core && npm pkg set version=0.0.0)
123122
(cd packages/cli && npm pkg set version=0.0.0)
124123
cd packages/core && pnpm pack --pack-destination ../../tmp/tgz && cd ../..

ecosystem-ci/patch-project.ts

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { execSync, spawn } from 'node:child_process';
2-
import { readdirSync } from 'node:fs';
2+
import { existsSync, readFileSync } from 'node:fs';
33
import { appendFile, readFile, writeFile } from 'node:fs/promises';
44
import { join } from 'node:path';
55

66
import { VITEST_VERSION } from '../packages/cli/src/utils/constants.ts';
7-
import { ecosystemCiDir, tgzDir } from './paths.ts';
7+
import { ecosystemCiDir, tgzDir, vitePlusTgzVersion } from './paths.ts';
88
import repos from './repo.json' with { type: 'json' };
99

1010
const projects = Object.keys(repos);
@@ -26,15 +26,7 @@ const cli = process.env.VP_CLI_BIN ?? 'vp';
2626
// The packed local build in tmp/tgz is served through a local npm registry
2727
// (local-npm-registry.ts), so vp migrate pins and installs the checkout's
2828
// own version through the standard registry code paths, with no `file:` specs.
29-
// The e2e build job pins packages/cli to 0.0.0 before `pnpm pack`; a local
30-
// run can serve whatever version the checkout carries.
31-
const vitePlusVersion = readdirSync(tgzDir)
32-
.map((entry) => /^vite-plus-(\d.*)\.tgz$/.exec(entry)?.[1])
33-
.find(Boolean);
34-
if (!vitePlusVersion) {
35-
console.error(`No vite-plus-<version>.tgz found in ${tgzDir}`);
36-
process.exit(1);
37-
}
29+
const vitePlusVersion = vitePlusTgzVersion();
3830

3931
const registryScript = join(
4032
import.meta.dirname,
@@ -166,20 +158,23 @@ const vitestOverrides = {
166158
// publish does not fail with ERR_PNPM_NO_MATURE_MATCHING_VERSION. pnpm >= 10.6
167159
// only reads the PNPM_CONFIG_* spelling; older pnpm reads the lowercase form.
168160
//
169-
// dify is the exception: it sets `resolutionMode: time-based`, and defining a
170-
// minimumReleaseAge (even 0, via any env spelling) activates pnpm's
171-
// resolution-policy engine, which vp's bundled pnpm cannot handle
172-
// (ERR_PNPM_RESOLUTION_POLICY_VIOLATIONS_UNHANDLED, no
173-
// handleResolutionPolicyViolations callback). Its `minimumReleaseAge:` key
174-
// was already removed above, so with no gate env the policy stays inactive
175-
// and installs work.
176-
const releaseAgeEnv =
177-
project === 'dify'
178-
? {}
179-
: {
180-
pnpm_config_minimum_release_age: '0',
181-
PNPM_CONFIG_MINIMUM_RELEASE_AGE: '0',
182-
};
161+
// Projects with `resolutionMode: time-based` (currently dify) are the
162+
// exception: defining a minimumReleaseAge (even 0, via any env spelling)
163+
// activates pnpm's resolution-policy engine there, which vp's bundled pnpm
164+
// cannot handle (ERR_PNPM_RESOLUTION_POLICY_VIOLATIONS_UNHANDLED, no
165+
// handleResolutionPolicyViolations callback wired). Their `minimumReleaseAge:`
166+
// key is stripped by the per-project patches above, so with no gate env the
167+
// policy stays inactive and installs work.
168+
const workspaceYamlPath = join(repoRoot, 'pnpm-workspace.yaml');
169+
const timeBasedResolution =
170+
existsSync(workspaceYamlPath) &&
171+
/^resolutionMode:\s*time-based/m.test(readFileSync(workspaceYamlPath, 'utf-8'));
172+
const releaseAgeEnv = timeBasedResolution
173+
? {}
174+
: {
175+
pnpm_config_minimum_release_age: '0',
176+
PNPM_CONFIG_MINIMUM_RELEASE_AGE: '0',
177+
};
183178

184179
const migrateEnv: NodeJS.ProcessEnv = {
185180
...process.env,

ecosystem-ci/paths.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { readdirSync } from 'node:fs';
12
import { tmpdir } from 'node:os';
23
import { dirname, join } from 'node:path';
34
import { fileURLToPath } from 'node:url';
@@ -11,3 +12,19 @@ export const ecosystemCiDir = join(tempBase, 'vite-plus-ecosystem-ci');
1112

1213
// tgz path: always use local tmp/tgz
1314
export const tgzDir = join(projectDir, '..', 'tmp', 'tgz');
15+
16+
/**
17+
* The version of the packed vite-plus tgz that the local registry serves and
18+
* that `vp migrate` pins: 0.0.0 on CI (the e2e pack step pins it so a local
19+
* build is always distinguishable from a published version), the checkout
20+
* version on a local run.
21+
*/
22+
export function vitePlusTgzVersion(): string {
23+
const version = readdirSync(tgzDir)
24+
.map((entry) => /^vite-plus-(\d.*)\.tgz$/.exec(entry)?.[1])
25+
.find(Boolean);
26+
if (!version) {
27+
throw new Error(`No vite-plus-<version>.tgz found in ${tgzDir}`);
28+
}
29+
return version;
30+
}

ecosystem-ci/verify-install.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import { readFileSync } from 'node:fs';
22
import { createRequire } from 'node:module';
33
import path from 'node:path';
44

5+
import { vitePlusTgzVersion } from './paths.ts';
6+
57
const require = createRequire(`${process.cwd()}/`);
68

7-
// The ecosystem-ci pack step pins packages/cli to 0.0.0 before `pnpm pack`,
8-
// and patch-project.ts serves that build through the local registry, so a
9-
// correctly installed local build always reports 0.0.0, never a published
10-
// registry version. A local (non-CI) run serves whatever version the checkout
11-
// carries; pass it via VP_EXPECTED_VERSION.
12-
const expectedVersion = process.env.VP_EXPECTED_VERSION ?? '0.0.0';
9+
// patch-project.ts serves the packed tgz through the local registry, so a
10+
// correctly installed local build always reports the tgz version (0.0.0 on
11+
// CI, where the pack step pins it precisely so a local build is never
12+
// mistaken for a published registry version).
13+
const expectedVersion = vitePlusTgzVersion();
1314

1415
try {
1516
const pkgPath = require.resolve('vite-plus/package.json');

packages/cli/snap-tests-global/create-framework-shim-astro/steps.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
{
22
"ignoredPlatforms": ["win32"],
33
"localVitePlusPackages": true,
4-
"env": {},
54
"commands": [
65
{
76
"command": "node $SNAP_LOCAL_REGISTRY -- vp create astro --no-interactive -- my-astro-app --yes --skip-houston --template basics # create Astro app",
8-
"ignoreOutput": true,
9-
"timeout": 120000
7+
"ignoreOutput": true
108
},
119
"cat my-astro-app/src/env.d.ts # check Astro shim",
1210
{
1311
"command": "cd my-astro-app && node $SNAP_LOCAL_REGISTRY -- vp install --ignore-scripts -- --no-frozen-lockfile # install dependencies",
14-
"ignoreOutput": true,
15-
"timeout": 120000
12+
"ignoreOutput": true
1613
},
1714
{
1815
"command": "cd my-astro-app && sed -i.bak -e '/jsPlugins/d' -e '/rules:/d' -e '/options:/d' vite.config.ts && vp check --fix # fix generated formatting and ensure no errors"

packages/cli/snap-tests-global/create-framework-shim-vue/steps.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
{
2-
"ignoredPlatforms": ["win32", { "os": "linux", "libc": "musl" }],
2+
"ignoredPlatforms": [
3+
"win32",
4+
{
5+
"os": "linux",
6+
"libc": "musl"
7+
}
8+
],
39
"linkCheckoutPackages": true,
410
"localVitePlusPackages": true,
5-
"env": {},
611
"commands": [
712
{
813
"command": "node $SNAP_LOCAL_REGISTRY -- vp create vite:application --no-interactive -- --template vue-ts # create Vue+TS app",
9-
"ignoreOutput": true,
10-
"timeout": 120000
14+
"ignoreOutput": true
1115
},
1216
"cat vite-plus-application/src/env.d.ts # check Vue shim was added",
1317
{
1418
"command": "cd vite-plus-application && node $SNAP_LOCAL_REGISTRY -- vp install # install dependencies",
15-
"ignoreOutput": true,
16-
"timeout": 120000
19+
"ignoreOutput": true
1720
},
1821
"cd vite-plus-application && vp check --fix # fix generated formatting and ensure no errors"
1922
]

packages/cli/snap-tests-global/migration-framework-shim-astro-vue/steps.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
"VP_SKIP_INSTALL": ""
88
},
99
"commands": [
10-
{
11-
"command": "node $SNAP_LOCAL_REGISTRY -- vp migrate --no-interactive --no-hooks # migration should add both Vue and Astro shims",
12-
"timeout": 120000
13-
},
10+
"node $SNAP_LOCAL_REGISTRY -- vp migrate --no-interactive --no-hooks # migration should add both Vue and Astro shims",
1411
"cat src/env.d.ts # check both shims were written"
1512
]
1613
}

packages/cli/snap-tests-global/migration-framework-shim-astro/steps.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
"VP_SKIP_INSTALL": ""
88
},
99
"commands": [
10-
{
11-
"command": "node $SNAP_LOCAL_REGISTRY -- vp migrate --no-interactive --no-hooks # migration should add Astro shim when astro dependency is detected",
12-
"timeout": 120000
13-
},
10+
"node $SNAP_LOCAL_REGISTRY -- vp migrate --no-interactive --no-hooks # migration should add Astro shim when astro dependency is detected",
1411
"cat src/env.d.ts # check Astro shim was written"
1512
]
1613
}

packages/cli/snap-tests-global/migration-framework-shim-vue/steps.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
"VP_SKIP_INSTALL": ""
88
},
99
"commands": [
10-
{
11-
"command": "node $SNAP_LOCAL_REGISTRY -- vp migrate --no-interactive --no-hooks # migration should add Vue shim when vue dependency is detected",
12-
"timeout": 120000
13-
},
10+
"node $SNAP_LOCAL_REGISTRY -- vp migrate --no-interactive --no-hooks # migration should add Vue shim when vue dependency is detected",
1411
"cat src/env.d.ts # check Vue shim was written"
1512
]
1613
}

packages/cli/snap-tests-global/migration-standalone-npm/steps.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
"VP_SKIP_INSTALL": ""
88
},
99
"commands": [
10-
{
11-
"command": "node $SNAP_LOCAL_REGISTRY -- vp migrate --no-interactive --no-hooks # migration should work with npm, add overrides, and update lockfile",
12-
"timeout": 120000
13-
},
10+
"node $SNAP_LOCAL_REGISTRY -- vp migrate --no-interactive --no-hooks # migration should work with npm, add overrides, and update lockfile",
1411
"cat package.json # check package.json has overrides field (not pnpm.overrides)",
1512
"node -e \"const lock = require('./package-lock.json'); const vite = lock.packages['node_modules/vite']; if (vite && (vite.name === '@voidzero-dev/vite-plus-core' || vite.resolved?.includes('/@voidzero-dev/vite-plus-core/'))) console.log('lockfile has vite override'); else { console.error('vite override not found in lockfile'); process.exit(1); }\" # verify lockfile updated with override"
1613
]

0 commit comments

Comments
 (0)