# ============================================================================= # WEBMoney Frontend - Script de Deploy para Windows # ============================================================================= # Este script faz build e deploy do frontend para o servidor de produção # Uso: .\deploy.ps1 # Requer: Node.js, npm, e clave SSH configurada (ou escribir contraseña) # ============================================================================= # Configurações $SERVER_USER = "root" $SERVER_HOST = "213.165.93.60" $REMOTE_PATH = "/var/www/webmoney/frontend/dist" $LOCAL_DIST = ".\dist" # Cores function Write-Color { param([string]$Text, [string]$Color = "White") Write-Host $Text -ForegroundColor $Color } Write-Color "========================================" "Cyan" Write-Color " WEBMoney Frontend - Deploy Script " "Cyan" Write-Color "========================================" "Cyan" Write-Host "" # 1. Build Write-Color "[1/4] Fazendo build do frontend..." "Yellow" if (Test-Path $LOCAL_DIST) { Remove-Item -Recurse -Force $LOCAL_DIST } npm run build if (-not (Test-Path $LOCAL_DIST)) { Write-Color "ERRO: Build falhou - pasta dist não encontrada" "Red" exit 1 } Write-Color "✓ Build concluído" "Green" Write-Host "" # 2. Limpar diretório remoto Write-Color "[2/4] Limpando diretório remoto..." "Yellow" ssh "$SERVER_USER@$SERVER_HOST" "rm -rf $REMOTE_PATH/* && echo 'Diretório limpo'" Write-Color "✓ Diretório remoto limpo" "Green" Write-Host "" # 3. Enviar arquivos Write-Color "[3/4] Enviando arquivos para $REMOTE_PATH ..." "Yellow" scp -r "$LOCAL_DIST\*" "${SERVER_USER}@${SERVER_HOST}:${REMOTE_PATH}/" Write-Color "✓ Arquivos enviados" "Green" Write-Host "" # 4. Verificar deploy Write-Color "[4/4] Verificando deploy..." "Yellow" $remoteFiles = ssh "$SERVER_USER@$SERVER_HOST" "ls -la $REMOTE_PATH/" Write-Host $remoteFiles Write-Host "" # Verificar se index.html existe $indexExists = ssh "$SERVER_USER@$SERVER_HOST" "test -f $REMOTE_PATH/index.html && echo 'OK'" if ($indexExists -eq "OK") { Write-Color "========================================" "Green" Write-Color " ✓ Deploy concluído com sucesso! " "Green" Write-Color "========================================" "Green" Write-Host "" Write-Host "Acesse: " -NoNewline Write-Color "https://webmoney.cnxifly.com" "Cyan" Write-Host "" } else { Write-Color "========================================" "Red" Write-Color " ✗ ERRO: index.html não encontrado " "Red" Write-Color "========================================" "Red" exit 1 }