Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Module / DownloadCommand.php
index cf799cb4bf1561aa59641881f49629296a5c0736..3e8200ff4388a453a0c61fe2e9ca1d55d4a43181 100644 (file)
@@ -7,14 +7,12 @@
 
 namespace Drupal\Console\Command\Module;
 
-use Drupal\Console\Core\Command\Shared\CommandTrait;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
 use Drupal\Console\Command\Shared\ProjectDownloadTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
 use Drupal\Console\Utils\DrupalApi;
 use GuzzleHttp\Client;
 use Drupal\Console\Extension\Manager;
@@ -25,7 +23,6 @@ use Drupal\Console\Core\Utils\ShellProcess;
 
 class DownloadCommand extends Command
 {
-    use CommandTrait;
     use ProjectDownloadTrait;
 
     /**
@@ -136,8 +133,9 @@ class DownloadCommand extends Command
                 'unstable',
                 null,
                 InputOption::VALUE_NONE,
-                $this->trans('commands.module.install.options.unstable')
-            );
+                $this->trans('commands.module.download.options.unstable')
+            )
+            ->setAliases(['mod']);
     }
 
     /**
@@ -145,19 +143,18 @@ class DownloadCommand extends Command
      */
     protected function interact(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
         $composer = $input->getOption('composer');
         $module = $input->getArgument('module');
 
         if (!$module) {
-            $module = $this->modulesQuestion($io);
+            $module = $this->modulesQuestion();
             $input->setArgument('module', $module);
         }
 
         if (!$composer) {
             $path = $input->getOption('path');
             if (!$path) {
-                $path = $io->ask(
+                $path = $this->getIo()->ask(
                     $this->trans('commands.module.download.questions.path'),
                     'modules/contrib'
                 );
@@ -171,8 +168,6 @@ class DownloadCommand extends Command
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
-        $io = new DrupalStyle($input, $output);
-
         $modules = $input->getArgument('module');
         $latest = $input->getOption('latest');
         $path = $input->getOption('path');
@@ -186,7 +181,7 @@ class DownloadCommand extends Command
                         ->getPackagistModuleReleases($module, 10, $unstable);
 
                     if (!$versions) {
-                        $io->error(
+                        $this->getIo()->error(
                             sprintf(
                                 $this->trans(
                                     'commands.module.download.messages.no-releases'
@@ -197,7 +192,7 @@ class DownloadCommand extends Command
 
                         return 1;
                     } else {
-                        $version = $io->choice(
+                        $version = $this->getIo()->choice(
                             sprintf(
                                 $this->trans(
                                     'commands.site.new.questions.composer-release'
@@ -212,7 +207,7 @@ class DownloadCommand extends Command
                         ->getPackagistModuleReleases($module, 10, $unstable);
 
                     if (!$versions) {
-                        $io->error(
+                        $this->getIo()->error(
                             sprintf(
                                 $this->trans(
                                     'commands.module.download.messages.no-releases'
@@ -230,7 +225,7 @@ class DownloadCommand extends Command
                 }
 
                 // Register composer repository
-                $command = "composer config repositories.drupal composer https://packagist.drupal-composer.org";
+                $command = "composer config repositories.drupal composer https://packages.drupal.org/8";
                 $this->shellProcess->exec($command, $this->root);
 
                 $command = sprintf(
@@ -240,7 +235,7 @@ class DownloadCommand extends Command
                 );
 
                 if ($this->shellProcess->exec($command, $this->root)) {
-                    $io->success(
+                    $this->getIo()->success(
                         sprintf(
                             $this->trans('commands.module.download.messages.composer'),
                             $module
@@ -249,7 +244,7 @@ class DownloadCommand extends Command
                 }
             }
         } else {
-            $this->downloadModules($io, $modules, $latest, $path);
+            $this->downloadModules($modules, $latest, $path);
         }
 
         return true;