Skip to content

Expose the resolved Node.js and package manager versions as outputs #198

Open

Description

@everton-dgn

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 empty

I 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:

  1. GitLab and Azure. The parity table in rfcs/azure-pipelines-integration.md lists "Version/cache-hit outputs", so I'd add the new values to .setup-vp-outputs.env and the Azure job variables as well. SETUP_VP_NODE_VERSION is already a GitLab input, though, so the output needs another name. Would SETUP_VP_INSTALLED_NODE_VERSION (next to SETUP_VP_INSTALLED_VERSION), SETUP_VP_PACKAGE_MANAGER_NAME and SETUP_VP_PACKAGE_MANAGER_VERSION work?
  2. Output names on GitHub. node-version matches setup-node and doesn't clash, since inputs and outputs live in separate namespaces. Fine with you, or would you prefer resolved-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.

Activity

  1. fengmk2 commented on Oct 13, 2026

    @fengmk2
    Member

    PR is welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions