Skip to content

Commit 2e1cde5

Browse files
authored
fix: preserve package-manager management when opting out of Node.js (#147)
`node-manager: false` currently runs unscoped `vp env off`, which also disables package-manager management in Vite+ 0.3.1+. Passing `VP_NODE_MANAGER=no` to the refactored installer has the same side effect. Configure Node.js after installation with `vp env off node` on Vite+ 0.3.1+, falling back to `vp env off` on older versions. Stop injecting `VP_NODE_MANAGER` in GitHub, GitLab, and Azure. `true` and unset now leave the installer default unchanged instead of force-enabling management. 🤖 Generated with Codex
1 parent 7ca28af commit 2e1cde5

19 files changed

Lines changed: 237 additions & 158 deletions

‎.github/workflows/test.yml‎

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,10 @@ jobs:
165165
exit 1
166166
fi
167167
168-
# End-to-end check of node-manager: false. The installer must skip
169-
# node/npm/npx/corepack shim creation (VP_NODE_MANAGER=no) and the action
170-
# must run `vp env off`, so vp commands resolve the Node.js already on the
171-
# runner instead of a managed one. Records the preinstalled Node.js binary,
172-
# runs a real `vp install`, then asserts the binary is unchanged, no shims
173-
# exist, and `vp exec` resolves the system Node.js. $VP_HOME/js_runtime is
174-
# NOT asserted empty: the installer always downloads a managed Node LTS
175-
# there to install vp's own production deps with a deterministic runtime
176-
# (vite_setup install_production_deps), independent of VP_NODE_MANAGER.
168+
# End-to-end check of node-manager: false. Node.js management is disabled
169+
# while package-manager management keeps the installer defaults. Shims may
170+
# remain on PATH, so compare process.execPath to verify that both `node`
171+
# and `vp exec node` execute the runner's original Node.js after installation.
177172
test-node-manager-off:
178173
strategy:
179174
fail-fast: false
@@ -187,8 +182,8 @@ jobs:
187182
id: before
188183
shell: bash
189184
run: |
190-
echo "path=$(command -v node)" >> "$GITHUB_OUTPUT"
191-
echo "version=$(node --version)" >> "$GITHUB_OUTPUT"
185+
echo "path=$(node -p 'process.execPath' | tr -d '\r')" >> "$GITHUB_OUTPUT"
186+
echo "version=$(node --version | tr -d '\r')" >> "$GITHUB_OUTPUT"
192187
193188
- name: Create test project
194189
shell: bash
@@ -211,8 +206,8 @@ jobs:
211206
- name: Verify system Node.js is untouched
212207
shell: bash
213208
run: |
214-
ACTUAL_PATH=$(command -v node)
215-
ACTUAL_VERSION=$(node --version)
209+
ACTUAL_PATH=$(node -p 'process.execPath' | tr -d '\r')
210+
ACTUAL_VERSION=$(node --version | tr -d '\r')
216211
echo "node before: ${{ steps.before.outputs.path }} (${{ steps.before.outputs.version }})"
217212
echo "node after: $ACTUAL_PATH ($ACTUAL_VERSION)"
218213
if [ "$ACTUAL_PATH" != "${{ steps.before.outputs.path }}" ]; then
@@ -224,20 +219,17 @@ jobs:
224219
exit 1
225220
fi
226221
227-
- name: Verify no Node.js shims were created
228-
shell: bash
229-
run: |
230-
SHIMS=$(ls "$HOME/.vite-plus/bin" | grep -E '^(node|npm|npx|corepack)' || true)
231-
if [ -n "$SHIMS" ]; then
232-
echo "::error::unexpected Node.js shims in $HOME/.vite-plus/bin: $SHIMS"
233-
exit 1
234-
fi
235-
236222
- name: Verify vp commands use the system Node.js
237223
shell: bash
238224
run: |
225+
EXEC_PATH=$(vp exec node -p 'process.execPath' | tr -d '\r')
239226
EXEC_VERSION=$(vp exec node --version | tr -d '\r')
227+
echo "vp exec node -p process.execPath: $EXEC_PATH"
240228
echo "vp exec node --version: $EXEC_VERSION"
229+
if [ "$EXEC_PATH" != "${{ steps.before.outputs.path }}" ]; then
230+
echo "::error::vp resolved Node.js at $EXEC_PATH; expected system ${{ steps.before.outputs.path }}"
231+
exit 1
232+
fi
241233
if [ "$EXEC_VERSION" != "${{ steps.before.outputs.version }}" ]; then
242234
echo "::error::vp resolved Node.js $EXEC_VERSION; expected system ${{ steps.before.outputs.version }}"
243235
exit 1

‎README.md‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -341,29 +341,29 @@ jobs:
341341

342342
## Inputs
343343

344-
| Input | Description | Required | Default |
345-
| ----------------------- | ----------------------------------------------------------------------------------------------------------- | -------- | ---------------- |
346-
| `version` | Version of Vite+ to install. Takes precedence over `version-file` | No | auto / `latest` |
347-
| `version-file` | Path to a file to resolve the Vite+ version from (`package.json`, `pnpm-workspace.yaml`, or `.yarnrc.yml`) | No | |
348-
| `node-version` | Node.js version to install via `vp env use` | No | Vite+ resolution |
349-
| `node-version-file` | Path to file containing Node.js version (`.nvmrc`, `.node-version`, `.tool-versions`, `package.json`) | No | |
350-
| `node-manager` | Control Vite+'s Node.js manager: `false` keeps the runner's Node.js, `true` force-enables the managed one | No | Auto (on for CI) |
351-
| `working-directory` | Project directory used for relative paths, lockfile auto-detection, environment checks, and default install | No | Workspace root |
352-
| `run-install` | Run `vp install` after setup. Accepts boolean or YAML object with `cwd`/`args` | No | `true` |
353-
| `sfw` | Wrap `vp install` with [Socket Firewall Free](https://docs.socket.dev/docs/socket-firewall-free) (`sfw`) | No | `false` |
354-
| `cache` | Enable caching of project dependencies | No | `false` |
355-
| `cache-save` | Save the dependency cache in the post action. Has no effect when `cache` is `false` | No | `true` |
356-
| `cache-dependency-path` | Path to lock file for cache key generation | No | Auto-detected |
357-
| `registry-url` | Optional registry to set up for auth. Sets the registry in `.npmrc` and reads auth from `NODE_AUTH_TOKEN` | No | |
358-
| `scope` | Optional scope for scoped registries. Falls back to repo owner for GitHub Packages | No | |
344+
| Input | Description | Required | Default |
345+
| ----------------------- | ------------------------------------------------------------------------------------------------------------------ | -------- | ---------------- |
346+
| `version` | Version of Vite+ to install. Takes precedence over `version-file` | No | auto / `latest` |
347+
| `version-file` | Path to a file to resolve the Vite+ version from (`package.json`, `pnpm-workspace.yaml`, or `.yarnrc.yml`) | No | |
348+
| `node-version` | Node.js version to install via `vp env use` | No | Vite+ resolution |
349+
| `node-version-file` | Path to file containing Node.js version (`.nvmrc`, `.node-version`, `.tool-versions`, `package.json`) | No | |
350+
| `node-manager` | Control Vite+'s Node.js manager: `false` keeps the runner's Node.js, `true` leaves the installer default unchanged | No | Auto (on for CI) |
351+
| `working-directory` | Project directory used for relative paths, lockfile auto-detection, environment checks, and default install | No | Workspace root |
352+
| `run-install` | Run `vp install` after setup. Accepts boolean or YAML object with `cwd`/`args` | No | `true` |
353+
| `sfw` | Wrap `vp install` with [Socket Firewall Free](https://docs.socket.dev/docs/socket-firewall-free) (`sfw`) | No | `false` |
354+
| `cache` | Enable caching of project dependencies | No | `false` |
355+
| `cache-save` | Save the dependency cache in the post action. Has no effect when `cache` is `false` | No | `true` |
356+
| `cache-dependency-path` | Path to lock file for cache key generation | No | Auto-detected |
357+
| `registry-url` | Optional registry to set up for auth. Sets the registry in `.npmrc` and reads auth from `NODE_AUTH_TOKEN` | No | |
358+
| `scope` | Optional scope for scoped registries. Falls back to repo owner for GitHub Packages | No | |
359359

360360
When `working-directory` is set, relative `run-install.cwd`, `node-version-file`, `version-file`, and `cache-dependency-path` values are resolved from that directory.
361361

362362
Omitting both `node-version` and `node-version-file` leaves the session without an override. With the Vite+ Node.js manager enabled, its shims search the current directory and its parents for `.node-version`, `package.json#devEngines.runtime`, `package.json#engines.node`, and `.nvmrc`, in that order. If the project does not declare a version, Vite+ uses the user-level default. Set this default with `vp env default <version>`. If no user-level default exists, Vite+ uses the latest LTS release.
363363

364364
`working-directory` applies to the action. Each later workflow step keeps its own working directory. Vite+ searches for Node.js version sources from each command's current working directory. For a subproject, set `working-directory` on the step that runs `node` or `vp`.
365365

366-
`node-manager: false` skips Node.js shim creation and runs `vp env off`, so `vp` commands prefer the Node.js already on `PATH`. It cannot be combined with `node-version` or `node-version-file`.
366+
`node-manager: false` runs `vp env off node` (Vite+ 0.3.1+; `vp env off` on older versions), so `vp` commands prefer the Node.js already on `PATH`. It cannot be combined with `node-version` or `node-version-file`.
367367

368368
## Outputs
369369

@@ -539,16 +539,16 @@ test:
539539

540540
### GitLab Inputs
541541

542-
| Input | Description | Default |
543-
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
544-
| `version` | Version of Vite+ to install | `latest` |
545-
| `working-directory` | Project directory used for relative paths and default `vp install` execution | `.` |
546-
| `run-install` | String input for `vp install` after setup. Use `"true"`/`"false"` or a YAML object/list with `cwd`/`args` | `true` |
547-
| `sfw` | Wrap `vp install` with [Socket Firewall Free](https://docs.socket.dev/docs/socket-firewall-free) | `false` |
548-
| `node-manager` | String input: `"false"` keeps the runner image's Node.js (skips shims and runs `vp env off`); `"true"` force-enables the managed Node.js; empty lets the installer decide (enabled on CI) | |
549-
| `registry-url` | Optional registry URL to write to a temporary `.npmrc` | |
550-
| `scope` | Optional scope for authenticating against scoped registries | |
551-
| `setup-ref` | setup-vp ref used to download the GitLab bootstrap and compiled runtime. Always set it to the same tag as the remote URL; the default is the latest release when the template was published | `v1.19.0` |
542+
| Input | Description | Default |
543+
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
544+
| `version` | Version of Vite+ to install | `latest` |
545+
| `working-directory` | Project directory used for relative paths and default `vp install` execution | `.` |
546+
| `run-install` | String input for `vp install` after setup. Use `"true"`/`"false"` or a YAML object/list with `cwd`/`args` | `true` |
547+
| `sfw` | Wrap `vp install` with [Socket Firewall Free](https://docs.socket.dev/docs/socket-firewall-free) | `false` |
548+
| `node-manager` | String input: `"false"` keeps the runner image's Node.js (disables Node.js management after installation); `"true"` leaves the installer default unchanged; empty lets the installer decide (enabled on CI) | |
549+
| `registry-url` | Optional registry URL to write to a temporary `.npmrc` | |
550+
| `scope` | Optional scope for authenticating against scoped registries | |
551+
| `setup-ref` | setup-vp ref used to download the GitLab bootstrap and compiled runtime. Always set it to the same tag as the remote URL; the default is the latest release when the template was published | `v1.19.0` |
552552

553553
### GitLab Notes
554554

@@ -610,7 +610,7 @@ Pin `ref` and `setupRef` to the same exact tag or commit SHA. Do not use the `v1
610610
| `scope` | | Optional npm registry scope. |
611611
| `setupRef` | `v1.19.0` | Ref used to download bootstrap scripts and `dist/azure/index.mjs`. Always set it to the same tag as `ref`; the default is the latest release when the template was published. |
612612
| `nodeVersion` | `24.x` | Passed to `UseNode@1`; an empty string skips Node setup. |
613-
| `nodeManager` | | Control Vite+'s Node.js manager: `false` keeps the agent's Node.js (e.g. from `UseNode@1`); `true` force-enables the managed one; empty lets the installer decide. |
613+
| `nodeManager` | | Control Vite+'s Node.js manager: `false` keeps the agent's Node.js (e.g. from `UseNode@1`); `true` leaves the installer default unchanged; empty lets the installer decide. |
614614
| `cache` | `false` | Enable Azure `Cache@2` around the package-manager cache directory. |
615615
| `cacheDependencyPath` | | Explicit lock file relative to `workingDirectory`; otherwise auto-detect. |
616616

‎action.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ inputs:
2828
description: "Path to file containing the Node.js version spec (.nvmrc, .node-version, .tool-versions, package.json). Ignored when node-version is specified."
2929
required: false
3030
node-manager:
31-
description: "Control Vite+'s Node.js version manager. When unset, the Vite+ installer decides (enabled on CI). Set to `false` to keep the Node.js already on the runner (e.g. from actions/setup-node or the runner image): shim creation is skipped and vp commands prefer the system Node.js. Set to `true` to force-enable the managed Node.js. Cannot be `false` together with node-version or node-version-file."
31+
description: "Control Vite+'s Node.js version manager. When unset, the Vite+ installer decides (enabled on CI). Set to `false` to keep the Node.js already on the runner (e.g. from actions/setup-node or the runner image): after installation, vp commands prefer the system Node.js. Set to `true` to leave the installer default unchanged. Cannot be `false` together with node-version or node-version-file."
3232
required: false
3333
working-directory:
3434
description: "Project directory to use for relative paths, lockfile auto-detection, environment checks, and default `vp install` execution."

0 commit comments

Comments
 (0)