Skip to content

Commit e8f4d95

Browse files
authored
docs: clarify automatic Node.js resolution (#130)
We updated `README.md` and `action.yml` to describe Vite+ Node.js version selection. The input table now shows `Vite+ resolution` as the `node-version` default. If users omit `node-version` and `node-version-file`, Vite+ resolves the version from the project. It checks these sources in order: 1. `.node-version` 2. `package.json#devEngines.runtime` 3. `package.json#engines.node` 4. `.nvmrc` Vite+ uses the user-level default if no project source exists. Set this default with `vp env default <version>`. Vite+ uses the latest LTS release if no user-level default exists. We added a CI test for `devEngines.runtime`. The test resolves Node.js `v22.18.0` without an explicit Node.js input. We changed documentation and tests. We kept the action runtime unchanged. Closes #128
1 parent 06b723b commit e8f4d95

3 files changed

Lines changed: 39 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,39 @@ jobs:
126126
echo "$ACTUAL" | grep -q "^v${{ matrix.node-version }}\." || (echo "Expected Node.js v${{ matrix.node-version }}.x but got $ACTUAL" && exit 1)
127127
fi
128128
129+
# Reproduces https://github.com/voidzero-dev/setup-vp/issues/128: with no
130+
# explicit Node.js input, the managed `node` shim should use Vite+'s normal
131+
# project resolution and honor package.json#devEngines.runtime.
132+
test-auto-node-version:
133+
runs-on: ubuntu-latest
134+
steps:
135+
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2
136+
137+
- name: Create project with devEngines.runtime
138+
shell: bash
139+
run: |
140+
DIR="${RUNNER_TEMP//\\//}/test-project"
141+
mkdir -p "$DIR"
142+
echo '{"name":"test-project","private":true,"devEngines":{"runtime":{"name":"node","version":"22.18.0"}}}' > "$DIR/package.json"
143+
144+
- name: Setup Vite+ without a Node.js input
145+
uses: ./
146+
with:
147+
working-directory: ${{ runner.temp }}/test-project
148+
run-install: false
149+
cache: false
150+
151+
- name: Verify project Node.js version
152+
working-directory: ${{ runner.temp }}/test-project
153+
shell: bash
154+
run: |
155+
ACTUAL=$(node --version)
156+
echo "Node.js version: $ACTUAL"
157+
if [ "$ACTUAL" != "v22.18.0" ]; then
158+
echo "::error::expected Node.js v22.18.0 from devEngines.runtime, got $ACTUAL"
159+
exit 1
160+
fi
161+
129162
# End-to-end check of node-manager: false. The installer must skip
130163
# node/npm/npx/corepack shim creation (VP_NODE_MANAGER=no) and the action
131164
# must run `vp env off`, so vp commands resolve the Node.js already on the

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ jobs:
332332
| ----------------------- | ----------------------------------------------------------------------------------------------------------- | -------- | ---------------- |
333333
| `version` | Version of Vite+ to install. Takes precedence over `version-file` | No | auto / `latest` |
334334
| `version-file` | Path to a file to resolve the Vite+ version from (`package.json`, `pnpm-workspace.yaml`, or `.yarnrc.yml`) | No | |
335-
| `node-version` | Node.js version to install via `vp env use` | No | Latest LTS |
335+
| `node-version` | Node.js version to install via `vp env use` | No | Vite+ resolution |
336336
| `node-version-file` | Path to file containing Node.js version (`.nvmrc`, `.node-version`, `.tool-versions`, `package.json`) | No | |
337337
| `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) |
338338
| `working-directory` | Project directory used for relative paths, lockfile auto-detection, environment checks, and default install | No | Workspace root |
@@ -345,6 +345,10 @@ jobs:
345345

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

348+
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.
349+
350+
`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`.
351+
348352
`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`.
349353

350354
## Outputs

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ inputs:
2222
required: false
2323
default: "false"
2424
node-version:
25-
description: "Node.js version to install via `vp env use`. Defaults to Node.js latest LTS version."
25+
description: "Node.js version to install via `vp env use`. Omit this input and node-version-file to let Vite+ resolve the version. `vp env default <version>` sets the user-level default. Vite+ checks the project, this default, and then the latest LTS release."
2626
required: false
2727
node-version-file:
2828
description: "Path to file containing the Node.js version spec (.nvmrc, .node-version, .tool-versions, package.json). Ignored when node-version is specified."

0 commit comments

Comments
 (0)