Repository navigation
Expose the resolved Node.js and package manager versions as outputs #198
Description
setup-vp only sets the version and cache-hit outputs. After the step runs, the workflow can't tell which Node.js version or which package manager version it ended up with, even though setup-vp (or vp itself, when node-version is omitted) just picked them.
- id: vp
uses: voidzero-dev/setup-vp@v1.21.2
- run: echo "node=${{ steps.vp.outputs.node-version }}" # always emptyI need these values for cache keys outside the dependency cache, like node_modules/.vitest-cache and .tsbuild, which should be invalidated when the runtime changes. Right now I read them back from package.json before calling the action:
- id: toolchain
shell: bash
run: |
echo "node=$(jq -er '.devEngines.runtime.version' package.json)" >> "$GITHUB_OUTPUT"
echo "bun=$(jq -er '.packageManager | capture("^bun@(?<v>[^+]+)").v' package.json)" >> "$GITHUB_OUTPUT"
- uses: voidzero-dev/setup-vp@v1.21.2
with:
node-version: ${{ steps.toolchain.outputs.node }}That only works because both versions in my package.json are exact. With a range, or with node-version left out so Vite+ resolves it (#128, #130), the value I compute and the one that got installed can differ. The matrix example in the README has the same gap: matrix.node-version is "22", not the patch release that was installed.
actions/setup-node has a node-version output and oven-sh/setup-bun has bun-version, so anyone moving from those to setup-vp loses this.
What I have in mind:
| Output | Example |
|---|---|
node-version |
24.20.0 |
package-manager |
bun |
package-manager-version |
1.4.2 |
vp env current --json already reports all three. Locally, with vp 1.0.0-rc.0 in a project that declares devEngines.runtime and "packageManager": "bun@1.4.2", it prints this (paths removed):
{
"node": { "version": "24.20.0", "source": "devEngines.runtime", "installed": true, "mode": "managed" },
"package_manager": { "name": "bun", "version": "1.4.2", "source": "packageManager", "installed": true, "mode": "managed" }
}So in runMain, after vp env use and the package-manager commands, the action could run vp env current --json with cwd: projectDir and set the outputs from node.version, package_manager.name and package_manager.version. If the command fails or a field is missing, fall back to unknown the way version does in printViteVersion.
From reading resolve_version in vite-plus (crates/vp_global_cli/src/commands/env/config.rs), the vp env use override is checked first (VP_NODE_VERSION, then the session file), and ranges or aliases from project files come back as exact versions. So the output should match what vp env use installed. I haven't checked that on a runner yet; if it turns out not to, node --version through the shim would do for Node.
The JSON layout changed in Vite+ 0.3.1 (voidzero-dev/vite-plus#2398): before that, the Node version was a top-level version field. Gating on supportsScopedEnv, like the package-manager input does, seems simpler than parsing both layouts.
With node-manager: false, reading current.rs it looks like vp env current reports the Node.js found on PATH, which is the right value for node-version in that case too.
Two questions before I write it:
- GitLab and Azure. The parity table in
rfcs/azure-pipelines-integration.mdlists "Version/cache-hit outputs", so I'd add the new values to.setup-vp-outputs.envand the Azure job variables as well.SETUP_VP_NODE_VERSIONis already a GitLab input, though, so the output needs another name. WouldSETUP_VP_INSTALLED_NODE_VERSION(next toSETUP_VP_INSTALLED_VERSION),SETUP_VP_PACKAGE_MANAGER_NAMEandSETUP_VP_PACKAGE_MANAGER_VERSIONwork? - Output names on GitHub.
node-versionmatches setup-node and doesn't clash, since inputs and outputs live in separate namespaces. Fine with you, or would you preferresolved-node-version?
I'm happy to send a PR covering all three integrations, with the rebuilt dist/ bundles and tests next to the changed sources.
This is unrelated to #126: that cache is keyed on the run id and doesn't need runtime versions.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
fengmk2 commentedon Oct 13, 2026
PR is welcome!