This is a child issue of #2982674: [meta] Composer Initiative Phase 1: Add composer build support to core
Problem/Motivation
Given a normalization to Composer-based site building, we need a tool to convert non-Composer-based sites into Composer-based ones.
We're targeting 'tarball' style installs, which have downloaded Drupal from the download page of drupal.org, and have then installed in place.
We want a core-native tool which can be easily used to reliably make a composer.json file, ideally without much user intervention.
Proposed resolution
Since Drupal tarball downloads will be Composer-ready out of the box, and updating a Drupal site via drush pm-update
essentially involves swapping out (parts of) your current code with the latest tarball download, so for folks who do not have any contrib modules, converting to Composer-managed will be a simple matter of running "composer update". Folks who do have contrib modules will need their composer.json adjusted post-update.
There are two stages:
- In a Composer post-update script, conspicuously warn the user that: a) they cannot go back and use `drush pm-update drupal` any longer, and b) they will need to add their contrib modules to their composer.json file. Maybe even do this in a pre-update script, if we want to prompt the user prior to conversion.
- After 1.b, prompt the user and ask them if they would like to import their contrib modules into their composer.json file. If they confirm, run a version of composerize-drupal ported into drupal/drupal project. If they decline, print a warning that `composer update` is not updating their contrib modules. We might want to warn but not prompt if the user is explicitly updating only drupal/core at this time.
composerize-drupal is already a Composer plugin, so it probably will not need a lot of work to convert it to this workflow. If we include it via a `path` repository, we can commit it to composer/Plugins
in the drupal/drupal repository. This will cause it to appear in the vendor
directory once the tarball generation process is altered to build the download archives from the Composer project templates. It could potentially even remove itself after it was done.
Remaining tasks
- [ ] Port grasmash/composerize-drupal to composer/Plugins directory, and add it as a path repository.
- [ ] Remove functionality of composerize-drupal' that is no longer necessary (alteration of root composer.json, .gitignore, etc., where such things have already been provided by the Composer-ready download).
- [ ] Warn the user at `composer update` time that they've started out on a one-way trip.
- [ ] Prompt the user after updating to a Composer-managed site, and ask them if they want to convert their contrib modules too. Ask every time they run `composer update` until the contrib modules are converted.
- [ ] Optional. Remove the conversion plugin after it has converted the contrib modules.