diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f948a88..12e7297 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,6 +44,11 @@ jobs: - name: Check composer.json normalization run: composer normalize --diff --dry-run + - name: Check README examples are in sync + run: | + vendor/bin/readme-examples-sync + git diff --exit-code README.md || (echo "README.md is out of sync with example files. Run 'vendor/bin/readme-examples-sync' and commit the changes." && exit 1) + - name: Check dependencies run: vendor/bin/composer-dependency-analyser diff --git a/composer.json b/composer.json index adfb043..96d8122 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,6 @@ "webonyx/graphql-php": "^15.24.0" }, "require-dev": { - "captainhook/captainhook-phar": "^5.25", "ergebnis/composer-normalize": "^2.47", "friendsofphp/php-cs-fixer": "^3.85", "guzzlehttp/psr7": "^2.7", @@ -34,7 +33,7 @@ "phpunit/phpunit": "^12.3", "psr/http-client": "^1.0", "psr/http-message": "^2.0", - "ruudk/readme-examples-sync-hook": "^1.0", + "ruudk/readme-examples-sync-hook": "^2.0", "shipmonk/composer-dependency-analyser": "^1.8", "shipmonk/dead-code-detector": "^0.13.2", "staabm/phpstan-todo-by": "^0.3.0", @@ -65,7 +64,6 @@ ], "config": { "allow-plugins": { - "captainhook/captainhook-phar": true, "ergebnis/composer-normalize": true, "php-http/discovery": true, "phpstan/extension-installer": true @@ -77,5 +75,10 @@ "extension.neon" ] } + }, + "scripts": { + "post-install-cmd": [ + "command -v lefthook >/dev/null 2>&1 && lefthook install || true" + ] } } diff --git a/composer.lock b/composer.lock index da5d739..87db32d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bc708324c8ddb6a5526641cff6068e1e", + "content-hash": "9c3925ec00d1db3ec1a62bfd707d2e20", "packages": [ { "name": "nikic/php-parser", @@ -1318,72 +1318,6 @@ }, "time": "2024-07-15T13:18:35+00:00" }, - { - "name": "captainhook/captainhook-phar", - "version": "5.25.11", - "source": { - "type": "git", - "url": "https://github.com/captainhook-git/captainhook-phar.git", - "reference": "a5dbcd8d20b3dcdb1cbd6948d0d3a058453b3d6a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/captainhook-git/captainhook-phar/zipball/a5dbcd8d20b3dcdb1cbd6948d0d3a058453b3d6a", - "reference": "a5dbcd8d20b3dcdb1cbd6948d0d3a058453b3d6a", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.1||^2.0", - "ext-json": "*", - "ext-spl": "*", - "phar-io/composer-distributor": "^1.0.1", - "php": ">=8.0" - }, - "require-dev": { - "composer/composer": "^1.1 || ^2.0" - }, - "type": "composer-plugin", - "extra": { - "class": "CaptainHook\\Composer\\Plugin" - }, - "autoload": { - "psr-4": { - "CaptainHook\\Composer\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Sebastian Feldmann", - "email": "sf@sebastian-feldmann.info" - } - ], - "description": "PHP git hook manager", - "homepage": "https://github.com/captainhook-git/captainhook", - "keywords": [ - "commit-msg", - "git", - "hooks", - "post-merge", - "pre-commit", - "pre-push", - "prepare-commit-msg" - ], - "support": { - "issues": "https://github.com/captainhook-git/captainhook/issues", - "source": "https://github.com/captainhook-git/captainhook-phar/tree/5.25.11" - }, - "funding": [ - { - "url": "https://github.com/sponsors/sebastianfeldmann", - "type": "github" - } - ], - "time": "2025-04-08T07:07:48+00:00" - }, { "name": "clue/ndjson-react", "version": "v1.3.0", @@ -3221,220 +3155,6 @@ }, "time": "2025-03-24T19:12:02+00:00" }, - { - "name": "phar-io/composer-distributor", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/phar-io/composer-distributor.git", - "reference": "dd7d936290b2a42b0c64bfe08090b5c597c280c9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/composer-distributor/zipball/dd7d936290b2a42b0c64bfe08090b5c597c280c9", - "reference": "dd7d936290b2a42b0c64bfe08090b5c597c280c9", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.1 || ^2.0", - "ext-dom": "*", - "ext-libxml": "*", - "phar-io/filesystem": "^2.0", - "phar-io/gnupg": "^1.0", - "php": "^7.3 || ^8.0" - }, - "require-dev": { - "composer/composer": "^2.0", - "phpunit/phpunit": "^9.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "PharIo\\ComposerDistributor\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Andreas Heigl", - "email": "andreas@heigl.org", - "role": "Developer" - }, - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Feldmann", - "email": "sf@sebastian-feldmann.info", - "role": "Developer" - } - ], - "description": "Base Code for a composer plugin that installs PHAR-files", - "homepage": "https://phar.io", - "keywords": [ - "bin", - "binary", - "composer", - "distribute", - "phar", - "phive" - ], - "support": { - "issues": "https://github.com/phar-io/composer-distributor/issues", - "source": "https://github.com/phar-io/composer-distributor/tree/1.0.2" - }, - "funding": [ - { - "url": "https://phar.io", - "type": "other" - } - ], - "time": "2023-05-31T17:05:49+00:00" - }, - { - "name": "phar-io/executor", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/phar-io/executor.git", - "reference": "5bfb7400224a0c1cf83343660af85c7f5a073473" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/executor/zipball/5bfb7400224a0c1cf83343660af85c7f5a073473", - "reference": "5bfb7400224a0c1cf83343660af85c7f5a073473", - "shasum": "" - }, - "require": { - "phar-io/filesystem": "^2.0", - "php": "^7.2||^8.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - } - ], - "support": { - "issues": "https://github.com/phar-io/executor/issues", - "source": "https://github.com/phar-io/executor/tree/1.0.1" - }, - "time": "2020-11-30T10:53:57+00:00" - }, - { - "name": "phar-io/filesystem", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/phar-io/filesystem.git", - "reference": "222e3ea432262a05706b7066697c21257664d9d1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/filesystem/zipball/222e3ea432262a05706b7066697c21257664d9d1", - "reference": "222e3ea432262a05706b7066697c21257664d9d1", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - } - ], - "support": { - "issues": "https://github.com/phar-io/filesystem/issues", - "source": "https://github.com/phar-io/filesystem/tree/2.0.1" - }, - "time": "2020-11-30T10:16:22+00:00" - }, - { - "name": "phar-io/gnupg", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/phar-io/gnupg.git", - "reference": "ed8ab1740ac4e9db99500e7252911f2821357093" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/gnupg/zipball/ed8ab1740ac4e9db99500e7252911f2821357093", - "reference": "ed8ab1740ac4e9db99500e7252911f2821357093", - "shasum": "" - }, - "require": { - "phar-io/executor": "^1.0", - "phar-io/filesystem": "^2.0", - "php": "^7.2||^8.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - } - ], - "description": "Thin GnuPG wrapper class around the gnupg binary, mimicking the pecl/gnupg api", - "support": { - "issues": "https://github.com/phar-io/gnupg/issues", - "source": "https://github.com/phar-io/gnupg/tree/1.0.3" - }, - "time": "2024-08-22T20:45:57+00:00" - }, { "name": "phar-io/manifest", "version": "2.0.4", @@ -5518,23 +5238,22 @@ }, { "name": "ruudk/readme-examples-sync-hook", - "version": "1.1.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/ruudk/readme-examples-sync-hook.git", - "reference": "b2c935a2a6efe37faa96d982207288d345fbfe5e" + "reference": "a7a73379aa6608534362cb96879e6430b4ddecdd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ruudk/readme-examples-sync-hook/zipball/b2c935a2a6efe37faa96d982207288d345fbfe5e", - "reference": "b2c935a2a6efe37faa96d982207288d345fbfe5e", + "url": "https://api.github.com/repos/ruudk/readme-examples-sync-hook/zipball/a7a73379aa6608534362cb96879e6430b4ddecdd", + "reference": "a7a73379aa6608534362cb96879e6430b4ddecdd", "shasum": "" }, "require": { "php": "^8.4" }, "require-dev": { - "captainhook/captainhook": "^5.25", "ergebnis/composer-normalize": "^2.48", "friendsofphp/php-cs-fixer": "^3.85", "phpstan/extension-installer": "^1.4", @@ -5542,6 +5261,9 @@ "ticketswap/php-cs-fixer-config": "^1.0", "ticketswap/phpstan-error-formatter": "^1.1" }, + "bin": [ + "bin/readme-examples-sync" + ], "type": "library", "autoload": { "psr-4": { @@ -5564,9 +5286,9 @@ ], "support": { "issues": "https://github.com/ruudk/readme-examples-sync-hook/issues", - "source": "https://github.com/ruudk/readme-examples-sync-hook/tree/1.1.1" + "source": "https://github.com/ruudk/readme-examples-sync-hook/tree/2.0.0" }, - "time": "2025-10-17T07:34:33+00:00" + "time": "2025-10-22T17:24:46+00:00" }, { "name": "sebastian/cli-parser", diff --git a/lefthook.yaml b/lefthook.yaml new file mode 100644 index 0000000..a999a78 --- /dev/null +++ b/lefthook.yaml @@ -0,0 +1,51 @@ +pre-commit: + parallel: false + commands: + ensure-sync: + glob: "*.php" + run: bin/graphql-client-code-generator --config=examples/config.php --config=tests/config.php --ensure-sync + + sync-readme-examples: + glob: + - "*.php" + - "*.md" + run: vendor/bin/readme-examples-sync + stage_fixed: true + + composer-validate: + glob: + - "composer.json" + - "composer.lock" + run: composer validate --strict + + composer-normalize: + glob: "composer.json" + run: composer normalize --diff + stage_fixed: true + + composer-dependency-analyser: + glob: + - "*.php" + - "composer.json" + - "composer.lock" + run: vendor/bin/composer-dependency-analyser + + php-cs-fixer: + glob: "*.php" + run: vendor/bin/php-cs-fixer fix --config .php-cs-fixer.php -- {staged_files} + stage_fixed: true + + twig-cs-fixer: + glob: "*.twig" + run: vendor/bin/twig-cs-fixer fix -- {staged_files} + stage_fixed: true + + phpstan: + glob: + - "*.php" + - "*.neon" + run: vendor/bin/phpstan + + phpunit: + glob: "*.php" + run: vendor/bin/phpunit