78 lines
1.8 KiB
Batchfile
78 lines
1.8 KiB
Batchfile
@echo off
|
|
setlocal EnableExtensions DisableDelayedExpansion
|
|
|
|
for %%I in ("%~dp0..") do set "REPO_ROOT=%%~fI"
|
|
set "FRONTEND_DIR=%REPO_ROOT%\frontend"
|
|
title SystemSimulationApp ReactFlow - 127.0.0.1:5173
|
|
|
|
if not exist "%FRONTEND_DIR%\package.json" (
|
|
echo [ERROR] Frontend package.json was not found:
|
|
echo %FRONTEND_DIR%\package.json
|
|
echo.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
set "NODE_DIR="
|
|
for /d %%D in ("%REPO_ROOT%\.tools\node-*-win-x64") do (
|
|
if not defined NODE_DIR if exist "%%~fD\node.exe" if exist "%%~fD\npm.cmd" (
|
|
"%%~fD\node.exe" -e "v=process.versions.node.split('.');M=+v[0];m=+v[1];process.exit((M===20&&m>=19)||(M===22&&m>=12)||M>=23?0:1)" >nul 2>&1
|
|
if not errorlevel 1 set "NODE_DIR=%%~fD"
|
|
)
|
|
)
|
|
|
|
if not defined NODE_DIR (
|
|
echo [ERROR] A compatible Node.js portable runtime was not found under:
|
|
echo %REPO_ROOT%\.tools
|
|
echo Vite requires Node.js 20.19+ or 22.12+.
|
|
echo.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
set "NPM_EXE=%NODE_DIR%\npm.cmd"
|
|
if not exist "%NPM_EXE%" (
|
|
echo [ERROR] npm.cmd was not found:
|
|
echo %NPM_EXE%
|
|
echo.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
if not exist "%FRONTEND_DIR%\node_modules\.bin\vite.cmd" (
|
|
echo [ERROR] Frontend dependencies are not installed.
|
|
echo Run the following command first:
|
|
echo cd /d "%FRONTEND_DIR%"
|
|
echo call "%NPM_EXE%" ci
|
|
echo.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
pushd "%FRONTEND_DIR%" >nul
|
|
if errorlevel 1 (
|
|
echo [ERROR] Unable to enter the frontend directory:
|
|
echo %FRONTEND_DIR%
|
|
echo.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
set "PATH=%NODE_DIR%;%PATH%"
|
|
|
|
echo Starting ReactFlow at http://127.0.0.1:5173
|
|
echo Press Ctrl+C to stop the service.
|
|
echo.
|
|
|
|
call "%NPM_EXE%" run dev -- --strictPort
|
|
set "EXIT_CODE=%ERRORLEVEL%"
|
|
|
|
if not "%EXIT_CODE%"=="0" (
|
|
echo.
|
|
echo [ERROR] ReactFlow exited with code %EXIT_CODE%.
|
|
pause
|
|
)
|
|
|
|
popd
|
|
exit /b %EXIT_CODE%
|