From a5fec24614c2cfafcb5ff75136d674babfef6480 Mon Sep 17 00:00:00 2001 From: Kajti Date: Mon, 19 Feb 2018 22:08:33 +0100 Subject: [PATCH 1/5] Kunstmaan Installer --- docs/installation/index.md | 8 + .../Command/InstallCommand.php | 162 ++++++++++++++++++ .../DependencyInjection/Configuration.php | 25 +++ .../KunstmaanGeneratorExtension.php | 2 + .../Resources/config/services.yml | 4 + 5 files changed, 201 insertions(+) create mode 100644 src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php create mode 100644 src/Kunstmaan/GeneratorBundle/DependencyInjection/Configuration.php diff --git a/docs/installation/index.md b/docs/installation/index.md index 72408f3642..e5cba51725 100644 --- a/docs/installation/index.md +++ b/docs/installation/index.md @@ -39,6 +39,14 @@ At this point refreshing the page for your repository on GitHub will show you yo > Please note that the [.gitignore](https://github.com/Kunstmaan/KunstmaanBundlesStandardEdition/blob/master/.gitignore#L4) file of the KunstmaanBundlesStandardEdition prevents committing your parameters.yml file into git. Depending on your needs, you could change this by removing that line from yout .gitignore file. +## Fast installation + +``` +bin/console kuma:install +``` + +Use above command to install kuma site or follow below steps. + ## Generating a bundle First, you should generate a bundle for your website specific code. diff --git a/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php b/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php new file mode 100644 index 0000000000..d4cfc5df3a --- /dev/null +++ b/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php @@ -0,0 +1,162 @@ +container = $container; + + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('kuma:install') + ->setDescription('KunstmaanCMS installer.') + ->setDefinition( + new InputDefinition( + [ + new InputOption('namespace', '', InputOption::VALUE_REQUIRED, 'The namespace of the bundle to create'), + new InputOption('demosite', '', InputOption::VALUE_REQUIRED, 'Do you want create "demosite"'), + new InputOption('dir', '', InputOption::VALUE_REQUIRED, 'The directory where to create the bundle'), + new InputOption('bundle-name', '', InputOption::VALUE_REQUIRED, 'The optional bundle name') + ] + ) + ); + ; + } + + protected function interact(InputInterface $input, OutputInterface $output) + { + $questionHelper = new QuestionHelper(); + + $outputStyle = new SymfonyStyle($input, $output); + $outputStyle->writeln('Installing KunstmaanCms...'); + $outputStyle->writeln($this->getKunstmaanLogo()); + + $question = new Question( + $questionHelper->getQuestion('Bundle namespace', $input->getOption('namespace')), + $input->getOption('namespace') + ); + $question->setValidator([Validators::class, 'validateBundleNamespace']); + $namespace = $questionHelper->ask($input, $output, $question); + $input->setOption('namespace', $namespace); + + $question = new ChoiceQuestion( + 'Do you want create "demosite"', + ["No", "Yes"], + 0 + ); + $question->setErrorMessage('Option "%s" is invalid.'); + $demositeOption = $questionHelper->ask($input, $output, $question); + + $input->setOption('demosite', $demositeOption); + $input->setOption('bundle-name', strtr($namespace, ['\\Bundle\\' => '', '\\' => ''])); + + $dir = $input->getOption('dir') ?: dirname($this->container->getParameter('kernel.root_dir')) . '/src'; + $input->setOption('dir', $dir); + + $output->writeln('Installation start'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $demositeOptions = ['--namespace' => $input->getOption('namespace')]; + $demositeOptions = $input->getOption('demosite') === 'Yes' + ? ['--demosite' => true] + : []; + + $this + ->executeCommand($output,'kuma:generate:bundle', [ + '--namespace' => $input->getOption('namespace'), + '--dir' => $input->getOption('dir'), + '--bundle-name' => $input->getOption('bundle-name'), + ]) + ->executeCommand($output,'kuma:generate:default-site', $demositeOptions) + ->executeCommand($output,'doctrine:database:create') + ->executeCommand($output,'doctrine:schema:drop', ['--force' => true]) + ->executeCommand($output,'doctrine:schema:create') + ->executeCommand($output,'doctrine:fixtures:load') + ->executeCommand($output,'kuma:generate:admin-tests', [ + '--namespace' => $input->getOption('namespace') + ]) + ; + } + + protected function executeCommand(OutputInterface $output, $command, array $options = []) + { + $options = array_merge( + [ + '--no-debug' => true, + '--no-interaction' => true + ], + $options + ); + + $this->commandSteps++; + try { + $updateInput = new ArrayInput($options); + $updateInput->setInteractive(false); + $this->getApplication()->find($command)->run($updateInput, new NullOutput()); + $output->writeln(sprintf('Step %d: "%s" - [OK]', $this->commandSteps, $command)); + } + catch (RuntimeException $exception) { + $output->writeln(sprintf('Step %d: "%s" - [FAILED]', $this->commandSteps, $command)); + } + catch (ContextErrorException $e) { + $output->writeln(sprintf('Step %d: "%s" - [FAILED]', $this->commandSteps, $command)); + } + + return $this; + } + + protected function getKunstmaanLogo() + { + return ' + /$$ /$$ /$$ /$$$$$$ + | $$ /$$/ | $$ /$$__ $$ + | $$ /$$/ /$$ /$$ /$$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$/$$$$ /$$$$$$ /$$$$$$ /$$$$$$$ | $$ \__/ /$$$$$$/$$$$ /$$$$$$$ + | $$$$$/ | $$ | $$| $$__ $$ /$$_____/|_ $$_/ | $$_ $$_ $$ |____ $$ |____ $$| $$__ $$| $$ | $$_ $$_ $$ /$$_____/ + | $$ $$ | $$ | $$| $$ \ $$| $$$$$$ | $$ | $$ \ $$ \ $$ /$$$$$$$ /$$$$$$$| $$ \ $$| $$ | $$ \ $$ \ $$| $$$$$$ + | $$\ $$ | $$ | $$| $$ | $$ \____ $$ | $$ /$$| $$ | $$ | $$ /$$__ $$ /$$__ $$| $$ | $$| $$ $$| $$ | $$ | $$ \____ $$ + | $$ \ $$| $$$$$$/| $$ | $$ /$$$$$$$/ | $$$$/| $$ | $$ | $$| $$$$$$$| $$$$$$$| $$ | $$| $$$$$$/| $$ | $$ | $$ /$$$$$$$/ + |__/ \__/ \______/ |__/ |__/|_______/ \___/ |__/ |__/ |__/ \_______/ \_______/|__/ |__/ \______/ |__/ |__/ |__/|_______/ + '; + } +} \ No newline at end of file diff --git a/src/Kunstmaan/GeneratorBundle/DependencyInjection/Configuration.php b/src/Kunstmaan/GeneratorBundle/DependencyInjection/Configuration.php new file mode 100644 index 0000000000..d11332b8ba --- /dev/null +++ b/src/Kunstmaan/GeneratorBundle/DependencyInjection/Configuration.php @@ -0,0 +1,25 @@ +root('kunstmaan_generator'); + + return $treeBuilder; + } +} diff --git a/src/Kunstmaan/GeneratorBundle/DependencyInjection/KunstmaanGeneratorExtension.php b/src/Kunstmaan/GeneratorBundle/DependencyInjection/KunstmaanGeneratorExtension.php index fba203e8b3..44e62e7480 100644 --- a/src/Kunstmaan/GeneratorBundle/DependencyInjection/KunstmaanGeneratorExtension.php +++ b/src/Kunstmaan/GeneratorBundle/DependencyInjection/KunstmaanGeneratorExtension.php @@ -14,6 +14,8 @@ class KunstmaanGeneratorExtension extends Extension */ public function load(array $configs, ContainerBuilder $container) { + $configuration = new Configuration(); + $this->processConfiguration($configuration, $configs); $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); } diff --git a/src/Kunstmaan/GeneratorBundle/Resources/config/services.yml b/src/Kunstmaan/GeneratorBundle/Resources/config/services.yml index 2a5c6a61d4..c38e84ba23 100644 --- a/src/Kunstmaan/GeneratorBundle/Resources/config/services.yml +++ b/src/Kunstmaan/GeneratorBundle/Resources/config/services.yml @@ -47,3 +47,7 @@ services: tags: - { name: console.command } + Kunstmaan\GeneratorBundle\Command\InstallCommand: + arguments: ['%kernel.root_dir%'] + tags: + - { name: console.command } From 69147bae86c774916c9b41a519c6c592939118d9 Mon Sep 17 00:00:00 2001 From: Kevin Jossart Date: Thu, 24 Jan 2019 11:30:58 +0100 Subject: [PATCH 2/5] Remove usage of container in favour of injecting the variable directly --- .../Command/InstallCommand.php | 20 +++++++-------- .../DependencyInjection/Configuration.php | 25 ------------------- .../KunstmaanGeneratorExtension.php | 2 -- 3 files changed, 9 insertions(+), 38 deletions(-) delete mode 100644 src/Kunstmaan/GeneratorBundle/DependencyInjection/Configuration.php diff --git a/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php b/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php index d4cfc5df3a..7f100b0b1c 100644 --- a/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php +++ b/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php @@ -29,17 +29,15 @@ class InstallCommand extends Command */ private $commandSteps = 0; - /** - * @var ContainerInterface - */ - private $containter; + /** @var string */ + private $rootDir; /** - * @param ContainerInterface $container Container + * @param string $rootDir */ - public function __construct(ContainerInterface $container) + public function __construct(string $rootDir) { - $this->container = $container; + $this->rootDir = $rootDir; parent::__construct(); } @@ -89,7 +87,7 @@ protected function interact(InputInterface $input, OutputInterface $output) $input->setOption('demosite', $demositeOption); $input->setOption('bundle-name', strtr($namespace, ['\\Bundle\\' => '', '\\' => ''])); - $dir = $input->getOption('dir') ?: dirname($this->container->getParameter('kernel.root_dir')) . '/src'; + $dir = $input->getOption('dir') ?: dirname($this->rootDir) . '/src'; $input->setOption('dir', $dir); $output->writeln('Installation start'); @@ -98,9 +96,9 @@ protected function interact(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output) { $demositeOptions = ['--namespace' => $input->getOption('namespace')]; - $demositeOptions = $input->getOption('demosite') === 'Yes' - ? ['--demosite' => true] - : []; + if($input->getOption('demosite') === 'Yes') { + $demositeOptions['--demosite'] = true; + } $this ->executeCommand($output,'kuma:generate:bundle', [ diff --git a/src/Kunstmaan/GeneratorBundle/DependencyInjection/Configuration.php b/src/Kunstmaan/GeneratorBundle/DependencyInjection/Configuration.php deleted file mode 100644 index d11332b8ba..0000000000 --- a/src/Kunstmaan/GeneratorBundle/DependencyInjection/Configuration.php +++ /dev/null @@ -1,25 +0,0 @@ -root('kunstmaan_generator'); - - return $treeBuilder; - } -} diff --git a/src/Kunstmaan/GeneratorBundle/DependencyInjection/KunstmaanGeneratorExtension.php b/src/Kunstmaan/GeneratorBundle/DependencyInjection/KunstmaanGeneratorExtension.php index 44e62e7480..fba203e8b3 100644 --- a/src/Kunstmaan/GeneratorBundle/DependencyInjection/KunstmaanGeneratorExtension.php +++ b/src/Kunstmaan/GeneratorBundle/DependencyInjection/KunstmaanGeneratorExtension.php @@ -14,8 +14,6 @@ class KunstmaanGeneratorExtension extends Extension */ public function load(array $configs, ContainerBuilder $container) { - $configuration = new Configuration(); - $this->processConfiguration($configuration, $configs); $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); } From 4997fa496d8798496395d121aa96defc36123b62 Mon Sep 17 00:00:00 2001 From: Ruud Denivel Date: Fri, 22 Mar 2019 12:07:40 +0100 Subject: [PATCH 3/5] apply styleci patch --- .../Command/InstallCommand.php | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php b/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php index 7f100b0b1c..0da6033a94 100644 --- a/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php +++ b/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php @@ -8,14 +8,12 @@ use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Output\OutputInterface; use Sensio\Bundle\GeneratorBundle\Command\Validators; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Process\Exception\RuntimeException; -use Symfony\Component\DependencyInjection\ContainerInterface; use Sensio\Bundle\GeneratorBundle\Command\Helper\QuestionHelper; use Symfony\Component\Debug\Exception\ContextErrorException; @@ -53,11 +51,10 @@ protected function configure() new InputOption('namespace', '', InputOption::VALUE_REQUIRED, 'The namespace of the bundle to create'), new InputOption('demosite', '', InputOption::VALUE_REQUIRED, 'Do you want create "demosite"'), new InputOption('dir', '', InputOption::VALUE_REQUIRED, 'The directory where to create the bundle'), - new InputOption('bundle-name', '', InputOption::VALUE_REQUIRED, 'The optional bundle name') + new InputOption('bundle-name', '', InputOption::VALUE_REQUIRED, 'The optional bundle name'), ] ) ); - ; } protected function interact(InputInterface $input, OutputInterface $output) @@ -78,14 +75,14 @@ protected function interact(InputInterface $input, OutputInterface $output) $question = new ChoiceQuestion( 'Do you want create "demosite"', - ["No", "Yes"], + ['No', 'Yes'], 0 ); $question->setErrorMessage('Option "%s" is invalid.'); $demositeOption = $questionHelper->ask($input, $output, $question); $input->setOption('demosite', $demositeOption); - $input->setOption('bundle-name', strtr($namespace, ['\\Bundle\\' => '', '\\' => ''])); + $input->setOption('bundle-name', strtr($namespace, ['\\Bundle\\' => '', '\\' => ''])); $dir = $input->getOption('dir') ?: dirname($this->rootDir) . '/src'; $input->setOption('dir', $dir); @@ -96,23 +93,23 @@ protected function interact(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output) { $demositeOptions = ['--namespace' => $input->getOption('namespace')]; - if($input->getOption('demosite') === 'Yes') { - $demositeOptions['--demosite'] = true; + if ($input->getOption('demosite') === 'Yes') { + $demositeOptions['--demosite'] = true; } $this - ->executeCommand($output,'kuma:generate:bundle', [ + ->executeCommand($output, 'kuma:generate:bundle', [ '--namespace' => $input->getOption('namespace'), '--dir' => $input->getOption('dir'), '--bundle-name' => $input->getOption('bundle-name'), ]) - ->executeCommand($output,'kuma:generate:default-site', $demositeOptions) - ->executeCommand($output,'doctrine:database:create') - ->executeCommand($output,'doctrine:schema:drop', ['--force' => true]) - ->executeCommand($output,'doctrine:schema:create') - ->executeCommand($output,'doctrine:fixtures:load') - ->executeCommand($output,'kuma:generate:admin-tests', [ - '--namespace' => $input->getOption('namespace') + ->executeCommand($output, 'kuma:generate:default-site', $demositeOptions) + ->executeCommand($output, 'doctrine:database:create') + ->executeCommand($output, 'doctrine:schema:drop', ['--force' => true]) + ->executeCommand($output, 'doctrine:schema:create') + ->executeCommand($output, 'doctrine:fixtures:load') + ->executeCommand($output, 'kuma:generate:admin-tests', [ + '--namespace' => $input->getOption('namespace'), ]) ; } @@ -122,22 +119,21 @@ protected function executeCommand(OutputInterface $output, $command, array $opti $options = array_merge( [ '--no-debug' => true, - '--no-interaction' => true + '--no-interaction' => true, ], $options ); - $this->commandSteps++; + ++$this->commandSteps; + try { $updateInput = new ArrayInput($options); $updateInput->setInteractive(false); $this->getApplication()->find($command)->run($updateInput, new NullOutput()); $output->writeln(sprintf('Step %d: "%s" - [OK]', $this->commandSteps, $command)); - } - catch (RuntimeException $exception) { + } catch (RuntimeException $exception) { $output->writeln(sprintf('Step %d: "%s" - [FAILED]', $this->commandSteps, $command)); - } - catch (ContextErrorException $e) { + } catch (ContextErrorException $e) { $output->writeln(sprintf('Step %d: "%s" - [FAILED]', $this->commandSteps, $command)); } @@ -157,4 +153,4 @@ protected function getKunstmaanLogo() |__/ \__/ \______/ |__/ |__/|_______/ \___/ |__/ |__/ |__/ \_______/ \_______/|__/ |__/ \______/ |__/ |__/ |__/|_______/ '; } -} \ No newline at end of file +} From 304569c4352e17b77a970c822337f6b6e3528fb4 Mon Sep 17 00:00:00 2001 From: Ruud Denivel Date: Fri, 22 Mar 2019 15:17:00 +0100 Subject: [PATCH 4/5] Refactored to work with SF4 --- .../Command/InstallCommand.php | 87 ++++++++++++------- 1 file changed, 55 insertions(+), 32 deletions(-) diff --git a/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php b/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php index 0da6033a94..ae4d0a21bf 100644 --- a/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php +++ b/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php @@ -13,6 +13,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Sensio\Bundle\GeneratorBundle\Command\Validators; use Symfony\Component\Console\Question\ChoiceQuestion; +use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Process\Exception\RuntimeException; use Sensio\Bundle\GeneratorBundle\Command\Helper\QuestionHelper; use Symfony\Component\Debug\Exception\ContextErrorException; @@ -20,7 +21,7 @@ /** * Kunstmaan installer */ -class InstallCommand extends Command +final class InstallCommand extends Command { /** * @var int @@ -48,10 +49,11 @@ protected function configure() ->setDefinition( new InputDefinition( [ - new InputOption('namespace', '', InputOption::VALUE_REQUIRED, 'The namespace of the bundle to create'), - new InputOption('demosite', '', InputOption::VALUE_REQUIRED, 'Do you want create "demosite"'), - new InputOption('dir', '', InputOption::VALUE_REQUIRED, 'The directory where to create the bundle'), - new InputOption('bundle-name', '', InputOption::VALUE_REQUIRED, 'The optional bundle name'), + new InputOption('demosite', '', InputOption::VALUE_REQUIRED, 'Do you want to create a "demosite"'), + new InputOption('create-tests', '', InputOption::VALUE_REQUIRED, 'Do you want to create tests for you pages/pageparts'), + new InputOption('namespace', '', InputOption::VALUE_OPTIONAL, 'The namespace of the bundle to create (only for SF3)'), + new InputOption('dir', '', InputOption::VALUE_OPTIONAL, 'The directory where to create the bundle (only for SF3)'), + new InputOption('bundle-name', '', InputOption::VALUE_OPTIONAL, 'The optional bundle name (only for SF3)'), ] ) ); @@ -65,53 +67,75 @@ protected function interact(InputInterface $input, OutputInterface $output) $outputStyle->writeln('Installing KunstmaanCms...'); $outputStyle->writeln($this->getKunstmaanLogo()); - $question = new Question( - $questionHelper->getQuestion('Bundle namespace', $input->getOption('namespace')), - $input->getOption('namespace') - ); - $question->setValidator([Validators::class, 'validateBundleNamespace']); - $namespace = $questionHelper->ask($input, $output, $question); - $input->setOption('namespace', $namespace); + // Only ask namespace for Symfony 3 + if (Kernel::VERSION_ID < 40000) { + $question = new Question( + $questionHelper->getQuestion('Bundle namespace', $input->getOption('namespace')), + $input->getOption('namespace') + ); + $question->setValidator([Validators::class, 'validateBundleNamespace']); + $namespace = $questionHelper->ask($input, $output, $question); + $input->setOption('namespace', $namespace); + $input->setOption('bundle-name', strtr($namespace, ['\\Bundle\\' => '', '\\' => ''])); + + $dir = $input->getOption('dir') ?: dirname($this->rootDir) . '/src'; + $input->setOption('dir', $dir); + } $question = new ChoiceQuestion( - 'Do you want create "demosite"', - ['No', 'Yes'], + 'Do you want to create a "demosite"', + ['No (default)', 'Yes'], 0 ); $question->setErrorMessage('Option "%s" is invalid.'); - $demositeOption = $questionHelper->ask($input, $output, $question); - - $input->setOption('demosite', $demositeOption); - $input->setOption('bundle-name', strtr($namespace, ['\\Bundle\\' => '', '\\' => ''])); + $demoSiteOption = $questionHelper->ask($input, $output, $question); + $input->setOption('demosite', $demoSiteOption); - $dir = $input->getOption('dir') ?: dirname($this->rootDir) . '/src'; - $input->setOption('dir', $dir); + $question = new ChoiceQuestion( + 'Do you want to create tests for you pages/pageparts?', + ['No (default)', 'Yes'], + 0 + ); + $question->setErrorMessage('Option "%s" is invalid.'); + $createTests = $questionHelper->ask($input, $output, $question); + $input->setOption('create-tests', $createTests); $output->writeln('Installation start'); } protected function execute(InputInterface $input, OutputInterface $output) { - $demositeOptions = ['--namespace' => $input->getOption('namespace')]; + $defaultSiteOptions = []; if ($input->getOption('demosite') === 'Yes') { - $demositeOptions['--demosite'] = true; + $defaultSiteOptions['--demosite'] = true; } - $this - ->executeCommand($output, 'kuma:generate:bundle', [ + if (Kernel::VERSION_ID < 40000) { + $defaultSiteOptions = ['--namespace' => $input->getOption('namespace')]; + + $this->executeCommand($output, 'kuma:generate:bundle', [ '--namespace' => $input->getOption('namespace'), '--dir' => $input->getOption('dir'), '--bundle-name' => $input->getOption('bundle-name'), - ]) - ->executeCommand($output, 'kuma:generate:default-site', $demositeOptions) + ]); + } + + $this + ->executeCommand($output, 'kuma:generate:default-site', $defaultSiteOptions) ->executeCommand($output, 'doctrine:database:create') ->executeCommand($output, 'doctrine:schema:drop', ['--force' => true]) ->executeCommand($output, 'doctrine:schema:create') ->executeCommand($output, 'doctrine:fixtures:load') - ->executeCommand($output, 'kuma:generate:admin-tests', [ - '--namespace' => $input->getOption('namespace'), - ]) ; + + if ($input->getOption('create-tests') === 'Yes') { + $adminTestOptions = []; + if (Kernel::VERSION_ID < 40000) { + $adminTestOptions = ['--namespace' => $input->getOption('namespace')]; + } + + $this->executeCommand($output, 'kuma:generate:admin-tests', $adminTestOptions); + } } protected function executeCommand(OutputInterface $output, $command, array $options = []) @@ -119,7 +143,6 @@ protected function executeCommand(OutputInterface $output, $command, array $opti $options = array_merge( [ '--no-debug' => true, - '--no-interaction' => true, ], $options ); @@ -128,8 +151,8 @@ protected function executeCommand(OutputInterface $output, $command, array $opti try { $updateInput = new ArrayInput($options); - $updateInput->setInteractive(false); - $this->getApplication()->find($command)->run($updateInput, new NullOutput()); + $updateInput->setInteractive(true); + $this->getApplication()->find($command)->run($updateInput, $output); $output->writeln(sprintf('Step %d: "%s" - [OK]', $this->commandSteps, $command)); } catch (RuntimeException $exception) { $output->writeln(sprintf('Step %d: "%s" - [FAILED]', $this->commandSteps, $command)); From a434ce4c7534a867c57c39b41ff2c1b26c828ee3 Mon Sep 17 00:00:00 2001 From: Ruud Denivel Date: Fri, 22 Mar 2019 15:23:37 +0100 Subject: [PATCH 5/5] refactor root_dir to project_dir --- src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php | 9 ++++----- .../GeneratorBundle/Resources/config/services.yml | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php b/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php index ae4d0a21bf..73c7f4d0ef 100644 --- a/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php +++ b/src/Kunstmaan/GeneratorBundle/Command/InstallCommand.php @@ -6,7 +6,6 @@ use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Question\Question; -use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputDefinition; @@ -29,14 +28,14 @@ final class InstallCommand extends Command private $commandSteps = 0; /** @var string */ - private $rootDir; + private $projectDir; /** * @param string $rootDir */ - public function __construct(string $rootDir) + public function __construct(string $projectDir) { - $this->rootDir = $rootDir; + $this->projectDir = $projectDir; parent::__construct(); } @@ -78,7 +77,7 @@ protected function interact(InputInterface $input, OutputInterface $output) $input->setOption('namespace', $namespace); $input->setOption('bundle-name', strtr($namespace, ['\\Bundle\\' => '', '\\' => ''])); - $dir = $input->getOption('dir') ?: dirname($this->rootDir) . '/src'; + $dir = $input->getOption('dir') ?: $this->projectDir . '/src'; $input->setOption('dir', $dir); } diff --git a/src/Kunstmaan/GeneratorBundle/Resources/config/services.yml b/src/Kunstmaan/GeneratorBundle/Resources/config/services.yml index c38e84ba23..1f2fa1a756 100644 --- a/src/Kunstmaan/GeneratorBundle/Resources/config/services.yml +++ b/src/Kunstmaan/GeneratorBundle/Resources/config/services.yml @@ -48,6 +48,6 @@ services: - { name: console.command } Kunstmaan\GeneratorBundle\Command\InstallCommand: - arguments: ['%kernel.root_dir%'] + arguments: ['%kernel.project_dir%'] tags: - { name: console.command }