File size: 1,780 Bytes
5cf987c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
param(
    [int]$BackendPort = 8000,
    [int]$FrontendPort = 3000,
    [switch]$DryRun
)

$ErrorActionPreference = "Stop"

$repoRoot = Resolve-Path "$PSScriptRoot\.."
$backendPath = Join-Path $repoRoot "backend"
$frontendPath = Join-Path $repoRoot "frontend"
$pythonPath = Join-Path $repoRoot ".venv\Scripts\python.exe"

if (-not (Test-Path $backendPath)) {
    throw "Backend folder not found: $backendPath"
}
if (-not (Test-Path $frontendPath)) {
    throw "Frontend folder not found: $frontendPath"
}
if (-not (Test-Path $pythonPath)) {
    throw "Python executable not found: $pythonPath"
}
if (-not (Get-Command npm -ErrorAction SilentlyContinue)) {
    throw "npm was not found in PATH. Install Node.js and retry."
}

$backendCommand = "Set-Location '$backendPath'; & '$pythonPath' -m uvicorn app.main:app --reload --port $BackendPort"
$frontendCommand = "Set-Location '$frontendPath'; npm run dev -- -p $FrontendPort"

Write-Host "Backend command:" -ForegroundColor Cyan
Write-Host $backendCommand
Write-Host "Frontend command:" -ForegroundColor Cyan
Write-Host $frontendCommand

if ($DryRun) {
    Write-Host "Dry-run mode enabled. No terminals launched." -ForegroundColor Yellow
    return
}

$backendProc = Start-Process -FilePath "powershell" -ArgumentList @("-NoExit", "-Command", $backendCommand) -PassThru
$frontendProc = Start-Process -FilePath "powershell" -ArgumentList @("-NoExit", "-Command", $frontendCommand) -PassThru

Write-Host "Started backend terminal (PID: $($backendProc.Id))." -ForegroundColor Green
Write-Host "Started frontend terminal (PID: $($frontendProc.Id))." -ForegroundColor Green
Write-Host "Backend URL: http://127.0.0.1:$BackendPort" -ForegroundColor Green
Write-Host "Frontend URL: http://127.0.0.1:$FrontendPort" -ForegroundColor Green