# Installs (or upgrades) the swea console game on Windows (x64). # # irm https://swea.pitan.net/install.ps1 | iex # # Downloads the latest self-contained swea.exe (no .NET runtime needed) into # %LOCALAPPDATA%\Programs\swea and adds that folder to your user PATH. # No admin rights needed. Everything runs inside Install-Swea, so a truncated # download never runs half a script. function Install-Swea { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' # Invoke-WebRequest is much faster without it. # Must match the "latest" uploads in .gitea/workflows/console.yaml. $url = 'https://dl.pitan.net/swea/latest/swea-win-x64.zip' $installDir = Join-Path $env:LOCALAPPDATA 'Programs\swea' if (-not [Environment]::Is64BitOperatingSystem -or $env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { throw 'Only x64 Windows is packaged.' } $tmp = Join-Path ([IO.Path]::GetTempPath()) ("swea-" + [Guid]::NewGuid()) New-Item -ItemType Directory -Path $tmp | Out-Null try { Write-Host '==> Downloading swea' -ForegroundColor Blue $zip = Join-Path $tmp 'swea-win-x64.zip' Invoke-WebRequest -Uri $url -OutFile $zip -UseBasicParsing Expand-Archive -Path $zip -DestinationPath $tmp -Force Write-Host "==> Installing to $installDir" -ForegroundColor Blue New-Item -ItemType Directory -Path $installDir -Force | Out-Null Copy-Item -Path (Join-Path $tmp 'swea.exe') -Destination $installDir -Force } finally { Remove-Item -Path $tmp -Recurse -Force -ErrorAction SilentlyContinue } $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') $entries = @($userPath -split ';' | Where-Object { $_ }) if ($entries -notcontains $installDir) { Write-Host '==> Adding swea to your user PATH' -ForegroundColor Blue [Environment]::SetEnvironmentVariable('Path', (($entries + $installDir) -join ';'), 'User') $env:Path = "$env:Path;$installDir" } $version = & (Join-Path $installDir 'swea.exe') --version Write-Host "==> Done: $version. Run 'swea' to play (open a new terminal if it isn't found)." -ForegroundColor Blue Write-Host ' For the best look, use Windows Terminal: the board uses emoji.' } Install-Swea