This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
162 lines (118 loc) · 5.13 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
.DEFAULT_GOAL:=help
THEMATIQUES = $(foreach file,$(subst contenus/thematiques/,,$(subst .md,.html,$(wildcard contenus/thematiques/*.md))),$(addprefix src/,$(shell echo $(file) | sed -r 's/[0-9]+-//')))
HTML = src/index.html $(THEMATIQUES)
key.pem: ## Generate certificates to be able to run `https` on `localhost`.
openssl req -nodes -newkey rsa:2048 -x509 -days 365 -keyout key.pem -out cert.pem -subj "/C=FR/CN=localhost"
install: install-python install-js
install-python: ## Install Python dependencies.
python3 -m pip install -U 'pip<22' setuptools wheel
python3 -m pip install -r requirements.txt
install-js: ## Install JS dependencies.
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install
uninstall-js:
rm -rf ./node_modules
clean:
rm -rf dist/ src/*.html .cache .parcel-cache __pycache__
##
## Run JS unit tests matching a given pattern/browser engine.
##
## Examples:
## make test-unit grep=profil
## make test-integration browser=webkit grep=suivi
## make test browser=webkit
test: test-unit test-integration test-tools test-feedback
ifdef grep
grepping = --grep $(grep)
else
grepping =
endif
ifdef cover
coverage = :coverage
else
coverage =
endif
ifdef watch
watching = --watch
else
watching =
endif
ifdef noopen
open =
else
open = --open
endif
test-unit: ## Run JS unit tests.
npm run-script test$(coverage) -- $(grepping) $(watching)
test-integration: dist/index.html ## Run JS browser tests.
ifdef browser
npx playwright install $(browser)
BROWSER=$(browser) npm run-script test-integration -- $(grepping)
else
npx playwright install chromium
BROWSER=chromium npm run-script test-integration -- $(grepping)
npx playwright install firefox
BROWSER=firefox npm run-script test-integration -- $(grepping)
npx playwright install webkit
BROWSER=webkit npm run-script test-integration -- $(grepping)
endif
test-tools:
PYTHONPATH=. pytest construction/
PYTHONPATH=tools pytest tools/
test-feedback:
tox -e py38 -c feedback/tox.ini
check: check-external-links check-orphelins check-diagrammes
check-external-links: # Check that links to external pages are still valid.
python3 check.py external_links --timeout 40 --delay 0.3
check-internal-links: build # Check that links to internal pages are still valid.
python3 check.py internal_links
check-orphelins: # Check that all markdown files are in use in template.
python3 check.py orphelins
check-diagrammes: # Check that all files from diagrammes/matrice exist.
python3 check.py diagrammes
HTML_EN = src/covid-in-france.html
HTML_FR = $(filter-out $(HTML_EN),$(HTML))
check-spelling: $(HTML) jargon.dic
hunspell -l -H --check-apostrophe -d en_US,fr,jargon $(HTML_EN)
hunspell -l -H --check-apostrophe -d fr,jargon $(HTML_FR)
jargon.dic: jargon.dic.txt
cat $< | sort | uniq >[email protected]
wc -l [email protected] >$@
cat [email protected] >>$@
rm -f [email protected]
lint: ## Run ESLint + check code style.
npm run-script lint
./node_modules/.bin/prettier "src/**/*.{js,ts,css}" --check
pretty: ## Run PrettierJS.
./node_modules/.bin/prettier "src/**/*.{js,ts,css}" --write
optimize-images:
find diagrammes src static -type f -iname "*.png" -print0 | xargs -I {} -0 zopflipng -y "{}" "{}"
build: dist/index.html
dist/index.html: src/index.html $(firstword $(THEMATIQUES)) static/sitemap.xml
npm run-script build
# Construire l’index (page d’accueil + questionnaire)
src/index.html: build.py construction/*.py construction/directives/*.py \
contenus/config/*.md contenus/conseils/*.md contenus/meta/*.md contenus/questions/*.md contenus/réponses/*.md contenus/statuts/*.md contenus/suivi/*.md \
contenus/thematiques/*.md \
templates/index.html
python3 build.py index
# Construire les pages thématiques
$(THEMATIQUES): build.py construction/*.py construction/directives/*.py \
contenus/meta/*.md contenus/thematiques/*.md \
templates/thematique.html
python3 build.py thematiques
# Construire la carte du site (pour les robots)
static/sitemap.xml: build.py templates/sitemap.html contenus/thematiques/*.md
python3 build.py sitemap
dev: dist/index.html ## Local HTTP server with auto rebuild (with LiveReload).
python3 serve.py --watch $(open)
dev-ssl: key.pem dist/index.html ## Local HTTPS server with auto rebuild (without LiveReload).
python3 serve.py --watch $(open) --ssl
pre-commit: pretty lint test-unit dist/index.html check-orphelins check-diagrammes ## Interesting prior to commit/push.
release:
echo "{\"version\": \"$$(date --iso-8601)\"}" >static/version.json
sed -i "2 a ## $$(date --iso-8601)\n\n* ...\n" CHANGELOG.md
prod: clean install lint pretty test check ## Make sure everything is clean prior to deploy.
# Note: `test` dependency will actually generate the `build`.
.PHONY: serve serve-ssl install install-python install-js clean test test-unit test-integration test-feedback check-external-links check-internal-links check-documentation check-spelling optimize-images build generate dev pre-commit release prod help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)