示例#1
0
 /**
  * {@inheritdoc}
  */
 public function getRequiredPackages()
 {
     if (!isset($this->packages['required'])) {
         // The root package on disk might not be up to date, build a new one.
         $core_package = $this->getCorePackage();
         $extension_packages = $this->getExtensionPackages();
         $root_package = $this->rootPackageBuilder->build($core_package, $extension_packages);
         $packages = array();
         foreach ($root_package['require'] as $package_name => $constraint) {
             $packages[$package_name] = array('constraint' => $constraint);
         }
         $installed_packages = JsonFile::read($this->root . '/core/vendor/composer/installed.json');
         foreach ($installed_packages as $package) {
             $package_name = $package['name'];
             if (!isset($packages[$package_name])) {
                 // The installed package is no longer required, and will be removed
                 // in the next composer update. Add it in order to inform the end-user.
                 $packages[$package_name] = array('constraint' => '');
             }
             // Add additional information available only for installed packages.
             $packages[$package_name] += array('description' => !empty($package['description']) ? $package['description'] : '', 'homepage' => !empty($package['homepage']) ? $package['homepage'] : '', 'require' => !empty($package['require']) ? $package['require'] : array(), 'version' => $package['version']);
             if ($package['version'] == 'dev-master') {
                 $packages[$package_name]['version'] .= '#' . $package['source']['reference'];
             }
         }
         // Process and cache the package list.
         $this->packages['required'] = $this->processRequiredPackages($packages);
     }
     return $this->packages['required'];
 }
示例#2
0
  /**
   * {@inheritdoc}
   */
  public function rebuildRootPackage() {
    $root_package = JsonFile::read($this->root . '/composer.json');
    // Rebuild the merged keys.
    $merged_extension_package = $this->buildMergedExtensionPackage();
    $root_package['require'] = [
      'composer/installers' => '^1.0.21',
      'wikimedia/composer-merge-plugin' => '^1.3.0',
    ] + $merged_extension_package['require'];
    $root_package['require-dev'] = $merged_extension_package['require-dev'];
    $root_package['replace'] = [
      'drupal/core' => '~8.0',
    ] + $merged_extension_package['replace'];
    $root_package['repositories'] = $merged_extension_package['repositories'];
    // Ensure the presence of the Drupal Packagist repository.
    // @todo Remove once Drupal Packagist moves to d.o and gets added to
    // the root package by default.
    $root_package['repositories'][] = [
      'type' => 'composer',
      'url' => 'https://packagist.drupal-composer.org',
    ];

    JsonFile::write($this->root . '/composer.json', $root_package);
  }
  /**
   * {@inheritdoc}
   */
  public function rebuildRootPackage() {
    $root_package = JsonFile::read($this->root . '/composer.json');
    // Initialize known start values. These should match what's already in
    // the root composer.json shipped with Drupal.
    $core_requirement = $root_package['replace']['drupal/core'];
    $root_package['replace'] = [
      'drupal/core' => $core_requirement,
    ];
    $root_package['repositories'] = [];
    $root_package['extra']['merge-plugin']['include'] = [
      'core/composer.json',
    ];
    // Add the discovered extensions to the replace list so that they doesn't
    // get redownloaded if required by another package.
    foreach ($this->getExtensionPackages() as $extension_package) {
      $version = '8.*';
      if (isset($extension_package['extra']['branch-alias']['dev-master'])) {
        $version = $extension_package['extra']['branch-alias']['dev-master'];
      }
      $root_package['replace'][$extension_package['name']] = $version;
    }
    // Ensure the presence of the Drupal Packagist repository.
    // @todo Remove once Drupal Packagist moves to d.o and gets added to
    // the root package by default.
    $root_package['repositories'][] = [
      'type' => 'composer',
      'url' => 'https://packagist.drupal-composer.org',
    ];
    // Add each discovered extension to the merge list.
    foreach ($this->getExtensionPackages() as $extension_package) {
      $root_package['extra']['merge-plugin']['include'][] = $extension_package['extra']['path'];
    }

    JsonFile::write($this->root . '/composer.json', $root_package);
  }