-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.cmd
More file actions
123 lines (107 loc) · 3.35 KB
/
shell.cmd
File metadata and controls
123 lines (107 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
@echo off
REM Glossa Lab Shell Wrapper
REM ALL tool invocations MUST go through this file.
REM NEVER call venv\Scripts\*.exe directly.
set "REPO_ROOT=%~dp0"
set "REPO_ROOT=%REPO_ROOT:~0,-1%"
set "VENV_PYTHON=%REPO_ROOT%\backend\venv\Scripts\python.exe"
REM Detect Python command (must be outside if-block to avoid delayed expansion bug)
set "PY=python"
where python3 >nul 2>&1 && set "PY=python3"
REM py launcher takes precedence when available (standard Windows Python installs)
where py >nul 2>&1 && set "PY=py"
REM Bootstrap if venv missing
if not exist "%VENV_PYTHON%" (
echo [SETUP] Creating venv ...
%PY% -m venv "%REPO_ROOT%\backend\venv"
if errorlevel 1 (
echo [ERROR] Failed to create venv.
exit /b 1
)
"%VENV_PYTHON%" -m pip install --quiet --upgrade pip
"%VENV_PYTHON%" -m pip install --quiet -e "%REPO_ROOT%\backend[dev]"
echo [SETUP] Done.
)
if "%~1"=="" goto usage
if /i "%~1"=="test" goto do_test
if /i "%~1"=="lint" goto do_lint
if /i "%~1"=="format" goto do_format
if /i "%~1"=="run" goto do_run
if /i "%~1"=="python" goto do_python
if /i "%~1"=="setup" goto do_setup
if /i "%~1"=="tray" goto do_tray
if /i "%~1"=="svc" goto do_svc
if /i "%~1"=="e2e" goto do_e2e
goto do_default
:do_test
shift
"%VENV_PYTHON%" -m pytest %1 %2 %3 %4 %5 %6 %7 %8 %9
exit /b %ERRORLEVEL%
:do_lint
shift
"%VENV_PYTHON%" -m ruff check %1 %2 %3 %4 %5 %6 %7 %8 %9
exit /b %ERRORLEVEL%
:do_format
shift
"%VENV_PYTHON%" -m ruff format %1 %2 %3 %4 %5 %6 %7 %8 %9
exit /b %ERRORLEVEL%
:do_run
shift
echo [OK] Backend running on http://localhost:8001 (Ctrl+C to stop)
"%VENV_PYTHON%" -m uvicorn glossa_lab.main:app --host ********* --port 8001 --reload --app-dir "%REPO_ROOT%\backend" %1 %2 %3 %4 %5 %6 %7 %8 %9
exit /b %ERRORLEVEL%
:do_python
shift
"%VENV_PYTHON%" %1 %2 %3 %4 %5 %6 %7 %8 %9
exit /b %ERRORLEVEL%
:do_tray
shift
set "PYTHONPATH=%REPO_ROOT%\tray;%PYTHONPATH%"
"%VENV_PYTHON%" -m glossa_tray %1 %2 %3 %4 %5 %6 %7 %8 %9
exit /b %ERRORLEVEL%
:do_svc
shift
call "%REPO_ROOT%\setup-os.cmd" %1 %2 %3 %4 %5 %6 %7 %8 %9
exit /b %ERRORLEVEL%
:do_e2e
shift
pushd "%REPO_ROOT%\frontend"
call npx playwright test %1 %2 %3 %4 %5 %6 %7 %8 %9
set E2E_EXIT=%ERRORLEVEL%
popd
exit /b %E2E_EXIT%
:do_setup
"%VENV_PYTHON%" -m pip install --upgrade pip
"%VENV_PYTHON%" -m pip install -e "%REPO_ROOT%\backend[dev,tray]"
if exist "%REPO_ROOT%\tray\requirements.txt" (
"%VENV_PYTHON%" -m pip install -r "%REPO_ROOT%\tray\requirements.txt"
)
REM Auto-detect GPU and install the right accelerator package (CuPy for NVIDIA, etc.)
if exist "%REPO_ROOT%\backend\scripts\install_gpu.py" (
"%VENV_PYTHON%" "%REPO_ROOT%\backend\scripts\install_gpu.py"
)
if exist "%REPO_ROOT%\frontend\package.json" (
pushd "%REPO_ROOT%\frontend"
call npm install
call npm run build
popd
)
echo [OK] Dependencies updated.
exit /b 0
:do_default
set "CMD=%~1"
shift
"%VENV_PYTHON%" -m %CMD% %1 %2 %3 %4 %5 %6 %7 %8 %9
exit /b %ERRORLEVEL%
:usage
echo Usage: shell.cmd ^<command^> [args]
echo test [args] pytest
echo lint [args] ruff check
echo format [args] ruff format
echo run [args] uvicorn backend
echo python [args] python in venv
echo setup install/update deps
echo tray start tray app
echo svc [cmd] OS service integration (delegates to setup-os.cmd)
echo e2e [args] run Playwright tests (from frontend/)
exit /b 0