コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     try {
         $this->status->add('Starting composer update...');
         if (isset($this->params['components'])) {
             $packages = [];
             foreach ($this->params['components'] as $compObj) {
                 $packages[] = implode(' ', $compObj);
             }
             foreach ($packages as $package) {
                 if (strpos($package, 'magento/product-enterprise-edition') !== false) {
                     $this->composerApp->runComposerCommand(['command' => 'remove', 'packages' => ['magento/product-community-edition'], '--no-update' => true]);
                 }
             }
             $this->status->add($this->composerApp->runComposerCommand(['command' => 'require', 'packages' => $packages, '--no-update' => true]));
         } else {
             throw new \RuntimeException('Cannot find component to update');
         }
         $this->status->add($this->composerApp->runComposerCommand(['command' => 'update']));
         $this->status->add('Composer update completed successfully');
         $this->createSetupUpgradeTasks();
     } catch (\Exception $e) {
         $this->status->setUpdateError(true);
         throw new \RuntimeException(sprintf('Could not complete %s successfully: %s', $this, $e->getMessage()));
     }
     return $this;
 }
コード例 #2
0
 function testRunCommand()
 {
     $inputData = ['command' => 'update', MagentoComposerApplication::COMPOSER_WORKING_DIR => '.'];
     $this->composerApplication->expects($this->once())->method('resetComposer');
     $this->inputFactory->expects($this->once())->method('create')->with($inputData);
     $this->consoleOutput->expects($this->once())->method('fetch')->willReturn('Nothing to update');
     $this->composerApplication->expects($this->once())->method('run')->willReturn(0);
     $message = $this->application->runComposerCommand($inputData);
     $this->assertEquals('Nothing to update', $message);
 }
コード例 #3
0
 /**
  * Run Composer dependency check
  *
  * @param array $packages
  * @return array
  * @throws \Exception
  */
 public function runReadinessCheck(array $packages)
 {
     $composerJson = $this->composerJsonFinder->findComposerJson();
     $this->file->copy($composerJson, $this->directoryList->getPath(DirectoryList::VAR_DIR) . '/composer.json');
     $workingDir = $this->directoryList->getPath(DirectoryList::VAR_DIR);
     try {
         foreach ($packages as $package) {
             if (strpos($package, 'magento/product-enterprise-edition') !== false) {
                 $this->magentoComposerApplication->runComposerCommand(['command' => 'remove', 'packages' => ['magento/product-community-edition'], '--no-update' => true], $workingDir);
             }
         }
         $this->requireUpdateDryRunCommand->run($packages, $workingDir);
         return ['success' => true];
     } catch (\RuntimeException $e) {
         $message = str_replace(PHP_EOL, '<br/>', htmlspecialchars($e->getMessage()));
         return ['success' => false, 'error' => $message];
     }
 }
コード例 #4
0
 /**
  * Retrieve all available versions for a package
  *
  * @param string $package
  * @return array
  * @throws \RuntimeException
  */
 private function getPackageAvailableVersions($package)
 {
     $versionsPattern = '/^versions\\s*\\:\\s(.+)$/m';
     $commandParams = [self::PARAM_COMMAND => self::COMPOSER_SHOW, self::PARAM_PACKAGE => $package, self::PARAM_AVAILABLE => true];
     $result = $this->application->runComposerCommand($commandParams);
     $matches = [];
     preg_match($versionsPattern, $result, $matches);
     if (!isset($matches[1])) {
         throw new \RuntimeException(sprintf('Couldn\'t get available versions for package %s', $commandParams[self::PARAM_PACKAGE]));
     }
     return explode(', ', $matches[1]);
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     try {
         $this->status->add('Starting composer remove...');
         if (isset($this->params['components'])) {
             $packages = [];
             foreach ($this->params['components'] as $compObj) {
                 $packages[] = $compObj['name'];
             }
             $this->status->add($this->composerApp->runComposerCommand(['command' => 'remove', 'packages' => $packages, '--no-update' => true]));
         } else {
             throw new \RuntimeException('Cannot find component to uninstall');
         }
         $this->status->add($this->composerApp->runComposerCommand(['command' => 'update']));
         $this->status->add('Composer remove completed successfully');
         $this->queue->addJobs([['name' => \Magento\Update\Queue\JobFactory::NAME_MAINTENANCE_MODE, 'params' => ['enable' => false]]]);
     } catch (\Exception $e) {
         $this->status->setUpdateError(true);
         throw new \RuntimeException(sprintf('Could not complete %s successfully: %s', $this, $e->getMessage()));
     }
     return $this;
 }