-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
165 lines (138 loc) · 5.8 KB
/
setup.ps1
File metadata and controls
165 lines (138 loc) · 5.8 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
153
154
155
156
157
158
159
160
161
162
163
164
165
# =============================================================================
# NSA-X Project Setup Script (Windows PowerShell)
# =============================================================================
# Run this script to set up the complete development environment
# Usage: .\setup.ps1
# =============================================================================
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " NSA-X Development Environment Setup " -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# -----------------------------------------------------------------------------
# Prerequisites Check
# -----------------------------------------------------------------------------
Write-Host "[1/6] Checking prerequisites..." -ForegroundColor Yellow
# Check Node.js
$nodeVersion = node --version 2>$null
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: Node.js not found. Please install Node.js 18+ from https://nodejs.org" -ForegroundColor Red
exit 1
}
Write-Host " Node.js: $nodeVersion" -ForegroundColor Green
# Check Python
$pythonVersion = python --version 2>$null
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: Python not found. Please install Python 3.11+ from https://python.org" -ForegroundColor Red
exit 1
}
Write-Host " Python: $pythonVersion" -ForegroundColor Green
# Check npm
$npmVersion = npm --version 2>$null
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: npm not found." -ForegroundColor Red
exit 1
}
Write-Host " npm: $npmVersion" -ForegroundColor Green
Write-Host ""
# -----------------------------------------------------------------------------
# Frontend Setup
# -----------------------------------------------------------------------------
Write-Host "[2/6] Setting up frontend..." -ForegroundColor Yellow
# Copy .env.example to .env if not exists
if (!(Test-Path ".env")) {
if (Test-Path ".env.example") {
Copy-Item ".env.example" ".env"
Write-Host " Created .env from .env.example" -ForegroundColor Green
}
}
# Install frontend dependencies
Write-Host " Installing npm packages..." -ForegroundColor Gray
npm install --silent
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: npm install failed" -ForegroundColor Red
exit 1
}
Write-Host " Frontend dependencies installed" -ForegroundColor Green
Write-Host ""
# -----------------------------------------------------------------------------
# Backend Setup
# -----------------------------------------------------------------------------
Write-Host "[3/6] Setting up backend..." -ForegroundColor Yellow
Push-Location backend
# Create virtual environment if not exists
if (!(Test-Path "venv")) {
Write-Host " Creating Python virtual environment..." -ForegroundColor Gray
python -m venv venv
}
# Activate virtual environment
Write-Host " Activating virtual environment..." -ForegroundColor Gray
& .\venv\Scripts\Activate.ps1
# Install backend dependencies
Write-Host " Installing Python packages..." -ForegroundColor Gray
pip install -r requirements.txt --quiet
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: pip install failed" -ForegroundColor Red
Pop-Location
exit 1
}
Write-Host " Backend dependencies installed" -ForegroundColor Green
# Copy .env.example to .env if not exists
if (!(Test-Path ".env")) {
if (Test-Path ".env.example") {
Copy-Item ".env.example" ".env"
Write-Host " Created backend .env from .env.example" -ForegroundColor Green
}
}
Pop-Location
Write-Host ""
# -----------------------------------------------------------------------------
# Database Setup
# -----------------------------------------------------------------------------
Write-Host "[4/6] Setting up database..." -ForegroundColor Yellow
Push-Location backend
& .\venv\Scripts\Activate.ps1
# Run migrations (SQLite will be created automatically)
Write-Host " Running database migrations..." -ForegroundColor Gray
alembic upgrade head 2>$null
if ($LASTEXITCODE -eq 0) {
Write-Host " Database migrations complete" -ForegroundColor Green
} else {
Write-Host " Note: Migrations may need manual setup (see backend/README.md)" -ForegroundColor Yellow
}
Pop-Location
Write-Host ""
# -----------------------------------------------------------------------------
# Verify Setup
# -----------------------------------------------------------------------------
Write-Host "[5/6] Verifying setup..." -ForegroundColor Yellow
# Check frontend build
Write-Host " Checking frontend build..." -ForegroundColor Gray
npm run build --silent 2>$null
if ($LASTEXITCODE -eq 0) {
Write-Host " Frontend builds successfully" -ForegroundColor Green
} else {
Write-Host " WARNING: Frontend build had issues" -ForegroundColor Yellow
}
Write-Host ""
# -----------------------------------------------------------------------------
# Success Message
# -----------------------------------------------------------------------------
Write-Host "[6/6] Setup complete!" -ForegroundColor Yellow
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Ready to start development! " -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "To start the application:" -ForegroundColor White
Write-Host ""
Write-Host " Backend (Terminal 1):" -ForegroundColor Gray
Write-Host " cd backend" -ForegroundColor White
Write-Host " .\venv\Scripts\Activate.ps1" -ForegroundColor White
Write-Host " uvicorn app.main:app --reload" -ForegroundColor White
Write-Host ""
Write-Host " Frontend (Terminal 2):" -ForegroundColor Gray
Write-Host " npm run dev" -ForegroundColor White
Write-Host ""
Write-Host " Then open: http://localhost:8080" -ForegroundColor Cyan
Write-Host " Login: admin / admin123" -ForegroundColor Cyan
Write-Host ""