param( [Parameter(Mandatory = $true)][string]$ProjectRoot, [Parameter(Mandatory = $true)][string]$OutputZip ) $ErrorActionPreference = "Stop" $apiDir = Join-Path $ProjectRoot "services\api" $stageRoot = Join-Path $env:TEMP ("abyssinfo-api-stage-" + [guid]::NewGuid().ToString("N")) $stageApi = Join-Path $stageRoot "api" New-Item -ItemType Directory -Force -Path $stageApi | Out-Null $excludeDirs = @(".venv", "__pycache__", "staticfiles") $excludeFiles = @("db.sqlite3") Get-ChildItem -LiteralPath $apiDir -Force | ForEach-Object { if ($_.PSIsContainer) { if ($excludeDirs -notcontains $_.Name) { Copy-Item -LiteralPath $_.FullName -Destination $stageApi -Recurse -Force } } elseif ($excludeFiles -notcontains $_.Name) { Copy-Item -LiteralPath $_.FullName -Destination $stageApi -Force } } if (Test-Path -LiteralPath $OutputZip) { Remove-Item -LiteralPath $OutputZip -Force } Compress-Archive -Path (Join-Path $stageApi "*") -DestinationPath $OutputZip -Force Remove-Item -LiteralPath $stageRoot -Recurse -Force Write-Host "[AbyssInfo] Packaged API to $OutputZip"