예제 #1
0
 /**
  * @param string $currentCE
  * @return array
  */
 public function getAllowedEnterpriseVersions($currentCE)
 {
     $result = [];
     $enterpriseVersions = $this->infoCommand->run('magento/product-enterprise-edition');
     $eeVersions = [];
     $maxVersion = '';
     if (is_array($enterpriseVersions) && array_key_exists('available_versions', $enterpriseVersions)) {
         $enterpriseVersions = $this->sortVersions($enterpriseVersions);
         if (isset($enterpriseVersions['available_versions'][0])) {
             $maxVersion = $enterpriseVersions['available_versions'][0];
         }
         $eeVersions = $this->filterEeVersions($currentCE, $enterpriseVersions, $maxVersion);
     }
     if (!empty($eeVersions)) {
         $result[] = ['package' => 'magento/product-enterprise-edition', 'versions' => $eeVersions];
     }
     return $result;
 }
 /**
  * Get Components from composer info command
  *
  * @return JsonModel
  * @throws \RuntimeException
  */
 public function componentsAction()
 {
     try {
         $components = $this->composerInformation->getInstalledMagentoPackages();
         foreach ($components as $component) {
             if (!$this->composerInformation->isPackageInComposerJson($component['name'])) {
                 unset($components[$component['name']]);
                 continue;
             }
             $componentNameParts = explode('/', $component['name']);
             $packageInfo = $this->infoCommand->run($component['name']);
             if (!$packageInfo) {
                 throw new \RuntimeException('Package info not found for ' . $component['name']);
             }
             if ($packageInfo[InfoCommand::NEW_VERSIONS]) {
                 $currentVersion = $packageInfo[InfoCommand::CURRENT_VERSION];
                 $components[$component['name']]['version'] = $currentVersion;
                 $versions = [];
                 foreach ($packageInfo[InfoCommand::NEW_VERSIONS] as $version) {
                     $versions[] = ['id' => $version, 'name' => $version];
                 }
                 $versions[] = ['id' => $packageInfo[InfoCommand::CURRENT_VERSION], 'name' => $packageInfo[InfoCommand::CURRENT_VERSION]];
                 $versions[0]['name'] .= ' (latest)';
                 $versions[count($versions) - 1]['name'] .= ' (current)';
                 $components[$component['name']]['vendor'] = $componentNameParts[0];
                 $components[$component['name']]['updates'] = $versions;
                 $components[$component['name']]['dropdownId'] = 'dd_' . $component['name'];
                 $components[$component['name']]['checkboxId'] = 'cb_' . $component['name'];
             } else {
                 unset($components[$component['name']]);
             }
         }
         return new JsonModel(['components' => array_values($components), 'total' => count($components), 'responseType' => ResponseTypeInterface::RESPONSE_TYPE_SUCCESS]);
     } catch (\Exception $e) {
         return new JsonModel(['responseType' => ResponseTypeInterface::RESPONSE_TYPE_ERROR]);
     }
 }
예제 #3
0
 public function testRunInstalled()
 {
     $this->application->expects($this->once())->method('runComposerCommand')->willReturn($this->installedOutput);
     $result = $this->infoCommand->run('3rdp/a', true);
     $this->assertEquals(['name' => '3rdp/a', 'descrip.' => 'Plugin project A', 'versions' => '* 1.0.0', 'keywords' => '', 'type' => 'library', 'names' => '3rdp/a', 'current_version' => '1.0.0', 'available_versions' => [], 'new_versions' => []], $result);
 }