diff --git a/Classes/Command/AcceptanceTestsCommand.php b/Classes/Command/AcceptanceTestsCommand.php index a74bf92..3a4c1b6 100644 --- a/Classes/Command/AcceptanceTestsCommand.php +++ b/Classes/Command/AcceptanceTestsCommand.php @@ -14,7 +14,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Finder\Finder; @@ -32,11 +31,6 @@ class AcceptanceTestsCommand extends AbstractCommand */ protected $filesystem; - /** - * @var SymfonyStyle $io - */ - protected $io; - /** * @var PackageInterface $package */ @@ -54,8 +48,7 @@ protected function configure(): void */ protected function execute(InputInterface $input, OutputInterface $output): int { - $this->io = new SymfonyStyle($input, $output); - $this->package = $this->askForPackage($this->io); + $this->package = $this->packageResolver->resolvePackage($this->askForExtensionKey()); $packageKey = $this->package->getPackageKey(); $targetPackagePath = $this->package->getPackagePath(); @@ -70,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $finder = GeneralUtility::makeInstance(Finder::class); $codeTemplatePath = '/Resources/Private/CodeTemplates/AcceptanceTests'; - $templatePath = $this->getPackageResolver()->resolvePackage('b13/make')->getPackagePath() . $codeTemplatePath; + $templatePath = $this->packageResolver->resolvePackage('b13/make')->getPackagePath() . $codeTemplatePath; $this->filesystem->mkdir([ $targetPackagePath . '/Tests/Acceptance/Fixtures', diff --git a/Classes/Command/RunTestsCommand.php b/Classes/Command/RunTestsCommand.php deleted file mode 100644 index e6becf8..0000000 --- a/Classes/Command/RunTestsCommand.php +++ /dev/null @@ -1,114 +0,0 @@ -setDescription('Setup runTests.sh to run tests, linter, cgl in a Docker environment'); - $this->filesystem = GeneralUtility::makeInstance(Filesystem::class); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->io = new SymfonyStyle($input, $output); - $this->package = $this->askForPackage($this->io); - - $templatesToCreate = [ - [ - 'source' => 'https://raw.githubusercontent.com/TYPO3/styleguide/main/Build/Scripts/runTests.sh', - 'target' => $this->package->getPackagePath() . 'Build/Scripts/runTests.sh' - ], - [ - 'source' => 'https://raw.githubusercontent.com/TYPO3/styleguide/main/Build/testing-docker/docker-compose.yml', - 'target' => $this->package->getPackagePath() . 'Build/testing-docker/docker-compose.yml' - ] - ]; - - foreach ($templatesToCreate as $template) { - $this->prepareTemplate( - $template['source'], - $template['target'] - ); - } - - $this->io->writeln('Created docker environment for testing:'); - $filePaths = array_map(function ($ar) {return $ar['target'];}, $templatesToCreate); - $this->io->listing($filePaths); - $this->io->writeln('For details run "cd ' . $this->package->getPackagePath() . ' && ' . 'Build/Scripts/runTests.sh -h"'); - - return 0; - } - - protected function prepareTemplate(string $source, string $target): void - { - try { - $template = $this->getGuzzleClient()->get($source); - } catch (GuzzleException $exception) { - $this->io->writeln('Failed to get remote file ' . $source . ''); - return; - } - - $markerService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class); - $templateContent = $markerService->substituteMarker( - $template->getBody(), - 'styleguide', - $this->package->getPackageKey() - ); - - try { - $this->filesystem->dumpFile($target, $templateContent); - if ((pathinfo($target)['extension'] ?? '') === 'sh') { - $this->filesystem->chmod([$target], 0770); - } - } catch (IOException $exception) { - $this->io->writeln('Failed to save file in ' . $target . PHP_EOL . $exception->getMessage() . ''); - } - } - - protected function getGuzzleClient(): Client - { - return GeneralUtility::makeInstance(GuzzleClientFactory::class)->getClient(); - } -} diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index fe69883..894d8b1 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -51,10 +51,3 @@ services: command: 'make:acceptance' description: 'Create files required to run acceptance tests' schedulable: false - - B13\Make\Command\RunTestsCommand: - tags: - - name: 'console.command' - command: 'make:runtests' - description: 'Setup runTests.sh to run tests, linter, cgl in a Docker environment' - schedulable: false \ No newline at end of file