-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile
More file actions
293 lines (243 loc) · 14.9 KB
/
Makefile
File metadata and controls
293 lines (243 loc) · 14.9 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# ------------------------------------------------------------------------------
# Default target: Help
# ------------------------------------------------------------------------------
TEST_LOCALE ?= en
B2B_DOMAIN_ID ?=
B2B_BASE_URL ?=
.DEFAULT_GOAL := help
help: ## Displays list of available commands
@echo ""
@echo "Available commands:"
@echo ""
@awk 'BEGIN {FS = ":.*?## "; printf " %-40s %s\n", "Command", "Description"; printf " %-40s %s\n", "----------------------------------------", "-----------"} /^[a-zA-Z0-9_-]+:.*?## / && !/^_/ { printf " %-40s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
@echo ""
# ------------------------------------------------------------------------------
# Phony targets - declaration of targets that are not files
# ------------------------------------------------------------------------------
.PHONY: help mutagen-up mutagen-up-build mutagen-up-build-no-cache mutagen-stop mutagen-down generate-schema generate-schema-native check-fix php-checks php-lock-icons php-translations \
storefront-checks storefront-translations check-schema run-acceptance-tests-base \
run-acceptance-tests-regression selected-acceptance-tests-base selected-acceptance-tests-regression \
run-specific-test-regression run-specific-test-base \
open-acceptance-tests-base open-acceptance-tests-regression run-smoke-tests \
generate-snapshots-info-table prepare-data-for-acceptance-tests cypress-prepare cypress-cleanup \
check-licenses
# ------------------------------------------------------------------------------
# 🐳 Docker Compose (macOS with Mutagen)
# ------------------------------------------------------------------------------
mutagen-up: ## Starts Docker environment with Mutagen sync (macOS)
./scripts/mutagen-up.sh
mutagen-up-build: ## Starts Docker environment with Mutagen sync and rebuilds images (macOS)
./scripts/mutagen-up.sh --build
mutagen-up-build-no-cache: ## Starts Docker environment with Mutagen sync and rebuilds images without cache (macOS)
./scripts/mutagen-up.sh --build --no-cache
mutagen-stop: ## Stops Docker environment and Mutagen sync, keeps containers (macOS)
./scripts/mutagen-stop.sh
mutagen-down: ## Removes Docker containers and stops Mutagen sync (macOS)
./scripts/mutagen-down.sh
# ------------------------------------------------------------------------------
# 🔧 Generating GraphQL schema and types
# ------------------------------------------------------------------------------
generate-schema: ## Generates GraphQL schema and frontend types (in Docker)
docker compose exec php-fpm php ./bin/console graphql:validate
docker compose exec php-fpm php phing frontend-api-generate-graphql-schema
docker compose cp php-fpm:/var/www/html/schema.graphql /tmp/schema.graphql
docker compose cp /tmp/schema.graphql storefront:/home/node/app/schema.graphql
docker compose exec -u root storefront chown node:node schema.graphql
find storefront/graphql/requests -type f -name "*.generated.tsx" -exec rm {} \;
docker compose exec storefront pnpm run gql
docker compose exec storefront rm -rf /home/node/app/schema.graphql
generate-schema-native: ## Generates GraphQL schema and frontend types (natively)
cd app; php ./bin/console graphql:validate
cd app; php phing frontend-api-generate-graphql-schema
cp app/schema.graphql storefront/schema.graphql
find storefront/graphql/requests -type f -name "*.generated.tsx" -exec rm {} \;
cd storefront; pnpm run gql
rm -rf storefront/schema.graphql
# ------------------------------------------------------------------------------
# ✅ Code Checks and Fixes (PHP and JS/TS)
# ------------------------------------------------------------------------------
check-fix: generate-schema php-checks php-translations storefront-checks storefront-translations storefront-styles-for-admin check-licenses ## Runs all code checks (backend & storefront) and attempts to fix issues
php-checks: ## Runs PHP checks (coding standards, PHPStan) and attempts to fix issues
docker compose exec php-fpm php phing standards-fix phpstan
php-lock-icons: ## Updates the UX icon lock
docker compose exec php-fpm php bin/console ux:icons:lock
php-translations: ## Updates translation files of the backend
docker compose exec php-fpm php phing translations-dump
storefront-checks: ## Runs Storefront (JS/TS) checks and attempts to fix issues
docker compose exec storefront pnpm run check--fix
storefront-translations: ## Updates translation files of the storefront
docker compose exec storefront pnpm run translate
storefront-styles-for-admin: ## Rebuilds the storefront styles for admin
docker compose exec storefront pnpm run compile-tailwind-for-admin
check-schema: ## Checks if generated GraphQL schema is correct
docker compose exec php-fpm php phing frontend-api-generate-graphql-schema
docker compose cp php-fpm:/var/www/html/schema.graphql /tmp/schema.graphql
docker compose cp /tmp/schema.graphql storefront:/home/node/app/schema.graphql
docker compose exec -u root storefront chown node:node schema.graphql
docker compose exec storefront sh check-code-gen.sh
# ------------------------------------------------------------------------------
# 🧪 Testing & Quality Assurance
# ------------------------------------------------------------------------------
define prepare-data-for-acceptance-tests
docker compose exec php-fpm php phing -D production.confirm.action=y -D change.environment=test environment-change
docker compose exec php-fpm php phing test-db-create test-db-demo test-elasticsearch-index-recreate test-elasticsearch-export
endef
define cypress-prepare
docker compose stop storefront
docker compose up -d --wait storefront-cypress --force-recreate
endef
define cypress-cleanup
docker compose stop storefront-cypress
docker compose rm -f storefront-cypress
docker compose up -d storefront
docker compose exec php-fpm php phing -D change.environment=dev environment-change
endef
define run_acceptance_tests
$(call prepare-data-for-acceptance-tests)
$(call cypress-prepare)
@echo "▶️ Running acceptance tests of type $(1)..."
-docker compose run --rm -e TYPE=$(1) -e COMMAND=run -e TEST_LOCALE=$(TEST_LOCALE) -e B2B_DOMAIN_ID=$(B2B_DOMAIN_ID) -e B2B_BASE_URL=$(B2B_BASE_URL) cypress || true
@echo "✅ Acceptance tests of type $(1) finished."
$(call cypress-cleanup)
endef
define selected_acceptance_tests
$(call prepare-data-for-acceptance-tests)
$(call cypress-prepare)
@echo "▶️ Running selected acceptance tests of type $(1)..."
-docker compose run --rm -e TYPE=$(1) -e COMMAND=selected -e TEST_LOCALE=$(TEST_LOCALE) -e B2B_DOMAIN_ID=$(B2B_DOMAIN_ID) -e B2B_BASE_URL=$(B2B_BASE_URL) cypress || true
@echo "✅ Selected acceptance tests of type $(1) finished."
$(call cypress-cleanup)
endef
define run_specific_acceptance_test
$(call prepare-data-for-acceptance-tests)
$(call cypress-prepare)
@echo "▶️ Running specific acceptance test: $(2) of type $(1)..."
docker compose build cypress
-docker compose run --rm -e TYPE=$(1) -e SPEC=$(2) -e TEST_LOCALE=$(TEST_LOCALE) -e B2B_DOMAIN_ID=$(B2B_DOMAIN_ID) -e B2B_BASE_URL=$(B2B_BASE_URL) cypress || true
@echo "✅ Specific acceptance test $(2) of type $(1) finished."
$(call cypress-cleanup)
endef
IS_WSL := $(shell uname -r | grep -i microsoft)
ifeq ($(IS_WSL),)
# MacOS or Linux
get_ip = $(shell ifconfig | awk '/^[a-z0-9]+: /{iface=substr($$1, 1, length($$1)-1)} /status: active/{print iface}' | head -1 | xargs -I {} ifconfig {} | awk '/inet /{print $$2; exit}')
else
# WSL
get_ip = $(shell awk '/nameserver / {print $$2; exit}' /etc/resolv.conf)
endif
define open_acceptance_tests
$(call prepare-data-for-acceptance-tests)
$(call cypress-prepare)
@if [ "$(IS_WSL)" = "" ]; then \
xhost + $(get_ip); \
fi
@echo "▶️ Opening acceptance tests of type $(1)..."
-docker compose run --rm -e TYPE=$(1) -e DISPLAY=$(get_ip):0 -e COMMAND=open -e TEST_LOCALE=$(TEST_LOCALE) -e B2B_DOMAIN_ID=$(B2B_DOMAIN_ID) -e B2B_BASE_URL=$(B2B_BASE_URL) cypress || true
@echo "✅ Acceptance tests of type $(1) finished."
$(call cypress-cleanup)
endef
# Cypress Acceptance Tests
run-acceptance-tests-base: ## Runs the base set of acceptance tests (headless)
$(call run_acceptance_tests,base)
run-acceptance-tests-regression: ## Runs the regression (project-specific) set of acceptance tests (headless)
$(call run_acceptance_tests,regression)
selected-acceptance-tests-base: ## Runs selected base acceptance tests (interactive selection, headless)
$(call selected_acceptance_tests,base)
selected-acceptance-tests-regression: ## Runs selected regression acceptance tests (interactive selection, headless)
$(call selected_acceptance_tests,regression)
run-specific-test-regression: ## Runs a specific regression acceptance test (interactive selection, headless)
@if [ -z "$(SPEC)" ]; then \
echo "❌ Error: SPEC parameter is required. Usage: make run-specific-test-regression SPEC=e2e/filterAndSort/categoryDetailFilterAndSort.cy.ts"; \
exit 1; \
fi
$(call run_specific_acceptance_test,regression,$(SPEC))
run-specific-test-base: ## Runs a specific base acceptance test (interactive selection, headless)
@if [ -z "$(SPEC)" ]; then \
echo "❌ Error: SPEC parameter is required. Usage: make run-specific-test-base SPEC=e2e/filterAndSort/categoryDetailFilterAndSort.cy.ts"; \
exit 1; \
fi
$(call run_specific_acceptance_test,base,$(SPEC))
open-acceptance-tests-base: ## Opens the Cypress GUI for debugging base acceptance tests
$(call open_acceptance_tests,base)
open-acceptance-tests-regression: ## Opens the Cypress GUI for debugging regression acceptance tests
$(call open_acceptance_tests,regression)
run-smoke-tests: ## Runs smoke tests (Cypress)
$(call prepare-data-for-acceptance-tests)
$(call cypress-prepare)
@echo "▶️ Running smoke tests..."
-docker compose run --rm -e TYPE=null -e COMMAND=smoke -e TEST_LOCALE=$(TEST_LOCALE) -e B2B_DOMAIN_ID=$(B2B_DOMAIN_ID) -e B2B_BASE_URL=$(B2B_BASE_URL) cypress || true
@echo "✅ Smoke tests finished."
$(call cypress-cleanup)
# ------------------------------------------------------------------------------
# 📸 Snapshots & Utilities
# ------------------------------------------------------------------------------
generate-snapshots-info-table: ## Generates overview table of Cypress snapshots
$(call prepare-data-for-acceptance-tests)
$(call cypress-prepare)
@echo "▶️ Generating snapshots info table..."
-docker compose exec storefront-cypress npm run generate-snapshots-table --prefix cypress || true
@echo "✅ Snapshots info table generation finished."
$(call cypress-cleanup)
# ------------------------------------------------------------------------------
# 📦 Checking dependencies licenses
# ------------------------------------------------------------------------------
check-licenses: ## Checks dependency licenses in Composer and NPM (php-fpm & storefront)
@echo "🔍 Checking dependency licenses..."
@docker compose exec -T php-fpm bash -lc "scripts/check-licenses.sh" && \
docker compose exec -T storefront sh -lc "sh scripts/check-licenses.sh" && \
echo "✅ All license checks passed"
# ------------------------------------------------------------------------------
# 💅 Compiling Tailwind CSS for admin
# ------------------------------------------------------------------------------
generate-tailwind-for-admin:
@echo "🚀 Compiling Tailwind CSS for admin..."
rm -rf storefront/public/tailwind-for-admin/style.css
mkdir -p storefront/public/tailwind-for-admin
docker compose exec storefront pnpm compile-tailwind-for-admin
@echo "✅ Tailwind CSS compiled to: storefront/public/tailwind-for-admin/style.css"
@echo "🔧 Rebuilding backend admin assets..."
docker compose exec php-fpm php phing npm-dev
@echo "🎉 Admin assets rebuilt! Tailwind classes are now available in GrapesJS."
# ------------------------------------------------------------------------------
# 🎨 Icon Generator for Styleguide
# ------------------------------------------------------------------------------
generate-icons-for-styleguide: ## Generates StyleguideIcons component from all icon files
@echo "🚀 Generating StyleguideIcons component..."
@echo ""
@echo "🗑️ Deleting existing file..."
@rm -f storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@echo "✅ Deleted"
@echo ""
@echo "🔄 Generating new component..."
@echo "/*" > storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@echo " * This file is auto-generated. Do not edit manually." >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@echo " * To regenerate this file, run: make generate-icons-for-styleguide" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@echo " */" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@echo "" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@echo "import { StyleguideSection } from './StyleguideElements';" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@for file in storefront/components/Basic/Icon/*.tsx; do \
name=$$(basename "$$file" .tsx); \
if [ "$$name" != "iconsListGeneratorScript" ]; then \
echo "import { $$name } from 'components/Basic/Icon/$$name';" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx; \
fi \
done
@echo "" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@echo "export const StyleguideIcons = () => (" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@echo " <StyleguideSection title=\"Icons\">" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@echo " <div className=\"grid grid-cols-2 gap-6 md:grid-cols-4 lg:grid-cols-6\">" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@for file in storefront/components/Basic/Icon/*.tsx; do \
name=$$(basename "$$file" .tsx); \
if [ "$$name" != "iconsListGeneratorScript" ]; then \
echo " <div className=\"border-border-less flex flex-col items-center gap-2 rounded-lg border p-4 transition-shadow hover:shadow-md\">" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx; \
echo " <$$name className=\"size-10\" />" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx; \
echo " <span className=\"text-center text-xs break-all\">$$name</span>" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx; \
echo " </div>" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx; \
fi \
done
@echo " </div>" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@echo " </StyleguideSection>" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@echo ");" >> storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx
@echo "✅ Generated $$(ls -1 storefront/components/Basic/Icon/*.tsx | grep -v Script | wc -l | xargs) icons"
@echo ""
@echo "🎉 StyleguideIcons generation complete!"
@echo "📁 File: storefront/components/Pages/Styleguide/StyleguideIcons.generated.tsx"