-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdev-tools.bat
More file actions
217 lines (188 loc) · 5.4 KB
/
Copy pathdev-tools.bat
File metadata and controls
217 lines (188 loc) · 5.4 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
@echo off
REM Batch script for Edge Mining Development Tools (Windows CMD alternative to Makefile)
setlocal EnableDelayedExpansion
REM Variables
set VENV=.venv\Scripts
set PYTHON=%VENV%\python.exe
set PIP=%VENV%\pip.exe
set PRE_COMMIT=%VENV%\pre-commit.exe
REM Get command from first argument
set COMMAND=%1
if "%COMMAND%"=="" set COMMAND=help
REM Main command dispatcher
if /i "%COMMAND%"=="help" goto :help
if /i "%COMMAND%"=="setup" goto :setup
if /i "%COMMAND%"=="venv" goto :venv
if /i "%COMMAND%"=="dev-core" goto :dev-core
if /i "%COMMAND%"=="dev-frontend" goto :dev-frontend
if /i "%COMMAND%"=="format" goto :format
if /i "%COMMAND%"=="lint" goto :lint
if /i "%COMMAND%"=="lint-fix" goto :lint-fix
if /i "%COMMAND%"=="test" goto :test
if /i "%COMMAND%"=="test-cov" goto :test-cov
if /i "%COMMAND%"=="pre-commit" goto :pre-commit
if /i "%COMMAND%"=="pre-commit-install" goto :pre-commit-install
if /i "%COMMAND%"=="clean" goto :clean
if /i "%COMMAND%"=="build" goto :build
if /i "%COMMAND%"=="up" goto :up
if /i "%COMMAND%"=="down" goto :down
if /i "%COMMAND%"=="restart" goto :restart
if /i "%COMMAND%"=="logs" goto :logs
echo Unknown command: %COMMAND%
echo.
goto :help
:help
echo Edge Mining App — Development ^& Docker Commands (Batch)
echo ========================================================
echo.
echo Development:
echo setup - Set up full development environment (core + frontend)
echo venv - Create .venv and install all Python dependencies
echo dev-core - Set up core backend development environment only
echo dev-frontend - Install frontend dependencies only
echo format - Format core code with ruff
echo lint - Run all linting checks on core
echo lint-fix - Run linting and auto-fix on core
echo test - Run core tests
echo test-cov - Run core tests with coverage
echo pre-commit - Run pre-commit hooks on all files
echo pre-commit-install - Install pre-commit hooks
echo clean - Clean cache and temporary files
echo.
echo Docker:
echo build - Build the Docker image (frontend + backend + nginx)
echo up - Start the application (docker compose up -d)
echo down - Stop the application (docker compose down)
echo restart - Rebuild and restart the application
echo logs - Follow application logs
echo.
echo Usage: dev-tools.bat ^<command^>
echo Example: dev-tools.bat setup
goto :end
:setup
call :do_venv
call :do_dev_core
call :do_dev_frontend
call :do_pre_commit_install
echo ✅ Full development environment setup complete!
goto :end
:venv
call :do_venv
goto :end
:do_venv
echo 🐍 Creating virtual environment and installing dependencies...
if not exist .venv (
python -m venv .venv
)
%PIP% install --upgrade pip
%PIP% install -r core\requirements.txt
echo ✅ Virtual environment ready!
exit /b
:dev-core
call :do_dev_core
goto :end
:do_dev_core
echo 🐍 Setting up core backend...
%PIP% install -r core\requirements-dev.txt
exit /b
:dev-frontend
call :do_dev_frontend
goto :end
:do_dev_frontend
echo 🌐 Installing frontend dependencies...
pushd frontend
call npm install
popd
exit /b
:format
echo 🔧 Formatting code...
pushd core
..\%PYTHON% -m ruff format edge_mining/ tests/
popd
echo ✅ Code formatting complete!
goto :end
:lint
echo 🔍 Running linting checks...
pushd core
..\%PYTHON% -m ruff check edge_mining/
..\%PYTHON% -m mypy edge_mining/
..\%PYTHON% -m bandit -r edge_mining/ --skip B311,B104
popd
echo ✅ Linting complete!
goto :end
:lint-fix
echo 🔧 Running auto-fixable linting...
pushd core
..\%PYTHON% -m ruff check --fix edge_mining/
..\%PYTHON% -m ruff format edge_mining/
popd
echo ✅ Auto-fix complete!
goto :end
:test
echo 🧪 Running tests...
pushd core
..\%PYTHON% -m pytest tests/ -v
popd
echo ✅ Tests complete!
goto :end
:test-cov
echo 🧪 Running tests with coverage...
pushd core
..\%PYTHON% -m pytest tests/ -v --cov=edge_mining --cov-report=html --cov-report=term
popd
echo ✅ Tests with coverage complete!
goto :end
:pre-commit
echo 🔧 Running pre-commit hooks...
call :do_pre_commit
goto :end
:do_pre_commit
%PRE_COMMIT% run --all-files
exit /b
:pre-commit-install
call :do_pre_commit_install
goto :end
:do_pre_commit_install
echo 🔧 Installing pre-commit hooks...
%PRE_COMMIT% install
exit /b
:clean
echo 🧹 Cleaning cache and temporary files...
pushd core
for /d /r . %%d in (__pycache__) do @if exist "%%d" rd /s /q "%%d" 2>nul
for /r . %%f in (*.pyc *.pyo) do @if exist "%%f" del /q "%%f" 2>nul
for /d /r . %%d in (*.egg-info) do @if exist "%%d" rd /s /q "%%d" 2>nul
if exist build rd /s /q build 2>nul
if exist dist rd /s /q dist 2>nul
if exist .coverage del /q .coverage 2>nul
if exist htmlcov rd /s /q htmlcov 2>nul
if exist .pytest_cache rd /s /q .pytest_cache 2>nul
popd
if exist frontend\node_modules\.tmp rd /s /q frontend\node_modules\.tmp 2>nul
echo ✅ Cleanup complete!
goto :end
:build
echo 🐳 Building Docker image...
docker compose build
echo ✅ Docker build complete!
goto :end
:up
echo 🐳 Starting application...
docker compose up -d
echo ✅ Application started!
goto :end
:down
echo 🐳 Stopping application...
docker compose down
echo ✅ Application stopped!
goto :end
:restart
echo 🐳 Rebuilding and restarting application...
docker compose build
docker compose up -d
echo ✅ Application restarted!
goto :end
:logs
docker compose logs -f
goto :end
:end