Skip to content

Commit b5ba31f

Browse files
authored
refactor: rename self-update command to upgrade (#565)
## Summary Rename the `vp self-update` command to `vp upgrade`. No alias is kept for `self-update`. ## Changes - **Command**: `vp self-update` → `vp upgrade` - **Module**: `commands/self_update/` → `commands/upgrade/` - **Types**: `SelfUpdateOptions` → `UpgradeOptions`, `Error::SelfUpdate` → `Error::Upgrade` - **CI**: Updated all workflow files (`ci.yml`, `test-standalone-install.yml`) - **Snap tests**: Renamed and updated all affected snap tests - **RFC**: Renamed `self-update-command.md` → `upgrade-command.md` - **Messages**: `Run \`vp upgrade\` to update.` ## Breaking Change `vp self-update` no longer works. Users must use `vp upgrade` instead.
1 parent 20c168a commit b5ba31f

22 files changed

Lines changed: 129 additions & 145 deletions

File tree

.github/workflows/ci.yml

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ jobs:
361361
RUST_BACKTRACE=1 pnpm test
362362
git diff --exit-code
363363
364-
# Self-update tests (merged from separate job to avoid duplicate build)
365-
- name: Test self-update (bash)
364+
# Upgrade tests (merged from separate job to avoid duplicate build)
365+
- name: Test upgrade (bash)
366366
shell: bash
367367
run: |
368368
# Helper to read the installed CLI version from package.json
@@ -375,12 +375,10 @@ jobs:
375375
echo "Initial version: $INITIAL_VERSION"
376376
377377
# --check queries npm registry and prints update status
378-
vp self-update --check
379-
# upgrade alias should also work
380378
vp upgrade --check
381379
382-
# full self-update: download, extract, swap
383-
vp self-update --tag test --force
380+
# full upgrade: download, extract, swap
381+
vp upgrade --tag test --force
384382
vp --version
385383
vp env doctor
386384
@@ -390,12 +388,12 @@ jobs:
390388
UPDATED_VERSION=$(get_cli_version)
391389
echo "Updated version: $UPDATED_VERSION"
392390
if [ "$UPDATED_VERSION" == "$INITIAL_VERSION" ]; then
393-
echo "Error: version should have changed after self-update (still $INITIAL_VERSION)"
391+
echo "Error: version should have changed after upgrade (still $INITIAL_VERSION)"
394392
exit 1
395393
fi
396394
397395
# rollback to the previous version
398-
vp self-update --rollback
396+
vp upgrade --rollback
399397
vp --version
400398
vp env doctor
401399
@@ -407,7 +405,7 @@ jobs:
407405
exit 1
408406
fi
409407
410-
- name: Test self-update (powershell)
408+
- name: Test upgrade (powershell)
411409
if: ${{ matrix.os == 'windows-latest' }}
412410
shell: pwsh
413411
run: |
@@ -423,12 +421,10 @@ jobs:
423421
Write-Host "Initial version: $initialVersion"
424422
425423
# --check queries npm registry and prints update status
426-
vp self-update --check
427-
# upgrade alias should also work
428424
vp upgrade --check
429425
430-
# full self-update: download, extract, swap
431-
vp self-update --tag test --force
426+
# full upgrade: download, extract, swap
427+
vp upgrade --tag test --force
432428
vp --version
433429
vp env doctor
434430
@@ -438,12 +434,12 @@ jobs:
438434
$updatedVersion = Get-CliVersion
439435
Write-Host "Updated version: $updatedVersion"
440436
if ($updatedVersion -eq $initialVersion) {
441-
Write-Error "Error: version should have changed after self-update (still $initialVersion)"
437+
Write-Error "Error: version should have changed after upgrade (still $initialVersion)"
442438
exit 1
443439
}
444440
445441
# rollback to the previous version
446-
vp self-update --rollback
442+
vp upgrade --rollback
447443
vp --version
448444
vp env doctor
449445
@@ -455,7 +451,7 @@ jobs:
455451
exit 1
456452
}
457453
458-
- name: Test self-update (cmd)
454+
- name: Test upgrade (cmd)
459455
if: ${{ matrix.os == 'windows-latest' }}
460456
shell: cmd
461457
run: |
@@ -464,12 +460,10 @@ jobs:
464460
echo Initial version: %INITIAL_VERSION%
465461
466462
REM --check queries npm registry and prints update status
467-
vp self-update --check
468-
REM upgrade alias should also work
469463
vp upgrade --check
470464
471-
REM full self-update: download, extract, swap
472-
vp self-update --tag test --force
465+
REM full upgrade: download, extract, swap
466+
vp upgrade --tag test --force
473467
vp --version
474468
vp env doctor
475469
@@ -479,12 +473,12 @@ jobs:
479473
for /f "usebackq delims=" %%v in (`node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'package.json')).version"`) do set UPDATED_VERSION=%%v
480474
echo Updated version: %UPDATED_VERSION%
481475
if "%UPDATED_VERSION%"=="%INITIAL_VERSION%" (
482-
echo Error: version should have changed after self-update, still %INITIAL_VERSION%
476+
echo Error: version should have changed after upgrade, still %INITIAL_VERSION%
483477
exit /b 1
484478
)
485479
486480
REM rollback to the previous version
487-
vp self-update --rollback
481+
vp upgrade --rollback
488482
vp --version
489483
vp env doctor
490484

