Reputation: 338
I'm trying to create a composer.json that generates a ready-to-use Drupal 8 (based on the excellent Drupal Project). It works well, but I want to include a custom theme that'll be use as a base for any developer. This theme is call in the composer.json "my-package/my-theme": "*"
, and is automatically include in the Drupal's theme folder. Perfect!
The problem is : when you make a change to this theme, if you run a composer install
or composer update
, all your changes get deleted. I understand that's a normal behavior of Composer.
So, is it possible to install a package without saving it into composer.json / composer.lock ?
composer remove my-package/my-theme --no-update
, but it removed my package only in composer.json and not composer.lock, which give the same result.Upvotes: 1
Views: 2955
Reputation: 338
Answered here by a Composer contributor :
This is intentionally impossible as well, not a missing feature or anything. The vendor folder is Composer's alone to meddle with.
Fyi - Node's
npm
is not only able to install packages without saving them, it's even default. And this is one of the main reasons many people are now usingyarn
instead because it cannot not save, as it is highly frustrating to discover while deploying to production that you forgot to add--save
to that one vital dependency. One of Composer's main design goals is absolute dev/prod parity for dependencies.
I found an alternative solution for anyone having the same issue :
For anyone wanting to achieve the same thing as me, I finally make a custom script launched after install that :
- Make a copy of the theme folder
- Change any mention of the previous theme system name to the new one (filenames + directly into files)
- Remove theme with composer remove command
- And finally enable the new theme
It works for me as the downloaded theme is just a base to start development and not an actual theme that will be updated.
Upvotes: 0
Reputation: 9022
If your theme is part of your installation profile, it should be present in the composer.json file. Your developer should only use that theme as a base theme and create a sub-theme. Within that sub-theme, the developer can overwrite CSS as well as template files and template functions.
Upvotes: 1