Skip to content

Comparison to Composer Scaffold #107

Description

@danepowell

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?

Activity

  1. greg-1-anderson commented on Sep 25, 2019

    @greg-1-anderson
    Collaborator

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

  2. greg-1-anderson commented on Sep 25, 2019

    @greg-1-anderson
    Collaborator

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

  3. danepowell commented on Sep 25, 2019

    @danepowell
    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.

  4. hudri commented on Jan 28, 2020

    @hudri

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

  5. greg-1-anderson commented on Jan 28, 2020

    @greg-1-anderson
    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.

  6. hudri commented on Jan 28, 2020

    @hudri

    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

  7. danepowell commented on Jan 28, 2020

    @danepowell
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions