Skip to content
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

Comparison to Composer Scaffold #107

Open
danepowell opened this issue Sep 25, 2019 · 7 comments
Open

Comparison to Composer Scaffold #107

danepowell opened this issue Sep 25, 2019 · 7 comments

Comments

@danepowell
Copy link

danepowell commented Sep 25, 2019

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?

@greg-1-anderson
Copy link
Collaborator

This does not answer all of your questions, but please see drupal-composer/drupal-project#522

@greg-1-anderson
Copy link
Collaborator

In short, we will want to deprecate drupal-composer/drupal-scaffold once the new component is in use in drupal-composer/drupal-project.

@danepowell
Copy link
Author

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.

@hudri
Copy link

hudri commented Jan 28, 2020

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/" }

@greg-1-anderson
Copy link
Collaborator

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.

@hudri
Copy link

hudri commented Jan 28, 2020

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

@danepowell
Copy link
Author

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.

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