-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
65 lines (49 loc) · 2.33 KB
/
install.ps1
File metadata and controls
65 lines (49 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# api-discover installer (Windows / PowerShell).
# Idempotent. Re-run after `git pull` to refresh.
$ErrorActionPreference = 'Stop'
function Say($msg) { Write-Host "[install] $msg" -ForegroundColor Blue }
function OK($msg) { Write-Host "[ok] $msg" -ForegroundColor Green }
function Err($msg) { Write-Host "[error] $msg" -ForegroundColor Red }
$repoRoot = (Get-Item $PSScriptRoot).FullName
$binDir = Join-Path $env:USERPROFILE ".local\bin"
if (-not (Test-Path $binDir)) { New-Item -ItemType Directory -Path $binDir -Force | Out-Null }
# --- Prereqs ---
Say "Checking prerequisites..."
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
Err "node not found. Install Node 18+ from https://nodejs.org/"; exit 1
}
$nodeMajor = [int](node -e "console.log(process.versions.node.split('.')[0])")
if ($nodeMajor -lt 18) { Err "Node 18+ required, found $(node --version)"; exit 1 }
OK "Node $(node --version)"
$py = Get-Command python -ErrorAction SilentlyContinue
if (-not $py) { $py = Get-Command python3 -ErrorAction SilentlyContinue }
if (-not $py) { $py = Get-Command py -ErrorAction SilentlyContinue }
if (-not $py) { Err "Python not found. Install Python 3.10+ from https://www.python.org/"; exit 1 }
OK "Python at $($py.Source)"
if (-not (Get-Command uv -ErrorAction SilentlyContinue)) {
Say "uv not found, installing via the official installer..."
irm https://astral.sh/uv/install.ps1 | iex
$env:PATH = "$env:USERPROFILE\.local\bin;$env:PATH"
}
OK "uv present"
# --- browser-harness ---
if (-not (Get-Command browser-harness -ErrorAction SilentlyContinue)) {
Say "Installing browser-harness via uv..."
uv tool install browser-harness
} else {
OK "browser-harness already on PATH at $((Get-Command browser-harness).Source)"
}
# --- api-discover shim ---
$shimPath = Join-Path $binDir "api-discover.cmd"
$sourceBin = Join-Path $repoRoot "bin\api-discover.mjs"
$shimContent = "@echo off`r`nnode `"$sourceBin`" %*`r`n"
Set-Content -Path $shimPath -Value $shimContent -Encoding ASCII
OK "Wrote shim $shimPath"
# --- PATH check ---
$onPath = ($env:PATH -split ';') -contains $binDir
if (-not $onPath) {
Say "Note: $binDir is not on PATH. Add it via System Settings or run:"
Write-Host " [Environment]::SetEnvironmentVariable('PATH', `"`$env:PATH;$binDir`", 'User')"
}
Write-Host ""
OK "Installed. Run 'api-discover doctor' to verify."