Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ jobs:

# Runs `vp env use <version>` then `vp install` in the test project.
- name: Setup Vite+ with Node.js ${{ matrix.node-version }}
id: setup
uses: ./
with:
node-version: ${{ matrix.node-version }}
Expand All @@ -372,6 +373,19 @@ jobs:
echo "$ACTUAL" | grep -q "^v${{ matrix.node-version }}\." || (echo "Expected Node.js v${{ matrix.node-version }}.x but got $ACTUAL" && exit 1)
fi

# The outputs describe the action's project directory (this repository),
# not the run-install cwd.
- name: Verify Node.js and package-manager outputs
shell: bash
env:
OUTPUT_NODE_VERSION: ${{ steps.setup.outputs.node-version }}
OUTPUT_PACKAGE_MANAGER: ${{ steps.setup.outputs.package-manager }}
OUTPUT_PACKAGE_MANAGER_VERSION: ${{ steps.setup.outputs.package-manager-version }}
run: |
test "v$OUTPUT_NODE_VERSION" = "$(node --version)"
expected="$(node -p "require('./package.json').packageManager.split('+')[0]")"
test "$OUTPUT_PACKAGE_MANAGER@$OUTPUT_PACKAGE_MANAGER_VERSION" = "$expected"

# Reproduces https://github.com/voidzero-dev/setup-vp/issues/128: with no
# explicit Node.js input, the managed `node` shim should use Vite+'s normal
# project resolution and honor package.json#devEngines.runtime.
Expand All @@ -388,6 +402,7 @@ jobs:
echo '{"name":"test-project","private":true,"devEngines":{"runtime":{"name":"node","version":"22.18.0"}}}' > "$DIR/package.json"

- name: Setup Vite+ without a Node.js input
id: setup
uses: ./
with:
working-directory: ${{ runner.temp }}/test-project
Expand All @@ -397,13 +412,16 @@ jobs:
- name: Verify project Node.js version
working-directory: ${{ runner.temp }}/test-project
shell: bash
env:
OUTPUT_NODE_VERSION: ${{ steps.setup.outputs.node-version }}
run: |
ACTUAL=$(node --version)
echo "Node.js version: $ACTUAL"
if [ "$ACTUAL" != "v22.18.0" ]; then
echo "::error::expected Node.js v22.18.0 from devEngines.runtime, got $ACTUAL"
exit 1
fi
test "$OUTPUT_NODE_VERSION" = "22.18.0"

# End-to-end check of node-manager: false. Node.js management is disabled
# while package-manager management keeps the installer defaults. Shims may
Expand Down Expand Up @@ -433,6 +451,7 @@ jobs:
echo '{"name":"test-project","private":true}' > "$DIR/package.json"

- name: Setup Vite+ without Node.js manager
id: setup
uses: ./
with:
node-manager: false
Expand All @@ -445,6 +464,8 @@ jobs:

- name: Verify system Node.js is untouched
shell: bash
env:
OUTPUT_NODE_VERSION: ${{ steps.setup.outputs.node-version }}
run: |
ACTUAL_PATH=$(node -p 'process.execPath' | tr -d '\r')
ACTUAL_VERSION=$(node --version | tr -d '\r')
Expand All @@ -458,6 +479,7 @@ jobs:
echo "::error::node is $ACTUAL_VERSION; expected ${{ steps.before.outputs.version }}"
exit 1
fi
test "v$OUTPUT_NODE_VERSION" = "${{ steps.before.outputs.version }}"

- name: Verify vp commands use the system Node.js
shell: bash
Expand Down
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,15 @@ Separate package-manager modes require Vite+ 0.3.1+. Any explicit configuration,

## Outputs

| Output | Description |
| ----------- | ---------------------------------------- |
| `version` | The installed version of Vite+ |
| `cache-hit` | Boolean indicating if cache was restored |
| Output | Description |
| ------------------------- | ----------------------------------------------------------- |
| `version` | The installed version of Vite+ |
| `cache-hit` | Boolean indicating if cache was restored |
| `node-version` | The Node.js version Vite+ resolved, such as `24.20.0` |
| `package-manager` | The package manager Vite+ resolved, such as `pnpm` or `bun` |
| `package-manager-version` | The version of that package manager, such as `10.33.0` |

The last three come from `vp env current --json` in `working-directory` at the end of setup. They require Vite+ 0.3.1+ and are `unknown` on older versions or when Vite+ reports no value. With `node-manager: false`, `node-version` is the version of the Node.js found on `PATH`.

## Caching

