Skip to content

feat(vp): refactor global cli to rust entry point#514

Merged
fengmk2 merged 47 commits intomainfrom
vite_global_cli_crate
Feb 7, 2026
Merged

feat(vp): refactor global cli to rust entry point#514
fengmk2 merged 47 commits intomainfrom
vite_global_cli_crate

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Jan 28, 2026

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

Verification Tests

@fengmk2 fengmk2 changed the title feat(global-cli): add vite_global_cli crate (Phase 1) feat(global-cli): add vite_global_cli crate Jan 28, 2026
Copy link
Copy Markdown
Member Author

fengmk2 commented Jan 28, 2026

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jan 28, 2026

Deploying vite-plus with  Cloudflare Pages  Cloudflare Pages

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

View logs

@fengmk2 fengmk2 force-pushed the vite_global_cli_crate branch from 8824030 to a9acd67 Compare January 28, 2026 08:56
@fengmk2 fengmk2 changed the title feat(global-cli): add vite_global_cli crate feat(vp): refactor global cli to rust entry point Jan 28, 2026
@fengmk2 fengmk2 force-pushed the vite_global_cli_crate branch from 499ea84 to c96424e Compare January 28, 2026 14:40
@fengmk2 fengmk2 added the test: install-e2e run vite install e2e test label Jan 28, 2026
@fengmk2 fengmk2 force-pushed the vite_global_cli_crate branch 2 times, most recently from b5aa8af to 22ea026 Compare January 29, 2026 04:06
@fengmk2 fengmk2 force-pushed the vite_shared branch 2 times, most recently from 59ab7cd to c6a1f1e Compare January 29, 2026 08:25
@fengmk2 fengmk2 changed the base branch from vite_shared to graphite-base/514 January 29, 2026 08:32
@fengmk2 fengmk2 force-pushed the vite_global_cli_crate branch from 4955d30 to 5f6b2ea Compare January 29, 2026 08:33
@graphite-app graphite-app Bot changed the base branch from graphite-base/514 to main January 29, 2026 08:34
@fengmk2 fengmk2 force-pushed the vite_global_cli_crate branch from 5f6b2ea to 23318e2 Compare January 29, 2026 08:34
@fengmk2 fengmk2 changed the base branch from main to graphite-base/514 January 29, 2026 09:51
@fengmk2 fengmk2 force-pushed the vite_global_cli_crate branch from 23318e2 to a213f27 Compare January 29, 2026 09:51
@fengmk2 fengmk2 changed the base branch from graphite-base/514 to improve-js-runtime January 29, 2026 09:51
@fengmk2 fengmk2 force-pushed the vite_global_cli_crate branch from a213f27 to 1750eb2 Compare January 29, 2026 10:15
@fengmk2 fengmk2 force-pushed the improve-js-runtime branch from 901823c to 256cd9b Compare January 29, 2026 10:15
@fengmk2 fengmk2 force-pushed the vite_global_cli_crate branch 5 times, most recently from 0afd672 to 485b520 Compare January 29, 2026 13:37
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: install-e2e run vite install e2e test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants