1#!/usr/bin/env bash
2
3# set -e
4
5SIMULATOR_NAME="bare-expo"
6port=${2:-8081}
7CURRENT_ENV=${NODE_ENV:-"development"}
8
9DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
10
11echo " ☛  Bootstrapping Expo in ${CURRENT_ENV} mode"
12
13$DIR/setup-project.sh
14
15$DIR/start-metro.sh $port
16
17if [ "${CURRENT_ENV}" = "test" ]; then
18    if which applesimutils > /dev/null; then
19    # if brew ls --versions applesimutils > /dev/null; then
20        echo " ✅ Detox simulators are installed"
21    else
22        echo "Detox simulators are not installed, installing..."
23        brew tap wix/brew
24        brew install applesimutils
25    fi
26
27    if [ -d "ios/build/Build/Products/Debug-iphonesimulator/BareExpo.app" ]; then
28        echo " ✅ Debug Detox project is built for iOS"
29    else
30        echo " ⚠️  Building the debug Detox project..."
31        yarn run ios:detox:build:debug
32    fi
33
34    echo " ☛  Opening the iOS simulator app"
35    # Detox requires that the app is opened before it can connect
36    open -a "Simulator"
37
38    echo " ☛  Starting Detox in watch mode"
39    # Run our default E2E tests
40    yarn run ios:detox:test:debug --watch
41else
42
43    echo " ☛  Running the iOS project..."
44
45    # CONNECTED_DEVICE=$(node ios-deploy -c | grep -oE 'Found ([0-9A-Za-z\-]+)' | sed 's/Found //g')
46    # if [ -z "${CONNECTED_DEVICE}" ]; then
47        # Build and run the iOS project using `react-native run-ios`
48        node "node_modules/react-native/cli.js" run-ios --no-packager --port ${port}
49    # else
50    #     # Build and run the iOS project using `react-native run-ios`
51    #     node "node_modules/react-native/cli.js" run-ios --no-packager --udid ${CONNECTED_DEVICE} --port ${port}
52    # fi
53fi
54
55