Skip to content

Commit 743b158

Browse files
Merge remote-tracking branch 'origin/main' into maestro_playground
2 parents ef2abea + 816c8a4 commit 743b158

File tree

3 files changed

+263
-29
lines changed

3 files changed

+263
-29
lines changed

__tests__/setup.test.js

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/**
2+
* Tests for the enhanced setup script
3+
*/
4+
5+
const { execSync } = require('child_process');
6+
const fs = require('fs');
7+
const path = require('path');
8+
9+
describe('Setup Script', () => {
10+
const setupScriptPath = path.join(__dirname, '..', 'script', 'setup');
11+
12+
beforeAll(() => {
13+
// Ensure the setup script exists and is executable
14+
expect(fs.existsSync(setupScriptPath)).toBe(true);
15+
});
16+
17+
test('setup script should be executable', () => {
18+
const stats = fs.statSync(setupScriptPath);
19+
// Check if the file has executable permission
20+
// eslint-disable-next-line no-bitwise
21+
expect(stats.mode & 0o111).not.toBe(0);
22+
});
23+
24+
test('setup script should contain progress functions', () => {
25+
const content = fs.readFileSync(setupScriptPath, 'utf8');
26+
27+
// Check for new progress functions
28+
expect(content).toContain('progress_header()');
29+
expect(content).toContain('step_start()');
30+
expect(content).toContain('step_success()');
31+
expect(content).toContain('step_warning()');
32+
expect(content).toContain('step_error()');
33+
expect(content).toContain('step_info()');
34+
expect(content).toContain('show_progress()');
35+
expect(content).toContain('final_summary()');
36+
});
37+
38+
test('setup script should contain color definitions', () => {
39+
const content = fs.readFileSync(setupScriptPath, 'utf8');
40+
41+
// Check for color definitions
42+
expect(content).toContain('RED=');
43+
expect(content).toContain('GREEN=');
44+
expect(content).toContain('YELLOW=');
45+
expect(content).toContain('BLUE=');
46+
expect(content).toContain('CYAN=');
47+
expect(content).toContain('NC=');
48+
});
49+
50+
test('setup script should contain progress tracking variables', () => {
51+
const content = fs.readFileSync(setupScriptPath, 'utf8');
52+
53+
// Check for progress tracking
54+
expect(content).toContain('TOTAL_STEPS=8');
55+
expect(content).toContain('CURRENT_STEP=0');
56+
expect(content).toContain('START_TIME=');
57+
});
58+
59+
test('setup script should have proper step structure', () => {
60+
const content = fs.readFileSync(setupScriptPath, 'utf8');
61+
62+
// Check for all steps
63+
expect(content).toContain('Step 1: Xcode Tools');
64+
expect(content).toContain('Step 2: Homebrew');
65+
expect(content).toContain('Step 3: Ruby Environment');
66+
expect(content).toContain('Step 4: Node.js Environment');
67+
expect(content).toContain('Step 5: Yarn Package Manager');
68+
expect(content).toContain('Step 6: Project Dependencies');
69+
expect(content).toContain('Step 7: iOS Dependencies');
70+
expect(content).toContain('Step 8: Final Setup');
71+
});
72+
73+
test('setup script should have enhanced user feedback', () => {
74+
const content = fs.readFileSync(setupScriptPath, 'utf8');
75+
76+
// Check for enhanced feedback
77+
expect(content).toContain('✅'); // Success checkmarks
78+
expect(content).toContain('⚠️'); // Warnings
79+
expect(content).toContain('❌'); // Errors
80+
expect(content).toContain('ℹ️'); // Info
81+
expect(content).toContain('🎉'); // Celebration
82+
expect(content).toContain('⏱️'); // Timer
83+
});
84+
85+
test('setup script should contain progress bar functionality', () => {
86+
const content = fs.readFileSync(setupScriptPath, 'utf8');
87+
88+
// Check for progress bar elements
89+
expect(content).toContain('Progress: [');
90+
expect(content).toContain('█'); // Filled progress
91+
expect(content).toContain('░'); // Empty progress
92+
expect(content).toContain('percentage');
93+
});
94+
95+
test('setup script should have timing functionality', () => {
96+
const content = fs.readFileSync(setupScriptPath, 'utf8');
97+
98+
// Check for timing
99+
expect(content).toContain('START_TIME=$(date +%s)');
100+
expect(content).toContain('end_time=$(date +%s)');
101+
expect(content).toContain('duration=');
102+
expect(content).toContain('Total setup time:');
103+
});
104+
105+
test('setup script should maintain all original functionality', () => {
106+
const content = fs.readFileSync(setupScriptPath, 'utf8');
107+
108+
// Check that all original functionality is preserved
109+
expect(content).toContain('xcode-select');
110+
expect(content).toContain('brew');
111+
expect(content).toContain('rbenv');
112+
expect(content).toContain('nvm');
113+
expect(content).toContain('yarn');
114+
expect(content).toContain('pod install');
115+
});
116+
117+
test('setup script should start with proper shebang', () => {
118+
const content = fs.readFileSync(setupScriptPath, 'utf8');
119+
expect(content.startsWith('#!/bin/sh')).toBe(true);
120+
});
121+
122+
test('setup script dry run should not fail on syntax', () => {
123+
// Test that the script doesn't have syntax errors
124+
// Note: This uses bash -n to check syntax without executing
125+
expect(() => {
126+
execSync(`bash -n "${setupScriptPath}"`, { stdio: 'pipe' });
127+
}).not.toThrow();
128+
});
129+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"!**/__mocks__"
2424
],
2525
"scripts": {
26-
"test": "echo test",
26+
"test": "jest",
2727
"typescript": "tsc --noEmit",
2828
"lint": "eslint \"**/*.{js,ts,tsx}\"",
2929
"prepare": "bob build",

script/setup

Lines changed: 133 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,189 @@
11
#!/bin/sh
22

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+
320
#
421
# Functions
522
#
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"
1128
}
1229

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+
}
1439

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+
}
1655

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" "🛠️"
1792
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"
1995
xcode-select --install
2096
exit 1
2197
fi
22-
echo "Xcode CommandLineTools installed 👍"
2398

