104 lines
3.6 KiB
PowerShell
104 lines
3.6 KiB
PowerShell
Write-Host "AZA Desktop EXE Build gestartet..."
|
|
|
|
$projectRoot = $PSScriptRoot
|
|
$specFile = Join-Path $projectRoot "aza_desktop.spec"
|
|
|
|
Set-Location $projectRoot
|
|
|
|
# --- Pre-Build-Validierung: Produktivwerte pruefen ---
|
|
Write-Host ""
|
|
Write-Host "Pre-Build-Validierung..."
|
|
|
|
$urlFile = Join-Path $projectRoot "backend_url.txt"
|
|
if (-not (Test-Path $urlFile)) {
|
|
Write-Error "ABBRUCH: backend_url.txt nicht gefunden. Datei muss die produktive Backend-URL enthalten."
|
|
exit 1
|
|
}
|
|
$urlContent = (Get-Content $urlFile -Raw).Trim()
|
|
if ($urlContent -match "127\.0\.0\.1|localhost|0\.0\.0\.0") {
|
|
Write-Error "ABBRUCH: backend_url.txt enthaelt eine lokale Adresse ($urlContent). Bitte auf die produktive URL setzen (z.B. https://api.aza-medwork.ch)."
|
|
exit 1
|
|
}
|
|
if (-not $urlContent) {
|
|
Write-Error "ABBRUCH: backend_url.txt ist leer. Bitte die produktive Backend-URL eintragen."
|
|
exit 1
|
|
}
|
|
Write-Host " backend_url.txt OK: $urlContent"
|
|
|
|
$tokenFile = Join-Path $projectRoot "backend_token.txt"
|
|
if (-not (Test-Path $tokenFile)) {
|
|
Write-Error "ABBRUCH: backend_token.txt nicht gefunden. Datei muss den produktiven API-Token enthalten."
|
|
exit 1
|
|
}
|
|
$tokenContent = (Get-Content $tokenFile -Raw).Trim()
|
|
if (-not $tokenContent) {
|
|
Write-Error "ABBRUCH: backend_token.txt ist leer. Bitte den produktiven API-Token eintragen."
|
|
exit 1
|
|
}
|
|
if ($tokenContent -match "CHANGE_ME") {
|
|
Write-Error "ABBRUCH: backend_token.txt enthaelt einen Platzhalter ($tokenContent). Bitte den echten produktiven Token eintragen."
|
|
exit 1
|
|
}
|
|
Write-Host " backend_token.txt OK (Token vorhanden, kein Platzhalter)"
|
|
Write-Host ""
|
|
|
|
Write-Host "Build-Stamp erzeugen (_build_info.py)..."
|
|
python (Join-Path $projectRoot "aza_build_stamp.py")
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Warning "Build-Stamp konnte nicht erzeugt werden - fahre trotzdem fort."
|
|
}
|
|
|
|
Write-Host "PyInstaller Installation pruefen..."
|
|
pip install pyinstaller --quiet
|
|
|
|
Write-Host "Alte Build-Artefakte werden bereinigt..."
|
|
if (Test-Path (Join-Path $projectRoot "build")) {
|
|
Remove-Item (Join-Path $projectRoot "build") -Recurse -Force
|
|
}
|
|
if (Test-Path (Join-Path $projectRoot "dist\aza_desktop")) {
|
|
Remove-Item (Join-Path $projectRoot "dist\aza_desktop") -Recurse -Force
|
|
}
|
|
|
|
Write-Host "EXE wird aus aza_desktop.spec gebaut..."
|
|
pyinstaller --noconfirm $specFile
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "PyInstaller Build fehlgeschlagen."
|
|
exit 1
|
|
}
|
|
|
|
$exePath = Join-Path $projectRoot "dist\aza_desktop\aza_desktop.exe"
|
|
if (-not (Test-Path $exePath)) {
|
|
Write-Error "Build wurde beendet, aber die EXE wurde nicht gefunden: $exePath"
|
|
exit 1
|
|
}
|
|
|
|
# backend_url.txt und backend_token.txt auch im dist-Root ablegen (neben der EXE),
|
|
# damit Installer und Runtime sie zuverlaessig finden.
|
|
$distRoot = Join-Path $projectRoot "dist\aza_desktop"
|
|
$internalDir = Join-Path $distRoot "_internal"
|
|
foreach ($cfgFile in @("backend_url.txt", "backend_token.txt")) {
|
|
$src = Join-Path $internalDir $cfgFile
|
|
$dst = Join-Path $distRoot $cfgFile
|
|
if ((Test-Path $src) -and -not (Test-Path $dst)) {
|
|
Copy-Item $src $dst -Force
|
|
Write-Host " $cfgFile -> dist\aza_desktop\ kopiert"
|
|
}
|
|
}
|
|
|
|
# Build-Info als lesbares Textfile neben die EXE legen
|
|
$buildInfoPy = Join-Path $projectRoot "_build_info.py"
|
|
if (Test-Path $buildInfoPy) {
|
|
$biDst = Join-Path $distRoot "BUILD_INFO.txt"
|
|
$biContent = Get-Content $buildInfoPy -Raw
|
|
$biContent | Out-File -FilePath $biDst -Encoding utf8
|
|
Write-Host " BUILD_INFO.txt -> dist\aza_desktop\ kopiert"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "Build fertig."
|
|
Write-Host "Die Desktop-App liegt in:"
|
|
Write-Host $distRoot
|
|
Write-Host "EXE:"
|
|
Write-Host $exePath
|