.github/workflows/test-standalone-install.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ jobs:
103103
which npx
104104
which vp
105105
106-
- name: Verify self-update
106+
- name: Verify upgrade
107107
run: |
108108
# --check queries npm registry and prints update status
109-
vp self-update --check
110-
vp self-update 0.0.0-b356849c.20260207-0631
109+
vp upgrade --check
110+
vp upgrade 0.0.0-b356849c.20260207-0631
111111
vp --version
112112
# rollback to the previous version (should succeed after a real update)
113-
vp self-update --rollback
113+
vp upgrade --rollback
114114
vp --version
115115
116116
test-install-sh-arm64:
@@ -165,11 +165,11 @@ jobs:
165165
export VITE_LOG=trace
166166
vp env run --node 24 -- node -p \"process.versions\"
167167
168-
# Verify self-update
169-
vp self-update --check
170-
vp self-update 0.0.0-b356849c.20260207-0631
168+
# Verify upgrade
169+
vp upgrade --check
170+
vp upgrade 0.0.0-b356849c.20260207-0631
171171
vp --version
172-
vp self-update --rollback
172+
vp upgrade --rollback
173173
vp --version
174174
175175
# FIXME: qemu: uncaught target signal 11 (Segmentation fault) - core dumped
@@ -197,15 +197,15 @@ jobs:
197197
run: |
198198
echo "$USERPROFILE\.vite-plus\bin" >> $GITHUB_PATH
199199
200-
- name: Verify self-update
200+
- name: Verify upgrade
201201
shell: pwsh
202202
run: |
203203
# --check queries npm registry and prints update status
204-
vp self-update --check
205-
vp self-update 0.0.0-b356849c.20260207-0631
204+
vp upgrade --check
205+
vp upgrade 0.0.0-b356849c.20260207-0631
206206
vp --version
207207
# rollback to the previous version (should succeed after a real update)
208-
vp self-update --rollback
208+
vp upgrade --rollback
209209
vp --version
210210
211211
- name: Verify installation on powershell

