61 lines
2.3 KiB
PowerShell
61 lines
2.3 KiB
PowerShell
|
|
# Frontend Fix Script
|
|||
|
|
|
|||
|
|
Write-Host "`n========================================" -ForegroundColor Cyan
|
|||
|
|
Write-Host " FRONTEND FIX SCRIPT" -ForegroundColor Cyan
|
|||
|
|
Write-Host "========================================`n" -ForegroundColor Cyan
|
|||
|
|
|
|||
|
|
# Step 1: Stop existing webapp
|
|||
|
|
Write-Host "1. Stopping existing webapp..." -ForegroundColor Yellow
|
|||
|
|
$webappProcess = Get-Process node -ErrorAction SilentlyContinue | Where-Object {
|
|||
|
|
(Get-NetTCPConnection -OwningProcess $_.Id -ErrorAction SilentlyContinue | Where-Object { $_.LocalPort -eq 3000 })
|
|||
|
|
}
|
|||
|
|
if ($webappProcess) {
|
|||
|
|
Stop-Process -Id $webappProcess.Id -Force -ErrorAction SilentlyContinue
|
|||
|
|
Write-Host " ✅ Stopped webapp process" -ForegroundColor Green
|
|||
|
|
Start-Sleep -Seconds 2
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# Step 2: Clear Next.js cache
|
|||
|
|
Write-Host "`n2. Clearing Next.js cache..." -ForegroundColor Yellow
|
|||
|
|
cd webapp
|
|||
|
|
if (Test-Path ".next") {
|
|||
|
|
Remove-Item -Recurse -Force .next -ErrorAction SilentlyContinue
|
|||
|
|
Write-Host " ✅ Cleared .next cache" -ForegroundColor Green
|
|||
|
|
} else {
|
|||
|
|
Write-Host " ℹ️ No cache to clear" -ForegroundColor Gray
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# Step 3: Check/Create .env.local
|
|||
|
|
Write-Host "`n3. Checking environment variables..." -ForegroundColor Yellow
|
|||
|
|
if (-not (Test-Path ".env.local")) {
|
|||
|
|
@"
|
|||
|
|
NEXT_PUBLIC_ORCH_URL=http://localhost:8080
|
|||
|
|
NEXTAUTH_SECRET=dev-secret-change-in-production-min-32-chars
|
|||
|
|
"@ | Out-File -FilePath ".env.local" -Encoding utf8
|
|||
|
|
Write-Host " [OK] Created .env.local" -ForegroundColor Green
|
|||
|
|
} else {
|
|||
|
|
Write-Host " [OK] .env.local exists" -ForegroundColor Green
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# Step 4: Verify dependencies
|
|||
|
|
Write-Host "`n4. Checking dependencies..." -ForegroundColor Yellow
|
|||
|
|
if (-not (Test-Path "node_modules")) {
|
|||
|
|
Write-Host " ⚠️ node_modules not found. Installing..." -ForegroundColor Yellow
|
|||
|
|
npm install
|
|||
|
|
} else {
|
|||
|
|
Write-Host " [OK] Dependencies installed" -ForegroundColor Green
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# Step 5: Start webapp
|
|||
|
|
Write-Host "`n5. Starting webapp..." -ForegroundColor Yellow
|
|||
|
|
Write-Host " Starting in new window..." -ForegroundColor Gray
|
|||
|
|
Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd '$PWD'; npm run dev" -WindowStyle Normal
|
|||
|
|
|
|||
|
|
Write-Host "`n[OK] Webapp starting!" -ForegroundColor Green
|
|||
|
|
Write-Host " Wait 10-15 seconds for Next.js to compile" -ForegroundColor Yellow
|
|||
|
|
Write-Host " Then open: http://localhost:3000" -ForegroundColor Cyan
|
|||
|
|
Write-Host ""
|
|||
|
|
|
|||
|
|
cd ..
|
|||
|
|
|