2018-11-21 12:14:43 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
RED='\033[0;31m'
|
|
|
|
GREEN='\033[0;32m'
|
|
|
|
YELLOW='\033[1;33m'
|
|
|
|
NC='\033[0m'
|
|
|
|
PLATFORM=""
|
|
|
|
|
2018-11-29 15:55:36 +00:00
|
|
|
EXPECTED_NODE_VERSION="v10.14.0" # note the 'v' in front, that is how node does versioning
|
2019-01-10 18:31:05 +00:00
|
|
|
EXPECTED_YARN_VERSION="1.13.0" # note the lack of 'v' in front. inconsistent. :(
|
2018-11-28 18:02:20 +00:00
|
|
|
|
2018-11-29 16:28:57 +00:00
|
|
|
function program_exists() {
|
|
|
|
local program=$1
|
|
|
|
command -v "$program" >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
2018-11-21 12:14:43 +00:00
|
|
|
#if no arguments passed, inform user about possible ones
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-11-29 16:28:57 +00:00
|
|
|
if ! program_exists node || ! program_exists yarn; then
|
|
|
|
echo -e "${YELLOW}********************************************************************************************"
|
2018-12-03 15:26:37 +00:00
|
|
|
|
|
|
|
nvmrc="./.nvmrc"
|
|
|
|
if [ -e "$nvmrc" ]; then
|
|
|
|
node_version=$(node -v)
|
|
|
|
version_alias=$(cat "$nvmrc")
|
|
|
|
echo -e "Please run 'nvm use $version_alias' in the terminal and try again."
|
|
|
|
else
|
|
|
|
echo -e "Please open another console to reload the environment, and then run make setup if necessary."
|
|
|
|
fi
|
|
|
|
|
2018-11-29 16:28:57 +00:00
|
|
|
echo -e "********************************************************************************************${NC}"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-11-28 18:02:20 +00:00
|
|
|
|
2018-11-29 16:28:57 +00:00
|
|
|
node_version=$(node -v)
|
2018-11-28 18:02:20 +00:00
|
|
|
if [[ $node_version != $EXPECTED_NODE_VERSION ]]; then
|
|
|
|
echo -e "${YELLOW}+ node version $node_version is installed. node version $EXPECTED_NODE_VERSION is recommended.${NC}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
yarn_version=$(yarn -v)
|
|
|
|
if [[ $yarn_version != $EXPECTED_YARN_VERSION ]]; then
|
|
|
|
echo -e "${YELLOW}+ yarn version $yarn_version is installed. yarn version $EXPECTED_YARN_VERSION is recommended.${NC}"
|
2018-11-21 12:14:43 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $PLATFORM == 'android' ]]; then
|
|
|
|
_localPropertiesPath=./android/local.properties
|
|
|
|
if ! grep -Fq "ndk.dir" $_localPropertiesPath; then
|
|
|
|
if [ -z $ANDROID_NDK_HOME ]; then
|
|
|
|
echo -e "${GREEN}NDK directory not configured, please run 'make setup' or add the line to ${_localPropertiesPath}!${NC}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "${GREEN}Finished!${NC}"
|