Added developer setup script for smoother setup
Moved run-osx.sh to scripts/ subdirectory
This commit is contained in:
parent
2dbefb706e
commit
db1efe51f8
|
@ -36,6 +36,7 @@ local.properties
|
|||
#
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
.nvmrc
|
||||
|
||||
# BUCK
|
||||
buck-out/
|
||||
|
@ -80,6 +81,7 @@ status-dev-cli
|
|||
#ios
|
||||
ios/Pods
|
||||
ios/StatusIm.xcworkspace
|
||||
.ruby-version
|
||||
|
||||
#python
|
||||
*.pyc
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
function install_node() {
|
||||
if nvm_installed; then
|
||||
install_node_via_nvm
|
||||
else
|
||||
install_node_via_brew
|
||||
fi
|
||||
}
|
||||
|
||||
function install_react_native_cli() {
|
||||
cd "$(repo_path)"
|
||||
|
||||
if npm list -g | grep -q react-native-cli; then
|
||||
already_installed "react-native-cli"
|
||||
else
|
||||
npm install -g react-native-cli
|
||||
fi
|
||||
}
|
||||
|
||||
function install_node_via_nvm() {
|
||||
local nvmrc="$(repo_path)/.nvmrc"
|
||||
|
||||
cd "$(repo_path)"
|
||||
|
||||
if [ ! -e "$nvmrc" ]; then
|
||||
cecho "@b@blue[[+ Installing latest stable Node version]]"
|
||||
|
||||
nvm install stable
|
||||
echo stable > "$nvmrc"
|
||||
|
||||
nvm use
|
||||
else
|
||||
nvm use >/dev/null
|
||||
|
||||
local version=$(node -v)
|
||||
cecho "+ Node already installed ($version via NVM)... skipping."
|
||||
fi
|
||||
}
|
||||
|
||||
function install_node_via_brew() {
|
||||
if ! program_exists "node"; then
|
||||
brew install node
|
||||
else
|
||||
cecho "+ Node already installed ($(node -v) via Homebrew)... skipping."
|
||||
fi
|
||||
}
|
||||
|
||||
function required_pod_version() {
|
||||
cat "$(repo_path)/ios/Podfile.lock" | grep "COCOAPODS: " | awk '{ print $2 }'
|
||||
}
|
||||
|
||||
function correct_pod_version_is_installed() {
|
||||
! program_exists "pod" && return 1
|
||||
|
||||
[[ "$(required_pod_version)" == "$(pod --version)" ]]
|
||||
}
|
||||
|
||||
function initialize_rvm() {
|
||||
cd "$(repo_path)"
|
||||
|
||||
if [ ! -e "$(repo_path)/.ruby-version" ]; then
|
||||
rvm use --default > /dev/null
|
||||
echo "$(rvm current)" > .ruby-version
|
||||
fi
|
||||
|
||||
rvm use . >/dev/null
|
||||
}
|
||||
|
||||
function install_cocoapods() {
|
||||
local gem_command="sudo gem"
|
||||
local destination="system Ruby"
|
||||
|
||||
if program_exists "rvm"; then
|
||||
initialize_rvm
|
||||
|
||||
gem_command="gem"
|
||||
destination="RVM ($(rvm current))"
|
||||
fi
|
||||
|
||||
if ! program_exists "pod"; then
|
||||
$gem_command install cocoapods
|
||||
elif ! correct_pod_version_is_installed; then
|
||||
local version=$(required_pod_version)
|
||||
|
||||
cecho "@b@blue[[+ Updating to cocoapods $version]]"
|
||||
|
||||
$gem_command uninstall cocoapods --ignore-dependencies --silent
|
||||
$gem_command install cocoapods -v "$version"
|
||||
else
|
||||
cecho "+ cocoapods already installed to $destination... skipping."
|
||||
fi
|
||||
}
|
||||
|
||||
function dependency_setup() {
|
||||
cecho "@b@blue[[\$ $@]]"
|
||||
echo
|
||||
|
||||
cd "$(repo_path)"
|
||||
eval "$@"
|
||||
|
||||
echo
|
||||
echo " + done"
|
||||
echo
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
function load_color_support() {
|
||||
# Check if we're in a terminal
|
||||
if test -t 1; then
|
||||
local color_count=$(tput colors)
|
||||
|
||||
# Only load colors if our terminal supports them
|
||||
if test -n "$color_count" && test $color_count -ge 8; then
|
||||
_color_bold="$(tput bold)"
|
||||
_color_underline="$(tput sgr 0 1)"
|
||||
_color_red="$(tput setaf 1)"
|
||||
_color_green="$(tput setaf 2)"
|
||||
_color_yellow="$(tput setaf 3)"
|
||||
_color_blue="$(tput setaf 4)"
|
||||
_color_magenta="$(tput setaf 5)"
|
||||
_color_cyan="$(tput setaf 6)"
|
||||
_color_white="$(tput setaf 7)"
|
||||
_color_reset="$(tput sgr0)"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
load_color_support
|
||||
|
||||
function cecho() {
|
||||
local colorized=$(
|
||||
echo "$@" | sed -E \
|
||||
-e 's/((@(red|green|yellow|blue|magenta|cyan|white|reset|b|u))+)[[]{2}(.*)[]]{2}/\1\4@reset/g' \
|
||||
-e "s/@red/${_color_red}/g" \
|
||||
-e "s/@green/${_color_green}/g" \
|
||||
-e "s/@yellow/${_color_yellow}/g" \
|
||||
-e "s/@blue/${_color_blue}/g" \
|
||||
-e "s/@magenta/${_color_magenta}/g" \
|
||||
-e "s/@cyan/${_color_cyan}/g" \
|
||||
-e "s/@white/${_color_white}/g" \
|
||||
-e "s/@reset/${_color_reset}/g" \
|
||||
-e "s/@b/${_color_bold}/g" \
|
||||
-e "s/@u/${_color_underline}/g"
|
||||
)
|
||||
|
||||
echo "$colorized"
|
||||
}
|
||||
|
||||
function setup_header() {
|
||||
local header=$1
|
||||
|
||||
cecho "@b@green[[$header]]"
|
||||
echo
|
||||
}
|
||||
|
||||
function already_installed() {
|
||||
local package=$1
|
||||
|
||||
cecho "+ $package already installed... skipping"
|
||||
}
|
||||
|
||||
function setup_complete() {
|
||||
cecho "@b@blue[[Setup complete!]]
|
||||
===============
|
||||
|
||||
There are a few @b[[manual steps]] you might want to do:
|
||||
|
||||
1. Optionally set up Genymotion if you don't want to use Android Virtual Device:
|
||||
|
||||
@blue[[https://www.genymotion.com]]
|
||||
|
||||
2. Setup Android Development Environment + Simulator:
|
||||
|
||||
@blue[[https://facebook.github.io/react-native/docs/android-setup.html]]
|
||||
|
||||
3. Add your SSH public key to Github if it isn't already in there.
|
||||
"
|
||||
|
||||
echo
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
########
|
||||
# Install checks
|
||||
########
|
||||
|
||||
function program_exists() {
|
||||
local program=$1
|
||||
command -v "$program" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
########
|
||||
# Homebrew
|
||||
########
|
||||
|
||||
function install_homebrew_if_needed() {
|
||||
! is_macos && return 0
|
||||
|
||||
if test ! $(which brew); then
|
||||
cecho "@b@blue[[+ Installing homebrew]]"
|
||||
|
||||
ruby -e "$(curl -fsSL \
|
||||
https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
|
||||
brew update
|
||||
else
|
||||
already_installed "Homebrew"
|
||||
fi
|
||||
}
|
||||
|
||||
function brew_install() {
|
||||
local package=$1
|
||||
|
||||
if ! is_macos; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if brew list "$package" > /dev/null 2>&1; then
|
||||
already_installed "$package"
|
||||
else
|
||||
brew install $@
|
||||
fi
|
||||
}
|
||||
|
||||
function brew_cask_install() {
|
||||
local package=$1
|
||||
|
||||
if ! is_macos; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if brew cask list | grep -q "$package"; then
|
||||
already_installed "$package"
|
||||
else
|
||||
brew cask install $@
|
||||
fi
|
||||
}
|
||||
|
||||
function brew_tap() {
|
||||
local cask=$1
|
||||
|
||||
if ! is_macos; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! brew tap | grep -q "$cask"; then
|
||||
brew tap "$cask"
|
||||
fi
|
||||
}
|
||||
|
||||
###############
|
||||
# RVM
|
||||
###############
|
||||
|
||||
function load_rvm_if_available() {
|
||||
[ -f ~/.rvm/scripts/rvm ] && source ~/.rvm/scripts/rvm
|
||||
}
|
||||
|
||||
###############
|
||||
# NVM
|
||||
###############
|
||||
|
||||
function load_nvm_if_available() {
|
||||
[ -f ~/.nvm/nvm.sh ] && source ~/.nvm/nvm.sh
|
||||
}
|
||||
|
||||
function nvm_installed() {
|
||||
program_exists "nvm"
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
_current_dir=$(cd "${BASH_SOURCE%/*}" && pwd)
|
||||
_scripts_dir=$(cd "$_current_dir/../.." && pwd)
|
||||
_repo_dir=$(cd "$_scripts_dir/.." && pwd)
|
||||
|
||||
function scripts_path() {
|
||||
echo $_scripts_dir
|
||||
}
|
||||
|
||||
function repo_path() {
|
||||
echo $_repo_dir
|
||||
}
|
||||
|
||||
function source_lib() {
|
||||
local library_path=$1
|
||||
|
||||
source "$_current_dir/$library_path"
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
OS=$(uname -s)
|
||||
|
||||
function is_macos() {
|
||||
[[ "$OS" =~ Darwin ]]
|
||||
}
|
||||
|
||||
function exit_unless_mac() {
|
||||
if ! is_macos; then
|
||||
cecho "@red[[This install script currently supports Mac OS X only. To
|
||||
manually install, please visit the wiki for more information:]]
|
||||
|
||||
@blue[[https://wiki.status.im/Building_Status]]"
|
||||
|
||||
echo
|
||||
fi
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
########################################################################
|
||||
# This install script will setup your development dependencies on OS X.
|
||||
# Windows/Linux support is welcome!
|
||||
#
|
||||
# Usage: scripts/setup-osx.sh
|
||||
########################################################################
|
||||
|
||||
_current_dir=$(cd "${BASH_SOURCE%/*}" && pwd)
|
||||
source "$_current_dir/lib/setup-osx/path-support.sh"
|
||||
|
||||
source_lib "output.sh"
|
||||
source_lib "packages.sh"
|
||||
source_lib "platform.sh"
|
||||
source_lib "installers.sh"
|
||||
|
||||
exit_unless_mac
|
||||
|
||||
load_nvm_if_available
|
||||
load_rvm_if_available
|
||||
|
||||
####
|
||||
setup_header "Installing requirements..."
|
||||
|
||||
install_homebrew_if_needed
|
||||
brew_tap "caskroom/cask"
|
||||
|
||||
brew_cask_install "caskroom/versions/java8"
|
||||
brew_install leiningen
|
||||
|
||||
install_node
|
||||
brew_install watchman
|
||||
install_react_native_cli
|
||||
|
||||
brew_cask_install android-sdk
|
||||
brew_install maven
|
||||
|
||||
install_cocoapods
|
||||
|
||||
####
|
||||
echo && setup_header "Installing dependencies..."
|
||||
|
||||
dependency_setup lein deps
|
||||
dependency_setup npm install
|
||||
dependency_setup ./re-natal deps
|
||||
dependency_setup ./re-natal enable-source-maps
|
||||
|
||||
dependency_setup \
|
||||
"mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack"
|
||||
|
||||
dependency_setup "cd ios && pod install && cd .."
|
||||
|
||||
setup_complete
|
Loading…
Reference in New Issue