feat(vp): refactor global cli to rust entry point#514
Merged
Conversation
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Deploying vite-plus with
|
| Latest commit: |
7b866d4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://74789c44.vite-plus.pages.dev |
| Branch Preview URL: | https://vite-global-cli-crate.vite-plus.pages.dev |
8824030 to
a9acd67
Compare
499ea84 to
c96424e
Compare
b5aa8af to
22ea026
Compare
59ab7cd to
c6a1f1e
Compare
c6a1f1e to
e0da176
Compare
4955d30 to
5f6b2ea
Compare
5f6b2ea to
23318e2
Compare
23318e2 to
a213f27
Compare
a213f27 to
1750eb2
Compare
901823c to
256cd9b
Compare
0afd672 to
485b520
Compare
- Add VITE_PLUS_CLI_BIN environment variable containing the vp binary path - JS scripts can use this to invoke vp commands when needed - Add CliBinaryNotFound error variant for proper error semantics - Extract create_node_command helper to reduce code duplication
Add prepend_js_runtime_to_path_env() helper that downloads managed Node.js via vite_js_runtime and prepends it to PATH before executing package manager commands. Uses project's devEngines.runtime if package.json exists, otherwise falls back to CLI's runtime. - Update all 12 PM command files to call the helper - Rename create_node_command to create_js_command - Add PATH prepending to create_js_command for child processes - Remove unused execute_pm_command method - Add snap test for devEngines.runtime verification
- Replace JS-only fallback with helpful error message directing users to install from https://viteplus.dev - Show OS-specific installation commands (bash for Unix, PowerShell for Windows) - Add ensureExecutable() to auto-fix binary permissions on non-Windows systems
- Only send Discord notification when npm_tag is 'latest' - Update install instructions to use install.sh/install.ps1 scripts
Move tracing initialization to vite_shared crate and reuse it in both vite_global_cli and vite-plus-cli bindings. Uses VITE_LOG environment variable for log filtering with OnceLock to ensure single initialization.
Create vp.cmd alongside vp.exe so Windows users can run 'vp' directly without needing to specify the .exe extension.
…lity Replace embedded forward slashes in format strings with separate join() calls to ensure proper path separators on Windows. This fixes paths like `C:\...\js_runtime\node/25.5.0` becoming `C:\...\js_runtime\node\25.5.0`.
Add tests for create_js_command and execute_cli_script to verify Node.js execution works correctly on both Windows and Unix platforms.
Use parent() to navigate up the directory tree instead of join("..")
with canonicalize(). This avoids the \\?\ prefix that Windows adds
during canonicalization.
Windows handles PATH resolution and executable extensions (.exe, .cmd, etc.) automatically, so we can let the OS resolve the binary path directly instead of using which::which_in.
The find command exits normally even when no files match. Add explicit check to fail the workflow if no vp binaries are found in target.
- Replace hard-coded platform mappings with dynamic lookup from optionalDependencies - Add libc detection (gnu vs musl) for Linux to support Alpine/musl environments - Fetch version-specific metadata to ensure correct platform packages - Provide helpful error messages listing available platforms when unsupported - Cache npm metadata to avoid duplicate API calls This makes the install scripts automatically support new platforms when they are added to the package.json optionalDependencies.
Helps users troubleshoot network issues or incorrect registry URLs.
- Cache vp binary directly from target/${target}/release/ instead of
packages/global/bin/
- Use merge-multiple: true when downloading artifacts to preserve
directory structure, eliminating the reorganization step
- Add separate "Copy Rust CLI binary" step that runs on both cache
hit and miss
- Update release body with shell-based install instructions for both
macOS/Linux and Windows, with version env var for non-latest tags
…t exit
When specifying a non-existent version, the installers previously failed
silently due to:
- Bash: `set -e` causing script exit when grep failed in subshell
- PowerShell: generic HTTP error instead of npm's specific message
Changes:
- Add npm registry error response detection in fetch_package_metadata()
- Handle both {"error":"..."} and plain string error responses
- Fix subshell exit issue by using global variables instead of command
substitution (exit in subshell only exits subshell, not main script)
- Extract and display npm error messages in PowerShell catch block
Replace text-based download messages with visual progress bars: - Bash: use curl --progress-bar instead of silent mode - PowerShell: remove -UseBasicParsing to enable native progress bar
Install gcc-aarch64-linux-gnu and set CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER to fix the release workflow failing with "failed to find tool aarch64-linux-gnu-gcc" when cross-compiling vite_global_cli from x86_64 to aarch64.
Download artifacts without merge-multiple and move files from artifact
subdirectories to the expected target/{target}/release/ locations.
Transform `vp help [command]` into `vp [command] --help` at the entry point before clap parsing. This restores the help subcommand that was lost during the Rust refactoring. Also disable clap's help flag for `new` and `migrate` commands so that `--help` and `-h` are passed through to the JavaScript handlers which have styled, comprehensive help output.
Wrap curl calls to capture exit codes and provide helpful error messages with troubleshooting suggestions when network errors occur. Maps common curl exit codes to descriptive messages: - Exit 6: DNS resolution failed - Exit 7: Connection refused - Exit 28: Connection timed out - Exit 35: SSL/TLS connection error - Exit 60: SSL certificate verification failed Each error includes the failed URL and a debug command users can run.
When PATH was already configured in shell profile, add_to_path returned 1 (failure), causing the script to show "Could not automatically update PATH" warning incorrectly. Now add_to_path uses return codes to indicate the result: - 0: path was newly added - 1: file not found (failure) - 2: path already exists This ensures the correct message is shown: "PATH already configured" when the path already exists in the profile.
…json - Copy templates, rules directories and AGENTS.md file to VERSION_DIR - Remove devDependencies and optionalDependencies from package.json - Run `CI=true vp install` to install production dependencies - Refactor copy logic into a loop to reduce duplication
- Replace verbose info messages with clean, minimal output - Use silent curl downloads (no progress bars) - Add smart PATH handling: prefer ~/.local/bin symlink when available - Show version, location, and next steps in success message - Display actual install path from VITE_PLUS_INSTALL_DIR - Add test-install.yml workflow to test installers on all platforms
Use `napi build --use-napi-cross` instead of `cargo build` for Linux gnu targets to link against glibc 2.17, ensuring compatibility with older Linux distributions (Ubuntu 20.04+, Debian 10+, RHEL 8+). - Build Linux gnu targets with napi-cross toolchain - Add glibc version verification step for x86_64-linux - Test install script on Ubuntu 20.04 (oldest supported LTS)
The napi CLI is a devDependency, not globally available. Use `pnpm --filter=vite-plus exec napi` to run it from the package context.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The binary can now be used as a drop-in replacement for the Node.js
global CLI for package manager operations.
Verification Tests