Skip to content

Commit

Permalink
Add dump-editorconfig command (#18)
Browse files Browse the repository at this point in the history
* clean

* add dump-editorconfig
  • Loading branch information
TomasVotruba authored Feb 8, 2024
1 parent 3945066 commit c14b90d
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 111 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Tools that make easy to setup CI.

- Check git conflicts in CI
- Check YAML configs for the same

## Install

Expand Down
1 change: 0 additions & 1 deletion build/rector-downgrade-php-72.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
$rectorConfig->skip([
'*/Tests/*',
'*/tests/*',
__DIR__ . '/../../tests',
]);
};
102 changes: 0 additions & 102 deletions build/target-repository/README.md

This file was deleted.

40 changes: 40 additions & 0 deletions src/Command/DumpEditorconfigCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace Symplify\EasyCI\Command;

use Nette\Utils\FileSystem;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

final class DumpEditorconfigCommand extends Command
{
public function __construct(
private readonly SymfonyStyle $symfonyStyle,
) {
parent::__construct();
}

protected function configure(): void
{
$this->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;
}
}
12 changes: 7 additions & 5 deletions src/DependencyInjection/ContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');

Expand All @@ -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);
Expand All @@ -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;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Testing/Command/DetectUnitTestsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions templates/.editorconfig
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c14b90d

Please sign in to comment.