63 Commits
Author SHA1 Message Date
MK (fengmk2) cab1ab9eaf chore: release v1.22.0 (#210)
Prepare `v1.22.0` with toolchain and package manager caches for GitHub Actions, earlier Node.js selection, and version outputs across all integrations.

Set `package.json` to `1.22.0`. Update the examples and GitLab and Azure defaults to `v1.22.0` so templates download the matching runtime.
2026-10-23 15:51:25 +08:00
MK (fengmk2) 6eb3ef76e4 perf: cache package managers and use native toolchain setup (#209)
Fresh runners still run a shell installer after a Vite+/Node.js cache
hit and download the project package manager. `cache-toolchain: true`
now caches the selected managed package manager and activates validated
toolchains through the cached CLI.

A temporary copy of the validated CLI performs Vite+'s native setup. It
creates the activation links, configuration, and shims.
`VP_SELF_SETUP_NO_MODIFY_PATH=1` skips persistent shell-profile and user
`PATH` changes. The action exports `PATH` for itself and subsequent
steps through `GITHUB_PATH`. Native activation requires an exact
validated cache hit and no active installation. Failed activation falls
back to the normal installer.

The selected managed `pnpm`, `npm`, `yarn`, or `bun` installation uses a
separate archive. Its key includes the toolchain identity, exact manager
version, and a hash of npm configuration. Configuration files and
credentials stay outside the archive. Existing installations remain
intact; invalid archives fall back to normal installation. Independent
directory and manager queries run together. All cache uploads run in
parallel and follow `cache-save`.

`package-manager-cache-hit` reports the manager archive.
`toolchain-cache-hit` retains its Vite+/Node.js meaning.

### Hosted comparison

The [GitHub Actions
run](https://github.com/voidzero-dev/setup-vp/actions/runs/39234874369)
passed all 57 jobs: three warm-ups and six samples per case on each
platform.

The PR base is
[`c025a93`](https://github.com/voidzero-dev/setup-vp/commit/c025a93923d2f9c524652d786386d11065fc3e8f).
Manager caching with shell setup uses
[`f28bb92`](https://github.com/voidzero-dev/setup-vp/commit/f28bb92ea995da2055edc7b12d14a1ac245f1fc6).
The optimized implementation is
[`06fe7ec`](https://github.com/voidzero-dev/setup-vp/commit/06fe7ecfda756e5871867245052c17baa9b4e974).

All cases use fresh runners, the same project checkout, and warm
dependency and Vite+/Node.js archives. Both PR implementations also
restore the same manager archive. Versions are fixed at `Vite+ 1.3.0`,
Node.js `24.22.0`, and `pnpm@12.7.0`. The local `vite-plus` package and
`vite` alias also use `1.3.0`.

Median setup plus post-action time includes `vp install`. All cases use
`cache-save: true` and `sfw: false`.

| Runner | PR base | Before optimization | Optimized | Reduction vs
before | Reduction vs base |
| --- | ---: | ---: | ---: | ---: | ---: |
| Linux x64 | 7 s | 9.5 s | 5.5 s | 42.1% | 21.4% |
| macOS ARM64 | 15.5 s | 18.5 s | 13.5 s | 27.0% | 12.9% |
| Windows x64 | 18 s | 16.5 s | 12 s | 27.3% | 33.3% |

```mermaid
xychart-beta
  title "PR 209: median setup + post time"
  x-axis ["Linux before", "Linux after", "macOS before", "macOS after", "Windows before", "Windows after"]
  y-axis "Seconds — lower is better" 0 --> 30
  bar [9.5, 5.5, 18.5, 13.5, 16.5, 12]
```

The chart compares the two PR implementations with manager caching
enabled. All 18 optimized samples used native activation without
installer fallback. All 36 PR samples reported
`package-manager-cache-hit: true`.

### Why cache hits could take more time

A manager archive adds a lookup, transfer, extraction, and executable
check. In the [earlier
run](https://github.com/voidzero-dev/setup-vp/actions/runs/39227680298),
Windows manager restoration took a median `1.18 s` after the cache
match. Dependency-cache discovery saved about `0.91 s`, so archive costs
could exceed that saving.

The earlier Windows totals also included bootstrap variation: `4.57 s`
at the PR base versus `6.19 s` with manager caching. The [shell
installer](https://github.com/voidzero-dev/vite-plus/blob/v1.3.0/packages/cli/install.ps1)
downloads a standalone CLI before native setup, even with a restored
payload. Native setup also [starts PowerShell to update user
PATH](https://github.com/voidzero-dev/vite-plus/blob/v1.3.0/crates/vp_global_cli/src/self_setup/shell.rs).
The optimized cache path removes these operations.

The new run measures this activation phase from toolchain validation to
Node.js configuration:

| Runner | Before optimization | Optimized |
| --- | ---: | ---: |
| Linux x64 | 0.605 s | 0.033 s |
| macOS ARM64 | 0.739 s | 0.056 s |
| Windows x64 | 4.632 s | 0.119 s |

The Windows activation saving is about `4.51 s`. Cache transfer and
runner variation also affect total time. The full Linux and macOS
reductions must not be attributed solely to native activation.

<details>
<summary>Samples, cache storage, and reproduction</summary>

All six samples are in seconds, in sample order:

| Runner | PR base | Before optimization | Optimized |
| --- | --- | --- | --- |
| Linux x64 | 5, 5, 7, 7, 9, 9 | 12, 8, 6, 6, 12, 11 | 7, 5, 6, 6, 4, 5
|
| macOS ARM64 | 18, 21, 13, 16, 10, 15 | 9, 10, 18, 23, 19, 22 | 16, 13,
12, 21, 10, 14 |
| Windows x64 | 23, 21, 17, 16, 16, 19 | 27, 17, 14, 15, 20, 16 | 11,
12, 12, 12, 11, 18 |

GitHub reports step durations in whole seconds; a six-sample median can
include half a second. Phase timings use log timestamps. Measurements
exclude runner startup, checkout, metadata checks, the project build,
and artifact uploads.

The [benchmark
workflow](https://github.com/voidzero-dev/setup-vp/blob/b0b235ae74110b9aa3637fb2762bf71658986cc9/.github/workflows/package-manager-benchmark.yml)
pins all three action commits and the project checkout. It uses isolated
cache paths and records each installation. The analysis checks versions,
binary hashes, lockfile hashes, runner images, and cache outputs. The
benchmark harness stays outside this PR's source diff.

The manager archives use `20.6 MiB` on Linux, `17.8 MiB` on macOS, and
`20.1 MiB` on Windows. One entry per platform totals about `59 MiB`.

</details>
2026-10-19 21:51:25 +08:00
MK (fengmk2) 03bf4282fc feat: cache the Vite+ toolchain in GitHub Actions (#207)
Fresh runners download the CLI dependencies and Node.js on each job. Add
`cache-toolchain: true` to restore these files before installation.

The cache requires exact Vite+ and managed Node.js versions. Moving
versions retain normal resolution. The installer recreates configuration
and active links after restoration. Invalid caches fall back to
installation. Windows restores recreate dependency junctions before
validation.

The action has two independent caches:

| Cache | Input | Cached files | Restore point |
| --- | --- | --- | --- |
| Toolchain (new) | `cache-toolchain` | Vite+ CLI, its dependencies, and
managed Node.js | Before the installer |
| Project dependencies (existing) | `cache` | Package manager store or
download cache | Before `vp install` |

The diagram shows fresh runners with the available caches enabled and
`run-install: true`.

```mermaid
flowchart TB
  subgraph after["After"]
    direction TB
    A1[("NEW: toolchain<br/>Restore and validate")]
    A2["Install toolchain<br/>Hit: reuse files<br/>Miss: download"]
    A3[("Dependency cache<br/>Restore packages")]
    A4["vp install<br/>Use cached packages"]
    A1 --> A2 --> A3 --> A4
  end

  subgraph before["Before"]
    direction TB
    B1["Install toolchain<br/>Download files"]
    B2[("Dependency cache<br/>Restore packages")]
    B3["vp install<br/>Use cached packages"]
    B1 --> B2 --> B3
  end

  classDef newCache fill:#dafbe1,stroke:#1a7f37,color:#1f2328
  classDef existingCache fill:#ddf4ff,stroke:#0969da,color:#1f2328
  class A1 newCache
  class B2,A3 existingCache
```

`vp install` uses restored packages and downloads missing packages. Both
caches default to `false`. `cache-save` controls uploads for both
enabled caches after a successful job. When both caches need uploads,
the post action saves them concurrently and waits for both.
`toolchain-cache-hit` reports a validated toolchain restore. Toolchain
caching applies only to GitHub Actions.

[Hosted
benchmark](https://github.com/voidzero-dev/setup-vp/actions/runs/39186092848):
six samples per OS, using action `dc128ee` and Node.js `22.23.1`. The
Vite+ preview is `65f9bc56f1f2d87e138013c5bcde9e7306d8eeb8`.

These measurements isolate the toolchain cache: `cache: false` and
`run-install: false`.

Each sample runs all three cases in one hosted job. Each case starts
with an empty installation and package caches. Misses upload to GitHub's
cache service; hits download from it. The uncached case alternates
before or after the miss/hit pair.

These medians include the action's main and post processes. They include
cache transfer, extraction, validation, and upload costs. They exclude
checkout, separate correctness checks, and artifact uploads.

| Runner | Cache disabled | Cache miss | Cache hit | Hit reduction |
Compressed cache |
| --- | ---: | ---: | ---: | ---: | ---: |
| Linux x64 | 6.65 s | 9.59 s | 3.06 s | 54.0% | ~88 MiB |
| macOS ARM64 | 7.92 s | 14.14 s | 6.55 s | 17.4% | ~82 MiB |
| Windows x64 | 21.92 s | 24.40 s | 16.10 s | 26.5% | ~74 MiB |

One entry per platform totals about **244 MiB (0.24 GiB)** of compressed
storage. These sizes exclude project dependency caches and extracted
files on runners. Sizes vary with toolchain versions. Each new cache key
stores a complete toolchain archive; cache hits reuse the existing
entry.

Different keys and GitHub cache scopes can retain separate entries. Both
cache types share the repository's [Actions cache storage
limit](https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#usage-limits-and-eviction-policy),
which defaults to 10 GB. Use `cache-save: false` to restore without
uploading new entries.

Misses cost more because they upload the cache. Results depend on runner
and network conditions; caching remains opt-in. The run artifacts
contain individual timings and logs.

All 54 cases check the exact versions, native binding, and formatter.
The [published-release
run](https://github.com/voidzero-dev/setup-vp/actions/runs/39186095114)
also passes cache misses and hits on all three operating systems with
`1.3.0`.
2026-10-19 12:22:36 +08:00
MK (fengmk2) e2e70bd8cc perf: select project Node before installation (#202)
CI setup can install an extra Node.js LTS runtime before it selects the
project's requested version.

`setup-vp` now reads the selection before installation and passes it
through `VP_SETUP_NODE_VERSION` across GitHub Actions, GitLab, and
Azure. `node-version` takes precedence over `node-version-file`. Without
explicit inputs, discovery checks `.node-version`,
`package.json#devEngines.runtime`, `package.json#engines.node`, then
`.nvmrc` in each directory before its parent.

Compatible installers return the exact version for explicit `vp env use`
requests. Automatic discovery keeps its directory scope. With no
selection or with `node-manager: false`, the installer keeps its LTS
default. Older installers retain the existing behavior.

Runtime reuse requires a Vite+ release with [the installer
change](https://github.com/voidzero-dev/vite-plus/pull/3087). The
installer itself does not discover project versions.

## Benchmark

Both cases use [Vite+ preview
`65f9bc5`](https://github.com/voidzero-dev/vite-plus/commit/65f9bc56f1f2d87e138013c5bcde9e7306d8eeb8)
and project Node.js `22.23.1`. The control uses `setup-vp` at `ad00cb8`
with the default LTS installer runtime. The updated case uses `25c45da`
and passes the project version through `VP_SETUP_NODE_VERSION`.

The table shows median setup time from 12 samples per case on each OS,
across two workflow runs. Each installation uses fresh local runtime and
package caches. Installation order rotates between samples. Timing
covers `setup-vp` execution, including Node.js activation. It excludes
checkout and application dependency installation.

| Platform | Default LTS bootstrap | Project Node bootstrap | Time saved
| Reduction |
| --- | ---: | ---: | ---: | ---: |
| Linux x64 | 7.57 s | 5.80 s | 1.77 s | 23.4% |
| macOS ARM64 | 12.36 s | 7.91 s | 4.45 s | 36.0% |
| Windows x64 | 10.64 s | 9.24 s | 1.39 s | 13.1% |

Every optimized installation downloaded only project Node.js `22.23.1`.
Each control installation also downloaded LTS `24.22.0`. Network
variation affects individual measurements, especially on Windows; these
figures are observed median savings.

The workflow artifacts contain the raw timings and logs: [first
run](https://github.com/voidzero-dev/setup-vp/actions/runs/38926176533),
[second
run](https://github.com/voidzero-dev/setup-vp/actions/runs/38926725215).
2026-10-19 11:46:57 +08:00
Éverton Toffanetto d2bd646916 feat: add Node.js and package manager version outputs (#199)
Closes #198

At the end of setup, all three integrations run `vp env current --json`
in the project directory and publish what Vite+ resolved:

| GitHub output | GitLab variable | Azure job variable and named output
|
| ------------------------- | ---------------------------------- |
----------------------------------------------------------- |
| `node-version` | `SETUP_VP_INSTALLED_NODE_VERSION` |
`SETUP_VP_INSTALLED_NODE_VERSION`, `nodeVersion` |
| `package-manager` | `SETUP_VP_PACKAGE_MANAGER_NAME` |
`SETUP_VP_PACKAGE_MANAGER_NAME`, `packageManager` |
| `package-manager-version` | `SETUP_VP_PACKAGE_MANAGER_VERSION` |
`SETUP_VP_PACKAGE_MANAGER_VERSION`, `packageManagerVersion` |

On GitLab they also go into `.setup-vp-outputs.env`, next to
`SETUP_VP_INSTALLED_VERSION`.

The command only runs when the installed Vite+ is 0.3.1 or newer, using
the same `supportsScopedEnv` check as the `package-manager` input.
Before 0.3.1 the JSON kept the Node.js version at the top level, and `vp
env current` ignored `vp env off`, so with `node-manager: false` it
would have reported the managed version instead of the one on `PATH`. On
older versions the outputs are `unknown`, like `version`. If the command
fails or doesn't print JSON, they are `unknown` too and each integration
logs a warning. Values that aren't a plain name or version also become
`unknown`, since they end up in a GitLab dotenv file.

The version check, the command call and the parsing live in
`src/ci/env-current.ts`, shared by the three integrations. The `dist/`
bundles are rebuilt, and the variable lists in the GitLab and Azure RFCs
include the new names.

The GitLab E2E fixture update is in
[setup-vp-gitlab-test!5](https://gitlab.com/fengmk2/setup-vp-gitlab-test/-/merge_requests/5).
It accepts either the two legacy dotenv keys or all five keys and
validates the new values against the exported environment. All 26 local
fixture tests pass. The [full GitLab suite passed in the
fork](https://gitlab.com/everton-dgn/setup-vp-gitlab-test/-/pipelines/2948528771)
against this PR's commit `f2c452ab1c34c245dd085f47a3ac1d7b23fb78a5`,
including the dotenv producer and consumer jobs. Windows jobs remain
disabled in the existing GitLab CI configuration. The fixture MR still
needs to merge before the upstream GitLab E2E workflow can use the
updated assertion.

How I tested it:

- New tests for the version check, the parser and the warnings, plus
GitHub, GitLab and Azure tests for the 0.3.1+ path, the fallback on
0.3.0, a failing `vp env current`, and the order of the call after `vp
env use`, the package-manager commands and the install. Without the
source changes, the new tests fail (11 failures, and the helper's test
file can't load).
- `vp run check`, `vp run build`, `vp run typecheck` and `vp run test`
pass locally on macOS: 1004 passed, 146 skipped. The skipped ones are
Windows or PowerShell-only, plus one that needs a case-sensitive volume.
- I fed real `vp env current --json` output from vp 1.0.0-rc.0 to the
parser (the JSON layout in `current.rs` is the same in v1.1.0). A Bun
project with `devEngines.runtime` 24.20.0 gives `24.20.0`, `bun`,
`1.4.2`. This repo, whose `.node-version` is `lts/*`, gives `24.21.0`,
`pnpm`, `12.7.0`. In a project without a local vite-plus, stdout is
still plain JSON.
- In `test.yml`, `test-node-version`, `test-auto-node-version` and
`test-node-manager-off` now check `node-version` against `node
--version` or the expected version, and `test-node-version` also checks
the package manager against `packageManager` in this repo's
`package.json`. I replayed those three jobs on macOS with a small script
that runs their steps against `dist/index.mjs` in an isolated `HOME`.
They pass for `node-version: 22` (output `22.23.3`), `lts` (`24.21.0`),
`devEngines.runtime` 22.18.0, and `node-manager: false` with a system
Node.js 22.19.0, where the managed version would have been 24.21.0. They
haven't run on real runners, Linux or Windows yet.
2026-10-15 09:32:54 +08:00
MK (fengmk2) 68f39c78aa chore: release v1.21.2 (#195)
Prepare patch release `v1.21.2` with fixes for command injection, `sfw`
executable lookup, and registry authentication.

Set `package.json` to `1.21.2`. Update the examples and GitLab and Azure
defaults to `v1.21.2` so templates download the matching runtime.
2026-10-11 00:01:26 +08:00
MK (fengmk2) 16e60efbfd fix: prevent shell injection through GitLab inputs (#193)
GitLab string inputs can close fixed shell delimiters and run commands
before the runtime checks their values. This affects pipelines that
accept inputs from callers who cannot edit job scripts.

Pass string inputs through job variables with `expand: false` in both
templates. Copy these values into `SETUP_VP_*` at runtime to keep input
precedence. Multiline values, quotes, and dollar signs remain literal
data.
2026-10-10 23:31:07 +08:00
MK (fengmk2) 2fb3264f28 fix: require explicit registry input for generated auth (#191)
A project `.npmrc` could make the runtime send `NODE_AUTH_TOKEN` to an
arbitrary registry when the workflow omitted the registry input.

Require `registry-url` (`registryUrl` in Azure) before the runtime
generates token entries. Apply this behavior to GitHub Actions, GitLab,
and Azure Pipelines. Preserve existing `.npmrc` auth entries and their
environment references.

Document how jobs that relied on automatic token entries must configure
authentication.
2026-10-08 14:00:26 +08:00
MK (fengmk2) 38584abba5 fix: validate refs before CI bootstrap downloads (#188)
An unchecked `setup-ref` can redirect GitLab downloads to another GitHub
repository and execute its code on the runner.

Both GitLab templates now check `setup-ref` before script interpolation
and reject unsafe `SETUP_VP_SETUP_REF` values before bootstrap
downloads. The GitLab and Azure bootstrap scripts also check refs before
runtime downloads.

Accepted refs contain ASCII letters, digits, underscores, and hyphens,
with single dots or slashes between groups.
2026-10-08 13:36:15 +08:00
MK (fengmk2) ad9155c955 fix: prevent Azure setupRef command injection (#184)
`azure/setup-vp.yml` inserted `setupRef` directly into Bash and
PowerShell scripts. A crafted value could execute commands on the agent.

Both prepare steps now read `SETUP_VP_SETUP_REF` from the environment
and reject unsafe values before the bootstrap download. The allowed
format supports release tags, branch paths, and commit SHAs.
2026-10-08 12:17:51 +08:00
MK (fengmk2) 3754dd7dbd chore: release v1.21.1 (#172)
Prepare patch release `v1.21.1`, which fixes repeated downloads when a
complete installation matches the requested exact Vite+ version.

Set `package.json` to `1.21.1`. Update examples and GitLab and Azure
defaults to `v1.21.1` so templates download the matching runtime.
2026-09-21 22:25:06 +08:00
MK (fengmk2) ad4675d7e2 fix: reuse active Vite+ installations for exact versions (#146)
The action reuses a complete active installation for an exact version
(`0.3.0` or later), avoiding repeated downloads on persistent runners.
Fixes #145.

```mermaid
flowchart LR
    A["Same exact version already installed"] -->|Before this PR| B["Download and reinstall"]
    A -->|With this PR| C{"Reuse checks pass?"}
    C -->|Yes| D["Reuse existing files<br/>No CLI download"]
    C -->|No| B
    B --> E["Apply inputs and continue setup"]
    D --> E
    classDef reuse fill:#dafbe1,stroke:#1a7f37,color:#1f2328
    classDef install fill:#fff1e5,stroke:#bc4c00,color:#1f2328
    class D reuse
    class B install
```

For two setups of the same exact version, with a healthy retained
installation and no management overrides:

| Work | Before this PR | With this PR |
| --- | --- | --- |
| Installer runs | 2 | 1 |
| CLI download during the second setup | Repeated | None |
| Active installation files during the second setup | Reinstalled |
Unchanged |

Reuse checks include the required native binding. Failed checks or
environment overrides that require configuration changes use the
installer. The action also adds `fallback-bin` to the end of `PATH` when
present.

Tests cover reuse and binding repair on Linux, macOS, and Windows. Linux
tests also cover restored installations and package-manager overrides.
[All 76 enabled CI jobs
pass](https://github.com/voidzero-dev/setup-vp/actions/runs/35580056227).
2026-09-21 21:43:51 +08:00
MK (fengmk2) 24d8702287 chore: release v1.21.0 (#166)
Set `package.json` to `1.21.0`. Update the examples and GitLab and Azure
defaults to `v1.21.0` so templates download the matching runtime.

This release adds GitLab caching, outputs, and Windows support. GitLab
and Azure also gain version files, Node.js selection, project `.npmrc`
authentication, and full YAML install inputs.

The release fixes Windows cache links and disables `sfw` for Vite+
preview builds. The README now identifies `v1.21.0` as the first release
with GitLab caching and outputs.
2026-09-18 11:05:53 +08:00
MK (fengmk2) 7fa02642ae fix: disable sfw for Vite+ preview builds (#160)
Preview builds currently use Socket Firewall Free when `sfw: true`. The
setup now disables `sfw` for `0.0.0-commit.<40-character SHA>` builds
and logs a warning. Dependency installation uses plain `vp install`,
even if an `sfw` binary exists on `PATH`.

This behavior applies to GitHub Actions, GitLab CI/CD, and Azure
Pipelines. Azure also skips the `sfw` cache. Published releases and
prereleases keep their current behavior.
2026-09-16 15:46:04 +08:00
MK (fengmk2) 07c9643df8 feat: align GitLab and Azure setup features (#152)
GitLab and Azure now support version files, Node.js selection, project
`.npmrc` authentication, and full YAML install inputs. The runtimes also
retry the known `sfw` command-lookup failure.

GitLab adds a Windows template, native cache controls, and outputs in
`.setup-vp-outputs.env`. Azure adds named outputs and a cache for `sfw`.

On Azure, `nodeVersion` now selects the project runtime through `vp env
use`. `bootstrapNodeVersion` controls `UseNode@1`.

Azure E2E tests remain out of scope. `Cache@2` still has no supported
restore-only control.
2026-09-15 12:17:24 +08:00
MK (fengmk2) 9fd26ff49f chore: release v1.20.0 (#151)
Set `package.json` to `1.20.0`. Update the README examples and the
GitLab and Azure template defaults to `v1.20.0`.

This release adds `package-manager` for GitHub and GitLab, and
`packageManager` for Azure. These inputs control package managers
separately from Node.js. The `node-manager: false` setting preserves
package-manager management on Vite+ `0.3.1` and later.
2026-09-12 21:36:50 +08:00
LiangandMK a28dce9c6a feat: add package-manager environment configuration (#148)
Add `package-manager` for GitHub and GitLab, and `packageManager` for
Azure. Accept a boolean or a mapping of npm, pnpm, yarn, and bun to
booleans.

`false` runs `vp env off pm`; individual false entries run commands such
as `vp env off pnpm`. True and omitted entries leave the installer
default unchanged, without explicit enable commands. Any explicit
configuration requires Vite+ 0.3.1+; older versions remain supported
when the input is unset.

🤖 Generated with Codex

---------

Co-authored-by: MK (fengmk2) <fengmk2@gmail.com>
2026-09-12 21:23:19 +08:00
MK (fengmk2) 9accff0ba4 feat: report GitLab E2E results in PR comments (#150)
GitLab E2E results currently appear only in the workflow summary, so PR
authors must open Actions to find them.

The workflow now posts the result, tested commit, and pipeline link in a
PR comment. Each later run updates the same comment. Older runs cannot
overwrite newer results.
2026-09-12 21:20:41 +08:00
MK (fengmk2) 380fffc966 feat: run GitLab E2E for labeled fork pull requests (#149)
Fork pull requests currently skip GitLab E2E because `pull_request`
workflows cannot access `GITLAB_TRIGGER_TOKEN`.

Allow maintainers with write access to request the full suite with the
`run-e2e` label. A `pull_request` helper starts the trusted
`workflow_run` handler. The handler checks the labeler, helper file, PR
state, and exact head SHA before it calls GitLab. It does not load fork
code, artifacts, or caches. This flow uses no `pull_request_target`
trigger.

Both workflows must reach `main` before use. The fork branch must
include the unchanged helper. New commits require another review and a
new `run-e2e` label event.
2026-09-12 19:34:08 +08:00
Liang 2e1cde50fc 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
2026-09-12 17:21:47 +08:00
yusuke 7ca28af3bd docs: add about using package managers (#138)
Closes #27
2026-09-10 14:54:24 +08:00
NaokiHaba 8eed5df2b9 docs: update checkout examples to v7 (#144)
## Context

`actions/checkout` is currently at v7.0.1.

https://github.com/actions/checkout/releases

As many projects are upgrading to v7, this PR updates the README
examples to use the latest version.

Since this is a documentation-only update and is not urgent, please
review it when you have a chance.
2026-09-08 23:22:39 +08:00
MK (fengmk2) 49c3e4e92c chore: release v1.19.0 (#141)
Bump `package.json`, the README examples, and the GitLab and Azure
template defaults to `v1.19.0`.

Changes since `v1.18.0`:

- Add the `cache-save` input for restore-only caching.
- Update `vite-plus` to `v0.3.0`.
- Update `socketdev/sfw-free` to `v1.15.1`.
- Update `pnpm` to `v11.25.0`.

After merge, create the annotated tag `v1.19.0` on the merge commit.
Push the tag.
2026-09-04 23:04:58 +08:00
NaokiHabaandMK d6f71cce9f feat: add cache-save input for restore-only caching (#140)
resolves #139

This PR adds a `cache-save` input, defaulting to `true` to keep existing
workflows working as expected. When `cache-save` is set to `false`,
setup-vp restores the cache as usual, but skips saving it at the end.
It’s mainly intended for setups where all branches need to read the
cache, but only trusted ones should update it.

Note that Azure Pipelines and GitLab handle cache behavior through their
own platform configs, so this only affects GitHub Actions.

---------

Signed-off-by: NaokiHaba <59875779+naokihaba@users.noreply.github.com>
Co-authored-by: MK (fengmk2) <fengmk2@gmail.com>
2026-09-04 12:43:29 +08:00
MK (fengmk2) 1b32467adb chore: release v1.18.0 (#133)
Bump `package.json`, README examples, and the GitLab and Azure template
defaults to `v1.18.0`.

Changes since `v1.17.0`:

- Resolve Vite+ executable paths from `VpDirs` (#131).
- Add GitLab end-to-end tests (#132).
- Clarify automatic Node.js version selection (#130).
- Pin the install script to the requested version (#127).
- Update `pnpm/action-setup` to `v6.0.10` (#124).
- Update `vite-plus` to `v0.2.9` (#125).

After merge, create the annotated tag `v1.18.0` on the merge commit.
Push the tag.
2026-08-24 11:42:00 +08:00
MK (fengmk2) 92568af1d9 ci: add GitLab end-to-end testing (#132)
Add a GitHub Actions workflow that starts the dedicated GitLab test
project. The workflow passes the exact setup-vp commit or tag. It waits
for GitLab and reports the result as a GitHub check.

Add required and full GitLab test suites for installation, structured
installs, Node.js management, registry authentication, sfw, and Alpine.
Fix the GitLab bootstrap so BusyBox `mktemp` can create the temporary
`.mjs` runtime file.
2026-08-20 20:06:40 +08:00
MK (fengmk2) e8f4d95a41 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
2026-08-19 11:17:20 +08:00
MK (fengmk2) 313600b80b chore: release v1.17.0 (#123)
Bump the version to v1.17.0 in package.json, the README examples, and
the setup-ref / setupRef defaults in the GitLab and Azure templates.

Changes since v1.16.1:

- feat: support disabling Vite+'s Node.js management with node-manager:
false (#115)
- fix: retry sfw vp install when sfw misreports vp as not found on
Windows (#120)
- chore(deps): update vite-plus to v0.2.8 (#119)
- ci: re-run bundle rebuild when Renovate pushes to a labeled PR (#122)
- chore: align Renovate release age for the whole vite-plus group (#121)

After merge, tag the merge commit as v1.17.0 and push the tag.
2026-08-06 15:22:50 +08:00
KTrainandMK 6559b71d43 feat: support disabling Vite+'s Node.js management with node-manager: false (#115)
Adds a tri-state `node-manager` input to GitHub, GitLab, and Azure.
Unset keeps the installer's auto-detection (enabled on CI). `false`
keeps the Node.js already on the runner: the install script skips
node/npm/npx/corepack shims (`VP_NODE_MANAGER=no`) and the action runs
`vp env off` so vp commands prefer the system Node.js. `true`
force-enables the managed Node.js.

`node-manager: false` fails fast when combined with `node-version` or
`node-version-file`. Supersedes the earlier `node-version: off`
approach, which broke under YAML 1.1 parsers (GitLab) and mixed a mode
into a version input.

Usage:

```yaml
- uses: actions/setup-node@v5
  with:
    node-version: 24
- uses: voidzero-dev/setup-vp@v1.17.0
  with:
    node-manager: false
```

Closes the request from
[Discord](https://discord.com/channels/1475973262193459293/1479410337223802951/1532574083177250887)
for Flox and other external Node.js managers.

---------

Co-authored-by: MK <fengmk2@gmail.com>
2026-08-06 14:37:55 +08:00
MK (fengmk2)andCopilot Autofix powered by AI 143f5f385f chore: release v1.16.1 (#118)
Bump the version to v1.16.1 in package.json, the README examples, and
the setup-ref / setupRef defaults in the GitLab and Azure templates.

Changes since v1.16.0:

- fix: stop defaulting setup-ref/setupRef to the frozen v1 tag (#117)
- docs: use exact version tags instead of the moving v1 tag (#116)

After merge, tag the merge commit as v1.16.1 and push the tag.

---------

Signed-off-by: MK (fengmk2) <fengmk2@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-08-04 13:59:39 +08:00
MK (fengmk2) a3a544ffb6 fix: stop defaulting setup-ref/setupRef to the frozen v1 tag (#117)
Follow-up to #116 (now merged).

An unpinned `setup-ref` (GitLab) or `setupRef` (Azure) downloaded the
compiled runtime from the moving `v1` tag, which is now frozen at
v1.15.0, so unpinned includes silently ran a stale v1.15.0 runtime.

- Default `setup-ref` / `setupRef` (input default and bash env fallback)
to `v1.16.0`, the latest release
- Update the README input tables and the release checklist: the release
PR now also bumps these defaults, so from v1.17.0 on the shipped
template downloads the runtime of its own release
- Update the `src/azure/template.test.ts` assertion

The README examples keep the explicit `setup-ref` pin, which is still
the recommended setup and the only correct one for v1.16.0 itself (its
shipped template default is the frozen `v1`).
2026-08-04 13:36:46 +08:00
MK (fengmk2) 54c513827c docs: use exact version tags instead of the moving v1 tag (#116)
The `v1` major tag is frozen at v1.15.0: the voidzero-dev org-level tag
ruleset blocks non-fast-forward tag updates, so it can no longer be
moved on each release. This PR restructures the docs around exact
version pinning.

- New `Versioning` section: pin an exact release tag (or commit SHA),
with a warning that `v1` is frozen at v1.15.0 and should not be used
- All GitHub, GitLab, and Azure examples now pin `v1.16.0`
- GitLab examples pin `setup-ref` to the same tag as the remote URL, so
the compiled runtime matches the included template; the separate
pinned-runtime section is folded into basic usage
- `package.json` version now tracks the latest release (bumped to
1.16.0); it was pinned at 1.0.0 when releases only moved tags
- Release steps updated: a PR bumps `package.json` and the README tags
before tagging, no `v1` move

Follow-up in #117 (stacked on this PR): the GitLab `setup-ref` and Azure
`setupRef` template defaults still fall back to the frozen `v1`, so an
unpinned include silently gets the v1.15.0 runtime.
2026-08-04 13:32:10 +08:00
0e2c9516a4 feat: add Azure Pipelines integration for setup-vp (#108)
## Summary

- Add a reusable Azure Pipelines step template (`azure/setup-vp.yml`)
with Bash and PowerShell bootstraps for Linux/macOS and Windows agents.
- Extract shared dependency-light CI primitives into `src/ci/*` and keep
the GitLab runtime as thin adapters over that layer.
- Add an Azure runtime (`src/azure/*`, `dist/azure/index.mjs`) with
`prepare` / `finalize` phases around Azure `Cache@2`, including
cross-platform SFW support and logging-command adapters.
- Document the integration in `rfcs/azure-pipelines-integration.md` and
extend README/AGENTS/CI smoke coverage.

## Test plan

- [x] `vp run typecheck`
- [x] `vp run test` (306 tests)
- [x] `vp run check`
- [x] `vp run build`
- [x] `bash -n azure/bootstrap.sh gitlab/bootstrap.sh`
- [x] PowerShell syntax check for `azure/bootstrap.ps1`
- [x] Portable bundle smoke test (`dist/azure/index.mjs` invalid-phase
failure)
- [x] GitHub Action bundle unchanged (`dist/index.mjs`)
- [x] Real Azure Pipelines validation on `ubuntu-latest`,
`macOS-latest`, and `windows-latest` (release-blocking follow-up)

## Notes

- `plans/` was intentionally excluded from this PR.
- Azure end-to-end cache and cross-OS validation still needs an Azure
DevOps project with a GitHub service connection before release.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Kevin Beier <k.beier@enbw.com>
2026-08-03 11:47:42 +08:00
NaokiHabaandMK 250f29ce39 feat: add GitLab CI/CD integration for setup-vp (#97)
resolves #88

I thought it would be best to document the GitLab integration features
as an RFC, so I’ve put everything together along with a diagram of the
overall flow.

`rfcs/assets/gitlab-runtime-flow.svg`


<img width="1120" height="780" alt="gitlab-runtime-flow"
src="https://github.com/user-attachments/assets/860e9587-a0d8-46eb-a733-ae5a0d0d0d20"
/>

---------

Co-authored-by: MK <fengmk2@gmail.com>
2026-07-05 21:48:51 +08:00
MK (fengmk2) 13e7afb99c feat: resolve Vite+ version from package.json / catalog / lockfile (#102)
Resolve the Vite+ version from the checked-out project so CI keeps a single source of truth. Adds a `version-file` input and, when neither `version` nor `version-file` is set, auto-detects from the project's package.json (exact pin or `catalog:` across pnpm/yarn/bun), resolving a semver range through the lockfile, and falling back to `latest`. Also hardens catalog/lockfile resolution for monorepos and fixes the `vp --version` output parsing.

Closes #82
2026-07-02 00:39:36 +08:00
MK (fengmk2) a9a1f8d087 docs: document the version release process (#101)
Adds a `### Releasing` subsection under `## Development` in the README,
capturing the current release process:

- Releases are published as git tags only; there is no npm package, so
`package.json` stays at `1.0.0`.
- Consumers reference the moving major tag `@v1` (or pin a SHA), so each
release moves `v1` forward.
- Steps: sync `main` and confirm `dist/index.mjs` is in sync, create the
annotated `v1.x.0` version tag (minor bump), move the `v1` major tag to
the same commit, then push the new tag and force-push `v1`.

Documents the process just used to cut `v1.13.0`.
2026-07-01 13:08:42 +08:00
MK (fengmk2) af4e4f62e2 feat: add sfw input to wrap vp install with Socket Firewall Free (#72)
## Summary

- Adds a boolean `sfw` input. When `true` and `run-install` is enabled,
the action downloads the matching
[`sfw`](https://github.com/SocketDev/sfw-free) binary from the upstream
releases (auto-detected per OS/arch, with musl support on Alpine) and
runs `sfw vp install …` so the underlying package manager's network
fetches are inspected before install.
- Default is `false` — no behavior change for existing consumers.
- `sfw` only wraps `vp install`. Other `vp` invocations (`vp env use`,
`vp --version`) stay unwrapped.

```yaml
- uses: voidzero-dev/setup-vp@v1
  with:
    sfw: true
    run-install: true
```

## Why

Lets open-source projects opt into Socket Firewall Free protection for
CI installs with a single input — no need to compose a separate
`socketdev/action@v1` step. See
https://docs.socket.dev/docs/socket-firewall-free.

## Implementation notes

- `src/install-sfw.ts` — downloads `sfw-free-<asset>` from
`releases/latest/download/`, `chmod +x` on POSIX, then `addPath`.
Mirrors the retry pattern in `install-viteplus.ts`.
- musl detection:
`process.report.getReport().header.glibcVersionRuntime` with
`fs.existsSync('/etc/alpine-release')` as a fallback. Selects
`sfw-free-musl-linux-{arm64,x86_64}` on Alpine.
- `src/run-install.ts` — execs `sfw` with `["vp", "install", …]` instead
of `vp` with `["install", …]` when `inputs.sfw` is true.

## Test plan

- [x] Unit tests: `vp run test` — 133 passed (13 new in
`install-sfw.test.ts` covering all 8 platform/arch/libc combos + error
cases; 1 new in `inputs.test.ts`).
- [x] `vp run typecheck` clean.
- [x] `vp run check:fix` clean.
- [x] `vp run build` regenerated `dist/index.mjs`.
- [ ] New `test-sfw` job (Ubuntu/macOS/Windows × latest/alpha) —
installs `is-odd` under `sfw vp install` and verifies `sfw --version`
resolves on PATH.
- [ ] New `test-sfw-alpine` job (`alpine:3.23` container) — proves the
musl asset is selected (a glibc binary would fail to exec inside
Alpine).
- [ ] All existing test jobs continue to pass with `sfw: false` default
(no behavior change).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes the install path for opted-in workflows (external binary
download and supply-chain surface) and gates platform behavior so
macOS/Windows silently skip wrapping; CI relies on a live
malicious-package canary that could flake if delisted.
> 
> **Overview**
> Adds an optional **`sfw`** input (default `false`) so CI can run
**`sfw vp install`** instead of plain **`vp install`** when
`run-install` is enabled, wiring in Socket Firewall Free without a
separate action step.
> 
> **Docs & metadata:** `action.yml` and **README** document usage,
Linux-only behavior (macOS/Windows warn and fall back without
downloading `sfw`), Alpine/musl assets, and composing with
**`socketdev/action`** when `sfw` is already on PATH. **Renovate** gains
a regex custom manager on `src/install-sfw.ts` to bump pinned
**`SocketDev/sfw-free`** releases.
> 
> **CI:** **`test.yml`** adds jobs for Linux PM matrix + non-Linux
fallback, Alpine musl, **`lodahs`** typosquat blocking (output grep, not
exit code alone), and verifying setup-vp skips its download when
**`socketdev/action`** pre-installs `sfw`. A path-triggered
**`verify-vp-1703-sfw.yml`** workflow smoke-tests a pkg-pr-new **`vp`**
build for cross-platform **`sfw vp install`** / TLS fixes ahead of
relaxing the Linux gate.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
2161235ce6. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2026-05-29 15:12:56 +08:00
MK (fengmk2) 4f5aa3e38c feat: respect project .npmrc and auto-generate _authToken (#54)
When no `registry-url` is passed, honor the project `.npmrc`:

- If `NODE_AUTH_TOKEN` is set and the project `.npmrc` declares a registry
  without a matching `_authToken`, write a supplemental `_authToken` line
  to `$RUNNER_TEMP/.npmrc` and point `NPM_CONFIG_USERCONFIG` at it.
- Existing `_authToken` lines (case-insensitive) are respected.
- `${VAR}` references in the project `.npmrc` that are set in env are
  re-exported via `GITHUB_ENV` so they reach the `vp install` subprocess
  and later steps. `RUNNER_*` / `GITHUB_*` prefixes are blocked with
  `GITHUB_TOKEN` on an explicit allowlist. Registry values containing
  `${VAR}` are skipped for auth-key synthesis.

Closes #50
2026-04-22 21:07:50 +08:00
MK (fengmk2) dc86dedaca chore: update README with bun support and bump deps (#44)
## Summary
- Add bun to features list and dependency caching table in README
- Update vite-plus 0.1.14 → 0.1.15
- Update @types/node 24.12.0 → 24.12.2

## Test plan
- [x] `vp run test` — 93 tests pass
- [x] `vp run check:fix` — clean
- [x] `vp run build` — up to date
2026-04-03 19:44:21 +08:00
MK (fengmk2) 624fe22ccf feat(deps): update @actions/cache, @actions/core, @actions/exec, and zod (#39)
## Summary
- Update `@actions/cache` from ^4.1.0 to ^6.0.0
- Update `@actions/core` from ^1.11.1 to ^3.0.0
- Update `@actions/exec` from ^1.1.1 to ^3.0.0
- Update `zod` from ^3.25.76 to ^4.0.0
- Fix zod v4 breaking change: `ZodError.errors` → `ZodError.issues` in
`src/inputs.ts`

Consolidates the following Renovate PRs:
- Closes #35
- Closes #36
- Closes #37
- Closes #38

## Test plan
- [x] `vp run check:fix` passes
- [x] `vp run test` passes (86 tests, 5 files)
- [x] `vp run build` produces updated `dist/index.mjs`
- [ ] Action functions correctly in a workflow run
2026-03-25 19:54:18 +08:00
MK 464ce5eff2 docs: update node-version examples from v22 to v24 in README 2026-03-25 16:25:29 +08:00
MK (fengmk2) dce965b4cf feat: support Alpine Linux containers (#22)
## Summary
- Fall back to `sh` when `bash` is not available, enabling Alpine Linux
support without requiring bash as a prerequisite
- Add "Alpine Container" usage example to README
- Add `test-alpine-container` CI job testing both `latest` and `alpha`
versions in Alpine 3.21 container

## Test plan
- [ ] `test-alpine-container` CI job passes for both vp versions
- [ ] `vp --version` and `vp exec` work inside Alpine container
- [ ] Existing tests on ubuntu/macos/windows still pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: MK (fengmk2) <fengmk2@gmail.com>
2026-03-24 23:39:06 +08:00
Stephen Zhou 20553a7a74 feat: add working-directory input (#21)
Follow #20

I found that the version printed by vite+ is also incorrect. I'm
thinking that adding a `working-directory` might be better, which could
also simplify the configuration.

It looks like the `working-directory` from the GitHub action does not
work with `uses`. https://github.com/orgs/community/discussions/25742

Feel free to close this PR if you do not want to introduce another "cwd"
input.
2026-03-23 23:41:44 +08:00
Stephen Zhou 906b5821fc fix: get cache dir for custom path (#20)
Tested in https://github.com/langgenius/dify/pull/33950, it works fine.
2026-03-23 21:14:41 +08:00
MK (fengmk2) fd19e06261 refactor: remove vp CLI cache feature (#16)
## Summary
- Remove the vp CLI caching feature (`src/cache-vp.ts`) which was
disabled due to Windows `Cannot find module 'which'` issue (#10)
- Remove `force-install` test matrix dimension and
`SETUP_VP_FORCE_INSTALL` env var from all CI jobs, halving the number of
CI matrix combinations
- Dependency caching (`cache: true`) is unaffected

## Test plan
- [x] `vp run typecheck` passes
- [x] `vp run test` passes (73 tests)
- [x] `vp run check` passes
- [x] `vp run build` succeeds

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-03-20 21:43:06 +08:00
MK (fengmk2) 6f7287dbf2 feat: add registry-url and scope inputs for npm auth (#9)
## Summary
- Add `registry-url` input to configure npm registry authentication via
`.npmrc`
- Add `scope` input for scoped registries (auto-detects repo owner for
GitHub Packages)
- Ported from `actions/setup-node`'s authutil.ts implementation
- Writes `.npmrc` at `$RUNNER_TEMP`, exports `NPM_CONFIG_USERCONFIG` and
`NODE_AUTH_TOKEN`

## Usage

```yaml
- uses: voidzero-dev/setup-vp@v1
  with:
    registry-url: "https://npm.pkg.github.com"
    scope: "@myorg"
- run: vp install
  env:
    NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
```

## Test plan
- [x] 10 unit tests for auth module (`src/auth.test.ts`)
- [x] All 85 tests pass
- [x] CI job `test-registry-url` verifies `.npmrc` is created correctly
- [x] README updated with usage example and input docs

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-03-19 16:18:20 +08:00
MK (fengmk2)andCopilot Autofix powered by AI e1609b4687 feat: cache vp CLI installation to speed up setup (#8)
## Summary
- Cache the `~/.vite-plus/` directory using `@actions/cache`, keyed by
OS + arch + resolved version
- On cache hit, skip the install script entirely (~60s → ~2-3s)
- For `version: "latest"`, resolve actual semver from npm registry so
the cache key updates when new versions are released
- Update install URLs from `staging.viteplus.dev` to `viteplus.dev`

## Test plan
- [x] All 73 existing + new tests pass (`vp run test`)
- [x] Lint/format clean (`vp run check:fix`)
- [x] Build succeeds (`vp run build`)
- [x] First CI run: installs vp fresh, saves cache in post phase
- [x] Second CI run: restores vp from cache, skips install (should be
~2-3s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: MK (fengmk2) <fengmk2@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-19 15:02:18 +08:00
MK (fengmk2) b5d848f5a6 feat: add node-version-file input for reading Node.js version from files (#5)
Support reading Node.js version from .nvmrc, .node-version,
.tool-versions, and package.json (devEngines.runtime then engines.node),
matching actions/setup-node behavior. Ignored when node-version is set.

Also extracts resolveWorkspacePath utility to reduce duplication.
2026-03-12 21:18:18 +08:00
MK (fengmk2) 976b1aad50 Update README links and license reference
Signed-off-by: MK (fengmk2) <fengmk2@gmail.com>
2026-03-09 14:00:50 +08:00
MK 38e6c92b55 docs: fix README URLs and add LICENSE
- Replace staging.viteplus.dev with viteplus.dev in install URLs
- Fix feedback link to point to setup-vp issues
- Add MIT LICENSE file
2026-03-04 21:09:09 +08:00