/**
  * Runs composer update --dry-run command
  *
  * @param array $packages
  * @param string|null $workingDir
  * @return string
  * @throws \RuntimeException
  */
 public function run($packages, $workingDir = null)
 {
     try {
         // run require
         $this->magentoComposerApplication->runComposerCommand(['command' => 'require', 'packages' => $packages, '--no-update' => true], $workingDir);
         $output = $this->magentoComposerApplication->runComposerCommand(['command' => 'update', '--dry-run' => true], $workingDir);
     } catch (\RuntimeException $e) {
         $errorMessage = $this->generateAdditionalErrorMessage($e->getMessage(), $packages);
         if ($errorMessage) {
             throw new \RuntimeException($errorMessage, $e->getCode(), $e);
         } else {
             throw new \RuntimeException($e->getMessage(), $e->getCode(), $e);
         }
     }
     return $output;
 }
Example #2
0
 /**
  * Runs composer info command
  *
  * @param string $package
  * @param bool $installed
  * @return array|bool
  */
 public function run($package, $installed = false)
 {
     $commandParameters = ['command' => 'info', 'package' => $package, '-i' => $installed];
     $result = [];
     try {
         $output = $this->magentoComposerApplication->runComposerCommand($commandParameters);
     } catch (\RuntimeException $e) {
         return false;
     }
     $rawLines = explode("\n", str_replace("\r\n", "\n", $output));
     foreach ($rawLines as $line) {
         $chunk = explode(':', $line);
         if (count($chunk) === 2) {
             $result[trim($chunk[0])] = trim($chunk[1]);
         }
     }
     $result = $this->extractVersions($result);
     return $result;
 }
Example #3
0
 /**
  * Runs composer info command
  *
  * @param string $package
  * @param bool $installed
  * @return array|bool
  */
 public function run($package, $installed = false)
 {
     $showAllPackages = !$installed;
     $commandParameters = ['command' => 'info', 'package' => $package, '-i' => $installed, '--all' => $showAllPackages];
     try {
         $output = $this->magentoComposerApplication->runComposerCommand($commandParameters);
     } catch (\RuntimeException $e) {
         return false;
     }
     $rawLines = explode("\n", str_replace("\r\n", "\n", $output));
     $result = [];
     foreach ($rawLines as $line) {
         $chunk = explode(':', $line);
         if (count($chunk) === 2) {
             $result[trim($chunk[0])] = trim($chunk[1]);
         }
     }
     $result = $this->extractVersions($result);
     if (!isset($result[self::NAME]) && isset($result[self::CURRENT_VERSION])) {
         $result[self::NAME] = $package;
     }
     return $result;
 }