Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

Commit 0bafa03

Browse files
committed
fix: improved Makefile
1 parent 21bc5e4 commit 0bafa03

1 file changed

Lines changed: 38 additions & 35 deletions

File tree

Makefile

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ DOCKER_MDBOOK := docker run --rm -v $$(pwd)/docs/gh-pages:/data -u $$(id -u):$$(
6565
IMPEX_PLUGIN_NAME := cm4all-wp-impex
6666
IMPEX_PLUGIN_DIR := ./plugins/$(IMPEX_PLUGIN_NAME)
6767

68+
# location of the on-the-fly subversion directory used to upload to wordpress.org
69+
WORDPRESS_ORG_SVN_DIR := dist/wordpress.org-svn
70+
# plugin name prefix for the downgraded impex version uploaded at wordpress.org
71+
DOWNGRADED_PLUGIN_DIR := dist/cm4all-wp-impex-php7.4.0
72+
6873
# javascript
6974
SCRIPT_SOURCES := $(wildcard $(IMPEX_PLUGIN_DIR)/src/*.mjs)
7075
SCRIPT_TARGETS := $(subst /src/,/dist/,$(SCRIPT_SOURCES:.mjs=.js))
@@ -87,6 +92,8 @@ DOCS_MARKDOWN_TARGETS := $(patsubst %.md,dist/%.pdf,$(wildcard $(DOCS_MARKDOWN_F
8792
DOCS_MERMAID_FILES := docs/**/*.mmd
8893
DOCS_MERMAID_TARGETS := $(patsubst %.mmd,%.mmd.svg,$(wildcard $(DOCS_MERMAID_FILES)))
8994

95+
.ONESHELL:
96+
9097
.PHONY: all
9198
#HELP: * build sources and spin up wp-env instance
9299
all: $(WP_ENV_HOME) build
@@ -124,14 +131,13 @@ plugins/cm4all-wp-impex/dist/%.js : plugins/cm4all-wp-impex/src/%.mjs
124131
# # development version
125132
# > sass --embed-sources --embed-source-map $< $@
126133

127-
.ONESHELL:
128134
$(WP_ENV_HOME): node_modules
129-
> mkdir -p dist/cm4all-wp-impex-php7.4.0
130-
> cat << EOF > dist/cm4all-wp-impex-php7.4.0/plugin.php
135+
> mkdir -p $(DOWNGRADED_PLUGIN_DIR)
136+
> cat << EOF > $(DOWNGRADED_PLUGIN_DIR)/plugin.php
131137
> <?php
132138
> /**
133139
> * dummy plugin placeholder for wp-env
134-
> * Plugin Name: cm4all-wp-impex-php7.4.0
140+
> * Plugin Name: $$(basename $(DOWNGRADED_PLUGIN_DIR))
135141
> **/
136142
> EOF
137143
# if a executable "Makefile-wp-env.preinit.sh" exists, call it now
@@ -217,7 +223,6 @@ docs/gh-pages/book $(MDBOOK_TARGETS): $(MDBOOK_SOURCES) $(DOCKER_MDBOOK_IMAGE)
217223
HELP: build docs
218224
dist/docs : node_modules $(DOCS_MERMAID_TARGETS) $(DOCS_MARKDOWN_TARGETS) docs/gh-pages/book
219225

220-
.ONESHELL:
221226
dist/cm4all-wp-impex-gh-pages: docs/gh-pages/book/
222227
> rsync -rupE $< $@/
223228

@@ -229,7 +234,6 @@ $(DOCS_MERMAID_TARGETS) : $(DOCS_MERMAID_FILES)
229234
> mkdir -p $(dir $@) && mmdc -i $< -o $@
230235

231236
.PHONY: clean
232-
.ONESHELL:
233237
#HELP: * clean up wp-env and intermediate files
234238
clean:
235239
> if [ -d "$$WP_ENV_HOME" ] && [ -d "node_modules/" ]; then
@@ -392,24 +396,24 @@ wp-env-tests-mysql-shell: $(WP_ENV_HOME) ## open mysql shell connected to wp-env
392396

393397
.PHONY: dist
394398
#HELP: * produce release artifacts
395-
dist: i18n dist/docs dist/cm4all-wp-impex.zip dist/cm4all-wp-impex-example.zip dist/cm4all-wp-impex-gh-pages.zip dist/cm4all-wp-impex-php7.4.0.zip
399+
dist: i18n dist/docs dist/cm4all-wp-impex.zip dist/cm4all-wp-impex-example.zip dist/cm4all-wp-impex-gh-pages.zip $(DOWNGRADED_PLUGIN_DIR).zip
396400
> @touch -m '$@'
397401

398-
dist/cm4all-wp-impex-php7.4.0: dist/cm4all-wp-impex tmp/composer.phar
399-
#HELP: * generate PHP 7.4 flavor of impex plugin
402+
$(DOWNGRADED_PLUGIN_DIR): dist/cm4all-wp-impex tmp/composer.phar
403+
#HELP: * generate downgraded PHP flavor of impex plugin
400404
> mkdir -p '$@'
401405
> rsync -rc dist/cm4all-wp-impex/ $@/
402-
# rename dummy plugin to cm4all-wp-impex-php7.4.0
403-
> sed -i 's/Plugin Name: cm4all-wp-impex/Plugin Name: cm4all-wp-impex-php7.4.0/g' $@/plugin.php
404-
> sed -i 's/Requires PHP: 8.0/Requires PHP: 7.4/' $@/plugin.php
406+
# rename dummy plugin for downgraded plugin variant
407+
> sed -i "s/Plugin Name: cm4all-wp-impex/Plugin Name: $$(basename $(DOWNGRADED_PLUGIN_DIR))/g" $@/plugin.php
408+
> sed -i 's/Requires PHP:[[:space:]]\+8.0/Requires PHP: 7.4/' $@/plugin.php $@/readme.txt
405409
> mkdir -p 'tmp/rector'
406410
> (cd 'tmp/rector' && php ../composer.phar require rector/rector --dev)
407-
# > tmp/rector/vendor/bin/rector --clear-cache --working-dir ./dist/cm4all-wp-impex-php7.4.0 --config ./tmp/rector/vendor/rector/rector/config/set/downgrade-php80.php --no-progress-bar process .
408-
> tmp/rector/vendor/bin/rector --clear-cache --working-dir ./dist/cm4all-wp-impex-php7.4.0 --config ./rector.php --no-progress-bar process .
411+
# > tmp/rector/vendor/bin/rector --clear-cache --working-dir ./$(DOWNGRADED_PLUGIN_DIR) --config ./tmp/rector/vendor/rector/rector/config/set/downgrade-php80.php --no-progress-bar process .
412+
> tmp/rector/vendor/bin/rector --clear-cache --working-dir ./$(DOWNGRADED_PLUGIN_DIR) --config ./rector.php --no-progress-bar process .
409413

410414
.PHONY: deploy-to-wordpress
411415
#HELP: * package and deploy impex plugin to wordpress.org
412-
deploy-to-wordpress: # dist # dist/cm4all-wp-impex-php7.4.0
416+
deploy-to-wordpress:
413417
# see https://github.com/10up/action-wordpress-plugin-deploy/blob/develop/deploy.sh
414418
ifndef SVN_TAG
415419
> $(error "$(@) : SVN_TAG is not set")
@@ -420,36 +424,37 @@ endif
420424
ifndef SVN_PASSWORD
421425
> $(error "$(@) : SVN_PASSWORD is not set")
422426
endif
423-
ifeq ($(wildcard dist/cm4all-wp-impex-php7.4.0), )
424-
> $(error "$(@) : directory dist/cm4all-wp-impex-php7.4.0 doesnt not yet exist. Please run 'make dist' first.")
427+
ifeq ($(wildcard $(DOWNGRADED_PLUGIN_DIR)), )
428+
> $(error "$(@) : directory $(DOWNGRADED_PLUGIN_DIR) doesnt not yet exist. Please run 'make dist' first.")
425429
endif
426430
# next steps requires apt packages ["subversion","librsvg2-bin","imagemagick" (=>convert) to be installed
427431
# checkout just trunk and assets for efficiency
428432
# tagging will be handled on the svn level
429-
> (cd dist && svn checkout --depth immediates https://plugins.svn.wordpress.org/cm4all-wp-impex wordpress.org-svn)
430-
> (cd dist/wordpress.org-svn && svn update --set-depth infinity assets && svn update --set-depth infinity trunk)
431-
> rsync -rc docs/wordpress.org-svn/ dist/wordpress.org-svn/assets/ --delete
433+
> svn checkout --depth immediates https://plugins.svn.wordpress.org/cm4all-wp-impex $(WORDPRESS_ORG_SVN_DIR)
434+
> (cd $(WORDPRESS_ORG_SVN_DIR) && svn update --set-depth infinity assets && svn update --set-depth infinity trunk)
435+
> rsync -rc docs/wordpress.org-svn/ $(WORDPRESS_ORG_SVN_DIR)/assets/ --delete
432436
# create wordpress png icons from svg
433-
> (cd dist/wordpress.org-svn/assets && convert -density 300 -define icon:auto-resize=128 -background none icon.svg icon-128x128.png)
434-
> (cd dist/wordpress.org-svn/assets && convert -density 300 -define icon:auto-resize=256 -background none icon.svg icon-256x256.png)
437+
> (cd $(WORDPRESS_ORG_SVN_DIR)/assets && convert -density 300 -define icon:auto-resize=128 -background none icon.svg icon-128x128.png)
438+
> (cd $(WORDPRESS_ORG_SVN_DIR)/assets && convert -density 300 -define icon:auto-resize=256 -background none icon.svg icon-256x256.png)
435439
# copy plugin to svn
436-
> rsync -rc dist/cm4all-wp-impex-php7.4.0/ dist/wordpress.org-svn/trunk/ --delete
440+
> rsync -rc $(DOWNGRADED_PLUGIN_DIR)/ $(WORDPRESS_ORG_SVN_DIR)/trunk/ --delete
441+
# rename downgraded plugin to original plugin name
442+
> sed -i "s/Plugin Name: $$(basename $(DOWNGRADED_PLUGIN_DIR))/Plugin Name: cm4all-wp-impex/g" $(WORDPRESS_ORG_SVN_DIR)/trunk/plugin.php
437443
# add files to svn
438-
> (cd dist/wordpress.org-svn && svn add . --force)
444+
> (cd $(WORDPRESS_ORG_SVN_DIR) && svn add . --force)
439445
# remove deleted files from svn
440-
> (cd dist/wordpress.org-svn && svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm %@ > /dev/null) || true
446+
> (cd $(WORDPRESS_ORG_SVN_DIR) && svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm %@ > /dev/null) || true
441447
# copy tag locally to make this a single commit
442-
> (cd dist/wordpress.org-svn && svn cp "trunk" "tags/$(SVN_TAG)")
448+
> (cd $(WORDPRESS_ORG_SVN_DIR) && svn cp "trunk" "tags/$(SVN_TAG)")
443449
# fix screenshots getting force downloaded when clicking them
444-
> (cd dist/wordpress.org-svn/assets && find . -maxdepth 1 -name '*.png' -quit -exec svn propset svn:mime-type 'image/png' *.png \; )
445-
> (cd dist/wordpress.org-svn/assets && find . -maxdepth 1 -name '*.jpg' -quit -exec svn propset svn:mime-type 'image/jpeg' *.jpg \; )
446-
> (cd dist/wordpress.org-svn/assets && find . -maxdepth 1 -name '*.ico' -quit -exec svn propset svn:mime-type 'image/x-icon' *.ico \; )
447-
> (cd dist/wordpress.org-svn/assets && find . -maxdepth 1 -name '*.gif' -quit -exec svn propset svn:mime-type 'image/gif' *.gif \; )
448-
> (cd dist/wordpress.org-svn && svn status)
449-
> (cd dist/wordpress.org-svn/assets svn commit -m "Update to version $(SVN_TAG) from GitHub" --no-auth-cache --non-interactive --username "$(SVN_USERNAME)" --password "$(SVN_PASSWORD)"
450+
> (cd $(WORDPRESS_ORG_SVN_DIR)/assets && find . -maxdepth 1 -name '*.png' -quit -exec svn propset svn:mime-type 'image/png' *.png \; )
451+
> (cd $(WORDPRESS_ORG_SVN_DIR)/assets && find . -maxdepth 1 -name '*.jpg' -quit -exec svn propset svn:mime-type 'image/jpeg' *.jpg \; )
452+
> (cd $(WORDPRESS_ORG_SVN_DIR)/assets && find . -maxdepth 1 -name '*.ico' -quit -exec svn propset svn:mime-type 'image/x-icon' *.ico \; )
453+
> (cd $(WORDPRESS_ORG_SVN_DIR)/assets && find . -maxdepth 1 -name '*.gif' -quit -exec svn propset svn:mime-type 'image/gif' *.gif \; )
454+
> (cd $(WORDPRESS_ORG_SVN_DIR) && svn status)
455+
> (cd $(WORDPRESS_ORG_SVN_DIR)/assets && svn commit -m "Update to version $(SVN_TAG) from GitHub" --no-auth-cache --non-interactive --username "$$SVN_USERNAME" --password "$$SVN_PASSWORD")
450456
> echo "$@ tagged svn to $(SVN_TAG)"
451457

452-
453458
.ONESHELL :
454459
dist/cm4all-wp-impex: build
455460
# optimization : create build/[plugin-name] directory and languages subdir at once
@@ -475,7 +480,6 @@ dist/cm4all-wp-impex: build
475480
> envsubst < plugins/cm4all-wp-impex/readme.txt.template > $@/readme.txt
476481
> touch -m $@
477482

478-
.ONESHELL:
479483
dist/cm4all-wp-impex-example: build
480484
> mkdir -p '$@'
481485
> rsync -rupE plugins/cm4all-wp-impex-example/{plugin.php,inc} $@/
@@ -489,7 +493,6 @@ dist/%.zip: dist/%
489493

490494
# see https://gist.github.com/Olshansk/689fc2dee28a44397c6e31a0776ede30
491495
.PHONY: help
492-
.ONESHELL:
493496
#HELP: * prints this screen
494497
help:
495498
> @printf "Available targets\n\n"

0 commit comments

Comments
 (0)