This repository has been archived by the owner on Dec 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathbootstrap.sh
executable file
·103 lines (86 loc) · 2.59 KB
/
bootstrap.sh
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
#
# Copyright (c) 2015-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
#
set -e
export PATH=$PATH:/usr/local/bin
BOLD="\033[1m"
if [[ ! -f Scripts/bootstrap.sh ]]; then
echo "Run this script from the root of repository"
exit 1
fi
function assert_has_carthage() {
if ! command -v carthage > /dev/null; then
echo "Please make sure that you have Carthage installed (https://github.com/Carthage/Carthage)"
echo "Note: We are expecting that carthage installed in /usr/local/bin/"
exit 1;
fi
}
function assert_has_npm() {
if ! command -v npm > /dev/null; then
echo "Please make sure that you have npm installed (https://www.npmjs.com)"
echo "Note: We are expecting that npm installed in /usr/local/bin/"
exit 1
fi
}
function print_usage() {
echo "Usage:"
echo $'\t -i Build Inspector bundle'
echo $'\t -d Fetch & build dependencies'
echo $'\t -D Fetch & build dependencies using SSH for downloading GitHub repositories'
echo $'\t -h print this help'
}
function fetch_and_build_dependencies() {
echo -e "${BOLD}Fetching dependencies"
assert_has_carthage
if ! cmp -s Cartfile.resolved Carthage/Cartfile.resolved; then
carthage bootstrap $USE_SSH
cp Cartfile.resolved Carthage
fi
}
function build_inspector() {
echo -e "${BOLD}Building Inspector"
assert_has_npm
CURRENT_DIR=$(pwd)
RESOURCE_BUNDLE_DIR="$CURRENT_DIR/Resources/WebDriverAgent.bundle"
INSPECTOR_DIR="$CURRENT_DIR/Inspector"
echo "Creating bundle directory..."
if [[ -e "$RESOURCE_BUNDLE_DIR" ]]; then
rm -R "$RESOURCE_BUNDLE_DIR";
fi
mkdir -p "$RESOURCE_BUNDLE_DIR"
cd "$INSPECTOR_DIR"
echo "Fetching Inspector dependencies..."
npm install
echo "Validating Inspector"
"$INSPECTOR_DIR"/node_modules/.bin/eslint js/*
echo "Building Inspector..."
BUILD_OUTPUT_DIR="$RESOURCE_BUNDLE_DIR" npm run build
cd "$CURRENT_DIR"
cp "$INSPECTOR_DIR/index.html" "$RESOURCE_BUNDLE_DIR"
echo "Done"
}
while getopts " i d D h " option; do
case "$option" in
i ) BUILD_INSPECTOR=1;;
d ) FETCH_DEPS=1;;
D ) FETCH_DEPS=1; USE_SSH="--use-ssh";;
h ) print_usage; exit 1;;
*) exit 1 ;;
esac
done
if [[ -n ${FETCH_DEPS+x} ]]; then
fetch_and_build_dependencies
fi
if [[ -n ${BUILD_INSPECTOR+x} ]]; then
build_inspector
fi
if [[ -z ${FETCH_DEPS+x} && -z ${BUILD_INSPECTOR+x} ]]; then
fetch_and_build_dependencies
build_inspector
fi