# DBAOps Sovereign — Prepare data-driven pilot demo (releases + collection + readiness)
param(
    [string]$SqlServer = ".",
    [switch]$SkipCollect,
    [switch]$SkipBuild
)

$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $PSScriptRoot
Set-Location $root

Write-Host "=== DBAOps Sovereign Pilot Demo Prep ===" -ForegroundColor Cyan

if (-not $SkipBuild) {
    Write-Host "`n[1/5] Building multi-OS release artifacts..." -ForegroundColor Yellow
    node scripts/build-release-artifacts.js
}

Write-Host "`n[2/5] Migrating database (v26 software releases)..." -ForegroundColor Yellow
npm run migrate

Write-Host "`n[3/5] Seeding release catalog (published)..." -ForegroundColor Yellow
node scripts/seed-software-releases.js --publish

if (-not $SkipCollect) {
    Write-Host "`n[4/5] Full fleet collection from $SqlServer..." -ForegroundColor Yellow
    npm run collect:full
} else {
    Write-Host "`n[4/5] Skipping collection (-SkipCollect)" -ForegroundColor DarkGray
}

Write-Host "`n[5/5] Shipment readiness assessment..." -ForegroundColor Yellow
& "$root\Assess-ShipmentReadiness.ps1" -SqlServer $SqlServer

Write-Host "`n=== Pilot demo ready ===" -ForegroundColor Green
Write-Host "  Dashboard:  http://localhost:3000"
Write-Host "  Downloads:  http://localhost:3000/downloads"
Write-Host "  Executive:  http://localhost:3000/executive"
Write-Host "  Compliance: http://localhost:3000/compliance-packs"
Write-Host "  License:    http://localhost:3000/license-settings"
Write-Host "`nRestart API if running: npm run start:api" -ForegroundColor DarkYellow
