All three setup scripts (Linux, macOS, Windows) now verify that the Antigravity app is installed and the LS binary exists before proceeding. Fails early with a clear error message and suggestions instead of a cryptic runtime crash. Closes #5
88 lines
3.2 KiB
PowerShell
88 lines
3.2 KiB
PowerShell
# ZeroGravity — Windows setup
|
|
# Creates config directories, builds the release binary, and optionally
|
|
# installs as a scheduled task for automatic startup.
|
|
# Run as: powershell -ExecutionPolicy Bypass -File scripts\setup-windows.ps1
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$ProjectDir = Split-Path -Parent $PSScriptRoot
|
|
if (-not $ProjectDir) { $ProjectDir = (Get-Location).Path }
|
|
|
|
# ── 1. Config directory ──
|
|
Write-Host "→ Setting up config directory…"
|
|
$ConfigDir = Join-Path $env:APPDATA "zerogravity"
|
|
New-Item -ItemType Directory -Force -Path $ConfigDir | Out-Null
|
|
Write-Host " $ConfigDir"
|
|
|
|
# ── 2. Data directory ──
|
|
Write-Host "→ Setting up data directory…"
|
|
$DataDir = Join-Path $env:TEMP "zerogravity-standalone"
|
|
New-Item -ItemType Directory -Force -Path $DataDir | Out-Null
|
|
Write-Host " $DataDir"
|
|
|
|
# ── 3. Prerequisite check: Antigravity must be installed ──
|
|
Write-Host "→ Checking for Antigravity installation…"
|
|
$LsBinary = Join-Path $env:LOCALAPPDATA "Programs\Antigravity\resources\app\extensions\antigravity\bin\language_server_windows_x64.exe"
|
|
if (-not (Test-Path $LsBinary)) {
|
|
Write-Host ""
|
|
Write-Host "✗ Antigravity is not installed (or the LS binary is missing)." -ForegroundColor Red
|
|
Write-Host " ZeroGravity requires a working Antigravity installation."
|
|
Write-Host " The Language Server binary is bundled with the Antigravity app"
|
|
Write-Host " and cannot be downloaded separately."
|
|
Write-Host ""
|
|
Write-Host " Expected path:"
|
|
Write-Host " $LsBinary"
|
|
Write-Host ""
|
|
Write-Host " Install Antigravity first, then re-run this script."
|
|
Write-Host " Alternatively, set ZEROGRAVITY_LS_PATH to a custom LS binary location."
|
|
exit 1
|
|
}
|
|
Write-Host " Found: $LsBinary"
|
|
|
|
# ── 4. Build ──
|
|
Write-Host "→ Building release binary…"
|
|
Push-Location $ProjectDir
|
|
cargo build --release
|
|
Pop-Location
|
|
|
|
$Binary = Join-Path $ProjectDir "target\release\zerogravity.exe"
|
|
if (-not (Test-Path $Binary)) {
|
|
Write-Error "Build failed — $Binary not found"
|
|
exit 1
|
|
}
|
|
Write-Host " Built: $Binary"
|
|
|
|
# ── 5. Scheduled task (optional) ──
|
|
$TaskName = "ZeroGravity Proxy"
|
|
$Existing = Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue
|
|
|
|
if ($Existing) {
|
|
Write-Host "→ Scheduled task '$TaskName' already exists. Updating…"
|
|
Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false
|
|
}
|
|
|
|
Write-Host "→ Creating scheduled task '$TaskName'…"
|
|
$Action = New-ScheduledTaskAction `
|
|
-Execute $Binary `
|
|
-WorkingDirectory $ProjectDir
|
|
|
|
$Trigger = New-ScheduledTaskTrigger -AtLogOn
|
|
$Settings = New-ScheduledTaskSettingsSet `
|
|
-AllowStartIfOnBatteries `
|
|
-DontStopIfGoingOnBatteries `
|
|
-RestartCount 3 `
|
|
-RestartInterval (New-TimeSpan -Minutes 1)
|
|
|
|
Register-ScheduledTask `
|
|
-TaskName $TaskName `
|
|
-Action $Action `
|
|
-Trigger $Trigger `
|
|
-Settings $Settings `
|
|
-Description "ZeroGravity OpenAI-compatible proxy" | Out-Null
|
|
|
|
Write-Host " Installed as logon task."
|
|
Write-Host ""
|
|
Write-Host "✓ Setup complete."
|
|
Write-Host " Start now: schtasks /run /tn '$TaskName'"
|
|
Write-Host " Stop: schtasks /end /tn '$TaskName'"
|
|
Write-Host " Or manually: .\target\release\zerogravity.exe"
|