-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_angular.sh
More file actions
executable file
·58 lines (50 loc) · 1.61 KB
/
build_angular.sh
File metadata and controls
executable file
·58 lines (50 loc) · 1.61 KB
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
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
# Check if the initial setups need to happen
#"${SCRIPT_DIR}"/install.sh
#secret_key=$(cat ${SCRIPT_DIR}/BackEnd/bmrbdep/configuration.json | grep \"secret_key\" | cut -f4 -d\")
#if [[ ${secret_key} == "CHANGE_ME" ]]; then
# echo 'Please change the secret key in the configuration first!'
# exit 1
#fi
user_id=`id -u`
if [[ $user_id != '17473' ]]; then
echo "Must run this as bmrbsvc user (or apache on production)..."
exit 1
fi
host=`hostname`
echo "Getting newest schema."
(
source "${SCRIPT_DIR}"/BackEnd/venv/bin/activate
if ! "${SCRIPT_DIR}"/BackEnd/schema/schema_loader.py; then
echo "Schema loader failed, quitting."
exit 2
fi
)
echo "Compiling angular."
source "${SCRIPT_DIR}"/FrontEnd/node_env/bin/activate
cd "${SCRIPT_DIR}"/FrontEnd || exit 2
if [[ $1 == "production" || $host == "bmrb-prod.nmrbox.org" ]]; then
if ! npm run build.prod; then
echo "Angular build failed, quitting."
exit 3
fi
else
if ! npm run ng build --configuration=devprod; then
echo "Angular build failed, quitting."
exit 3
fi
fi
cd "${SCRIPT_DIR}"
echo "Writing out git version to file..."
# https://gist.github.com/dciccale/5560837
function parse_git_dirty() {
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [[ $? -eq 1 ]] && echo "*"
}
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
function parse_git_hash() {
git rev-parse --short HEAD 2> /dev/null | sed "s/\(.*\)/@\1/"
}
echo "$(parse_git_branch)$(parse_git_hash)" > "${SCRIPT_DIR}"/version.txt