This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
131 lines (113 loc) · 3.21 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
HERE := $(shell basename $(CURDIR))
PROJECT := "rock_me"
PYTHON := "python3.6"
VENV_DIR := "$(HOME)/venvs"
DEP_FILE := "scripts/os-deps.apt"
test:
@py.test
run:
@( \
. $(VENV_DIR)/$(PROJECT)/bin/activate; \
python manage.py runserver; \
)
run8000:
@( \
. $(VENV_DIR)/$(PROJECT)/bin/activate; \
python manage.py runserver 0.0.0.0:8000; \
)
migrations:
@( \
. $(VENV_DIR)/$(PROJECT)/bin/activate; \
python manage.py makemigrations; \
)
migrate:
@( \
. $(VENV_DIR)/$(PROJECT)/bin/activate; \
python manage.py migrate; \
)
sass:
@( \
. $(VENV_DIR)/$(PROJECT)/bin/activate; \
python scripts/compile-sass.py $(PROJECT); \
)
shell:
@( \
. ~/venvs/$(PROJECT)/bin/activate; \
python manage.py shell; \
)
os_install:
# Bootstrap the current environment for running DeCart
@./scripts/bootstrap-ubuntu.sh $(DEP_FILE)
install:
@( \
$(PYTHON) -m pip install virtualenv; \
[ -d $(VENV_DIR) ] || mkdir $(VENV_DIR); \
$(PYTHON) -m virtualenv $(VENV_DIR)/$(PROJECT); \
. $(VENV_DIR)/$(PROJECT)/bin/activate; \
pip install -r scripts/py-dev.txt; \
)
newapp:
@( \
. $(VENV_DIR)/$(PROJECT)/bin/activate; \
python manage.py startapp $(NAME); \
)
project:
@. $(VENV_DIR)/$(PROJECT)/bin/activate
@python manage.py startproject $(NAME)
superuser:
@( \
. $(VENV_DIR)/$(PROJECT)/bin/activate; \
python manage.py createsuperuser; \
)
stats:
@cloc .
db_visual:
@( \
. $(VENV_DIR)/$(PROJECT)/bin/activate; \
./scripts/visualise-db.sh; \
)
# NOTE: Add other fixture files here when they are written
seed_db:
@( \
. $(VENV_DIR)/$(PROJECT)/bin/activate; \
python manage.py loaddata rock_me/fixtures/city.json; \
python manage.py loaddata decart/core/fixtures/kpi_category.json; \
python manage.py loaddata decart/core/fixtures/kpi.json; \
)
# Delete all migration .py and .pyc files then reset the DB
reset_db:
@( \
. $(VENV_DIR)/$(PROJECT)/bin/activate; \
./scripts/with-env flush; \
find . -type f -wholename '*migrations/[^_]*.py' -delete; \
find . -type f -wholename '*migrations/__pycache__/*' -delete; \
find . -type d -wholename '*migrations/__pycache__' -delete; \
find $(VENV_DIR) -type f -wholename '*decart/core/migrations/[^_]*.py' -delete; \
find $(VENV_DIR) -type f -wholename '*decart/core/migrations/__pycache__/*' -delete; \
find $(VENV_DIR) -type d -wholename '*decart/core/migrations/__pycache__' -delete; \
make migrations; \
make migrate; \
make superuser; \
make seed_db; \
python manage.py shell < scripts/import_users.py; \
)
clear_migrations:
@( \
echo "Clearing existing migration files..."; \
find . -type f -wholename '*migrations/[^_]*.py' -delete; \
find . -type f -wholename '*migrations/__pycache__/*' -delete; \
find . -type d -wholename '*migrations/__pycache__' -delete; \
find $(VENV_DIR) -type f -wholename '*decart/core/migrations/[^_]*.py' -delete; \
find $(VENV_DIR) -type f -wholename '*decart/core/migrations/__pycache__/*' -delete; \
find $(VENV_DIR) -type d -wholename '*decart/core/migrations/__pycache__' -delete; \
echo "Done."; \
)
init_rock:
@( \
. $(VENV_DIR)/$(PROJECT)/bin/activate; \
make migrations; \
make migrate; \
make superuser; \
make seed_db; \
python manage.py shell < scripts/import_users.py; \
)