diff --git a/docs/03-01-intro.md b/docs/03-01-intro.md index bab716e2db..1a2fcfe627 100644 --- a/docs/03-01-intro.md +++ b/docs/03-01-intro.md @@ -43,6 +43,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 new file mode 100644 index 0000000000..fe63ccf4f0 --- /dev/null +++ b/src/Kunstmaan/GeneratorBundle/DependencyInjection/KunstmaanGeneratorExtension.php @@ -0,0 +1,28 @@ +processConfiguration($configuration, $configs); + + $loader = new Loader\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 new file mode 100644 index 0000000000..7643953d8e --- /dev/null +++ b/src/Kunstmaan/GeneratorBundle/Resources/config/services.yml @@ -0,0 +1,5 @@ +services: + Kunstmaan\GeneratorBundle\Command\InstallCommand: + arguments: ['@service_container'] + tags: + - { name: console.command }