-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-local-dev.ps1
More file actions
153 lines (132 loc) Β· 6.01 KB
/
start-local-dev.ps1
File metadata and controls
153 lines (132 loc) Β· 6.01 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# PowerShell script to start both frontend and backend for local development
# Run this from the project root directory
Write-Host "π Starting Plated Local Development Environment..." -ForegroundColor Green
Write-Host ""
# Check if Node.js is installed
try {
$nodeVersion = node --version
Write-Host "β
Node.js version: $nodeVersion" -ForegroundColor Green
} catch {
Write-Host "β Node.js is not installed. Please install Node.js v18+ first." -ForegroundColor Red
Write-Host " Download from: https://nodejs.org/" -ForegroundColor Yellow
exit 1
}
# Check if Python is installed
try {
$pythonVersion = python --version
Write-Host "β
Python version: $pythonVersion" -ForegroundColor Green
} catch {
Write-Host "β Python is not installed. Please install Python 3.8+ first." -ForegroundColor Red
Write-Host " Download from: https://www.python.org/downloads/" -ForegroundColor Yellow
exit 1
}
Write-Host ""
Write-Host "π¦ Checking dependencies..." -ForegroundColor Cyan
Write-Host ""
# Check if backend dependencies are installed
if (-not (Test-Path "backend/venv")) {
Write-Host "β οΈ Backend virtual environment not found. Creating..." -ForegroundColor Yellow
cd backend
python -m venv venv
Write-Host "β
Virtual environment created" -ForegroundColor Green
cd ..
}
# Check if frontend dependencies are installed
if (-not (Test-Path "frontend/Plated/node_modules")) {
Write-Host "β οΈ Frontend dependencies not found. Installing..." -ForegroundColor Yellow
cd frontend/Plated
npm install
Write-Host "β
Frontend dependencies installed" -ForegroundColor Green
cd ../..
}
Write-Host ""
Write-Host "π§ Starting servers..." -ForegroundColor Cyan
Write-Host ""
# Function to start backend
$backendJob = Start-Job -ScriptBlock {
cd $using:PWD
cd backend
& .\venv\Scripts\Activate.ps1
$env:ENV = "dev"
python app.py
}
Write-Host "β
Backend server starting... (Job ID: $($backendJob.Id))" -ForegroundColor Green
Write-Host " Backend will be available at: http://localhost:5000" -ForegroundColor Cyan
# Wait a moment for backend to start
Start-Sleep -Seconds 3
# Function to start frontend
$frontendJob = Start-Job -ScriptBlock {
cd $using:PWD
cd frontend/Plated
npm run dev
}
Write-Host "β
Frontend server starting... (Job ID: $($frontendJob.Id))" -ForegroundColor Green
Write-Host " Frontend will be available at: http://localhost:5173" -ForegroundColor Cyan
Write-Host ""
Write-Host "ββββββββββββββββββββββββββββββββββββββββββββββββββββββ" -ForegroundColor Gray
Write-Host "π Development servers are starting!" -ForegroundColor Green
Write-Host "ββββββββββββββββββββββββββββββββββββββββββββββββββββββ" -ForegroundColor Gray
Write-Host ""
Write-Host "π Frontend: http://localhost:5173" -ForegroundColor Cyan
Write-Host "π Backend: http://localhost:5000" -ForegroundColor Cyan
Write-Host ""
Write-Host "π‘ To test the application:" -ForegroundColor Yellow
Write-Host " 1. Open http://localhost:5173 in your browser" -ForegroundColor White
Write-Host " 2. Click 'Get Started' or 'Sign In'" -ForegroundColor White
Write-Host " 3. Click 'Continue with Mock Login (Testing)'" -ForegroundColor White
Write-Host " 4. Complete your profile and start testing!" -ForegroundColor White
Write-Host ""
Write-Host "π To view server logs:" -ForegroundColor Yellow
Write-Host " Backend: Receive-Job -Id $($backendJob.Id) -Keep" -ForegroundColor White
Write-Host " Frontend: Receive-Job -Id $($frontendJob.Id) -Keep" -ForegroundColor White
Write-Host ""
Write-Host "π To stop servers:" -ForegroundColor Yellow
Write-Host " Press Ctrl+C or run: Stop-Job -Id $($backendJob.Id),$($frontendJob.Id); Remove-Job -Id $($backendJob.Id),$($frontendJob.Id)" -ForegroundColor White
Write-Host ""
Write-Host "ββββββββββββββββββββββββββββββββββββββββββββββββββββββ" -ForegroundColor Gray
Write-Host ""
# Wait for user input
Write-Host "β³ Servers are running in the background..." -ForegroundColor Cyan
Write-Host " Press 'Q' to stop all servers and exit" -ForegroundColor Yellow
Write-Host " Press 'L' to view logs" -ForegroundColor Yellow
Write-Host ""
# Monitor jobs and wait for user input
$continue = $true
while ($continue) {
if ($Host.UI.RawUI.KeyAvailable) {
$key = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp")
if ($key.Character -eq 'q' -or $key.Character -eq 'Q') {
$continue = $false
} elseif ($key.Character -eq 'l' -or $key.Character -eq 'L') {
Write-Host ""
Write-Host "βββ BACKEND LOGS βββ" -ForegroundColor Cyan
Receive-Job -Id $backendJob.Id -Keep | Select-Object -Last 20
Write-Host ""
Write-Host "βββ FRONTEND LOGS βββ" -ForegroundColor Cyan
Receive-Job -Id $frontendJob.Id -Keep | Select-Object -Last 20
Write-Host ""
}
}
# Check if jobs are still running
$backendState = (Get-Job -Id $backendJob.Id).State
$frontendState = (Get-Job -Id $frontendJob.Id).State
if ($backendState -eq 'Failed') {
Write-Host "β Backend server failed!" -ForegroundColor Red
Receive-Job -Id $backendJob.Id
$continue = $false
}
if ($frontendState -eq 'Failed') {
Write-Host "β Frontend server failed!" -ForegroundColor Red
Receive-Job -Id $frontendJob.Id
$continue = $false
}
Start-Sleep -Milliseconds 500
}
# Cleanup
Write-Host ""
Write-Host "π Stopping servers..." -ForegroundColor Yellow
Stop-Job -Id $backendJob.Id, $frontendJob.Id
Remove-Job -Id $backendJob.Id, $frontendJob.Id
Write-Host "β
All servers stopped" -ForegroundColor Green
Write-Host ""
Write-Host "π Goodbye!" -ForegroundColor Cyan