Skip to content

Commit f8668d9

Browse files
committed
feat(install): streamline installation output for cleaner UX
- 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
1 parent 91760c6 commit f8668d9

4 files changed

Lines changed: 196 additions & 93 deletions

File tree

.github/workflows/test-install.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Test Install Scripts
2+
3+
permissions: {}
4+
5+
on:
6+
workflow_dispatch:
7+
pull_request:
8+
paths:
9+
- 'packages/global/install.sh'
10+
- 'packages/global/install.ps1'
11+
- '.github/workflows/test-install.yml'
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
15+
cancel-in-progress: true
16+
17+
defaults:
18+
run:
19+
shell: bash
20+
21+
jobs:
22+
test-install-sh:
23+
name: Test install.sh (${{ matrix.name }})
24+
runs-on: ${{ matrix.os }}
25+
permissions:
26+
contents: read
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
include:
31+
- os: ubuntu-latest
32+
name: Linux x64 glibc
33+
- os: namespace-profile-mac-default
34+
name: macOS ARM64
35+
steps:
36+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
37+
38+
- name: Run install.sh
39+
env:
40+
VITE_PLUS_VERSION: test
41+
run: bash packages/global/install.sh
42+
43+
- name: Verify installation
44+
run: |
45+
# Source shell config to get PATH updated
46+
source ~/.zshrc 2>/dev/null || source ~/.bashrc 2>/dev/null || true
47+
# Also check if symlink was created in ~/.local/bin
48+
export PATH="$HOME/.local/bin:$HOME/.vite-plus/current/bin:$PATH"
49+
vp --version
50+
vp --help
51+
52+
test-install-ps1:
53+
name: Test install.ps1 (Windows x64)
54+
runs-on: windows-latest
55+
permissions:
56+
contents: read
57+
steps:
58+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
59+
60+
- name: Run install.ps1
61+
shell: pwsh
62+
env:
63+
VITE_PLUS_VERSION: test
64+
run: |
65+
& ./packages/global/install.ps1
66+
67+
- name: Verify installation
68+
shell: pwsh
69+
run: |
70+
# Refresh PATH from environment
71+
$env:Path = "$env:USERPROFILE\.vite-plus\current\bin;$env:Path"
72+
vp --version
73+
vp --help

