You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(cli): add `vp self-update` command
Implement `vp self-update` (alias: `vp upgrade`) that downloads and
installs a new vp CLI version from the npm registry with SHA-512
integrity verification.
Features:
- Version resolution from npm registry (latest, specific version, or dist-tag)
- Parallel download of platform binary + main JS package tarballs
- SHA-512 SRI integrity verification for both tarballs
- Atomic symlink swap on Unix, junction swap on Windows
- Production dependency installation via new binary
- Shim refresh after update
- Automatic cleanup of old versions (keeps 5 most recent)
- `--check` flag to check for updates without installing
- `--rollback` to revert to previous version
- `--force`, `--silent`, `--tag`, `--registry` flags
- Path traversal protection in tarball extraction
- Post-extraction validation of critical files
test(cli): add snap tests for `vp self-update` command
- Add self-update help to cli-helper-message snap test
- Add command-self-update-check test (--check flag and upgrade alias)
- Add command-self-update-rollback test (error when no previous version)
- Rename help section to "Maintenance Commands" for consistency
- Fix description alignment to match other sections
# --check queries npm registry and prints update status
482
+
vp self-update --check
483
+
# upgrade alias should also work
484
+
vp upgrade --check
485
+
486
+
# full self-update: download, extract, swap
487
+
vp self-update --tag test --force
488
+
vp --version
489
+
vp env doctor
490
+
491
+
Get-ChildItem "$env:USERPROFILE\.vite-plus\"
492
+
493
+
# Verify version changed after update
494
+
$updatedVersion = Get-CliVersion
495
+
Write-Host "Updated version: $updatedVersion"
496
+
if ($updatedVersion -eq $initialVersion) {
497
+
Write-Error "Error: version should have changed after self-update (still $initialVersion)"
498
+
exit 1
499
+
}
500
+
501
+
# rollback to the previous version
502
+
vp self-update --rollback
503
+
vp --version
504
+
vp env doctor
505
+
506
+
# Verify version restored after rollback
507
+
$rollbackVersion = Get-CliVersion
508
+
Write-Host "Rollback version: $rollbackVersion"
509
+
if ($rollbackVersion -ne $initialVersion) {
510
+
Write-Error "Error: version should have been restored after rollback (expected $initialVersion, got $rollbackVersion)"
511
+
exit 1
512
+
}
513
+
514
+
- name: Test self-update (cmd)
515
+
if: matrix.os == 'windows-latest'
516
+
shell: cmd
517
+
run: |
518
+
REM Save initial (dev build) version
519
+
for /f "usebackq delims=" %%v in (`node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'package.json')).version"`) do set INITIAL_VERSION=%%v
520
+
echo Initial version: %INITIAL_VERSION%
521
+
522
+
REM --check queries npm registry and prints update status
523
+
vp self-update --check
524
+
REM upgrade alias should also work
525
+
vp upgrade --check
526
+
527
+
REM full self-update: download, extract, swap
528
+
vp self-update --tag test --force
529
+
vp --version
530
+
vp env doctor
531
+
532
+
dir "%USERPROFILE%\.vite-plus\"
533
+
534
+
REM Verify version changed after update
535
+
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
536
+
echo Updated version: %UPDATED_VERSION%
537
+
if "%UPDATED_VERSION%"=="%INITIAL_VERSION%" (
538
+
echo Error: version should have changed after self-update, still %INITIAL_VERSION%
539
+
exit /b 1
540
+
)
541
+
542
+
REM rollback to the previous version
543
+
vp self-update --rollback
544
+
vp --version
545
+
vp env doctor
546
+
547
+
REM Verify version restored after rollback
548
+
for /f "usebackq delims=" %%v in (`node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'package.json')).version"`) do set ROLLBACK_VERSION=%%v
549
+
echo Rollback version: %ROLLBACK_VERSION%
550
+
if not "%ROLLBACK_VERSION%"=="%INITIAL_VERSION%" (
551
+
echo Error: version should have been restored after rollback, expected %INITIAL_VERSION%, got %ROLLBACK_VERSION%
552
+
exit /b 1
553
+
)
554
+
364
555
install-e2e-test:
365
556
name: Local CLI `vite install` E2E test
366
557
needs:
@@ -398,7 +589,7 @@ jobs:
398
589
- name: Build CLI
399
590
run: |
400
591
pnpm bootstrap-cli:ci
401
-
echo "$HOME/.vite-plus-dev/bin" >> $GITHUB_PATH
592
+
echo "$HOME/.vite-plus/bin" >> $GITHUB_PATH
402
593
403
594
- name: Run local CLI `vite install`
404
595
run: |
@@ -440,6 +631,7 @@ jobs:
440
631
- lint
441
632
- run
442
633
- cli-e2e-test
634
+
- cli-self-update
443
635
steps:
444
636
- run: exit 1
445
637
# Thank you, next https://github.com/vercel/next.js/blob/canary/.github/workflows/build_and_test.yml#L379
0 commit comments