-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathsetup
More file actions
executable file
·189 lines (160 loc) · 6.04 KB
/
setup
File metadata and controls
executable file
·189 lines (160 loc) · 6.04 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
#!/bin/sh
#
# Enhanced Setup Script with Progress Indicators
#
# Colors for better output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Progress tracking
TOTAL_STEPS=8
CURRENT_STEP=0
START_TIME=$(date +%s)
#
# Functions
#
function progress_header() {
echo "\n${CYAN}┌─────────────────────────────────────────────────────────────┐${NC}"
echo "${CYAN}│ 🏎️ Intercom React Native Setup Script 🏎️ │${NC}"
echo "${CYAN}└─────────────────────────────────────────────────────────────┘${NC}"
echo "${BLUE}Setting up your development environment...${NC}\n"
}
function step_start() {
CURRENT_STEP=$((CURRENT_STEP + 1))
local step_name="$1"
local icon="$2"
echo "${CYAN}┌─ Step ${CURRENT_STEP}/${TOTAL_STEPS} ────────────────────────────────────────────────┐${NC}"
echo "${CYAN}│${NC} ${icon} ${step_name}"
echo "${CYAN}└─────────────────────────────────────────────────────────────┘${NC}"
}
function step_success() {
local message="$1"
echo "${GREEN}✅ ${message}${NC}"
echo ""
}
function step_warning() {
local message="$1"
echo "${YELLOW}⚠️ ${message}${NC}"
}
function step_error() {
local message="$1"
echo "${RED}❌ ${message}${NC}"
}
function step_info() {
local message="$1"
echo "${BLUE}ℹ️ ${message}${NC}"
}
function show_progress() {
local percentage=$((CURRENT_STEP * 100 / TOTAL_STEPS))
local filled=$((CURRENT_STEP * 50 / TOTAL_STEPS))
local empty=$((50 - filled))
printf "${CYAN}Progress: [${NC}"
printf "%${filled}s" | tr ' ' '█'
printf "%${empty}s" | tr ' ' '░'
printf "${CYAN}] ${percentage}%%${NC}\n"
}
function final_summary() {
local end_time=$(date +%s)
local duration=$((end_time - START_TIME))
local minutes=$((duration / 60))
local seconds=$((duration % 60))
echo "\n${GREEN}┌─────────────────────────────────────────────────────────────┐${NC}"
echo "${GREEN}│ 🎉 Setup Complete! 🎉 │${NC}"
echo "${GREEN}└─────────────────────────────────────────────────────────────┘${NC}"
echo "${GREEN}✅ All dependencies installed successfully${NC}"
printf "${BLUE}⏱️ Total setup time: %dm %ds${NC}\n" "$minutes" "$seconds"
echo "\n${CYAN}Next steps:${NC}"
echo "${GREEN}📱 Run example app on iOS: ${YELLOW}yarn example ios${NC}"
echo "${GREEN}📱 Run example app on Android: ${YELLOW}yarn example android${NC}"
}
progress_header
# Step 1: Xcode Tools
step_start "Checking Xcode Command Line Tools" "🛠️"
if [ ! -f /Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib ]; then
step_warning "Xcode CommandLineTools not found. Installing..."
step_info "Please complete the Xcode installation and rerun this script"
xcode-select --install
exit 1
fi
if ! [ -x "$(command -v xcode-select)" ]; then
step_error "Xcode is required to setup this project. Please install and rerun this script"
exit 1
fi
step_success "Xcode Command Line Tools are installed"
show_progress
# Step 2: Homebrew
step_start "Setting up Homebrew package manager" "🍺"
if ! [ -x "$(command -v brew)" ]; then
step_info "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.bash_profile
echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.zshrc
step_success "Homebrew installed successfully"
else
step_success "Homebrew is already installed"
fi
show_progress
# Step 3: Ruby Environment (rbenv)
step_start "Setting up Ruby environment with rbenv" "💎"
if ! [ -x "$(command -v rbenv)" ]; then
step_info "Installing rbenv and ruby-build..."
brew install rbenv ruby-build
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
eval "$(rbenv init -)"
step_success "rbenv installed successfully"
else
step_success "rbenv is already installed"
fi
step_info "Setting up Ruby version..."
rbenv install --skip-existing
step_success "Ruby environment configured"
show_progress
# Step 4: Node.js Environment (nvm)
step_start "Setting up Node.js environment with nvm" "📗"
if ! [ -x "$(command -v nvm)" ]; then
step_info "Installing nvm..."
brew install nvm
step_success "nvm installed successfully"
else
step_success "nvm is already installed"
fi
# Source nvm
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"
step_info "Installing Node.js version from .nvmrc..."
nvm install
step_success "Node.js environment configured"
show_progress
# Step 5: Yarn Package Manager
step_start "Setting up Yarn package manager" "🧶"
if ! [ -x "$(command -v yarn)" ]; then
step_info "Installing Yarn..."
brew install yarn
step_success "Yarn installed successfully"
else
step_success "Yarn is already installed"
fi
show_progress
# Step 6: Project Dependencies
step_start "Installing project dependencies" "📦"
step_info "Running yarn install..."
yarn
step_success "Project dependencies installed"
show_progress
# Step 7: iOS Dependencies
step_start "Installing iOS dependencies" "📱"
step_info "Installing CocoaPods dependencies..."
cd example/ios
pod install
cd -
step_success "iOS dependencies installed"
show_progress
# Step 8: Final Setup
step_start "Finalizing setup" "🏁"
step_success "Setup completed successfully"
show_progress
final_summary