diff --git a/.ahoy.yml b/.ahoy.yml index eb127f5..129f9e0 100644 --- a/.ahoy.yml +++ b/.ahoy.yml @@ -32,7 +32,7 @@ commands: vendor/bin/phpstan vendor/bin/rector --clear-cache --dry-run vendor/bin/phpmd . text phpmd.xml - vendor/bin/twigcs + vendor/bin/twig-cs-fixer popd >/dev/null || exit 1 lint-fix: @@ -71,6 +71,14 @@ commands: vendor/bin/phpunit --testsuite functional popd >/dev/null || exit 1 + reset: + usage: Reset the project. + cmd: | + killall -9 php >/dev/null 2>&1 || true + chmod -Rf 777 build > /dev/null + rm -Rf build > /dev/null || true + rm -Rf .logs > /dev/null || true + # Override entrypoint to alter default behaviour of Ahoy. entrypoint: - bash diff --git a/.circleci/config.yml b/.circleci/config.yml index 79e099a..6f79fa0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,8 +52,8 @@ job-test: &job-test working_directory: build - run: - name: Lint code with Twigcs - command: vendor/bin/twigcs || [ "${CI_TWIGCS_IGNORE_FAILURE:-0}" -eq 1 ] + name: Lint code with Twig CS Fixer + command: vendor/bin/twig-cs-fixer || [ "${CI_TWIGCSFIXER_IGNORE_FAILURE:-0}" -eq 1 ] working_directory: build - run: diff --git a/.devtools/build-codebase.sh b/.devtools/build-codebase.sh index 54a6b26..4dac388 100755 --- a/.devtools/build-codebase.sh +++ b/.devtools/build-codebase.sh @@ -107,7 +107,7 @@ for composer_suggest in $composer_suggests; do done echo "> Copy tools configuration files." -cp phpcs.xml phpstan.neon phpmd.xml rector.php .twig_cs.php phpunit.xml "build/" +cp phpcs.xml phpstan.neon phpmd.xml rector.php .twig-cs-fixer.php phpunit.xml "build/" echo "> Symlink extension's code." rm -rf "build/web/${type}/custom" >/dev/null && mkdir -p "build/web/${type}/custom/${extension}" diff --git a/.gitattributes b/.gitattributes index a0d3dee..d4ebe5b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,21 +1,21 @@ # Ignore files for distribution archives. # Uncomment the lines below in your project. -# .ahoy.yml export-ignore -# .circleci export-ignore -# .devtools export-ignore -# .editorconfig export-ignore -# .gitattributes export-ignore -# .github export-ignore -# .gitignore export-ignore -# .twig_cs.php export-ignore -# composer.dev.json export-ignore -# phpcs.xml export-ignore -# phpmd.xml export-ignore -# phpstan.neon export-ignore -# rector.php export-ignore -# renovate.json export-ignore -# tests export-ignore +# .ahoy.yml export-ignore +# .circleci export-ignore +# .devtools export-ignore +# .editorconfig export-ignore +# .gitattributes export-ignore +# .github export-ignore +# .gitignore export-ignore +# .twig-cs-fixer.php export-ignore +# composer.dev.json export-ignore +# phpcs.xml export-ignore +# phpmd.xml export-ignore +# phpstan.neon export-ignore +# rector.php export-ignore +# renovate.json export-ignore +# tests export-ignore # Remove the lines below in your project. .github/FUNDING.yml export-ignore diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 343e789..22a65e4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -89,9 +89,9 @@ jobs: working-directory: build run: vendor/bin/phpmd . text phpmd.xml || [ "${CI_PHPMD_IGNORE_FAILURE:-0}" -eq 1 ] - - name: Lint code with Twigcs + - name: Lint code with Twig CS Fixer working-directory: build - run: vendor/bin/twigcs || [ "${CI_TWIGCS_IGNORE_FAILURE:-0}" -eq 1 ] + run: vendor/bin/twig-cs-fixer || [ "${CI_TWIGCSFIXER_IGNORE_FAILURE:-0}" -eq 1 ] - name: Run tests working-directory: build diff --git a/.scaffold/tests/bats/_assert_init.bash b/.scaffold/tests/bats/_assert_init.bash index bfebaaa..f8e140f 100644 --- a/.scaffold/tests/bats/_assert_init.bash +++ b/.scaffold/tests/bats/_assert_init.bash @@ -129,7 +129,7 @@ assert_workflow() { vendor/bin/phpstan vendor/bin/rector --clear-cache --dry-run vendor/bin/phpmd . text phpmd.xml - vendor/bin/twigcs + vendor/bin/twig-cs-fixer popd >/dev/null || exit 1 diff --git a/.twig-cs-fixer.php b/.twig-cs-fixer.php new file mode 100644 index 0000000..7db2293 --- /dev/null +++ b/.twig-cs-fixer.php @@ -0,0 +1,16 @@ +addStandard(new TwigCsFixer\Standard\Twig()); + +$finder = new TwigCsFixer\File\Finder(); +$finder->in(__DIR__ . '/web/modules/custom'); +$finder->in(__DIR__ . '/web/themes/custom'); + +$config = new TwigCsFixer\Config\Config(); +$config->setRuleset($ruleset); +$config->setFinder($finder); + +return $config; diff --git a/.twig_cs.php b/.twig_cs.php deleted file mode 100644 index a44f6be..0000000 --- a/.twig_cs.php +++ /dev/null @@ -1,15 +0,0 @@ -setName('custom-config') - ->setSeverity('error') - ->setReporter('console') - ->setRuleSet(Twigcs\Ruleset\Official::class) - ->addFinder(Twigcs\Finder\TemplateFinder::create()->in([ - __DIR__ . '/web/modules/custom', - __DIR__ . '/web/themes/custom', - ])); diff --git a/README.dist.md b/README.dist.md index c40f438..591af97 100644 --- a/README.dist.md +++ b/README.dist.md @@ -58,14 +58,14 @@ vendor/bin/phpcs vendor/bin/phpstan vendor/bin/rector --clear-cache --dry-run vendor/bin/phpmd . text phpmd.xml -vendor/bin/twigcs +vendor/bin/twig-cs-fixer ``` - PHPCS config: [`phpcs.xml`](phpcs.xml) - PHPStan config: [`phpstan.neon`](phpstan.neon) - PHPMD config: [`phpmd.xml`](phpmd.xml) - Rector config: [`rector.php`](rector.php) -- TwigCS config: [`.twig_cs.php`](.twig_cs.php) +- Twig CS Fixer config: [`.twig-cs-fixer.php`](.twig-cs-fixer.php) ### Tests diff --git a/README.md b/README.md index 8953912..e1258c4 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ to [drupal.org](https://drupal.org). with PHPStan (including [PHPStan Drupal](https://github.com/mglaman/phpstan-drupal)). - PHP deprecated code analysis with [Drupal Rector](https://github.com/palantirnet/drupal-rector). - - Twig code analysis with [TwigCS](https://github.com/friendsoftwig/twigcs). + - Twig code analysis with [Twig CS Fixer](https://github.com/VincentLanglet/Twig-CS-Fixer). ![Lint process](https://user-images.githubusercontent.com/378794/253732548-9403e4cc-db03-4696-b114-32517ab0a571.gif) - Drupal's Simpletest testing support - runs tests in the same way as [drupal.org](https://drupal.org)'s Drupal CI diff --git a/composer.dev.json b/composer.dev.json index 6a7f151..84ae244 100644 --- a/composer.dev.json +++ b/composer.dev.json @@ -1,14 +1,14 @@ { "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^1.0", - "friendsoftwig/twigcs": "^6.2", "jangregor/phpstan-prophecy": "^1.0", "mglaman/phpstan-drupal": "^1.2", "palantirnet/drupal-rector": "^0.18", "phpcompatibility/php-compatibility": "^9.3", "phpmd/phpmd": "^2.15", "phpspec/prophecy-phpunit": "^2", - "phpstan/extension-installer": "^1.3" + "phpstan/extension-installer": "^1.3", + "vincentlanglet/twig-cs-fixer": "^2.8" }, "config": { "allow-plugins": { diff --git a/init.sh b/init.sh index dd7b0d7..9f26a5a 100755 --- a/init.sh +++ b/init.sh @@ -187,7 +187,7 @@ process_internal() { uncomment_line ".gitattributes" ".gitattributes" uncomment_line ".gitattributes" ".github" uncomment_line ".gitattributes" ".gitignore" - uncomment_line ".gitattributes" ".twig_cs.php" + uncomment_line ".gitattributes" ".twig-cs-fixer.php" uncomment_line ".gitattributes" "composer.dev.json" uncomment_line ".gitattributes" "phpcs.xml" uncomment_line ".gitattributes" "phpmd.xml"