-
Notifications
You must be signed in to change notification settings - Fork 42
/
algobsetup
75 lines (64 loc) · 1.63 KB
/
algobsetup
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
#!/usr/bin/env bash
# The scripts automates setup from source
# It clones the algo-builder repository and uses `yarn link` to link
# all workspace packages (algob, runtime ...)
BASEDIR=$(pwd)
ALGO_BUILDER_DIR="algo-builder"
declare -a PACKAGES=("algob" "runtime" "web")
declare -a LINKED_PACKAGES=("@algo-builder/algob" "@algo-builder/runtime" "@algo-builder/web")
function err () {
printf "$1\n"
exit 1
}
function check_algob_dir(){
if [[ -d $1 ]]
then
echo "$1 already exists in this project, pulling the latest version"
cd $ALGO_BUILDER_DIR
git pull
else
git clone https://github.com/scale-it/algo-builder.git
if [ $? -ne 0 ]; then
err "Error while cloning algo-builder"
fi
cd $ALGO_BUILDER_DIR
fi
}
function link(){
if [ -d "$1" ]
then
cd $1
yarn link
else
cd $BASEDIR
yarn link $1;
fi
}
function link_all(){
for (( i=0; i<${#PACKAGES[@]}; i++ ));
do
link "$BASEDIR/$ALGO_BUILDER_DIR/packages/${PACKAGES[$i]}"
done
cd $BASEDIR
for (( i=0; i<${#LINKED_PACKAGES[@]}; i++ ));
do
link ${LINKED_PACKAGES[$i]}
done
}
check_algob_dir $ALGO_BUILDER_DIR
yarn
yarn build
rm -rf ~/.config/yarn/link/@algo-builder
while true; do
read -p "Do you wish to link also ${PACKAGES[1]} and ${PACKAGES[2]}? [yes/no] " yn
case $yn in
[Yy]* )
link_all
break;;
[Nn]* )
link "$BASEDIR/$ALGO_BUILDER_DIR/packages/algob";
link ${LINKED_PACKAGES[0]}
exit;;
* ) echo "Please answer yes or no.";;
esac
done