aboutsummaryrefslogtreecommitdiffhomepage
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile97
1 files changed, 32 insertions, 65 deletions
diff --git a/Makefile b/Makefile
index 0ae03226..b758d1fd 100644
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,6 @@
2# Makefile for PHP code analysis & testing, documentation and release generation 2# Makefile for PHP code analysis & testing, documentation and release generation
3 3
4BIN = vendor/bin 4BIN = vendor/bin
5PHP_SOURCE = index.php application tests plugins
6PHP_COMMA_SOURCE = index.php,application,tests,plugins
7 5
8all: static_analysis_summary check_permissions test 6all: static_analysis_summary check_permissions test
9 7
@@ -18,84 +16,32 @@ docker_%:
18 cd ~/shaarli && make $* 16 cd ~/shaarli && make $*
19 17
20## 18##
21# Concise status of the project
22# These targets are non-blocking: || exit 0
23##
24
25static_analysis_summary: code_sniffer_source copy_paste mess_detector_summary
26 @echo
27
28##
29# PHP_CodeSniffer 19# PHP_CodeSniffer
30# Detects PHP syntax errors 20# Detects PHP syntax errors
31# Documentation (usage, output formatting): 21# Documentation (usage, output formatting):
32# - http://pear.php.net/manual/en/package.php.php-codesniffer.usage.php 22# - http://pear.php.net/manual/en/package.php.php-codesniffer.usage.php
33# - http://pear.php.net/manual/en/package.php.php-codesniffer.reporting.php 23# - http://pear.php.net/manual/en/package.php.php-codesniffer.reporting.php
34## 24##
25PHPCS := $(BIN)/phpcs
35 26
36code_sniffer: code_sniffer_full 27code_sniffer:
28 @$(PHPCS)
37 29
38### - errors filtered by coding standard: PEAR, PSR1, PSR2, Zend... 30### - errors filtered by coding standard: PEAR, PSR1, PSR2, Zend...
39PHPCS_%: 31PHPCS_%:
40 @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200 --standard=$* 32 @$(PHPCS) --report-full --report-width=200 --standard=$*
41 33
42### - errors by Git author 34### - errors by Git author
43code_sniffer_blame: 35code_sniffer_blame:
44 @$(BIN)/phpcs $(PHP_SOURCE) --report-gitblame 36 @$(PHPCS) --report-gitblame
45 37
46### - all errors/warnings 38### - all errors/warnings
47code_sniffer_full: 39code_sniffer_full:
48 @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200 40 @$(PHPCS) --report-full --report-width=200
49 41
50### - errors grouped by kind 42### - errors grouped by kind
51code_sniffer_source: 43code_sniffer_source:
52 @$(BIN)/phpcs $(PHP_SOURCE) --report-source || exit 0 44 @$(PHPCS) --report-source || exit 0
53
54##
55# PHP Copy/Paste Detector
56# Detects code redundancy
57# Documentation: https://github.com/sebastianbergmann/phpcpd
58##
59
60copy_paste:
61 @echo "-----------------------"
62 @echo "PHP COPY/PASTE DETECTOR"
63 @echo "-----------------------"
64 @$(BIN)/phpcpd $(PHP_SOURCE) || exit 0
65 @echo
66
67##
68# PHP Mess Detector
69# Detects PHP syntax errors, sorted by category
70# Rules documentation: http://phpmd.org/rules/index.html
71##
72MESS_DETECTOR_RULES = cleancode,codesize,controversial,design,naming,unusedcode
73
74mess_title:
75 @echo "-----------------"
76 @echo "PHP MESS DETECTOR"
77 @echo "-----------------"
78
79### - all warnings
80mess_detector: mess_title
81 @$(BIN)/phpmd $(PHP_COMMA_SOURCE) text $(MESS_DETECTOR_RULES) | sed 's_.*\/__'
82
83### - all warnings + HTML output contains links to PHPMD's documentation
84mess_detector_html:
85 @$(BIN)/phpmd $(PHP_COMMA_SOURCE) html $(MESS_DETECTOR_RULES) \
86 --reportfile phpmd.html || exit 0
87
88### - warnings grouped by message, sorted by descending frequency order
89mess_detector_grouped: mess_title
90 @$(BIN)/phpmd $(PHP_SOURCE) text $(MESS_DETECTOR_RULES) \
91 | cut -f 2 | sort | uniq -c | sort -nr
92
93### - summary: number of warnings by rule set
94mess_detector_summary: mess_title
95 @for rule in $$(echo $(MESS_DETECTOR_RULES) | tr ',' ' '); do \
96 warnings=$$($(BIN)/phpmd $(PHP_COMMA_SOURCE) text $$rule | wc -l); \
97 printf "$$warnings\t$$rule\n"; \
98 done;
99 45
100## 46##
101# Checks source file & script permissions 47# Checks source file & script permissions
@@ -157,21 +103,32 @@ composer_dependencies: clean
157 composer install --no-dev --prefer-dist 103 composer install --no-dev --prefer-dist
158 find vendor/ -name ".git" -type d -exec rm -rf {} + 104 find vendor/ -name ".git" -type d -exec rm -rf {} +
159 105
106### download 3rd-party frontend libraries
107frontend_dependencies:
108 yarn install
109
110### Build frontend dependencies
111build_frontend: frontend_dependencies
112 yarn run build
113
160### generate a release tarball and include 3rd-party dependencies and translations 114### generate a release tarball and include 3rd-party dependencies and translations
161release_tar: composer_dependencies htmldoc translate 115release_tar: composer_dependencies htmldoc translate build_frontend
162 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).tar HEAD 116 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).tar HEAD
163 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^vendor|$(ARCHIVE_PREFIX)vendor|" vendor/ 117 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^vendor|$(ARCHIVE_PREFIX)vendor|" vendor/
164 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^doc/html|$(ARCHIVE_PREFIX)doc/html|" doc/html/ 118 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^doc/html|$(ARCHIVE_PREFIX)doc/html|" doc/html/
119 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^tpl|$(ARCHIVE_PREFIX)tpl|" tpl/
165 gzip $(ARCHIVE_VERSION).tar 120 gzip $(ARCHIVE_VERSION).tar
166 121
167### generate a release zip and include 3rd-party dependencies and translations 122### generate a release zip and include 3rd-party dependencies and translations
168release_zip: composer_dependencies htmldoc translate 123release_zip: composer_dependencies htmldoc translate build_frontend
169 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).zip -9 HEAD 124 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).zip -9 HEAD
170 mkdir -p $(ARCHIVE_PREFIX)/{doc,vendor} 125 mkdir -p $(ARCHIVE_PREFIX)/{doc,vendor}
171 rsync -a doc/html/ $(ARCHIVE_PREFIX)doc/html/ 126 rsync -a doc/html/ $(ARCHIVE_PREFIX)doc/html/
172 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)doc/ 127 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)doc/
173 rsync -a vendor/ $(ARCHIVE_PREFIX)vendor/ 128 rsync -a vendor/ $(ARCHIVE_PREFIX)vendor/
174 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)vendor/ 129 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)vendor/
130 rsync -a tpl/ $(ARCHIVE_PREFIX)tpl/
131 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)tpl/
175 rm -rf $(ARCHIVE_PREFIX) 132 rm -rf $(ARCHIVE_PREFIX)
176 133
177## 134##
@@ -192,17 +149,27 @@ authors:
192### generate Doxygen documentation 149### generate Doxygen documentation
193doxygen: clean 150doxygen: clean
194 @rm -rf doxygen 151 @rm -rf doxygen
195 @( cat Doxyfile ; echo "PROJECT_NUMBER=`git describe`" ) | doxygen - 152 @doxygen Doxyfile
196 153
197### generate HTML documentation from Markdown pages with MkDocs 154### generate HTML documentation from Markdown pages with MkDocs
198htmldoc: 155htmldoc:
199 python3 -m venv venv/ 156 python3 -m venv venv/
200 bash -c 'source venv/bin/activate; \ 157 bash -c 'source venv/bin/activate; \
201 pip install mkdocs; \ 158 pip install mkdocs; \
202 mkdocs build' 159 mkdocs build --clean'
203 find doc/html/ -type f -exec chmod a-x '{}' \; 160 find doc/html/ -type f -exec chmod a-x '{}' \;
204 rm -r venv 161 rm -r venv
205 162
163
206### Generate Shaarli's translation compiled file (.mo) 164### Generate Shaarli's translation compiled file (.mo)
207translate: 165translate:
208 @find inc/languages/ -name shaarli.po -execdir msgfmt shaarli.po -o shaarli.mo \; 166 @find inc/languages/ -name shaarli.po -execdir msgfmt shaarli.po -o shaarli.mo \;
167
168### Run ESLint check against Shaarli's JS files
169eslint:
170 @yarn run eslint -c .dev/.eslintrc.js assets/vintage/js/
171 @yarn run eslint -c .dev/.eslintrc.js assets/default/js/
172
173### Run CSSLint check against Shaarli's SCSS files
174sasslint:
175 @yarn run sass-lint -c .dev/.sasslintrc 'assets/default/scss/*.scss' -v -q