Expand Down Expand Up @@ -594,12 +599,15 @@ test:
script:
- vp run test
- echo "$SETUP_VP_INSTALLED_VERSION / $SETUP_VP_CACHE_HIT"
- echo "$SETUP_VP_INSTALLED_NODE_VERSION / $SETUP_VP_PACKAGE_MANAGER_NAME $SETUP_VP_PACKAGE_MANAGER_VERSION"
artifacts:
reports:
dotenv: .setup-vp-outputs.env
```

The two output variables are available in the current job. The optional dotenv report passes them to downstream jobs; it contains no auth tokens. Keep `.setup-vp-cache/` as the only cache path. The generated `.setup-vp-runtime.mjs` and `.setup-vp-cache-state.json` support post-job saving and must not be cached. If you replace `after_script`, include `!reference [.setup-vp-cached, after_script]` in your own array. Override the job's native `cache` mapping when you need different keys or additional cache paths. [GitLab cache behavior](https://docs.gitlab.com/ci/caching/)
On refs containing these changes, `SETUP_VP_INSTALLED_NODE_VERSION`, `SETUP_VP_PACKAGE_MANAGER_NAME`, and `SETUP_VP_PACKAGE_MANAGER_VERSION` match the GitHub `node-version`, `package-manager`, and `package-manager-version` outputs, including the Vite+ 0.3.1 requirement and the `unknown` fallback.

The output variables are available in the current job. The optional dotenv report passes them to downstream jobs; it contains no auth tokens. Keep `.setup-vp-cache/` as the only cache path. The generated `.setup-vp-runtime.mjs` and `.setup-vp-cache-state.json` support post-job saving and must not be cached. If you replace `after_script`, include `!reference [.setup-vp-cached, after_script]` in your own array. Override the job's native `cache` mapping when you need different keys or additional cache paths. [GitLab cache behavior](https://docs.gitlab.com/ci/caching/)

### GitLab Windows Runners

Expand Down Expand Up @@ -679,14 +687,17 @@ On refs containing these changes, `nodeVersion` selects the managed project runt

### Azure Job Variables

| Variable | Purpose |
| ---------------------------- | --------------------------------------------------------------------- |
| `SETUP_VP_INSTALLED_VERSION` | Installed global Vite+ version (`unknown` when parsing fails). |
| `SETUP_VP_CACHE_HIT` | `true`, `inexact`, or `false` from `Cache@2` when caching is enabled. |
| Variable | Purpose |
| ---------------------------------- | --------------------------------------------------------------------------------- |
| `SETUP_VP_INSTALLED_VERSION` | Installed global Vite+ version (`unknown` when parsing fails). |
| `SETUP_VP_CACHE_HIT` | `true`, `inexact`, or `false` from `Cache@2` when caching is enabled. |
| `SETUP_VP_INSTALLED_NODE_VERSION` | Node.js version resolved by `vp env current` (Vite+ 0.3.1+, otherwise `unknown`). |
| `SETUP_VP_PACKAGE_MANAGER_NAME` | Package manager resolved by `vp env current` (Vite+ 0.3.1+, otherwise `unknown`). |
| `SETUP_VP_PACKAGE_MANAGER_VERSION` | Version of that package manager (Vite+ 0.3.1+, otherwise `unknown`). |

`vp`, `NPM_CONFIG_USERCONFIG`, and `PNPM_CONFIG_USERCONFIG` are available to later steps in the same job. Define `NODE_AUTH_TOKEN` as an Azure secret pipeline variable when private registry auth is required; the template maps it into both finalize tasks.

Finalize tasks also expose `version` and `cacheHit` as named outputs. Use `$(setupVpUnix.version)` on Linux/macOS or `$(setupVpWindows.version)` on Windows; `stepName` changes the prefix. `cacheHit` is `true` only for an exact match, while the job variable retains Azure's `inexact` value. Cross-job consumers use Azure's `dependencies.<job>.outputs['setupVpUnix.version']` syntax. [Azure output variables](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-variables-scripts?view=azure-devops)
Finalize tasks also expose `version`, `cacheHit`, `nodeVersion`, `packageManager`, and `packageManagerVersion` as named outputs. Use `$(setupVpUnix.version)` on Linux/macOS or `$(setupVpWindows.version)` on Windows; `stepName` changes the prefix. `cacheHit` is `true` only for an exact match, while the job variable retains Azure's `inexact` value. Cross-job consumers use Azure's `dependencies.<job>.outputs['setupVpUnix.version']` syntax. [Azure output variables](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-variables-scripts?view=azure-devops)

Without `registryUrl`, the runtime preserves existing project `.npmrc` auth entries but does not generate token entries for its registry URLs. Set `registryUrl` to generate auth configuration for a registry. Referenced custom token variables are propagated as secret pipeline variables, not public outputs. Pass custom secret mappings through `authEnv`, for example `authEnv: { CUSTOM_TOKEN: "$(CUSTOM_TOKEN)" }`. Azure does not automatically put secret pipeline variables in task environments.

Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ outputs:
description: "The installed version of Vite+"
cache-hit:
description: "Boolean indicating if cache was restored"
node-version:
description: "The Node.js version Vite+ resolved for working-directory, from `vp env current` (0.3.1+). `unknown` on older versions or when Vite+ reports none."
package-manager:
description: "The package manager Vite+ resolved for working-directory, such as pnpm or bun (0.3.1+). `unknown` on older versions or when Vite+ reports none."
package-manager-version:
description: "The version of that package manager (0.3.1+). `unknown` on older versions or when Vite+ reports none."

runs:
using: node24
Expand Down
Loading
Loading