58 lines
2.2 KiB
PowerShell
58 lines
2.2 KiB
PowerShell
param(
|
|
[string]$OutputPath = "release\algorithm-demo-standalone.zip"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
|
|
$releaseRoot = Join-Path $repoRoot "release"
|
|
$stageDir = Join-Path $releaseRoot "algorithm-demo-standalone"
|
|
$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
|
|
|
|
Push-Location (Join-Path $repoRoot "frontend")
|
|
try {
|
|
npm run build
|
|
}
|
|
finally {
|
|
Pop-Location
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
New-Item -ItemType Directory -Force -Path $stageDir | Out-Null
|
|
New-Item -ItemType Directory -Force -Path (Join-Path $stageDir "data") | Out-Null
|
|
|
|
Copy-Item -Recurse -Path (Join-Path $repoRoot "frontend\dist") -Destination (Join-Path $stageDir "frontend")
|
|
Copy-Item -Path (Join-Path $repoRoot "src\demo_service.py") -Destination (Join-Path $stageDir "demo_service.py")
|
|
Copy-Item -Path (Join-Path $repoRoot "data\demo_equipment_costs.csv") -Destination (Join-Path $stageDir "data\demo_equipment_costs.csv")
|
|
Copy-Item -Path (Join-Path $repoRoot "demo_standalone\server.py") -Destination (Join-Path $stageDir "server.py")
|
|
Copy-Item -Path (Join-Path $repoRoot "demo_standalone\requirements.txt") -Destination (Join-Path $stageDir "requirements.txt")
|
|
Copy-Item -Path (Join-Path $repoRoot "demo_standalone\start_demo.bat") -Destination (Join-Path $stageDir "start_demo.bat")
|
|
Copy-Item -Path (Join-Path $repoRoot "demo_standalone\README.md") -Destination (Join-Path $stageDir "README.md")
|
|
|
|
Get-ChildItem -Path $stageDir -Recurse -Include "*.map", "__pycache__" | ForEach-Object {
|
|
Remove-Item -LiteralPath $_.FullName -Recurse -Force
|
|
}
|
|
|
|
Compress-Archive -Path (Join-Path $stageDir "*") -DestinationPath $zipPath -Force
|
|
|
|
Write-Host "Demo zip created: $zipPath"
|