param( [string]$OutputPath = "release\intelligent-cost-prediction-html5.zip" ) $ErrorActionPreference = "Stop" $repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..") $sourceDir = Join-Path $repoRoot "html5_cost_prediction" $releaseRoot = Join-Path $repoRoot "release" $stageDir = Join-Path $releaseRoot "intelligent-cost-prediction-html5" $zipPath = Join-Path $repoRoot $OutputPath function Assert-InRepo([string]$PathToCheck) { $resolved = [System.IO.Path]::GetFullPath($PathToCheck) $root = [System.IO.Path]::GetFullPath($repoRoot) if (-not $resolved.StartsWith($root, [System.StringComparison]::OrdinalIgnoreCase)) { throw "Refusing to operate outside repository: $resolved" } } Assert-InRepo $stageDir Assert-InRepo $zipPath New-Item -ItemType Directory -Force -Path $releaseRoot | Out-Null if (Test-Path $stageDir) { Remove-Item -LiteralPath $stageDir -Recurse -Force } if (Test-Path $zipPath) { Remove-Item -LiteralPath $zipPath -Force } Copy-Item -Recurse -Path $sourceDir -Destination $stageDir Compress-Archive -Path (Join-Path $stageDir "*") -DestinationPath $zipPath -Force Write-Host "HTML5 zip created: $zipPath"