#Requires -Version 5.1 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $BASE_URL = "https://enkoala.pages.dev" $INSTALL_DIR = Join-Path $env:APPDATA "enkoala" $SCRIPT_PATH = Join-Path $INSTALL_DIR "enkoala.py" $SHIM_PATH = Join-Path $INSTALL_DIR "enkoala.cmd" $TMP = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName()) function Remove-Tmp { if (Test-Path $TMP) { Remove-Item $TMP -Force -ErrorAction SilentlyContinue } } try { Write-Host "" Write-Host " ███████╗███╗ ██╗██╗ ██╗ ██████╗ █████╗ ██╗ █████╗" -ForegroundColor Green Write-Host " ██╔════╝████╗ ██║██║ ██╔╝██╔═══██╗██╔══██╗██║ ██╔══██╗" -ForegroundColor Green Write-Host " █████╗ ██╔██╗ ██║█████╔╝ ██║ ██║███████║██║ ███████║" -ForegroundColor Green Write-Host " ██╔══╝ ██║╚██╗██║██╔═██╗ ██║ ██║██╔══██║██║ ██╔══██║" -ForegroundColor Green Write-Host " ███████╗██║ ╚████║██║ ██╗╚██████╔╝██║ ██║███████╗██║ ██║" -ForegroundColor Green Write-Host " ╚══════╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝" -ForegroundColor Green Write-Host "" Write-Host " Installer" -ForegroundColor Cyan Write-Host "" $python = $null foreach ($cmd in @("python", "python3", "py")) { try { $ver = & $cmd --version 2>&1 if ($ver -match "Python 3\.([6-9]|[1-9]\d)") { $python = $cmd break } } catch {} } if (-not $python) { Write-Host "[!] Python 3.6+ not found." -ForegroundColor Red Write-Host " Download from: https://www.python.org/downloads/" -ForegroundColor Yellow Write-Host " Make sure to check 'Add Python to PATH' during install." -ForegroundColor Yellow exit 1 } Write-Host "[*] Found Python: $python" -ForegroundColor Cyan Write-Host "[*] Fetching version info..." -ForegroundColor Cyan try { $versionJson = (Invoke-WebRequest -Uri "$BASE_URL/version.json" -UseBasicParsing).Content | ConvertFrom-Json $expectedSha = $versionJson.sha256 $versionNum = $versionJson.version } catch { Write-Host "[!] Failed to fetch version info: $_" -ForegroundColor Red exit 1 } Write-Host "[*] Downloading enkoala v$versionNum..." -ForegroundColor Cyan try { Invoke-WebRequest -Uri "$BASE_URL/enkoala.py" -OutFile $TMP -UseBasicParsing } catch { Write-Host "[!] Download failed: $_" -ForegroundColor Red exit 1 } if ($expectedSha) { Write-Host "[*] Verifying checksum..." -ForegroundColor Cyan $sha = (Get-FileHash -Path $TMP -Algorithm SHA256).Hash.ToLower() if ($sha -ne $expectedSha.ToLower()) { Write-Host "[!] Checksum mismatch - file may be corrupted or tampered with. Aborting." -ForegroundColor Red Write-Host " Expected : $expectedSha" Write-Host " Got : $sha" exit 1 } Write-Host "[+] Checksum OK (SHA256 verified)." -ForegroundColor Green } else { Write-Host "[~] Warning: no checksum available, skipping verification." -ForegroundColor Yellow } if (-not (Test-Path $INSTALL_DIR)) { New-Item -ItemType Directory -Path $INSTALL_DIR | Out-Null } Copy-Item -Path $TMP -Destination $SCRIPT_PATH -Force $quotedPython = $python $quotedScript = $SCRIPT_PATH -replace '"', '""' $shim = "@echo off`r`n`"$quotedPython`" `"$quotedScript`" %*" Set-Content -Path $SHIM_PATH -Value $shim -Encoding ASCII $userPath = [Environment]::GetEnvironmentVariable("PATH", "User") if ($userPath -notlike "*$INSTALL_DIR*") { [Environment]::SetEnvironmentVariable("PATH", "$userPath;$INSTALL_DIR", "User") Write-Host "[*] Added $INSTALL_DIR to PATH" -ForegroundColor Cyan Write-Host "[!] Restart your terminal for PATH changes to take effect." -ForegroundColor Yellow } Write-Host "[+] Installed enkoala v$versionNum to $SCRIPT_PATH" -ForegroundColor Green Write-Host "[+] Run: enkoala --help" -ForegroundColor Green Write-Host "" } finally { Remove-Tmp }