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
Expand Up @@ -7,7 +7,7 @@ Explicit npm family scopes use standalone registry npm; only the directly invoke
an explicit npm scope exports the standalone npm fallback

```
export VP_PACKAGE_MANAGER=npm@12.0.2
export VP_NPM_VERSION=12.0.2
Using npm <version> (resolved from registry fallback)
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ steps = [
{ argv = ["vp", "env", "use", "npm@10.9.4", "--no-install"], snapshot = false },
{ argv = ["vpt", "write-file", "$VP_HOME/package_manager/npm/10.9.4/npm/bin/npm", "#!/bin/sh\n"], snapshot = false },
{ argv = ["vpt", "chmod", "+x", "$VP_HOME/package_manager/npm/10.9.4/npm/bin/npm"], snapshot = false },
{ argv = ["vp", "env", "current", "pm", "--json"], comment = "current reports the package-manager session file path" },
{ argv = ["vp", "env", "current", "npm", "--json"], comment = "current reports the package-manager session file path" },
{ argv = ["vp", "env", "which", "npm"], comment = "which reports the package-manager session file as its source" },
]

Expand All @@ -43,5 +43,5 @@ skip-platforms = ["windows"]
steps = [
{ argv = ["vp", "env", "use", "pnpm@10.18.0", "--no-install"], snapshot = false },
{ argv = ["vp", "env", "use", "--unset", "pnpm"], envs = [["VP_PACKAGE_MANAGER", "yarn@4.12.0"]], snapshot = false },
{ argv = ["vpt", "stat-file", "$VP_HOME/.session-package-manager", "--assert", "missing"], comment = "a different environment override does not hide the matching session file from scoped cleanup" },
{ argv = ["vpt", "stat-file", "$VP_HOME/.session-pnpm-version", "--assert", "missing"], comment = "a different environment override does not hide the matching session file from scoped cleanup" },
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
## `vpt chmod +x $VP_HOME/package_manager/npm/10.9.4/npm/bin/npm`


## `vp env current pm --json`
## `vp env current npm --json`

current reports the package-manager session file path

Expand All @@ -19,8 +19,8 @@ current reports the package-manager session file path
"package_manager": {
"name": "npm",
"version": "<version>",
"source": ".session-package-manager",
"source_path": "<home>/.vite-plus/.session-package-manager",
"source": ".session-npm-version",
"source_path": "<home>/.vite-plus/.session-npm-version",
"bin_paths": {
"npm": "<home>/.vite-plus/package_manager/npm/<version>/npm/bin/npm",
"npx": "<home>/.vite-plus/package_manager/npm/<version>/npm/bin/npx"
Expand All @@ -40,5 +40,5 @@ VITE+ - The Unified Toolchain for the Web

<home>/.vite-plus/package_manager/npm/<version>/npm/bin/npm
Package: npm@10.9.4
Source: <home>/.vite-plus/.session-package-manager
Source: <home>/.vite-plus/.session-npm-version
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Scoped unset must inspect and clear the session file independently of any differ
## `VP_PACKAGE_MANAGER=yarn@4.12.0 vp env use --unset pnpm`


## `vpt stat-file $VP_HOME/.session-package-manager --assert missing`
## `vpt stat-file $VP_HOME/.session-pnpm-version --assert missing`

a different environment override does not hide the matching session file from scoped cleanup

```
<home>/.vite-plus/.session-package-manager: missing
<home>/.vite-plus/.session-pnpm-version: missing
```
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
a different fallback manager does not warn

```
export VP_PACKAGE_MANAGER=yarn@4.12.0
export VP_YARN_VERSION=4.12.0
Using yarn <version> (resolved from 4.12.0)
```
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ an explicit project manager warns before a different session manager is used

```
warn: Current environment resolves to pnpm from packageManager, but yarn was requested.
export VP_PACKAGE_MANAGER=yarn@4.12.0
export VP_YARN_VERSION=4.12.0
Using yarn <version> (resolved from 4.12.0)
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ vp = "global"
seed-runtime = false
steps = [
{ argv = ["vp", "env", "off", "pnpm"], comment = "switch only pnpm to system-first mode" },
{ argv = ["vp", "env", "current", "pnpm", "--json"], envs = [["VP_PACKAGE_MANAGER", "pnpm@10.18.0"], ["VP_BYPASS", "${PATH}"]], comment = "pnpm uses its individual mode" },
{ argv = ["vp", "env", "current", "bun", "--json"], envs = [["VP_PACKAGE_MANAGER", "bun@1.2.3"]], comment = "bun keeps the shared managed mode" },
{ argv = ["vp", "env", "current", "pnpm", "--json"], envs = [["VP_PNPM_VERSION", "10.18.0"], ["VP_BYPASS", "${PATH}"]], comment = "pnpm uses its individual mode" },
{ argv = ["vp", "env", "current", "bun", "--json"], envs = [["VP_BUN_VERSION", "1.2.3"]], comment = "bun keeps the shared managed mode" },
{ argv = ["vp", "env", "on", "pnpm"], comment = "restore only pnpm to managed mode" },
{ argv = ["vp", "env", "current", "pnpm", "--json"], envs = [["VP_PACKAGE_MANAGER", "pnpm@10.18.0"]], comment = "pnpm returns to the shared managed mode" },
{ argv = ["vp", "env", "current", "pnpm", "--json"], envs = [["VP_PNPM_VERSION", "10.18.0"]], comment = "pnpm returns to the shared managed mode" },
]

