From 50cd0d64259e157576cf0a21a8864c455d3620df Mon Sep 17 00:00:00 2001 From: jaguerrau <143662442+jaguerrau@users.noreply.github.com> Date: Tue, 10 Mar 2026 10:35:19 -0600 Subject: [PATCH] Add files via upload --- _sync_project.ps1 | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 _sync_project.ps1 diff --git a/_sync_project.ps1 b/_sync_project.ps1 new file mode 100644 index 0000000..de31906 --- /dev/null +++ b/_sync_project.ps1 @@ -0,0 +1,61 @@ +# 1. Mensaje inicial y pausa +Clear-Host +Write-Host "Se va a hacer un respaldo del codigo actual en el directorio ""AutoBackups""" -ForegroundColor Yellow +Write-Host "y al terminar, traemos desde GitHub la ultima version del codigo." -ForegroundColor Yellow +Write-Host "" +Write-Host "Presione cualquier tecla para continuar..." -ForegroundColor Yellow +$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") + +# 2. Asegurar ubicación en la raíz +Set-Location $PSScriptRoot +Write-Host "`nScript ejecutado desde: $PWD" -ForegroundColor DarkGray + +# 3. Buscar el proyecto +$B4AFile = Get-ChildItem -Path ".\B4A\*.b4a" | Select-Object -First 1 +if (!$B4AFile) { + Write-Host "ERROR: No encontre el archivo .b4a" -ForegroundColor Red + Start-Sleep -Seconds 3 + exit +} + +$ProjectName = $B4AFile.BaseName +$BackupDir = ".\B4A\AutoBackups" +if (!(Test-Path $BackupDir)) { New-Item -ItemType Directory -Path $BackupDir } + +Write-Host "Respaldando $ProjectName..." -ForegroundColor Cyan + +# 4. Preparar archivos limpios (Método Copiar y Podar) +$tempFolder = Join-Path $env:TEMP "B4A_Stage_$ProjectName" +if (Test-Path $tempFolder) { Remove-Item $tempFolder -Recurse -Force -ErrorAction SilentlyContinue } +New-Item -ItemType Directory -Path $tempFolder | Out-Null + +Write-Host "Extrayendo archivos de codigo..." -ForegroundColor Gray +foreach ($f in @("B4A", "Files")) { + if (Test-Path $f) { + $target = Join-Path $tempFolder $f + Copy-Item -Path $f -Destination $target -Recurse -Force -ErrorAction SilentlyContinue + } +} + +Write-Host "Podando carpetas Objects y AutoBackups..." -ForegroundColor Gray +Remove-Item -Path "$tempFolder\B4A\Objects" -Recurse -Force -ErrorAction SilentlyContinue +Remove-Item -Path "$tempFolder\B4A\AutoBackups" -Recurse -Force -ErrorAction SilentlyContinue +Remove-Item -Path "$tempFolder\B4A\*.zip" -Force -ErrorAction SilentlyContinue + +# 5. Zipear +$Timestamp = Get-Date -Format "yyyyMMdd_HHmmss" +Write-Host "Comprimiendo..." -ForegroundColor Gray +Compress-Archive -Path "$tempFolder\*" -DestinationPath "$BackupDir\$ProjectName`_$Timestamp.zip" -Force +Remove-Item $tempFolder -Recurse -Force -ErrorAction SilentlyContinue + +Write-Host "¡Respaldo limpio creado con exito en AutoBackups!`n" -ForegroundColor Green + +# 6. Sincronizar con GitHub (Pull forzado) +Write-Host "--- Sincronizando con GitHub (Borrando cambios locales) ---" -ForegroundColor Cyan +git fetch --all +git reset --hard origin/main +git pull + +Write-Host "`n¡PROCESO COMPLETADO!" -ForegroundColor Green +# Pausa de 3 segundos para que veas el resultado antes de que se cierre sola +Start-Sleep -Seconds 3 \ No newline at end of file