2019-03-01 13:24:23 +00:00
|
|
|
#!/usr/bin/env bash
|
2018-11-21 12:14:43 +00:00
|
|
|
|
|
|
|
RED='\033[0;31m'
|
|
|
|
GREEN='\033[0;32m'
|
|
|
|
YELLOW='\033[1;33m'
|
|
|
|
NC='\033[0m'
|
|
|
|
PLATFORM=""
|
|
|
|
|
2019-01-10 18:32:30 +00:00
|
|
|
_current_dir=$(cd "${BASH_SOURCE%/*}" && pwd)
|
|
|
|
source "$_current_dir/lib/setup/path-support.sh"
|
2018-11-28 18:02:20 +00:00
|
|
|
|
2019-01-10 18:32:30 +00:00
|
|
|
source_lib "packages.sh"
|
|
|
|
|
2019-01-18 14:09:23 +00:00
|
|
|
EXPECTED_NODE_VERSION="v$(toolversion node)" # note the 'v' in front, that is how node does versioning
|
|
|
|
EXPECTED_YARN_VERSION="$(toolversion yarn)" # note the lack of 'v' in front. inconsistent. :(
|
2018-11-29 16:28:57 +00:00
|
|
|
|
2019-01-26 15:36:12 +00:00
|
|
|
# if no arguments passed, inform user about possible ones
|
2018-11-21 12:14:43 +00:00
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
echo -e "${GREEN}This script should be invoked with platform argument: 'android', 'ios' or 'desktop'${NC}"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
PLATFORM=$1
|
|
|
|
fi
|
|
|
|
|
2019-02-15 08:04:03 +00:00
|
|
|
if [ -z "$IN_NIX_SHELL" ]; then
|
|
|
|
if ! program_version_exists node $EXPECTED_NODE_VERSION || ! program_version_exists yarn $EXPECTED_YARN_VERSION; then
|
|
|
|
echo -e "${YELLOW}********************************************************************************************"
|
|
|
|
|
|
|
|
echo -e "The current environment doesn't contain the expected versions of node and/or yarn"
|
|
|
|
echo -e " - node:\texpected\t${EXPECTED_NODE_VERSION}"
|
|
|
|
echo -e " \t\tfound\t\t$(node -v) ($(which node))"
|
|
|
|
echo -e " - yarn:\texpected\t${EXPECTED_YARN_VERSION}"
|
|
|
|
echo -e " \t\tfound\t\t$(yarn -v) ($(which yarn))"
|
2019-04-09 19:02:39 +00:00
|
|
|
echo -e "Please open another console to reload the environment."
|
2019-02-15 08:04:03 +00:00
|
|
|
|
|
|
|
echo -e "**********************************************************************************************${NC}"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-11-29 16:28:57 +00:00
|
|
|
fi
|
2018-11-28 18:02:20 +00:00
|
|
|
|
2019-04-05 17:22:49 +00:00
|
|
|
if [ "$PLATFORM" == 'android' ]; then
|
2019-02-01 10:44:51 +00:00
|
|
|
if [ ! -d $ANDROID_SDK_ROOT ]; then
|
2019-04-03 11:06:42 +00:00
|
|
|
echo -e "${GREEN}SDK setup not complete, please run 'scripts/setup'!${NC}"
|
2019-02-01 10:44:51 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ ! -d $ANDROID_NDK_ROOT ]; then
|
2019-04-09 19:02:39 +00:00
|
|
|
echo -e "${GREEN}NDK setup not complete, please run 'scripts/setup'!${NC}"
|
2019-02-01 10:44:51 +00:00
|
|
|
exit 1
|
2018-11-21 12:14:43 +00:00
|
|
|
fi
|
2019-04-05 17:22:49 +00:00
|
|
|
elif [ "$PLATFORM" == 'ios' ] && [ "$(uname)" != "Darwin" ]; then
|
|
|
|
echo -e "${RED}iOS builds are only possible on macOS hosts${NC}"
|
|
|
|
exit 1
|
2018-11-21 12:14:43 +00:00
|
|
|
fi
|
|
|
|
|
2019-01-26 15:36:12 +00:00
|
|
|
if [[ $PLATFORM == 'setup' ]]; then
|
2019-02-01 10:44:51 +00:00
|
|
|
echo -e "${YELLOW}Finished! Please close your terminal, reopen a new one and type 'nix-shell' before building Status.${NC}"
|
2019-01-26 15:36:12 +00:00
|
|
|
else
|
|
|
|
echo -e "${GREEN}Finished!${NC}"
|
|
|
|
fi
|