# ======================================== # SCRIPT PARA INICIAR O PROJETO LOCALMENTE # ======================================== Write-Host "========================================" -ForegroundColor Cyan Write-Host " INICIANDO PROJETO SGSE" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" # Diretório do projeto $PROJECT_ROOT = "C:\Users\Deyvison\OneDrive\Desktop\Secretaria de Esportes\Tecnologia da Informacao\SGSE\sgse-app" Write-Host "1. Navegando para o diretório do projeto..." -ForegroundColor Yellow Set-Location $PROJECT_ROOT Write-Host " Diretório atual: $(Get-Location)" -ForegroundColor White Write-Host "" # Verificar se os arquivos .env existem Write-Host "2. Verificando arquivos .env..." -ForegroundColor Yellow if (Test-Path "packages\backend\.env") { Write-Host " [OK] packages\backend\.env encontrado" -ForegroundColor Green Get-Content "packages\backend\.env" | ForEach-Object { Write-Host " $_" -ForegroundColor Gray } } else { Write-Host " [ERRO] packages\backend\.env NAO encontrado!" -ForegroundColor Red Write-Host " Criando arquivo..." -ForegroundColor Yellow @" BETTER_AUTH_SECRET=+Nfg4jTxPv1giF5MlmyYTxpU/VkS3QaDOvgSWd+QmbY= SITE_URL=http://localhost:5173 "@ | Out-File -FilePath "packages\backend\.env" -Encoding utf8 Write-Host " [OK] Arquivo criado!" -ForegroundColor Green } Write-Host "" if (Test-Path "apps\web\.env") { Write-Host " [OK] apps\web\.env encontrado" -ForegroundColor Green Get-Content "apps\web\.env" | ForEach-Object { Write-Host " $_" -ForegroundColor Gray } } else { Write-Host " [ERRO] apps\web\.env NAO encontrado!" -ForegroundColor Red Write-Host " Criando arquivo..." -ForegroundColor Yellow @" PUBLIC_CONVEX_URL=http://127.0.0.1:3210 PUBLIC_SITE_URL=http://localhost:5173 "@ | Out-File -FilePath "apps\web\.env" -Encoding utf8 Write-Host " [OK] Arquivo criado!" -ForegroundColor Green } Write-Host "" # Verificar processos nas portas Write-Host "3. Verificando portas..." -ForegroundColor Yellow $port5173 = Get-NetTCPConnection -LocalPort 5173 -ErrorAction SilentlyContinue $port3210 = Get-NetTCPConnection -LocalPort 3210 -ErrorAction SilentlyContinue if ($port5173) { Write-Host " [AVISO] Porta 5173 em uso (Vite)" -ForegroundColor Yellow $pid5173 = $port5173 | Select-Object -First 1 -ExpandProperty OwningProcess Write-Host " Matando processo PID: $pid5173" -ForegroundColor Yellow Stop-Process -Id $pid5173 -Force Start-Sleep -Seconds 2 Write-Host " [OK] Processo finalizado" -ForegroundColor Green } else { Write-Host " [OK] Porta 5173 disponível" -ForegroundColor Green } if ($port3210) { Write-Host " [OK] Porta 3210 em uso (Convex rodando)" -ForegroundColor Green } else { Write-Host " [AVISO] Porta 3210 livre - Convex precisa ser iniciado!" -ForegroundColor Yellow } Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " PROXIMOS PASSOS" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" Write-Host "TERMINAL 1 - Backend (Convex):" -ForegroundColor Yellow Write-Host " cd `"$PROJECT_ROOT\packages\backend`"" -ForegroundColor White Write-Host " npx convex dev" -ForegroundColor White Write-Host "" Write-Host "TERMINAL 2 - Frontend (Vite):" -ForegroundColor Yellow Write-Host " cd `"$PROJECT_ROOT\apps\web`"" -ForegroundColor White Write-Host " npm run dev" -ForegroundColor White Write-Host "" Write-Host "Pressione qualquer tecla para iniciar o Backend..." -ForegroundColor Cyan $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") Write-Host "" Write-Host "========================================" -ForegroundColor Green Write-Host " INICIANDO BACKEND (Convex)" -ForegroundColor Green Write-Host "========================================" -ForegroundColor Green Write-Host "" Set-Location "$PROJECT_ROOT\packages\backend" Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd '$PROJECT_ROOT\packages\backend'; npx convex dev" Write-Host "Aguardando 5 segundos para o Convex inicializar..." -ForegroundColor Yellow Start-Sleep -Seconds 5 Write-Host "" Write-Host "========================================" -ForegroundColor Green Write-Host " INICIANDO FRONTEND (Vite)" -ForegroundColor Green Write-Host "========================================" -ForegroundColor Green Write-Host "" Set-Location "$PROJECT_ROOT\apps\web" Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd '$PROJECT_ROOT\apps\web'; npm run dev" Write-Host "" Write-Host "========================================" -ForegroundColor Green Write-Host " PROJETO INICIADO!" -ForegroundColor Green Write-Host "========================================" -ForegroundColor Green Write-Host "" Write-Host "Acesse: http://localhost:5173" -ForegroundColor Cyan Write-Host "" Write-Host "Pressione qualquer tecla para sair..." -ForegroundColor Gray $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")