mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-13 04:14:56 +00:00
fix(desktop): improve Windows install script error handling
- SilentlyContinue progress preference (10x faster download) - try/catch on API + download calls with colored error messages - Non-fatal shortcut creation (works without admin) - Colored output for better UX
This commit is contained in:
1 parent
e5175a044a
commit
c2cb37afcf
1 file changed
+45
-22
+45
-22
@@ -1,4 +1,5 @@
|
||||
# GoClaw Lite (Desktop) installer for Windows
|
||||
#
|
||||
# Usage:
|
||||
# irm https://raw.githubusercontent.com/nextlevelbuilder/goclaw/main/scripts/install-lite.ps1 | iex
|
||||
# .\install-lite.ps1 -Version lite-v0.1.0
|
||||
@@ -6,52 +7,74 @@
|
||||
param([string]$Version = "")
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProgressPreference = "SilentlyContinue" # Speeds up Invoke-WebRequest significantly
|
||||
$Repo = "nextlevelbuilder/goclaw"
|
||||
$InstallDir = "$env:LOCALAPPDATA\GoClaw Lite"
|
||||
$InstallDir = Join-Path $env:LOCALAPPDATA "GoClaw Lite"
|
||||
|
||||
# Resolve latest version
|
||||
# ── Resolve version ──
|
||||
if (-not $Version) {
|
||||
Write-Host "-> Fetching latest desktop release..."
|
||||
$releases = Invoke-RestMethod "https://api.github.com/repos/$Repo/releases"
|
||||
Write-Host "-> Fetching latest desktop release..." -ForegroundColor Cyan
|
||||
try {
|
||||
$releases = Invoke-RestMethod "https://api.github.com/repos/$Repo/releases" -ErrorAction Stop
|
||||
} catch {
|
||||
Write-Host "Failed to fetch releases: $_" -ForegroundColor Red
|
||||
Write-Host "Check: https://github.com/$Repo/releases" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
$latest = $releases | Where-Object { $_.tag_name -like "lite-v*" -and -not $_.prerelease -and -not $_.draft } | Select-Object -First 1
|
||||
if (-not $latest) {
|
||||
Write-Error "No desktop release found. Check https://github.com/$Repo/releases"
|
||||
Write-Host "No desktop release found." -ForegroundColor Red
|
||||
Write-Host "Check: https://github.com/$Repo/releases" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
$Version = $latest.tag_name
|
||||
}
|
||||
|
||||
$Semver = $Version -replace "^lite-v", ""
|
||||
Write-Host "-> Installing GoClaw Lite v$Semver..."
|
||||
Write-Host "-> Installing GoClaw Lite v$Semver..." -ForegroundColor Cyan
|
||||
|
||||
# Download
|
||||
# ── Download ──
|
||||
$Asset = "goclaw-lite-$Semver-windows-amd64.zip"
|
||||
$Url = "https://github.com/$Repo/releases/download/$Version/$Asset"
|
||||
$TmpZip = Join-Path $env:TEMP $Asset
|
||||
|
||||
Write-Host "-> Downloading $Url..."
|
||||
Invoke-WebRequest -Uri $Url -OutFile $TmpZip -UseBasicParsing
|
||||
Write-Host "-> Downloading $Asset..."
|
||||
try {
|
||||
Invoke-WebRequest -Uri $Url -OutFile $TmpZip -UseBasicParsing -ErrorAction Stop
|
||||
} catch {
|
||||
Write-Host "Download failed: $_" -ForegroundColor Red
|
||||
Write-Host "URL: $Url" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Extract
|
||||
# ── Extract ──
|
||||
Write-Host "-> Installing to $InstallDir..."
|
||||
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
|
||||
Expand-Archive -Path $TmpZip -DestinationPath $InstallDir -Force
|
||||
Remove-Item $TmpZip -Force
|
||||
Remove-Item $TmpZip -Force -ErrorAction SilentlyContinue
|
||||
|
||||
# Create Start Menu shortcut
|
||||
# ── Create Start Menu shortcut ──
|
||||
$ExePath = Join-Path $InstallDir "goclaw-lite.exe"
|
||||
if (Test-Path $ExePath) {
|
||||
$ShortcutPath = Join-Path ([Environment]::GetFolderPath("StartMenu")) "Programs\GoClaw Lite.lnk"
|
||||
$Shell = New-Object -ComObject WScript.Shell
|
||||
$Shortcut = $Shell.CreateShortcut($ShortcutPath)
|
||||
$Shortcut.TargetPath = $ExePath
|
||||
$Shortcut.WorkingDirectory = $InstallDir
|
||||
$Shortcut.Save()
|
||||
Write-Host "-> Start Menu shortcut created"
|
||||
try {
|
||||
$StartMenu = [Environment]::GetFolderPath("StartMenu")
|
||||
$ShortcutPath = Join-Path $StartMenu "Programs\GoClaw Lite.lnk"
|
||||
$Shell = New-Object -ComObject WScript.Shell
|
||||
$Shortcut = $Shell.CreateShortcut($ShortcutPath)
|
||||
$Shortcut.TargetPath = $ExePath
|
||||
$Shortcut.WorkingDirectory = $InstallDir
|
||||
$Shortcut.Save()
|
||||
Write-Host "-> Start Menu shortcut created" -ForegroundColor Gray
|
||||
} catch {
|
||||
Write-Host "-> Could not create shortcut (non-fatal): $_" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
|
||||
# ── Done ──
|
||||
Write-Host ""
|
||||
Write-Host "GoClaw Lite v$Semver installed to $InstallDir" -ForegroundColor Green
|
||||
Write-Host "GoClaw Lite v$Semver installed!" -ForegroundColor Green
|
||||
Write-Host " Location: $InstallDir" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
Write-Host "To launch: Start Menu -> GoClaw Lite"
|
||||
Write-Host "Or run: & '$ExePath'"
|
||||
Write-Host "To launch:" -ForegroundColor White
|
||||
Write-Host " Start Menu -> GoClaw Lite"
|
||||
Write-Host " Or run: & '$ExePath'"
|
||||
Reference in new issue
Block a user