forked from PrestaShop/PrestaShop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
154 lines (114 loc) · 7.76 KB
/
Copy pathMakefile
File metadata and controls
154 lines (114 loc) · 7.76 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
# Executables (local)
DOCKER_COMP = docker compose
DOCKER_AS_WWW = prestashop-git runuser -u www-data -g www-data --
PHP_CONT =
PHP_CONT_WITH_LOGIN = bash
WATCH_CONT = bash
# Determine if we are using docker
DOCKER_RUNNING := $(shell docker compose ps -q 2>/dev/null)
ifneq ($(strip $(DOCKER_RUNNING)),)
PHP_CONT = $(DOCKER_COMP) exec -T $(DOCKER_AS_WWW)
PHP_CONT_WITH_LOGIN = $(DOCKER_COMP) exec -T $(DOCKER_AS_WWW) bash -l
# Watch targets are long lived, and `docker exec` has no signal proxying: Ctrl+C only
# reaches webpack through the pty line discipline inside the container, so a TTY is
# allocated whenever there is one to attach. Without it (CI, IDE tasks) -t would make
# the target fail outright, so we fall back to -i alone -- and there an interrupt kills
# the local client only, leaving the watcher running inside the container.
WATCH_TTY := $(shell [ -t 0 ] && printf %s -it || printf %s -i)
WATCH_CONT = $(DOCKER_COMP) exec $(WATCH_TTY) $(DOCKER_AS_WWW) bash -l
endif
# Executables (local or docker)
PHP = $(PHP_CONT) php
COMPOSER = $(PHP_CONT) composer
SYMFONY = $(PHP_CONT) bin/console
# Misc
.DEFAULT_GOAL = install
.PHONY : help docker-build docker-up docker-start docker-restart docker-down docker-logs docker-sh composer cc test test-unit test-integration test-integration-behaviour test-api-module assets assets-clean wait-assets admin front admin-default admin-new-theme front-core front-classic front-hummingbird watch-admin-default watch-admin-new-theme watch-front-core watch-front-classic watch-front-hummingbird install install-prestashop cs-fixer cs-fixer-dry phpstan scss-fixer es-linter
## —— 🎵 🐳 PrestaShop Docker Makefile 🐳 🎵 ———————————————————————————————————
help: ## Outputs this help screen
@grep -E '(^[a-zA-Z0-9\./_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
## —— Docker 🐳 ————————————————————————————————————————————————————————————————
docker-build: ## Builds the Docker images
COMPOSE_BAKE=true $(DOCKER_COMP) build --pull --no-cache
docker-up: ## Start the docker hub in detached mode (no logs)
$(DOCKER_COMP) up --detach --force-recreate --remove-orphans
docker-start: docker-build docker-up ## Build and start the containers
docker-restart: docker-down docker-start ## Restart the docker hub
docker-down: ## Stop the docker hub
$(DOCKER_COMP) down --remove-orphans
docker-logs: ## Show live logs
$(DOCKER_COMP) logs --follow
docker-sh: ## Connect to the PHP container via bash so up and down arrows go to previous commands
@$(DOCKER_COMP) exec -it prestashop-git runuser -u www-data -g www-data -- bash -l
## —— PrestaShop 🛒 ———————————————————————————————————————————————————————————
install: composer cc assets ## Install PHP dependencies and build the static assets
install-prestashop: ## Install fresh PrestaShop database (requires containers to be running)
$(PHP_CONT) .docker/install/database.sh
## —— Assets 🎨 ———————————————————————————————————————————————————————————————
assets: ## Build all assets
$(PHP_CONT_WITH_LOGIN) ./tools/assets/build.sh all --force
assets-clean: ## Build all assets, forcing a clean reinstall of node_modules
$(PHP_CONT_WITH_LOGIN) ./tools/assets/build.sh all --force-install
wait-assets: ## Wait for assets to be built
$(PHP_CONT_WITH_LOGIN) ./tools/assets/wait-build.sh
admin: ## Build admin assets
$(PHP_CONT_WITH_LOGIN) ./tools/assets/build.sh admin-default --force
$(PHP_CONT_WITH_LOGIN) ./tools/assets/build.sh admin-new-theme --force
front: ## Build front assets
$(PHP_CONT_WITH_LOGIN) ./tools/assets/build.sh front-core --force
$(PHP_CONT_WITH_LOGIN) ./tools/assets/build.sh front-classic --force
$(PHP_CONT_WITH_LOGIN) ./tools/assets/build.sh front-hummingbird --force
admin-default: ## Build assets for default admin theme
$(PHP_CONT_WITH_LOGIN) ./tools/assets/build.sh admin-default --force
admin-new-theme: ## Build assets for new admin theme
$(PHP_CONT_WITH_LOGIN) ./tools/assets/build.sh admin-new-theme --force
front-core: ## Build assets for core theme
$(PHP_CONT_WITH_LOGIN) ./tools/assets/build.sh front-core --force
front-classic: ## Build assets for classic theme
$(PHP_CONT_WITH_LOGIN) ./tools/assets/build.sh front-classic --force
front-hummingbird: ## Build assets for hummingbird theme
$(PHP_CONT_WITH_LOGIN) ./tools/assets/build.sh front-hummingbird --force
# Ctrl+C is the expected way to stop a watch: it surfaces as exit code 130, which is not
# a failure.
watch-admin-default: ## Watch and rebuild assets for default admin theme
$(WATCH_CONT) ./tools/assets/build.sh admin-default --watch || [ $$? -eq 130 ]
watch-admin-new-theme: ## Watch and rebuild assets for new admin theme
$(WATCH_CONT) ./tools/assets/build.sh admin-new-theme --watch || [ $$? -eq 130 ]
watch-front-core: ## Watch and rebuild assets for core theme
$(WATCH_CONT) ./tools/assets/build.sh front-core --watch || [ $$? -eq 130 ]
watch-front-classic: ## Watch and rebuild assets for classic theme
$(WATCH_CONT) ./tools/assets/build.sh front-classic --watch || [ $$? -eq 130 ]
watch-front-hummingbird: ## Watch and rebuild assets for hummingbird theme
$(WATCH_CONT) ./tools/assets/build.sh front-hummingbird --watch || [ $$? -eq 130 ]
## —— Composer & Symfony 🧙 ————————————————————————————————————————————————————
composer: ## Install PHP dependencies
$(COMPOSER) install --no-interaction
cc: ## Clear Symfony cache
$(SYMFONY) cache:clear --no-warmup
## —— Tests 🧪 —————————————————————————————————————————————————————————————————
test: ## Run all tests
$(COMPOSER) run test-all
test-unit: ## Run unit tests
$(COMPOSER) run unit-tests
test-integration: ## Run integration tests
$(COMPOSER) run integration-tests
test-integration-behaviour: ## Run integration behaviour tests
$(COMPOSER) run integration-behaviour-tests
test-api-module: ## Run api module tests
$(COMPOSER) run api-module-tests
## -- Code quality 🧹 ——————————————————————————————————————————————————————————
cs-fixer: ## Run php-cs-fixer
$(COMPOSER) run php-cs-fixer
cs-fixer-dry: ## Run php-cs-fixer with dry-run
$(COMPOSER) run php-cs-fixer:dry
phpstan: ## Run phpstan analysis
$(COMPOSER) run phpstan
scss-fixer: ## Run scss-fix
$(PHP_CONT_WITH_LOGIN) -c "cd admin-dev/themes/new-theme && (test -d node_modules || npm install) && npm run scss-fix"
$(PHP_CONT_WITH_LOGIN) -c "cd admin-dev/themes/default && (test -d node_modules || npm install) && npm run scss-fix"
$(PHP_CONT_WITH_LOGIN) -c "cd themes/classic/_dev && (test -d node_modules || npm install) && npm run scss-fix"
es-linter: ## Run lint-fix
$(PHP_CONT_WITH_LOGIN) -c "cd admin-dev/themes/new-theme && (test -d node_modules || npm install) && npm run lint-fix"
$(PHP_CONT_WITH_LOGIN) -c "cd admin-dev/themes/default && (test -d node_modules || npm install) && npm run lint-fix"
$(PHP_CONT_WITH_LOGIN) -c "cd themes/classic/_dev && (test -d node_modules || npm install) && npm run lint-fix"
$(PHP_CONT_WITH_LOGIN) -c "cd themes && (test -d node_modules || npm install) && npm run lint-fix"