Commit 83dc889e authored by Bojan Živanović's avatar Bojan Živanović
Browse files

Issue #2398037: Fix composer rebuild json to remove use of optional modules parameter

parent 3937799c
Loading
Loading
Loading
Loading
+1 −12
Changes for composer_manager.drush.inc: 1 added line, 12 removed lines.
Original line number Diff line number Diff line
@@ -27,12 +27,6 @@ function composer_manager_drush_command() {
      'composer-rebuild',
      'composer-rebuild-file',
    ),
    'options' => array(
      'include' => array(
        'description' => 'Comma delimited list of disabled modules to include in addition to enabled modules. Useful when a module provides a class with a dependency.',
        'example-value' => 'module1,module2',
      ),
    ),
  );

  return $items;
@@ -113,12 +107,7 @@ function drush_composer_manager($command = 'install') {
 */
function drush_composer_manager_composer_json_rebuild() {
  try {
    $other_modules = array();
    if ($include = drush_get_option('include')) {
      $other_modules = explode(',', $include);
    }

    Drupal::service('composer_manager.packages')->writeComposerJsonFile($other_modules);
    Drupal::service('composer_manager.packages')->writeComposerJsonFile();
    drush_log(dt('Completed building composer.json file.'), 'ok');
    return TRUE;
  }
+2 −8
Changes for src/ComposerPackages.php: 2 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -216,14 +216,11 @@ class ComposerPackages implements ComposerPackagesInterface {
   * Writes the consolidated composer.json file for all modules that require
   * third-party packages managed by Composer.
   *
   * @param array $modules
   *   (Optional) Array of modules to include in addition to enabled modules.
   *
   * @return int
   *
   * @throws \RuntimeException
   */
  public function writeComposerJsonFile(array $modules = array()) {
  public function writeComposerJsonFile() {
    $bytes = $this->composerJsonWritten = FALSE;

    // Ensure only one process runs at a time. 10 seconds is more than enough.
@@ -235,7 +232,7 @@ class ComposerPackages implements ComposerPackagesInterface {

    try {
      $composer_json = $this->manager->getComposerJsonFile();
      $files = $this->getComposerJsonFiles($modules);
      $files = $this->getComposerJsonFiles();

      $filedata = (array) $this->mergeComposerJsonFiles($files);
      $bytes = $composer_json->write($filedata);
@@ -265,9 +262,6 @@ class ComposerPackages implements ComposerPackagesInterface {
  /**
   * Fetches the data in each module's composer.json file.
   *
   * @param array $modules
   *   (Optional) Array of modules in addition to enabled modules.
   *
   * @return \Drupal\composer_manager\ComposerFileInterface[]
   *
   * @throws \RuntimeException
+1 −4
Changes for src/ComposerPackagesInterface.php: 1 added line, 4 removed lines.
Original line number Diff line number Diff line
@@ -67,14 +67,11 @@ interface ComposerPackagesInterface {
   * Writes the consolidated composer.json file for all modules that require
   * third-party packages managed by Composer.
   *
   * @param array $modules
   *   (Optional) Array of modules to include in addition to enabled modules.
   *
   * @return int
   *
   * @throws \RuntimeException
   */
  public function writeComposerJsonFile(array $modules = array());
  public function writeComposerJsonFile();

  /**
   * Returns TRUE if the composer.json file was written in this request.
+1 −12
Changes for src/Form/RebuildForm.php: 1 added line, 12 removed lines.
Original line number Diff line number Diff line
@@ -57,13 +57,6 @@ class RebuildForm implements FormInterface, ContainerInjectionInterface {
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $file_dir = $this->config->get('file_dir');

    $form['include'] = array(
      '#type' => 'textfield',
      '#title' => t('Include the following disabled modules'),
      '#description' => t('Provide a comma-delimited list of disabled modules to include. This is required for modules that provide a service from an external library.'),
    );

    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Rebuild composer.json file'),
@@ -87,13 +80,9 @@ class RebuildForm implements FormInterface, ContainerInjectionInterface {
      $other_modules = array();
      $form_state_values = $form_state->getValues();

      if (!empty($form_state_values['include'])) {
        $other_modules = preg_split('/,[\s]?/', $form_state_values['include']);
      }

      /* @var $packages \Drupal\composer_manager\ComposerPackagesInterface */
      $packages = \Drupal::service('composer_manager.packages');
      $packages->writeComposerJsonFile($other_modules);
      $packages->writeComposerJsonFile();

      $filepath = drupal_realpath($packages->getManager()->getComposerJsonFile()->getFilepath());
      drupal_set_message(t('A composer.json file was written to @filepath.', array('@filepath' => $filepath)));