# Build CLI - Build Next.js standalone and copy to cli/app/
# Run from project root: .\scripts\build-cli.ps1

$ErrorActionPreference = "Stop"

Write-Host "`n[1/3] Building Next.js standalone..." -ForegroundColor Cyan
npm run build

Write-Host "`n[2/3] Copying standalone to cli/app/..." -ForegroundColor Cyan
if (Test-Path "cli/app") { Remove-Item -Recurse -Force "cli/app" }
New-Item -ItemType Directory -Path "cli/app" -Force | Out-Null
Copy-Item -Recurse -Force ".next\standalone\*" "cli/app/"
Copy-Item -Recurse -Force ".next\static" "cli/app/.next/static"
Copy-Item -Recurse -Force "public" "cli/app/public"

Write-Host "`n[3/3] Done!" -ForegroundColor Green
Write-Host "`nCLI ready at cli/"
Write-Host "Test with: cd cli && node cli.js`n" -ForegroundColor Yellow
