forked from GMOD/Apollo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apollo
executable file
·218 lines (198 loc) · 6.88 KB
/
apollo
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/bin/bash
function usage(){
echo "";
echo "Usage: apollo <command>";
echo "";
echo "Production Commands:";
echo "";
echo "deploy: Builds Unoptimized war file (no processing of javascript) into the target directory.";
echo "release: Builds in release mode (minimized javascript). (beta)";
echo "run-local <port>: Runs from current directory, but not in dev-mode. ";
echo "help: This message.";
echo "";
echo "Development Commands:";
echo "devmode: Runs from current directory debug mode (non-minimized javascript).";
echo "run-app <port>: Runs from current directory, but does not compile annotator panel (you have to run run-local once first).";
echo "test: Runs test-suite.";
echo "debug: Runs from current directory in debug mode (non-minimized javascript).";
echo "watchman: Creates watchman daemon to autocopy plugin files (non-minimized javascript).";
echo "compile: Compiled the build.";
echo "clean: Removes class files.";
echo "clean-all: Removes class files and jbrowse files.";
echo "create-rest-doc: Recreates REST documentation.";
};
grails_executable=""
gradle_executable=""
if [[ $# == 0 || $1 == help || $1 == --help ]]; then
usage
exit 1;
fi
function deploy_message(){
echo "***************************************"
echo "NOTE: Please set the memory for your servlet container (tomcat, jetty, etc.) or Apollo may not start correctly: http://genomearchitect.readthedocs.io/en/latest/Troubleshooting/#tomcat-memory"
echo "***************************************"
}
function check_rest_api(){
if [ ! -f web-app/js/restapidoc/restapidoc.json ]; then
$grails_executable rest-api-doc
fi
}
function check_node(){
node_executable=$(which node)
if ! [ -x "$node_executable" ] ; then
nodejs_executable=$(which nodejs)
if ! [ -x "$nodejs_executable" ] ; then
echo "You must install 'Node JS' to do a release of Apollo."
exit 1 ;
else
echo "Creating an alias 'node' for 'nodejs'"
alias node="nodejs"
fi
fi
npm_executable=$(which npm)
}
function check_bower(){
bower_executable=$(which bower)
if ! [ -x "$bower_executable" ] ; then
$npm_executable install -g bower
if ! [ -x "$bower_executable" ] ; then
echo "You must install 'Bower' to do a release of Apollo. sudo ${npm_executable} install -g bower"
exit 1 ;
fi
fi
}
function check_perldependencies(){
perl -e 'use Text::Markdown'
if [ $? != 0 ] ; then
echo "Perl package 'Text::Markdown' is required in order to do a release of Apollo."
exit 1 ;
fi
perl -e 'use DateTime'
if [ $? != 0 ] ; then
echo "Perl package 'DateTime' is required in order to do a release of Apollo."
exit 1 ;
fi
}
function check_configs_for_release(){
check_perldependencies
}
function check_configs(){
grails_executable=$(which grails)
gradle_executable=$(which gradle)
git_executable=$(which git)
if ! [ -x "$grails_executable" ] ; then
if [ -f 'grailsw' ]; then
echo "Grails not found using grailsw";
grails_executable="./grailsw"
else
echo "You must install 'grails' to install Apollo."
exit 1 ;
fi
fi
if ! [ -x "$gradle_executable" ] ; then
if [ -f 'gradlew' ]; then
echo "Gradle not found using gradlew";
gradle_executable="./gradlew"
else
echo "You must install 'gradle' to install Apollo."
exit 1 ;
fi
fi
if ! [ -x "$git_executable" ] ; then
echo "You must install 'git' to install Apollo."
exit 1 ;
fi
check_node
check_bower
}
function copy_configs(){
rm -f src/java/apollo-config.groovy
cp apollo-config.groovy src/java/apollo-config.groovy
}
function clean_code(){
$grails_executable clean
$gradle_executable cleanAll
}
function clean_all(){
check_configs
rm -rf bin
rm -rf jbrowse-download
rm -rf JBrowse-dev
rm -rf web-app/jbrowse
rm -f *.zip
clean_code
}
if [[ $1 == "devmode" ]];then
check_configs
$gradle_executable handleJBrowse copyResourcesDev devmode &
$grails_executable -reloading run-app
elif [[ $1 == "run-local" ]];then
check_configs
if [[ $# == 2 ]]; then
$gradle_executable handleJBrowse copy-resources copyResourcesDev gwtc && $grails_executable -Dserver.port=$2 run-app
else
$gradle_executable handleJBrowse copy-resources copyResourcesDev gwtc && $grails_executable run-app
fi
elif [[ $1 == "watchman" ]]; then
watchman_executable=$(which watchman)
if ! [ -x "$watchman_executable" ] ; then
echo "Watchman not found. Install watchman to automatically update the client side plugins for apollo development modes"
fi
if [ -x "$watchman_executable" ]; then $watchman_executable -- trigger $(PWD) jsfilescopy 'client/apollo/**/*.js' -- scripts/copy_client.sh; fi;
elif [[ $1 == "run-app" ]];then
check_configs
if [[ $# == 2 ]]; then
$gradle_executable handleJBrowse copyResourcesDev && $grails_executable -Dserver.port=$2 run-app
else
$gradle_executable handleJBrowse copyResourcesDev && $grails_executable run-app
fi
elif [[ $1 == "debug" ]];then
# TODO: feel like there is a better way to do this
OLD_MAVEN_OPTS=$MAVEN_OPTS
check_configs
copy_configs
clean_all
export MAVEN_OPTS=-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n
$gradle_executable handleJBrowse devmode &
$grails_executable -reloading debug
export MAVEN_OPTS=$OLD_MAVEN_OPTS
unset OLD_MAVEN_OPTS
elif [[ $1 == "test" ]];then
check_configs
copy_configs
$gradle_executable handleJBrowse
check_rest_api
$grails_executable test-app
elif [[ $1 == "test-unit" ]];then
check_configs
copy_configs
$grails_executable handleJBrowse test-app :unit
elif [[ $1 == "deploy" ]];then
check_configs
copy_configs
$gradle_executable handleJBrowse copy-resources gwtc && $grails_executable war
deploy_message
elif [[ $1 == "release" ]];then
check_configs
check_configs_for_release
copy_configs
clean_all
$gradle_executable handleJBrowse release gwtc && $grails_executable war
deploy_message
elif [[ $1 == "compile" ]];then
check_configs
$gradle_executable gwtc && $grails_executable compile
elif [[ $1 == "create-rest-doc" ]];then
check_configs
$grails_executable compile && $grails_executable rest-api-doc && cp restapidoc.json web-app/js/restapidoc/
elif [[ $1 == "clean-all" ]];then
clean_all
elif [[ $1 == "clean" ]];then
check_configs
$gradle_executable clean && $grails_executable clean
elif [[ $1 == "jbrowse" ]];then
check_configs
$gradle_executable handleJBrowse
else
usage
fi