-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.sh
executable file
·96 lines (81 loc) · 2.65 KB
/
setup.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
# Setup geneaprove for end-users and developers
DEVELOPER=${DEVELOPER:-no}
VENV=python_env
#########################
# Front-end development #
#########################
npm install
########################
# Back-end development #
########################
if [ ! -d python_env ]; then
python3 -m venv python_env
fi
${VENV}/bin/python -c \
'import sys; v = sys.version_info; assert v.major==3 and v.minor>=7' \
2>/dev/null
if [ $? != 0 ]; then
echo "Incorrect python version in python_env/: needs at least 3.7"
echo "Remove python_env/ and rerun $0"
exit 1
fi
${VENV}/bin/pip install \
appdirs==1.4 \
django==3.0.2 \
django_extensions==2.2.6 \
django-cors-headers==3.2.1 \
grandalf==0.6 \
pillow==6.1 \
psycopg2-binary==2.8 \
django-stubs[compatible-mypy]
if [ "$DEVELOPER" != "no" ]; then
# Some useful tools for developers.
${VENV}/bin/pip install \
autopep8 \
cprofilev \
pep8 \
pyinstaller \
pylint \
pylint-django
fi
# The actual layout of the sources was created with:
# django-admin startproject backend
# cd backend
# ./manage.py startapp geneaprove
###################
# Create database #
###################
MANAGE_PY="${VENV}/bin/python backend/manage.py"
(
dir=`${MANAGE_PY} showconf | grep dir= | cut -d= -f2`
mkdir -p "backend/$dir"
${MANAGE_PY} makemigrations
${MANAGE_PY} migrate
)
#########################################
# Generate the sources and start server #
#########################################
if [ "$DEVELOPER" = "no" ]; then
# Non-developers will use a static version of JS and CSS.
# They should connect directly to the server on the :8002 port
npm run build # create static version of site
echo "---------------------------------------------------------"
echo "Geneaprove: next time, you can simply run 'sh ./server.sh'"
echo "Connect to localhost:8002"
echo "---------------------------------------------------------"
sh ./server.sh # run the server
else
# Developers should connect to the node server, which will proxy to the
# django server as needed. This means javascript files will be recompiled
# as they are modified.
# They should connect to localhost:3000, which will be opened automatically
# by npm.
# (
# rm -rf build/
# # run both in parallel. When the server is killed with ctrl-c, bring
# # client to the foreground so that it can also be killed with ctrl-c
# npm run start &
# sh ./server.sh && fg
# )
echo
fi