This repository was archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (105 loc) · 3.38 KB
/
Makefile
File metadata and controls
122 lines (105 loc) · 3.38 KB
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
.ONESHELL:
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
VENV:=${ROOT_DIR}/venv/bin
default:
@echo "== Available commands for python =="
@echo "'pylint'\truns flake8"
@echo "'pyfix'\t\truns black"
@echo "'run'\t\truns manage.py runserver"
@echo "'test'\t\truns pytest"
@echo "'upgrade'\tupgrades python dependencies"
@echo "'deploy'\truns deploy script for vigilio"
@echo ""
@echo "== Available commands for JS =="
@echo "'jslint'\truns prettier check"
@echo "'jsfix'\t\truns prettier write"
@echo "'install'\truns yarn install"
@echo "'start'\t\truns webpack in dev mode (watch)"
@echo "'build'\t\truns webpack build in prod mode"
check_venv:
@if [ -a ${ROOT_DIR}/venv/bin/activate ]; \
then \
echo "Found virtualenv"; \
else \
echo "Virtualenv could not be found. Initiating..." && \
python3 -m venv ${ROOT_DIR}/venv && \
echo "Activating the virtualenv..." && \
. ${VENV}/activate && echo "Installing the dependencies..." && \
pip install wheel && \
pip install -r ${ROOT_DIR}/requirements/dev.txt && \
echo "Installation complete. Disabling the virtualenv for consistency..." && \
deactivate && \
echo "Resuming normal operation"; \
fi;
# ========================================================
# JS
# ========================================================
jslint:
@echo "Running JS linter"
yarn --cwd ${ROOT_DIR}/frontend lint
@echo "Linter process ended"
jsfix:
@echo "Running JS linter"
yarn --cwd ${ROOT_DIR}/frontend fix
@echo "Linter process ended"
install:
@echo "Initiating node server..."
yarn --cwd ${ROOT_DIR}/frontend install
start:
@echo "Initiating node server..."
yarn --cwd ${ROOT_DIR}/frontend start
build:
@echo "Compiling js files..."
yarn --cwd ${ROOT_DIR}/frontend build
@echo "Compilation has finished."
# ========================================================
# PYTHON
# ========================================================
activate: check_venv
@echo "Activating virtualenv"
@. ${VENV}/activate;
pylint: activate
@echo "Running linter"
@${VENV}/flake8 ${ROOT_DIR}
@echo "Linter process ended"
pyfix: activate
@echo "Running syntax fixer"
@${VENV}/black --exclude venv ${ROOT_DIR}
@echo "Syntax fixer process ended"
test: activate
@echo "Testing..."
@${VENV}/pytest ${ROOT_DIR}
run: activate
@echo "Running the server"
@${VENV}/python ${ROOT_DIR}/manage.py runserver
upgrade: activate
@echo "Upgrading dependencies"
@${VENV}/python ${ROOT_DIR}/requirements/upgrade_dependencies.py
deploy:
set -e
@echo "Deploying to production"
rm -rf ${ROOT_DIR}/frontend/dist
@echo "Fetching latest version"
git pull
@if [ -a ${ROOT_DIR}/venv/bin/activate ]; \
then \
echo "Found virtualenv"; \
else \
echo "Virtualenv could not be found. Initiating..." && \
python3 -m venv ${ROOT_DIR}/venv && \
echo "Activating the virtualenv..."; \
fi;
. ${VENV}/activate
@echo "Upgrading pip..."
pip install --upgrade pip
pip install wheel
@echo "Installing the dependencies..."
pip install -r ${ROOT_DIR}/requirements/prod.txt
@echo "Requirements installation is complete."
@echo "Attempting to migrate database..."
${VENV}/python ${ROOT_DIR}/manage.py migrate
${VENV}/python ${ROOT_DIR}/manage.py collectstatic --no-input
@echo "Installation is complete. Attempting to restarting the service..."
@echo "If prompt, please enter password."
systemctl restart vigilio.service
systemctl restart celery-vigilio.service