chore: import upstream snapshot with attribution
CI: cua-driver distro-compat matrix / debian:12 (glibc 2.36) (push) Has been cancelled
CI: SPDX Headers / Check SPDX headers (warn-only) (push) Has been cancelled
CD: Docs MCP Server / build (linux/amd64) (push) Has been cancelled
CD: Docs MCP Server / build (linux/arm64) (push) Has been cancelled
CD: Docs MCP Server / merge (push) Has been cancelled
CI: cua-driver distro-compat matrix / Resolve release version (push) Has been cancelled
CI: cua-driver distro-compat matrix / fedora:41 (glibc 2.40) (push) Has been cancelled
CI: cua-driver distro-compat matrix / rockylinux:9 (glibc 2.34) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:22.04 (glibc 2.35) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:24.04 (glibc 2.39) (push) Has been cancelled
CI: cua-driver distro-compat matrix / Distro compat summary (push) Has been cancelled
CI: Rust Linux unit / Rust Linux unit and compile (push) Has been cancelled
CI: Rust Windows unit / Rust Windows unit and compile (push) Has been cancelled
CI: Nix Linux Rust source / Nix / compositor build (push) Has been cancelled
CI: Nix Linux Rust source / Nix / driver package (push) Has been cancelled
CI: Nix Linux Rust source / Nix / Rust unit tests (push) Has been cancelled
CI: cua-driver distro-compat matrix / debian:12 (glibc 2.36) (push) Has been cancelled
CI: SPDX Headers / Check SPDX headers (warn-only) (push) Has been cancelled
CD: Docs MCP Server / build (linux/amd64) (push) Has been cancelled
CD: Docs MCP Server / build (linux/arm64) (push) Has been cancelled
CD: Docs MCP Server / merge (push) Has been cancelled
CI: cua-driver distro-compat matrix / Resolve release version (push) Has been cancelled
CI: cua-driver distro-compat matrix / fedora:41 (glibc 2.40) (push) Has been cancelled
CI: cua-driver distro-compat matrix / rockylinux:9 (glibc 2.34) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:22.04 (glibc 2.35) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:24.04 (glibc 2.39) (push) Has been cancelled
CI: cua-driver distro-compat matrix / Distro compat summary (push) Has been cancelled
CI: Rust Linux unit / Rust Linux unit and compile (push) Has been cancelled
CI: Rust Windows unit / Rust Windows unit and compile (push) Has been cancelled
CI: Nix Linux Rust source / Nix / compositor build (push) Has been cancelled
CI: Nix Linux Rust source / Nix / driver package (push) Has been cancelled
CI: Nix Linux Rust source / Nix / Rust unit tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,245 @@
|
||||
# Cua CLI Installation Script for Windows
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Get-LatestCuaTag {
|
||||
$page = 1
|
||||
$perPage = 100
|
||||
$maxPages = 10
|
||||
|
||||
while ($page -le $maxPages) {
|
||||
try {
|
||||
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/trycua/cua/tags?per_page=$perPage&page=$page" -ErrorAction Stop
|
||||
|
||||
if (-not $response -or $response.Count -eq 0) {
|
||||
return $null
|
||||
}
|
||||
|
||||
$cuaTag = $response | Where-Object { $_.name -like "cua-*" } | Select-Object -First 1
|
||||
|
||||
if ($cuaTag) {
|
||||
return $cuaTag.name
|
||||
}
|
||||
|
||||
$page++
|
||||
} catch {
|
||||
return $null
|
||||
}
|
||||
}
|
||||
|
||||
return $null
|
||||
}
|
||||
|
||||
# Install shell completions (idempotent)
|
||||
function Install-Completions {
|
||||
param([string]$CuaBinaryPath)
|
||||
|
||||
$completionsDir = "$env:USERPROFILE\.cua\completions"
|
||||
if (-not (Test-Path $completionsDir)) {
|
||||
New-Item -ItemType Directory -Path $completionsDir -Force | Out-Null
|
||||
}
|
||||
|
||||
$completionScript = Join-Path $completionsDir "cua.ps1"
|
||||
|
||||
# Generate completion script
|
||||
try {
|
||||
$completionContent = & $CuaBinaryPath completion 2>$null
|
||||
if ($completionContent) {
|
||||
Set-Content -Path $completionScript -Value $completionContent -Force
|
||||
}
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
if (-not (Test-Path $completionScript)) {
|
||||
return
|
||||
}
|
||||
|
||||
# Add to PowerShell profile (idempotent)
|
||||
$profilePath = $PROFILE.CurrentUserAllHosts
|
||||
if (-not $profilePath) {
|
||||
$profilePath = $PROFILE
|
||||
}
|
||||
|
||||
$sourceLine = ". `"$completionScript`""
|
||||
|
||||
# Create profile if it doesn't exist
|
||||
if (-not (Test-Path $profilePath)) {
|
||||
$profileDir = Split-Path $profilePath -Parent
|
||||
if (-not (Test-Path $profileDir)) {
|
||||
New-Item -ItemType Directory -Path $profileDir -Force | Out-Null
|
||||
}
|
||||
New-Item -ItemType File -Path $profilePath -Force | Out-Null
|
||||
}
|
||||
|
||||
# Check if line already exists
|
||||
$profileContent = Get-Content $profilePath -Raw -ErrorAction SilentlyContinue
|
||||
if ($profileContent -notlike "*$completionScript*") {
|
||||
Add-Content -Path $profilePath -Value "`n# Cua CLI completions`n$sourceLine"
|
||||
Write-Host "Success: Added shell completions to PowerShell profile" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
function Install-WithBun {
|
||||
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
|
||||
try {
|
||||
powershell -c "irm bun.sh/install.ps1|iex"
|
||||
|
||||
# Refresh environment variables
|
||||
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
|
||||
|
||||
# Add bun to PATH for this session if not already there
|
||||
$bunPath = "$env:USERPROFILE\.bun\bin"
|
||||
if ($env:Path -notlike "*$bunPath*") {
|
||||
$env:Path = "$bunPath;$env:Path"
|
||||
}
|
||||
} catch {
|
||||
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 "Error: Bun installation failed. Please install manually from https://bun.sh" -ForegroundColor Red
|
||||
return $false
|
||||
}
|
||||
|
||||
try {
|
||||
bun add -g @trycua/cli
|
||||
# Determine installed version from npm registry
|
||||
try {
|
||||
$bunVersion = (npm view @trycua/cli version) 2>$null
|
||||
if (-not $bunVersion) { $bunVersion = "unknown" }
|
||||
} catch { $bunVersion = "unknown" }
|
||||
# Ensure install dir and write version file
|
||||
$installDir = "$env:USERPROFILE\.cua\bin"
|
||||
if (-not (Test-Path $installDir)) { New-Item -ItemType Directory -Path $installDir -Force | Out-Null }
|
||||
Set-Content -Path (Join-Path $installDir ".version") -Value $bunVersion -NoNewline
|
||||
# Install completions
|
||||
$cuaPath = Get-Command cua -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Source
|
||||
if ($cuaPath) { Install-Completions -CuaBinaryPath $cuaPath }
|
||||
return $true
|
||||
} catch {
|
||||
Write-Host "Warning: Failed to install with Bun, trying npm..." -ForegroundColor Yellow
|
||||
try {
|
||||
npm install -g @trycua/cli
|
||||
# Determine installed version from npm registry
|
||||
try {
|
||||
$npmVersion = (npm view @trycua/cli version) 2>$null
|
||||
if (-not $npmVersion) { $npmVersion = "unknown" }
|
||||
} catch { $npmVersion = "unknown" }
|
||||
# Ensure install dir and write version file
|
||||
$installDir = "$env:USERPROFILE\.cua\bin"
|
||||
if (-not (Test-Path $installDir)) { New-Item -ItemType Directory -Path $installDir -Force | Out-Null }
|
||||
Set-Content -Path (Join-Path $installDir ".version") -Value $npmVersion -NoNewline
|
||||
# Install completions
|
||||
$cuaPath = Get-Command cua -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Source
|
||||
if ($cuaPath) { Install-Completions -CuaBinaryPath $cuaPath }
|
||||
return $true
|
||||
} catch {
|
||||
Write-Host "Error: Installation failed with npm as well." -ForegroundColor Red
|
||||
return $false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Installing Cua CLI..." -ForegroundColor Green
|
||||
|
||||
# Determine if this is a 64-bit system
|
||||
$is64Bit = [Environment]::Is64BitOperatingSystem
|
||||
if (-not $is64Bit) {
|
||||
Write-Host "Warning: 32-bit Windows is not supported. Falling back to Bun installation..." -ForegroundColor Yellow
|
||||
if (Install-WithBun) {
|
||||
exit 0
|
||||
} else {
|
||||
Write-Host "Error: Installation failed. Please try installing manually:" -ForegroundColor Red
|
||||
Write-Host " irm https://cua.ai/install.ps1 | iex"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Get the latest cua release tag
|
||||
$tagName = Get-LatestCuaTag
|
||||
if (-not $tagName) {
|
||||
Write-Host "Warning: Could not find latest cua release, falling back to Bun installation" -ForegroundColor Yellow
|
||||
if (Install-WithBun) {
|
||||
exit 0
|
||||
} else {
|
||||
Write-Host "Error: Installation failed. Please try installing manually:" -ForegroundColor Red
|
||||
Write-Host " irm https://cua.ai/install.ps1 | iex"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Extract version number (remove 'cua-v' prefix)
|
||||
$version = $tagName -replace '^cua-v', ''
|
||||
|
||||
# Construct download URL using the specific cua release tag
|
||||
$binaryUrl = "https://github.com/trycua/cua/releases/download/$tagName/cua-windows-x64.exe"
|
||||
|
||||
# Create installation directory
|
||||
$installDir = "$env:USERPROFILE\.cua\bin"
|
||||
if (-not (Test-Path $installDir)) {
|
||||
New-Item -ItemType Directory -Path $installDir -Force | Out-Null
|
||||
}
|
||||
|
||||
$binaryPath = Join-Path $installDir "cua.exe"
|
||||
|
||||
# Download the binary
|
||||
Write-Host "Downloading Cua CLI $version for Windows x64..." -ForegroundColor Cyan
|
||||
try {
|
||||
Invoke-WebRequest -Uri $binaryUrl -OutFile $binaryPath -ErrorAction Stop
|
||||
} catch {
|
||||
Write-Host "Warning: Failed to download pre-built binary, falling back to Bun installation" -ForegroundColor Yellow
|
||||
if (Install-WithBun) {
|
||||
exit 0
|
||||
} else {
|
||||
Write-Host "Error: Installation failed. Please try installing manually:" -ForegroundColor Red
|
||||
Write-Host " irm https://cua.ai/install.ps1 | iex"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Write version file for binary install
|
||||
try {
|
||||
Set-Content -Path (Join-Path $installDir ".version") -Value $version -NoNewline
|
||||
} catch {
|
||||
# Non-fatal
|
||||
}
|
||||
|
||||
# Add to PATH if not already there
|
||||
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
||||
if ($currentPath -notlike "*$installDir*") {
|
||||
[Environment]::SetEnvironmentVariable("Path", "$currentPath;$installDir", "User")
|
||||
$env:Path = "$env:Path;$installDir"
|
||||
Write-Host "Success: Added $installDir to your PATH" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Install shell completions
|
||||
Install-Completions -CuaBinaryPath $binaryPath
|
||||
|
||||
# Verify installation
|
||||
if (Test-Path $binaryPath) {
|
||||
Write-Host "Success: Cua CLI $version installed successfully to $binaryPath" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "Get started with:" -ForegroundColor Cyan
|
||||
Write-Host " cua login"
|
||||
Write-Host " cua create --os linux --size small --region north-america"
|
||||
Write-Host ""
|
||||
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 "Note: Please restart your terminal or run the following command to use Cua CLI:" -ForegroundColor Yellow
|
||||
Write-Host " `$env:Path += ';$installDir'"
|
||||
}
|
||||
} else {
|
||||
Write-Host "Error: Installation failed. Please try installing manually:" -ForegroundColor Red
|
||||
Write-Host " irm https://cua.ai/install.ps1 | iex"
|
||||
exit 1
|
||||
}
|
||||
Reference in New Issue
Block a user