Impossible to append from a library implementing composer-scaffold

Created on 1 May 2024, about 2 months ago
Updated 2 May 2024, about 2 months ago

Problem/Motivation

I'm trying to implement a library that scaffolds custom settings-custom.php file and include that into the main settings.php file, exactly like in the example in https://git.drupalcode.org/project/drupal/-/blob/11.x/composer/Plugin/Sc... following this description

"The example below demonstrates scaffolding a settings-custom.php file, and
including it from the existing settings.php file."

Steps to reproduce

Following Examples

  • define a library, main-settings, that will scaffold settings.php
  • define another library, custom-settings, that will scaffold settings-custom.php and append it to the settings.php scaffolded by the main-settings
  • run composer drupal:scaffold

Expected result: settings-custom.php appended to the settings.php scaffolded by the main-settings

Actual result: append operation skipped with

- Skip [web-root]/sites/default/settings.php: overridden in library/main-settings

Proposed resolution

Fix the bug.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Closed: works as designed

Version

11.0 πŸ”₯

Component
ComposerΒ  β†’

Last updated about 22 hours ago

No maintainer
Created by

πŸ‡³πŸ‡ΏNew Zealand RoSk0 Wellington

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @RoSk0
  • πŸ‡³πŸ‡ΏNew Zealand RoSk0 Wellington

    Formatting

  • πŸ‡³πŸ‡ΏNew Zealand RoSk0 Wellington

    When I tried to replicate this issue on a pure core 10.3 , unfortunately I don't have access to PHP 8.3 to testing on Drupal 11, the behaviour was different - requiring main-settings library scaffolds settings.php as expected, however requiring custom-settings library scaffolds the settings-custom.php and completely ignores the main settings.php - there is even no mention of it in the output related to the custom-settings library ... Feels like that file is completely ignored.

    However if I remove main-settings library and leave settings.php in place - custom-settings library appends to it as expected:

    Scaffolding files for library/custom-settings:
      - NOTICE Modifying existing file at [web-root]/sites/default/settings.php. Examine the contents and ensure that it came out correctly.
      - Append to [web-root]/sites/default/settings.php from assets/settings-php-include.txt
    
  • Status changed to Closed: works as designed about 2 months ago
  • πŸ‡³πŸ‡ΏNew Zealand RoSk0 Wellington

    I've already was burnt by the order once and somehow managed to forgot about it - order of the packages in the `allowed-packages` list is very important!

    My libraries was ordered incorrectly in the top level composer.json:

    "drupal-scaffold": {
                "allowed-packages": [
                    "library/custom-settings",
                    "library/main-settings"
                ],
            }
    

    and it should be

    "drupal-scaffold": {
                "allowed-packages": [
                    "library/main-settings",
                    "library/custom-settings"
                ],
            }
    

    .

    All of this is properly documented in the README.md "Allowed packages" section.

Production build 0.69.0 2024