-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathsetup.bat
More file actions
317 lines (261 loc) · 7.84 KB
/
setup.bat
File metadata and controls
317 lines (261 loc) · 7.84 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
@echo off
REM ==============================================================================
REM AUTO-blogger Setup Script for Windows
REM Copyright (c) 2025 AryanVBW
REM https://github.com/AryanVBW/AUTO-blogger
REM ==============================================================================
setlocal EnableDelayedExpansion
REM Configuration
set "VENV_DIR=venv"
set "PYTHON_MIN_VERSION=3.8"
set "PROJECT_NAME=AUTO-blogger"
REM Colors (Windows 10+)
set "RED=[91m"
set "GREEN=[92m"
set "YELLOW=[93m"
set "BLUE=[94m"
set "PURPLE=[95m"
set "CYAN=[96m"
set "NC=[0m"
REM ==============================================================================
REM Main Entry Point
REM ==============================================================================
:main
call :print_header
echo %BLUE%[INFO]%NC% Starting %PROJECT_NAME% setup...
echo.
REM Parse arguments
set "MODE=base"
set "CLEAN=false"
set "SKIP_VENV=false"
:parse_args
if "%~1"=="" goto :start_setup
if /i "%~1"=="--dev" set "MODE=dev" & shift & goto :parse_args
if /i "%~1"=="--test" set "MODE=test" & shift & goto :parse_args
if /i "%~1"=="--clean" set "CLEAN=true" & shift & goto :parse_args
if /i "%~1"=="--no-venv" set "SKIP_VENV=true" & shift & goto :parse_args
if /i "%~1"=="--help" goto :usage
if /i "%~1"=="-h" goto :usage
echo %RED%[ERROR]%NC% Unknown option: %~1
goto :usage
:start_setup
REM Navigate to script directory
cd /d "%~dp0"
REM Clean if requested
if "%CLEAN%"=="true" (
if exist "%VENV_DIR%" (
echo %CYAN%[STEP]%NC% Cleaning existing virtual environment...
rmdir /s /q "%VENV_DIR%"
echo %GREEN%[SUCCESS]%NC% Cleaned
)
)
REM Check Python
call :check_python
if errorlevel 1 exit /b 1
REM Check pip
call :check_pip
if errorlevel 1 exit /b 1
REM Check Chrome
call :check_chrome
echo.
REM Setup virtual environment
if "%SKIP_VENV%"=="false" (
call :setup_venv
if errorlevel 1 exit /b 1
call :activate_venv
if errorlevel 1 exit /b 1
)
REM Upgrade pip
call :upgrade_pip
REM Install dependencies
call :install_dependencies %MODE%
REM Install package
call :install_package %MODE%
REM Create .env file
call :create_env_file
echo.
REM Verify installation
call :verify_installation
call :print_success
exit /b 0
REM ==============================================================================
REM Functions
REM ==============================================================================
:print_header
echo %PURPLE%
echo ======================================================================
echo AUTO-blogger Setup
echo Professional WordPress Automation Tool
echo ======================================================================
echo %NC%
exit /b 0
:usage
echo.
echo Usage: %~nx0 [OPTIONS]
echo.
echo Options:
echo --dev Install development dependencies
echo --test Install test dependencies
echo --no-venv Skip virtual environment creation
echo --clean Remove existing venv before setup
echo --help Show this help message
echo.
echo Examples:
echo %~nx0 # Standard installation
echo %~nx0 --dev # Development setup
echo %~nx0 --clean # Clean reinstall
exit /b 0
:check_python
echo %CYAN%[STEP]%NC% Checking Python installation...
REM Try python first, then python3
where python >nul 2>&1
if %errorlevel%==0 (
set "PYTHON_CMD=python"
) else (
where python3 >nul 2>&1
if %errorlevel%==0 (
set "PYTHON_CMD=python3"
) else (
echo %RED%[ERROR]%NC% Python not found. Please install Python 3.8 or higher.
echo Download from: https://www.python.org/downloads/
exit /b 1
)
)
REM Check version
for /f "tokens=*" %%i in ('%PYTHON_CMD% -c "import sys; print('.'.join(map(str, sys.version_info[:2])))"') do set "PY_VERSION=%%i"
echo %GREEN%[SUCCESS]%NC% Found %PYTHON_CMD% version %PY_VERSION%
exit /b 0
:check_pip
echo %CYAN%[STEP]%NC% Checking pip installation...
%PYTHON_CMD% -m pip --version >nul 2>&1
if errorlevel 1 (
echo %YELLOW%[WARNING]%NC% pip not found. Installing...
%PYTHON_CMD% -m ensurepip --default-pip
if errorlevel 1 (
echo %RED%[ERROR]%NC% Failed to install pip
exit /b 1
)
)
echo %GREEN%[SUCCESS]%NC% pip is available
exit /b 0
:check_chrome
echo %CYAN%[STEP]%NC% Checking Chrome installation...
set "CHROME_FOUND=false"
if exist "C:\Program Files\Google\Chrome\Application\chrome.exe" set "CHROME_FOUND=true"
if exist "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" set "CHROME_FOUND=true"
if "%CHROME_FOUND%"=="true" (
echo %GREEN%[SUCCESS]%NC% Chrome found
) else (
echo %YELLOW%[WARNING]%NC% Chrome not found. Selenium automation requires Chrome.
echo Download from: https://www.google.com/chrome/
)
exit /b 0
:setup_venv
echo %CYAN%[STEP]%NC% Setting up virtual environment...
if exist "%VENV_DIR%" (
echo %BLUE%[INFO]%NC% Virtual environment exists. Recreating...
rmdir /s /q "%VENV_DIR%"
)
%PYTHON_CMD% -m venv "%VENV_DIR%"
if errorlevel 1 (
echo %RED%[ERROR]%NC% Failed to create virtual environment
exit /b 1
)
echo %GREEN%[SUCCESS]%NC% Virtual environment created at .\%VENV_DIR%
exit /b 0
:activate_venv
echo %CYAN%[STEP]%NC% Activating virtual environment...
call "%VENV_DIR%\Scripts\activate.bat"
if errorlevel 1 (
echo %RED%[ERROR]%NC% Failed to activate virtual environment
exit /b 1
)
echo %GREEN%[SUCCESS]%NC% Virtual environment activated
exit /b 0
:upgrade_pip
echo %CYAN%[STEP]%NC% Upgrading pip and setuptools...
pip install --upgrade pip setuptools wheel >nul 2>&1
echo %GREEN%[SUCCESS]%NC% pip and setuptools upgraded
exit /b 0
:install_dependencies
echo %CYAN%[STEP]%NC% Installing %1 dependencies...
if "%1"=="dev" (
if exist "requirements\dev.txt" (
pip install -r requirements\dev.txt
) else (
pip install -r requirements.txt
pip install black flake8 mypy pytest pytest-cov pre-commit
)
) else if "%1"=="test" (
if exist "requirements\test.txt" (
pip install -r requirements\test.txt
) else (
pip install -r requirements.txt
pip install pytest pytest-cov pytest-mock
)
) else (
if exist "requirements\base.txt" (
pip install -r requirements\base.txt
) else (
pip install -r requirements.txt
)
)
echo %GREEN%[SUCCESS]%NC% %1 dependencies installed
exit /b 0
:install_package
echo %CYAN%[STEP]%NC% Installing AUTO-blogger package...
if "%1"=="dev" (
pip install -e ".[dev]"
) else (
pip install -e .
)
echo %GREEN%[SUCCESS]%NC% AUTO-blogger package installed
exit /b 0
:create_env_file
echo %CYAN%[STEP]%NC% Setting up environment configuration...
if not exist ".env" (
if exist ".env.example" (
copy ".env.example" ".env" >nul
echo %GREEN%[SUCCESS]%NC% Created .env file from template
echo %YELLOW%[WARNING]%NC% Please update .env with your API keys
) else (
echo %BLUE%[INFO]%NC% No .env.example template found
)
) else (
echo %BLUE%[INFO]%NC% .env file already exists
)
exit /b 0
:verify_installation
echo %CYAN%[STEP]%NC% Verifying installation...
%PYTHON_CMD% -c "import auto_blogger" 2>nul
if errorlevel 0 (
echo %GREEN%[SUCCESS]%NC% AUTO-blogger package imports successfully
) else (
echo %YELLOW%[WARNING]%NC% Package import verification skipped
)
echo %GREEN%[SUCCESS]%NC% Installation verified
exit /b 0
:print_success
echo.
echo %GREEN%
echo ======================================================================
echo Setup Complete!
echo ======================================================================
echo %NC%
echo.
echo %CYAN%Quick Start:%NC%
echo.
echo 1. Activate the virtual environment:
echo venv\Scripts\activate
echo.
echo 2. Run AUTO-blogger:
echo autoblog
echo # or
echo python -m auto_blogger
echo.
echo 3. For development:
echo setup.bat --dev
echo.
echo %YELLOW%Note:%NC% Update your .env file with API keys before running.
echo.
exit /b 0