-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-deps.sh
More file actions
335 lines (293 loc) · 9.88 KB
/
install-deps.sh
File metadata and controls
335 lines (293 loc) · 9.88 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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#!/bin/bash
# VRecommendation System - Dependency Installation Script
# For Linux/Unix systems
set -e
# Colors
GREEN='\033[0;92m'
RED='\033[0;91m'
YELLOW='\033[0;93m'
BLUE='\033[0;94m'
CYAN='\033[0;96m'
NC='\033[0m' # No Color
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo ""
echo -e "${BLUE}========================================================${NC}"
echo -e "${BLUE} VRecommendation System - Dependency Installation ${NC}"
echo -e "${BLUE}========================================================${NC}"
echo ""
# ========================================
# Check System Dependencies
# ========================================
check_deps() {
echo -e "${BLUE}[INFO]${NC} Checking system dependencies..."
echo ""
local ALL_OK=1
# Check Go
echo "Checking Go..."
if command -v go &> /dev/null; then
GO_VERSION=$(go version | awk '{print $3}')
echo -e " ${GREEN}[OK]${NC} $GO_VERSION"
else
echo -e " ${RED}[MISSING]${NC} Go is not installed"
echo " Download from: https://golang.org/dl/"
ALL_OK=0
fi
# Check Python
echo "Checking Python..."
if command -v python3 &> /dev/null; then
PYTHON_VERSION=$(python3 --version 2>&1)
echo -e " ${GREEN}[OK]${NC} $PYTHON_VERSION"
elif command -v python &> /dev/null; then
PYTHON_VERSION=$(python --version 2>&1)
echo -e " ${GREEN}[OK]${NC} $PYTHON_VERSION"
else
echo -e " ${RED}[MISSING]${NC} Python is not installed"
echo " Download from: https://python.org/downloads/"
ALL_OK=0
fi
# Check Poetry
echo "Checking Poetry..."
if command -v poetry &> /dev/null; then
POETRY_VERSION=$(poetry --version 2>&1)
echo -e " ${GREEN}[OK]${NC} $POETRY_VERSION"
else
echo -e " ${RED}[MISSING]${NC} Poetry is not installed"
echo " Install with: pip install poetry"
echo " Or visit: https://python-poetry.org/docs/"
ALL_OK=0
fi
# Check Node.js
echo "Checking Node.js..."
if command -v node &> /dev/null; then
NODE_VERSION=$(node --version)
echo -e " ${GREEN}[OK]${NC} Node.js $NODE_VERSION"
else
echo -e " ${RED}[MISSING]${NC} Node.js is not installed"
echo " Download from: https://nodejs.org/"
ALL_OK=0
fi
# Check npm
echo "Checking npm..."
if command -v npm &> /dev/null; then
NPM_VERSION=$(npm --version)
echo -e " ${GREEN}[OK]${NC} npm $NPM_VERSION"
else
echo -e " ${RED}[MISSING]${NC} npm is not installed"
ALL_OK=0
fi
echo ""
if [ "$ALL_OK" -eq 1 ]; then
echo -e "${GREEN}[SUCCESS]${NC} All system dependencies are installed!"
else
echo -e "${RED}[WARNING]${NC} Some dependencies are missing. Please install them."
fi
echo ""
return $((1 - ALL_OK))
}
# Silent system dependency check
check_system_deps_silent() {
command -v go &> /dev/null && \
command -v poetry &> /dev/null && \
command -v node &> /dev/null
}
# ========================================
# Install AI Server Dependencies
# ========================================
install_ai() {
echo -e "${BLUE}[INFO]${NC} Installing AI Server dependencies..."
echo ""
if [ ! -f "backend/ai_server/pyproject.toml" ]; then
echo -e "${RED}[ERROR]${NC} pyproject.toml not found in backend/ai_server"
return 1
fi
echo "Checking Poetry..."
if ! command -v poetry &> /dev/null; then
echo -e "${RED}[ERROR]${NC} Poetry is not installed"
echo "Install with: pip install poetry"
return 1
fi
cd backend/ai_server
echo "Installing Python dependencies with Poetry..."
echo "This may take a few minutes..."
echo ""
if poetry install; then
echo ""
echo -e "${GREEN}[OK]${NC} AI Server dependencies installed successfully"
else
echo -e "${RED}[ERROR]${NC} Failed to install AI Server dependencies"
cd "$SCRIPT_DIR"
return 1
fi
cd "$SCRIPT_DIR"
}
# ========================================
# Install API Server Dependencies
# ========================================
install_api() {
echo -e "${BLUE}[INFO]${NC} Installing API Server dependencies..."
echo ""
if [ ! -f "backend/api_server/go.mod" ]; then
echo -e "${RED}[ERROR]${NC} go.mod not found in backend/api_server"
return 1
fi
echo "Checking Go..."
if ! command -v go &> /dev/null; then
echo -e "${RED}[ERROR]${NC} Go is not installed"
echo "Download from: https://golang.org/dl/"
return 1
fi
cd backend/api_server
echo "Downloading Go modules..."
echo ""
if go mod download; then
echo "Tidying Go modules..."
go mod tidy || echo -e "${YELLOW}[WARN]${NC} go mod tidy returned warnings"
echo ""
echo -e "${GREEN}[OK]${NC} API Server dependencies installed successfully"
else
echo -e "${RED}[ERROR]${NC} Failed to download Go modules"
cd "$SCRIPT_DIR"
return 1
fi
cd "$SCRIPT_DIR"
}
# ========================================
# Install Frontend Dependencies
# ========================================
install_frontend() {
echo -e "${BLUE}[INFO]${NC} Installing Frontend dependencies..."
echo ""
if [ ! -f "frontend/project/package.json" ]; then
echo -e "${RED}[ERROR]${NC} package.json not found in frontend/project"
return 1
fi
echo "Checking Node.js..."
if ! command -v node &> /dev/null; then
echo -e "${RED}[ERROR]${NC} Node.js is not installed"
echo "Download from: https://nodejs.org/"
return 1
fi
cd frontend/project
echo "Installing npm packages..."
echo "This may take a few minutes..."
echo ""
if npm install; then
echo ""
echo -e "${GREEN}[OK]${NC} Frontend dependencies installed successfully"
else
echo -e "${RED}[ERROR]${NC} Failed to install Frontend dependencies"
cd "$SCRIPT_DIR"
return 1
fi
cd "$SCRIPT_DIR"
}
# ========================================
# Install All Dependencies
# ========================================
install_all() {
echo -e "${BLUE}[INFO]${NC} Installing all project dependencies..."
echo ""
# Check system dependencies first
if ! check_system_deps_silent; then
echo -e "${RED}[ERROR]${NC} Missing system dependencies. Please install them first."
echo "Run: ./install-deps.sh check"
exit 1
fi
# Install AI Server
echo ""
echo -e "${CYAN}========================================${NC}"
echo -e "${CYAN}[1/3] AI Server (Python/Poetry)${NC}"
echo -e "${CYAN}========================================${NC}"
install_ai || true
# Install API Server
echo ""
echo -e "${CYAN}========================================${NC}"
echo -e "${CYAN}[2/3] API Server (Go)${NC}"
echo -e "${CYAN}========================================${NC}"
install_api || true
# Install Frontend
echo ""
echo -e "${CYAN}========================================${NC}"
echo -e "${CYAN}[3/3] Frontend (Node.js/npm)${NC}"
echo -e "${CYAN}========================================${NC}"
install_frontend || true
echo ""
echo -e "${GREEN}========================================================${NC}"
echo -e "${GREEN} All dependencies installed successfully! ${NC}"
echo -e "${GREEN}========================================================${NC}"
echo ""
echo -e "${YELLOW}Next steps:${NC}"
echo " 1. Configure your .env files (run: ./start-local.sh)"
echo " 2. Start the services: ./start-local.sh start"
echo ""
}
# ========================================
# Help
# ========================================
show_help() {
echo -e "${CYAN}VRecommendation System - Dependency Installation${NC}"
echo ""
echo "Usage: ./install-deps.sh [COMPONENT]"
echo ""
echo "Components:"
echo " all Install all dependencies (default)"
echo " ai Install AI Server dependencies (Python/Poetry)"
echo " api Install API Server dependencies (Go)"
echo " frontend Install Frontend dependencies (Node.js/npm)"
echo " check Check if system dependencies are installed"
echo " help Show this help message"
echo ""
echo "Examples:"
echo " ./install-deps.sh Install all dependencies"
echo " ./install-deps.sh all Install all dependencies"
echo " ./install-deps.sh ai Install only AI Server dependencies"
echo " ./install-deps.sh api Install only API Server dependencies"
echo " ./install-deps.sh frontend Install only Frontend dependencies"
echo " ./install-deps.sh check Check system dependencies"
echo ""
echo "System Requirements:"
echo " - Go 1.24+ (for API Server)"
echo " - Python 3.9+ (for AI Server)"
echo " - Poetry (for AI Server dependency management)"
echo " - Node.js 18+ (for Frontend)"
echo " - npm (for Frontend)"
echo ""
echo "Installation Links:"
echo " - Go: https://golang.org/dl/"
echo " - Python: https://python.org/downloads/"
echo " - Poetry: https://python-poetry.org/docs/ (or: pip install poetry)"
echo " - Node.js: https://nodejs.org/"
echo ""
}
# ========================================
# Main
# ========================================
COMPONENT=${1:-all}
case "$COMPONENT" in
all)
install_all
;;
ai)
install_ai
;;
api)
install_api
;;
frontend|fe)
install_frontend
;;
check)
check_deps
;;
help|--help|-h)
show_help
;;
*)
echo -e "${RED}[ERROR]${NC} Unknown component: $COMPONENT"
echo ""
show_help
exit 1
;;
esac