-
Notifications
You must be signed in to change notification settings - Fork 35
/
setup
executable file
·86 lines (73 loc) · 2.81 KB
/
setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
source $(dirname $0)/logging.sh
NVM_VERSION="v0.34.0"
append_once() {
if grep -Fxq "$1" "$2"; then
status "Already updated."
else
echo "$1" >> "$2" || warn "Failed to update $2"
fi
}
# Detect Platform
case $(uname | tr '[:upper:]' '[:lower:]') in
linux*)
OS_NAME=linux
;;
darwin*)
OS_NAME=osx
;;
msys*)
OS_NAME=windows
# TODO(alxr) investigate windows compatibility
fail "Windows is currently unsupported. Please follow install instructions in the README."
;;
*)
OS_NAME=notset
fail "Can't detect host OS"
;;
esac
status "0. Pre-requisites"
if [ "$OS_NAME" = "linux" ]; then
status "0.1 Installing pre-requisites for Bazel and node modules"
sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python3 make python openjdk-8-jdk
elif [ "$OS_NAME" = "osx" ]; then
status "0.1. Checking for Command Line Tools"
xcode-select --version || xcode-select --install || fail "Unable to install Command Line Tools"
status "0.2. Updating SSL Certificates for Python3.6"
/Applications/Python\ 3.6/Install\ Certificates.command
fi
status "1. Install nvm"
curl -L -s -o- "https://raw.githubusercontent.com/creationix/nvm/$NVM_VERSION/install.sh" | sh || \
fail "Failed to download nvm version $NVM_VERSION."
status "1.1 ensure nvm is in your current process"
# shellcheck disable=SC1090
. $NVM_DIR/nvm.sh || fail "Nvm load failed"
status "2. Install node"
cd $ROOT && nvm install && nvm use || fail 'Failed to install target node version.'
cd -
status "3. Update npm to latest version"
nvm install-latest-npm || fail 'Failed to update npm to latest version.'
status "4. Install dependencies"
(cd $ROOT && npm install && npm --prefix=cloud install) || fail 'Failed to install dependencies.'
# chokidar is useful when developing, but we don't want to require it for all installations
status "4.1. Install useful optional dependencies"
(cd $ROOT && npm install --no-save chokidar) || fail 'Failed to install optional dependencies.'
status "5. Install ktlint"
(mkdir -p $HOME/bin && cd $HOME/bin && curl -L -s -O https://github.com/pinterest/ktlint/releases/download/0.35.0/ktlint && cd -) || fail 'Failed to install ktlint'
chmod a+x $HOME/bin/ktlint
append_once 'export PATH="$HOME/bin:$PATH"' $HOME/.bashrc
echo -e "$GRN$BLD\n\nSETUP COMPLETE\n$END"
echo -e "node --version"
node --version
echo -e "npm --version"
npm --version
echo -e "ktlint --version"
ktlint --version
echo -e "\nNext, try the following:\n"
echo -e "- Setup git hooks: $CMD\`git config core.hooksPath tools/hooks\`$END"
echo -e "- Serve the project: $CMD\`./tools/sigh devServer\`$END"
echo -e "- Run tests:"
echo -e " - $CMD\`./tools/sigh test\`$END"
echo -e " - $CMD\`./tools/local-presubmit\`$END"
echo -e "\nPlease source the updated environment variables:"
echo -e " - $CMD\`source ~/.profile\`$END"