-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
115 lines (87 loc) · 3.51 KB
/
Makefile
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
SHELL=/bin/bash
.DEFAULT_GOAL := help
# -------------------------------
# Common targets for Dev projects
# -------------------------------
#
# Edit these targets so they work as expected on the current project.
#
# Remember there may be other tools which use these targets, so if a target is not suitable for
# the current project, then keep the target and simply make it do nothing.
help: ## This help dialog.
help: help-display
nuke: ## Wipes database
nuke: django-drop-db
reset: ## Resets your local environment. Useful after switching branches, etc.
reset: venv-check venv-wipe pip-install django-migrate
nuke-reset: ## Nuke & Reset & Load fixtures
nuke-reset: nuke reset django-load-fixtures
clear: ## Like reset but without the wiping of the installs.
clear: django-migrate
messages: ## Creates locale translations for apps
messages: django-make-messages
test: ## Run tests.
test: django-test
test.wip: ## Run work-in-progress tests. Useful when working on new tests
test.wip: django-test-only
shell: ## Runs a python shell
shell:
python manage.py shell
entity-stats: ## Run Entity Stats command
entity-stats:
python manage.py stats ${ARGS}
# ---------------
# Utility targets
# ---------------
#
# Targets which are used by the common targets. You likely want to customise these per project,
# to ensure they're pointing at the correct directories, etc.
# Virtual Environments
venv-check:
ifndef VIRTUAL_ENV
$(error Must be in a virtualenv)
endif
venv-wipe: venv-check
if ! pip list --format=freeze | grep -v "^appdirs=\|^distribute=\|^packaging=\|^pip=\|^pyparsing=\|^setuptools=\|^six=\|^wheel=" | xargs pip uninstall -y; then \
echo "Nothing to remove"; \
fi
# Pip commands
pip-install: venv-check
pip install -r requirements/local.txt
# Django commands
django-test:
python manage.py test --settings=ia2.settings.test --noinput --exclude-tag="skip" --pattern="test*.py" --verbosity 1
django-test-only:
python manage.py test --settings=ia2.settings.test --noinput --tag="wip" --pattern="test*.py" --verbosity 1
django-createsuperuser: DJANGO_DEV_USERNAME ?= admin
django-createsuperuser: DJANGO_DEV_MAIL_DOMAIN ?= @camba.coop
django-createsuperuser: DJANGO_DEV_PASSWORD ?= admin
django-createsuperuser:
@echo "import sys; from django.contrib.auth import get_user_model; obj = get_user_model().objects.create_superuser('$(DJANGO_DEV_USERNAME)', '$(DJANGO_DEV_USERNAME)$(DJANGO_DEV_MAIL_DOMAIN)', '$(DJANGO_DEV_PASSWORD)');" | python manage.py shell >> /dev/null
@echo
@echo "Superuser details: "
@echo
@echo " $(DJANGO_DEV_USERNAME)$(DJANGO_DEV_MAIL_DOMAIN):$(DJANGO_DEV_PASSWORD)"
@echo
django-make-messages:
python manage.py makemessages
django-migrate:
./manage.py migrate
./manage.py migrate --database data_db
django-drop-db:
./manage.py sqlflush | ./manage.py dbshell
./manage.py sqlflush --database data_db | ./manage.py dbshell --database data_db
django-load-fixtures:
for i in $$(find . -regextype posix-egrep -regex ".+\.json$$" -path '*/fixtures/*' -not -path './apps/data/*' -printf '%f\n' | sort -t '\0' -n); do \
echo "Loading $$i" ;\
find -name $$i -exec python manage.py loaddata {} \; ;\
done
for i in $$(find . -regextype posix-egrep -regex ".+\.json$$" -path '*/data/fixtures/*' -printf '%f\n' | sort -t '\0' -n); do \
echo "Loading $$i" ;\
find -name $$i -exec python manage.py loaddata --database data_db {} \; ;\
done
django-compile-messages:
./manage.py compilemessages
# Help
help-display:
@awk '/^[[:alnum:]-]*: ##/ { split($$0, x, "##"); printf "%20s%s\n", x[1], x[2]; }' $(MAKEFILE_LIST)