Skip to content

Commit 3823ae2

Browse files
committed
Release v1.4.0: Twig Extra (REQ-TWIG-004) and Twig-CS-Fixer.
1 parent df3e737 commit 3823ae2

18 files changed

Lines changed: 1024 additions & 338 deletions

.scripts/check-open-prs.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
# Fail if the GitHub repo has unresolved open pull requests (REQ-REL-003).
33
# Allowed temporary exceptions: label hold|do-not-merge AND a future review-by ISO date
4-
# in the PR body (or first few comments are not fetched; body must carry the date).
4+
# in the PR body (body must carry the date).
55
set -euo pipefail
66

77
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
@@ -22,7 +22,26 @@ if ! command -v python3 >/dev/null 2>&1; then
2222
exit 1
2323
fi
2424

25-
PRS_JSON="$(gh pr list --state open --limit 100 --json number,title,labels,body,url)"
25+
# Resolve owner/name for -R (works when SSH remotes confuse `gh` default repo detection).
26+
resolve_repo() {
27+
local url owner_repo
28+
if url="$(git remote get-url origin 2>/dev/null)"; then
29+
# git@github.com:org/repo.git | https://github.com/org/repo.git
30+
owner_repo="$(printf '%s\n' "${url}" | sed -E 's#^(git@github\.com:|https://github\.com/)##; s#\.git$##')"
31+
if [[ "${owner_repo}" == */* ]]; then
32+
printf '%s\n' "${owner_repo}"
33+
return 0
34+
fi
35+
fi
36+
return 1
37+
}
38+
39+
REPO_ARGS=()
40+
if REPO="$(resolve_repo)"; then
41+
REPO_ARGS=(-R "${REPO}")
42+
fi
43+
44+
PRS_JSON="$(gh pr list "${REPO_ARGS[@]}" --state open --limit 100 --json number,title,labels,body,url)"
2645

2746
export PRS_JSON
2847
python3 <<'PY'
@@ -38,7 +57,6 @@ if not prs:
3857
sys.exit(0)
3958
4059
HOLD_LABELS = {"hold", "do-not-merge"}
41-
# review-by: 2026-09-01 | review_by: 2026-09-01 | review-by 2026-09-01
4260
REVIEW_BY_RE = re.compile(
4361
r"(?i)\breview[-_ ]?by\b\s*[:=]?\s*(\d{4}-\d{2}-\d{2})"
4462
)

.scripts/check-twig-extra.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
# REQ-TWIG-004 — fail when Twig applies but twig/extra-bundle (and demos) are not ready.
3+
set -euo pipefail
4+
5+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6+
cd "$ROOT"
7+
8+
has_twig=0
9+
if find src -type f -name '*.twig' 2>/dev/null | grep -q .; then
10+
has_twig=1
11+
elif find templates Resources -type f -name '*.twig' 2>/dev/null | grep -q .; then
12+
has_twig=1
13+
fi
14+
15+
if [[ "$has_twig" -eq 0 ]]; then
16+
echo "check-twig-extra: Twig does not apply (no templates) — OK"
17+
exit 0
18+
fi
19+
20+
fail=0
21+
22+
if ! grep -q '"twig/extra-bundle"' composer.json; then
23+
echo "ERROR: twig/extra-bundle missing from package composer.json require (REQ-TWIG-004)" >&2
24+
fail=1
25+
fi
26+
27+
if ! grep -q '"twig/string-extra"' composer.json; then
28+
echo "ERROR: twig/string-extra missing from package composer.json require (REQ-TWIG-004 baseline)" >&2
29+
fail=1
30+
fi
31+
32+
shopt -s nullglob
33+
for demo_composer in demo/*/composer.json demo/*/*/composer.json; do
34+
[[ -f "$demo_composer" ]] || continue
35+
demo_dir="$(dirname "$demo_composer")"
36+
# Skip demos that never render Twig (no bundles.php / no twig)
37+
bundles_php="$demo_dir/config/bundles.php"
38+
if [[ ! -f "$bundles_php" ]]; then
39+
continue
40+
fi
41+
if ! grep -q 'TwigBundle' "$bundles_php" 2>/dev/null; then
42+
continue
43+
fi
44+
if ! grep -q '"twig/extra-bundle"' "$demo_composer"; then
45+
echo "ERROR: $demo_composer missing twig/extra-bundle (REQ-TWIG-004)" >&2
46+
fail=1
47+
fi
48+
if ! grep -q 'Twig\\\\Extra\\\\TwigExtraBundle\\\\TwigExtraBundle' "$bundles_php" \
49+
&& ! grep -q 'Twig\\Extra\\TwigExtraBundle\\TwigExtraBundle' "$bundles_php"; then
50+
echo "ERROR: $bundles_php missing TwigExtraBundle (REQ-TWIG-004)" >&2
51+
fail=1
52+
fi
53+
done
54+
55+
if [[ "$fail" -ne 0 ]]; then
56+
exit 1
57+
fi
58+
59+
echo "check-twig-extra: OK"

.twig-cs-fixer.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use TwigCsFixer\Config\Config;
6+
use TwigCsFixer\File\Finder;
7+
use TwigCsFixer\Ruleset\Ruleset;
8+
use TwigCsFixer\Standard\TwigCsFixer;
9+
10+
$paths = [];
11+
foreach ([__DIR__ . '/src', __DIR__ . '/templates'] as $path) {
12+
if (is_dir($path)) {
13+
$paths[] = $path;
14+
}
15+
}
16+
17+
$finder = new Finder();
18+
foreach ($paths as $path) {
19+
$finder->in($path);
20+
}
21+
$finder->exclude(['vendor', 'var', 'node_modules', 'coverage', 'demo']);
22+
23+
$ruleset = new Ruleset();
24+
$ruleset->addStandard(new TwigCsFixer());
25+
26+
$config = new Config();
27+
$config->setRuleset($ruleset);
28+
$config->setFinder($finder);
29+
30+
return $config;

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# CKEditor 5 Editor Bundle — development (Docker + pnpm + PHPUnit).
2-
.PHONY: help up down build shell install test test-coverage coverage-php-percent cs-check cs-fix qa clean assets assets-build assets-watch test-ts ensure-up rector rector-dry phpstan release-check release-check-demos composer-sync update validate validate-translations check-no-cursor-coauthor check-open-prs demo-smoke strip-cursor-coauthor-from-history setup-hooks
2+
.PHONY: help up down build shell install test test-coverage coverage-php-percent cs-check cs-fix qa clean assets assets-build assets-watch test-ts ensure-up rector rector-dry phpstan release-check release-check-demos composer-sync update validate validate-translations check-no-cursor-coauthor check-open-prs demo-smoke strip-cursor-coauthor-from-history setup-hooks check-twig-extra
33

44
COMPOSE_FILE ?= docker-compose.yml
55
# Prefer Compose V2 plugin (GitHub Actions / modern Docker Desktop); fall back to docker-compose V1 (REQ-MAKE-010).
@@ -116,7 +116,11 @@ setup-hooks:
116116
@git config core.hooksPath .githooks
117117
@echo "Git hooks installed (.githooks — includes commit-msg for REQ-GIT-001)."
118118

119-
release-check: check-no-cursor-coauthor check-open-prs ensure-up composer-sync cs-fix cs-check rector-dry phpstan test-coverage test-ts release-check-demos
119+
120+
check-twig-extra:
121+
@chmod +x .scripts/check-twig-extra.sh
122+
@./.scripts/check-twig-extra.sh
123+
release-check: check-no-cursor-coauthor check-open-prs check-twig-extra ensure-up composer-sync cs-fix cs-check rector-dry phpstan test-coverage test-ts release-check-demos
120124

121125
release-check-demos:
122126
@if [ -d demo ]; then $(MAKE) -C demo release-check; fi
@@ -134,3 +138,6 @@ validate: ensure-up
134138
BUNDLE_ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
135139
# Optional: monorepo helper absent on standalone GitHub Actions checkout (REQ-MAKE-009).
136140
-include $(BUNDLE_ROOT)/../.scripts/Makefile.update-deps.mk
141+
142+
twig-lint: ensure-up
143+
@$(COMPOSE) exec -T $(SERVICE_PHP) composer twig:lint || $(COMPOSE) exec -T $(SERVICE_PHP) ./vendor/bin/twig-cs-fixer lint --config=.twig-cs-fixer.php

composer.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
"symfony/http-kernel": "^6.4 || ^7.0 || ^8.0",
4545
"symfony/routing": "^6.4 || ^7.0 || ^8.0",
4646
"symfony/security-csrf": "^6.4 || ^7.0 || ^8.0",
47-
"symfony/twig-bundle": "^6.4 || ^7.0 || ^8.0"
47+
"symfony/twig-bundle": "^6.4 || ^7.0 || ^8.0",
48+
"twig/extra-bundle": "^3.12",
49+
"twig/string-extra": "^3.12"
4850
},
4951
"require-dev": {
5052
"friendsofphp/php-cs-fixer": "^3.0",
@@ -55,7 +57,8 @@
5557
"phpstan/phpstan-symfony": "^2.0",
5658
"phpunit/phpunit": "^11.0",
5759
"rector/rector": "^2.0",
58-
"symfony/yaml": "^6.4 || ^7.0 || ^8.0"
60+
"symfony/yaml": "^6.4 || ^7.0 || ^8.0",
61+
"vincentlanglet/twig-cs-fixer": "^3.0"
5962
},
6063
"autoload": {
6164
"psr-4": {
@@ -80,7 +83,10 @@
8083
"minimum-stability": "stable",
8184
"prefer-stable": true,
8285
"archive": {
83-
"exclude": ["/demo", "/.cursor"]
86+
"exclude": [
87+
"/demo",
88+
"/.cursor"
89+
]
8490
},
8591
"scripts": {
8692
"test": "@php vendor/bin/phpunit --color=always",
@@ -93,6 +99,12 @@
9399
"rector": "@php vendor/bin/rector process",
94100
"rector-dry": "@php vendor/bin/rector process --dry-run --no-progress-bar",
95101
"phpstan": "@php vendor/bin/phpstan analyse --memory-limit=512M",
96-
"qa": ["@cs-check", "@test"]
102+
"qa": [
103+
"@cs-check",
104+
"@test"
105+
],
106+
"twig:lint": "twig-cs-fixer lint --config=.twig-cs-fixer.php",
107+
"twig:fix": "twig-cs-fixer fix --config=.twig-cs-fixer.php",
108+
"twig:fix:check": "twig-cs-fixer lint --config=.twig-cs-fixer.php --fix"
97109
}
98110
}

0 commit comments

Comments
 (0)