1#!/usr/bin/env bash
2
3echo " ☛  Ensuring Android project is setup..."
4
5if [ -d "./node_modules" ]; then
6    echo " ✅ Node modules installed"
7else
8    echo " ⚠️  Cannot find node modules for this project, installing..."
9    yarn
10fi
11
12REACT_NATIVE_VERSION=$(node --print "require('react-native/package.json').version")
13
14if [ -d "node_modules/react-native/android/com/facebook/react/react-native/$REACT_NATIVE_VERSION" ]; then
15    echo " ✅ React Android is installed"
16else
17    echo " ⚠️  Compiling React Android (~5-10 minutes)..."
18
19    if [ ! -f "../../react-native-lab/react-native/local.properties" ]; then
20        # Copying local.properties to react-native-lab since it may come in handy
21        if [ -f "../../android/local.properties" ]; then
22            cp ../../android/local.properties ../../react-native-lab/react-native
23            echo "   ✅ local.properties copied from Expo client Android project"
24        else
25            echo "   ⚠️  No local.properties found, the build may fail if you have no required (ANDROID_*) env variables set"
26        fi
27    fi
28
29    # Go to our fork of React Native
30    cd ../../react-native-lab/react-native
31    # Build the AARs (~5-10 minutes)
32    ./gradlew :ReactAndroid:installArchives
33    # Come back to the project
34    cd ../../apps/bare-expo
35
36    echo " ✅ React Android is now installed!"
37fi
38
39../../tools/bin/expotools.js android-generate-dynamic-macros --configuration $1 --bare
40echo " ✅ Generete dynamic macros"
41