# Syncs deploy bundle and creates firebase-server-files.zip for cPanel upload.
$ErrorActionPreference = 'Stop'
$root = Split-Path $PSScriptRoot -Parent

& (Join-Path $PSScriptRoot 'sync-service-account-to-deploy.ps1')
& (Join-Path $PSScriptRoot 'verify-firebase-service-account.ps1')

$src = Join-Path $root 'deploy\firebase-server-files'
$zip = Join-Path $root 'deploy\firebase-server-files.zip'
if (Test-Path $zip) { Remove-Item -Force $zip }
Compress-Archive -Path (Join-Path $src '*') -DestinationPath $zip -Force

Write-Host ""
Write-Host "Created: $zip" -ForegroundColor Green
Write-Host "Upload and extract at document root so paths are:"
Write-Host "  api/firebase-service-account.local.json"
Write-Host "  api/firebase-admin-bootstrap.local.php"
Write-Host "  super-admin-panel/api/..."
Write-Host "Then chmod 600 on both .json files (see deploy/firebase-server-files/README-DEPLOY.txt)."
