diff --git a/config/dist/chain/site.new.yml b/config/dist/chain/site.new.yml new file mode 100644 index 0000000..9c54a60 --- /dev/null +++ b/config/dist/chain/site.new.yml @@ -0,0 +1,18 @@ +# How to use +# site:new --placeholder="directory:/path/to/drupal-project/" --placeholder="profile:minimal" +command: + name: site:new + description: 'Create, install and launch a new Drupal project' +commands: + # Create Drupal project using DrupalComposer + - command: exec + arguments: + bin: composer create-project %{{repository|drupal-composer/drupal-project:8.x-dev}} %{{directory}} --prefer-dist --no-progress --no-interaction + # Install Drupal + - command: exec + arguments: + bin: drupal site:install %{{profile|standard}} --root=%{{directory}} --no-interaction + # Start PHP bult-in server + - command: exec + arguments: + bin: drupal server --root=%{{directory}} diff --git a/src/Command/Chain/ChainCommand.php b/src/Command/Chain/ChainCommand.php index 29a82aa..3c476eb 100644 --- a/src/Command/Chain/ChainCommand.php +++ b/src/Command/Chain/ChainCommand.php @@ -101,6 +101,7 @@ protected function interact(InputInterface $input, OutputInterface $output) $chainContent = $this->getFileContents($file); $placeholder = $input->getOption('placeholder'); + $inlinePlaceHolders = $this->extractInlinePlaceHolders($chainContent); if (!$placeholder && $inlinePlaceHolders) { @@ -140,7 +141,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $learning = $input->hasOption('learning')?$input->getOption('learning'):false; $file = $input->getOption('file'); - if (!$file) { $io->error($this->trans('commands.chain.messages.missing_file')); @@ -148,7 +148,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } $fileSystem = new Filesystem(); - $file = calculateRealPath($file); if (!$fileSystem->exists($file)) { @@ -166,6 +165,10 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($placeholder) { $placeholder = $this->inlineValueAsArray($placeholder); } + $placeHolderOptions = []; + foreach ($placeholder as $placeholderItem) { + $placeHolderOptions[] = key($placeholderItem); + } $chainContent = $this->getFileContents($file); $inlinePlaceHolders = $this->extractInlinePlaceHolders($chainContent); @@ -184,11 +187,11 @@ protected function execute(InputInterface $input, OutputInterface $output) continue; } - if ($placeholder && array_key_exists($inlinePlaceHolder, $placeholder[0])) { + if (in_array($inlinePlaceHolder, $placeHolderOptions)) { continue; } - $placeholder[0][$inlinePlaceHolder] = $inlinePlaceHolderDefault; + $placeholder[] = [$inlinePlaceHolder => $inlinePlaceHolderDefault]; } }