-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathMakefile
150 lines (122 loc) · 5.2 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
.DEFAULT_GOAL := help
NOW := $(shell date +'%Y%m%d-%H%M%S')
STORAGE_PATH_RIPLOG := $(shell bin/getconf STORAGE_PATH_RIPLOG)
STORAGE_PATH_RIPLOGHTML := $(shell bin/getconf STORAGE_PATH_RIPLOGHTML)
STORAGE_PATH_TORRENT := $(shell bin/getconf STORAGE_PATH_TORRENT)
.SILENT: help
.PHONY: help
help:
echo ' help - output this message'
echo ' build-css - build the CSS'
echo ' check-php - check that the modified PHP files are syntactically correct'
echo ' composer-dev-update - run local composer update'
echo ' composer-live-update - run production composer install from composer.lock'
echo ' config-css - generate the configuration variables to build the CSS files'
echo ' dump-all - create tarballs of the following:'
echo ' dump-riplog - create a tarball of the rip logs'
echo ' dump-riploghtml - create a tarball of the HTMLified rip logs'
echo ' dump-torrent - create a tarball of the rip logs'
echo ' git-submodules - update the git submodules'
echo ' lint-css - lint (style check) the CSS'
echo ' lint-js - lint (style check) the Javascript'
echo ' lint-php - lint (style check) the PHP'
echo ' lint-twig - lint (style check) the Twig templates'
echo ' lint-staged - lint (style check) all staged changes'
echo ' reformat-staged - reformat all staged changes'
echo ' mysqldump - dump mysql database from docker to misc/mysql-dump.sql'
echo ' ocelot-reload-conf - signal Ocelot to reload its configuration'
echo ' ocelot-reload-db - signal Ocelot to reload from database'
echo ' pgdump - dump postgresql database from docker to misc/postgresql-dump.sql'
echo ' phpstan-analyse - run phpstan over the code'
echo ' phpstan-baseline - generate a new phpstan baseline'
echo ' test - run unit test suite'
echo ' twig-flush - purge the Twig cache'
.PHONY: build-css
build-css:
docker compose exec -T web bin/config-css /tmp/config-css.js
docker compose exec -T web npm run build:scss
.PHONY: check-php
check-php:
git status | awk '/(modified|new file):.*\.php$$/ {print $$NF}' | xargs php -l
.PHONY: composer-dev-update
composer-dev-update:
composer update --optimize-autoloader
.PHONY: composer-live-update
composer-live-update:
composer install --no-dev --optimize-autoloader --no-progress
.PHONY: dump-all
dump-all: dump-riplog dump-riploghtml dump-torrent
.PHONY: dump-riplog
dump-riplog:
tar -C "$(STORAGE_PATH_RIPLOG)/.." -jcf riplog.$(NOW).tar.bz2 "$$(basename $(STORAGE_PATH_RIPLOG))"
.PHONY: dump-riploghtml
dump-riploghtml:
tar -C "$(STORAGE_PATH_RIPLOGHTML)/.." -jcf riploghtml.$(NOW).tar.bz2 "$$(basename $(STORAGE_PATH_RIPLOGHTML))"
.PHONY: dump-torrent
dump-torrent:
tar -C "$(STORAGE_PATH_TORRENT)/.." -jcf torrent.$(NOW).tar.bz2 "$$(basename $(STORAGE_PATH_TORRENT))"
.PHONY: git-submodules
git-submodules:
git pull --recurse-submodules
.PHONY: lint-css
lint-css:
docker compose exec -T web node_modules/.bin/stylelint --config misc/stylelint.json --cache --cache-location cache/stylelint 'sass/**/*.scss'
docker compose exec -T web node_modules/.bin/stylelint --config misc/stylelint.json --cache --cache-location cache/stylelint 'sass/**/*.scss' --custom-formatter ./node_modules/stylelint-checkstyle-formatter/index.js
.PHONY: lint-js
lint-js:
npx eslint -c misc/eslint.config.mjs public/static
.PHONY: lint-php
lint-php:
find . -path ./vendor -prune \
-o -path ./cache -prune \
-o -path ./node_modules -prune \
-o -path ./misc/docker -prune \
-o -type f -name '*.php' \
print0 \
| xargs -0 php -l -n | grep -v '^No syntax errors detected in' || true
vendor/bin/phpcs -p --report-width=256
vendor/bin/phpstan analyse --memory-limit=1024M --configuration=misc/phpstan.neon
.PHONY: lint-twig
lint-twig:
bin/twig-parse $(find templates -type f)
.PHONY: lint-staged
lint-staged:
bin/lint-staged
.PHONY: reformat-staged
reformat-staged:
bin/reformat-staged
# defaults file must be chmod 0400 and look something like:
#
# [mysqldump]
# user=gazelle
# password=password
.PHONY: mysqldump
mysqldump:
docker compose exec -T mysql mysqldump --defaults-file=~/mysqldump.cnf gazelle --single-transaction > misc/mysql-dump.sql
.PHONY: ocelot-reload-conf
ocelot-reload-conf:
pkill -HUP ocelot
.PHONY: ocelot-reload-db
ocelot-reload-db:
pkill -USR1 ocelot
.PHONY: pgdump
pgdump:
docker exec -e POSTGRES_PASSWORD=nyalapw $(shell docker ps|awk '/postgres:/ {print $$1}') pg_dumpall -U nyala > misc/postgresql-dump.sql
.PHONY: phpstan-analyse
phpstan-analyse:
vendor/bin/phpstan analyse --memory-limit=1024M --configuration=misc/phpstan.neon
.PHONY: phpstan-baseline
phpstan-baseline:
vendor/bin/phpstan analyse --memory-limit=1024M --configuration=misc/phpstan.neon --generate-baseline misc/phpstan-baseline.neon
.PHONY: rector
rector:
vendor/bin/rector process --config misc/rector.php
.PHONY: rector-dry-run
rector-dry-run:
vendor/bin/rector process --dry-run --config misc/rector.php
.PHONY: test
test:
docker compose exec -T web vendor/bin/phpunit -c misc/phpunit.xml
.PHONY: twig-flush
twig-flush:
find cache/twig -mindepth 1 -depth -delete