forked from monsieurbiz/SyliusSettingsPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
210 lines (159 loc) · 6.14 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
.DEFAULT_GOAL := help
SHELL=/bin/bash
APP_DIR=tests/Application
SYLIUS_VERSION=1.11.0
SYMFONY=cd ${APP_DIR} && symfony
COMPOSER=symfony composer
CONSOLE=${SYMFONY} console
export COMPOSE_PROJECT_NAME=settings
PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin
COMPOSE=docker-compose
YARN=yarn
###
### DEVELOPMENT
### ¯¯¯¯¯¯¯¯¯¯¯
install: application platform sylius ## Install the plugin
.PHONY: install
up: docker.up server.start ## Up the project (start docker, start symfony server)
stop: server.stop docker.stop ## Stop the project (stop docker, stop symfony server)
down: server.stop docker.down ## Down the project (removes docker containers, stop symfony server)
reset: ## Stop docker and remove dependencies
${MAKE} docker.down || true
rm -rf ${APP_DIR}/node_modules ${APP_DIR}/yarn.lock
rm -rf ${APP_DIR}
rm -rf vendor composer.lock
.PHONY: reset
dependencies: composer.lock node_modules ## Setup the dependencies
.PHONY: dependencies
.php-version: .php-version.dist
rm -f .php-version
ln -s .php-version.dist .php-version
php.ini: php.ini.dist
rm -f php.ini
ln -s php.ini.dist php.ini
composer.lock: composer.json
${COMPOSER} install --no-scripts --no-plugins
yarn.install: ${APP_DIR}/yarn.lock
${APP_DIR}/yarn.lock:
ln -sf ${APP_DIR}/node_modules node_modules
cd ${APP_DIR} && ${YARN} install && ${YARN} build
# No CSS and JS on this plugin yet
# ${YARN} install
# ${YARN} encore prod
node_modules: ${APP_DIR}/node_modules ## Install the Node dependencies using yarn
${APP_DIR}/node_modules: yarn.install
###
### TEST APPLICATION
### ¯¯¯¯¯
application: .php-version php.ini ${APP_DIR} setup_application ${APP_DIR}/docker-compose.yaml
${APP_DIR}:
(${COMPOSER} create-project --no-interaction --prefer-dist --no-scripts --no-progress --no-install sylius/sylius-standard="~${SYLIUS_VERSION}" ${APP_DIR})
setup_application:
rm -f ${APP_DIR}/yarn.lock
(cd ${APP_DIR} && ${COMPOSER} config repositories.plugin '{"type": "path", "url": "../../"}')
(cd ${APP_DIR} && ${COMPOSER} config extra.symfony.allow-contrib true)
(cd ${APP_DIR} && ${COMPOSER} config minimum-stability dev)
(cd ${APP_DIR} && ${COMPOSER} require --no-install --no-scripts --no-progress sylius/sylius="~${SYLIUS_VERSION}") # Make sure to install the required version of sylius because the sylius-standard has a soft constraint
$(MAKE) ${APP_DIR}/.php-version
$(MAKE) ${APP_DIR}/php.ini
(cd ${APP_DIR} && ${COMPOSER} install --no-interaction)
$(MAKE) apply_dist
(cd ${APP_DIR} && ${COMPOSER} require --no-progress monsieurbiz/${PLUGIN_NAME}="*@dev")
rm -rf ${APP_DIR}/var/cache
${APP_DIR}/docker-compose.yaml:
rm -f ${APP_DIR}/docker-compose.yml
rm -f ${APP_DIR}/docker-compose.yaml
ln -s ../../docker-compose.yaml.dist ${APP_DIR}/docker-compose.yaml
.PHONY: ${APP_DIR}/docker-compose.yaml
${APP_DIR}/.php-version: .php-version
(cd ${APP_DIR} && ln -sf ../../.php-version)
${APP_DIR}/php.ini: php.ini
(cd ${APP_DIR} && ln -sf ../../php.ini)
apply_dist:
ROOT_DIR=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))); \
for i in `cd dist && find . -type f`; do \
FILE_PATH=`echo $$i | sed 's|./||'`; \
FOLDER_PATH=`dirname $$FILE_PATH`; \
echo $$FILE_PATH; \
(cd ${APP_DIR} && rm -f $$FILE_PATH); \
(cd ${APP_DIR} && mkdir -p $$FOLDER_PATH); \
(cd ${APP_DIR} && ln -s $$ROOT_DIR/dist/$$FILE_PATH $$FILE_PATH); \
done
###
### TESTS
### ¯¯¯¯¯
test.all: test.composer test.phpstan test.phpmd test.phpunit test.phpspec test.phpcs test.yaml test.schema test.twig test.container ## Run all tests in once
test.composer: ## Validate composer.json
${COMPOSER} validate --strict
test.phpstan: ## Run PHPStan
${COMPOSER} phpstan
test.phpmd: ## Run PHPMD
${COMPOSER} phpmd
test.phpunit: ## Run PHPUnit
${COMPOSER} phpunit
test.phpspec: ## Run PHPSpec
${COMPOSER} phpspec
test.phpcs: ## Run PHP CS Fixer in dry-run
${COMPOSER} run -- phpcs --dry-run -v
test.phpcs.fix: ## Run PHP CS Fixer and fix issues if possible
${COMPOSER} run -- phpcs -v
test.container: ## Lint the symfony container
${CONSOLE} lint:container
test.yaml: ## Lint the symfony Yaml files
${CONSOLE} lint:yaml ../../recipes ../../src/Resources/config
test.schema: ## Validate MySQL Schema
${CONSOLE} doctrine:schema:validate
test.twig: ## Validate Twig templates
${CONSOLE} lint:twig --no-debug templates/ ../../src/Resources/views/
###
### SYLIUS
### ¯¯¯¯¯¯
sylius: dependencies sylius.database sylius.fixtures sylius.assets ## Install Sylius
.PHONY: sylius
sylius.database: ## Setup the database
${CONSOLE} doctrine:database:drop --if-exists --force
${CONSOLE} doctrine:database:create --if-not-exists
${CONSOLE} doctrine:migration:migrate -n
sylius.fixtures: ## Run the fixtures
${CONSOLE} sylius:fixtures:load -n default
sylius.assets: ## Install all assets with symlinks
${CONSOLE} assets:install --symlink
${CONSOLE} sylius:install:assets
${CONSOLE} sylius:theme:assets:install --symlink
###
### PLATFORM
### ¯¯¯¯¯¯¯¯
platform: .php-version up ## Setup the platform tools
.PHONY: platform
docker.pull: ## Pull the docker images
cd ${APP_DIR} && ${COMPOSE} pull
docker.up: ## Start the docker containers
cd ${APP_DIR} && ${COMPOSE} up -d
.PHONY: docker.up
docker.stop: ## Stop the docker containers
cd ${APP_DIR} && ${COMPOSE} stop
.PHONY: docker.stop
docker.down: ## Stop and remove the docker containers
cd ${APP_DIR} && ${COMPOSE} down
.PHONY: docker.down
docker.logs: ## Logs the docker containers
cd ${APP_DIR} && ${COMPOSE} logs -f
.PHONY: docker.logs
docker.dc: ARGS=ps
docker.dc: ## Run docker-compose command. Use ARGS="" to pass parameters to docker-compose.
cd ${APP_DIR} && ${COMPOSE} ${ARGS}
.PHONY: docker.dc
server.start: ## Run the local webserver using Symfony
${SYMFONY} local:server:start -d
server.stop: ## Stop the local webserver
${SYMFONY} local:server:stop
###
### HELP
### ¯¯¯¯
help: SHELL=/bin/bash
help: ## Dislay this help
@IFS=$$'\n'; for line in `grep -h -E '^[a-zA-Z_#-]+:?.*?##.*$$' $(MAKEFILE_LIST)`; do if [ "$${line:0:2}" = "##" ]; then \
echo $$line | awk 'BEGIN {FS = "## "}; {printf "\033[33m %s\033[0m\n", $$2}'; else \
echo $$line | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m%s\n", $$1, $$2}'; fi; \
done; unset IFS;
.PHONY: help