forked from PrincetonUniversity/PsyNeuLinkView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installation.sh
executable file
·181 lines (157 loc) · 4.69 KB
/
installation.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
# set -e
trap ctrl_c INT
ctrl_c() {
echo "### Stopping dev server ###"
if [ "$GEPPETTO_META" = true ]; then
mv package.json dev-package.json
mv package.backup package.json
fi
exit 0
}
INSTALL=false
UPDATE=false
GEPPETTO_META=false
GEPPETTO_META_BRANCH=""
function parse() {
for arg in "$@"; do # transform long options to short ones
shift
case "$arg" in
"--install") set -- "$@" "-i" ;;
"--update") set -- "$@" "-u" ;;
"--geppetto_meta") set -- "$@" "-m" ;;
*) set -- "$@" "$arg"
esac
done
while getopts "ium" optname
do
case "$optname" in
"i") INSTALL=true ;;
"u") UPDATE=true ;;
"m") GEPPETTO_META=true ;;
esac
done
shift "$((OPTIND-1))" # shift out all the already processed options
}
parse "$@"
echo "=== Install / Update script for PsyNeuLinkViewer and meta-diagram ==="
if [ "$GEPPETTO_META" = true ]; then
echo "=== Please give the branch name you would like to use for geppetto-meta (defaul development) ==="
printf "> "
read GEPPETTO_META_BRANCH
if [ "$GEPPETTO_META_BRANCH" = "" ]; then
GEPPETTO_META_BRANCH="development"
fi
fi
if [ "$INSTALL" = true ]; then
echo " ### re-installing all the packages"
npm -g install yalc
PSYVIEW=`pwd`
if [ -d '../meta-diagram' ]; then
cd ../meta-diagram;
yarn && yarn run build:dev && yalc push --changed
cd $PSYVIEW
else
cd ../
git clone https://github.com/metacell/meta-diagram
cd meta-diagram
yarn && yarn run build:dev && yalc push --changed
cd $PSYVIEW
fi
if [ "$GEPPETTO_META" = true ]; then
echo " ### re-installing geppetto-meta with yalc"
mv package.json package.backup
mv dev-package.json package.json
if [ -d '../geppetto-meta' ]; then
cd ../geppetto-meta/geppetto.js/geppetto-client/;
git checkout $GEPPETTO_META_BRANCH
yarn && yarn run build:dev && yarn publish:yalc
cd ../geppetto-ui;
yarn && yarn run build:dev && yarn publish:yalc;
cd ../geppetto-core;
yarn && yarn run build:dev && yarn publish:yalc;
cd $PSYVIEW
else
cd ../
git clone https://github.com/MetaCell/geppetto-meta
cd geppetto-meta/geppetto.js/geppetto-client/
git checkout $GEPPETTO_META_BRANCH
yarn && yarn run build:dev && yarn publish:yalc
cd ../geppetto-ui;
yarn && yarn run build:dev && yarn publish:yalc;
cd ../geppetto-core;
yarn && yarn run build:dev && yarn publish:yalc;
cd $PSYVIEW
fi
yalc add @metacell/geppetto-meta-client
yalc add @metacell/geppetto-meta-ui
yalc add @metacell/geppetto-meta-core
fi
yalc add @metacell/meta-diagram
rm -rf node_modules/
yarn
# yarn run start
echo "### Installation completed ###"
elif [ "$UPDATE" = true ]; then
echo " ### Updating meta-diagram"
# yarn remove @metacell/meta-diagram
rm -rf yalc.lock
PSYVIEW=`pwd`
if [ -d '../meta-diagram' ]; then
cd ../meta-diagram;
yarn && yarn run build:dev && yalc push --changed
cd $PSYVIEW
else
cd ../
git clone https://github.com/metacell/meta-diagram
cd meta-diagram
yarn && yarn run build:dev && yalc push --changed
cd $PSYVIEW
fi
yalc add @metacell/meta-diagram
yarn upgrade @metacell/meta-diagram
if [ "$GEPPETTO_META" = true ]; then
mv package.json package.backup
mv dev-package.json package.json
if [ -d '../geppetto-meta' ]; then
cd ../geppetto-meta/geppetto.js/geppetto-client/;
git checkout $GEPPETTO_META_BRANCH
yarn && yarn run build:dev && yarn publish:yalc
cd ../geppetto-ui;
yarn && yarn run build:dev && yarn publish:yalc;
cd ../geppetto-core;
yarn && yarn run build:dev && yarn publish:yalc;
cd $PSYVIEW
else
cd ../
git clone https://github.com/MetaCell/geppetto-meta
cd geppetto-meta/geppetto.js/geppetto-client/
git checkout $GEPPETTO_META_BRANCH
yarn && yarn run build:dev && yarn publish:yalc
cd ../geppetto-ui;
yarn && yarn run build:dev && yarn publish:yalc;
cd ../geppetto-core;
yarn && yarn run build:dev && yarn publish:yalc;
cd $PSYVIEW
fi
yalc add @metacell/geppetto-meta-client
yarn upgrade @metacell/geppetto-meta-client
yalc add @metacell/geppetto-meta-ui
yarn upgrade @metacell/geppetto-meta-ui
yalc add @metacell/geppetto-meta-core
yarn upgrade @metacell/geppetto-meta-core
fi
test=$(grep 'FAST_REFRESH=' .env | sed "s/FAST_REFRESH=//")
sed '/FAST_REFRESH/d' .env > temp_env
mv temp_env .env
if [[ "$test" == 'false' ]]; then
echo -e '\nFAST_REFRESH=true' >> .env
else
echo -e '\nFAST_REFRESH=false' >> .env
fi
# yarn run start
echo "### Installation completed ###"
else
echo " - The script can be run in update (-u / --update) or install (-i / --install) mode."
echo " - please use the option desidered to run the script again."
fi