Initial commit: GSPro Remote MVP - Phase 1 complete
This commit is contained in:
commit
74ca4b38eb
50 changed files with 12818 additions and 0 deletions
193
scripts/dev.ps1
Normal file
193
scripts/dev.ps1
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
# GSPro Remote Development Script
|
||||
# Starts both backend and frontend servers for development
|
||||
|
||||
Write-Host "GSPro Remote Development Environment" -ForegroundColor Green
|
||||
Write-Host "=====================================" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# Check if Python is installed
|
||||
$pythonVersion = python --version 2>$null
|
||||
if (-not $pythonVersion) {
|
||||
Write-Host "ERROR: Python is not installed or not in PATH" -ForegroundColor Red
|
||||
Write-Host "Please install Python 3.11+ from https://www.python.org/" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
Write-Host "✓ Python found: $pythonVersion" -ForegroundColor Green
|
||||
|
||||
# Check if Node.js is installed
|
||||
$nodeVersion = node --version 2>$null
|
||||
if (-not $nodeVersion) {
|
||||
Write-Host "ERROR: Node.js is not installed or not in PATH" -ForegroundColor Red
|
||||
Write-Host "Please install Node.js 20+ from https://nodejs.org/" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
Write-Host "✓ Node.js found: $nodeVersion" -ForegroundColor Green
|
||||
|
||||
# Check if npm is installed
|
||||
$npmVersion = npm --version 2>$null
|
||||
if (-not $npmVersion) {
|
||||
Write-Host "ERROR: npm is not installed or not in PATH" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Write-Host "✓ npm found: $npmVersion" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# Get the script directory (project root)
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$projectRoot = Split-Path -Parent $scriptDir
|
||||
$backendDir = Join-Path $projectRoot "backend"
|
||||
$frontendDir = Join-Path $projectRoot "frontend"
|
||||
|
||||
# Function to check if a port is in use
|
||||
function Test-Port {
|
||||
param($port)
|
||||
$tcpClient = New-Object System.Net.Sockets.TcpClient
|
||||
try {
|
||||
$tcpClient.Connect("localhost", $port)
|
||||
$tcpClient.Close()
|
||||
return $true
|
||||
} catch {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
# Check if backend port is already in use
|
||||
if (Test-Port 5005) {
|
||||
Write-Host "WARNING: Port 5005 is already in use. Backend server might already be running." -ForegroundColor Yellow
|
||||
Write-Host "Do you want to continue anyway? (Y/N): " -NoNewline
|
||||
$response = Read-Host
|
||||
if ($response -ne "Y" -and $response -ne "y") {
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
# Check if frontend port is already in use
|
||||
if (Test-Port 5173) {
|
||||
Write-Host "WARNING: Port 5173 is already in use. Frontend server might already be running." -ForegroundColor Yellow
|
||||
Write-Host "Do you want to continue anyway? (Y/N): " -NoNewline
|
||||
$response = Read-Host
|
||||
if ($response -ne "Y" -and $response -ne "y") {
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
# Setup backend
|
||||
Write-Host "Setting up Backend..." -ForegroundColor Cyan
|
||||
Set-Location $backendDir
|
||||
|
||||
# Check if virtual environment exists
|
||||
$venvPath = Join-Path $backendDir ".venv"
|
||||
if (-not (Test-Path $venvPath)) {
|
||||
Write-Host "Creating Python virtual environment..." -ForegroundColor Yellow
|
||||
python -m venv .venv
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "ERROR: Failed to create virtual environment" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Activate virtual environment and install dependencies
|
||||
Write-Host "Installing backend dependencies..." -ForegroundColor Yellow
|
||||
$activateScript = Join-Path $venvPath "Scripts\Activate.ps1"
|
||||
if (Test-Path $activateScript) {
|
||||
& $activateScript
|
||||
} else {
|
||||
Write-Host "ERROR: Virtual environment activation script not found" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if requirements are installed
|
||||
$pipList = pip list 2>$null
|
||||
if (-not ($pipList -like "*fastapi*")) {
|
||||
Write-Host "Installing Python packages..." -ForegroundColor Yellow
|
||||
pip install -e . 2>&1 | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "ERROR: Failed to install backend dependencies" -ForegroundColor Red
|
||||
Write-Host "Try running: pip install -e . manually in the backend directory" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "✓ Backend dependencies installed" -ForegroundColor Green
|
||||
|
||||
# Setup frontend
|
||||
Write-Host ""
|
||||
Write-Host "Setting up Frontend..." -ForegroundColor Cyan
|
||||
Set-Location $frontendDir
|
||||
|
||||
# Check if node_modules exists
|
||||
if (-not (Test-Path "node_modules")) {
|
||||
Write-Host "Installing frontend dependencies..." -ForegroundColor Yellow
|
||||
npm install 2>&1 | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "ERROR: Failed to install frontend dependencies" -ForegroundColor Red
|
||||
Write-Host "Try running: npm install manually in the frontend directory" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "✓ Frontend dependencies installed" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# Start servers
|
||||
Write-Host "Starting Development Servers..." -ForegroundColor Cyan
|
||||
Write-Host "================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Start backend server in a new PowerShell window
|
||||
Write-Host "Starting Backend Server on http://localhost:5005" -ForegroundColor Green
|
||||
$backendScript = @"
|
||||
Write-Host 'GSPro Remote Backend Server' -ForegroundColor Cyan
|
||||
Write-Host '===========================' -ForegroundColor Cyan
|
||||
Write-Host ''
|
||||
Write-Host 'Server: http://localhost:5005' -ForegroundColor Yellow
|
||||
Write-Host 'API Docs: http://localhost:5005/api/docs' -ForegroundColor Yellow
|
||||
Write-Host 'mDNS: http://gsproapp.local:5005' -ForegroundColor Yellow
|
||||
Write-Host ''
|
||||
Set-Location '$backendDir'
|
||||
& '$activateScript'
|
||||
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 5005 --log-level info
|
||||
"@
|
||||
|
||||
$backendScriptPath = Join-Path $env:TEMP "gspro-backend.ps1"
|
||||
$backendScript | Out-File -FilePath $backendScriptPath -Encoding UTF8
|
||||
Start-Process powershell -ArgumentList "-NoExit", "-ExecutionPolicy", "Bypass", "-File", $backendScriptPath
|
||||
|
||||
# Give backend a moment to start
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
# Start frontend server in a new PowerShell window
|
||||
Write-Host "Starting Frontend Server on http://localhost:5173" -ForegroundColor Green
|
||||
$frontendScript = @"
|
||||
Write-Host 'GSPro Remote Frontend Server' -ForegroundColor Cyan
|
||||
Write-Host '============================' -ForegroundColor Cyan
|
||||
Write-Host ''
|
||||
Write-Host 'UI: http://localhost:5173' -ForegroundColor Yellow
|
||||
Write-Host ''
|
||||
Set-Location '$frontendDir'
|
||||
npm run dev
|
||||
"@
|
||||
|
||||
$frontendScriptPath = Join-Path $env:TEMP "gspro-frontend.ps1"
|
||||
$frontendScript | Out-File -FilePath $frontendScriptPath -Encoding UTF8
|
||||
Start-Process powershell -ArgumentList "-NoExit", "-ExecutionPolicy", "Bypass", "-File", $frontendScriptPath
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Development servers starting..." -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "Access Points:" -ForegroundColor Cyan
|
||||
Write-Host " Frontend UI: http://localhost:5173" -ForegroundColor White
|
||||
Write-Host " Backend API: http://localhost:5005" -ForegroundColor White
|
||||
Write-Host " API Docs: http://localhost:5005/api/docs" -ForegroundColor White
|
||||
Write-Host " mDNS Access: http://gsproapp.local:5005" -ForegroundColor White
|
||||
Write-Host ""
|
||||
Write-Host "Press any key to stop watching for changes..." -ForegroundColor Yellow
|
||||
|
||||
# Wait for user input
|
||||
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||
|
||||
# The servers are running in separate windows, so they'll keep running
|
||||
# This script can exit, and the user can close the server windows manually
|
||||
Write-Host ""
|
||||
Write-Host "Note: The servers are still running in separate windows." -ForegroundColor Yellow
|
||||
Write-Host "Close those windows to stop the servers." -ForegroundColor Yellow
|
||||
Loading…
Add table
Add a link
Reference in a new issue