Problem/Motivation

In order to maintain appropriate security, safety and "principal of least surprise," the Scaffold Plugin will only allow a dependency to provide scaffold files if it is explicitly whitelisted in the top-level composer.json. The top-level composer.json file itself is also implicitly allowed.

At the same time, we would like to keep the Composer template projects (c.f. #2982680: Add composer-ready project templates to Drupal core) simple, so that there as few moving parts as possible to give users the best odds of being successful in moving to Composer. Also in the works is a new project drupal/legacy-scaffold-assets that will provide forward-compatibility for Drupal 8.8.x Composer components with Drupal 8.7.x sites.

Proposed resolution

Since the new core-composer-scaffold component is specifically designed for use with Drupal, it seems simpler and more logical to implicitly allow the standard projects that contain scaffold files without explicit mention in the project composer.json file.

Without this change, the project templates must contain an "allowed-packages" entry in the "extra/composer-scaffold" section:

    "extra": {
        "composer-scaffold": {
            "allowed-packages": [
                "drupal/core"
            ],
            "locations": {
                "web-root": "web/"
            }
        },

With it:

    "extra": {
        "composer-scaffold": {
            "locations": {
                "web-root": "web/"
            }
        },

If a project has a distribution / installation profile or a host-compatibility project that scaffolds files or alters scaffold files, it must still be whitelisted in "allowed-packages".

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

The Drupal Composer Scaffold component now implicitly allows the projects drupal/core and drupal/legacy-scaffold-assets to scaffold files, even if they are not whitelisted in the top-level composer.json file.

Comments

greg.1.anderson created an issue. See original summary.

greg.1.anderson’s picture

StatusFileSize
new2.78 KB

Patch enabling the implicit approval.

greg.1.anderson’s picture

Status: Active » Needs review

Set status to 'needs review'

greg.1.anderson’s picture

StatusFileSize
new3.7 KB
new943 bytes

We also want to suppress warnings about lack of scaffold files in old versions of drupal/core. This is expected if we implicitly allow core.

Mixologic’s picture

Status: Needs review » Reviewed & tested by the community

This is a reasonable thing to do. Saves extra config in the rest of the ecosystem, which, we can assume that drupal/core is not a bad actor.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Seems sane to me, as well. :) I had one question which was whether the conditional for pre-8.7 made sense to mark for explicit removal in D9, but Greg pointed out that no, because this tool will still be usable with older versions of Drupal, even in Drupal 9. Works for me!

Committed and pushed to 8.8.x. Thanks for the nice little DX improvement!

  • webchick committed 6340ef5 on 8.8.x
    Issue #3080205 by greg.1.anderson: Implicitly allow drupal/core and...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

danepowell’s picture

I updated the Composer Scaffold docs to reflect this change. Up until now, they still indicated the drupal/core had to be explicitly allowed.

If anyone wants to check my changes, I'd appreciate it: https://www.drupal.org/node/3057099/revisions/view/11668194/11712166