@echo off setlocal ENABLEDELAYEDEXPANSION cd /d %~dp0 :: One-click builder for BibleApp Windows EXE :: 1) Installs dependencies :: 2) Packages Electron app :: 3) Opens the output folder echo === BibleApp Windows Builder === where node >nul 2>&1 if errorlevel 1 ( echo. echo Node.js is not installed. Please install Node LTS from https://nodejs.org and run this again. if not defined CI pause exit /b 1 ) :: Install dependencies (safe to re-run) echo. echo Installing dependencies... call npm install --no-audit --no-fund if errorlevel 1 ( echo. echo npm install failed. Fix errors above and re-run. if not defined CI pause exit /b 1 ) :: Ensure no previous build is locked (close running app, remove old output) echo. echo Stopping any running BibleApp.exe and cleaning previous build... taskkill /F /IM BibleApp.exe /T >nul 2>&1 timeout /T 1 >nul 2>&1 :: Preserve existing Notes folder from previous build (if any) before cleaning set NOTES_BACKUP=dist\__NotesBackup if exist "dist\BibleApp-win32-x64\Notes" ( echo Backing up existing Notes from previous build... rmdir /S /Q "%NOTES_BACKUP%" >nul 2>&1 mkdir "%NOTES_BACKUP%" >nul 2>&1 xcopy /E /I /Y "dist\BibleApp-win32-x64\Notes" "%NOTES_BACKUP%\Notes" >nul 2>&1 ) if exist "dist\BibleApp-win32-x64" ( attrib -R /S /D "dist\BibleApp-win32-x64\*" >nul 2>&1 rmdir /S /Q "dist\BibleApp-win32-x64" >nul 2>&1 ) :: Package the app (x64 Windows) echo. echo Packaging app... :: Determine app version from package.json for /f %%i in ('node -p "require('./package.json').version"') do set APP_VERSION=%%i :: Optional icon flag if icon.ico exists set ICON_FLAG= if exist "icon.ico" ( set ICON_FLAG=--icon=icon.ico ) call npx electron-packager . BibleApp --platform=win32 --arch=x64 --out=dist --overwrite %ICON_FLAG% --app-version=%APP_VERSION% if errorlevel 1 ( echo. echo Packaging failed. Fix errors above and re-run. if not defined CI pause exit /b 1 ) :: Ensure ffmpeg.dll is present in the packaged output (some environments miss this file) set OUTDIR=dist\BibleApp-win32-x64 if exist "%OUTDIR%" ( echo. echo Ensuring ffmpeg.dll is present in output... if exist "node_modules\electron\dist\ffmpeg.dll" ( copy /Y "node_modules\electron\dist\ffmpeg.dll" "%OUTDIR%\ffmpeg.dll" >nul 2>&1 ) else ( echo Could not find node_modules\electron\dist\ffmpeg.dll; run npm install and try again. ) echo. echo Syncing Notes folder to output... if exist "Notes" ( if not exist "%OUTDIR%\Notes" mkdir "%OUTDIR%\Notes" >nul 2>&1 echo Copying Notes from source directory... xcopy /E /I /Y "Notes" "%OUTDIR%\Notes" >nul 2>&1 ) echo. echo Syncing Graphics folder to output... if exist "Graphics" ( if not exist "%OUTDIR%\Graphics" mkdir "%OUTDIR%\Graphics" >nul 2>&1 echo Copying Graphics from source directory... xcopy /E /I /Y "Graphics" "%OUTDIR%\Graphics" >nul 2>&1 ) else ( echo No Graphics folder found to copy. ) echo. echo Syncing Announcements folder to output... if exist "Announcements" ( if not exist "%OUTDIR%\Announcements" mkdir "%OUTDIR%\Announcements" >nul 2>&1 echo Copying Announcements from source directory... xcopy /E /I /Y "Announcements" "%OUTDIR%\Announcements" >nul 2>&1 ) else ( echo No Announcements folder found to copy. ) if exist "%NOTES_BACKUP%\Notes\osc-config.json" ( echo Preserving osc-config.json from previous build... copy /Y "%NOTES_BACKUP%\Notes\osc-config.json" "%OUTDIR%\Notes\osc-config.json" >nul 2>&1 ) if not exist "%OUTDIR%\Notes" ( echo No Notes folder found to include. ) rmdir /S /Q "%NOTES_BACKUP%" >nul 2>&1 ) else ( echo Expected output folder not found: %OUTDIR% ) echo. echo Build complete. if exist "%OUTDIR%\BibleApp.exe" ( echo Opening output folder... start "" explorer "%OUTDIR%" echo. echo To run the app: double-click BibleApp.exe ) else ( echo Could not find output EXE at %OUTDIR%\BibleApp.exe ) echo. if not defined CI pause endlocal