66 lines
2.1 KiB
PowerShell
66 lines
2.1 KiB
PowerShell
# Ensure we are in the frontend directory
|
|
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
Set-Location $ScriptDir
|
|
|
|
# $ProjectRoot = Split-Path -Parent $ScriptDir
|
|
# $BackendBuildScript = Join-Path $ProjectRoot "backend\build_backend.ps1"
|
|
|
|
# Write-Host "Starting Full Build Process..." -ForegroundColor Cyan
|
|
|
|
# # 1. Build Backend
|
|
# Write-Host "Invoking Backend Build..." -ForegroundColor Yellow
|
|
# & $BackendBuildScript
|
|
# if ($LASTEXITCODE -ne 0) {
|
|
# Write-Error "Backend build failed. Aborting."
|
|
# exit 1
|
|
# }
|
|
|
|
# 2. Build Frontend (Electron)
|
|
Write-Host "`nBuilding Frontend (Electron)..." -ForegroundColor Yellow
|
|
|
|
# Ensure we are back in frontend directory (Backend script changes location)
|
|
Set-Location $ScriptDir
|
|
|
|
try {
|
|
Get-Process -Name "SmartEDT" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
|
} catch {}
|
|
|
|
# Clean release directory to prevent file lock issues
|
|
if (Test-Path "release") {
|
|
Write-Host "Cleaning release directory..." -ForegroundColor Yellow
|
|
|
|
# Try multiple times to remove the directory
|
|
$maxRetries = 3
|
|
$retryCount = 0
|
|
while ($retryCount -lt $maxRetries) {
|
|
try {
|
|
Remove-Item -Recurse -Force "release" -ErrorAction Stop
|
|
break
|
|
} catch {
|
|
Write-Host "Failed to clean release directory. Retrying in 2 seconds... ($($retryCount + 1)/$maxRetries)" -ForegroundColor Yellow
|
|
Start-Sleep -Seconds 2
|
|
try {
|
|
Get-Process -Name "SmartEDT" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
|
} catch {}
|
|
$retryCount++
|
|
}
|
|
}
|
|
|
|
if (Test-Path "release") {
|
|
Write-Warning "Could not fully clean release directory. Attempting to proceed..."
|
|
} else {
|
|
# Wait a bit to ensure filesystem is ready
|
|
Start-Sleep -Seconds 1
|
|
}
|
|
}
|
|
|
|
npm run dist
|
|
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host "`nFull build successful!" -ForegroundColor Green
|
|
Write-Host "Installer located at: $(Join-Path $ScriptDir 'release\SmartEDT Setup 0.1.0.exe')" -ForegroundColor Green
|
|
} else {
|
|
Write-Error "`nFrontend build failed!"
|
|
exit 1
|
|
}
|