forked from Alex-cmd-dev/Help2Study
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.bat
More file actions
163 lines (152 loc) · 4.29 KB
/
setup.bat
File metadata and controls
163 lines (152 loc) · 4.29 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
@echo off
REM ============================================
REM Help2Study - Windows Setup Script
REM ============================================
REM This script automates the setup process for Windows
REM It will check requirements, install dependencies, and configure the app
REM ============================================
echo ============================================
echo Help2Study - Automated Setup (Windows)
echo ============================================
echo.
echo IMPORTANT: Before proceeding, make sure you've set PowerShell execution policy.
echo If you haven't done this yet, press Ctrl+C to cancel, then run as Administrator:
echo Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
echo.
echo Press any key to continue with setup...
pause >nul
echo.
REM Check Python
echo [1/6] Checking Python installation...
python --version >nul 2>&1
if errorlevel 1 (
echo [ERROR] Python is not installed or not in PATH
echo Please install Python 3.8+ from https://www.python.org/downloads/
echo Make sure to check "Add Python to PATH" during installation
pause
exit /b 1
)
python --version
echo [OK] Python is installed
echo.
REM Check Node.js
echo [2/6] Checking Node.js installation...
node --version >nul 2>&1
if errorlevel 1 (
echo [ERROR] Node.js is not installed or not in PATH
echo Please install Node.js 16+ from https://nodejs.org/
pause
exit /b 1
)
node --version
call npm.cmd --version
echo [OK] Node.js and npm are installed
echo.
REM Check for .env file
echo [3/6] Checking environment configuration...
if not exist .env (
echo [WARNING] Backend .env file not found
if exist .env.example (
echo Creating .env from .env.example...
copy .env.example .env
echo.
echo [ACTION REQUIRED] Please edit .env and add your Gemini API key
echo Get your API key from: https://makersuite.google.com/app/apikey
echo.
echo Press any key after you've updated the .env file...
pause >nul
) else (
echo [ERROR] .env.example not found
pause
exit /b 1
)
) else (
echo [OK] Backend .env file exists
)
echo.
REM Check for frontend .env file
echo Checking frontend environment configuration...
if not exist frontend\.env (
echo [WARNING] Frontend .env file not found
if exist frontend\.env.example (
echo Creating frontend\.env from frontend\.env.example...
copy frontend\.env.example frontend\.env
echo [OK] Frontend .env file created
) else (
echo [ERROR] frontend\.env.example not found
pause
exit /b 1
)
) else (
echo [OK] Frontend .env file exists
)
echo.
REM Install backend dependencies
echo [4/6] Installing Python dependencies...
cd backend
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
if errorlevel 1 (
echo [ERROR] Failed to install Python dependencies
cd ..
pause
exit /b 1
)
cd ..
echo [OK] Python dependencies installed
echo.
REM Install frontend dependencies
echo [5/6] Installing Node.js dependencies...
echo This may take a few minutes...
cd frontend
call npm.cmd install
if errorlevel 1 (
echo [ERROR] Failed to install Node.js dependencies
echo.
echo Common causes:
echo 1. PowerShell execution policy not set - Run as Administrator:
echo Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
echo 2. Network connection issues
echo 3. npm cache issues - Try: npm cache clean --force
echo.
cd ..
pause
exit /b 1
)
cd ..
echo [OK] Node.js dependencies installed
echo.
REM Run migrations
echo [6/6] Setting up database...
cd backend
python manage.py migrate
if errorlevel 1 (
echo [ERROR] Failed to run database migrations
cd ..
pause
exit /b 1
)
cd ..
echo [OK] Database initialized
echo.
echo ============================================
echo Setup Complete!
echo ============================================
echo.
echo To start the development servers:
echo.
echo Open TWO separate Command Prompt or PowerShell windows:
echo.
echo Window 1 - Backend:
echo cd backend
echo python manage.py runserver
echo.
echo Window 2 - Frontend:
echo cd frontend
echo npm run dev
echo.
echo Then visit: http://localhost:5173
echo.
echo To stop the servers later, press Ctrl+C in each window.
echo.
pause