Skip to content

Commit bc627a7

Browse files
Xakkisamdark
andauthored
Fix #448: Add grouping to make help output
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
1 parent 8585ae8 commit bc627a7

File tree

3 files changed

+34
-24
lines changed

3 files changed

+34
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 1.2.1 under development
44

55
- Chg #447: Allow symfony/console 8 (@samdark)
6+
- Enh #448: Add grouping to `make` help output (@Xakki, @samdark)
67
- Enh #449: Update composer dependencies and refactor to replace use of deprecated classes (@vjik)
78
- Chg #449: Remove `yiisoft/data-response` dependency (@vjik)
89

Makefile

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,53 +26,57 @@ DOCKER_COMPOSE_TEST := docker compose -f docker/compose.yml -f docker/test/compo
2626
#
2727

2828
ifeq ($(PRIMARY_GOAL),build)
29-
build: ## Build docker images
29+
build: ## Build docker images.
3030
$(DOCKER_COMPOSE_DEV) build $(CLI_ARGS)
3131
endif
3232

3333
ifeq ($(PRIMARY_GOAL),up)
34-
up: ## Up the dev environment
34+
up: ## Up the dev environment.
3535
$(DOCKER_COMPOSE_DEV) up -d --remove-orphans
3636
endif
3737

3838
ifeq ($(PRIMARY_GOAL),down)
39-
down: ## Down the dev environment
39+
down: ## Down the dev environment.
4040
$(DOCKER_COMPOSE_DEV) down --remove-orphans
4141
endif
4242

4343
ifeq ($(PRIMARY_GOAL),stop)
44-
stop: ## Stop the dev environment
44+
stop: ## Stop the dev environment.
4545
$(DOCKER_COMPOSE_DEV) stop
4646
endif
4747

4848
ifeq ($(PRIMARY_GOAL),clear)
49-
clear: ## Remove development docker containers and volumes
49+
clear: ## Remove development docker containers and volumes.
5050
$(DOCKER_COMPOSE_DEV) down --volumes --remove-orphans
5151
endif
5252

5353
ifeq ($(PRIMARY_GOAL),shell)
54-
shell: ## Get into container shell
54+
shell: ## Get into container shell.
5555
$(DOCKER_COMPOSE_DEV) exec app /bin/bash
5656
endif
5757

58+
#
59+
# Tools
60+
#
61+
5862
ifeq ($(PRIMARY_GOAL),yii)
59-
yii: ## Execute Yii command
63+
yii: ## Execute Yii command.
6064
$(DOCKER_COMPOSE_DEV) run --rm app ./yii $(CLI_ARGS)
6165
.PHONY: yii
6266
endif
6367

6468
ifeq ($(PRIMARY_GOAL),composer)
65-
composer: ## Run Composer
69+
composer: ## Run Composer.
6670
$(DOCKER_COMPOSE_DEV) run --rm app composer $(CLI_ARGS)
6771
endif
6872

6973
ifeq ($(PRIMARY_GOAL),rector)
70-
rector: ## Run Rector
74+
rector: ## Run Rector.
7175
$(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/rector $(CLI_ARGS)
7276
endif
7377

7478
ifeq ($(PRIMARY_GOAL),cs-fix)
75-
cs-fix: ## Run PHP CS Fixer
79+
cs-fix: ## Run PHP CS Fixer.
7680
$(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff
7781
endif
7882

@@ -81,27 +85,27 @@ endif
8185
#
8286

8387
ifeq ($(PRIMARY_GOAL),test)
84-
test:
88+
test: ## Run tests.
8589
$(DOCKER_COMPOSE_TEST) run --rm app ./vendor/bin/codecept run $(CLI_ARGS)
8690
endif
8791

8892
ifeq ($(PRIMARY_GOAL),test-coverage)
89-
test-coverage:
93+
test-coverage: ## Run tests with coverage.
9094
$(DOCKER_COMPOSE_TEST) run --rm app ./vendor/bin/codecept run --coverage --coverage-html --disable-coverage-php
9195
endif
9296

9397
ifeq ($(PRIMARY_GOAL),codecept)
94-
codecept: ## Run Codeception
98+
codecept: ## Run Codeception.
9599
$(DOCKER_COMPOSE_TEST) run --rm app ./vendor/bin/codecept $(CLI_ARGS)
96100
endif
97101

98102
ifeq ($(PRIMARY_GOAL),psalm)
99-
psalm: ## Run Psalm
103+
psalm: ## Run Psalm.
100104
$(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/psalm $(CLI_ARGS)
101105
endif
102106

103107
ifeq ($(PRIMARY_GOAL),composer-dependency-analyser)
104-
composer-dependency-analyser: ## Run Composer Dependency Analyser
108+
composer-dependency-analyser: ## Run Composer Dependency Analyser.
105109
$(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/composer-dependency-analyser --config=composer-dependency-analyser.php $(CLI_ARGS)
106110
endif
107111

@@ -110,17 +114,17 @@ endif
110114
#
111115

112116
ifeq ($(PRIMARY_GOAL),prod-build)
113-
prod-build: ## PROD | Build an image
117+
prod-build: ## Build an image.
114118
docker build --file docker/Dockerfile --target prod --pull -t ${IMAGE}:${IMAGE_TAG} .
115119
endif
116120

117121
ifeq ($(PRIMARY_GOAL),prod-push)
118-
prod-push: ## PROD | Push image to repository
122+
prod-push: ## Push image to repository.
119123
docker push ${IMAGE}:${IMAGE_TAG}
120124
endif
121125

122126
ifeq ($(PRIMARY_GOAL),prod-deploy)
123-
prod-deploy: ## PROD | Deploy to production
127+
prod-deploy: ## Deploy to production.
124128
set -euo pipefail \
125129
docker -H ${PROD_SSH} stack deploy --prune --detach=false --with-registry-auth -c docker/compose.yml -c docker/prod/compose.yml ${STACK_NAME} 2>&1 | tee deploy.log \
126130
if grep -qiE 'rollback:|update rolled back' deploy.log then \
@@ -141,7 +145,16 @@ endif
141145
#
142146

143147
ifeq ($(PRIMARY_GOAL),help)
144-
# Output the help for each task, see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
145148
help: ## This help.
146-
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
149+
@awk 'BEGIN { printf "\nUsage:\n make \033[36m<target>\033[0m\n" } \
150+
/^#$$/ { blank = 1; next } \
151+
blank && /^# [a-zA-Z]/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 3); blank = 0; next } \
152+
/^[a-zA-Z_-]+:([^=]|$$)/ { \
153+
split($$0, parts, "##"); \
154+
target = parts[1]; sub(/:.*/, "", target); \
155+
desc = parts[2]; \
156+
gsub(/^[[:space:]]+|[[:space:]]+$$/, "", desc); \
157+
printf " \033[36m%-25s\033[0m %s\n", target, desc; \
158+
blank = 0; \
159+
}' $(MAKEFILE_LIST)
147160
endif

docker/.env

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
STACK_NAME=app
22

3-
#
43
# Development
5-
#
64

75
DEV_PORT=80
86

9-
#
107
# Production
11-
#
128

139
PROD_HOST=app.example.com
1410
PROD_SSH="ssh://docker-web"

0 commit comments

Comments
 (0)