Skip to content

Commit 1e51d3a

Browse files
authored
Merge pull request #297 from City-of-Helsinki/UHF-11184
UHF-11184: Simplify toolkit
2 parents b38dd23 + 163d578 commit 1e51d3a

22 files changed

+83
-854
lines changed

Makefile

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
11
PHONY :=
22
PROJECT_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
33

4+
# Colors
5+
NO_COLOR=\033[0m
6+
CYAN=\033[36m
7+
GREEN=\033[0;32m
8+
RED=\033[0;31m
9+
YELLOW=\033[0;33m
10+
11+
ENV := local
12+
413
# Include project env vars (if exists)
514
-include .env
615
-include .env.local
716

8-
# Include druidfi/tools config
9-
include $(PROJECT_DIR)/tools/make/Makefile
17+
define step
18+
@printf "\n⭐ ${YELLOW}${1}${NO_COLOR}\n"
19+
endef
20+
21+
PHONY += help
22+
help: ## List all make commands
23+
$(call step,Available make commands:\n)
24+
@cat $(MAKEFILE_LIST) | grep -e "^[a-zA-Z_\-]*: *.*## *" | awk 'BEGIN {FS = ":.*?## "}; {printf "${CYAN}%-30s${NO_COLOR} %s\n", $$1, $$2}'
1025

11-
# Include project specific make files (if they exist)
12-
-include $(PROJECT_DIR)/tools/make/project/*.mk
26+
# Allow projects to specify makefiles.
27+
-include tools/make/project/*.mk
1328

14-
# Project specific overrides for variables (if they exist)
15-
-include $(PROJECT_DIR)/tools/make/override.mk
29+
include tools/make/docker.mk
30+
include tools/make/composer.mk
31+
include tools/make/drupal.mk
32+
include tools/make/git.mk
33+
include tools/make/theme.mk
34+
include tools/make/qa.mk
1635

1736
.PHONY: $(PHONY)

tools/make/Makefile

Lines changed: 0 additions & 48 deletions
This file was deleted.

tools/make/ansible.mk

Lines changed: 0 additions & 35 deletions
This file was deleted.

tools/make/common.mk

Lines changed: 0 additions & 75 deletions
This file was deleted.

tools/make/composer.mk

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
BUILD_TARGETS += composer-install
2-
COMPOSER_PROD_FLAGS := --no-dev --optimize-autoloader --prefer-dist
3-
4-
PHONY += composer-info
5-
composer-info: ## Composer info
6-
$(call step,Do Composer info...\n)
7-
$(call composer,info)
8-
91
PHONY += composer-update
102
composer-update: ## Update Composer packages
113
$(call step,Do Composer update...\n)
@@ -14,19 +6,13 @@ composer-update: ## Update Composer packages
146
PHONY += composer-install
157
composer-install: ## Install Composer packages
168
$(call step,Do Composer install...\n)
17-
$(call composer,install$(if $(filter production,$(ENV)), $(COMPOSER_PROD_FLAGS),))
9+
$(call composer,install)
1810

1911
PHONY += composer-outdated
2012
composer-outdated: ## Show outdated Composer packages
2113
$(call step,Show outdated Composer packages...\n)
2214
$(call composer,outdated --direct)
2315

24-
ifeq ($(RUN_ON),docker)
25-
define composer
26-
$(call docker_compose_exec,composer --ansi$(if $(filter $(COMPOSER_JSON_PATH),.),, --working-dir=$(COMPOSER_JSON_PATH)) $(1))
27-
endef
28-
else
2916
define composer
30-
@composer --ansi$(if $(filter $(COMPOSER_JSON_PATH),.),, --working-dir=$(COMPOSER_JSON_PATH)) $(1)
17+
$(call docker_compose_exec,composer $(1))
3118
endef
32-
endif

tools/make/docker.mk

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
CLI_SERVICE := app
2-
CLI_SHELL := sh
3-
# Note: specification says this file would be compose.yaml
4-
DOCKER_COMPOSE_YML_PATH ?= compose.yaml
5-
DOCKER_COMPOSE_YML_EXISTS := $(shell test -f $(DOCKER_COMPOSE_YML_PATH) && echo yes || echo no)
6-
DOCKER_PROJECT_ROOT ?= /app
7-
DOCKER_WARNING_INSIDE := You are inside the Docker container!
8-
9-
# If docker-compose.yml exists
10-
ifeq ($(DOCKER_COMPOSE_YML_EXISTS),yes)
11-
RUN_ON := docker
12-
endif
13-
14-
PHONY += config
15-
config: ## Show docker-compose config
16-
$(call step,Show Docker Compose config...\n)
17-
$(call docker_compose,config)
18-
191
PHONY += pull
202
pull: ## Pull docker images
213
$(call step,Pull the latest docker images...\n)
@@ -43,43 +25,13 @@ up: ## Launch the environment
4325

4426
PHONY += shell
4527
shell: ## Login to CLI container
46-
ifeq ($(RUN_ON),docker)
47-
$(call docker_compose,exec $(CLI_SERVICE) $(CLI_SHELL))
48-
else
49-
$(call warn,$(DOCKER_WARNING_INSIDE))
50-
endif
51-
52-
PHONY += ssh-check
53-
ssh-check: ## Check SSH keys on CLI container
54-
$(call docker_compose_exec,ssh-add -L)
55-
56-
ifeq ($(RUN_ON),docker)
57-
define docker
58-
@docker $(1) > /dev/null 2>&1 && $(if $(2),echo "$(2)",)
59-
endef
60-
else
61-
define docker
62-
$(call sub_step,$(DOCKER_WARNING_INSIDE))
63-
endef
64-
endif
28+
$(call docker_compose,exec app bash)
6529

66-
ifeq ($(RUN_ON),docker)
67-
define docker_compose_exec
68-
$(call docker_compose,exec$(if $(CLI_USER), -u $(CLI_USER),) $(CLI_SERVICE) $(CLI_SHELL) -c "$(1)")
69-
$(if $(2),@echo "$(2)",)
70-
endef
71-
else
7230
define docker_compose_exec
73-
@$(1) && echo $(2)
31+
$(call docker_compose,exec app bash -c "$(1)")
7432
endef
75-
endif
7633

77-
ifeq ($(RUN_ON),docker)
7834
define docker_compose
79-
@docker compose$(if $(filter $(DOCKER_COMPOSE_YML_PATH),$(DOCKER_COMPOSE_YML_PATH)),, -f $(DOCKER_COMPOSE_YML_PATH)) $(1)
35+
@docker compose $(1)
8036
endef
81-
else
82-
define docker_compose
83-
$(call sub_step,$(DOCKER_WARNING_INSIDE))
84-
endef
85-
endif
37+

0 commit comments

Comments
 (0)