72 lines
1.7 KiB
Batchfile
72 lines
1.7 KiB
Batchfile
@echo off
|
|
title Warehouse Management System Launcher
|
|
|
|
cd /d "%~dp0"
|
|
|
|
echo Building frontend...
|
|
pushd "%~dp0frontend"
|
|
if not exist "node_modules\vite\bin\vite.js" (
|
|
call npm ci
|
|
if errorlevel 1 (
|
|
popd
|
|
echo Frontend dependency installation failed.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
)
|
|
call npm run build
|
|
if errorlevel 1 (
|
|
popd
|
|
echo Frontend build failed. Fix the errors above and run this launcher again.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
popd
|
|
|
|
rem go:embed resolves dist relative to internal/web, not the project root.
|
|
echo Preparing embedded frontend...
|
|
xcopy "%~dp0frontend\dist\*" "%~dp0internal\web\dist\" /E /I /H /Y >nul
|
|
if errorlevel 1 (
|
|
echo Copying frontend build output failed.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
if not exist "%~dp0internal\web\dist\index.html" (
|
|
echo Embedded frontend index.html is missing.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo Building backend...
|
|
rem Rebuild on every launch so the executable can never be a stale one.
|
|
go build -o server.exe ./cmd/server
|
|
if errorlevel 1 (
|
|
echo.
|
|
echo Backend build failed. Fix the errors above and run this launcher again.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
rem Optional validation mode: build both components without starting services.
|
|
if /I "%~1"=="--build-only" exit /b 0
|
|
|
|
echo Starting backend (8082)...
|
|
rem Work dir must stay at the project root: frontend/dist and uploads are relative paths.
|
|
start "Warehouse MMS - Backend" /D "%~dp0" cmd /k "server.exe"
|
|
|
|
echo Starting frontend (8083)...
|
|
start "Warehouse MMS - Frontend" /D "%~dp0frontend" cmd /k "npm run dev"
|
|
|
|
echo.
|
|
echo Frontend: http://localhost:8083
|
|
echo Backend: http://localhost:8082
|
|
echo.
|
|
|
|
rem Open the browser automatically after 3 seconds.
|
|
timeout /t 3 /nobreak >nul
|
|
start "" "http://localhost:8083"
|
|
|
|
rem Keep this launcher window open until a key is pressed.
|
|
echo.
|
|
pause
|