# -----------------------------------------------------------------------------
#  Build script - compiles sysinfo_bot.py into a standalone Windows .exe
#  Run this from the sc-sysinfo-bot folder in PowerShell
# -----------------------------------------------------------------------------

$ErrorActionPreference = "Stop"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
Set-Location $ScriptDir

Write-Host "`n[1/4] Checking Python..." -ForegroundColor Cyan
$py = Get-Command python -ErrorAction SilentlyContinue
if (-not $py) {
    Write-Host "ERROR: Python not found. Install from https://python.org" -ForegroundColor Red
    exit 1
}
python --version

Write-Host "`n[2/4] Installing dependencies..." -ForegroundColor Cyan
python -m pip install --upgrade pip --quiet
python -m pip install psutil pyinstaller requests --quiet
Write-Host "  psutil + pyinstaller + requests ready." -ForegroundColor Green

Write-Host "`n[3/4] Compiling to .exe..." -ForegroundColor Cyan
pyinstaller `
    --onefile `
    --noconsole `
    --name "SC-SysInfo" `
    --icon NONE `
    sysinfo_bot.py

Write-Host "`n[4/4] Done!" -ForegroundColor Green
$exe = Join-Path $ScriptDir "dist\SC-SysInfo.exe"
if (Test-Path $exe) {
    Write-Host "  Output : $exe" -ForegroundColor Yellow
    Write-Host "  Size   : $([Math]::Round((Get-Item $exe).Length / 1MB, 1)) MB" -ForegroundColor Yellow
} else {
    Write-Host "  Build failed - check output above." -ForegroundColor Red
}