2499
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"
26101
exit 1
27102
fi
28103

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" "🍺"
30109
if ! [ -x "$(command -v brew)" ]; then
31-
echo "🍺 Installing Homebrew 🍺"
110+
step_info "Installing Homebrew..."
32111
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
33112
echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.bash_profile
34113
echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.zshrc
114+
step_success "Homebrew installed successfully"
35115
else
36-
echo "Homebrew already installed 👍"
116+
step_success "Homebrew is already installed"
37117
fi
118+
show_progress
38119

39-
log "👀 Looking for rbenv 👀"
120+
# Step 3: Ruby Environment (rbenv)
121+
step_start "Setting up Ruby environment with rbenv" "💎"
40122
if ! [ -x "$(command -v rbenv)" ]; then
41-
echo "🍺 Installing rbenv with brew 🍺"
123+
step_info "Installing rbenv and ruby-build..."
42124
brew install rbenv ruby-build
43125
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
44126
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
45127
eval "$(rbenv init -)"
128+
step_success "rbenv installed successfully"
46129
else
47-
echo "rbenv already installed 👍"
130+
step_success "rbenv is already installed"
48131
fi
49132

133+
step_info "Setting up Ruby version..."
50134
rbenv install --skip-existing
51-
echo "Ruby setup complete 👍"
135+
step_success "Ruby environment configured"
136+
show_progress
52137

53-
log "👀 Looking for nvm 👀"
138+
# Step 4: Node.js Environment (nvm)
139+
step_start "Setting up Node.js environment with nvm" "📗"
54140
if ! [ -x "$(command -v nvm)" ]; then
55-
echo "🍺 Installing nvm with brew 🍺"
141+
step_info "Installing nvm..."
56142
brew install nvm
143+
step_success "nvm installed successfully"
144+
else
145+
step_success "nvm is already installed"
57146
fi
58147

59148
# Source nvm
60149
export NVM_DIR="$HOME/.nvm"
61150
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"
62151

152+
step_info "Installing Node.js version from .nvmrc..."
63153
nvm install
64-
echo "Node.js setup complete 👍"
154+
step_success "Node.js environment configured"
155+
show_progress
65156

66-
log "👀 Looking for yarn 👀"
157+
# Step 5: Yarn Package Manager
158+
step_start "Setting up Yarn package manager" "🧶"
67159
if ! [ -x "$(command -v yarn)" ]; then
68-
echo "🍺 Installing yarn 🍺"
160+
step_info "Installing Yarn..."
69161
brew install yarn
162+
step_success "Yarn installed successfully"
70163
else
71-
echo "yarn already installed 👍"
164+
step_success "Yarn is already installed"
72165
fi
166+
show_progress
73167

74-
log "📟 installing dependencies 📟"
168+
# Step 6: Project Dependencies
169+
step_start "Installing project dependencies" "📦"
170+
step_info "Running yarn install..."
75171
yarn
172+
step_success "Project dependencies installed"
173+
show_progress
76174

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..."
78178
cd example/ios
79179
pod install
80180
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
81188

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

Comments
 (0)