$ErrorActionPreference = "Stop"

# Lade .env Datei automatisch
Write-Host "Loading .env file..."
if (Test-Path ".env") {
    Get-Content ".env" | ForEach-Object {
        if ($_ -match '^([^#][^=]+)=(.*)$') {
            $name = $matches[1].Trim()
            $value = $matches[2].Trim()
            [Environment]::SetEnvironmentVariable($name, $value, 'Process')
            Write-Host "✓ Loaded from .env: $name" -ForegroundColor Green
        }
    }
    Write-Host "Environment variables loaded from .env file" -ForegroundColor Cyan
} else {
    Write-Warning ".env file not found!"
    Write-Host "Please create a .env file with your environment variables." -ForegroundColor Red
    exit 1
}

Write-Host "Starting app with pnpm dev..."
pnpm dev


