mirror of
https://github.com/KeymonSoft/Guna_Reparto_BAT.git
synced 2026-04-17 12:56:19 +00:00
Add files via upload
This commit is contained in:
61
_sync_project.ps1
Normal file
61
_sync_project.ps1
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user