-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathmakefile
More file actions
198 lines (166 loc) · 8.65 KB
/
Copy pathmakefile
File metadata and controls
198 lines (166 loc) · 8.65 KB
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
#
# Makefile
#
.PHONY: help prod dev clean build fixtures pr release
.DEFAULT_GOAL := help
PLUGIN_VERSION = $(shell php -r 'echo json_decode(file_get_contents("composer.json"))->version;')
NODE_VERSION:=$(shell node -v)
ifndef nossl
EXPORT_CMD := export NODE_OPTIONS=--openssl-legacy-provider &&
else
EXPORT_CMD :=
endif
help:
@echo ""
@echo "PROJECT COMMANDS"
@echo "--------------------------------------------------------------------------------------------"
@printf "\033[33mInstallation:%-30s\033[0m %s\n"
@grep -E '^[a-zA-Z_-]+:.*?##1 .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?##1 "}; {printf "\033[33m - %-30s\033[0m %s\n", $$1, $$2}'
@echo "--------------------------------------------------------------------------------------------"
@printf "\033[36mDevelopment:%-30s\033[0m %s\n"
@grep -E '^[a-zA-Z_-]+:.*?##2 .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?##2 "}; {printf "\033[36m - %-30s\033[0m %s\n", $$1, $$2}'
@echo "--------------------------------------------------------------------------------------------"
@printf "\033[32mTests:%-30s\033[0m %s\n"
@grep -E '^[a-zA-Z_-]+:.*?##3 .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?##3 "}; {printf "\033[32m - %-30s\033[0m %s\n", $$1, $$2}'
@echo "---------------------------------------------------------------------------------------------------------"
@printf "\033[35mDevOps:%-30s\033[0m %s\n"
@grep -E '^[a-zA-Z_-]+:.*?##4 .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?##4 "}; {printf "\033[35m - %-30s\033[0m %s\n", $$1, $$2}'
# ------------------------------------------------------------------------------------------------------------
prod: ##1 Installs all production dependencies
# ----------------------------------------------------------------
composer validate
composer install --no-dev
cd src/Resources/app/administration && npm install --omit=dev
cd src/Resources/app/storefront && npm install --omit=dev
dev: ##1 Installs all dev dependencies
composer validate
composer install
cd dev && npm install
chmod a+x dev/node_modules/.bin/prettier
cd src/Resources/app/administration && npm install
cd src/Resources/app/storefront && npm install
clean: ##1 Cleans all dependencies and files
rm -rf vendor/*
# ------------------------------------------------------
rm -rf .reports | true
# ------------------------------------------------------
rm -rf ./dev/node_modules/*
rm -rf config-*
rm -rf ./src/Resources/app/administration/node_modules
rm -rf ./src/Resources/app/storefront/node_modules
# ------------------------------------------------------
rm -rf ./src/Resources/app/storefront/dist/storefront
build: ##2 Runs the Shopware theme and asset pipeline (JS assets must be built beforehand via shopware-cli).
rm -rf ../../../public/bundles/molliepayments/administration
cd ../../.. && php bin/console --no-debug theme:refresh
cd ../../.. && php bin/console --no-debug theme:compile
cd ../../.. && php bin/console --no-debug theme:refresh
cd ../../.. && php bin/console --no-debug assets:install
cd ../../.. && php bin/console --no-debug cache:clear
fixtures: ##2 Installs all available testing fixtures of the Mollie plugin
cd ../../.. && php bin/console --no-debug cache:clear
cd ../../.. && php bin/console --no-debug mollie:fixtures:load
pr: ##2 Prepares everything for a Pull Request
# -----------------------------------------------------------------
# FIXERS
@make csfix mode=fix -B
@make eslint mode=fix -B
@make stylelint mode=fix -B
@make prettier mode=fix -B
# -----------------------------------------------------------------
# VALIDATORS
@make phpcheck -B
@make phpmin -B
@make stan -B
@make phpunit -B
@make phpintegration -B
@make behat -B
@make vitest -B
@make configcheck -B
@make phpunuhi -B
snippetexport: ##2 Exports all snippets
php vendor/bin/phpunuhi export --configuration=./config/.phpunuhi.xml --dir=./.phpunuhi
snippetimport: ##2 Imports the provided snippet set [set=xyz file=xz.csv]
php vendor/bin/phpunuhi import --configuration=./config/.phpunuhi.xml --set=$(set) --file=$(file) --intent=1
# ------------------------------------------------------------------------------------------------------------
phpcheck: ##3 Starts the PHP syntax checks
@find . -name '*.php' -not -path "./vendor/*" -not -path "./tests/*" | xargs -n 1 -P4 php -l
phpmin: ##3 Starts the PHP compatibility checks
echo "PHPCompatibility is in alpha right now and has issues with enums"
#@php vendor/bin/phpcs -p --standard=PHPCompatibility --extensions=php --runtime-set testVersion 8.2 ./src ./shopware
csfix: ##3 Starts the PHP CS Fixer
ifndef mode
php vendor/bin/php-cs-fixer fix --config=./config/.php_cs.php --dry-run --show-progress=dots --verbose
endif
ifeq ($(mode), fix)
php vendor/bin/php-cs-fixer fix --config=./config/.php_cs.php --show-progress=dots --verbose
endif
stan: ##3 Starts the PHPStan Analyser
cd ../../.. && php vendor/bin/phpstan analyse -c ./custom/plugins/MolliePayments/config/.phpstan.neon
phpunit: ##3 Starts all PHPUnit Tests
@XDEBUG_MODE=coverage php vendor/bin/phpunit --configuration=./config/phpunit.xml --coverage-html ./.reports/phpunit/coverage
phpintegration: ##3 Starts all PHPUnit Tests [groups=core to limit to a group]
@XDEBUG_MODE=coverage cd ../../.. && php vendor/bin/phpunit --configuration=./custom/plugins/MolliePayments/config/phpunit.integration.xml $(if $(groups),--group $(groups),)
behat:
cd ../../.. && php vendor/bin/behat --config ./custom/plugins/MolliePayments/config/behat.yaml --format progress --colors
insights: ##3 Starts the PHPInsights Analyser
@php vendor/bin/phpinsights analyse --no-interaction
vitest: ##3 Starts all Vitest tests
NODE_PATH=$(CURDIR)/dev/node_modules ./dev/node_modules/.bin/vitest -c ./config/vitest.config.ts
eslint: ##3 Starts the ESLinter
ifndef mode
NODE_PATH=$(CURDIR)/dev/node_modules ./dev/node_modules/.bin/eslint --config ./config/.eslintrc.json ./src/Resources/app
endif
ifeq ($(mode), fix)
NODE_PATH=$(CURDIR)/dev/node_modules ./dev/node_modules/.bin/eslint --config ./config/.eslintrc.json ./src/Resources/app --fix
endif
stylelint: ##3 Starts the Stylelinter
ifndef mode
NODE_PATH=$(CURDIR)/dev/node_modules ./dev/node_modules/.bin/stylelint --allow-empty-input ./src/Resources/app/**/*.scss --config=./config/.stylelintrc
endif
ifeq ($(mode), fix)
NODE_PATH=$(CURDIR)/dev/node_modules ./dev/node_modules/.bin/stylelint --allow-empty-input ./src/Resources/app/**/*.scss --fix --config=./config/.stylelintrc
endif
prettier: ##3 Starts the Prettier
ifndef mode
./dev/node_modules/.bin/prettier ./src/Resources/app/ --config=./config/.prettierrc --check
endif
ifeq ($(mode), fix)
./dev/node_modules/.bin/prettier ./src/Resources/app/ --config=./config/.prettierrc --write
endif
configcheck: ##3 Tests and verifies the plugin configuration file
cd ./tests/Custom && php verify-plugin-config.php
phpunuhi: ##3 Tests and verifies all plugin snippets
php vendor/bin/phpunuhi validate --configuration=./config/.phpunuhi.xml --report-format=junit --report-output=./.phpunuhi/junit.xml
# -------------------------------------------------------------------------------------------------
release: ##4 Builds a PROD version and creates a ZIP file in plugins/.build.
cd .. && rm -rf ./.build/MolliePayments* && mkdir -p ./.build
# An empty node_modules makes shopware-cli skip npm install, producing a ZIP
# without admin assets (broken backend on customer update). Remove it so the
# asset build always installs fresh.
rm -rf ./src/Resources/app/administration/node_modules
rm -rf ./src/Resources/app/storefront/node_modules
docker run --rm \
--user "$(shell id -u):$(shell id -g)" \
-e HOME=/tmp \
-v "$(CURDIR)/..":/plugins \
-v "$(CURDIR)/config/.shopware-extension.yml":/plugins/MolliePayments/.shopware-extension.yml \
-w /plugins/.build \
ghcr.io/shopware/shopware-cli:latest \
extension zip /plugins/MolliePayments --disable-git
# Make the same ZIP work on Shopware 6.5.x as well:
# - 6.6/6.7 load the nested js/<name>/<name>.js (built above via constraint >=6.6.0.0)
# - 6.5 loads the flat js/<name>.js
# The shopware-cli esbuild bundle is byte-identical in both layouts (only the
# output path differs), so we copy the freshly built nested file to the flat
# 6.5 path inside the ZIP instead of running a second build.
cd ../.build && \
ZIP=$$(ls MolliePayments*.zip | head -1) && \
JS=MolliePayments/src/Resources/app/storefront/dist/storefront/js && \
unzip -o -q "$$ZIP" "$$JS/mollie-payments/mollie-payments.js" && \
cp "$$JS/mollie-payments/mollie-payments.js" "$$JS/mollie-payments.js" && \
zip -q "$$ZIP" "$$JS/mollie-payments.js" && \
rm -rf MolliePayments
@echo ""
@echo "CONGRATULATIONS"
@echo "ZIP file available at plugins/.build/"