fix ps1 giving errors with emojis

This commit is contained in:
Dillon DuPont
2025-11-14 15:31:24 -05:00
parent 45349b4b1b
commit 60b7f07c3e

View File

@@ -2,11 +2,11 @@
$ErrorActionPreference = "Stop"
function Install-WithBun {
Write-Host "📦 Installing CUA CLI using Bun..." -ForegroundColor Yellow
Write-Host "Installing CUA CLI using Bun..." -ForegroundColor Yellow
# Check if bun is already installed
if (-not (Get-Command bun -ErrorAction SilentlyContinue)) {
Write-Host "📦 Installing Bun..." -ForegroundColor Yellow
Write-Host "Installing Bun..." -ForegroundColor Yellow
try {
powershell -c "irm bun.sh/install.ps1|iex"
@@ -19,14 +19,14 @@ function Install-WithBun {
$env:Path = "$bunPath;$env:Path"
}
} catch {
Write-Host " Failed to install Bun. Please install manually from https://bun.sh" -ForegroundColor Red
Write-Host "Error: Failed to install Bun. Please install manually from https://bun.sh" -ForegroundColor Red
return $false
}
}
# Verify bun installation
if (-not (Get-Command bun -ErrorAction SilentlyContinue)) {
Write-Host " Bun installation failed. Please install manually from https://bun.sh" -ForegroundColor Red
Write-Host "Error: Bun installation failed. Please install manually from https://bun.sh" -ForegroundColor Red
return $false
}
@@ -34,27 +34,27 @@ function Install-WithBun {
bun add -g @trycua/cli
return $true
} catch {
Write-Host " Failed to install with Bun, trying npm..." -ForegroundColor Yellow
Write-Host "Warning: Failed to install with Bun, trying npm..." -ForegroundColor Yellow
try {
npm install -g @trycua/cli
return $true
} catch {
Write-Host " Installation failed with npm as well." -ForegroundColor Red
Write-Host "Error: Installation failed with npm as well." -ForegroundColor Red
return $false
}
}
}
Write-Host "🚀 Installing CUA CLI..." -ForegroundColor Green
Write-Host "Installing CUA CLI..." -ForegroundColor Green
# Determine if this is a 64-bit system
$is64Bit = [Environment]::Is64BitOperatingSystem
if (-not $is64Bit) {
Write-Host "⚠️ 32-bit Windows is not supported. Falling back to Bun installation..." -ForegroundColor Yellow
Write-Host "Warning: 32-bit Windows is not supported. Falling back to Bun installation..." -ForegroundColor Yellow
if (Install-WithBun) {
exit 0
} else {
Write-Host " Installation failed. Please try installing manually:" -ForegroundColor Red
Write-Host "Error: Installation failed. Please try installing manually:" -ForegroundColor Red
Write-Host " irm https://cua.ai/install.ps1 | iex"
exit 1
}
@@ -66,11 +66,11 @@ try {
$version = $release.tag_name -replace '^cua-v', ''
$binaryUrl = "https://github.com/trycua/cua/releases/download/$($release.tag_name)/cua-windows-x64.exe"
} catch {
Write-Host "⚠️ Could not fetch latest release, falling back to Bun installation" -ForegroundColor Yellow
Write-Host "Warning: Could not fetch latest release, falling back to Bun installation" -ForegroundColor Yellow
if (Install-WithBun) {
exit 0
} else {
Write-Host " Installation failed. Please try installing manually:" -ForegroundColor Red
Write-Host "Error: Installation failed. Please try installing manually:" -ForegroundColor Red
Write-Host " irm https://cua.ai/install.ps1 | iex"
exit 1
}
@@ -85,15 +85,15 @@ if (-not (Test-Path $installDir)) {
$binaryPath = Join-Path $installDir "cua.exe"
# Download the binary
Write-Host "📥 Downloading CUA CLI $version for Windows x64..." -ForegroundColor Cyan
Write-Host "Downloading CUA CLI $version for Windows x64..." -ForegroundColor Cyan
try {
Invoke-WebRequest -Uri $binaryUrl -OutFile $binaryPath -ErrorAction Stop
} catch {
Write-Host "⚠️ Failed to download pre-built binary, falling back to Bun installation" -ForegroundColor Yellow
Write-Host "Warning: Failed to download pre-built binary, falling back to Bun installation" -ForegroundColor Yellow
if (Install-WithBun) {
exit 0
} else {
Write-Host " Installation failed. Please try installing manually:" -ForegroundColor Red
Write-Host "Error: Installation failed. Please try installing manually:" -ForegroundColor Red
Write-Host " irm https://cua.ai/install.ps1 | iex"
exit 1
}
@@ -104,27 +104,27 @@ $currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($currentPath -notlike "*$installDir*") {
[Environment]::SetEnvironmentVariable("Path", "$currentPath;$installDir", "User")
$env:Path = "$env:Path;$installDir"
Write-Host " Added $installDir to your PATH" -ForegroundColor Green
Write-Host "Success: Added $installDir to your PATH" -ForegroundColor Green
}
# Verify installation
if (Test-Path $binaryPath) {
Write-Host " CUA CLI $version installed successfully to $binaryPath" -ForegroundColor Green
Write-Host "Success: CUA CLI $version installed successfully to $binaryPath" -ForegroundColor Green
Write-Host ""
Write-Host "🎉 Get started with:" -ForegroundColor Cyan
Write-Host "Get started with:" -ForegroundColor Cyan
Write-Host " cua auth login"
Write-Host " cua vm create --os linux --configuration small --region north-america"
Write-Host ""
Write-Host "📚 For more help, visit: https://docs.cua.ai/libraries/cua-cli" -ForegroundColor Cyan
Write-Host "For more help, visit: https://docs.cua.ai/libraries/cua-cli" -ForegroundColor Cyan
# Offer to add to PATH if not already there
if (-not ($env:Path -like "*$installDir*")) {
Write-Host ""
Write-Host "⚠️ Please restart your terminal or run the following command to use CUA CLI:" -ForegroundColor Yellow
Write-Host "Note: Please restart your terminal or run the following command to use CUA CLI:" -ForegroundColor Yellow
Write-Host " `$env:Path += ';$installDir'"
}
} else {
Write-Host " Installation failed. Please try installing manually:" -ForegroundColor Red
Write-Host "Error: Installation failed. Please try installing manually:" -ForegroundColor Red
Write-Host " irm https://cua.ai/install.ps1 | iex"
exit 1
}
}