-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
165 lines (128 loc) · 6.2 KB
/
Copy pathMakefile
File metadata and controls
165 lines (128 loc) · 6.2 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
163
164
165
# Password Strength Bundle - Development
.PHONY: help up down build shell install test test-coverage coverage-check coverage-php-percent cs-check cs-fix qa clean assets assets-build assets-watch assets-test test-ts ensure-up rector rector-dry phpstan release-check release-check-demos demo-smoke composer-sync update validate validate-translations check-no-cursor-coauthor check-open-prs strip-cursor-coauthor-from-history check-twig-extra
COMPOSE_FILE ?= docker-compose.yml
# Prefer Compose V2 plugin (GitHub Actions / modern Docker Desktop); fall back to docker-compose V1 (REQ-MAKE-010).
COMPOSE_BIN ?= $(shell docker compose version >/dev/null 2>&1 && echo "docker compose" || echo "docker-compose")
COMPOSE ?= $(COMPOSE_BIN) -f $(COMPOSE_FILE)
SERVICE_PHP ?= php
help:
@echo "Password Strength Bundle - Development Commands"
@echo ""
@echo " up Start Docker container"
@echo " down Stop Docker container"
@echo " build Rebuild Docker image (no cache)"
@echo " shell Open shell in container"
@echo " install Install Composer + pnpm dependencies"
@echo " assets Build TypeScript (pnpm install + pnpm run build)"
@echo " assets-build Alias for assets"
@echo " assets-watch Watch and rebuild TS on change"
@echo " test-ts Run TypeScript (Vitest) unit tests"
@echo " assets-test Alias of test-ts"
@echo " test Run PHPUnit tests"
@echo " test-coverage Run tests with code coverage"
@echo " cs-check / cs-fix Code style"
@echo " rector / rector-dry Rector"
@echo " phpstan Static analysis"
@echo " qa cs-check + test"
@echo " release-check Pre-release checks"
@echo " composer-sync Validate and align composer.lock"
@echo " clean Remove vendor and cache"
@echo " update / validate Composer"
@echo ""
@echo "Demos: make -C demo/symfony7 or make -C demo/symfony8"
build:
$(COMPOSE) build --no-cache
up:
$(COMPOSE) build
$(COMPOSE) up -d
@sleep 3
$(COMPOSE) exec -T $(SERVICE_PHP) composer install --no-interaction
$(COMPOSE) exec -T -e CI=true $(SERVICE_PHP) pnpm install
@echo "Container ready."
down:
$(COMPOSE) down
ensure-up:
@if ! $(COMPOSE) exec -T $(SERVICE_PHP) true 2>/dev/null; then \
$(COMPOSE) up -d; sleep 3; \
$(COMPOSE) exec -T $(SERVICE_PHP) composer install --no-interaction; \
$(COMPOSE) exec -T -e CI=true $(SERVICE_PHP) pnpm install; \
fi
shell:
$(COMPOSE) exec $(SERVICE_PHP) sh
install: ensure-up
$(COMPOSE) exec -T $(SERVICE_PHP) composer install
$(COMPOSE) exec -T -e CI=true $(SERVICE_PHP) pnpm install
assets: ensure-up
$(COMPOSE) exec -T -e CI=true $(SERVICE_PHP) pnpm install
$(COMPOSE) exec -T $(SERVICE_PHP) pnpm run build
@echo "Assets built (src/Resources/public/password-strength.js)."
assets-build: assets
assets-watch: ensure-up
$(COMPOSE) exec $(SERVICE_PHP) pnpm run watch
# TypeScript/Vitest tests (bundle has TS)
test-ts: ensure-up
$(COMPOSE) exec -T -e CI=true $(SERVICE_PHP) pnpm install --no-frozen-lockfile 2>/dev/null || true
$(COMPOSE) exec -T $(SERVICE_PHP) pnpm run test:coverage | tee coverage-ts.txt
sh .scripts/ts-coverage-percent.sh coverage-ts.txt
assets-test: test-ts
test: ensure-up
$(COMPOSE) exec -T $(SERVICE_PHP) composer install --no-interaction
$(COMPOSE) exec $(SERVICE_PHP) composer test
test-coverage: ensure-up
$(COMPOSE) exec -T $(SERVICE_PHP) composer install --no-interaction
$(COMPOSE) exec $(SERVICE_PHP) sh -c 'set -o pipefail; composer test-coverage | tee coverage-php.txt'
sh .scripts/php-coverage-percent.sh coverage-php.txt
coverage-check: test-coverage
@chmod +x .scripts/coverage-fail-under.sh
@./.scripts/coverage-fail-under.sh coverage-php.txt 99
cs-check: ensure-up
$(COMPOSE) exec -T $(SERVICE_PHP) composer cs-check
cs-fix: ensure-up
$(COMPOSE) exec -T $(SERVICE_PHP) composer cs-fix
rector: ensure-up
$(COMPOSE) exec -T $(SERVICE_PHP) composer rector
rector-dry: ensure-up
$(COMPOSE) exec -T $(SERVICE_PHP) composer rector-dry
phpstan: ensure-up
$(COMPOSE) exec -T $(SERVICE_PHP) composer phpstan
validate-translations: ensure-up
$(COMPOSE) exec -T $(SERVICE_PHP) sh -c 'for f in src/Resources/translations/*.yaml; do php -r "require \"vendor/autoload.php\"; Symfony\\Component\\Yaml\\Yaml::parseFile(\$$argv[1]);" "$$f" || exit 1; done'
qa: ensure-up
$(COMPOSE) exec -T $(SERVICE_PHP) composer qa
composer-sync: ensure-up
$(COMPOSE) exec -T $(SERVICE_PHP) composer validate --strict
$(COMPOSE) exec -T $(SERVICE_PHP) composer update --no-install
check-open-prs:
@chmod +x .scripts/check-open-prs.sh
@GH_REPO=nowo-tech/PasswordStrengthBundle ./.scripts/check-open-prs.sh
demo-smoke:
@if [ -f demo/Makefile ]; then $(MAKE) -C demo release-verify; else echo "No demo/Makefile"; exit 1; fi
check-twig-extra:
@chmod +x .scripts/check-twig-extra.sh
@./.scripts/check-twig-extra.sh
release-check: check-no-cursor-coauthor check-open-prs check-twig-extra ensure-up composer-sync cs-fix cs-check rector-dry phpstan validate-translations coverage-check release-check-demos test-ts
release-check-demos:
@$(MAKE) -C demo release-check
clean:
rm -rf vendor node_modules .phpunit.cache coverage .php-cs-fixer.cache
update: ensure-up
$(COMPOSE) exec -T $(SERVICE_PHP) composer update --no-interaction
validate: ensure-up
$(COMPOSE) exec -T $(SERVICE_PHP) composer validate --strict
setup-hooks:
@chmod +x .githooks/pre-commit 2>/dev/null || true
@chmod +x .githooks/commit-msg 2>/dev/null || true
@git config core.hooksPath .githooks
@echo "✅ Git hooks installed (.githooks — includes commit-msg for REQ-GIT-001)."
# REQ-MAKE-008: update-deps (REQ-MAKE-008)
BUNDLE_ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
# Optional: monorepo helper absent on standalone GitHub Actions checkout (REQ-MAKE-009).
-include $(BUNDLE_ROOT)/../.scripts/Makefile.update-deps.mk
check-no-cursor-coauthor:
@chmod +x .scripts/check-no-cursor-coauthor.sh
@./.scripts/check-no-cursor-coauthor.sh HEAD
strip-cursor-coauthor-from-history:
@chmod +x .scripts/strip-cursor-coauthor-from-history.sh
@./.scripts/strip-cursor-coauthor-from-history.sh main
twig-lint: ensure-up
@$(COMPOSE) exec -T $(SERVICE_PHP) composer twig:lint || $(COMPOSE) exec -T $(SERVICE_PHP) ./vendor/bin/twig-cs-fixer lint --config=.twig-cs-fixer.php