crates/vite_global_cli/src/cli.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,8 @@ pub enum Commands {
593593
// Self-Management
594594
// =========================================================================
595595
/// Update vp itself to the latest version
596-
#[command(name = "self-update", visible_alias = "upgrade")]
597-
SelfUpdate {
596+
#[command(name = "upgrade")]
597+
Upgrade {
598598
/// Target version (e.g., "0.2.0"). Defaults to latest.
599599
version: Option<String>,
600600

@@ -1548,8 +1548,8 @@ pub async fn run_command(cwd: AbsolutePathBuf, args: Args) -> Result<ExitStatus,
15481548
Commands::Env(args) => commands::env::execute(cwd, args).await,
15491549

15501550
// Self-Management
1551-
Commands::SelfUpdate { version, tag, check, rollback, force, silent, registry } => {
1552-
commands::self_update::execute(commands::self_update::SelfUpdateOptions {
1551+
Commands::Upgrade { version, tag, check, rollback, force, silent, registry } => {
1552+
commands::upgrade::execute(commands::upgrade::UpgradeOptions {
15531553
version,
15541554
tag,
15551555
check,
@@ -1619,7 +1619,7 @@ fn apply_custom_help(cmd: clap::Command) -> clap::Command {
16191619
{bold}why, explain{reset} Show why a package is installed
16201620
16211621
{bold_underline}Maintenance Commands:{reset}
1622-
{bold}self-update, upgrade{reset} Update vp itself to the latest version
1622+
{bold}upgrade{reset} Update vp itself to the latest version
16231623
"
16241624
);
16251625
let help_template = format!(

crates/vite_global_cli/src/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pub mod version;
140140
pub mod env;
141141

142142
// Self-Management
143-
pub mod self_update;
143+
pub mod upgrade;
144144

145145
// Category C: Local CLI Delegation
146146
pub mod delegate;

crates/vite_global_cli/src/commands/self_update/install.rs renamed to crates/vite_global_cli/src/commands/upgrade/install.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Installation logic for self-update.
1+
//! Installation logic for upgrade.
22
//!
33
//! Handles tarball extraction, dependency installation, symlink swapping,
44
//! and version cleanup.
@@ -92,7 +92,7 @@ pub async fn extract_platform_package(
9292
Ok::<(), Error>(())
9393
})
9494
.await
95-
.map_err(|e| Error::SelfUpdate(format!("Task join error: {e}").into()))??;
95+
.map_err(|e| Error::Upgrade(format!("Task join error: {e}").into()))??;
9696

9797
Ok(())
9898
}
@@ -159,7 +159,7 @@ pub async fn extract_main_package(
159159
Ok::<(), Error>(())
160160
})
161161
.await
162-
.map_err(|e| Error::SelfUpdate(format!("Task join error: {e}").into()))??;
162+
.map_err(|e| Error::Upgrade(format!("Task join error: {e}").into()))??;
163163

164164
Ok(())
165165
}
@@ -193,7 +193,7 @@ pub async fn install_production_deps(version_dir: &AbsolutePath) -> Result<(), E
193193
let vp_binary = version_dir.join("bin").join(if cfg!(windows) { "vp.exe" } else { "vp" });
194194

195195
if !tokio::fs::try_exists(&vp_binary).await.unwrap_or(false) {
196-
return Err(Error::SelfUpdate(
196+
return Err(Error::Upgrade(
197197
format!("New binary not found at {}", vp_binary.as_path().display()).into(),
198198
));
199199
}
@@ -209,7 +209,7 @@ pub async fn install_production_deps(version_dir: &AbsolutePath) -> Result<(), E
209209

210210
if !output.status.success() {
211211
let stderr = String::from_utf8_lossy(&output.stderr);
212-
return Err(Error::SelfUpdate(
212+
return Err(Error::Upgrade(
213213
format!(
214214
"Failed to install production dependencies (exit code: {})\n{}",
215215
output.status.code().unwrap_or(-1),
@@ -254,7 +254,7 @@ pub async fn swap_current_link(install_dir: &AbsolutePath, version: &str) -> Res
254254

255255
// Verify the version directory exists
256256
if !tokio::fs::try_exists(&version_dir).await.unwrap_or(false) {
257-
return Err(Error::SelfUpdate(
257+
return Err(Error::Upgrade(
258258
format!("Version directory does not exist: {}", version_dir.as_path().display()).into(),
259259
));
260260
}
@@ -282,7 +282,7 @@ pub async fn swap_current_link(install_dir: &AbsolutePath, version: &str) -> Res
282282
if let Err(e) = std::fs::remove_dir(&current_link) {
283283
tracing::debug!("remove_dir failed ({}), trying junction::delete", e);
284284
junction::delete(&current_link).map_err(|e| {
285-
Error::SelfUpdate(
285+
Error::Upgrade(
286286
format!(
287287
"Failed to remove existing junction at {}: {e}",
288288
current_link.as_path().display()
@@ -294,7 +294,7 @@ pub async fn swap_current_link(install_dir: &AbsolutePath, version: &str) -> Res
294294
}
295295

296296
junction::create(&version_dir, &current_link).map_err(|e| {
297-
Error::SelfUpdate(
297+
Error::Upgrade(
298298
format!(
299299
"Failed to create junction at {}: {e}\nTry removing it manually and run again.",
300300
current_link.as_path().display()
@@ -365,9 +365,7 @@ pub async fn cleanup_old_versions(
365365
metadata.modified().unwrap_or(std::time::SystemTime::UNIX_EPOCH)
366366
});
367367
let path = AbsolutePathBuf::new(entry.path()).ok_or_else(|| {
368-
Error::SelfUpdate(
369-
format!("Invalid absolute path: {}", entry.path().display()).into(),
370-
)
368+
Error::Upgrade(format!("Invalid absolute path: {}", entry.path().display()).into())
371369
})?;
372370
versions.push((time, path));
373371
}
@@ -496,7 +494,7 @@ mod tests {
496494
// Verifies that cleanup_old_versions propagates errors on non-existent dir.
497495
// In the real flow, such errors from post-swap operations should be non-fatal.
498496
let non_existent =
499-
AbsolutePathBuf::new(std::env::temp_dir().join("non-existent-self-update-test-dir"))
497+
AbsolutePathBuf::new(std::env::temp_dir().join("non-existent-upgrade-test-dir"))
500498
.unwrap();
501499
let result = cleanup_old_versions(&non_existent, 5, &[]).await;
502500
assert!(result.is_err(), "cleanup_old_versions should error on non-existent dir");

crates/vite_global_cli/src/commands/self_update/integrity.rs renamed to crates/vite_global_cli/src/commands/upgrade/integrity.rs

File renamed without changes.

crates/vite_global_cli/src/commands/self_update/mod.rs renamed to crates/vite_global_cli/src/commands/upgrade/mod.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Self-update command for the vp CLI.
1+
//! Upgrade command for the vp CLI.
22
//!
33
//! Downloads and installs a new version of the CLI from the npm registry
44
//! with SHA-512 integrity verification.
@@ -16,8 +16,8 @@ use vite_path::AbsolutePathBuf;
1616

1717
use crate::{commands::env::config::get_vite_plus_home, error::Error};
1818

19-
/// Options for the self-update command.
20-
pub struct SelfUpdateOptions {
19+
/// Options for the upgrade command.
20+
pub struct UpgradeOptions {
2121
/// Target version (e.g., "0.2.0"). None means use the tag.
2222
pub version: Option<String>,
2323
/// npm dist-tag (default: "latest")
@@ -37,9 +37,9 @@ pub struct SelfUpdateOptions {
3737
/// Maximum number of old versions to keep.
3838
const MAX_VERSIONS_KEEP: usize = 5;
3939

40-
/// Execute the self-update command.
40+
/// Execute the upgrade command.
4141
#[allow(clippy::print_stdout, clippy::print_stderr)]
42-
pub async fn execute(options: SelfUpdateOptions) -> Result<ExitStatus, Error> {
42+
pub async fn execute(options: UpgradeOptions) -> Result<ExitStatus, Error> {
4343
let install_dir = get_vite_plus_home()?;
4444

4545
// Handle --rollback
@@ -75,7 +75,7 @@ pub async fn execute(options: SelfUpdateOptions) -> Result<ExitStatus, Error> {
7575
println!("\n{} Already up to date ({})", "\u{2714}".green(), current_version);
7676
} else {
7777
println!("Update available: {} \u{2192} {}", current_version, resolved.version);
78-
println!("Run `vp self-update` to update.");
78+
println!("Run `vp upgrade` to update.");
7979
}
8080
return Ok(ExitStatus::default());
8181
}
@@ -101,13 +101,14 @@ pub async fn execute(options: SelfUpdateOptions) -> Result<ExitStatus, Error> {
101101
let (platform_data, main_data) = tokio::try_join!(
102102
async {
103103
client.get_bytes(&resolved.platform_tarball_url).await.map_err(|e| {
104-
Error::SelfUpdate(format!("Failed to download platform package: {e}").into())
104+
Error::Upgrade(format!("Failed to download platform package: {e}").into())
105105
})
106106
},
107107
async {
108-
client.get_bytes(&resolved.main_tarball_url).await.map_err(|e| {
109-
Error::SelfUpdate(format!("Failed to download main package: {e}").into())
110-
})
108+
client
109+
.get_bytes(&resolved.main_tarball_url)
110+
.await
111+
.map_err(|e| Error::Upgrade(format!("Failed to download main package: {e}").into()))
111112
},
112113
)?;
113114

@@ -165,13 +166,13 @@ async fn install_platform_and_main(
165166
let binary_name = if cfg!(windows) { "vp.exe" } else { "vp" };
166167
let binary_path = version_dir.join("bin").join(binary_name);
167168
if !tokio::fs::try_exists(&binary_path).await.unwrap_or(false) {
168-
return Err(Error::SelfUpdate(
169+
return Err(Error::Upgrade(
169170
"Binary not found after extraction. The download may be corrupted.".into(),
170171
));
171172
}
172173
let package_json_path = version_dir.join("package.json");
173174
if !tokio::fs::try_exists(&package_json_path).await.unwrap_or(false) {
174-
return Err(Error::SelfUpdate(
175+
return Err(Error::Upgrade(
175176
"package.json not found after extraction. The download may be corrupted.".into(),
176177
));
177178
}
@@ -227,12 +228,12 @@ async fn execute_rollback(
227228
) -> Result<ExitStatus, Error> {
228229
let previous = install::read_previous_version(install_dir)
229230
.await?
230-
.ok_or_else(|| Error::SelfUpdate("No previous version found. Cannot rollback.".into()))?;
231+
.ok_or_else(|| Error::Upgrade("No previous version found. Cannot rollback.".into()))?;
231232

232233
// Verify the version directory still exists
233234
let prev_dir = install_dir.join(&previous);
234235
if !tokio::fs::try_exists(&prev_dir).await.unwrap_or(false) {
235-
return Err(Error::SelfUpdate(
236+
return Err(Error::Upgrade(
236237
format!("Previous version directory ({}) no longer exists. Cannot rollback.", previous)
237238
.into(),
238239
));

0 commit comments

Comments
 (0)