# Dragonflight Premiere panel — build everything
#
# Produces both artifacts in dist/:
#   - dragonflight-premiere-panel-<version>.zxp                (Mac + Win)
#   - dragonflight-premiere-panel-<version>-windows-setup.exe  (Win)
#
# Requires: Node 18+, Inno Setup 6 (ISCC.exe on PATH).
# Usage:    pwsh -File build-all.ps1

$ErrorActionPreference = 'Stop'
Set-Location $PSScriptRoot

if (-not (Test-Path 'node_modules')) {
    Write-Host 'Installing npm deps...'
    npm install --no-audit --no-fund
    if ($LASTEXITCODE -ne 0) { throw 'npm install failed' }
}

Write-Host ''
Write-Host '=== Building .zxp ==='
node build-zxp.mjs
if ($LASTEXITCODE -ne 0) { throw 'ZXP build failed' }

Write-Host ''
Write-Host '=== Building Windows .exe ==='
& (Join-Path $PSScriptRoot 'build-installer.ps1')
if ($LASTEXITCODE -ne 0) { throw 'Installer build failed' }

Write-Host ''
Write-Host 'All artifacts:'
Get-ChildItem -Path 'dist' | ForEach-Object {
    $size = [math]::Round($_.Length / 1KB, 1)
    Write-Host ('  {0,8} KB  {1}' -f $size, $_.Name)
}
