# setup-dev-environment.ps1 # Installs everything needed to develop and run the StudioFlow project on a new Windows machine. # # Run this ONCE on a fresh machine, then use export-data.ps1 / import-data.ps1 for data. # Recommended: run from an elevated PowerShell (right-click -> "Run as Administrator"). # # What gets installed: # - Git # - Node.js LTS (v24.x -- matches the current dev machine) # - VSCodium (open-source VS Code build without Microsoft telemetry) $ErrorActionPreference = "Stop" Write-Host "" Write-Host "============================================" -ForegroundColor Cyan Write-Host " StudioFlow -- Dev Environment Setup" -ForegroundColor Cyan Write-Host "============================================" -ForegroundColor Cyan Write-Host "" # --- Check: running as Administrator ------------------------------------------ $IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator ) if (-not $IsAdmin) { Write-Host "WARNING: Not running as Administrator." -ForegroundColor Yellow Write-Host " Some installers (Docker Desktop) may fail or prompt for elevation." -ForegroundColor Yellow Write-Host " Re-run with 'Run as Administrator' if anything fails." -ForegroundColor Yellow Write-Host "" } # --- Check: winget available -------------------------------------------------- if (-not (Get-Command winget -ErrorAction SilentlyContinue)) { Write-Host "ERROR: winget not found." -ForegroundColor Red Write-Host "Install it from the Microsoft Store (search 'App Installer') and re-run." exit 1 } # --- Helper: install one package via winget ----------------------------------- $NeedsRestart = $false function Install-Package($DisplayName, $WingetId) { Write-Host "" Write-Host "[$DisplayName]" -ForegroundColor Cyan # Check if already installed $listOutput = winget list --id $WingetId --exact --accept-source-agreements 2>&1 $alreadyInstalled = $listOutput | Where-Object { $_ -match [regex]::Escape($WingetId) } if ($alreadyInstalled) { Write-Host " Already installed -- skipping." -ForegroundColor Green return } Write-Host " Downloading and installing..." winget install ` --id $WingetId ` --exact ` --silent ` --accept-package-agreements ` --accept-source-agreements if ($LASTEXITCODE -eq 0) { Write-Host " Installed OK." -ForegroundColor Green } elseif ($LASTEXITCODE -eq -1978335189) { # 0x8A150021 -- "No applicable update found" means already installed at latest Write-Host " Already at latest version." -ForegroundColor Green } else { Write-Host " WARNING: winget exited with code $LASTEXITCODE." -ForegroundColor Yellow Write-Host " The install may have partially worked -- check manually." -ForegroundColor Yellow } } # --- Install core tools ------------------------------------------------------- Install-Package "Git" "Git.Git" Install-Package "Node.js LTS (v24)" "OpenJS.NodeJS.LTS" Install-Package "VSCodium" "VSCodium.VSCodium" # --- Refresh PATH so npm is available in this session ------------------------- Write-Host "" Write-Host "[Refreshing PATH]" -ForegroundColor Cyan $MachinePath = [System.Environment]::GetEnvironmentVariable("Path", "Machine") $UserPath = [System.Environment]::GetEnvironmentVariable("Path", "User") $env:Path = "$MachinePath;$UserPath" Write-Host " Done." -ForegroundColor Green # --- Summary ------------------------------------------------------------------ Write-Host "" Write-Host "============================================" -ForegroundColor Cyan Write-Host " Setup complete!" -ForegroundColor Cyan Write-Host "============================================" -ForegroundColor Cyan Write-Host "" Write-Host "IMPORTANT -- before you can run the project:" -ForegroundColor Yellow Write-Host "" Write-Host " 1. Restart your terminal (or reboot) so Git and Node are in PATH." -ForegroundColor White Write-Host "" Write-Host " 2. Copy the project folder to this machine (or clone from git)." -ForegroundColor White Write-Host "" Write-Host " 3. Copy the data_backup\ folder into the project root" -ForegroundColor White Write-Host " and run: .\import-data.ps1" -ForegroundColor White Write-Host "" Write-Host " 4. Start infrastructure (Docker Desktop must already be running):" -ForegroundColor White Write-Host " cd infrastructure" -ForegroundColor Gray Write-Host " docker compose up -d postgres redis" -ForegroundColor Gray Write-Host "" Write-Host " 5. Install dependencies and start the app:" -ForegroundColor White Write-Host " cd backend && npm install && npm run start:dev" -ForegroundColor Gray Write-Host " cd frontend && npm install && npm run dev" -ForegroundColor Gray Write-Host " (second terminal for the worker)" -ForegroundColor Gray Write-Host " cd backend && npx ts-node src/worker.ts" -ForegroundColor Gray Write-Host ""