feature/integracion-cpanel-asrecovery

This commit is contained in:
2026-06-30 11:29:06 -06:00
parent 072be5b5db
commit 034a5ca5bb
35 changed files with 2416 additions and 320 deletions

113
build.ps1
View File

@@ -1,72 +1,63 @@
# Script de build para PyInstaller
# Genera un ejecutable único de la aplicación
# Build CloudRestoreAS — PyInstaller onefile portable
$ErrorActionPreference = "Stop"
$Root = $PSScriptRoot
Write-Host "===============================================" -ForegroundColor Cyan
Write-Host "CloudRestoreAS - Build Script" -ForegroundColor Cyan
Write-Host "CloudRestoreAS - Build Windows (onefile)" -ForegroundColor Cyan
Write-Host "===============================================" -ForegroundColor Cyan
Write-Host ""
# Verificar que PyInstaller esté instalado
Write-Host "Verificando PyInstaller..." -ForegroundColor Yellow
$pyinstallerCheck = pip show pyinstaller 2>$null
if (-not $pyinstallerCheck) {
Write-Host "PyInstaller no está instalado. Instalando..." -ForegroundColor Yellow
pip install pyinstaller
& "$Root\packaging\scripts\download-bundled-deps.ps1"
# Python de Windows (evitar venv creado desde WSL)
$PythonCandidates = @(
"$env:LOCALAPPDATA\Programs\Python\Python313\python.exe",
"$env:LOCALAPPDATA\Programs\Python\Python312\python.exe",
"$env:LOCALAPPDATA\Programs\Python\Python311\python.exe"
)
$Python = $PythonCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $Python) {
throw "No se encontró Python 3.11+ en Windows. Instale desde python.org"
}
Write-Host "Python: $Python" -ForegroundColor Gray
# Crear directorio de build
$buildDir = "build"
$distDir = "dist"
Write-Host ""
Write-Host "Limpiando builds anteriores..." -ForegroundColor Yellow
if (Test-Path $buildDir) {
Remove-Item -Recurse -Force $buildDir
}
if (Test-Path $distDir) {
Remove-Item -Recurse -Force $distDir
}
if (Test-Path "*.spec") {
Remove-Item -Force *.spec
$venvDir = Join-Path $Root "venv-windows"
$venvPython = Join-Path $venvDir "Scripts\python.exe"
if (-not (Test-Path $venvPython)) {
if (Test-Path $venvDir) { Remove-Item -Recurse -Force $venvDir }
& $Python -m venv $venvDir
}
& $venvPython -m pip install --upgrade pip -q
& $venvPython -m pip install -r (Join-Path $Root "requirements-windows.txt") -q
Write-Host ""
Write-Host "Ejecutando PyInstaller..." -ForegroundColor Yellow
Write-Host ""
# Ejecutar PyInstaller
pyinstaller --name CloudRestoreAS `
--onefile `
--windowed `
--icon=NONE `
--add-data "app;app" `
--hidden-import PySide6 `
--hidden-import pyodbc `
--hidden-import win32crypt `
--collect-all PySide6 `
runner.py
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "===============================================" -ForegroundColor Green
Write-Host "Build completado exitosamente!" -ForegroundColor Green
Write-Host "===============================================" -ForegroundColor Green
Write-Host ""
Write-Host "El ejecutable se encuentra en:" -ForegroundColor Cyan
Write-Host " $PWD\dist\CloudRestoreAS.exe" -ForegroundColor White
Write-Host ""
Write-Host "IMPORTANTE:" -ForegroundColor Yellow
Write-Host " - Copia las carpetas 'data' y 'logs' junto al .exe" -ForegroundColor White
Write-Host " - Asegúrate de tener 7-Zip instalado" -ForegroundColor White
Write-Host " - Asegúrate de tener ODBC Driver 17 for SQL Server" -ForegroundColor White
Write-Host ""
$distDir = Join-Path $Root "dist"
$isUncRoot = $Root -like "\\*"
# PyInstaller no puede usar workpath en UNC (WSL); usar carpeta local en Windows
if ($isUncRoot) {
$buildDir = Join-Path $env:LOCALAPPDATA "Temp\cloudrestore-build"
} else {
Write-Host ""
Write-Host "===============================================" -ForegroundColor Red
Write-Host "Error durante el build" -ForegroundColor Red
Write-Host "===============================================" -ForegroundColor Red
Write-Host ""
$buildDir = Join-Path $Root "build"
}
if (Test-Path $buildDir) {
Remove-Item -Recurse -Force $buildDir -ErrorAction SilentlyContinue
}
New-Item -ItemType Directory -Force -Path $distDir, $buildDir | Out-Null
if (Test-Path (Join-Path $distDir "CloudRestoreAS.exe")) {
Remove-Item -Force (Join-Path $distDir "CloudRestoreAS.exe") -ErrorAction SilentlyContinue
}
# Pausar para ver resultados
Read-Host "Presiona Enter para continuar..."
Write-Host "Ejecutando PyInstaller (onefile)..." -ForegroundColor Yellow
Write-Host "Workpath: $buildDir" -ForegroundColor Gray
& $venvPython -m PyInstaller (Join-Path $Root "packaging\CloudRestoreAS.spec") `
--clean --noconfirm `
--distpath $distDir `
--workpath $buildDir
$exe = Join-Path $Root "dist\CloudRestoreAS.exe"
if (Test-Path $exe) {
Write-Host ""
Write-Host "Build OK: $exe" -ForegroundColor Green
Write-Host "Distribuir solo el .exe; al ejecutar crea config/ automaticamente." -ForegroundColor Cyan
} else {
Write-Host "Error: no se genero el ejecutable" -ForegroundColor Red
exit 1
}