Drupal-project: composer install and composer require should not rewrite .htaccess and other files

Created on 3 Mar 2020  路  5Comments  路  Source: drupal-composer/drupal-project

I've been using this project for all my Drupal sites and I noticed one thing that bothers me.

When requiring new modules locally or running composer install on production (I use git for deployment) the following files will always be overwritten.

Screenshot

I understand that this is done on composer create-project and composer update but why when requiring new modules?

Is there any way to prevent this?

Most helpful comment

Relevant core issue: "Avoid re-scaffolding unchanged files (and printing scaffold file information over and over)" https://www.drupal.org/project/drupal/issues/3103090

All 5 comments

I was sure that this didn't happen in the past so I explored a little further (thanks Zan for helping me) and found that this happens since drupal-composer/drupal-scaffold was changed to drupal/core-composer-scaffold. Related issue: https://github.com/drupal-composer/drupal-project/pull/522

Are there any downsides if I keep the old (drupal-composer/drupal-scaffold) package?

I found a solution but this will also exclude these files on composer update: Excluding Scaffold Files

I'm not an expert in composer but is it possible to somehow disable exclusion on composer update?

Maybe use the approach covered on the same page under Altering Scaffold Files. By that you always use the core scaffold files and apply your own patches to make them look like you want. When you $ composer update and there are changes in these files you'll recognise it by your patches failing to apply. You then can review and readjust your patches accordingly. https://drupal.stackexchange.com/a/290990/15055

But let's continue this discussion somewhere else. It's off-topic here.

Relevant core issue: "Avoid re-scaffolding unchanged files (and printing scaffold file information over and over)" https://www.drupal.org/project/drupal/issues/3103090

Thank you both!
I also found this issue: https://www.drupal.org/project/drupal/issues/3092563

Scaffold files should not be modified in Composer-managed Drupal sites; instead, users are expected to use "append" or "patch" capabilities to add their custom content to the Drupal-provided files. Some users do not know this yet, though, so some additional behavior to detect and warn users who modify the generate files is being proposed.

I am closing this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chanster picture chanster  路  5Comments

zaxx81 picture zaxx81  路  5Comments

InspiredPrynce picture InspiredPrynce  路  4Comments

9034725985 picture 9034725985  路  6Comments

superfedya picture superfedya  路  7Comments