blob: 755c3aa8ce834cfc90ff7a4a8f258a46fec2c1f3 (
plain)
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
|
PLUGIN := cepis-woocommerce
VERSION := 0.2.0
DIST := dist
ZIP := $(DIST)/$(PLUGIN)-$(VERSION).zip
PHP_LOCAL := $(shell command -v php 2>/dev/null)
ifeq ($(PHP_LOCAL),)
PHP := docker run --rm -v "$(CURDIR)":/app -w /app php:8.3-cli php
else
PHP := $(PHP_LOCAL)
endif
PHPCS := docker run --rm -v "$(CURDIR)":/app -v "$(CURDIR)/.phpcs/vendor":/phpcs -w /app \
php:8.3-cli /phpcs/bin/phpcs --standard=phpcs.xml.dist --no-colors
SOURCES := cepis-woocommerce.php uninstall.php includes lib assets languages LICENSE README.md
.DEFAULT_GOAL := help
.PHONY: help install test lint format build check clean phpcs up down
help:
@echo "targets:"
@echo " test stand the store up and drive the checkout in Chromium"
@echo " lint php -l, prettier --check, and phpcs when installed"
@echo " format apply prettier (writes)"
@echo " build produce $(ZIP)"
@echo " check lint, then test, then build"
@echo " clean remove build output and throw the test containers away"
@echo " phpcs fetch PHP_CodeSniffer and the WordPress standard"
@echo " up start the test store and leave it running"
@echo " down stop the test store"
# node_modules is gitignored, so a fresh clone has no playwright-core and the
# suite dies before the first assertion. Depending on it here is what makes
# `make check` work on a machine that has only just cloned this.
node_modules: package.json
bun install
@touch node_modules
install: node_modules
test: node_modules
sh test/setup.sh
bun test test/checkout.test.js
lint: node_modules
@find . -name '*.php' -not -path './node_modules/*' -not -path './.phpcs/*' -not -path './dist/*' \
| sort | sed 's|^\./||' | xargs -n1 $(PHP) -l >/dev/null
@echo "php -l: no syntax errors"
@bunx prettier --check 'assets/js/cepis-woocommerce-*.js' 'test/*.js'
@if [ -x .phpcs/vendor/bin/phpcs ]; then \
$(PHPCS); \
else \
echo "phpcs: not installed, run 'make phpcs' for the WordPress standard"; \
fi
format:
bunx prettier --write 'assets/js/cepis-woocommerce-*.js' 'test/*.js'
phpcs:
sh tools/install-phpcs.sh
build: clean-dist
@mkdir -p $(DIST)/$(PLUGIN)
@cp -R $(SOURCES) $(DIST)/$(PLUGIN)/
@cd $(DIST) && zip -qr $(PLUGIN)-$(VERSION).zip $(PLUGIN)
@rm -rf $(DIST)/$(PLUGIN)
@unzip -l $(ZIP) | tail -1
@echo "built $(ZIP)"
check: lint test build
up:
sh test/setup.sh
down:
docker compose -f test/compose.yml down
clean: clean-dist
docker compose -f test/compose.yml down -v --remove-orphans 2>/dev/null || true
rm -rf node_modules .phpcs
.PHONY: clean-dist
clean-dist:
@rm -rf $(DIST)
|