first commit
SAP-ERP Portal CI/CD / build (push) Failing after 5m20s

This commit is contained in:
John
2026-09-23 17:31:02 +05:30
commit 69b4e68baf
51657 changed files with 3864077 additions and 0 deletions
+77
View File
@@ -0,0 +1,77 @@
@echo off
rem ==================================================================
rem BUILD FOR DEPLOYMENT - run on the DEVELOPMENT machine.
rem
rem Produces a dist\ folder containing ONLY what the server needs:
rem dist\server.js whole backend bundled + minified (1 file,
rem no readable source, no node_modules needed)
rem dist\public\ frontend (browsers download this anyway)
rem dist\deploy\ the run/install scripts
rem dist\SapDiConsole\..\SapDiConsole.exe + interop (DI API)
rem dist\sap-di-pr.ps1, dist\logo.png etc.
rem
rem COPY THE dist\ CONTENTS to the server as the app folder, add the
rem .env there manually (never ships with the build), done.
rem
rem NOTE: pdfkit also has a second, rarely-hit fallback path for its ICC
rem color profile at "<app folder>\..\color_profiles\sRGB_IEC61966_2_1.icc"
rem - i.e. OUTSIDE the app folder entirely, a sibling of it on the server.
rem This script can't produce that (it only ever writes inside dist\), so
rem if a future ENOENT ever names that path, copy dist\data\
rem sRGB_IEC61966_2_1.icc to a "color_profiles" folder next to the server's
rem app folder (not inside it) by hand.
rem ==================================================================
cd /d "%~dp0.."
echo [1/4] Bundling backend with esbuild...
if exist dist rmdir /s /q dist
mkdir dist
call npx esbuild server.js --bundle --platform=node --target=node18 --minify --outfile=dist\server.js --log-level=warning
if %ERRORLEVEL% NEQ 0 (
echo BUILD FAILED - see errors above.
pause
exit /b 1
)
echo [2/4] Copying frontend + assets...
xcopy /e /i /q /y public dist\public >nul
if exist logo.png copy /y logo.png dist\ >nul
rem esbuild only inlines JS - pdfkit/fontkit load these binary data files at
rem runtime via __dirname-relative fs.readFileSync() calls, so they must sit
rem next to dist\server.js or "Download PDF" fails with ENOENT (data.trie,
rem then Helvetica-Bold.afm, etc. - found the hard way, see chat history).
mkdir dist\data 2>nul
copy /y node_modules\@foliojs-fork\fontkit\data.trie dist\ >nul
copy /y node_modules\@foliojs-fork\fontkit\indic.trie dist\ >nul
copy /y node_modules\@foliojs-fork\fontkit\use.trie dist\ >nul
copy /y node_modules\@foliojs-fork\linebreak\src\classes.trie dist\ >nul
copy /y node_modules\@foliojs-fork\pdfkit\js\data\*.afm dist\data\ >nul
copy /y node_modules\@foliojs-fork\pdfkit\js\data\sRGB_IEC61966_2_1.icc dist\data\ >nul
echo [3/4] Copying deploy scripts + DI console...
xcopy /e /i /q /y deploy dist\deploy >nul
del dist\deploy\build-dist.bat >nul 2>&1
if exist services\sap-di-pr.ps1 copy /y services\sap-di-pr.ps1 dist\ >nul
if exist services\SapDiConsole\bin\Release\net472\SapDiConsole.exe (
xcopy /i /q /y services\SapDiConsole\bin\Release\net472\* dist\SapDiConsole\bin\Release\net472\ >nul
) else (
echo WARNING: SapDiConsole.exe not built - Purchase Requests will not work.
)
echo [4/4] Creating runtime folders + .env template...
mkdir dist\uploads 2>nul
mkdir dist\logs 2>nul
echo # Copy the real .env here manually - it is NEVER included in the build. > dist\PUT-ENV-FILE-HERE.txt
echo.
echo ==========================================================
echo Build complete: dist\
for %%A in (dist\server.js) do echo Bundle size: %%~zA bytes
echo.
echo Next steps:
echo 1. Copy the CONTENTS of dist\ to the server app folder
echo 2. Put the real .env in that folder
echo 3. On the server run deploy\install-autostart.bat (as admin)
echo ==========================================================
pause