-
Notifications
You must be signed in to change notification settings - Fork 9
/
manage.sh
executable file
·88 lines (85 loc) · 2.43 KB
/
manage.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
#!/usr/bin/env bash
set -e
wrapper=(env)
cli=(python run.py huskar_api.cli:main)
if [ -n "$(command -v honcho)" ]; then
wrapper=(honcho run)
cli=(honcho run python run.py huskar_api.cli:main)
fi
clear_py_cache() {
find . -name '*.pyc' -delete
find . -name '*.pyo' -delete
find . -name __pycache__ -delete
}
case $1 in
bash)
exec /bin/bash
;;
alembic)
exec "${wrapper[@]}" alembic --config=database/migration/alembic.ini "${@:2}"
;;
initdb)
exec "${wrapper[@]}" python run.py huskar_api.scripts.db:initdb
;;
dumpdb)
exec "${wrapper[@]}" python run.py huskar_api.scripts.db:dumpdb
;;
initadmin)
exec "${wrapper[@]}" python run.py huskar_api.cli:main initadmin
;;
testall)
clear_py_cache
"$0" lint
"pytest" tests "${@:2}"
"pytest" coverage html
;;
testonly)
clear_py_cache
exec pytest "${@:2}"
;;
test)
clear_py_cache
"$0" lint
exec "${wrapper[@]}" pytest "${@:2}"
;;
lint)
if [ -n "$(command -v misspell)" ]; then
find huskar_api docs tools tests \
\( \
-name '*.rst' -or \
-name '*.py' -or \
-name '*.yml' \
\) \
-exec misspell -error {} +
else
echo "misspell is not installed." >&2
fi
if [ -n "$(command -v shellcheck)" ]; then
find . -type f -name '*.sh' -exec shellcheck {} +
else
echo "shellcheck is not installed." >&2
fi
flake8 --exclude=docs,.venv,database/migration/versions .
;;
make)
exec "${@}"
;;
docs)
exec make \
'SPHINXBUILD=sphinx-autobuild' \
'SPHINXOPTS=-i *.swp -s 3' \
-C docs html
;;
""|help|--help|-h)
"${cli[@]}" -- --help
printf '\n'
printf 'extra commands:\n'
printf ' alembic\t\tMigrates the database schema.\n'
printf ' initdb\t\tDrops and creates all database tables.\n'
printf ' dumpdb\t\tDumps the schema and alembic version of database.\n'
printf ' testall\t\tRuns testing for all modules.\n'
printf ' test\t\tRuns testing for specified arguments.\n'
printf ' docs\t\tBuilds docs with auto-reload support.\n'
;;
*) exec "$@"
esac