mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-08-09 04:06:01 +02:00
release: prepare v0.9.7
This commit is contained in:
@@ -6,8 +6,13 @@ echo S H A D O W B R O K E R -- STARTUP
|
||||
echo ===================================================
|
||||
echo.
|
||||
|
||||
:: Remember where we started (project root)
|
||||
set "ROOT=%~dp0"
|
||||
:: Strip trailing backslash
|
||||
if "%ROOT:~-1%"=="\" set "ROOT=%ROOT:~0,-1%"
|
||||
|
||||
:: Check for stale docker-compose.yml from pre-migration clones
|
||||
findstr /R /C:"build:" docker-compose.yml >nul 2>&1
|
||||
findstr /R /C:"build:" "%ROOT%\docker-compose.yml" >nul 2>&1
|
||||
if %errorlevel% equ 0 (
|
||||
echo.
|
||||
echo ================================================================
|
||||
@@ -26,9 +31,16 @@ if %errorlevel% equ 0 (
|
||||
echo.
|
||||
)
|
||||
|
||||
:: Check for Python
|
||||
where python >nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
:: Check for Python and pin the exact interpreter we will use later.
|
||||
set "PYTHON_EXE="
|
||||
for /f "usebackq delims=" %%p in (`python -c "import sys; print(sys.executable)" 2^>nul`) do if not defined PYTHON_EXE set "PYTHON_EXE=%%p"
|
||||
if not defined PYTHON_EXE (
|
||||
for /f "usebackq delims=" %%p in (`py -3.11 -c "import sys; print(sys.executable)" 2^>nul`) do if not defined PYTHON_EXE set "PYTHON_EXE=%%p"
|
||||
)
|
||||
if not defined PYTHON_EXE (
|
||||
for /f "usebackq delims=" %%p in (`py -3 -c "import sys; print(sys.executable)" 2^>nul`) do if not defined PYTHON_EXE set "PYTHON_EXE=%%p"
|
||||
)
|
||||
if not defined PYTHON_EXE (
|
||||
echo [!] ERROR: Python is not installed or not in PATH.
|
||||
echo [!] Install Python 3.10-3.12 from https://python.org
|
||||
echo [!] IMPORTANT: Check "Add to PATH" during install.
|
||||
@@ -36,9 +48,10 @@ if %errorlevel% neq 0 (
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
set "BACKEND_BASE_PYTHON=%PYTHON_EXE%"
|
||||
|
||||
:: Check Python version (warn if 3.13+)
|
||||
for /f "tokens=2 delims= " %%v in ('python --version 2^>^&1') do set PYVER=%%v
|
||||
for /f "tokens=2 delims= " %%v in ('"%PYTHON_EXE%" --version 2^>^&1') do set PYVER=%%v
|
||||
echo [*] Found Python %PYVER%
|
||||
for /f "tokens=1,2 delims=." %%a in ("%PYVER%") do (
|
||||
if %%b GEQ 13 (
|
||||
@@ -61,9 +74,6 @@ if %errorlevel% neq 0 (
|
||||
for /f "tokens=1 delims= " %%v in ('node --version 2^>^&1') do echo [*] Found Node.js %%v
|
||||
|
||||
:: ── AGGRESSIVE ZOMBIE CLEANUP ──────────────────────────────────────
|
||||
:: Kill ANY process holding ports 8000 or 3000 (LISTENING, TIME_WAIT,
|
||||
:: ESTABLISHED — all states). Also kill orphaned uvicorn/ais_proxy
|
||||
:: processes that might be lingering from a previous crashed session.
|
||||
echo.
|
||||
echo [*] Clearing zombie processes...
|
||||
|
||||
@@ -75,9 +85,6 @@ for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":3000 "') do (
|
||||
taskkill /F /PID %%a >nul 2>&1
|
||||
)
|
||||
|
||||
:: Note: wmic zombie-kill removed — hangs on Win11. Port-based kill above
|
||||
:: already catches any process holding 8000/3000.
|
||||
|
||||
:: Brief pause to let OS release the ports
|
||||
timeout /t 1 /nobreak >nul
|
||||
|
||||
@@ -98,44 +105,105 @@ echo [*] Ports clear.
|
||||
|
||||
echo.
|
||||
echo [*] Setting up backend...
|
||||
cd backend
|
||||
cd /d "%ROOT%\backend"
|
||||
set "VENV_MARKER=.venv-dir"
|
||||
set "PINNED_VENV_DIR="
|
||||
if exist "%VENV_MARKER%" set /p PINNED_VENV_DIR=<"%VENV_MARKER%"
|
||||
|
||||
:: Check if UV is available (preferred, much faster installs)
|
||||
where uv >nul 2>&1
|
||||
if %errorlevel% neq 0 goto :use_pip
|
||||
|
||||
echo [*] Using UV for Python dependency management.
|
||||
if not exist "venv\" (
|
||||
set "PRIMARY_VENV_DIR=venv"
|
||||
if defined PINNED_VENV_DIR set "PRIMARY_VENV_DIR=%PINNED_VENV_DIR%"
|
||||
set "REPAIR_VENV_DIR=venv-repair-%RANDOM%%RANDOM%"
|
||||
set "VENV_DIR=%PRIMARY_VENV_DIR%"
|
||||
set "VENV_PY=%VENV_DIR%\Scripts\python.exe"
|
||||
if exist "%VENV_PY%" (
|
||||
"%VENV_PY%" -V >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [*] Existing backend Python venv is stale. Rebuilding it...
|
||||
rmdir /s /q "%PRIMARY_VENV_DIR%" >nul 2>&1
|
||||
if exist "%PRIMARY_VENV_DIR%\" (
|
||||
set "VENV_DIR=%REPAIR_VENV_DIR%"
|
||||
echo [*] Primary venv could not be replaced cleanly. Falling back to %REPAIR_VENV_DIR%...
|
||||
)
|
||||
)
|
||||
)
|
||||
set "VENV_PY=%VENV_DIR%\Scripts\python.exe"
|
||||
if /I not "%VENV_DIR%"=="%PRIMARY_VENV_DIR%" if exist "%VENV_PY%" (
|
||||
"%VENV_PY%" -V >nul 2>&1
|
||||
if errorlevel 1 rmdir /s /q "%VENV_DIR%" >nul 2>&1
|
||||
)
|
||||
set "BACKEND_VENV_DIR=%VENV_DIR%"
|
||||
if not exist "%VENV_DIR%\" (
|
||||
echo [*] Creating Python virtual environment...
|
||||
uv venv
|
||||
if %errorlevel% neq 0 (
|
||||
if exist "%VENV_DIR%\" rmdir /s /q "%VENV_DIR%" >nul 2>&1
|
||||
uv venv "%VENV_DIR%"
|
||||
if errorlevel 1 (
|
||||
echo [!] ERROR: Failed to create virtual environment.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
call venv\Scripts\activate.bat
|
||||
"%VENV_PY%" -V >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [!] ERROR: Backend virtual environment could not start Python after repair.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo [*] Installing Python dependencies via UV (fast)...
|
||||
cd ..
|
||||
cd /d "%ROOT%"
|
||||
set "UV_PROJECT_ENVIRONMENT=%ROOT%\backend\%VENV_DIR%"
|
||||
uv sync --frozen --no-dev
|
||||
set "UV_PROJECT_ENVIRONMENT="
|
||||
if %errorlevel% neq 0 goto :dep_fail
|
||||
cd backend
|
||||
cd /d "%ROOT%\backend"
|
||||
goto :deps_ok
|
||||
|
||||
:use_pip
|
||||
echo [*] UV not found, using pip (install UV for faster installs: https://docs.astral.sh/uv/)
|
||||
if not exist "venv\" (
|
||||
set "PRIMARY_VENV_DIR=venv"
|
||||
if defined PINNED_VENV_DIR set "PRIMARY_VENV_DIR=%PINNED_VENV_DIR%"
|
||||
set "REPAIR_VENV_DIR=venv-repair-%RANDOM%%RANDOM%"
|
||||
set "VENV_DIR=%PRIMARY_VENV_DIR%"
|
||||
set "VENV_PY=%VENV_DIR%\Scripts\python.exe"
|
||||
if exist "%VENV_PY%" (
|
||||
"%VENV_PY%" -V >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [*] Existing backend Python venv is stale. Rebuilding it...
|
||||
rmdir /s /q "%PRIMARY_VENV_DIR%" >nul 2>&1
|
||||
if exist "%PRIMARY_VENV_DIR%\" (
|
||||
set "VENV_DIR=%REPAIR_VENV_DIR%"
|
||||
echo [*] Primary venv could not be replaced cleanly. Falling back to %REPAIR_VENV_DIR%...
|
||||
)
|
||||
)
|
||||
)
|
||||
set "VENV_PY=%VENV_DIR%\Scripts\python.exe"
|
||||
if /I not "%VENV_DIR%"=="%PRIMARY_VENV_DIR%" if exist "%VENV_PY%" (
|
||||
"%VENV_PY%" -V >nul 2>&1
|
||||
if errorlevel 1 rmdir /s /q "%VENV_DIR%" >nul 2>&1
|
||||
)
|
||||
set "BACKEND_VENV_DIR=%VENV_DIR%"
|
||||
if not exist "%VENV_DIR%\" (
|
||||
echo [*] Creating Python virtual environment...
|
||||
python -m venv venv
|
||||
if %errorlevel% neq 0 (
|
||||
echo [!] ERROR: Failed to create virtual environment.
|
||||
if /I not "%VENV_DIR%"=="%PRIMARY_VENV_DIR%" if exist "%VENV_DIR%\" rmdir /s /q "%VENV_DIR%" >nul 2>&1
|
||||
"%PYTHON_EXE%" -m venv "%VENV_DIR%"
|
||||
if errorlevel 1 (
|
||||
echo [!] ERROR: Failed to create virtual environment with %PYTHON_EXE%.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
call venv\Scripts\activate.bat
|
||||
"%VENV_PY%" -V >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [!] ERROR: Backend virtual environment could not start Python after repair.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo [*] Installing Python dependencies (this may take a minute)...
|
||||
pip install -q -r requirements.txt
|
||||
"%VENV_PY%" -m pip install -q .
|
||||
if %errorlevel% neq 0 goto :dep_fail
|
||||
goto :deps_ok
|
||||
|
||||
@@ -145,26 +213,33 @@ echo [!] ERROR: Python dependency install failed. See errors above.
|
||||
echo [!] If you see Rust/cargo errors, your Python version may be too new.
|
||||
echo [!] Recommended: Python 3.10, 3.11, or 3.12.
|
||||
echo.
|
||||
cd /d "%ROOT%"
|
||||
pause
|
||||
exit /b 1
|
||||
|
||||
:deps_ok
|
||||
> "%VENV_MARKER%" echo %VENV_DIR%
|
||||
echo [*] Backend dependencies OK.
|
||||
if not exist "node_modules\ws" (
|
||||
echo [*] Installing backend Node.js dependencies...
|
||||
call npm ci --omit=dev --silent
|
||||
)
|
||||
echo [*] Backend Node.js dependencies OK.
|
||||
cd ..
|
||||
cd /d "%ROOT%"
|
||||
|
||||
echo.
|
||||
echo [*] Setting up frontend...
|
||||
cd frontend
|
||||
if not exist "node_modules\" (
|
||||
echo [*] Installing frontend dependencies...
|
||||
call npm install
|
||||
if %errorlevel% neq 0 (
|
||||
echo [!] ERROR: npm install failed. See errors above.
|
||||
cd /d "%ROOT%\frontend"
|
||||
set "FRONTEND_DEPS_OK=1"
|
||||
if not exist "node_modules\" set "FRONTEND_DEPS_OK=0"
|
||||
if "%FRONTEND_DEPS_OK%"=="1" node -e "require.resolve('next/dist/bin/next',{paths:['.']});require.resolve('lucide-react',{paths:['.']});require.resolve('maplibre-gl',{paths:['.']});require.resolve('@swc/helpers/_/_interop_require_default',{paths:['.']})" >nul 2>&1
|
||||
if "%FRONTEND_DEPS_OK%"=="1" if errorlevel 1 set "FRONTEND_DEPS_OK=0"
|
||||
if "%FRONTEND_DEPS_OK%"=="0" (
|
||||
echo [*] Frontend install is missing required packages. Repairing with npm ci...
|
||||
call npm ci
|
||||
if errorlevel 1 (
|
||||
echo [!] ERROR: frontend dependency install failed. See errors above.
|
||||
cd /d "%ROOT%"
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
@@ -183,3 +258,9 @@ echo (Press Ctrl+C to stop)
|
||||
echo.
|
||||
|
||||
call npm run dev
|
||||
|
||||
echo.
|
||||
echo ===================================================
|
||||
echo ShadowBroker has stopped. Check errors above.
|
||||
echo ===================================================
|
||||
pause
|
||||
|
||||
Reference in New Issue
Block a user