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
2 changes: 1 addition & 1 deletion crates/vite_setup/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub mod platform;
pub mod registry;

/// Maximum number of old versions to keep.
pub const MAX_VERSIONS_KEEP: usize = 5;
pub const MAX_VERSIONS_KEEP: usize = 3;

/// Platform-specific binary name for the `vp` CLI.
pub const VP_BINARY_NAME: &str = if cfg!(windows) { "vp.exe" } else { "vp" };
13 changes: 12 additions & 1 deletion docs/guide/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@ You can upgrade both of them independently.
## Global `vp`

```bash
vp upgrade
vp upgrade # upgrade to the latest version
vp upgrade --check # check for updates without installing
```

### Rollback

Vite+ keeps the **3 most recent** versions installed so you can revert quickly:

```bash
vp upgrade --rollback
```

Older versions are pruned automatically after each upgrade. The active version and the previous version are always kept, so a rollback target is never removed.

## Local `vite-plus`

Update the project dependency with the package manager commands in Vite+:
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function Download-AndExtract {
function Cleanup-OldVersions {
param([string]$InstallDir)

$maxVersions = 5
$maxVersions = 3
# Only cleanup semver format directories (0.1.0, 1.2.3-beta.1, etc.)
# This excludes 'current' symlink and non-semver directories like 'local-dev'
$semverPattern = '^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ setup_node_manager() {

# Cleanup old versions, keeping only the most recent ones
cleanup_old_versions() {
local max_versions=5
local max_versions=3
local versions=()

# List version directories (semver format like 0.1.0, 1.2.3-beta.1, 0.0.0-f48af939.20260205-0533)
Expand Down
6 changes: 3 additions & 3 deletions rfcs/global-cli-rust-binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ main_url="${NPM_REGISTRY}/vite-plus-cli/-/vite-plus-cli-${VITE_PLUS_VERSION}.tgz
# Create/update current symlink
ln -sfn "$VITE_PLUS_VERSION" "$CURRENT_LINK"

# Cleanup old versions (keep max 5)
# Cleanup old versions (keep max 3)
cleanup_old_versions

# Add ~/.vite-plus/current/bin to PATH
Expand Down Expand Up @@ -803,7 +803,7 @@ if (Test-Path $CurrentLink) {
}
cmd /c mklink /J "$CurrentLink" "$VersionDir" | Out-Null

# Cleanup old versions (keep max 5)
# Cleanup old versions (keep max 3)
Cleanup-OldVersions -InstallDir $InstallDir

# Add $InstallDir\current\bin to user PATH
Expand Down Expand Up @@ -853,7 +853,7 @@ The installer supports multiple versions with symlinks, allowing version switchi

- PATH points to `~/.vite-plus/current/bin` (stable location)
- Installing a new version updates the `current` symlink
- Old versions are automatically cleaned up (keeps max 5 versions)
- Old versions are automatically cleaned up (keeps max 3 versions)

#### How the Rust Binary Uses JS Scripts

Expand Down
16 changes: 8 additions & 8 deletions rfcs/upgrade-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Key invariant: `~/.vite-plus/bin/vp` is a symlink to `../current/bin/vp` (Unix)
1. Provide a fast, reliable `vp upgrade` command that upgrades the CLI to the latest (or specified) version
2. Reuse the same npm-based distribution channel (no new infrastructure)
3. Support atomic upgrades with automatic rollback on failure
4. Keep the last 5 versions for manual rollback
4. Keep the last 3 versions for manual rollback
5. Support version pinning and channel selection (latest, test)

## Non-Goals
Expand Down Expand Up @@ -161,7 +161,7 @@ The upgrade command is implemented entirely in Rust within the `vite_global_cli`
│ 6. Install production dependencies │
│ 7. Atomic swap: current → {version} │
│ 8. Refresh shims (non-fatal) │
│ 9. Cleanup old versions (non-fatal, keep 5) │
│ 9. Cleanup old versions (non-fatal, keep 3) │
└─────────────────────────────────────────────────┘
```

Expand Down Expand Up @@ -303,7 +303,7 @@ Key differences on Windows:
After the symlink swap (the **point of no return**), post-update operations are treated as non-fatal. Errors are printed to stderr as warnings but do not trigger the outer error handler (which would delete the now-active version directory).

1. **Refresh shims**: Run the equivalent of `vp env setup --refresh` to ensure node/npm/npx shims point to the new version. This also refreshes trampoline `.exe` files for globally installed package shims (e.g., `corepack.exe`, `tsc.exe`) by scanning `BinConfig` entries. If this fails, the user can run it manually.
2. **Cleanup old versions**: Remove old version directories, keeping the 5 most recent by **creation time** (matching `install.sh` behavior). The new version and the previous version are always protected from cleanup, even if they fall outside the top 5 (e.g., after a downgrade via `--rollback`).
2. **Cleanup old versions**: Remove old version directories, keeping the 3 most recent by **creation time** (matching `install.sh` behavior). The new version and the previous version are always protected from cleanup, even if they fall outside the top 3 (e.g., after a downgrade via `--rollback`).

#### Step 7: Running Binary Consideration

Expand Down Expand Up @@ -501,15 +501,15 @@ Upgrade {
- Users can opt into periodic checks via their own cron/launchd if desired
- This can be revisited as a future enhancement with proper opt-in

### 5. Keep 5 Versions for Rollback
### 5. Keep 3 Versions for Rollback

**Decision**: Maintain the same cleanup policy as `install.sh` (keep 5 most recent versions by creation time, with protected versions).
**Decision**: Maintain the same cleanup policy as `install.sh` (keep 3 most recent versions by creation time, with protected versions).

**Rationale**:

- Consistent with existing `install.sh` behavior (sorts by creation time, not semver)
- Provides rollback safety net without unbounded disk usage
- Each version is ~20-30MB, so 5 versions is ~100-150MB total
- Each version is ~20-30MB, so 3 versions is ~60-90MB total
- The active version and previous version are always protected from cleanup, preventing accidental deletion after a downgrade

## Implementation Phases
Expand All @@ -522,7 +522,7 @@ Upgrade {
- `vp upgrade <version>` — installs a specific version
- `--tag`, `--force`, `--silent` flags
- Platform detection, npm registry query, download, extract, symlink swap
- Version cleanup (keep 5)
- Version cleanup (keep 3)
- Error handling with clean rollback

**Files to create/modify:**
Expand All @@ -542,7 +542,7 @@ Upgrade {
- [ ] Downloaded tarballs are verified against npm registry `integrity` (SHA-512)
- [ ] Running binary is not affected during update
- [ ] Failed update leaves the current installation untouched
- [ ] Old versions are cleaned up (max 5 retained)
- [ ] Old versions are cleaned up (max 3 retained)
- [ ] Works on macOS, Linux, and Windows

### Phase 1 (P1): Rollback and Check
Expand Down
2 changes: 1 addition & 1 deletion rfcs/windows-installer.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ The installer replicates the same result as `install.ps1`, implemented in Rust v
│ │ (junction on Windows, │
│ │ atomic symlink on Unix) │
│ │ │
│ └─ cleanup old versions ── keep last 5 by creation time │
│ └─ cleanup old versions ── keep last 3 by creation time │
│ protects new + previous version │
└─────────────────────────────────────────────────────────────┘
Expand Down
Loading