-
Notifications
You must be signed in to change notification settings - Fork 28
/
Makefile
191 lines (140 loc) · 4.94 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
DOCKER_COMPOSE = docker-compose
EXEC_PHP = $(DOCKER_COMPOSE) exec -T php /entrypoint
EXEC_JS = $(DOCKER_COMPOSE) exec -T node /entrypoint
SYMFONY = $(EXEC_PHP) bin/console
COMPOSER = $(EXEC_PHP) composer
YARN = $(EXEC_JS) yarn
##
## Project
## -------
##
build:
@$(DOCKER_COMPOSE) pull --parallel --quiet --ignore-pull-failures 2> /dev/null
$(DOCKER_COMPOSE) build --pull
kill:
$(DOCKER_COMPOSE) kill
$(DOCKER_COMPOSE) down --volumes --remove-orphans
install: ## Install and start the project
install: .env.local build start assets db
reset: ## Stop and start a fresh install of the project
reset: kill install
start: ## Start the project
$(DOCKER_COMPOSE) up -d --remove-orphans --no-recreate
stop: ## Stop the project
$(DOCKER_COMPOSE) stop
clean: ## Stop the project and remove generated files
clean: kill
rm -rf .env.local vendor node_modules
no-docker:
$(eval DOCKER_COMPOSE := \#)
$(eval EXEC_PHP := )
$(eval EXEC_JS := )
.PHONY: build kill install reset start stop clean no-docker
##
## Utils
## -----
##
db: ## Reset the database and load fixtures
db: .env.local vendor
@$(EXEC_PHP) php -r 'echo "Wait database...\n"; set_time_limit(30); require __DIR__."/config/bootstrap.php"; $$u = parse_url($$_ENV["DATABASE_URL"]); for(;;) { if(@fsockopen($$u["host"].":".($$u["port"] ?? 3306))) { break; }}'
-$(SYMFONY) doctrine:database:drop --if-exists --force
-$(SYMFONY) doctrine:database:create --if-not-exists
$(SYMFONY) doctrine:migrations:migrate --no-interaction --allow-no-migration
$(SYMFONY) doctrine:fixtures:load --no-interaction --purge-with-truncate
migration: ## Generate a new doctrine migration
migration: vendor
$(SYMFONY) doctrine:migrations:diff
db-validate-schema: ## Validate the doctrine ORM mapping
db-validate-schema: .env.local vendor
$(SYMFONY) doctrine:schema:validate
assets: ## Run Webpack Encore to compile assets
assets: node_modules
$(YARN) run dev
watch: ## Run Webpack Encore in watch mode
watch: node_modules
$(YARN) run watch
.PHONY: db migration assets watch
##
## Tests
## -----
##
test: ## Run unit and functional tests
test: tu tf
tu: ## Run unit tests
tu: vendor
$(EXEC_PHP) bin/phpunit --exclude-group functional
tf: ## Run functional tests
tf: vendor
$(EXEC_PHP) bin/phpunit --group functional
.PHONY: test tu tf
# rules based on files
composer.lock: composer.json
$(COMPOSER) update --lock --no-scripts --no-interaction
vendor: composer.lock
$(COMPOSER) install
node_modules: yarn.lock
$(YARN) install
@touch -c node_modules
yarn.lock: package.json
$(YARN) upgrade
.env.local: .env.local.docker
@if [ -f .env ]; \
then\
echo '\033[1;41m/!\ The .env.local.docker file has changed. Please check your .env.local file (this message will not be displayed again).\033[0m';\
touch .env.local;\
exit 1;\
else\
echo cp .env.local.docker .env.local;\
cp .env.local.docker .env.local;\
fi
##
## Quality assurance
## -----------------
##
QA = docker run --rm -v `pwd`:/project mykiwi/phaudit:7.3
ARTEFACTS = var/artefacts
lint: ## Lints twig and yaml files
lint: lt ly
lt: vendor
$(SYMFONY) lint:twig templates
ly: vendor
$(SYMFONY) lint:yaml config
security: ## Check security of your dependencies (https://security.sensiolabs.org/)
security: vendor
$(EXEC_PHP) ./vendor/bin/security-checker security:check
phploc: ## PHPLoc (https://github.com/sebastianbergmann/phploc)
$(QA) phploc src/
pdepend: ## PHP_Depend (https://pdepend.org)
pdepend: artefacts
$(QA) pdepend \
--summary-xml=$(ARTEFACTS)/pdepend_summary.xml \
--jdepend-chart=$(ARTEFACTS)/pdepend_jdepend.svg \
--overview-pyramid=$(ARTEFACTS)/pdepend_pyramid.svg \
src/
phpmd: ## PHP Mess Detector (https://phpmd.org)
$(QA) phpmd src text .phpmd.xml
php_codesnifer: ## PHP_CodeSnifer (https://github.com/squizlabs/PHP_CodeSniffer)
$(QA) phpcs -v --standard=.phpcs.xml src
phpcpd: ## PHP Copy/Paste Detector (https://github.com/sebastianbergmann/phpcpd)
$(QA) phpcpd src
phpdcd: ## PHP Dead Code Detector (https://github.com/sebastianbergmann/phpdcd)
$(QA) phpdcd src
phpmetrics: ## PhpMetrics (http://www.phpmetrics.org)
phpmetrics: artefacts
$(QA) phpmetrics --report-html=$(ARTEFACTS)/phpmetrics src
php-cs-fixer: ## php-cs-fixer (http://cs.sensiolabs.org)
$(QA) php-cs-fixer fix --dry-run --using-cache=no --verbose --diff
apply-php-cs-fixer: ## apply php-cs-fixer fixes
$(QA) php-cs-fixer fix --using-cache=no --verbose --diff
twigcs: ## twigcs (https://github.com/allocine/twigcs)
$(QA) twigcs lint templates
eslint: ## eslint (https://eslint.org/)
eslint: node_modules
$(EXEC_JS) node_modules/.bin/eslint --fix-dry-run assets/js/**
artefacts:
mkdir -p $(ARTEFACTS)
.PHONY: lint lt ly phploc pdepend phpmd php_codesnifer phpcpd phpdcd phpmetrics php-cs-fixer apply-php-cs-fixer artefacts
.DEFAULT_GOAL := help
help:
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
.PHONY: help