|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# |
| 4 | +# Functions |
| 5 | +# |
| 6 | +function log() { |
| 7 | + echo "\n" |
| 8 | + echo "=======================================" |
| 9 | + echo "$1" |
| 10 | + echo "=======================================" |
| 11 | +} |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +EXPECTED_RUBY_VERSION=$(cat ${SOURCE_ROOT_DIR}/.ruby-version) |
| 16 | +ruby_version="2.4.4" |
| 17 | +rbenv_version="2.5.7" |
| 18 | + |
| 19 | +log "🏎️ Running React native setup script 🏎️" |
| 20 | + |
| 21 | +log "📱 Installing xcode tools 📱" |
| 22 | + |
| 23 | +if [ ! -f /Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib ]; then |
| 24 | + echo "⚠️ Xcode CommandLineTools not found installing. Please install and rerun this script ⚠️" |
| 25 | + xcode-select --install |
| 26 | + exit 1 |
| 27 | +fi |
| 28 | +echo "Xcode CommandLineTools installed 👍" |
| 29 | + |
| 30 | +if ! [ -x "$(command -v xcode-select)" ]; then |
| 31 | + echo "⚠️ You need Xcode to setuo this project. Please install and rerun this script ⚠️" |
| 32 | + exit 1s |
| 33 | +fi |
| 34 | + |
| 35 | +log "👀 Looking for Homebrew 👀" |
| 36 | +if ! [ -x "$(command -v brew)" ]; then |
| 37 | + echo "🍺 Installing Homebrew 🍺" |
| 38 | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 39 | + echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.bash_profile |
| 40 | + echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.zshrc |
| 41 | +else |
| 42 | + echo "Homebrew already installed 👍" |
| 43 | +fi |
| 44 | + |
| 45 | +log "👀 Looking for rbenv 👀" |
| 46 | + |
| 47 | +if ! [ -x "$(command -v rbenv)" ]; then |
| 48 | + echo "🍺 Installing rbenv with brew 🍺" |
| 49 | + brew install rbenv |
| 50 | + echo 'eval "$(rbenv init -)"' >> ~/.bash_profile |
| 51 | + echo 'eval "$(rbenv init -)"' >> ~/.zshrc |
| 52 | + eval "$(rbenv init -)" |
| 53 | + rbenv install "2.5.7" |
| 54 | +else |
| 55 | + rbenv install "2.5.7" |
| 56 | + echo "rbenv already installed 👍" |
| 57 | +fi |
| 58 | +rbenv local "2.5.7" |
| 59 | + |
| 60 | +log "👀 Looking for yarn 👀" |
| 61 | +if ! [ -x "$(command -v yarn)" ]; then |
| 62 | + echo "🍺 Installing yarn 🍺" |
| 63 | + brew install yarn |
| 64 | +else |
| 65 | + echo "yarn already installed 👍" |
| 66 | +fi |
| 67 | + |
| 68 | +log "👀 Looking for ruby 👀" |
| 69 | +ruby-build --definitions | grep ^${EXPECTED_RUBY_VERSION} > /dev/null |
| 70 | +RUBYBUILD_DEFS_EXIT_CODE=$? |
| 71 | +if [ "$RUBYBUILD_DEFS_EXIT_CODE" -ne 0 ]; then |
| 72 | + echo "🍺 Ruby Build: Cannot find Ruby version required, updating via brew 🍺" |
| 73 | + brew update && brew upgrade ruby-build |
| 74 | +fi |
| 75 | +rbenv install --skip-existing |
| 76 | +echo "Ruby installed 👍" |
| 77 | + |
| 78 | +log "📟 installing dependencies 📟" |
| 79 | +yarn |
| 80 | + |
| 81 | +log "📟 installing dependencies for our example app 📟" |
| 82 | +cd example/ios |
| 83 | +pod install |
| 84 | +cd - |
| 85 | + |
| 86 | +echo "You're all set up 👍" |
| 87 | +echo "📱 Run example app on iOS using -> yarn example ios" |
| 88 | +echo "📱 Run example app on android using -> yarn example android --variant=fossDebug" |
0 commit comments