5 * Contains \Drupal\Console\Command\Module\UpdateCommand.
8 namespace Drupal\Console\Command\Module;
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputOption;
12 use Symfony\Component\Console\Input\InputInterface;
13 use Symfony\Component\Console\Output\OutputInterface;
14 use Drupal\Console\Core\Command\Command;
15 use Drupal\Console\Command\Shared\ProjectDownloadTrait;
16 use Drupal\Console\Core\Utils\ShellProcess;
18 class UpdateCommand extends Command
20 use ProjectDownloadTrait;
26 protected $shellProcess;
34 * UpdateCommand constructor.
36 * @param ShellProcess $shellProcess
39 public function __construct(
40 ShellProcess $shellProcess,
43 $this->shellProcess = $shellProcess;
45 parent::__construct();
47 protected function configure()
50 ->setName('module:update')
51 ->setDescription($this->trans('commands.module.update.description'))
54 InputArgument::IS_ARRAY,
55 $this->trans('commands.module.update.arguments.module')
60 InputOption::VALUE_NONE,
61 $this->trans('commands.module.update.options.composer')
66 InputOption::VALUE_NONE,
67 $this->trans('commands.module.update.options.simulate')
68 )->setAliases(['moup']);
74 protected function interact(InputInterface $input, OutputInterface $output)
76 $composer = $input->getOption('composer');
77 $module = $input->getArgument('module');
80 $this->getIo()->error($this->trans('commands.module.update.messages.only-composer'));
86 $module = $this->modulesQuestion();
87 $input->setArgument('module', $module);
94 protected function execute(InputInterface $input, OutputInterface $output)
96 $modules = $input->getArgument('module');
97 $composer = $input->getOption('composer');
98 $simulate = $input->getOption('simulate');
101 $this->getIo()->error($this->trans('commands.module.update.messages.only-composer'));
107 $this->getIo()->error(
108 $this->trans('commands.module.update.messages.missing-module')
114 if (count($modules) > 1) {
115 $modules = " drupal/" . implode(" drupal/", $modules);
117 $modules = " drupal/" . current($modules);
121 // Register composer repository
122 $command = "composer config repositories.drupal composer https://packages.drupal.org/8";
123 $this->shellProcess->exec($command, $this->root);
125 $command = 'composer update ' . $modules . ' --optimize-autoloader --prefer-dist --no-dev --root-reqs ';
128 $command .= " --dry-run";
131 if ($this->shellProcess->exec($command, $this->root)) {
132 $this->getIo()->success(
134 $this->trans('commands.module.update.messages.composer'),