$ErrorActionPreference = "Stop" $repoUrl = if ($env:ANUREO_REPO_URL) { $env:ANUREO_REPO_URL } else { "https://github.com/hi-youichi/anureo-tunnel.git" } $installDir = if ($env:ANUREO_INSTALL_DIR) { $env:ANUREO_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA "Anureo\bin" } foreach ($commandName in @("git", "cmake")) { if (-not (Get-Command $commandName -ErrorAction SilentlyContinue)) { throw "Anureo installer: missing required command: $commandName" } } $workDir = Join-Path ([System.IO.Path]::GetTempPath()) ("anureo-install-" + [guid]::NewGuid().ToString("N")) try { Write-Host "Cloning Anureo Tunnel..." git clone --depth 1 $repoUrl (Join-Path $workDir "anureo-tunnel") Write-Host "Building Anureo CLI..." cmake -S (Join-Path $workDir "anureo-tunnel\cli") -B (Join-Path $workDir "build") -DBUILD_TESTING=OFF cmake --build (Join-Path $workDir "build") --config Release --parallel New-Item -ItemType Directory -Force $installDir | Out-Null Copy-Item (Join-Path $workDir "build\Release\anureo.exe") (Join-Path $installDir "anureo.exe") -Force $userPath = [Environment]::GetEnvironmentVariable("Path", "User") $pathEntries = @($userPath -split ";" | Where-Object { $_ }) if ($pathEntries -notcontains $installDir) { [Environment]::SetEnvironmentVariable("Path", (($pathEntries + $installDir) -join ";"), "User") } $env:Path = "$installDir;$env:Path" Write-Host "Installed Anureo CLI to $(Join-Path $installDir 'anureo.exe')" Write-Host "Run: anureo expose --anonymous http://127.0.0.1:8080" } finally { if (Test-Path $workDir) { Remove-Item -Recurse -Force $workDir } }