[CmdletBinding()] param( [switch]$Help ) $ErrorActionPreference = "Stop" if ($Help) { Write-Host "=========================================" -ForegroundColor Cyan Write-Host "Test Artifact Data Lake - Development Setup" -ForegroundColor Cyan Write-Host "=========================================" -ForegroundColor Cyan Write-Host "" Write-Host "Usage: .\dev-start.ps1 [OPTIONS]" -ForegroundColor White Write-Host "" Write-Host "Options:" -ForegroundColor Yellow Write-Host " -Help Show this help message" -ForegroundColor White Write-Host "" Write-Host "This script starts backend services and frontend development server." -ForegroundColor Green Write-Host "" exit 0 } Write-Host "=========================================" -ForegroundColor Cyan Write-Host "Test Artifact Data Lake - Development Setup" -ForegroundColor Cyan Write-Host "=========================================" -ForegroundColor Cyan Write-Host "" # Check if Node.js is installed if (-not (Get-Command "node" -ErrorAction SilentlyContinue)) { Write-Host "Error: Node.js is not installed. Please install Node.js 18+ first." -ForegroundColor Red Write-Host "Visit: https://nodejs.org/" -ForegroundColor Yellow Read-Host "Press Enter to exit" exit 1 } # Check Node.js version try { $nodeVersion = & node --version $majorVersion = [int]($nodeVersion -replace 'v(\d+)\..*', '$1') if ($majorVersion -lt 18) { Write-Host "Error: Node.js version 18 or higher is required. Current version: $nodeVersion" -ForegroundColor Red Read-Host "Press Enter to exit" exit 1 } Write-Host "[OK] Node.js version: $nodeVersion" -ForegroundColor Green } catch { Write-Host "Error: Failed to check Node.js version" -ForegroundColor Red Read-Host "Press Enter to exit" exit 1 } # Check if npm is installed if (-not (Get-Command "npm" -ErrorAction SilentlyContinue)) { Write-Host "Error: npm is not installed. Please install npm first." -ForegroundColor Red Read-Host "Press Enter to exit" exit 1 } $npmVersion = & npm --version Write-Host "[OK] npm version: $npmVersion" -ForegroundColor Green # Check if Docker is installed if (-not (Get-Command "docker" -ErrorAction SilentlyContinue)) { Write-Host "Error: Docker is not installed. Please install Docker Desktop first." -ForegroundColor Red Write-Host "Visit: https://www.docker.com/products/docker-desktop" -ForegroundColor Yellow Read-Host "Press Enter to exit" exit 1 } # Check if Docker Compose is available $ComposeCmd = $null if (Get-Command "docker-compose" -ErrorAction SilentlyContinue) { $ComposeCmd = "docker-compose" } else { try { & docker compose version | Out-Null $ComposeCmd = "docker compose" } catch { Write-Host "Error: Docker Compose is not available." -ForegroundColor Red Write-Host "Please ensure Docker Desktop is running." -ForegroundColor Yellow Read-Host "Press Enter to exit" exit 1 } } Write-Host "[OK] Docker Compose command: $ComposeCmd" -ForegroundColor Green Write-Host "" # Create .env file if it doesn't exist if (-not (Test-Path ".env")) { Write-Host "Creating .env file from .env.example..." -ForegroundColor Yellow Copy-Item ".env.example" ".env" Write-Host "[OK] .env file created" -ForegroundColor Green } else { Write-Host "[OK] .env file already exists" -ForegroundColor Green } Write-Host "" Write-Host "Starting backend services (PostgreSQL, MinIO, API)..." -ForegroundColor Yellow # Start backend services try { if ($ComposeCmd -eq "docker compose") { & docker compose up -d postgres minio api } else { & docker-compose up -d postgres minio api } } catch { Write-Host "Error: Failed to start backend services." -ForegroundColor Red Write-Host "Make sure Docker Desktop is running." -ForegroundColor Yellow Read-Host "Press Enter to exit" exit 1 } Write-Host "" Write-Host "Waiting for backend services to be ready..." -ForegroundColor Yellow Start-Sleep -Seconds 10 Write-Host "" Write-Host "Installing frontend dependencies..." -ForegroundColor Yellow Set-Location "frontend" try { & npm install Write-Host "[OK] Frontend dependencies installed" -ForegroundColor Green } catch { Write-Host "Error: Failed to install frontend dependencies" -ForegroundColor Red Set-Location ".." Read-Host "Press Enter to exit" exit 1 } Write-Host "" Write-Host "=========================================" -ForegroundColor Cyan Write-Host "Development Environment Ready!" -ForegroundColor Green Write-Host "=========================================" -ForegroundColor Cyan Write-Host "" Write-Host "Backend API: http://localhost:8000" -ForegroundColor White Write-Host "API Docs: http://localhost:8000/docs" -ForegroundColor White Write-Host "MinIO Console: http://localhost:9001" -ForegroundColor White Write-Host " Username: minioadmin" -ForegroundColor Gray Write-Host " Password: minioadmin" -ForegroundColor Gray Write-Host "" Write-Host "Frontend will be available at: http://localhost:4200" -ForegroundColor White Write-Host "" Write-Host "To view backend logs: $ComposeCmd logs -f api" -ForegroundColor Yellow Write-Host "To stop backend: $ComposeCmd down" -ForegroundColor Yellow Write-Host "" Write-Host "Starting frontend development server..." -ForegroundColor Green # Start the frontend development server & npm run start