Open danepowell opened 5 years ago
This does not answer all of your questions, but please see https://github.com/drupal-composer/drupal-project/pull/522
In short, we will want to deprecate drupal-composer/drupal-scaffold once the new component is in use in drupal-composer/drupal-project.
Thanks a lot, I searched for exactly such an issue in drupal-composer/drupal-project queue, not sure how I missed that 🙄
I think it would be good to document that this transition is happening in the READMEs for each project, but it's up to you, this at least answers the question for me. Thanks again.
If drupal-composer/drupal-scaffold
is going to be deprecated:
Anybody having some ideas how to switch existing projects from drupal-composer/drupal-scaffold
to drupal/core-composer-scaffold
using an automated method? I'm currently updating a few dozen projects running v8.7.x and I'd like to transform existing composer.json
to the new format using CLI commands to automatically update all projects.
One of the very first problems i've found is that the config-command allows nesting up to a max-depth of three levels only. So
composer config extra.drupal-scaffold.locations.web-root 'web/'
results into
"drupal-scaffold": { "locations.web-root": "web/" }
Conversion tools are planned. There is an issue for converting non-Composer projects into Composer projects. There will also be a tool for updating from old to new Composer components, but there isn't an issue for it yet. The steps are discussed in Composer and Drupal: Past, Present and Future from DrupalCon Amsterdam, on slides 42 and 43.
It's too bad about composer config
. Maybe the Composer project would accept an enhancement to allow more nesting.
My workaround was doing the updates using json_encode
and json_decode
inside a PHP script, and running that file with PHP-CLI within my deployment/update shell script.
If it helps someone, here is my quick & dirty code:
$jsonString = file_get_contents('composer.json');
$json = json_decode($jsonString, FALSE);
if (is_null($json) || !$json || !$jsonString) {
fwrite(STDERR, "composer.json could not be read\n");
exit(1);
}
//new drupal/core scaffolding (can't be done with composer CLI)
$json->extra->{'drupal-scaffold'} = new stdClass();
$json->extra->{'drupal-scaffold'}->locations = new stdClass();
$json->extra->{'drupal-scaffold'}->locations->{'web-root'} = 'web/';
//could be done with composer CLI too
$json->require->{'php'} = '>=7.0.8';
$json->require->{'drupal/core-recommended'} = '^8.8.1';
$json->require->{'drupal/core-composer-scaffold'} = '^8.8.1';
unset($json->scripts->{'drupal-scaffold'});
unset($json->require->{'webmozart/path-util'});
unset($json->{'require-dev'}->{'webflo/drupal-core-require-dev'});
//write the new composer.json
$newJson = json_encode($json, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
file_put_contents('composer.json', $newJson);
Delete the old composer.lock
and run composer install
- worked for me quite well inside a bash script running over all my projects
Acquia BLT provides a command for migrating to Composer Scaffold, however it's fairly specific to projects created using BLT's project template and limited in what configuration it tries to preserve. Perhaps a useful reference though.
It seems like Composer Scaffold (https://github.com/grasmash/composer-scaffold) is a more flexible replacement for Drupal Scaffold that could largely replace it, and perhaps that's what the community has decided to do, but it's not very well documented. Is there any plan to deprecate Drupal Scaffold in favor of Composer Scaffold, and whether there is or not, can we document the status of and relation between these two projects in the Drupal Scaffold readme?