As a follow-up to #1978180: Re-build with Composer Manager when enabling a module with Drush, we shouldn't run Composer's update command every time we enable a module. We should only perform the actions if necessary to improve the DX.

Comments

cpliakas’s picture

Status: Active » Needs review
StatusFileSize
new2.73 KB

Attached patch seems to work. Couple of things to point out...

  • The logic is changed to leverage Composer Manager's hook_enable() implementation for the composer.json rebuild. This eliminates the file being built twice.
  • I also implemented Drush's disable hook so that dependencies are removed when a module containing a composer.json file is disabled

We should also explore adding an option in the UI to neither rebuild the composer.json file nor prompt the user to update Composer dependencies. The use case here is if you have a site in production where you don't want to ever modify composer.json and the packages it manages but have to disable a module in an emergency. On hosted platforms you might not have the ability to write to these locations anyways depending on how it is set up and how the application is configured.

cpliakas’s picture

StatusFileSize
new2.77 KB

Same functionality, modified comments in composer_manager_write_if_changed() for clarity.

cpliakas’s picture

Status: Needs review » Needs work

Marking as needs work to implement the setting mentioned in #1.

cpliakas’s picture

Status: Needs work » Needs review
StatusFileSize
new4.94 KB

Attached patch adds the setting.

cpliakas’s picture

Status: Needs review » Fixed

I'm super-psyched about this patch because I think it really improves the DX and allows people to not have to think about Composer when installing and disabling modules via Drush, so I am committing.

http://drupalcode.org/project/composer_manager.git/commit/1a51e83

Status: Fixed » Closed (fixed)

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