@echo off setlocal EnableExtensions rem Canonical Windows entrypoint for production deploy. rem Vite/npm run on Windows (this process). rsync/ssh still run in WSL bash. rem This distro cannot execute Windows PE binaries from Linux (Exec format error), rem so powershell.exe/npm.cmd cannot be launched from inside WSL. set "ROOT=%~dp0" if "%ROOT:~-1%"=="\" set "ROOT=%ROOT:~0,-1%" where wsl.exe >nul 2>&1 if errorlevel 1 ( echo ERROR: wsl.exe was not found on PATH. echo Install WSL or run from an existing WSL shell: bash deploy.sh exit /b 1 ) rem Local WSL is Ubuntu. Remote production server is Debian 13 (unrelated to this choice). rem Override only with a non-empty DEPLOY_WSL_DISTRO. set "DEPLOY_WSL_DISTRO_EFFECTIVE=Ubuntu" if defined DEPLOY_WSL_DISTRO if not "%DEPLOY_WSL_DISTRO%"=="" set "DEPLOY_WSL_DISTRO_EFFECTIVE=%DEPLOY_WSL_DISTRO%" set "SKIP_WINDOWS_BUILD=0" set "SHOW_HELP=0" for %%A in (%*) do ( if /I "%%~A"=="--skip-build" set "SKIP_WINDOWS_BUILD=1" if /I "%%~A"=="--help" set "SHOW_HELP=1" if /I "%%~A"=="-h" set "SHOW_HELP=1" ) if defined LOCAL_BUILD_COMMAND set "SKIP_WINDOWS_BUILD=1" set "WINDOWS_FRONTEND_BUILT=0" if "%SHOW_HELP%"=="1" goto run_wsl if "%SKIP_WINDOWS_BUILD%"=="1" goto run_wsl echo. echo Building frontend assets with Windows npm.cmd... echo. pushd "%ROOT%" where npm.cmd >nul 2>&1 if errorlevel 1 ( echo ERROR: npm.cmd was not found on PATH. echo Install Node.js or add Laragon's node directory to PATH, then retry. popd exit /b 1 ) call npm.cmd run build set "NPM_EXIT=%ERRORLEVEL%" popd if not "%NPM_EXIT%"=="0" ( echo ERROR: Windows npm run build failed with exit code %NPM_EXIT%. exit /b %NPM_EXIT% ) set "WINDOWS_FRONTEND_BUILT=1" :run_wsl if defined WSLENV ( set "WSLENV=WINDOWS_FRONTEND_BUILT/u:%WSLENV%" ) else ( set "WSLENV=WINDOWS_FRONTEND_BUILT/u" ) rem --cd keeps the working directory on the Windows checkout without fragile path munging. wsl.exe -d %DEPLOY_WSL_DISTRO_EFFECTIVE% --cd "%ROOT%" -e bash "./deploy.sh" %* set "EXIT_CODE=%ERRORLEVEL%" exit /b %EXIT_CODE%