Ejemplo n.º 1
0
 /**
  * Create \Composer\Composer
  *
  * @return \Composer\Composer
  * @throws \Exception
  */
 public function create()
 {
     if (!getenv('COMPOSER_HOME')) {
         putenv('COMPOSER_HOME=' . $this->directoryList->getPath(DirectoryList::COMPOSER_HOME));
     }
     return \Composer\Factory::create(new BufferIO(), $this->composerJsonFinder->findComposerJson());
 }
Ejemplo n.º 2
0
 /**
  * Get Product version
  *
  * @return string
  * @throws \Exception
  */
 public function getVersion()
 {
     if (!$this->version) {
         $composerJsonFile = $this->composerJsonFinder->findComposerJson();
         $composerContent = file_get_contents($composerJsonFile);
         if ($composerContent === false) {
             throw new \Exception('Composer file content is empty');
         }
         $composerContent = json_decode($composerContent, true);
         if (!$composerContent || !is_array($composerContent) || !array_key_exists('version', $composerContent)) {
             throw new \Exception('Unable to decode Composer file');
         }
         $this->version = $composerContent['version'];
     }
     return $this->version;
 }
 /**
  * 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];
     }
 }
 /**
  * Constructor
  *
  * @param ComposerJsonFinder $composerJsonFinder
  * @param DirectoryList $directoryList
  */
 public function __construct(ComposerJsonFinder $composerJsonFinder, DirectoryList $directoryList)
 {
     $this->pathToComposerJson = $composerJsonFinder->findComposerJson();
     $this->pathToComposerHome = $directoryList->getPath(DirectoryList::COMPOSER_HOME);
 }