|
1 | 1 | #!/bin/sh |
2 | 2 |
|
| 3 | +# |
| 4 | +# Enhanced Setup Script with Progress Indicators |
| 5 | +# |
| 6 | + |
| 7 | +# Colors for better output |
| 8 | +RED='\033[0;31m' |
| 9 | +GREEN='\033[0;32m' |
| 10 | +YELLOW='\033[1;33m' |
| 11 | +BLUE='\033[0;34m' |
| 12 | +CYAN='\033[0;36m' |
| 13 | +NC='\033[0m' # No Color |
| 14 | + |
| 15 | +# Progress tracking |
| 16 | +TOTAL_STEPS=8 |
| 17 | +CURRENT_STEP=0 |
| 18 | +START_TIME=$(date +%s) |
| 19 | + |
3 | 20 | # |
4 | 21 | # Functions |
5 | 22 | # |
6 | | -function log() { |
7 | | - echo "\n" |
8 | | - echo "=======================================" |
9 | | - echo "$1" |
10 | | - echo "=======================================" |
| 23 | +function progress_header() { |
| 24 | + echo "\n${CYAN}┌─────────────────────────────────────────────────────────────┐${NC}" |
| 25 | + echo "${CYAN}│ 🏎️ Intercom React Native Setup Script 🏎️ │${NC}" |
| 26 | + echo "${CYAN}└─────────────────────────────────────────────────────────────┘${NC}" |
| 27 | + echo "${BLUE}Setting up your development environment...${NC}\n" |
11 | 28 | } |
12 | 29 |
|
13 | | -log "🏎️ Running React native setup script 🏎️" |
| 30 | +function step_start() { |
| 31 | + CURRENT_STEP=$((CURRENT_STEP + 1)) |
| 32 | + local step_name="$1" |
| 33 | + local icon="$2" |
| 34 | + |
| 35 | + echo "${CYAN}┌─ Step ${CURRENT_STEP}/${TOTAL_STEPS} ────────────────────────────────────────────────┐${NC}" |
| 36 | + echo "${CYAN}│${NC} ${icon} ${step_name}" |
| 37 | + echo "${CYAN}└─────────────────────────────────────────────────────────────┘${NC}" |
| 38 | +} |
14 | 39 |
|
15 | | -log "📱 Installing xcode tools 📱" |
| 40 | +function step_success() { |
| 41 | + local message="$1" |
| 42 | + echo "${GREEN}✅ ${message}${NC}" |
| 43 | + echo "" |
| 44 | +} |
| 45 | + |
| 46 | +function step_warning() { |
| 47 | + local message="$1" |
| 48 | + echo "${YELLOW}⚠️ ${message}${NC}" |
| 49 | +} |
| 50 | + |
| 51 | +function step_error() { |
| 52 | + local message="$1" |
| 53 | + echo "${RED}❌ ${message}${NC}" |
| 54 | +} |
16 | 55 |
|
| 56 | +function step_info() { |
| 57 | + local message="$1" |
| 58 | + echo "${BLUE}ℹ️ ${message}${NC}" |
| 59 | +} |
| 60 | + |
| 61 | +function show_progress() { |
| 62 | + local percentage=$((CURRENT_STEP * 100 / TOTAL_STEPS)) |
| 63 | + local filled=$((CURRENT_STEP * 50 / TOTAL_STEPS)) |
| 64 | + local empty=$((50 - filled)) |
| 65 | + |
| 66 | + printf "${CYAN}Progress: [${NC}" |
| 67 | + printf "%${filled}s" | tr ' ' '█' |
| 68 | + printf "%${empty}s" | tr ' ' '░' |
| 69 | + printf "${CYAN}] ${percentage}%%${NC}\n" |
| 70 | +} |
| 71 | + |
| 72 | +function final_summary() { |
| 73 | + local end_time=$(date +%s) |
| 74 | + local duration=$((end_time - START_TIME)) |
| 75 | + local minutes=$((duration / 60)) |
| 76 | + local seconds=$((duration % 60)) |
| 77 | + |
| 78 | + echo "\n${GREEN}┌─────────────────────────────────────────────────────────────┐${NC}" |
| 79 | + echo "${GREEN}│ 🎉 Setup Complete! 🎉 │${NC}" |
| 80 | + echo "${GREEN}└─────────────────────────────────────────────────────────────┘${NC}" |
| 81 | + echo "${GREEN}✅ All dependencies installed successfully${NC}" |
| 82 | + printf "${BLUE}⏱️ Total setup time: %dm %ds${NC}\n" "$minutes" "$seconds" |
| 83 | + echo "\n${CYAN}Next steps:${NC}" |
| 84 | + echo "${GREEN}📱 Run example app on iOS: ${YELLOW}yarn example ios${NC}" |
| 85 | + echo "${GREEN}📱 Run example app on Android: ${YELLOW}yarn example android${NC}" |
| 86 | +} |
| 87 | + |
| 88 | +progress_header |
| 89 | + |
| 90 | +# Step 1: Xcode Tools |
| 91 | +step_start "Checking Xcode Command Line Tools" "🛠️" |
17 | 92 | if [ ! -f /Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib ]; then |
18 | | - echo "⚠️ Xcode CommandLineTools not found installing. Please install and rerun this script ⚠️" |
| 93 | + step_warning "Xcode CommandLineTools not found. Installing..." |
| 94 | + step_info "Please complete the Xcode installation and rerun this script" |
19 | 95 | xcode-select --install |
20 | 96 | exit 1 |
21 | 97 | fi |
22 | | -echo "Xcode CommandLineTools installed 👍" |
23 | 98 |
|
24 | 99 | if ! [ -x "$(command -v xcode-select)" ]; then |
25 | | - echo "⚠️ You need Xcode to setup this project. Please install and rerun this script ⚠️" |
| 100 | + step_error "Xcode is required to setup this project. Please install and rerun this script" |
26 | 101 | exit 1 |
27 | 102 | fi |
28 | 103 |
|
29 | | -log "👀 Looking for Homebrew 👀" |
| 104 | +step_success "Xcode Command Line Tools are installed" |
| 105 | +show_progress |
| 106 | + |
| 107 | +# Step 2: Homebrew |
| 108 | +step_start "Setting up Homebrew package manager" "🍺" |
30 | 109 | if ! [ -x "$(command -v brew)" ]; then |
31 | | - echo "🍺 Installing Homebrew 🍺" |
| 110 | + step_info "Installing Homebrew..." |
32 | 111 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
33 | 112 | echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.bash_profile |
34 | 113 | echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.zshrc |
| 114 | + step_success "Homebrew installed successfully" |
35 | 115 | else |
36 | | - echo "Homebrew already installed 👍" |
| 116 | + step_success "Homebrew is already installed" |
37 | 117 | fi |
| 118 | +show_progress |
38 | 119 |
|
39 | | -log "👀 Looking for rbenv 👀" |
| 120 | +# Step 3: Ruby Environment (rbenv) |
| 121 | +step_start "Setting up Ruby environment with rbenv" "💎" |
40 | 122 | if ! [ -x "$(command -v rbenv)" ]; then |
41 | | - echo "🍺 Installing rbenv with brew 🍺" |
| 123 | + step_info "Installing rbenv and ruby-build..." |
42 | 124 | brew install rbenv ruby-build |
43 | 125 | echo 'eval "$(rbenv init -)"' >> ~/.bash_profile |
44 | 126 | echo 'eval "$(rbenv init -)"' >> ~/.zshrc |
45 | 127 | eval "$(rbenv init -)" |
| 128 | + step_success "rbenv installed successfully" |
46 | 129 | else |
47 | | - echo "rbenv already installed 👍" |
| 130 | + step_success "rbenv is already installed" |
48 | 131 | fi |
49 | 132 |
|
| 133 | +step_info "Setting up Ruby version..." |
50 | 134 | rbenv install --skip-existing |
51 | | -echo "Ruby setup complete 👍" |
| 135 | +step_success "Ruby environment configured" |
| 136 | +show_progress |
52 | 137 |
|
53 | | -log "👀 Looking for nvm 👀" |
| 138 | +# Step 4: Node.js Environment (nvm) |
| 139 | +step_start "Setting up Node.js environment with nvm" "📗" |
54 | 140 | if ! [ -x "$(command -v nvm)" ]; then |
55 | | - echo "🍺 Installing nvm with brew 🍺" |
| 141 | + step_info "Installing nvm..." |
56 | 142 | brew install nvm |
| 143 | + step_success "nvm installed successfully" |
| 144 | +else |
| 145 | + step_success "nvm is already installed" |
57 | 146 | fi |
58 | 147 |
|
59 | 148 | # Source nvm |
60 | 149 | export NVM_DIR="$HOME/.nvm" |
61 | 150 | [ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" |
62 | 151 |
|
| 152 | +step_info "Installing Node.js version from .nvmrc..." |
63 | 153 | nvm install |
64 | | -echo "Node.js setup complete 👍" |
| 154 | +step_success "Node.js environment configured" |
| 155 | +show_progress |
65 | 156 |
|
66 | | -log "👀 Looking for yarn 👀" |
| 157 | +# Step 5: Yarn Package Manager |
| 158 | +step_start "Setting up Yarn package manager" "🧶" |
67 | 159 | if ! [ -x "$(command -v yarn)" ]; then |
68 | | - echo "🍺 Installing yarn 🍺" |
| 160 | + step_info "Installing Yarn..." |
69 | 161 | brew install yarn |
| 162 | + step_success "Yarn installed successfully" |
70 | 163 | else |
71 | | - echo "yarn already installed 👍" |
| 164 | + step_success "Yarn is already installed" |
72 | 165 | fi |
| 166 | +show_progress |
73 | 167 |
|
74 | | -log "📟 installing dependencies 📟" |
| 168 | +# Step 6: Project Dependencies |
| 169 | +step_start "Installing project dependencies" "📦" |
| 170 | +step_info "Running yarn install..." |
75 | 171 | yarn |
| 172 | +step_success "Project dependencies installed" |
| 173 | +show_progress |
76 | 174 |
|
77 | | -log "📟 installing dependencies for our example app 📟" |
| 175 | +# Step 7: iOS Dependencies |
| 176 | +step_start "Installing iOS dependencies" "📱" |
| 177 | +step_info "Installing CocoaPods dependencies..." |
78 | 178 | cd example/ios |
79 | 179 | pod install |
80 | 180 | cd - |
| 181 | +step_success "iOS dependencies installed" |
| 182 | +show_progress |
| 183 | + |
| 184 | +# Step 8: Final Setup |
| 185 | +step_start "Finalizing setup" "🏁" |
| 186 | +step_success "Setup completed successfully" |
| 187 | +show_progress |
81 | 188 |
|
82 | | -echo "You're all set up 👍" |
83 | | -echo "📱 Run example app on iOS using -> yarn example ios" |
84 | | -echo "📱 Run example app on android using -> yarn example android" |
| 189 | +final_summary |
0 commit comments