-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
139 lines (99 loc) · 4.89 KB
/
Makefile
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
UNAME := $(shell uname)
comma := ,
datetime := $(shell date +"%Y%m%d%H%M%S")
AUTOLOAD = vendor/autoload.php
THEME_NAME =
PLUGIN_NAME = player-for-web-pure-data-patches
THEME_FOLDER = public/wp-content/themes/$(THEME_NAME)
PLUGIN_FOLDER = public/wp-content/plugins/$(PLUGIN_NAME)
CERTS_DIR = .certs
DOCKER_COMPOSE = docker-compose
DOCKER_COMPOSE_FLAGS = -f docker/docker-compose.yaml -f docker/docker-compose-dev.yaml --env-file docker/.env
MKCERT = mkcert
docker-compose = $(DOCKER_COMPOSE) $(DOCKER_COMPOSE_FLAGS) $1
docker-exec = $(call docker-compose,exec -T app /bin/bash -c "$1")
ifeq ($(shell docker ps | grep "app" -c),1)
wp-core-version = $(shell $(call docker-exec,wp core version --allow-root --path=/srv/app/public/wp))
endif
.PHONY: up composer build halt destroy ssh certs provision composer-install \
composer-normalize phpstan php-cs-fixer php-cs phpunit phpunit-coverage lint-twig database
# Docker
up: compose $(AUTOLOAD)
compose: $(CERTS_DIR)
ifeq ($(UNAME), Darwin)
SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock $(call docker-compose,up -d)
else
$(call docker-compose,up -d)
endif
build: halt
$(call docker-compose,build)
halt:
$(call docker-compose,stop)
destroy:
$(call docker-compose,down --remove-orphans)
ssh:
$(call docker-compose,exec app /bin/bash)
$(CERTS_DIR):
$(MAKE) certs
certs:
mkdir -p $(CERTS_DIR)
$(MKCERT) -install
$(MKCERT) -cert-file $(CERTS_DIR)/certificate.pem -key-file $(CERTS_DIR)/certificate-key.pem localhost
# App
$(AUTOLOAD):
$(MAKE) provision
provision: composer-install public/wp/installed $(PLUGIN_FOLDER)/tests/bootstrap.php database
composer-init-plugin-$(PLUGIN_NAME):
$(call docker-exec,composer init -d $(PLUGIN_FOLDER))
composer-install-plugin-$(PLUGIN_NAME):
$(call docker-exec,composer install -d $(PLUGIN_FOLDER) --optimize-autoloader)
composer-install-plugin-$(PLUGIN_NAME)-for-deploy:
$(call docker-exec,composer install -d $(PLUGIN_FOLDER) --prefer-dist --classmap-authoritative --no-progress --no-interaction --no-dev)
composer-outdated-plugin-$(PLUGIN_NAME):
$(call docker-exec,composer outdated -d $(PLUGIN_FOLDER) --direct)
composer-update-plugin-$(PLUGIN_NAME):
$(call docker-exec,composer update -d $(PLUGIN_FOLDER) --optimize-autoloader --prefer-source)
composer-dump-autoload-plugin-$(PLUGIN_NAME):
$(call docker-exec,composer dump-autoload -d $(PLUGIN_FOLDER))
composer-normalize-plugin-$(PLUGIN_NAME):
$(call docker-exec,composer normalize -d $(PLUGIN_FOLDER))
composer-install:
$(call docker-exec,composer install --optimize-autoloader)
composer-install-for-deploy:
$(call docker-exec,composer install --prefer-dist --classmap-authoritative --no-progress --no-interaction --no-dev)
composer-outdated:
$(call docker-exec,composer outdated --direct)
composer-update:
$(call docker-exec,composer update --optimize-autoloader --prefer-source)
composer-normalize:
$(call docker-exec,composer normalize)
phpstan:
$(call docker-exec,composer phpstan)
psalm:
$(call docker-exec,composer psalm)
php-cs-fixer:
$(call docker-exec,composer phpcbf)
php-cs:
$(call docker-exec,composer phpcs)
$(THEME_FOLDER)/tests/bootstrap.php:
$(call docker-exec,wp scaffold theme-tests $(THEME_NAME) --allow-root --path=public/wp)
$(PLUGIN_FOLDER)/tests/bootstrap.php:
$(call docker-exec,wp scaffold plugin-tests $(PLUGIN_NAME) --allow-root --path=public/wp)
$(PLUGIN_FOLDER)/tests_installed_$(wp-core-version):
$(call docker-exec,cd $(PLUGIN_FOLDER) && bash bin/install-wp-tests.sh wordpress_test_$(wp-core-version)_plugin_$(PLUGIN_NAME) root root mysql $(wp-core-version) && touch tests_installed_$(wp-core-version))
phpunit-plugin-$(PLUGIN_NAME): $(PLUGIN_FOLDER)/tests_installed_$(wp-core-version)
$(call docker-exec,cd $(PLUGIN_FOLDER) && bash bin/install-wp-tests.sh wordpress_test_$(wp-core-version)_plugin_$(PLUGIN_NAME) root root mysql $(wp-core-version) true)
$(call docker-exec,cd $(PLUGIN_FOLDER) && phpunit)
$(THEME_FOLDER)/tests_installed_$(wp-core-version):
$(call docker-exec,cd $(THEME_FOLDER) && bash bin/install-wp-tests.sh wordpress_test_$(wp-core-version)_theme_$(THEME_NAME) root root mysql $(wp-core-version) && touch tests_installed_$(wp-core-version))
phpunit-theme-$(THEME_NAME): $(THEME_FOLDER)/tests_installed_$(wp-core-version)
$(call docker-exec,cd $(THEME_FOLDER) && bash bin/install-wp-tests.sh wordpress_test_$(wp-core-version)_theme_$(THEME_NAME) root root mysql $(wp-core-version) true)
$(call docker-exec,cd $(THEME_FOLDER) && phpunit)
phpunit: phpunit-plugin-$(PLUGIN_NAME)
lint-twig:
$(call docker-exec,composer lint-twig)
database:
#$(call docker-exec,wp search-replace 'http://localhost' 'https://localhost:8443' --allow-root --path=/srv/app/public/wp)
public/wp/installed:
$(call docker-exec,wp core install --url=localhost:8443 --title='Wordpress Archetype' --admin_user=wordpress --admin_password=wordpress [email protected] --allow-root --path=public/wp)
$(call docker-exec,touch public/wp/installed)