crates/vite_global_cli/src/js_executor.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ impl JsExecutor {
5757
// JS scripts are at ../dist relative to bin/
5858
// e.g., packages/global/bin/vp -> packages/global/dist/
5959
let exe_path = std::env::current_exe().map_err(|_| Error::JsScriptsDirNotFound)?;
60+
// Resolve symlinks to get the real binary path (Unix only)
61+
// This is important when vp is symlinked from ~/.local/bin/vp
62+
// Skip on Windows to avoid path resolution issues
63+
#[cfg(unix)]
64+
let exe_path = std::fs::canonicalize(&exe_path).map_err(|_| Error::JsScriptsDirNotFound)?;
6065
let bin_dir = exe_path.parent().ok_or(Error::JsScriptsDirNotFound)?;
6166
let package_dir = bin_dir.parent().ok_or(Error::JsScriptsDirNotFound)?;
6267
let scripts_dir = package_dir.join("dist");

packages/global/install.ps1

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ function Download-AndExtract {
140140

141141
$tempFile = New-TemporaryFile
142142
try {
143-
# Progress bar is shown by default with Invoke-WebRequest
143+
# Suppress progress bar for cleaner output
144+
$ProgressPreference = 'SilentlyContinue'
144145
Invoke-WebRequest -Uri $Url -OutFile $tempFile
145146

146147
# Create temp extraction directory
@@ -179,24 +180,24 @@ function Cleanup-OldVersions {
179180
Select-Object -First ($versions.Count - $maxVersions)
180181

181182
foreach ($old in $toDelete) {
182-
Write-Info "Removing old version: $($old.Name)"
183+
# Remove silently
183184
Remove-Item -Path $old.FullName -Recurse -Force
184185
}
185186
}
186187

187188
function Main {
188189
Write-Host ""
189-
Write-Host " VITE+(⚡︎) Installer"
190+
Write-Host "Setting up VITE+(⚡︎)..."
190191
Write-Host ""
191192

193+
# Suppress progress bars for cleaner output
194+
$ProgressPreference = 'SilentlyContinue'
195+
192196
$arch = Get-Architecture
193197
$platform = "win32-$arch"
194-
Write-Info "Detected platform: $platform"
195198

196199
# Fetch package metadata and resolve version
197-
Write-Info "Fetching package metadata..."
198200
$ViteVersion = Get-VersionFromMetadata
199-
Write-Info "Installing vite-plus-cli v$ViteVersion"
200201

201202
# Set up version-specific directories
202203
$VersionDir = "$InstallDir\$ViteVersion"
@@ -215,11 +216,9 @@ function Main {
215216

216217
# Download and extract native binary and .node files from platform package
217218
$platformUrl = "$NpmRegistry/$packageName/-/vite-plus-cli-$packageSuffix-$ViteVersion.tgz"
218-
Write-Info "Downloading platform package..."
219219

220220
$platformTempFile = New-TemporaryFile
221221
try {
222-
# Progress bar is shown by default with Invoke-WebRequest
223222
Invoke-WebRequest -Uri $platformUrl -OutFile $platformTempFile
224223

225224
# Create temp extraction directory
@@ -252,11 +251,9 @@ function Main {
252251

253252
# Download and extract JS bundle
254253
$mainUrl = "$NpmRegistry/vite-plus-cli/-/vite-plus-cli-$ViteVersion.tgz"
255-
Write-Info "Downloading JS scripts..."
256254

257255
$mainTempFile = New-TemporaryFile
258256
try {
259-
# Progress bar is shown by default with Invoke-WebRequest
260257
Invoke-WebRequest -Uri $mainUrl -OutFile $mainTempFile
261258

262259
# Create temp extraction directory
@@ -289,7 +286,6 @@ function Main {
289286
$pkg | ConvertTo-Json -Depth 10 | Set-Content $pkgFile
290287

291288
# Install production dependencies
292-
Write-Info "Installing dependencies..."
293289
Push-Location $VersionDir
294290
try {
295291
$env:CI = "true"
@@ -310,10 +306,7 @@ function Main {
310306
# Cleanup old versions
311307
Cleanup-OldVersions -InstallDir $InstallDir
312308

313-
Write-Success "Vite+ CLI installed to $VersionDir"
314-
315309
# Update PATH
316-
Write-Host ""
317310
$pathToAdd = "$InstallDir\current\bin"
318311
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
319312

@@ -327,19 +320,28 @@ function Main {
327320
$newPath = "$pathToAdd;$userPath"
328321
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
329322
$env:Path = "$pathToAdd;$env:Path"
330-
Write-Success "PATH has been updated"
331-
Write-Host ""
332-
Write-Host " Restart your terminal to use vp, or run:"
333-
Write-Host ""
334-
Write-Host " `$env:Path = `"$pathToAdd;`$env:Path`""
335-
} else {
336-
Write-Info "PATH already contains $pathToAdd"
337323
}
338324

325+
# Print success message
326+
Write-Host ""
327+
Write-Host "" -ForegroundColor Green -NoNewline
328+
Write-Host "VITE+(⚡︎) successfully installed!"
339329
Write-Host ""
340-
Write-Host " Then run:"
330+
Write-Host " Version: $ViteVersion"
341331
Write-Host ""
342-
Write-Host " vp --version"
332+
# Use ~ shorthand if install dir is under USERPROFILE, otherwise show full path
333+
$displayDir = $InstallDir -replace [regex]::Escape($env:USERPROFILE), '~'
334+
Write-Host " Location: $displayDir\current\bin"
335+
Write-Host ""
336+
Write-Host " Next: Run vp --help to get started"
337+
338+
# Show note if PATH was updated
339+
if ($needsPathUpdate) {
340+
Write-Host ""
341+
Write-Host " Note: Restart your terminal or run:"
342+
Write-Host " `$env:Path = `"$pathToAdd;`$env:Path`""
343+
}
344+
343345
Write-Host ""
344346
}
345347

0 commit comments

Comments
 (0)