diff --git a/README.md b/README.md index eae20696c..bfbd48019 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ Tools that make easy to setup CI. - Check git conflicts in CI -- Check YAML configs for the same ## Install diff --git a/build/rector-downgrade-php-72.php b/build/rector-downgrade-php-72.php index 5f8802617..68641a459 100644 --- a/build/rector-downgrade-php-72.php +++ b/build/rector-downgrade-php-72.php @@ -11,6 +11,5 @@ $rectorConfig->skip([ '*/Tests/*', '*/tests/*', - __DIR__ . '/../../tests', ]); }; diff --git a/build/target-repository/README.md b/build/target-repository/README.md deleted file mode 100644 index 024cac75e..000000000 --- a/build/target-repository/README.md +++ /dev/null @@ -1,102 +0,0 @@ -# Easy CI - -[![Downloads total](https://img.shields.io/packagist/dt/symplify/easy-ci.svg?style=flat-square)](https://packagist.org/packages/symplify/easy-ci/stats) - -Tools that make easy to setup CI. - -- Check git conflicts in CI -- Check TWIG templates for missing classes, non-existing static calls and constant fetches -- Check YAML configs for the same - -## Install - -```bash -composer require symplify/easy-ci --dev -``` - -## Usage - -### 1. Check your Code for Git Merge Conflicts - -Do you use Git? Then merge conflicts is not what you want in your code ever to see: - -```bash -<<<<<<< HEAD -this is some content to mess with -content to append -======= -totally different content to merge later -```` - -How to avoid it? Add check to your CI: - -```bash -vendor/bin/easy-ci check-conflicts . -``` - -The `/vendor` directory is excluded by default. - -
- -### 2. Check Configs for Non-Existing Classes - -```bash -vendor/bin/easy-ci check-config src -``` - -Supported types are YAML. - -
- -### 3. Check Twig Controller Paths - -```bash -vendor/bin/easy-ci check-twig-render src/Controller -``` - -```php -final class SomeController -{ - public function index() - { - return $this->render('does_path_exist.twig'); - } -} -``` - -
- -### 4. Detect Static Calls in Your Code - -```bash -vendor/bin/easy-ci detect-static src -``` - -
- -### 5. Detect Commented Code - -Have you ever forgot commented code in your code? - -```php -// foreach ($matches as $match) { -// $content = str_replace($match[0], $match[2], $content); -// } -``` - -Clutter no more! Add `check-commented-code` command to your CI and don't worry about it: - -```bash -vendor/bin/easy-ci check-commented-code -vendor/bin/easy-ci check-commented-code packages --line-limit 5 -``` - -
- -## Report Issues - -In case you are experiencing a bug or want to request a new feature head over to the [Symplify monorepo issue tracker](https://github.com/symplify/symplify/issues) - -## Contribute - -The sources of this package are contained in the Symplify monorepo. We welcome contributions for this package on [symplify/symplify](https://github.com/symplify/symplify). diff --git a/src/Command/DumpEditorconfigCommand.php b/src/Command/DumpEditorconfigCommand.php new file mode 100644 index 000000000..88f937ffc --- /dev/null +++ b/src/Command/DumpEditorconfigCommand.php @@ -0,0 +1,40 @@ +setName('dump-editorconfig'); + $this->setDescription('Dump .editorconfig file to project root'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $projectEditorconfigFilePath = getcwd() . '/.editorconfig'; + if (file_exists($projectEditorconfigFilePath)) { + $this->symfonyStyle->error('.editorconfig file already exists'); + return self::FAILURE; + } + + FileSystem::copy(__DIR__ . '/../../templates/.editorconfig', $projectEditorconfigFilePath); + $this->symfonyStyle->success('.editorconfig file was created'); + + return self::SUCCESS; + } +} diff --git a/src/DependencyInjection/ContainerFactory.php b/src/DependencyInjection/ContainerFactory.php index 2a2a0a697..29513891c 100644 --- a/src/DependencyInjection/ContainerFactory.php +++ b/src/DependencyInjection/ContainerFactory.php @@ -11,6 +11,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symplify\EasyCI\Command\CheckCommentedCodeCommand; use Symplify\EasyCI\Command\CheckConflictsCommand; +use Symplify\EasyCI\Command\DumpEditorconfigCommand; use Symplify\EasyCI\Command\FindMultiClassesCommand; use Symplify\EasyCI\Command\NamespaceToPSR4Command; use Symplify\EasyCI\Command\ValidateFileLengthCommand; @@ -26,11 +27,6 @@ public function create(): Container $container = new Container(); // console - $container->singleton( - SymfonyStyle::class, - static fn (): SymfonyStyle => new SymfonyStyle(new ArrayInput([]), new ConsoleOutput()) - ); - $container->singleton(Application::class, function (Container $container): Application { $application = new Application('Easy CI toolkit'); @@ -41,6 +37,7 @@ public function create(): Container $container->make(DetectUnitTestsCommand::class), $container->make(FindMultiClassesCommand::class), $container->make(NamespaceToPSR4Command::class), + $container->make(DumpEditorconfigCommand::class), ]; $application->addCommands($commands); @@ -51,6 +48,11 @@ public function create(): Container return $application; }); + $container->singleton( + SymfonyStyle::class, + static fn (): SymfonyStyle => new SymfonyStyle(new ArrayInput([]), new ConsoleOutput()) + ); + return $container; } diff --git a/src/Testing/Command/DetectUnitTestsCommand.php b/src/Testing/Command/DetectUnitTestsCommand.php index 8a7b8f39d..a760ee385 100644 --- a/src/Testing/Command/DetectUnitTestsCommand.php +++ b/src/Testing/Command/DetectUnitTestsCommand.php @@ -34,8 +34,7 @@ protected function configure(): void { $this->setName('detect-unit-tests'); - $this->setDescription('Get list of tests in specific directory, that are considered "unit". -They depend only on bare PHPUnit test case, but not on KernelTestCase. Move the generated file to your phpunit.xml test group.'); + $this->setDescription('Get list of tests in specific directory, that are considered "unit"'); $this->addArgument( Option::SOURCES, diff --git a/templates/.editorconfig b/templates/.editorconfig new file mode 100644 index 000000000..bec95c449 --- /dev/null +++ b/templates/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 4