-
Notifications
You must be signed in to change notification settings - Fork 5
/
helpers.sh
executable file
·115 lines (87 loc) · 2.96 KB
/
helpers.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
#!/bin/bash
function limbus_create_kryten() {
echo ">>>> Creating Kryten"
docker-compose run web sh -c "flask cmd_setup create-kryten"
}
# This function allows the user to install a python package via
# the pypi repository.
function limbus_pip_install() {
echo "Enter the pip package you want to install:"
read package
echo " >>> Now attempting to install $package:"
docker-compose run web sh -c "pip3 install $package"
echo "Do you want to save the changes to requirements.txt? (Y/N)"
read answer
if [ ${answer^^} == "Y" ]; then
echo " >>> Writing to requirements.txt:"
docker-compose run web sh -c "pip3 freeze > requirements.txt"
fi
}
function limbus_clear_binary_files() {
echo " >>> Cleaning binary files"
docker-compose run web sh -c "find . -type f -name '*.pyc' -exec rm {} +"
}
function limbus_yarn_install() {
echo ">>> Running yarn install:"
docker-compose run web sh -c "yarn install"
}
function limbus_db_nuke() {
echo "WARNING: THIS WILL DESTROY THE DATABASE, INCLUDING VERSIONS"
echo "Are you sure you want todo this? (Y/N)"
read answer
if [ ${answer^^} == "Y" ]; then
docker-compose run web sh -c "alembic stamp base"
docker-compose run web sh -c "rm migrations/versions/*"
docker-compose down -v
fi
}
function limbus_db_create() {
echo "CREATING DATABASE"
if [ ! -d ./services/web/migrations/versions ]; then
mkdir -p ./services/web/migrations/versions
fi
docker-compose run web sh -c "alembic revision --autogenerate -m 'Generating database'; alembic upgrade head"
}
function limbus_db_upgrade() {
echo "Preparing datbase update"
# A lil bit of fun
echo "alembic commit -m"
read commit
docker-compose run web sh -c "alembic revision --autogenerate -m '$commit'"
docker-compose run web sh -c "alembic upgrade head"
}
function limbus_test_entrypoint() {
docker-compose build
limbus_yarn_install
docker-compose run --service-ports web sh -c "nose2 -v"
}
function limbus_create_test_user() {
docker-compose run web sh -c "flask cmd_setup create-testuser"
}
function limbus_setup_dev() {
echo "WELCOME TO LIMBUS"
echo "================="
echo "Do you want to build from the Dockerfile? (Y/N)"
read answer_one
if [ ${answer_one^^} == "Y" ]; then
echo ">>>> Building from Dockerfile"
docker-compose build
fi
echo "Do you want to install yarn dependencies? (Y/N)"
read answer_two
if [ ${answer_two^^} == "Y" ]; then
limbus_yarn_install
fi
echo "Do you want to set up the database? (Y/N)"
read answer_three
if [ ${answer_three^^} == "Y" ]; then
limbus_db_nuke
limbus_db_create
fi
echo "Creating Kryten"
limbus_create_kryten
echo "Creating dev user"
echo "You should now be able to start up your dev environment by running:"
echo "$ docker-compose up"
echo "Happy hacking :)"
}