Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ Configuration
✓ Package manager system-first mode
PATH
✓ vp in PATH
✓ vp ~/.vite-plus/bin/vp
✓ Shim dir ~/.vite-plus/bin
✓ pnpm ~/.vite-plus/bin/pnpm (vp shim)
✓ pnpx ~/.vite-plus/bin/pnpx (vp shim)
Package Manager Resolution
Source system PATH
Version pnpm@10.18.0
Source system PATH
Version pnpm@10.18.0
✓ PM binary <workspace>/system-bin/pnpm
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'node:fs';
import path from 'node:path';

const expected = path.resolve('external/vp');
const expected = path.resolve('external/bin/vp');
const shims = [
'vp',
'node',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
name = "command_env_setup_external_vp"
vp = "global"
skip-platforms = ["windows"]
env = { VP_NODE_MANAGER = "yes", VP_SELF_SETUP_NO_MODIFY_PATH = "1" }
steps = [
{ argv = ["vpt", "mkdir", "-p", "external", "home"], comment = "Prepare isolated external install and VP_HOME", snapshot = false },
{ argv = ["vpt", "cp", "$VP_HOME/bin/vp", "external/vp"], comment = "Simulate a Homebrew-style vp outside VP_HOME", snapshot = false },
{ argv = ["vpt", "chmod", "+x", "external/vp"], snapshot = false },
{ argv = ["vpt", "touch-file", "external/.vp-setup-complete"], comment = "The external package manager has already set up this binary", snapshot = false },
{ argv = ["vpt", "mkdir", "-p", "external/bin", "home"], comment = "Prepare isolated external install and VP_HOME", snapshot = false },
{ argv = ["vpt", "cp", "$VP_HOME/bin/vp", "external/bin/vp"], comment = "Simulate a Homebrew-style vp outside VP_HOME", snapshot = false },
{ argv = ["vpt", "chmod", "+x", "external/bin/vp"], snapshot = false },
{ argv = ["vpt", "write-file", "external/node_modules/vite-plus/package.json", "{}"], snapshot = false },
{ argv = ["vpt", "write-file", "external/node_modules/vite-plus/dist/bin.js", "// Bundled CLI"], snapshot = false },
{ argv = ["vpt", "write-file", ".node-version", "22.18.0\n"], comment = "Project Node.js version", snapshot = false },
{ argv = ["vpt", "write-file", "home/js_runtime/node/22.18.0/bin/node", "#!/bin/sh\necho vp-managed-node-22.18.0\n"], comment = "Preinstall managed Node runtime", snapshot = false },
{ argv = ["vpt", "chmod", "+x", "home/js_runtime/node/22.18.0/bin/node"], snapshot = false },
{ argv = ["./external/vp", "env", "setup"], envs = [["VP_HOME", "${workspace}/home"]], comment = "Setup shims from external vp", snapshot = false },
{ argv = ["./external/bin/vp", "env", "setup"], envs = [["VP_HOME", "${workspace}/home"]], comment = "Setup shims from external vp without a package-manager-owned marker", snapshot = false },
# The legacy step set VP_BYPASS to reach a system node, which the hermetic
# case PATH does not have; the node shim resolving the pinned 22.18.0 from
# the seeded runtime serves the same purpose (any node can run the asserts).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# command_env_setup_external_vp

## `vpt mkdir -p external home`
## `vpt mkdir -p external/bin home`

Prepare isolated external install and VP_HOME


## `vpt cp $VP_HOME/bin/vp external/vp`
## `vpt cp $VP_HOME/bin/vp external/bin/vp`

Simulate a Homebrew-style vp outside VP_HOME


## `vpt chmod +x external/vp`
## `vpt chmod +x external/bin/vp`


## `vpt touch-file external/.vp-setup-complete`
## `vpt write-file external/node_modules/vite-plus/package.json {}`

The external package manager has already set up this binary

## `vpt write-file external/node_modules/vite-plus/dist/bin.js '// Bundled CLI'`


## `vpt write-file .node-version '22.18.0
Expand All @@ -34,9 +35,9 @@ Preinstall managed Node runtime
## `vpt chmod +x home/js_runtime/node/22.18.0/bin/node`


## `VP_HOME=${workspace}/home ./external/vp env setup`
## `VP_HOME=${workspace}/home ./external/bin/vp env setup`

Setup shims from external vp
Setup shims from external vp without a package-manager-owned marker


## `node assert-shims.mjs`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
[[case]]
name = "command_self_setup_external_bundled"
vp = "global"
skip-platforms = ["windows"]
env = { VP_SELF_SETUP_NO_MODIFY_PATH = "1", NPM_CONFIG_REGISTRY = "http://127.0.0.1:9" }
steps = [
{ argv = ["vpt", "mkdir", "-p", "external/bin", "system/bin", "home"], snapshot = false },
{ argv = ["vpt", "cp", "$VP_HOME/bin/vp", "external/bin/vp"], snapshot = false },
{ argv = ["vpt", "cp", "$VP_HOME/js_runtime/node/22.18.0/bin/node", "system/bin/node"], snapshot = false },
{ argv = ["vpt", "chmod", "+x", "system/bin/node"], snapshot = false },
{ argv = ["vpt", "write-file", "external/node_modules/vite-plus/package.json", '{"name":"vite-plus","version":"0.3.2"}'], snapshot = false },
{ argv = ["vpt", "write-file", "external/node_modules/vite-plus/dist/bin.js", "console.log('external bundled CLI: ' + process.argv.slice(2).join(' '));"], snapshot = false },
{ argv = ["vpt", "chmod", "555", "external/bin/vp"], snapshot = false },
{ argv = ["vpt", "chmod", "555", "external/bin"], snapshot = false },
{ argv = ["vpt", "chmod", "555", "external"], snapshot = false },
{ argv = ["./external/bin/vp", "--help"], envs = [["VP_HOME", "${workspace}/home"], ["VP_NODE_MANAGER", "no"], ["VP_PM_MANAGER", "no"]], comment = "A read-only package prefix needs neither a marker nor registry access", snapshot = false },
["vpt", "stat-file", "external/bin/.vp-setup-complete", "--assert", "missing"],
["vpt", "stat-file", "home/current", "--assert", "missing"],
["vpt", "stat-file", "home/self-setup", "--assert", "dir"],
{ argv = ["./external/bin/vp", "sync-versions", "--json"], envs = [["VP_HOME", "${workspace}/home"], ["PATH", "${workspace}/system/bin${PATH_SEPARATOR}${PATH}"]], comment = "A later command uses the package manager's bundled JavaScript without another setup prompt" },
{ argv = ["./external/bin/vp", "env", "off"], envs = [["VP_HOME", "${workspace}/home"]], snapshot = false },
{ argv = ["./external/bin/vp", "--help"], envs = [["VP_HOME", "${workspace}/home"], ["VP_NODE_MANAGER", "yes"]], comment = "Later invocations preserve the user's saved management choices", snapshot = false },
["vpt", "print-file", "home/config.json"],
{ argv = ["./home/bin/vp", "--help"], envs = [["VP_HOME", "${workspace}/home"]], comment = "The user shim also recognizes the external installation", snapshot = false },
["vpt", "stat-file", "home/bin/vp", "--assert", "symlink"],
]
after = [
["vpt", "chmod", "755", "external"],
["vpt", "chmod", "755", "external/bin"],
]

[[case]]
name = "command_self_setup_external_replacement"
vp = "global"
skip-platforms = ["windows"]
requires = ["bash"]
steps = [["node", "verify-refresh.mjs", "replacement"]]

[[case]]
name = "command_self_setup_external_preferences"
vp = "global"
skip-platforms = ["windows"]
steps = [["node", "verify-refresh.mjs", "preferences"]]

[[case]]
name = "command_self_setup_external_doctor"
vp = "global"
skip-platforms = ["windows"]
steps = [["node", "verify-refresh.mjs", "doctor"]]

[[case]]
name = "command_self_setup_external_bare"
vp = "global"
skip-platforms = ["windows"]
env = { VP_SKIP_DEPS_INSTALL = "1", VP_VERSION = "external-test", VP_SELF_SETUP_NO_MODIFY_PATH = "1" }
steps = [
{ argv = ["vpt", "mkdir", "-p", "external", "home/external-test/bin"], snapshot = false },
{ argv = ["vpt", "cp", "$VP_HOME/bin/vp", "external/vp"], snapshot = false },
{ argv = ["vpt", "chmod", "555", "external/vp"], snapshot = false },
{ argv = ["vpt", "cp", "external/vp", "home/external-test/bin/vp"], snapshot = false },
{ argv = ["vpt", "chmod", "555", "home/external-test/bin/vp"], comment = "An interrupted bootstrap left a read-only binary before activation", snapshot = false },
{ argv = ["./external/vp", "--help"], tty = false, envs = [["VP_HOME", "${workspace}/home"], ["VP_NODE_MANAGER", "no"]], comment = "Retry replaces the incomplete copy and finishes setup", snapshot = false },
["vpt", "stat-file", "home/current/bin/.vp-setup-complete", "--assert", "file"],
["vpt", "stat-file", "external/.vp-setup-complete", "--assert", "missing"],
{ argv = ["./external/vp", "env", "off"], envs = [["VP_HOME", "${workspace}/home"]], comment = "The external binary reuses its completed installation" },
{ argv = ["./external/vp", "--help"], envs = [["VP_HOME", "${workspace}/home"], ["VP_NODE_MANAGER", "yes"]], snapshot = false },
["vpt", "stat-file", "home/.previous-version", "--assert", "missing"],
["vpt", "print-file", "home/config.json"],
{ argv = ["./external/vp"], tty = false, envs = [["VP_HOME", "${workspace}/home"], ["VP_NODE_MANAGER", "no"], ["VP_SELF_SETUP_SHELL", "sh"]], comment = "An explicit installer handoff still reinstalls the same version", snapshot = false },
["vpt", "print-file", "home/.previous-version"],
["vpt", "stat-file", "home/current/bin/.vp-setup-complete", "--assert", "file"],
]

[[case]]
name = "command_self_setup_external_homebrew"
vp = "global"
skip-platforms = ["windows"]
unset-env = ["VP_CLI_TEST", "VP_NO_UPDATE_CHECK", "CI"]
env = { VP_SELF_SETUP_NO_MODIFY_PATH = "1", NPM_CONFIG_REGISTRY = "http://127.0.0.1:9" }
steps = [
{ argv = ["vpt", "mkdir", "-p", "brew-prefix/bin", "home"], snapshot = false },
{ argv = ["vpt", "cp", "$VP_HOME/bin/vp", "brew-prefix/bin/vp"], snapshot = false },
{ argv = ["vpt", "write-file", "brew-prefix/INSTALL_RECEIPT.json", '{"homebrew_version":"7.0.2","source":{"tap":"fengmk2/core"}}'], snapshot = false },
{ argv = ["vpt", "write-file", "brew-prefix/node_modules/vite-plus/package.json", '{"name":"vite-plus"}'], snapshot = false },
{ argv = ["vpt", "write-file", "brew-prefix/node_modules/vite-plus/dist/bin.js", "console.log('bundled CLI');"], snapshot = false },
{ argv = ["./brew-prefix/bin/vp", "--help"], envs = [["VP_HOME", "${workspace}/home"], ["VP_NODE_MANAGER", "no"], ["VP_PM_MANAGER", "no"]], snapshot = false },
{ argv = ["./home/bin/vp", "upgrade"], envs = [["VP_HOME", "${workspace}/home"]], continue-on-failure = true },
{ argv = ["./home/bin/vp", "upgrade", "--force"], envs = [["VP_HOME", "${workspace}/home"]], continue-on-failure = true },
{ argv = ["./home/bin/vp", "upgrade", "0.0.1", "--registry", "http://127.0.0.1:9"], envs = [["VP_HOME", "${workspace}/home"]], continue-on-failure = true },
{ argv = ["./home/bin/vp", "upgrade", "--rollback"], envs = [["VP_HOME", "${workspace}/home"]], continue-on-failure = true },
{ argv = ["./home/bin/vp", "upgrade", "--silent"], envs = [["VP_HOME", "${workspace}/home"]], continue-on-failure = true },
{ argv = ["./home/bin/vp", "upgrade", "--check"], envs = [["VP_HOME", "${workspace}/home"]] },
{ argv = ["./home/bin/vp", "upgrade", "--check", "--silent"], envs = [["VP_HOME", "${workspace}/home"]] },
{ argv = ["./home/bin/vp", "upgrade", "--background-check"], envs = [["VP_HOME", "${workspace}/home"]] },
{ argv = ["./home/bin/vp", "env", "off"], envs = [["VP_HOME", "${workspace}/home"]] },
["vpt", "stat-file", "home/current", "--assert", "missing"],
["vpt", "stat-file", "home/cache/upgrade-check.json", "--assert", "missing"],
["vpt", "stat-file", "brew-prefix/bin/.vp-setup-complete", "--assert", "missing"],
{ argv = ["./home/bin/vp", "implode", "--yes"], envs = [["VP_HOME", "${workspace}/home"]], comment = "Cleanup removes user data and leaves the Homebrew package installed" },
["vpt", "stat-file", "home", "--assert", "missing"],
["vpt", "stat-file", "brew-prefix/bin/vp", "--assert", "file"],
["vpt", "stat-file", "brew-prefix/INSTALL_RECEIPT.json", "--assert", "file"],
["vpt", "stat-file", "brew-prefix/node_modules/vite-plus/dist/bin.js", "--assert", "file"],
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# command_self_setup_external_bare

## `vpt mkdir -p external home/external-test/bin`


## `vpt cp $VP_HOME/bin/vp external/vp`


## `vpt chmod 555 external/vp`


## `vpt cp external/vp home/external-test/bin/vp`


## `vpt chmod 555 home/external-test/bin/vp`

An interrupted bootstrap left a read-only binary before activation


## `VP_HOME=${workspace}/home VP_NODE_MANAGER=no ./external/vp --help`

Retry replaces the incomplete copy and finishes setup


## `vpt stat-file home/current/bin/.vp-setup-complete --assert file`

```
home/current/bin/.vp-setup-complete: file
```

## `vpt stat-file external/.vp-setup-complete --assert missing`

```
external/.vp-setup-complete: missing
```

## `VP_HOME=${workspace}/home ./external/vp env off`

The external binary reuses its completed installation

```
VITE+ - The Unified Toolchain for the Web

✓ Node.js and package-manager management set to system-first.

Selected commands and shims will now prefer system tools, falling back to managed tools.

Run `vp env on` to always use Vite+ managed tools.
```

## `VP_HOME=${workspace}/home VP_NODE_MANAGER=yes ./external/vp --help`


## `vpt stat-file home/.previous-version --assert missing`

```
home/.previous-version: missing
```

## `vpt print-file home/config.json`

```
{
"nodeShimMode": "system_first",
"packageManagerShimModes": {
"bun": "system_first",
"npm": "system_first",
"pnpm": "system_first",
"yarn": "system_first"
}
}
```

## `VP_HOME=${workspace}/home VP_NODE_MANAGER=no VP_SELF_SETUP_SHELL=sh ./external/vp`

An explicit installer handoff still reinstalls the same version


## `vpt print-file home/.previous-version`

```
external-test
```

## `vpt stat-file home/current/bin/.vp-setup-complete --assert file`

```
home/current/bin/.vp-setup-complete: file
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# command_self_setup_external_bundled

## `vpt mkdir -p external/bin system/bin home`


## `vpt cp $VP_HOME/bin/vp external/bin/vp`


## `vpt cp $VP_HOME/js_runtime/node/22.18.0/bin/node system/bin/node`


## `vpt chmod +x system/bin/node`


## `vpt write-file external/node_modules/vite-plus/package.json '{"name":"vite-plus","version":"0.3.2"}'`


## `vpt write-file external/node_modules/vite-plus/dist/bin.js 'console.log('\''external bundled CLI: '\'' + process.argv.slice(2).join('\'' '\''));'`


## `vpt chmod 555 external/bin/vp`


## `vpt chmod 555 external/bin`


## `vpt chmod 555 external`


## `VP_HOME=${workspace}/home VP_NODE_MANAGER=no VP_PM_MANAGER=no ./external/bin/vp --help`

A read-only package prefix needs neither a marker nor registry access


## `vpt stat-file external/bin/.vp-setup-complete --assert missing`

```
external/bin/.vp-setup-complete: missing
```

## `vpt stat-file home/current --assert missing`

```
home/current: missing
```

## `vpt stat-file home/self-setup --assert dir`

```
home/self-setup: dir
```

## `VP_HOME=${workspace}/home PATH=${workspace}/system/bin${PATH_SEPARATOR}${PATH} ./external/bin/vp sync-versions --json`

A later command uses the package manager's bundled JavaScript without another setup prompt

```
external bundled CLI: sync-versions --json
```

## `VP_HOME=${workspace}/home ./external/bin/vp env off`


## `VP_HOME=${workspace}/home VP_NODE_MANAGER=yes ./external/bin/vp --help`

Later invocations preserve the user's saved management choices


## `vpt print-file home/config.json`

```
{
"nodeShimMode": "system_first",
"packageManagerShimModes": {
"bun": "system_first",
"npm": "system_first",
"pnpm": "system_first",
"yarn": "system_first"
}
}
```

## `VP_HOME=${workspace}/home ./home/bin/vp --help`

The user shim also recognizes the external installation


## `vpt stat-file home/bin/vp --assert symlink`

```
home/bin/vp: symlink
```
Loading
Loading