/
Makefile
108 lines (86 loc) · 3.53 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
.PHONY: install install-minimal
.PHONY: createtables createtables-minimal createtables-celery createsuperuser installsysdeps configuresysdeps
.PHONY: run run-celery run-server run-minimal
.PHONY: update oncommit test create-companion-app static migrate reformat
.PHONY: clear-celery
CP = cp
PROJECT_NAME = linklibrary
PORT=8080
APP_NAME = rsshistory
# Edit companion app if necessary
COMPANION_APP = catalog
# Assumptions:
# - python poetry is in your path
install:
poetry install
poetry run python -m spacy download en_core_web_sm
@$(CP) $(PROJECT_NAME)/settings_template.py $(PROJECT_NAME)/settings.py
@echo "*******************************************************************"
@echo "Please configure your django application linklibrary in settings.py"
@echo "Please:"
@echo " - define SECRET_KEY settings.py"
@echo " - use createtables rule to create tables"
@echo " - add required hosts to ALLOWED_HOSTS"
@echo "*******************************************************************"
install-minimal:
poetry install
poetry run python -m spacy download en_core_web_sm
@$(CP) $(PROJECT_NAME)/settings_template_minimal.py $(PROJECT_NAME)/settings.py
@echo "*******************************************************************"
@echo "Please configure your django application linklibrary in settings.py"
@echo "Please:"
@echo " - define SECRET_KEY settings.py"
@echo " - use createtables rule to create tables"
@echo " - add required hosts to ALLOWED_HOSTS"
@echo "*******************************************************************"
createtables: createtables-minimal createtables-celery
createtables-minimal:
poetry run python manage.py migrate --run-syncdb
createtables-celery:
poetry run python manage.py migrate django_celery_results
createsuperuser:
poetry run python manage.py createsuperuser
# Assumptions:
# - I cannot write installation commands for each Linux distro. I assume you are using debian-derivative
# - assume you are using sudo for this command. solve it later https://github.com/rumca-js/Django-link-archive/issues/10
# http://pont.ist/rabbit-mq/
installsysdeps:
apt -y install rabbitmq-server memcached wget id3v2 chromium-browser chromium-chromedriver
systemctl enable rabbitmq-server
systemctl start rabbitmq-server
systemctl enable memcached.service
systemctl start memcached.service
run: run-celery run-server
run-minimal: run-server
run-celery:
poetry run celery -A linklibrary worker -l INFO -B &
run-server:
poetry run python manage.py runserver 0.0.0.0:$(PORT)
# Assumptions:
# - python black is in your path
# Black should use gitignore files to ignore refactoring
reformat:
poetry run black $(APP_NAME)
static:
poetry run python -m manage collectstatic
migrations-check:
poetry run python -m manage makemigrations --check --dry-run
migrate:
poetry run python manage.py makemigrations
poetry run python manage.py migrate
update: migrate static
test: migrations-check
@poetry run python manage.py test $(APP_NAME) -v 2
oncommit: reformat test
create-companion-app:
rm -rf ./$(COMPANION_APP)
mkdir $(COMPANION_APP)
cp -r $(APP_NAME)/* ./$(COMPANION_APP)/*
grep -rl $(APP_NAME) ./$(COMPANION_APP) | xargs sed -i 's/$(APP_NAME)/$(COMPANION_APP)/g'
@echo "*******************************************************************"
@echo "Please configure your django application linklibrary in settings.py"
@echo "Please:"
@echo " - register app in INSTALLED_APPS, add '$(COMPANION_APP).apps.LinkDatabase',
@echo "*******************************************************************"
clear-celery:
rm -f celerybeat-schedule.db