Skip to content

composer install and composer require should not rewrite .htaccess and other files #556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tinamrak opened this issue Mar 3, 2020 · 5 comments

Comments

@tinamrak
Copy link

tinamrak commented Mar 3, 2020

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?

@tinamrak
Copy link
Author

tinamrak commented Mar 3, 2020

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: #522

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

@tinamrak
Copy link
Author

tinamrak commented Mar 3, 2020

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?

@normanlolx
Copy link
Collaborator

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.

@joestewart
Copy link

joestewart commented Mar 3, 2020

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

@tinamrak
Copy link
Author

tinamrak commented Mar 3, 2020

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.

@tinamrak tinamrak closed this as completed Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants