-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathverify-setup.sh
More file actions
executable file
·505 lines (449 loc) · 15.8 KB
/
Copy pathverify-setup.sh
File metadata and controls
executable file
·505 lines (449 loc) · 15.8 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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
#!/bin/bash
# Development Environment Verification Script
# Checks system configuration and optionally fixes issues
#
# Usage:
# ./verify-setup.sh # Read-only verification
# ./verify-setup.sh --fix # Verify and fix issues
# ./verify-setup.sh --deep # Deep verification (all checks)
# ./verify-setup.sh --help # Show usage information
set -e
set -u
set -o pipefail
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Flags
FIX_MODE=false
DEEP_MODE=false
REPORT_MODE=false
ISSUES_FOUND=0
REPORT_FILE=""
# Helper functions
print_header() {
echo ""
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
}
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
print_warning() {
echo -e "${YELLOW}⚠${NC} $1"
((ISSUES_FOUND++))
}
print_error() {
echo -e "${RED}✗${NC} $1"
((ISSUES_FOUND++))
}
print_info() {
echo -e "${BLUE}ℹ${NC} $1"
}
# Parse command line arguments
for arg in "$@"; do
case $arg in
--fix)
FIX_MODE=true
shift
;;
--deep)
DEEP_MODE=true
shift
;;
--report)
REPORT_MODE=true
shift
;;
--help)
echo "Development Environment Verification Script"
echo ""
echo "Usage:"
echo " ./verify-setup.sh # Read-only verification (default)"
echo " ./verify-setup.sh --fix # Verify and fix issues interactively"
echo " ./verify-setup.sh --deep # Deep verification with all checks"
echo " ./verify-setup.sh --report # Generate detailed report file"
echo " ./verify-setup.sh --help # Show this help message"
echo ""
echo "Examples:"
echo " ./verify-setup.sh # Quick check"
echo " ./verify-setup.sh --fix # Fix any issues found"
echo " ./verify-setup.sh --deep # Comprehensive check"
echo " ./verify-setup.sh --fix --deep # Fix all issues with deep scan"
echo " ./verify-setup.sh --deep --report # Generate comprehensive report"
echo ""
echo "Report file will be saved to: verification-report-TIMESTAMP.txt"
echo ""
exit 0
;;
*)
echo "Unknown option: $arg"
echo "Run './verify-setup.sh --help' for usage information"
exit 1
;;
esac
done
# Set up report file if requested
if [ "$REPORT_MODE" = true ]; then
TIMESTAMP=$(date +"%Y%m%d-%H%M%S")
REPORT_FILE="$SCRIPT_DIR/verification-report-$TIMESTAMP.txt"
# Create report file and add header
{
echo "========================================"
echo "DEVELOPMENT ENVIRONMENT VERIFICATION REPORT"
echo "========================================"
echo ""
echo "Generated: $(date '+%Y-%m-%d %H:%M:%S')"
echo "Script: verify-setup.sh"
echo "Mode: $([ "$FIX_MODE" = true ] && echo "FIX" || echo "READ-ONLY") $([ "$DEEP_MODE" = true ] && echo "+ DEEP" || echo "")"
echo ""
echo "======================================== "
echo "SYSTEM INFORMATION"
echo "========================================"
echo ""
echo "macOS Version: $(sw_vers -productVersion)"
echo "macOS Build: $(sw_vers -buildVersion)"
echo "Architecture: $(uname -m)"
echo "Hostname: $(hostname)"
echo "User: $USER"
echo "Home: $HOME"
echo "Shell: $SHELL"
echo "Script Directory: $SCRIPT_DIR"
echo ""
if command -v brew &>/dev/null; then
echo "Homebrew Version: $(brew --version | head -1)"
echo "Homebrew Prefix: $(brew --prefix)"
fi
echo ""
echo "========================================"
echo "VERIFICATION RESULTS"
echo "========================================"
echo ""
} > "$REPORT_FILE"
# Redirect all output to both terminal and file
exec > >(tee -a "$REPORT_FILE")
exec 2> >(tee -a "$REPORT_FILE" >&2)
fi
# Main verification
clear
if [ "$FIX_MODE" = true ]; then
print_header "Development Environment Verification & Fixing"
print_info "FIX MODE: Issues will be fixed interactively"
else
print_header "Development Environment Verification"
print_info "READ-ONLY: No changes will be made"
fi
if [ "$DEEP_MODE" = true ]; then
print_info "DEEP MODE: Running comprehensive checks"
fi
echo ""
#######################################
# Check 1: Shell Configuration Symlinks
#######################################
print_info "1. Checking shell configuration symlinks..."
echo ""
if [ -L ~/.zshrc ] && [ -L ~/.zprofile ]; then
print_success "Shell configs are symlinked"
print_info " ~/.zshrc -> $(readlink ~/.zshrc)"
print_info " ~/.zprofile -> $(readlink ~/.zprofile)"
else
print_warning "Shell configs are NOT symlinked"
if [ "$FIX_MODE" = true ]; then
read -r -p "Fix shell configuration symlinks? (y/N): " response
if [[ "$response" =~ ^[Yy]$ ]]; then
"$SCRIPT_DIR/setup.sh"
print_success "Shell configuration updated"
fi
else
print_info " To fix: cd ~/dev-environment && ./setup.sh"
fi
fi
echo ""
#######################################
# Check 2: Package Configuration
#######################################
print_info "2. Checking package configuration..."
echo ""
if [ -f "$SCRIPT_DIR/config/packages.conf" ]; then
print_success "config/packages.conf exists"
source "$SCRIPT_DIR/config/packages.conf"
print_info " Formulae: ${#FORMULAE[@]}"
print_info " Casks: ${#CASKS[@]}"
print_info " VS Code Extensions: ${#VSCODE_EXTENSIONS[@]}"
else
print_error "config/packages.conf NOT found"
fi
echo ""
#######################################
# Check 3: nvm Configuration
#######################################
print_info "3. Checking nvm configuration..."
echo ""
if grep -q "NVM_LOADING" ~/.zshrc 2>/dev/null; then
print_success "nvm lazy loading is configured"
if [ -f ~/.zshrc ]; then
NVM_LOADING=$(grep "NVM_LOADING=" ~/.zshrc | head -1 | cut -d'"' -f2 || echo "lazy")
print_info " Mode: ${NVM_LOADING}"
fi
else
print_warning "nvm lazy loading NOT configured"
fi
echo ""
#######################################
# Check 4: MCP Servers
#######################################
print_info "4. Checking MCP servers..."
echo ""
if command -v claude &>/dev/null; then
print_success "Claude Code CLI available"
if [ "$DEEP_MODE" = true ]; then
MCP_LIST=$(claude mcp list 2>/dev/null || echo "")
if [ -n "$MCP_LIST" ]; then
echo "$MCP_LIST"
else
print_warning "Could not list MCP servers"
fi
else
MCP_COUNT=$(claude mcp list 2>/dev/null | grep -c "codex-cli\|gemini-cli" || echo "0")
print_info " Configured servers: $MCP_COUNT"
fi
else
print_warning "Claude Code CLI not found"
print_info " To install: See install.sh Step 2"
fi
echo ""
#######################################
# Check 5: Node.js Version Conflict
#######################################
if [ "$DEEP_MODE" = true ]; then
print_info "5. Checking for Node.js version conflicts..."
echo ""
if brew list --formula 2>/dev/null | grep -q "^node$"; then
print_warning "Homebrew node formula is installed (conflicts with nvm)"
if [ "$FIX_MODE" = true ]; then
read -r -p "Uninstall Homebrew node? (y/N): " response
if [[ "$response" =~ ^[Yy]$ ]]; then
brew uninstall node
print_success "Homebrew node uninstalled"
fi
else
print_info " To fix: brew uninstall node"
fi
else
print_success "No Node.js version conflict"
fi
# Verify nvm is working
if [ -s "$HOME/.nvm/nvm.sh" ]; then
source "$HOME/.nvm/nvm.sh"
print_success "nvm is working"
print_info " Current version: $(nvm current)"
else
print_warning "nvm not found"
fi
echo ""
fi
#######################################
# Check 6: Docker Desktop
#######################################
if [ "$DEEP_MODE" = true ]; then
print_info "6. Checking Docker Desktop..."
echo ""
if ! docker info &>/dev/null; then
print_warning "Docker is not running"
if [ "$FIX_MODE" = true ]; then
if [ -d "/Applications/Docker.app" ]; then
read -r -p "Launch Docker Desktop? (y/N): " response
if [[ "$response" =~ ^[Yy]$ ]]; then
open -a "Docker"
print_success "Docker Desktop launched"
print_info "Waiting for Docker to start..."
sleep 5
for i in {1..25}; do
if docker info &>/dev/null; then
print_success "Docker is now running"
break
fi
sleep 1
done
fi
else
print_error "Docker.app not found in /Applications"
fi
else
print_info " To fix: open -a Docker"
fi
else
print_success "Docker is running"
fi
echo ""
fi
#######################################
# Check 7: VS Code Extensions
#######################################
if [ "$DEEP_MODE" = true ]; then
print_info "7. Checking VS Code extensions..."
echo ""
if command -v code &>/dev/null; then
# Source packages.conf for extension list
if [ -f "$SCRIPT_DIR/config/packages.conf" ]; then
source "$SCRIPT_DIR/config/packages.conf"
INSTALLED_EXTS=$(code --list-extensions 2>/dev/null || echo "")
MISSING_EXTS=()
for ext in "${VSCODE_EXTENSIONS[@]}"; do
if echo "$INSTALLED_EXTS" | grep -q "^${ext}$"; then
print_success "$ext"
else
print_warning "$ext (missing)"
MISSING_EXTS+=("$ext")
fi
done
if [ ${#MISSING_EXTS[@]} -gt 0 ] && [ "$FIX_MODE" = true ]; then
read -r -p "Install missing VS Code extensions? (y/N): " response
if [[ "$response" =~ ^[Yy]$ ]]; then
for ext in "${MISSING_EXTS[@]}"; do
print_info "Installing $ext..."
code --install-extension "$ext" &>/dev/null
print_success "$ext installed"
done
fi
fi
fi
else
print_warning "VS Code command 'code' not found"
fi
echo ""
fi
#######################################
# Check 8: Ghostty Configuration
#######################################
if [ "$DEEP_MODE" = true ]; then
print_info "8. Checking Ghostty configuration..."
echo ""
GHOSTTY_CONFIG_DIR="$HOME/Library/Application Support/com.mitchellh.ghostty"
GHOSTTY_CONFIG="$GHOSTTY_CONFIG_DIR/config"
if [ -L "$GHOSTTY_CONFIG" ]; then
LINK_TARGET=$(readlink "$GHOSTTY_CONFIG")
if [[ "$LINK_TARGET" == *"dev-environment/ghostty/config" ]]; then
print_success "Ghostty config symlinked correctly"
else
print_warning "Ghostty config symlinked to wrong location: $LINK_TARGET"
if [ "$FIX_MODE" = true ]; then
read -r -p "Fix Ghostty config symlink? (y/N): " response
if [[ "$response" =~ ^[Yy]$ ]]; then
rm "$GHOSTTY_CONFIG"
ln -s "$SCRIPT_DIR/ghostty/config" "$GHOSTTY_CONFIG"
print_success "Ghostty config symlink fixed"
fi
fi
fi
elif [ -f "$GHOSTTY_CONFIG" ]; then
print_warning "Ghostty config exists but is not a symlink"
if [ "$FIX_MODE" = true ]; then
read -r -p "Replace with symlink? (y/N): " response
if [[ "$response" =~ ^[Yy]$ ]]; then
mv "$GHOSTTY_CONFIG" "$GHOSTTY_CONFIG.backup"
ln -s "$SCRIPT_DIR/ghostty/config" "$GHOSTTY_CONFIG"
print_success "Ghostty config symlinked (backup created)"
fi
fi
else
print_warning "Ghostty config not found"
if [ "$FIX_MODE" = true ]; then
read -r -p "Create Ghostty config symlink? (y/N): " response
if [[ "$response" =~ ^[Yy]$ ]]; then
mkdir -p "$GHOSTTY_CONFIG_DIR"
ln -s "$SCRIPT_DIR/ghostty/config" "$GHOSTTY_CONFIG"
print_success "Ghostty config symlink created"
fi
fi
fi
echo ""
fi
#######################################
# Check 9: Repository Status
#######################################
print_info "9. Checking repository status..."
echo ""
if [ -d "$SCRIPT_DIR/.git" ]; then
cd "$SCRIPT_DIR"
LATEST_COMMIT=$(git log -1 --oneline 2>/dev/null || echo "unknown")
BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
print_success "Repository is a git repository"
print_info " Branch: $BRANCH"
print_info " Latest commit: $LATEST_COMMIT"
if [ "$DEEP_MODE" = true ]; then
STATUS=$(git status --porcelain 2>/dev/null || echo "")
if [ -z "$STATUS" ]; then
print_success "Working directory is clean"
else
print_warning "Working directory has uncommitted changes"
fi
fi
else
print_error "Not a git repository"
fi
echo ""
#######################################
# Final Summary
#######################################
print_header "Verification Summary"
if [ "$ISSUES_FOUND" -eq 0 ]; then
print_success "All checks passed! System is properly configured."
echo ""
print_info "To activate any recent changes:"
echo " 1. Close and reopen your terminal, OR"
echo " 2. Run: source ~/.zshrc"
else
print_warning "Found $ISSUES_FOUND issue(s)"
echo ""
if [ "$FIX_MODE" = false ]; then
print_info "To fix issues:"
echo " 1. Run: ./verify-setup.sh --fix"
echo " 2. Or manually apply the suggested fixes above"
fi
fi
echo ""
print_header "Additional Commands"
echo " ./verify-setup.sh - Quick verification (default)"
echo " ./verify-setup.sh --deep - Comprehensive check"
echo " ./verify-setup.sh --fix - Fix issues interactively"
echo " ./verify-setup.sh --report - Generate detailed report file"
echo " ./setup.sh - Re-run setup (non-destructive)"
echo " make verify - Same as ./verify-setup.sh"
echo " make verify-fix - Same as ./verify-setup.sh --fix"
echo ""
# Report summary
if [ "$REPORT_MODE" = true ]; then
{
echo ""
echo "========================================"
echo "REPORT SUMMARY"
echo "========================================"
echo ""
echo "Total Issues Found: $ISSUES_FOUND"
echo "Verification Mode: $([ "$FIX_MODE" = true ] && echo "FIX" || echo "READ-ONLY")"
echo "Deep Mode: $([ "$DEEP_MODE" = true ] && echo "YES" || echo "NO")"
echo ""
echo "Report Generated: $(date '+%Y-%m-%d %H:%M:%S')"
echo "========================================"
} >> "$REPORT_FILE"
echo ""
print_header "Report Generated"
print_success "Report saved to: $(basename "$REPORT_FILE")"
print_info "Full path: $REPORT_FILE"
echo ""
print_info "Share this file when requesting support or troubleshooting"
echo ""
fi
# Exit with appropriate code
if [ "$ISSUES_FOUND" -gt 0 ]; then
exit 1
else
exit 0
fi