-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
162 lines (108 loc) · 4.18 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
PHP := docker compose exec php
YARN := docker run --rm -v $(PWD):/app -w /app -u $(shell id -u):$(shell id -g) node:latest yarn
COMPOSER := $(PHP) composer
PHPUNIT := $(PHP) bin/phpunit
SYMFONY := $(PHP) bin/console
##
## Database
.PHONY: db db-reset db-cache db-validate fixtures
db: vendor db-reset fixtures ## Reset database and load fixtures
db-reset: vendor ## Reset database
@-$(SYMFONY) doctrine:database:drop --if-exists --force
@-$(SYMFONY) doctrine:database:create --if-not-exists
@$(SYMFONY) doctrine:schema:update --force
db-cache: vendor ## Clear doctrine database cache
@$(SYMFONY) doctrine:cache:clear-metadata
@$(SYMFONY) doctrine:cache:clear-query
@$(SYMFONY) doctrine:cache:clear-result
@echo "Cleared doctrine cache"
db-validate: vendor ## Checks doctrine's mapping configurations are valid
@$(SYMFONY) doctrine:schema:validate --skip-sync -vvv --no-interaction
fixtures: vendor ## Load fixtures - requires database with tables
@$(SYMFONY) doctrine:fixtures:load --no-interaction
##
## Linting
.PHONY: lint lint-container lint-twig lint-xliff lint-yaml
lint: vendor ## Run all lint commands
make -j lint-container lint-twig lint-xliff lint-yaml
lint-container: vendor ## Checks the services defined in the container
@$(SYMFONY) lint:container
lint-twig: vendor ## Check twig syntax in /templates folder (prod environment)
@$(SYMFONY) lint:twig templates -e prod
lint-xliff: vendor ## Check xliff syntax in /translations folder
@$(SYMFONY) lint:xliff translations
lint-yaml: vendor ## Check yaml syntax in /config and /translations folders
@$(SYMFONY) lint:yaml config translations
##
## Node.js
.PHONY: assets build watch
yarn.lock: package.json
@$(YARN) upgrade
node_modules: yarn.lock ## Install yarn packages
@$(YARN) install
assets: node_modules ## Run Webpack Encore to compile development assets
@$(YARN) dev
build: node_modules ## Run Webpack Encore to compile production assets
@$(YARN) build
watch: node_modules ## Recompile assets automatically when files change
@$(YARN) watch
##
## PHP
.PHONY: php
php: ## Exec PHP container
@docker-compose exec -u 0 php bash
composer.lock: composer.json
@$(COMPOSER) update
vendor: composer.lock ## Install dependencies in /vendor folder
@$(COMPOSER) install --optimize-autoloader --no-progress
##
## Project
.PHONY: install update cache-clear cache-warmup ci clean reset
install: db assets ## Install project dependencies
update: vendor node_modules ## Update project dependencies
@$(COMPOSER) update
@$(YARN) upgrade
cache-clear: vendor ## Clear cache for current environment
@$(SYMFONY) cache:clear --no-warmup
cache-warmup: vendor cache-clear ## Clear and warm up cache for current environment
@$(SYMFONY) cache:warmup
ci: db-validate quality tests ## Continuous integration
clean: purge ## Delete all dependencies
@rm -rf .env.local var vendor node_modules public/build
@echo "Var, vendor, node_modules and public/build folders have been deleted !"
reset: clean install ## Reset project
##
## Quality tools
.PHONY: quality eslint-fix phpcsfixer-audit phpcsfixer-fix phpstan twigcs
quality: ## Run linters and others quality tools
make lint phpcsfixer-audit phpstan twigcs
eslint-audit: node_modules
@$(YARN) run eslint assets --quiet
eslint-fix: node_modules
@$(YARN) run eslint assets --quiet --fix
phpcsfixer-audit: vendor ## Run php-cs-fixer audit
@$(PHP) ./vendor/bin/php-cs-fixer fix --diff --dry-run --no-interaction --ansi --verbose
phpcsfixer-fix: vendor ## Run php-cs-fixer fix
@$(PHP) ./vendor/bin/php-cs-fixer fix --verbose
phpstan: vendor ## Run phpstan
@$(PHP) ./vendor/bin/phpstan analyse --memory-limit=-1 --no-progress --xdebug
twigcs: vendor ## Run twigcs
#@$(PHP) ./vendor/bin/twigcs templates
##
## Tests
.PHONY: tests
tests: vendor ## Run tests
@$(SYMFONY) doctrine:database:create --env=test --if-not-exists
@$(PHPUNIT)
##
## Utils
.PHONY: purge
purge: ## Purge cache and logs
@rm -rf var/cache/* var/log/*
@echo "Cache and logs have been deleted !"
##
## Help
.PHONY: help
help: ## List of all commands
@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/'