@echo off setlocal set "SCRIPT_DIR=%~dp0" set "DIST_DIR=%SCRIPT_DIR%dist" echo Building and packaging dist... echo Project folder: %SCRIPT_DIR% cd /d "%SCRIPT_DIR%" if errorlevel 1 ( echo Error: could not enter project folder. pause exit /b 1 ) where npm >nul 2>nul if errorlevel 1 ( echo Error: npm was not found. Please install Node.js first. pause exit /b 1 ) echo. echo Running npm run build:prod... call npm run build:prod if errorlevel 1 ( echo Error: build:prod failed. Package was not created. pause exit /b 1 ) if not exist "%DIST_DIR%\" ( echo Error: dist folder was not found after build. pause exit /b 1 ) where powershell >nul 2>nul if errorlevel 1 ( echo Error: PowerShell was not found. pause exit /b 1 ) powershell -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference='Stop'; $scriptDir=$env:SCRIPT_DIR; $distDir=Join-Path $scriptDir 'dist'; $packageName='popiart-website-new'; $outputZip=Join-Path $scriptDir ($packageName + '.zip'); $tmpRoot=Join-Path ([IO.Path]::GetTempPath()) ('popiart-package-' + [guid]::NewGuid().ToString('N')); try { $packageDir=Join-Path $tmpRoot $packageName; New-Item -ItemType Directory -Path $packageDir -Force | Out-Null; Get-ChildItem -LiteralPath $distDir -Force | Copy-Item -Destination $packageDir -Recurse -Force; Get-ChildItem -LiteralPath $packageDir -Recurse -Force -Filter '.DS_Store' | Remove-Item -Force; if (Test-Path -LiteralPath $outputZip) { Remove-Item -LiteralPath $outputZip -Force }; Compress-Archive -LiteralPath $packageDir -DestinationPath $outputZip -Force; Write-Host 'Done:' $outputZip; Get-Item -LiteralPath $outputZip | Format-List FullName,Length } finally { if (Test-Path -LiteralPath $tmpRoot) { Remove-Item -LiteralPath $tmpRoot -Recurse -Force } }" if errorlevel 1 ( echo Error: package failed. pause exit /b 1 ) echo. echo Package complete. echo Closing this window in 3 seconds... timeout /t 3 /nobreak >nul