Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
162 lines (117 loc) · 5.04 KB
/
Copy pathMakefile
File metadata and controls
162 lines (117 loc) · 5.04 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
COMPOSE ?= docker compose
PLUGIN_CONTAINER_DIR := /plugin-source
RELEASE_ARCHIVE := release/development-assistant.zip
WPORG_RELEASE_SCRIPT := ./scripts/wporg-release.sh
GITHUB_RELEASE_SCRIPT := ./scripts/github-release.sh
.PHONY: init setup env dependencies composer-install node-install assets up down restart reinit cert trust-cert wp-core wp-core-update logs ps shell wp db-shell db-backup db-restore db-backups sync-env xdebug-on xdebug-off xdebug-status composer-update start-watch build-src dist-archive create-release-zip version-sync version-check github-release wporg-checkout wporg-update wporg-release wporg-status wporg-diff wporg-assets-publish fix lint test
init: setup
setup: env dependencies node-install build-src cert wp-core
env:
@if [ ! -f .env ]; then cp .env.example .env; echo "Created .env from .env.example."; fi
dependencies: composer-install
composer-install:
$(COMPOSE) --profile tools run --rm --no-deps composer install
node-install:
NVM_DIR="$${HOME}/.nvm" && . "$${NVM_DIR}/nvm.sh" && nvm use && npm install
assets:
@if [ ! -d node_modules ]; then $(MAKE) node-install; fi
@if [ ! -d assets ]; then $(MAKE) build-src; fi
up: env cert wp-core composer-install assets
$(COMPOSE) up -d --build
down:
$(COMPOSE) down
restart: env cert wp-core composer-install assets
$(COMPOSE) up -d --build --force-recreate
reinit: env cert wp-core composer-install assets
./scripts/db-backup.sh before-reinit
$(COMPOSE) down --remove-orphans
@project="$${COMPOSE_PROJECT_NAME:-$$(basename "$$(pwd)")}" ; \
volume="$$(docker volume ls -q --filter label=com.docker.compose.project=$$project --filter label=com.docker.compose.volume=db_data)" ; \
if [ -z "$$volume" ] && docker volume inspect "$${project}_db_data" >/dev/null 2>&1; then \
volume="$${project}_db_data" ; \
fi ; \
if [ -n "$$volume" ]; then \
echo "Removing database volume: $$volume" ; \
docker volume rm $$volume ; \
else \
echo "Database volume db_data does not exist yet." ; \
fi
$(COMPOSE) up -d --build --force-recreate
cert:
./scripts/generate-local-cert.sh docker/certs
trust-cert:
mkcert -install
wp-core:
@if [ -f wp/wp-includes/version.php ]; then echo "WordPress runtime is already initialized."; else ./scripts/update-wp-core.sh wp; fi
wp-core-update:
./scripts/update-wp-core.sh wp
logs:
$(COMPOSE) logs -f
ps:
$(COMPOSE) ps
shell:
$(COMPOSE) exec wordpress bash
wp:
$(COMPOSE) run --rm wp-cli $(cmd)
db-shell:
$(COMPOSE) exec db sh -lc 'mariadb -u root -p"$${MARIADB_ROOT_PASSWORD}"'
db-backup:
./scripts/db-backup.sh "$(label)"
db-restore:
@if [ -z "$(file)" ]; then echo "Usage: make db-restore file=backups/db/YYYY-MM-DD-HHMMSS-db.sql.gz"; exit 1; fi
./scripts/db-restore.sh "$(file)"
db-backups:
@find backups/db -maxdepth 1 -type f \( -name '*.sql' -o -name '*.sql.gz' \) | sort
sync-env:
$(COMPOSE) run --rm wp-cli sh /usr/local/bin/sync-wp-env.sh
xdebug-on:
./scripts/set-xdebug-mode.sh debug,develop
$(COMPOSE) up -d --build wordpress
xdebug-off:
./scripts/set-xdebug-mode.sh off
$(COMPOSE) up -d --build wordpress
xdebug-status:
@grep -E '^XDEBUG_MODE=' .env 2>/dev/null || echo 'XDEBUG_MODE is not set; default is off.'
@$(COMPOSE) exec wordpress php -i | grep -E 'xdebug.mode|xdebug.start_with_request|xdebug.client_host|xdebug.client_port' || true
composer-update:
$(COMPOSE) --profile tools run --rm --no-deps composer update
start-watch:
NVM_DIR="$${HOME}/.nvm" && . "$${NVM_DIR}/nvm.sh" && nvm use && npm run start
build-src:
NVM_DIR="$${HOME}/.nvm" && . "$${NVM_DIR}/nvm.sh" && nvm use && npm run build
dist-archive:
$(RM) "$(RELEASE_ARCHIVE)"
$(COMPOSE) --profile tools run --rm --no-deps --build \
--user "$$(id -u):$$(id -g)" wp-cli-release \
dist-archive "$(PLUGIN_CONTAINER_DIR)" "$(PLUGIN_CONTAINER_DIR)/$(RELEASE_ARCHIVE)" \
--create-target-dir \
--force \
--plugin-dirname=development-assistant
create-release-zip: composer-install lint build-src
./scripts/with-production-dependencies.sh $(MAKE) dist-archive
version-sync:
NVM_DIR="$${HOME}/.nvm" && . "$${NVM_DIR}/nvm.sh" && nvm use && node ./scripts/sync-version.mjs
version-check:
NVM_DIR="$${HOME}/.nvm" && . "$${NVM_DIR}/nvm.sh" && nvm use && npm run version:check
github-release: create-release-zip
NVM_DIR="$${HOME}/.nvm" && . "$${NVM_DIR}/nvm.sh" && nvm use && $(GITHUB_RELEASE_SCRIPT)
wporg-checkout:
$(WPORG_RELEASE_SCRIPT) checkout
wporg-update:
$(WPORG_RELEASE_SCRIPT) update
wporg-release: create-release-zip
$(WPORG_RELEASE_SCRIPT) release
wporg-status:
$(WPORG_RELEASE_SCRIPT) status
wporg-diff:
$(WPORG_RELEASE_SCRIPT) diff
wporg-assets-publish:
WPORG_CONFIRM="$(confirm)" $(WPORG_RELEASE_SCRIPT) publish-assets
fix: composer-install
./scripts/run-composer.sh run fix
NVM_DIR="$${HOME}/.nvm" && . "$${NVM_DIR}/nvm.sh" && nvm use && npm run fix-style && npm run fix-script
lint: composer-install
./scripts/run-composer.sh run lint
NVM_DIR="$${HOME}/.nvm" && . "$${NVM_DIR}/nvm.sh" && nvm use && npm run version:check && npm run lint-style && npm run lint-script && npm run typecheck
test: wp-core composer-install
COMPOSE="$(COMPOSE)" ./scripts/run-phpunit.sh