2019-03-01 13:24:23 +00:00
|
|
|
#!/usr/bin/env bash
|
2018-07-23 15:21:31 +00:00
|
|
|
|
2019-01-23 10:11:31 +00:00
|
|
|
set -e
|
|
|
|
|
2019-03-22 11:00:32 +00:00
|
|
|
GIT_ROOT=$(git rev-parse --show-toplevel)
|
|
|
|
|
2018-07-23 15:21:31 +00:00
|
|
|
RED='\033[0;31m'
|
|
|
|
GREEN='\033[0;32m'
|
|
|
|
YELLOW='\033[1;33m'
|
|
|
|
NC='\033[0m'
|
|
|
|
PLATFORM=""
|
|
|
|
PLATFORM_FOLDER=""
|
|
|
|
|
2019-03-22 11:00:32 +00:00
|
|
|
RCTSTATUS_DIR="$GIT_ROOT/modules/react-native-status/ios/RCTStatus"
|
|
|
|
|
2018-07-23 15:21:31 +00:00
|
|
|
#if no arguments passed, inform user about possible ones
|
|
|
|
|
2018-11-21 12:14:43 +00:00
|
|
|
if [ $# -eq 0 ]; then
|
2019-03-22 11:00:32 +00:00
|
|
|
echo -e "${GREEN}This script should be invoked with platform argument: 'android', 'ios', or 'desktop'${NC}"
|
|
|
|
echo "If invoked with 'android' argument it will link: "
|
|
|
|
echo "mobile_files/package.json.orig -> package.json"
|
2018-11-21 12:14:43 +00:00
|
|
|
echo "etc.."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
case $1 in
|
|
|
|
android | ios)
|
|
|
|
PLATFORM='mobile'
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
PLATFORM=$1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
PLATFORM_FOLDER="${PLATFORM}_files"
|
2018-07-23 15:21:31 +00:00
|
|
|
fi
|
|
|
|
|
2019-03-22 11:00:32 +00:00
|
|
|
$GIT_ROOT/scripts/run-environment-check.sh $1
|
|
|
|
|
|
|
|
if [ ! -f .babelrc ] || [ $(readlink .babelrc) != "${PLATFORM_FOLDER}/.babelrc" ]; then
|
|
|
|
echo "Creating link: package.json -> ${PLATFORM_FOLDER}/package.json.orig"
|
|
|
|
ln -sf ${PLATFORM_FOLDER}/package.json.orig package.json
|
2018-07-23 15:21:31 +00:00
|
|
|
|
2019-03-22 11:00:32 +00:00
|
|
|
echo "Creating link: yarn.lock -> ${PLATFORM_FOLDER}/yarn.lock"
|
|
|
|
ln -sf ${PLATFORM_FOLDER}/yarn.lock yarn.lock
|
2018-07-23 15:21:31 +00:00
|
|
|
|
2019-03-22 11:00:32 +00:00
|
|
|
echo "Creating link: VERSION -> ${PLATFORM_FOLDER}/VERSION"
|
|
|
|
ln -sf ${PLATFORM_FOLDER}/VERSION VERSION
|
2018-07-23 15:21:31 +00:00
|
|
|
|
2019-03-22 11:00:32 +00:00
|
|
|
echo "Creating link: .babelrc -> ${PLATFORM_FOLDER}/.babelrc"
|
|
|
|
ln -sf ${PLATFORM_FOLDER}/.babelrc .babelrc
|
2019-03-04 12:38:41 +00:00
|
|
|
|
|
|
|
echo "Creating link: .babelrc -> ${PLATFORM_FOLDER}/.babelrc"
|
|
|
|
ln -sf ${PLATFORM_FOLDER}/metro.config.js metro.config.js
|
2019-03-22 11:00:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
yarn install --frozen-lockfile
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
android)
|
|
|
|
set -e
|
|
|
|
if [ ! -d $GIT_ROOT/node_modules/react-native/android/com/facebook/react/react-native/ ]; then
|
|
|
|
cd $GIT_ROOT/android && ./gradlew react-native-android:installArchives
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
ios)
|
2019-03-25 16:35:01 +00:00
|
|
|
targetBasename='Statusgo.framework'
|
|
|
|
# Compare target folder with source to see if copying is required
|
|
|
|
if [ -d "$RCTSTATUS_DIR/$targetBasename" ] && \
|
|
|
|
diff -q --no-dereference --recursive $RCTSTATUS_DIR/$targetBasename/ $RCTSTATUS_FILEPATH/ > /dev/null; then
|
|
|
|
echo "$RCTSTATUS_DIR/$targetBasename already in place"
|
|
|
|
else
|
|
|
|
sourceBasename="$(basename $RCTSTATUS_FILEPATH)"
|
|
|
|
echo "Copying $sourceBasename from Nix store to $RCTSTATUS_DIR"
|
|
|
|
rm -rf "$RCTSTATUS_DIR/$targetBasename/"
|
|
|
|
cp -a $RCTSTATUS_FILEPATH $RCTSTATUS_DIR && chmod -R 755 "$RCTSTATUS_DIR/$targetBasename"
|
|
|
|
if [ "$sourceBasename" != "$targetBasename" ]; then
|
|
|
|
mv "$RCTSTATUS_DIR/$sourceBasename" "$RCTSTATUS_DIR/$targetBasename"
|
|
|
|
fi
|
2019-03-22 11:00:32 +00:00
|
|
|
if [ "$(uname)" == 'Darwin' ]; then
|
2019-03-25 16:35:01 +00:00
|
|
|
# TODO: remove this patch when we upgrade to a RN version that plays well with the modern build system
|
2019-03-22 11:00:32 +00:00
|
|
|
git apply --check $GIT_ROOT/ios/patches/ios-legacy-build-system.patch 2> /dev/null && \
|
|
|
|
git apply $GIT_ROOT/ios/patches/ios-legacy-build-system.patch || \
|
|
|
|
echo "Patch already applied"
|
|
|
|
# CocoaPods are trash and can't handle other pod instances running at the same time
|
|
|
|
$GIT_ROOT/scripts/wait-for.sh pod 240
|
|
|
|
pushd $GIT_ROOT/ios && pod install; popd
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2018-07-23 15:21:31 +00:00
|
|
|
|
|
|
|
echo -e "${GREEN}Finished!${NC}"
|