-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-dev.ps1
More file actions
65 lines (54 loc) · 2.99 KB
/
Copy pathstart-dev.ps1
File metadata and controls
65 lines (54 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env pwsh
# Meru Coders - Development Startup Script
# Starts both backend and frontend for local development
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Meru Coders - Development Server" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# Get the script directory
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$BackendDir = Join-Path $ScriptDir "backend"
$FrontendDir = Join-Path $ScriptDir "frontend"
# Get local IP address
$LocalIP = (Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.InterfaceAlias -notmatch 'Loopback' -and $_.IPAddress -notmatch '^169\.' -and $_.IPAddress -ne '127.0.0.1' } | Select-Object -First 1).IPAddress
if (-not $LocalIP) { $LocalIP = "localhost" }
Write-Host "Detected Local IP: $LocalIP" -ForegroundColor Green
Write-Host ""
# Check if directories exist
if (-not (Test-Path $BackendDir)) {
Write-Host "ERROR: Backend directory not found at $BackendDir" -ForegroundColor Red
exit 1
}
if (-not (Test-Path $FrontendDir)) {
Write-Host "ERROR: Frontend directory not found at $FrontendDir" -ForegroundColor Red
exit 1
}
# Start Backend in a new PowerShell window (with venv activation)
Write-Host "[1/2] Starting Backend API server..." -ForegroundColor Yellow
$backendCmd = "cd '$BackendDir'; .\venv\Scripts\Activate.ps1; `$env:PYTHONPATH='$ScriptDir'; python run.py"
Start-Process powershell -ArgumentList "-NoExit", "-Command", $backendCmd -WindowStyle Normal
# Wait for backend to start
Write-Host " Waiting for backend to initialize..." -ForegroundColor Gray
Start-Sleep -Seconds 4
# Start Frontend in a new PowerShell window with VITE_API_URL set
Write-Host "[2/2] Starting Frontend dev server..." -ForegroundColor Yellow
# Set VITE_API_URL so frontend knows where the backend is
$frontendCmd = "`$env:PATH = `$env:PATH + ';C:\Program Files\nodejs;' + `$env:APPDATA + '\npm'; `$env:VITE_API_URL = 'http://${LocalIP}:5000/api'; cd '$FrontendDir'; npm run dev -- --host"
Start-Process powershell -ArgumentList "-NoExit", "-Command", $frontendCmd -WindowStyle Normal
# Wait for frontend to start
Start-Sleep -Seconds 2
Write-Host ""
Write-Host "========================================" -ForegroundColor Green
Write-Host " Servers Started Successfully!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host ""
Write-Host " Local Access:" -ForegroundColor Yellow
Write-Host " Frontend: http://localhost:8080" -ForegroundColor White
Write-Host " Backend: http://localhost:5000/api" -ForegroundColor White
Write-Host ""
Write-Host " Network Access (for other devices):" -ForegroundColor Yellow
Write-Host " Frontend: http://${LocalIP}:8080" -ForegroundColor Green
Write-Host " Backend: http://${LocalIP}:5000/api" -ForegroundColor Green
Write-Host ""
Write-Host " Press any key to close this window..." -ForegroundColor Gray
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")