|
| 1 | +# SCUD + Rho Installer for Windows |
| 2 | +# irm https://raw.githubusercontent.com/pyrex41/scud/master/install.ps1 | iex |
| 3 | +$ErrorActionPreference = "Stop" |
| 4 | + |
| 5 | +$ScudRepo = "pyrex41/scud" |
| 6 | +$RhoRepo = "pyrex41/rho" |
| 7 | +$InstallDir = if ($env:INSTALL_DIR) { $env:INSTALL_DIR } else { "$env:USERPROFILE\.local\bin" } |
| 8 | + |
| 9 | +function Download-Binary { |
| 10 | + param($Repo, $BinName, $AssetPrefix) |
| 11 | + |
| 12 | + $Asset = "$AssetPrefix-windows-x64.exe" |
| 13 | + $Dest = "$InstallDir\$BinName.exe" |
| 14 | + |
| 15 | + try { |
| 16 | + $Release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" |
| 17 | + $Tag = $Release.tag_name |
| 18 | + } catch { |
| 19 | + Write-Host " Could not fetch latest release for $Repo" |
| 20 | + return $false |
| 21 | + } |
| 22 | + |
| 23 | + $Url = "https://github.com/$Repo/releases/download/$Tag/$Asset" |
| 24 | + Write-Host " Downloading $BinName $Tag (windows/x64)..." |
| 25 | + |
| 26 | + try { |
| 27 | + Invoke-WebRequest -Uri $Url -OutFile $Dest -UseBasicParsing |
| 28 | + Write-Host " Installed $BinName to $Dest" |
| 29 | + return $true |
| 30 | + } catch { |
| 31 | + Write-Host " Download failed: $_" |
| 32 | + return $false |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +function Cargo-Fallback { |
| 37 | + param($BinName, $CrateName) |
| 38 | + |
| 39 | + Write-Host " Prebuilt binary not available. Installing via cargo..." |
| 40 | + if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) { |
| 41 | + Write-Host " Rust not found. Install from https://rustup.rs first." |
| 42 | + exit 1 |
| 43 | + } |
| 44 | + cargo install $CrateName |
| 45 | +} |
| 46 | + |
| 47 | +Write-Host "Installing SCUD CLI + Rho harness..." |
| 48 | +Write-Host "" |
| 49 | + |
| 50 | +if (-not (Test-Path $InstallDir)) { |
| 51 | + New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null |
| 52 | +} |
| 53 | + |
| 54 | +# Install scud |
| 55 | +Write-Host "scud:" |
| 56 | +if (-not (Download-Binary -Repo $ScudRepo -BinName "scud" -AssetPrefix "scud")) { |
| 57 | + Cargo-Fallback -BinName "scud" -CrateName "scud-cli" |
| 58 | +} |
| 59 | + |
| 60 | +Write-Host "" |
| 61 | + |
| 62 | +# Install rho-cli |
| 63 | +Write-Host "rho-cli:" |
| 64 | +if (-not (Download-Binary -Repo $RhoRepo -BinName "rho-cli" -AssetPrefix "rho-cli")) { |
| 65 | + Cargo-Fallback -BinName "rho-cli" -CrateName "rho-agent" |
| 66 | +} |
| 67 | + |
| 68 | +Write-Host "" |
| 69 | + |
| 70 | +# Check PATH |
| 71 | +if ($env:PATH -notlike "*$InstallDir*") { |
| 72 | + Write-Host "Add $InstallDir to your PATH:" |
| 73 | + Write-Host " [Environment]::SetEnvironmentVariable('PATH', `"$InstallDir;`$env:PATH`", 'User')" |
| 74 | + Write-Host "" |
| 75 | + Write-Host "Or run this to add it now (current session only):" |
| 76 | + Write-Host " `$env:PATH = `"$InstallDir;`$env:PATH`"" |
| 77 | + Write-Host "" |
| 78 | +} |
| 79 | + |
| 80 | +Write-Host "Done! Run 'scud init' in any project to get started." |
| 81 | +Write-Host "https://github.com/pyrex41/scud" |
0 commit comments