5 * Contains \Drupal\Console\Command\Module\UpdateCommand.
8 namespace Drupal\Console\Command\Module;
10 use Drupal\Console\Core\Command\Shared\CommandTrait;
11 use Symfony\Component\Console\Input\InputArgument;
12 use Symfony\Component\Console\Input\InputOption;
13 use Symfony\Component\Console\Input\InputInterface;
14 use Symfony\Component\Console\Output\OutputInterface;
15 use Symfony\Component\Console\Command\Command;
16 use Drupal\Console\Core\Style\DrupalStyle;
17 use Drupal\Console\Command\Shared\ProjectDownloadTrait;
18 use Drupal\Console\Core\Utils\ShellProcess;
20 class UpdateCommand extends Command
23 use ProjectDownloadTrait;
29 protected $shellProcess;
37 * UpdateCommand constructor.
39 * @param ShellProcess $shellProcess
42 public function __construct(
43 ShellProcess $shellProcess,
46 $this->shellProcess = $shellProcess;
48 parent::__construct();
50 protected function configure()
53 ->setName('module:update')
54 ->setDescription($this->trans('commands.module.update.description'))
57 InputArgument::IS_ARRAY,
58 $this->trans('commands.module.update.arguments.module')
63 InputOption::VALUE_NONE,
64 $this->trans('commands.module.update.options.composer')
69 InputOption::VALUE_NONE,
70 $this->trans('commands.module.update.options.simulate')
77 protected function interact(InputInterface $input, OutputInterface $output)
79 $io = new DrupalStyle($input, $output);
80 $composer = $input->getOption('composer');
81 $module = $input->getArgument('module');
84 $io->error($this->trans('commands.module.update.messages.only-composer'));
90 $module = $this->modulesQuestion($io);
91 $input->setArgument('module', $module);
98 protected function execute(InputInterface $input, OutputInterface $output)
100 $io = new DrupalStyle($input, $output);
102 $modules = $input->getArgument('module');
103 $composer = $input->getOption('composer');
104 $simulate = $input->getOption('simulate');
107 $io->error($this->trans('commands.module.update.messages.only-composer'));
114 $this->trans('commands.module.update.messages.missing-module')
120 if (count($modules) > 1) {
121 $modules = " drupal/" . implode(" drupal/", $modules);
123 $modules = " drupal/" . current($modules);
127 // Register composer repository
128 $command = "composer config repositories.drupal composer https://packagist.drupal-composer.org";
129 $this->shellProcess->exec($command, $this->root);
131 $command = 'composer update ' . $modules . ' --optimize-autoloader --prefer-dist --no-dev --root-reqs ';
134 $command .= " --dry-run";
137 if ($this->shellProcess->exec($command, $this->root)) {
140 $this->trans('commands.module.update.messages.composer'),