acquia / drupal-recommended-settings

The composer plugin to add Acquia's drupal recommended settings in your drupal project.
6 stars 6 forks source link

DRS is not compatible with BLT making migration not possible #75

Open korkhau opened 6 days ago

korkhau commented 6 days ago

Describe the bug BLT allowed for configuration overrides; for example, we had init disabled:

disable-targets:
  blt:
    shell-alias:
      init: true

To Reproduce

  1. Install with composer install
  2. See settings added into /default/settings.php
    require DRUPAL_ROOT . "/../vendor/acquia/drupal-recommended-settings/settings/acquia-recommended.settings.php";
    /**
    * IMPORTANT.
    *
    * Do not include additional settings here. Instead, add them to settings
    * included by `acquia-recommended.settings.php`. See Acquia's documentation for more detail.
    *
    * @link https://docs.acquia.com/
    */

Expected behavior By using /drs/config.yml we should be able to disable running of /bin/drush drs:init:settings on composer install as it is in BLT

Additional context onPostCmdEvent does not take into account any properties from config at all:

  /**
   * Includes Acquia recommended settings post composer update/install command.
   */
  public function onPostCmdEvent(): void {
    // Only install the template files, if the drupal-recommended-settings
    // plugin is installed, with drupal project.
    if ($this->settingsPackage && $this->getDrupalRoot() && !$this->bltUpdated) {
      $vendor_dir = $this->composer->getConfig()->get('vendor-dir');
      $this->executeCommand(
        $vendor_dir . "/bin/drush drs:init:settings", [],
        TRUE
      );
    }
  }
vishalkhode1 commented 3 hours ago

Hi @korkhau Thank you for reporting this issue. If I understand your concern correctly, you would like to prevent the drs:init:settings command from being invoked during composer install. If that’s accurate, here are two possible solutions:

Quick Solution (Option 1): Update your root's composer.json file to disallow the "acquia/drupal-recommended-settings" plugin. I believe the DRS plugin will still be downloaded, but none of its associated events will be triggered. Ex:

"config": {
  "allow-plugins": {
    "acquia/drupal-recommended-settings": false
  }

Recommended Solution (Option 2): Modify the SettingsDrushCommands class to implement the CustomEventAwareInterface as Drush recommend the same here. This approach allows others to define and implement a custom event that determines whether command drs:init:settings should be executed or skipped.