-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-integrity.sh
More file actions
executable file
·297 lines (253 loc) · 8.18 KB
/
check-integrity.sh
File metadata and controls
executable file
·297 lines (253 loc) · 8.18 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
#!/bin/bash
# 🔍 Project Integrity Checker
# Validates all critical files and dependencies for GitHub repository
echo "🔍 AI Agent Simulation Observatory - Integrity Check"
echo "=================================================="
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
ERRORS=0
WARNINGS=0
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
((ERRORS++))
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
((WARNINGS++))
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
# Check core backend files
check_backend() {
print_info "Checking backend files..."
# Critical files
if [ -f "backend/server.py" ]; then
FILE_SIZE=$(wc -l < backend/server.py)
if [ $FILE_SIZE -gt 100 ]; then
print_success "backend/server.py exists ($FILE_SIZE lines)"
else
print_error "backend/server.py is too small ($FILE_SIZE lines)"
fi
else
print_error "backend/server.py missing"
fi
if [ -f "backend/requirements.txt" ]; then
DEPS=$(wc -l < backend/requirements.txt)
print_success "backend/requirements.txt exists ($DEPS dependencies)"
else
print_error "backend/requirements.txt missing"
fi
if [ -f "backend/.env.example" ]; then
print_success "backend/.env.example exists"
else
print_warning "backend/.env.example missing"
fi
# Check for syntax errors in Python files
if command -v python3 &> /dev/null; then
if python3 -m py_compile backend/server.py 2>/dev/null; then
print_success "backend/server.py syntax valid"
else
print_error "backend/server.py has syntax errors"
fi
fi
}
# Check core frontend files
check_frontend() {
print_info "Checking frontend files..."
# Critical files
FRONTEND_FILES=(
"src/App.js"
"src/SimulationControl.js"
"src/AgentLibraryComplete.js"
"src/ConversationViewer.js"
"package.json"
"tailwind.config.js"
)
cd frontend
for file in "${FRONTEND_FILES[@]}"; do
if [ -f "$file" ]; then
FILE_SIZE=$(wc -l < "$file")
print_success "frontend/$file exists ($FILE_SIZE lines)"
else
print_error "frontend/$file missing"
fi
done
# Check package.json structure
if [ -f "package.json" ]; then
if command -v node &> /dev/null; then
if node -e "JSON.parse(require('fs').readFileSync('package.json'))" 2>/dev/null; then
print_success "package.json is valid JSON"
else
print_error "package.json has invalid JSON"
fi
fi
fi
# Check for node_modules
if [ -d "node_modules" ]; then
MODULE_COUNT=$(ls node_modules | wc -l)
print_success "node_modules exists ($MODULE_COUNT packages)"
else
print_warning "node_modules missing (run yarn install)"
fi
cd ..
}
# Check documentation files
check_documentation() {
print_info "Checking documentation files..."
DOC_FILES=(
"README.md"
"API.md"
"setup.sh"
)
for file in "${DOC_FILES[@]}"; do
if [ -f "$file" ]; then
FILE_SIZE=$(wc -l < "$file")
if [ $FILE_SIZE -gt 50 ]; then
print_success "$file exists ($FILE_SIZE lines)"
else
print_warning "$file exists but seems incomplete ($FILE_SIZE lines)"
fi
else
print_error "$file missing"
fi
done
# Check README structure
if [ -f "README.md" ]; then
if grep -q "Quick Start" README.md && grep -q "Installation" README.md; then
print_success "README.md has proper structure"
else
print_warning "README.md missing key sections"
fi
fi
}
# Check configuration files
check_configuration() {
print_info "Checking configuration files..."
# Docker files
if [ -f "Dockerfile" ]; then
print_success "Dockerfile exists"
else
print_warning "Dockerfile missing"
fi
if [ -f "docker-compose.yml" ] || [ -f "docker-compose.yaml" ]; then
print_success "Docker Compose file exists"
else
print_warning "Docker Compose file missing"
fi
# Kubernetes files
if [ -d "k8s" ]; then
K8S_FILES=$(ls k8s/*.yaml 2>/dev/null | wc -l)
if [ $K8S_FILES -gt 0 ]; then
print_success "Kubernetes configs exist ($K8S_FILES files)"
else
print_warning "k8s directory empty"
fi
else
print_warning "k8s directory missing"
fi
}
# Check for test files and cleanup
check_cleanup() {
print_info "Checking for test files and cleanup..."
# Count test files
TEST_FILES=$(find . -name "*test*.py" -o -name "*test*.js" | grep -v node_modules | wc -l)
if [ $TEST_FILES -gt 20 ]; then
print_warning "Many test files found ($TEST_FILES) - consider cleanup for production"
else
print_success "Test files manageable ($TEST_FILES found)"
fi
# Check for large files
LARGE_FILES=$(find . -size +10M -type f | grep -v node_modules | wc -l)
if [ $LARGE_FILES -gt 0 ]; then
print_warning "Large files found ($LARGE_FILES) - check for unnecessary files"
find . -size +10M -type f | grep -v node_modules | head -5
else
print_success "No large files found"
fi
# Check for sensitive files
SENSITIVE_PATTERNS=("*.env" "*.key" "*.pem" "*.p12" "*secret*")
for pattern in "${SENSITIVE_PATTERNS[@]}"; do
FOUND=$(find . -name "$pattern" -not -name "*.example" | grep -v node_modules | wc -l)
if [ $FOUND -gt 0 ]; then
print_warning "Potential sensitive files found: $pattern ($FOUND files)"
print_info "Make sure these are in .gitignore"
fi
done
}
# Check Git setup
check_git() {
print_info "Checking Git setup..."
if [ -d ".git" ]; then
print_success "Git repository initialized"
# Check .gitignore
if [ -f ".gitignore" ]; then
if grep -q "node_modules" .gitignore && grep -q "\.env" .gitignore; then
print_success ".gitignore properly configured"
else
print_warning ".gitignore missing important entries"
fi
else
print_error ".gitignore missing"
fi
# Check for uncommitted changes
if git diff --quiet && git diff --cached --quiet; then
print_success "No uncommitted changes"
else
print_warning "Uncommitted changes detected"
fi
else
print_warning "Not a Git repository"
fi
}
# Generate integrity report
generate_report() {
echo ""
echo "📊 Integrity Check Summary"
echo "=========================="
if [ $ERRORS -eq 0 ] && [ $WARNINGS -eq 0 ]; then
print_success "✅ Repository is ready for GitHub!"
print_info "All critical files present and valid"
elif [ $ERRORS -eq 0 ]; then
print_warning "⚠️ Repository mostly ready with $WARNINGS warnings"
print_info "Consider addressing warnings before publishing"
else
print_error "❌ Repository has $ERRORS errors and $WARNINGS warnings"
print_info "Please fix errors before publishing to GitHub"
fi
echo ""
print_info "Quick Start Test Commands:"
echo " ./setup.sh check # Check prerequisites"
echo " ./setup.sh full # Complete setup"
echo " ./setup.sh start # Start services"
echo ""
print_info "Manual Verification:"
echo " 1. Check backend/.env configuration"
echo " 2. Verify frontend/.env settings"
echo " 3. Test API endpoints with curl"
echo " 4. Run frontend in browser"
}
# Run all checks
main() {
check_backend
check_frontend
check_documentation
check_configuration
check_cleanup
check_git
generate_report
# Exit with error code if there are errors
if [ $ERRORS -gt 0 ]; then
exit 1
else
exit 0
fi
}
main "$@"