-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_and_run.sh
executable file
·191 lines (171 loc) · 3.74 KB
/
build_and_run.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
182
183
184
185
186
187
188
189
190
191
#!/bin/bash
ExportEnvironmentVars()
{
export FLASK_APP=pydash.py
export FLASK_ENV=development
export FMD_CONFIG_PATH=fmd_config.cfg
}
PydashPrint()
{
echo -e '\e[1m\e[92m[PyDash.io]: \e[0m\e[1m' "$1" '\e[0m'
}
BuildFrontend()
{
PydashPrint "building frontend..."
cd pydash-front
yarn
yarn build
cd ..
PydashPrint "Done!"
}
BuildBackend()
{
PydashPrint "building backend..."
cd pydash
mkdir -p logs
pipenv install
cd ..
PydashPrint "Done!"
}
SeedBackend()
{
PydashPrint "seeding backend..."
cd pydash
mkdir -p logs
ExportEnvironmentVars
#rm -f ./zeo_filestorage.fs*
pipenv run flask seed
cd ..
PydashPrint "Done!"
}
RunDatabase()
{
PydashPrint "Starting database in background..."
cd pydash
pipenv run "./start_database.sh" &
cd ..
PydashPrint "Done!"
}
RunDatabaseForeground()
{
PydashPrint "Starting database in foreground..."
cd pydash
pipenv run "./start_database.sh"
cd ..
PydashPrint "Done!"
}
RunFlask()
{
PydashPrint "Starting flask webservice. Close with Ctrl+C"
cd pydash
ExportEnvironmentVars
pipenv run flask run --no-reload --host=0.0.0.0
cd ..
}
RunFlaskConsole()
{
PydashPrint "Starting flask webservice as shell."
cd pydash
ExportEnvironmentVars
pipenv run flask shell
cd ..
}
RunFrontend()
{
cd pydash-front
yarn start
cd ..
PydashPrint "Done!"
}
RunTests()
{
cd pydash
ExportEnvironmentVars
pipenv run pytest
cd ..
PydashPrint "Done!"
}
BuildDocumentation()
{
RunDatabase
PydashPrint "Starting Backend Documentation generation"
cd pydash/sphinx_docs
pipenv run make latexpdf
cd ../..
cp ./pydash/sphinx_docs/_build/latex/PyDash.pdf ./docs/PyDashDocumentation.pdf
PydashPrint "Resulting Backend Documentation PDF can be found in ./docs/PyDashDocumentation.pdf"
killall runzeo
PydashPrint "Starting Frontend Documentation generation"
cd pydash-front
yarn doc
sed -i.bak 's/-----/\n\n/g' DOCUMENTATION.md
sed -i.bak 's/1. //g' DOCUMENTATION.md
sed -i.bak 's/^Components//g' DOCUMENTATION.md
sed -i '1i # PyDash Front-end Components Documentation \n\n\n' DOCUMENTATION.md
pandoc DOCUMENTATION.md -o PyDashFrontDocumentation.pdf
cd ..
cp ./pydash-front/PyDashFrontDocumentation.pdf ./docs/PyDashFrontDocumentation.pdf
PydashPrint "Resulting Frontend Documentation PDF can be found in ./docs/PyDashFrontDocumentation.pdf"
PydashPrint "Done!"
PydashPrint "Documentation files in ./docs updated!"
}
RunProduction()
{
PydashPrint "Starting Production Server..."
export FLASK_DEBUG=0;
export FLASK_ENV=production;
export ENV=production;
RunDatabase
RunFlask
}
if [ $# -gt 0 ];
then
for i in "$@";
do
if [ $i == "seed" ];
then
SeedBackend
fi
if [ $i == "build" ];
then
BuildFrontend
BuildBackend
fi
if [ $i == "database" ];
then
RunDatabaseForeground
fi
if [ $i == "databasebg" ];
then
RunDatabase
fi
if [ $i == "production" ];
then
RunProduction
fi
if [ $i == "server" ];
then
xdg-open "http://localhost:5000" &
RunFlask
fi
if [ $i == "frontend" ];
then
RunFrontend
fi
if [ $i == "test" ];
then
RunTests
fi
if [ $i == "shell" ];
then
RunFlaskConsole
fi
if [ $i == "documentation" ];
then
BuildDocumentation
fi
done;
PydashPrint "Done! Goodbye :-)"
else
./$0 build databasebg server
fi