# =============================================================================
# WEBMoney - Status do Projeto (Conforme Diretrizes v3.0)
# =============================================================================

$ProjectRoot = "c:\Users\marco\OneDrive\Documents\WebMoney"

Write-Host ""
Write-Host "=======================================================" -ForegroundColor Cyan
Write-Host "  WEBMoney - Status (Diretrizes v3.0)" -ForegroundColor Cyan
Write-Host "=======================================================" -ForegroundColor Cyan
Write-Host ""

# Versao
$version = (Get-Content (Join-Path $ProjectRoot "VERSION")).Trim()
Write-Host "  Versao:        " -NoNewline
Write-Host $version -ForegroundColor Green

# Ultima entrada do CHANGELOG
$changelog = Get-Content (Join-Path $ProjectRoot "CHANGELOG.md") -Raw
if ($changelog -match '\[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})') {
    Write-Host "  Ultimo commit: " -NoNewline
    Write-Host "$($Matches[1]) ($($Matches[2]))" -ForegroundColor White
}

# Git status
Push-Location $ProjectRoot
$gitBranch = git branch --show-current 2>$null
$gitStatus = git status --porcelain 2>$null
Pop-Location

Write-Host "  Branch:        " -NoNewline
Write-Host $gitBranch -ForegroundColor Yellow

# Status de mudancas
$changedFiles = @($gitStatus | Where-Object { $_ }).Count
if ($changedFiles -gt 0) {
    Write-Host "  Mudancas:      " -NoNewline
    Write-Host "$changedFiles arquivos modificados" -ForegroundColor Red
    Write-Host ""
    Write-Host "  AVISO: Existem mudancas nao commitadas!" -ForegroundColor Yellow
    Write-Host "  Execute release.ps1 para seguir as diretrizes." -ForegroundColor Yellow
} else {
    Write-Host "  Mudancas:      " -NoNewline
    Write-Host "Nenhuma (working tree clean)" -ForegroundColor Green
}

Write-Host ""
Write-Host "-------------------------------------------------------" -ForegroundColor Gray

# SSH Status
Write-Host ""
$sshTest = ssh -o ConnectTimeout=3 -o BatchMode=yes root@213.165.93.60 "echo OK" 2>$null
if ($sshTest -eq "OK") {
    Write-Host "  SSH:           " -NoNewline
    Write-Host "Conectado (sem senha)" -ForegroundColor Green
} else {
    Write-Host "  SSH:           " -NoNewline
    Write-Host "Requer configuracao" -ForegroundColor Red
    Write-Host "                 Execute: .\scripts\setup-ssh.ps1" -ForegroundColor Gray
}

Write-Host ""
Write-Host "-------------------------------------------------------" -ForegroundColor Gray
Write-Host ""

# Diretrizes
Write-Host "  DIRETRIZES v3.0 (Sempre seguir):" -ForegroundColor Yellow
Write-Host "  1. VERSION + CHANGELOG em cada commit" -ForegroundColor Gray
Write-Host "  2. Deploy via scripts (nunca manual)" -ForegroundColor Gray
Write-Host "  3. Teste em producao OBRIGATORIO" -ForegroundColor Gray
Write-Host "  4. Commit somente apos teste OK" -ForegroundColor Gray

Write-Host ""
Write-Host "-------------------------------------------------------" -ForegroundColor Gray
Write-Host ""

# URLs
Write-Host "  URLs:" -ForegroundColor White
Write-Host "    Producao:    https://webmoney.cnxifly.com" -ForegroundColor Cyan
Write-Host "    API:         https://webmoney.cnxifly.com/api" -ForegroundColor Cyan

Write-Host ""
Write-Host "-------------------------------------------------------" -ForegroundColor Gray
Write-Host ""

# Comandos
Write-Host "  Comandos:" -ForegroundColor White
Write-Host "    .\scripts\dev.ps1          " -NoNewline -ForegroundColor Yellow
Write-Host "Desenvolvimento local" -ForegroundColor Gray
Write-Host "    .\scripts\quick-deploy.ps1 " -NoNewline -ForegroundColor Yellow
Write-Host "Deploy rapido (dev)" -ForegroundColor Gray
Write-Host "    .\scripts\release.ps1      " -NoNewline -ForegroundColor Yellow
Write-Host "Release oficial" -ForegroundColor Green
Write-Host ""

Write-Host ""