[[case]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Selected commands and shims will now prefer system tools, falling back to manage
Run `vp env on` to always use Vite+ managed tools.
```

## `VP_PACKAGE_MANAGER=pnpm@10.18.0 VP_BYPASS=${PATH} vp env current pnpm --json`
## `VP_PNPM_VERSION=10.18.0 VP_BYPASS=${PATH} vp env current pnpm --json`

pnpm uses its individual mode

Expand All @@ -23,7 +23,7 @@ pnpm uses its individual mode
"package_manager": {
"name": "pnpm",
"version": "<version>",
"source": "VP_PACKAGE_MANAGER",
"source": "VP_PNPM_VERSION",
"bin_paths": {
"pnpm": "<home>/.vite-plus/package_manager/pnpm/<version>/pnpm/bin/pnpm",
"pnpx": "<home>/.vite-plus/package_manager/pnpm/<version>/pnpm/bin/pnpx"
Expand All @@ -34,7 +34,7 @@ pnpm uses its individual mode
}
```

## `VP_PACKAGE_MANAGER=bun@1.2.3 vp env current bun --json`
## `VP_BUN_VERSION=1.2.3 vp env current bun --json`

bun keeps the shared managed mode

Expand All @@ -43,7 +43,7 @@ bun keeps the shared managed mode
"package_manager": {
"name": "bun",
"version": "<version>",
"source": "VP_PACKAGE_MANAGER",
"source": "VP_BUN_VERSION",
"bin_paths": {
"bun": "<home>/.vite-plus/package_manager/bun/<version>/bun/bin/bun",
"bunx": "<home>/.vite-plus/package_manager/bun/<version>/bun/bin/bunx"
Expand All @@ -68,7 +68,7 @@ Selected commands and shims will now use Vite+ managed tools.
Run `vp env off` to prefer system tools instead.
```

## `VP_PACKAGE_MANAGER=pnpm@10.18.0 vp env current pnpm --json`
## `VP_PNPM_VERSION=10.18.0 vp env current pnpm --json`

pnpm returns to the shared managed mode

Expand All @@ -77,7 +77,7 @@ pnpm returns to the shared managed mode
"package_manager": {
"name": "pnpm",
"version": "<version>",
"source": "VP_PACKAGE_MANAGER",
"source": "VP_PNPM_VERSION",
"bin_paths": {
"pnpm": "<home>/.vite-plus/package_manager/pnpm/<version>/pnpm/bin/pnpm",
"pnpx": "<home>/.vite-plus/package_manager/pnpm/<version>/pnpm/bin/pnpx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ steps = [
{ argv = ["vp", "env", "use", "--unset"], comment = "should output unset command to stdout", continue-on-failure = true },
{ argv = ["vp", "env", "use", "d"], comment = "should show friendly error for invalid version", continue-on-failure = true },
{ argv = ["vp", "env", "use", "abc"], comment = "should show friendly error for invalid version", continue-on-failure = true },
{ argv = ["vp", "env", "use", "--silent-if-unchanged", "--no-install"], comment = "an unchanged project environment emits no shell mutations", envs = [["VP_NODE_VERSION", "20.18.0"], ["VP_PACKAGE_MANAGER", "npm@10.9.4"]] },
{ argv = ["vp", "env", "use", "--silent-if-unchanged", "--no-install"], comment = "an unchanged project environment emits no shell mutations", envs = [["VP_NODE_VERSION", "20.18.0"], ["VP_NPM_VERSION", "10.9.4"]] },
]

[[case]]
Expand All @@ -19,6 +19,6 @@ comment = "The unchanged guard must return before installation so --silent-if-un
seed-runtime = false
steps = [
{ argv = ["vpt", "write-file", "package.json", "{\"name\":\"command-env-use\",\"private\":true,\"packageManager\":\"pnpm@10.18.0\"}\n"], snapshot = false },
{ argv = ["vp", "env", "use", "pm", "--silent-if-unchanged"], envs = [["VP_PACKAGE_MANAGER", "pnpm@10.18.0"]], snapshot = false },
{ argv = ["vp", "env", "use", "pm", "--silent-if-unchanged"], envs = [["VP_PNPM_VERSION", "10.18.0"]], snapshot = false },
{ argv = ["vpt", "stat-file", "$VP_HOME/package_manager/pnpm/10.18.0/pnpm/bin/pnpm", "--assert", "missing"], comment = "silent unchanged mode preserves the legacy no-op behavior" },
]
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ should output unset command to stdout

```
unset VP_NODE_VERSION
unset VP_PACKAGE_MANAGER
unset VP_NPM_VERSION
unset VP_PNPM_VERSION
unset VP_YARN_VERSION
unset VP_BUN_VERSION
Reverted selected components to project environment resolution
```

Expand Down Expand Up @@ -79,7 +82,7 @@ Valid examples:
vp env use latest # Latest version
```

## `VP_NODE_VERSION=20.18.0 VP_PACKAGE_MANAGER=npm@10.9.4 vp env use --silent-if-unchanged --no-install`
## `VP_NODE_VERSION=20.18.0 VP_NPM_VERSION=10.9.4 vp env use --silent-if-unchanged --no-install`

an unchanged project environment emits no shell mutations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The unchanged guard must return before installation so --silent-if-unchanged rem
'`


## `VP_PACKAGE_MANAGER=pnpm@10.18.0 vp env use pm --silent-if-unchanged`
## `VP_PNPM_VERSION=10.18.0 vp env use pm --silent-if-unchanged`


## `vpt stat-file $VP_HOME/package_manager/pnpm/10.18.0/pnpm/bin/pnpm --assert missing`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ steps = [
name = "env_use_clears_stale_package_manager_override"
vp = "global"
skip-platforms = ["windows"]
env = { VP_ENV_USE_EVAL_ENABLE = "1", VP_PACKAGE_MANAGER = "pnpm@10.18.0" }
env = { VP_ENV_USE_EVAL_ENABLE = "1", VP_PNPM_VERSION = "10.18.0", VP_PACKAGE_MANAGER = "yarn@4.12.0" }
steps = [
{ argv = ["vp", "env", "use", "--no-install"], comment = "activating a project with no package-manager selection clears the previous override", envs = [["VP_SHELL", "bash"]] },
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ should detect bash and output both posix exports

```
export VP_NODE_VERSION=20.18.0
export VP_PACKAGE_MANAGER=pnpm@10.18.0
export VP_PNPM_VERSION=10.18.0
Using Node.js <version> (resolved from 20.18.0)
Using pnpm <version> (resolved from 10.18.0)
```
Expand All @@ -17,7 +17,7 @@ should detect zsh and output both posix exports

```
export VP_NODE_VERSION=20.18.0
export VP_PACKAGE_MANAGER=pnpm@10.18.0
export VP_PNPM_VERSION=10.18.0
Using Node.js <version> (resolved from 20.18.0)
Using pnpm <version> (resolved from 10.18.0)
```
Expand All @@ -28,7 +28,7 @@ should detect fish and output both fish exports

```
set -gx VP_NODE_VERSION 20.18.0
set -gx VP_PACKAGE_MANAGER pnpm@10.18.0
set -gx VP_PNPM_VERSION 10.18.0
Using Node.js <version> (resolved from 20.18.0)
Using pnpm <version> (resolved from 10.18.0)
```
Expand All @@ -39,7 +39,7 @@ should detect nushell and output both nushell exports

```
$env.VP_NODE_VERSION = "20.18.0"
$env.VP_PACKAGE_MANAGER = "pnpm@10.18.0"
$env.VP_PNPM_VERSION = "10.18.0"
Using Node.js <version> (resolved from 20.18.0)
Using pnpm <version> (resolved from 10.18.0)
```
Expand All @@ -50,7 +50,7 @@ should detect powershell and output both powershell exports

```
$env:VP_NODE_VERSION = "20.18.0"
$env:VP_PACKAGE_MANAGER = "pnpm@10.18.0"
$env:VP_PNPM_VERSION = "10.18.0"
Using Node.js <version> (resolved from 20.18.0)
Using pnpm <version> (resolved from 10.18.0)
```
Expand All @@ -61,7 +61,7 @@ should detect cmd and output both cmd exports

```
set VP_NODE_VERSION=20.18.0
set VP_PACKAGE_MANAGER=pnpm@10.18.0
set VP_PNPM_VERSION=10.18.0
Using Node.js <version> (resolved from 20.18.0)
Using pnpm <version> (resolved from 10.18.0)
```
Expand All @@ -72,7 +72,7 @@ should detect case-insensitive bash

```
export VP_NODE_VERSION=20.18.0
export VP_PACKAGE_MANAGER=pnpm@10.18.0
export VP_PNPM_VERSION=10.18.0
Using Node.js <version> (resolved from 20.18.0)
Using pnpm <version> (resolved from 10.18.0)
```
Expand All @@ -83,7 +83,7 @@ should detect case-insensitive fish

```
set -gx VP_NODE_VERSION 20.18.0
set -gx VP_PACKAGE_MANAGER pnpm@10.18.0
set -gx VP_PNPM_VERSION 10.18.0
Using Node.js <version> (resolved from 20.18.0)
Using pnpm <version> (resolved from 10.18.0)
```
Expand All @@ -94,7 +94,7 @@ should detect case-insensitive powershell

```
$env:VP_NODE_VERSION = "20.18.0"
$env:VP_PACKAGE_MANAGER = "pnpm@10.18.0"
$env:VP_PNPM_VERSION = "10.18.0"
Using Node.js <version> (resolved from 20.18.0)
Using pnpm <version> (resolved from 10.18.0)
```
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ activating a project with no package-manager selection clears the previous overr

```
export VP_NODE_VERSION=20.18.0
unset VP_PACKAGE_MANAGER
unset VP_NPM_VERSION
unset VP_PNPM_VERSION
unset VP_YARN_VERSION
unset VP_BUN_VERSION
Using Node.js <version> (resolved from .node-version)
```
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,12 @@ steps = [
{ argv = ["vp", "env", "on", "npm"], snapshot = false },
{ argv = ["vp", "env", "exec", "--node", "22.18.0", "node", "assert-unix-shim-path.cjs", "partial", "10.5.0"], comment = "A project npm pin still takes priority over bundled npm after a PATH reset" },
]

[[case]]
name = "explicit_npm_after_partial_path_reset"
vp = "global"
skip-platforms = ["windows"]
env = { VP_NPM_VERSION = "10.9.4" }
steps = [
{ argv = ["vp", "env", "exec", "--node", "22.18.0", "--npm", "10.5.0", "node", "assert-unix-shim-path.cjs", "partial", "10.5.0"], comment = "An explicit npm version overrides the inherited version and survives a PATH reset" },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# explicit_npm_after_partial_path_reset

## `vp env exec --node 22.18.0 --npm 10.5.0 node assert-unix-shim-path.cjs partial 10.5.0`

An explicit npm version overrides the inherited version and survives a PATH reset

```
Node and its tools survive partial PATH
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set -eu
. "$VP_HOME/env"

export VP_PACKAGE_MANAGER=pnpm@10.19.0
vp env use pnpm@10.20.0 --no-install
vp env use yarn@1.22.22 --no-install
test "$VP_PNPM_VERSION" = 10.20.0
test "$VP_YARN_VERSION" = 1.22.22
test "$VP_PACKAGE_MANAGER" = pnpm@10.19.0

vp env use pnpm --unset
test "${VP_PNPM_VERSION-unset}" = unset
test "$VP_YARN_VERSION" = 1.22.22
test "$VP_PACKAGE_MANAGER" = pnpm@10.19.0

vp env use pm --unset
test "${VP_YARN_VERSION-unset}" = unset
test "$VP_PACKAGE_MANAGER" = pnpm@10.19.0
echo 'env use keeps shim versions independent of the selected manager'
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const assert = require('node:assert/strict');
const { execFileSync } = require('node:child_process');
const { delimiter } = require('node:path');

// Start each child at the shim even though the parent Node process has injected tool paths.
const env = {
...process.env,
PATH: [process.env.VP_HOME + '/bin', '/usr/bin', '/bin'].join(delimiter),
VP_PATH_INJECTED_TOOLS: '',
};
const [tool, expected] = process.argv.slice(2);
const args = tool === 'vp' ? ['install', '--', '--version'] : ['--version'];
const actual = execFileSync(tool, args, { env, encoding: 'utf8' }).trim();
assert.equal(actual, expected);
console.log(`${tool} uses the expected version`);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "shim-package-manager-version-overrides",
"private": true,
"packageManager": "pnpm@10.18.0"
}
Loading
Loading