Problem/Motivation

In order to fix support for core in composer, we need to add a composer kickstart template to core that becomes the starting point for all future drupal sites.

The https://github.com/drupal-composer/drupal-project has shown that this is the best practice method for starting drupal sites using composer, and should be used as a basis for what this looks like.

Proposed resolution

  • Two templates will be provided: a "recommended" template modeled after drupal-composer/drupal-project, and a "legacy" template modeled after the existing tarball downloads.
  • The project templates will be split out from core using the existing subtree splitter, and will exist on packagist.org and github.com.
  • These templates *are not meant to be upgraded*. They are intended to initially set up a drupal site, but should be free from any implied features.
  • The initial effort is *not meant* to make it easier/faster/better to get a site up and running over a bare tarball. (i.e. patches/docroots/webroot/security fixes etc). Those features can be added later, in an additional template.
  • The "legacy" template is expressly designed to change absolutely nothing about what the filesystem structure and layout looks like. When you run composer create-project drupal/legacy-project, it should mirror *exactly* what you get when you download the current tarball from drupal.org git clone and composer install the git repository (although there will of necessity be minor differences in certain files, such as composer.json and composer.lock).

Remaining tasks

  1. [X] #2982684: Add a composer scaffolding plugin to core
  2. [X] Plan to support multiple templates. (Just put them in a directory)
  3. [X] Decide naming convention for templates. (drupal/recommended-project and drupal/legacy-project)
  4. [X] Decide where it's physically located inside of the directory tree. (composer/Templates)
  5. [X] Decide how to test this, and what the bar is for success vs failure. (Just test 'composer install' to start.)
  6. [X] Submit a patch that takes all of the above into account.
  7. [X] Write a change record.
  8. [X] Add documentation to drupal.org.
  9. [X] Remove .gitignore from the project template for now, pending discussion in follow-on issue (see below).
  10. [X] Make a follow-on issue to decide what to do about the .gitignore file long-term. (#3082958: Add gitignore(s) to Composer-ready project templates)
  11. [X] Make a follow-on issue to decide what to put in the "suggests" section. (#3082983: Decide what to "suggest" in Composer Project Templates)
  12. [X] Make a follow-on issue to strip wikimedia/composer-merge-plugin from drupal/core-recommended. (drupalorg-infrastructure/package-generator#1)
  13. [X] Determine whether the Composer-managed layout causes Drupal to use more memory. (Memory requirement increase not due to Composer, per #3082985: Determine whether it is expected to be able to install demo_umami with 128m of RAM)

Follow-on tasks

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

Drupal.org now provides "starter" Composer project templates that can be used to start new Composer-managed sites.

  • Use composer create-project drupal/recommended-project to create a site where the Drupal root has been relocated into a web subdirectory.
  • Use composer create-project drupal/legacy-project to create a site where the Drupal root is in the top-level directory, with the vendor folder.
CommentFileSizeAuthor
#111 2982680-111.patch8.21 KBmbaynton
#111 2982680-91-111.interdiff.txt2.27 KBmbaynton
#104 2982680-104.patch12.01 KBmbaynton
#104 2982680-91-104.interdiff.txt2.96 KBmbaynton
#91 2982680-91.patch10.48 KBMixologic
#91 2982680-80-91.interdiff.txt2.69 KBMixologic
#80 2982680-80.patch10.52 KBmbaynton
#80 2982680-74-80.interdiff.txt982 bytesmbaynton
#74 2982680-71-to-74-interdiff.txt2.03 KBgreg.1.anderson
#74 2982680-74.patch10.68 KBgreg.1.anderson
#71 2982680-66-71-interdiff.txt3.45 KBgreg.1.anderson
#71 2982680-71.patch10.69 KBgreg.1.anderson
#66 2982680-66.patch10.98 KBmbaynton
#66 2982680-54-66.interdiff.txt3.87 KBmbaynton
#54 2982680-54.patch11.2 KBgreg.1.anderson
#54 2982680-50-to-54-interdiff.txt1.96 KBgreg.1.anderson
#50 2982680-50.patch10.85 KBjibran
#50 interdiff-054ce0.txt2.32 KBjibran
#45 2982680-45.patch9.44 KBgreg.1.anderson
#45 2982680-44-to-45.interdiff.txt1.09 KBgreg.1.anderson
#44 2982680-44.patch9.96 KBgreg.1.anderson
#44 2982680-43-to-44.interdiff.txt1.42 KBgreg.1.anderson
#43 2982680-43.patch9.95 KBgreg.1.anderson
#24 2982684-23.patch1.83 KBMixologic
#2 2982680-2.patch2.69 KBwebflo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mixologic created an issue. See original summary.

webflo’s picture

Multiple templates is easy, we could do it by providing multiple templates and subtree splits.

  • drupal-project introduces a web and separate vendor folder, its the continuation of drupal-composer/drupal-project
  • drupal-project-legacy keeps the tarball structure as is
webchick’s picture

Priority: Normal » Major

This is a core requirement of the Composer initiative, so escalating to Major.

webchick’s picture

Status: Active » Needs review

Also there's a patch! :D

phenaproxima’s picture

Issue tags: +Needs manual testing

Tagging for manual testing.

phenaproxima’s picture

  1. +++ b/core/scripts/composer/drupal-project-legacy/composer.json
    @@ -0,0 +1,34 @@
    +    "name": "drupal/drupal-project-legacy",
    +    "description": "Project template for Drupal 8",
    

    Can the description explain the difference between this project and drupal/drupal-project? A _readme section in the extra block might also be useful here.

  2. +++ b/core/scripts/composer/drupal-project-legacy/composer.json
    @@ -0,0 +1,34 @@
    +            "drush/contrib/{$name}": ["type:drupal-drush"],
    

    I like this line, but I thought core wasn't supposed to be Drush-aware? I'm asking merely for completeness' sake.

webflo’s picture

Related to #6 - 2

The current version in on the repo root is already Drush-aware :)

phenaproxima’s picture

Another question: will the subtree split begin at core/scripts/composer/drupal-project? If so, maybe we want to add a .gitignore which ignores the vendor directory and any directories in the webroot which are likely to be heavily customized (modules/custom, for example). I realize this is out of scope for this issue, but maybe a follow-up is called for?

webflo’s picture

Yes the subtree split should start at core/scripts/composer/drupal-project. All other required files like .htaccess, .gitignore should be shipped via drupal-scaffold.

Mixologic’s picture

+++ b/core/scripts/composer/drupal-project-legacy/composer.json
@@ -0,0 +1,34 @@
+        "drupal-composer/drupal-scaffold": "^2.5",

Should we get the core version of the scaffold in first, and have this depend on that instead?

And if we have multiple versions (drupal-project-legacy/drupal-project), then do we need to have multiple scaffold plugins? or some way to make the scaffold plugin figure out where to lay out the files?

I just want to ensure that composer create project drupal/drupal-project-legacy creates an identical copy to what we get today with a git clone (except /composer.json and /composer.lock)

phenaproxima’s picture

I just want to ensure that composer create project drupal/drupal-project-legacy creates an identical copy to what we get today with a git clone (except /composer.json and /composer.lock)

If I understand this correctly, that will require the scaffold plugin to be ready first. So maybe we should block on that issue.

Mixologic’s picture

Status: Needs review » Postponed (maintainer needs more info)

Yep. thats what I was implying. Postponing this on #2982684: Add a composer scaffolding plugin to core

So, I was also thinking about how to test this stuff, since the subtree splits only happen against the stuff thats committed to the repository.

*if* we can agree on the name, or at least call it temporarily, I can create github projects for drupal/drupal-project and drupal/drupal-project-legacy and drupal/drupal-scaffold, and we could work on these there if need be. That way we can add them to packagist, and write the build tests to prove that they work. The final step could be then to move them into core.

Once they are in core, we'll overwrite the github repo's with the subtree splits.

phenaproxima’s picture

That sounds like a pretty good plan to me. As far as I know, Drupal CI has no way to test this kind of packaging functionality, but we could easily do it on Travis CI.

effulgentsia’s picture

Just an idea, feel free to disagree or suggest improvements, but what do you think of renaming drupal-project-legacy to drupal-project-everything-in-document-root or drupal-project-root-is-document-root?

effulgentsia’s picture

Also, the word "kickstart" doesn't appear in the patch at all. Should we remove it from the issue title as well?

Mixologic’s picture

Title: Add composer-ready kickstart component to Drupal core. » Add composer-ready project templates to Drupal core.

drupal-project-everything-in-document-root

I guess it depends on who we'd be telling to use that particular starting point.

If its literally just drupal.org's packaging infra to create identical tarballs, then we can name it whatever we want.

But, if we're going to have our documentation say stuff like "If you have a webhost that gives you just one folder and says "put your website in this folder", then we might also be telling people "run composer create project drupal/drupal-project-legacy" in that folder, or download the tarball from drupal.org.

And sure "project templates" is probably a better name than 'kickstart' for the overarching category of what these things are.

Mixologic’s picture

In light of #12, I went ahead and created 2 projects under the drupal namespace on github:

https://github.com/drupal/drupal-project-legacy
and
https://github.com/drupal/drupal-scaffold

I got rid of any branches/tags, and set the default branch to 8.6.x, and submitted both of them to packagist, and setup the auto update hooks.

That means we ought to be able to setup travisCI on the drupal-project-legacy project for the time being to run the test I outlined here: https://www.drupal.org/project/drupal/issues/2984031

Maybe @phenaproxima you can help with that? (I havent used travisCI much, being as I have another CI system where I spend most of my time).

effulgentsia’s picture

I don't know if this is feasible, but something like this might be cool if it were:

A single project with installer paths like:

"{docroot}/core": ["type:drupal-core"],

And the ability to pass the value of docroot through when calling composer create-project, maybe something like:

composer create-project drupal/drupal-project --docroot=web 

or

composer create-project drupal/drupal-project --docroot=.
Mile23’s picture

I think this issue needs some scope love.

If this is the issue where we make drupal/kickstart, then we should spec it out and only do that.

So we have:

  • What's it named?
  • Where should it live?
  • It replicates the filesystem of the current non-Composer tarball that we have.

(Two bikesheds and a specification walk into a bar...)

I suggest outside of core/ for the location since core/ is also its own Composer package. We could have a projects/ or packages/ directory, if that won't conflict with something or be too confusing. Also should have a README.txt per project explaining the whole thing.

We can do packaging type behaviors on DrupalCI, and eventually we should move to doing that, but we don't have a way to trigger different types of builds. In some ways that would be good because we can always make sure a patch doesn't break a build. But that's a bit wasteful.

Some experimentation tells me that we can make our own packages.json file for the local file system and specify that as composer create-project --repository path/to/packages.json. This would help us write in-place patch tests of builds. I'm not sure where the canonical subtree split file is located; maybe we could repurpose that in some way.

Mixologic’s picture

What's it named?

For now, we'll just go with whats in the patch, which is 'drupal/drupal-project-legacy', and 'drupal/drupal-project'. The former is mostly for the packaging infrastructure and those users who somehow have a terribad webhost with only one folder, yet want to command line composer start a project. Not a particularly common use case IMO -> most of those users will probably download the tarball. The latter will be for those who want that sweet sweet web folder.

Where should it live?

I agree that it probably should not be nested underneath /core since we're eventually wanting to make a subtree split of core that does not contain nested packages. Granted we may be able to do that anyhow, but since we're no longer treating the core repository as our product, then yes, we can make an arbitrary top level directory that is "starter-templates" or something.

It replicates the filesystem of the current non-Composer tarball that we have.

So I was doing some experiments, and I think we should aim for this to replicate the filesystem of the current git repository, and not of the tarball. The tarball is built out of the git repo, but then adds additional 'magic' to the packaging, like modifying all of the .info.yml files to have the version string added. 😢, as well as injecting the LICENSE.txt file into the root of the repo.

In the interests of doing one thing at a time, if we aim to replicate the git repo, then packaging only has to change from 'git clone' to 'composer create project' to make the tarball. We can address the version and license stuff later on in future issues. This would mean that if that version stuff is critical in the .info.yaml files, then we'll probably need to address it with something like https://www.drupal.org/project/composer_deploy

So, speaking of those experiments, I built a test that is running on travis.

https://www.drupal.org/project/drupal/issues/2984031#comment-12676495

Mixologic’s picture

Issue summary: View changes
Mixologic’s picture

Issue summary: View changes

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mixologic’s picture

terribad patch. Jetlag to blame.

bojanz’s picture

I agree that it probably should not be nested underneath /core since we're eventually wanting to make a subtree split of core that does not contain nested packages. Granted we may be able to do that anyhow, but since we're no longer treating the core repository as our product, then yes, we can make an arbitrary top level directory that is "starter-templates" or something.

Agreed. Could be just "composer", or "composer_templates" (we tend to prefer underscore over dashes, no?).

Mile23’s picture

By way of an update:

So I had been doing some work on https://github.com/drupal/drupal-project-legacy with my own fork at https://github.com/paul-m/drupal-project-legacy

The goal was to make a file-diff perfect replica of the 'tarball' package using Composer. We currently don't have a way to test this with DrupalCI, but we're using travis-ci.

I succeeded, but I had to import the Composer event scripts from core to accomplish this, since using diff means we can’t just compare the packages that were installed, but we also have to compare all the test code removal that our scripts perform when we run composer install.

I talked it over with @mixologic and the consensus was that we needed to solve the following problem: We must use those scripts to clean out test code from dependencies, but the scripts are only present in one of the dependencies, not in our template project.

That is, we must use the event scripts, but we must also not put the scripts in the drupal/drupal-project-legacy codebase.

That’s because once you use the project template, it never goes away, and more importantly it’s never modified or updated.

This is reflected in the concerns in #2990257: Determine how to handle composer scripts in drupal/drupal

Mixologic’s picture

Building off the work that @mile23 did in #26, I've updated https://github.com/drupal/drupal-project-legacy, and now we have a template that builds something very, very similar to what we get with a git clone and composer install.

Some notes:

  1. It has a lock file, which contains all of the dependencies of drupal/drupal's lock file, merged with the drupal/core, and drupal/scaffold dependencies. See #2983089: Add a core lockfile creator to generate template lockfiles. for more information on how this works.
  2. It currently has a reference to a fork of "drupal/core" so that it can test out the composer scripts that cleanup the filesystem. See #2998829: Add a composer script method to Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup.
  3. The .travis.yml file and the packages.json are there so we can setup the travis test that we have running now, which allows us to run composer create-project without needing drupal-project-legacy to be updated at packagist.
  4. The travis test that is running for this is building a drupal project with composer create-project, and then comparing that to a git clone/composer installed version of drupal. We're removing files that we *know* will be different and are not relevant to the comparison. The goal here is to prove that what we've built is functionally identical to what we provide currently in the tarball and when users start with a git clone.
  5. The results of the latest travis test can be found here: https://travis-ci.org/drupal/drupal-project-legacy/builds/443380886
  6. As we can see from https://travis-ci.org/drupal/drupal-project-legacy/builds/443350373#L832..., there are a couple of discrepancies with what composer generates as part of its autoloader.
  7. From what I can gather, these are probably related to the fact that when using the drupal git clone, we have the wikimedia merge plugin pulling all kinds of information out of the repo and feeding it to composer. Im not entirely sure if thats something we really need or not. so,

    I could *really* use more sets of eyes

    to help determine if any of this: https://travis-ci.org/drupal/drupal-project-legacy/builds/443380886#L841... matters.

Things that remain:
1. potentially move the code from core/lib/Drupal/Core/Composer/Composer.php into the drupal-scaffold plugin. Or, perhaps into a plugin of its own (re: https://www.drupal.org/project/drupal/issues/2990257#comment-12804649), Or, commit the patch in https://www.drupal.org/project/drupal/issues/2998829 to core, but suffer error messages on project creation.
2. incorporate the code reviews of the drupal-scaffold plugin (https://www.drupal.org/project/drupal/issues/2982684#comment-12769425 and https://www.drupal.org/project/drupal/issues/2982684#comment-12769839),
3. determine if the preautoloaddump script is needed (potential followup - non-blocking).
4. determine if the ensurehtaccess script is needed, or if it can be replaced by drupal-scaffold (potential followup - non-blocking).

Mile23’s picture

The diffs in https://travis-ci.org/drupal/drupal-project-legacy/builds/443380886#L841... are there because the autoloading setups are slightly different.

I just removed the whole vendor/composer directory in my version of that travis test: https://github.com/paul-m/drupal-project-legacy/blob/passing/.travis.yml... because as your diff points out: We'll have different sets of classes loading, especially with the scaffolding plugin, and potentially different order of adding the dependencies.

So if we can run and pass tests then it's clear that the autoloading is occurring, but it might not be a carbon copy of the autoloader files. Since we don't install with --dev, we have to figure out some other suitable way of proving that autoloading works. Maybe try to do the quickstart install before we delete all the different stuff: php core/scripts/drupal quick-start demo_umami

Mixologic’s picture

because the autoloading setups are slightly different.

I just want to make sure that whatever differences there are, are not material and/or important, or we at least understand why the differences are there. Im pretty sure that the answer is "because of wikimedia merge plugin" but I'd like some other folks to either confirm or deny that.

I'd be willing to bet that all of the currently installed drupal 8 sites that are using the drupal-composer/drupal-project template are also getting the same type of discrepancies in autoloading, which is somewhat of another indicator that the changes arent relevant. But again, Im just betting. Confirmation would be build confidence in this case.

Somebody could definitely try the umami profile to ensure its working in this case, as a way to prove this works.

Mile23’s picture

All the differences are either components or packages that aren't added to the tarball.

You're correct that it's the merge that does it. drupal-project-legacy doesn't do the merge that drupal/drupal does.

In drupal/drupal we merge core/composer.json recursively, and core/composer.json merges all the components. We do this so we at least verify that the components' composer.json files are usable, and that they reconcile with the other dependencies.

I just spent 20 minutes waiting for various phases of composer create-project to timeout due to network issues, so congratulate me on verifying that drupal-project-legacy does in fact add a PSR-4 classmap for Drupal\Component, which catches all the components:

    'Drupal\\Component\\' => array($baseDir . '/core/lib/Drupal/Component'),

Whereas drupal/drupal sets up PSR4 for all the individual components like Drupal\Component\[YourComponentHere], which is arguably better but not by much. See especially the last line:

    'Drupal\\Component\\Uuid\\' => array($baseDir . '/core/lib/Drupal/Component/Uuid'),
    'Drupal\\Component\\Utility\\' => array($baseDir . '/core/lib/Drupal/Component/Utility'),
    'Drupal\\Component\\Transliteration\\' => array($baseDir . '/core/lib/Drupal/Component/Transliteration'),
    'Drupal\\Component\\Serialization\\' => array($baseDir . '/core/lib/Drupal/Component/Serialization'),
    'Drupal\\Component\\Render\\' => array($baseDir . '/core/lib/Drupal/Component/Render'),
    'Drupal\\Component\\ProxyBuilder\\' => array($baseDir . '/core/lib/Drupal/Component/ProxyBuilder'),
    'Drupal\\Component\\Plugin\\' => array($baseDir . '/core/lib/Drupal/Component/Plugin'),
    'Drupal\\Component\\PhpStorage\\' => array($baseDir . '/core/lib/Drupal/Component/PhpStorage'),
    'Drupal\\Component\\HttpFoundation\\' => array($baseDir . '/core/lib/Drupal/Component/HttpFoundation'),
    'Drupal\\Component\\Graph\\' => array($baseDir . '/core/lib/Drupal/Component/Graph'),
    'Drupal\\Component\\Gettext\\' => array($baseDir . '/core/lib/Drupal/Component/Gettext'),
    'Drupal\\Component\\FileSystem\\' => array($baseDir . '/core/lib/Drupal/Component/FileSystem'),
    'Drupal\\Component\\FileCache\\' => array($baseDir . '/core/lib/Drupal/Component/FileCache'),
    'Drupal\\Component\\EventDispatcher\\' => array($baseDir . '/core/lib/Drupal/Component/EventDispatcher'),
    'Drupal\\Component\\Discovery\\' => array($baseDir . '/core/lib/Drupal/Component/Discovery'),
    'Drupal\\Component\\Diff\\' => array($baseDir . '/core/lib/Drupal/Component/Diff'),
    'Drupal\\Component\\DependencyInjection\\' => array($baseDir . '/core/lib/Drupal/Component/DependencyInjection'),
    'Drupal\\Component\\Datetime\\' => array($baseDir . '/core/lib/Drupal/Component/Datetime'),
    'Drupal\\Component\\ClassFinder\\' => array($baseDir . '/core/lib/Drupal/Component/ClassFinder'),
    'Drupal\\Component\\Bridge\\' => array($baseDir . '/core/lib/Drupal/Component/Bridge'),
    'Drupal\\Component\\Assertion\\' => array($baseDir . '/core/lib/Drupal/Component/Assertion'),
    'Drupal\\Component\\Annotation\\' => array($baseDir . '/core/lib/Drupal/Component/Annotation'),
    'Drupal\\Component\\' => array($baseDir . '/core/lib/Drupal/Component'),

The scope here is to be able to build a file-perfect replica of drupal/drupal. So we can do that easily minus the autoloading files, if we prove that the autoloading works by running something in the travis test.

We have a few options:

1) Not care about this discrepancy as long as we run something to prove that autoloading works.

2) Add the merge plugin and have it recursively merge core/composer.json. This gets us a similar set of PSR4 arrays. The reason we have the merge is to exercise the composer.json files. We don't need the merge here because we exercise it whenever we use drupal/drupal. But it would maybe give us similar PSR4 arrays.

3) Make core/composer.json require the components. That's part of the goal in this issue: #2943842: Allow component namespaces to be autoloaded independently and others. So we shouldn't do that here.

Mixologic’s picture

Fabulous. Thanks for verifying that.

The scope here is to be able to build a file-perfect replica of drupal/drupal.

Or, if there *are* changes, to be able to explain any discrepancies and confirm that its all backwards compatible and not going to impact/impair existing sites or functionality, so I think this qualifies.

As far as the options go:

1. is where I think we should focus.

2. I'd love to kill the merge plugin with fire. We should have better ways to "exercise the composer.json files", we definitely dont want to have this moving forward, and we definitely want to revert the addition of it to drupal/core.

3. Definitely want to do this, and it'll be significantly easier to do once these templates are in place, but I don't think it needs to be done just yet.

So, was exploring the quick start, which seems like a reasonable assumption that core needs at least one of the components to render the home page of umami, and it appears to work fine. I ran `php core/scripts/drupal quick-start demo_umami` and curl'ed the homepage for both the git repo version and the template version, and they were identical in every way except the expected hash tokens were different.

so, I'm comfortable saying "not care about the discrepancy" - as I dont think we really need to add the check to travis since it'd be kinda tough to do a comparison without figuring out how to handle the itok/hashing stuff in the html etc.

Mile23’s picture

Is there a PR or github branch related to this work?

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture

Issue summary: View changes

Updating IS to show that the only real blocker here is #2982684: Add a composer scaffolding plugin to core

Mile23’s picture

Status: Postponed (maintainer needs more info) » Postponed

Over in the Composer Initiative meeting we decided that the scaffolding plugin and the vendor cleanup plugin should be different. #3053800: Agenda for 5-15-2019

So now we're also blocked by #3057094: Add Composer vendor/ hardening plugin to core

We'll also be able to reliably test after #3031379: Add a new test type to do real update testing but that might not be a hard blocker.

greg.1.anderson’s picture

I forked https://github.com/greg-1-anderson/drupal-drupal-composer to demonstrate the legacy project using the drupal/scaffold plugin #2982684: Add a composer scaffolding plugin to core.

grasmash’s picture

I'd like to document some thoughts coming out of the the most recent Composer in Core initiative meeting.

For the initiative to be successful, we will need to modify and create multiple composer packages. I was having some trouble wrapping my head around all the packages, their purposes, their file structures, and their dependencies, so I've drafted a quick summary of the plan:

drupal/core

8.8.x

This will contain Drupal core files and files that were formerly "scaffold" files within the drupal/drupal package. I.e., the structure will look like:

* assets
** scaffold
*** .htaccess
*** robots.txt
*** ...
** ...
* config
* includes
* ...

drupal/drupal

8.7.x

This branch would be deprecated. It (still) cannot be used to create new Drupal projects that can be managed with Composer.

I.e., the structure will (still) look like:

* core
* .htaccess
* vendor
* ...

8.8.x

This branch will be used to create new Drupal projects that can be managed with Composer.

I.e., the structure will look like:

* docroot
** core (provided by drupal/core package)
*** assets
**** scaffold
***** .htaccess
** .htaccess (copied from docroot/core/assets/scaffold/.htaccess)
** ...
* vendor
* ...

And it’s composer.json will include:

{
  "name": "my/project",
  "require": {
    "drupal/core": "^8.8",
    "drupal/core-strict": "^8.8",
  },
}

drupal/drupal-legacy

This package will support the legacy layout for future versions of core. I.e, it will support the layout of files used in drupal/drupal:8.7.x and prior, but will do so for drupal/core 8.8.x and forward.

The purpose of this package is to provide an upgrade path for users that downloaded Drupal using a tarball. This package will be used to continue to generate tarballs on Drupal.org using an (unchanged) legacy layout of files.

drupal/core-strict

This package will force projects to use exactly the versions of pinned dependencies that Drupal core specifies in its own composer.lock file, much like https://github.com/webflo/drupal-core-strict.

Mile23’s picture

New child issue, working on the scaffolding package: #3067645: Add core scaffold assets to drupal/core's composer.json extra field

Mile23’s picture

New child issue. Begone, foul merge! #2912387: Stop using wikimedia/composer-merge-plugin

Mixologic’s picture

jibran’s picture

Status: Postponed » Active
greg.1.anderson’s picture

Yes, we can start working here. We probably want to do #3076600: Create drupal/core-recommended metapackage before we call this issue done, though.

The tests for my prototype project are green again using the scaffold files from drupal/core:

https://travis-ci.org/greg-1-anderson/drupal-drupal-composer/builds/5768...

This project is a good starting point for making the templates here.

greg.1.anderson’s picture

Status: Active » Needs review
FileSize
9.95 KB

Here are some templates for the "recommended" and "traditional" project layouts. As noted in the README, the Vendor Hardening plugin is not included yet pending #3077455: Move Drupal Components out of 'core' directory.

I included a couple of extremely rudimentary tests for the provided template projects: composer install must work, and both the core directory and the autoload.php file must be placed in the correct location. We can improve the tests with #3031379: Add a new test type to do real update testing, once that is committed.

greg.1.anderson’s picture

Fix typo / quote escaping error.

greg.1.anderson’s picture

My naive tests did not play well with the test bot; rather than fiddle with it, I am just going to take out the simple assertions and rely on only the exit code for `composer install`, and see if we can't do something better after #3031379: Add a new test type to do real update testing.

greg.1.anderson’s picture

Status: Needs review » Postponed

Marking as postponed on #3077455: Move Drupal Components out of 'core' directory, which is preventing us from adding the Vendor Hardening plugin here.

jibran’s picture

Status: Postponed » Needs review
+++ b/core/drupalci.yml
@@ -51,9 +51,5 @@ build:
-          - "[ -f ${SOURCE_DIR}/composer/Template/RecommendedProject/web/autoload.php ] || echo 'No autoload.php file' && exit 1"
-          - "[ -f ${SOURCE_DIR}/composer/Template/RecommendedProject/web/core/authorize.php ] || echo 'No authorize.php file' && exit 1"
...
-          - "[ -f ${SOURCE_DIR}/composer/Template/TraditionalProject/autoload.php ] || echo 'No autoload.php file' && exit 1"
-          - "[ -f ${SOURCE_DIR}/composer/Template/TraditionalProject/core/authorize.php ] || echo 'No authorize.php file' && exit 1"

Let's create a script file for these and then we can run that here.

greg.1.anderson’s picture

Status: Needs review » Postponed

@jibran: That's not a bad idea. However, even if we do not wait on #3031379: Add a new test type to do real update testing, we are still blocked on #3077455: Move Drupal Components out of 'core' directory. I'd recommend waiting to see how both of those issues progress before deciding how to move forward here; however, I wouldn't be opposed if someone wanted to try making a patch for #47 as a contingency.

Mixologic’s picture

Status: Postponed » Needs work

So I believe that we're unpostponed now.

jibran’s picture

RE #48: How about something like this?

greg.1.anderson’s picture

#50 looks very similar to the script I wrote last night. :)

I'm +1 on it, except that I would put the test script somewhere in 'core/tests' rather than in 'core/scripts'.

greg.1.anderson’s picture

Status: Needs review » Needs work

We also need to add the vendor hardening plugin to the traditional template (but not the recommended template).

I'm going to wait until the tests in #50 complete before rolling a new patch, but anyone else who feels like pushing this forward is welcome to do so.

greg.1.anderson’s picture

Status: Needs work » Postponed
greg.1.anderson’s picture

Status: Postponed » Needs review
FileSize
1.96 KB
11.2 KB

Added vendor hardening plugin, moved the script, and fixed up the .gitignore file for the recommended project template.

Setting the status to 'needs review' so that the tests will run, but this should go back to 'postponed' once the job is complete.

jibran’s picture

+++ b/core/scripts/drupal_project_templates.sh
@@ -0,0 +1,44 @@
+set -euo pipefail
+IFS=$'\n\t'
+
+#/ Usage:       ./drupal_project_templates.sh
+#/ Description: Container command to check default composer templates.
+#/ Options:
+#/   --help: Display this help message
+usage() { grep '^#/' "$0" | cut -c4- ; exit 0 ; }
+expr "$*" : ".*--help" > /dev/null && usage
+
+info()    { echo "[INFO]    $*" ; }
+fatal()   { echo "[FATAL]   $*" ; exit 1 ; }

I copied these utlity methods from @nicksanta's blog post https://www.nicksantamaria.net/post/boilerplate-bash-script/.

voleger’s picture

Status: Needs review » Postponed

See #54

greg.1.anderson’s picture

The issue that this one is postponed on is RTBC, so I expect we should be un-postponed again here soon. In the meantime, if anyone has any review comments on things that need to be changed, feedback would be appreciated. Of particular note is whether the README says what it needs to say. We could also use a change record here (the two already listed are actually for subtasks of this issue). I'll probably have time to write up the change record later this evening if someone else doesn't do it first.

jibran’s picture

Here is a suggestion.

+++ b/core/drupalci.yml
rename from core/scripts/drupal_project_templates.sh
rename to core/tests/test_composer_project_templates.sh

Let's move it under core/tests/scripts/.

Mile23’s picture

+++ b/core/tests/test_composer_project_templates.sh
@@ -0,0 +1,44 @@
+#/ Usage:       ./drupal_project_templates.sh

+1 on core/tests/scripts/.

Also, can we add a @todo to this script so that we'll convert this to a build test after #3031379: Add a new test type to do real update testing?

That way you won't need bash to run this test, and it can be easily performed locally.

Mixologic’s picture

  1. +++ b/composer/Template/RecommendedProject/composer.json
    @@ -0,0 +1,51 @@
    +        "drupal/core-recommended": "8.8.x-dev",
    +        "drupal/core-composer-scaffold": "8.8.x-dev"
    ...
    +        "drupal/dev-dependencies": "8.8.x-dev"
    
    +++ b/composer/Template/TraditionalProject/composer.json
    @@ -0,0 +1,52 @@
    +        "drupal/core-recommended": "8.8.x-dev",
    +        "drupal/core-composer-scaffold": "8.8.x-dev",
    +        "drupal/core-vendor-hardening": "8.8.x-dev"
    ...
    +        "drupal/dev-dependencies": "8.8.x-dev"
    

    The version numbers here concern me. When core is released, should these be 8.8.0? Do these need to be bumped every minor version?

    can/should these be self.version?

    drupal/traditional-project and drupal/recommended-project are going to get the exact version/tag numbers from whatever version of core they are subtree split from.

    Also, is 'traditional' vs 'recommended' clear enough as to which is which? Im somewhat in favor of 'legacy' over traditional, just because that language would cause anybody who needs that to question 'what am I doing wrong by using 'legacy' ?'

  2. +++ b/composer/Template/RecommendedProject/composer.json
    @@ -0,0 +1,51 @@
    +        "composer-exit-on-patch-failure": true,
    +        "patchLevel": {
    +            "drupal/core": "-p2"
    +        },
    

    Are these artifacts of including cweagans/composer_patches

greg.1.anderson’s picture

@todo-ing the tests is a good idea.

> When core is released, should these be 8.8.0?

Actually, we can just start using '^8.8'. With minimum-stability: dev, that will select 8.8-x.dev. Once we have a stable release of Drupal 8.8.0, and stable release of our behat/mink dev dependencies, we can switch minimum-stability to "stable".

self.version would not be right, because folks usually do not tag their projects with the version of Drupal they are using, and these are templates for copying -- they will not be used directly.

> I'm somewhat in favor of 'legacy' over traditional

We should definitely delve into the naming conventions here so that we can hone in on the best name. First off, I want to be clear that I'm okay with 'legacy', and think it's fine to go with this option if it is the consensus.The reason I prefer 'traditional' over 'legacy' is that the later implies 'deprecated'. The flat layout is definitely the less-esteemed option, but I also feel like it's probably here to stay. Bare-bones providers commonly have no-config web server setups where there is no option but to serve files from the root of the directory that you can write files to. Drupal will probably still be supporting this layout in Drupal 9 and Drupal 10. I would prefer to use the word 'legacy' only when you're actually getting legacy code - something that is not main-line Drupal. If you use the 'traditional' layout, what you get is the real Drupal.

Other names we might consider:





drupal/
flat

inadvisable

use-with-caution

for-barebone-hosting-only

here-there-be-dragons

OK, most of those are not serious. But I care 3/10, let's just take a straw poll or something and pick one. (Last option, for the ballot stuffers: boaty-mc-boat-project).

> Are these artifacts of including cweagans/composer_patches

I copied this configuration from drupal-composer/drupal-project. In general, I think that we should strip as much optional stuff out of the template as possible, and strictly speaking, cweagans/composer-patches and its configuration thereof is optional. However, it is very common for folks to need to patch their Drupal sites, so it seemed very desirable to me to have common configuration like this available in the standard template.

This configuration is also the answer to the question I had in slack the other day: does patching drupal/core even work (since the patch was rolled against drupal/drupal), and if so, how? This config sets -p2 for drupal/core only, which adjusts for the difference in nesting levels in the patch. Patches rolled against modules don't need this setting, so they won't get it.

mbaynton’s picture

@Mixologic, I thought I'd test doing it with self.version, but to do that I'd like to reproduce "the existing subtree splitter" locally. Where can I learn more about that / see exactly what is being run?

mbaynton’s picture

Argh, I was one refresh behind on this issue, never mind.

self.version would not be right, because folks usually do not tag their projects with the version of Drupal they are using, and these are templates for copying -- they will not be used directly.

webchick’s picture

Status: Postponed » Needs review
greg.1.anderson’s picture

Status: Needs review » Needs work

Woot! We are unblocked! Still a pile of things to do, mostly minor, in #58, #59, #60 and #61.

mbaynton’s picture

Status: Needs work » Needs review
FileSize
3.87 KB
10.98 KB

Pile of minor things patch

mbaynton’s picture

Re:

We should definitely delve into the naming conventions here so that we can hone in on the best name. ... let's just take a straw poll or something and pick one

I'll suggest that I agree with @greg.1.anderson. "traditional" by itself isn't strong language, but contrasted with "recommended" I think communicates here-there-be-dragons at the appropriate volume. I'll then request that my vote count proportionally less to bigger contributors on this initiative.

greg.1.anderson’s picture

Oh, another thing on the naming conventions front: if we go with project templates such as `drupal/recommended`, `drupal/traditional` and/or `drupal/legacy`, we are folding into the same namespace as all of the Drupal projects. Today, there are no projects named "recommended" or "traditional", but there IS a project named "legacy". Applesauce.

If we go with "legacy", we'd have to add a modifier, like "legacy-project". I kind of prefer the shorter names, although the issue summary still says "drupal-project-legacy" (by which I think "drupal/project-legacy" was meant).

+1 on #66, but I can't RTBC here. I'll write up a change record, and then I think we just need to ro-sham-bo on the project names to be done (so not quite RTBC yet anyway).

greg.1.anderson’s picture

Regarding #60 / #61, I was just reading the issue summary again, and it definitely says that patches is a non-goal for the template projects. So, as very useful and common as cweagans/patches is, perhaps we should take that out.

I'll do that & fix the test failure in #66.

Mile23’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record, +Needs documentation

Adding NCR and ND tags cuz we need those things. Documentation can be just a copy of the readme.

For names: +1 for drupal/legacy-project and drupal/recommended-project.

We're going to recommend the recommended project. :-) But since it's recommended and not required, it should be clear that people can roll their own if they want to.

Also, that's how you say it: Drupal legacy project, Drupal recommended project.

+++ b/core/tests/scripts/test_composer_project_templates.sh
@@ -0,0 +1,46 @@
+# @todo: convert to a build test after #3031379 is in.

Sorry I referenced the wrong issue. We should link to the more-specific #2984031: Create Build Tests For Composer and Drupal instead.

greg.1.anderson’s picture

Status: Needs work » Needs review
FileSize
10.69 KB
3.45 KB

Remove cweagans/patches configuration, and adjust base pass in test script. Renamed 'drupal/traditional-project' to 'drupal/legacy-project'. Updated issue reference in test script TODO.

greg.1.anderson’s picture

Issue summary: View changes

Update issue summary.

greg.1.anderson’s picture

Issue summary: View changes

Provide link to follow-on task to update tarball download generation.

greg.1.anderson’s picture

Update documentation to change references to "traditional" to "legacy".

greg.1.anderson’s picture

Issue summary: View changes
Issue tags: -Needs change record

Wrote a change record.

greg.1.anderson’s picture

Issue summary: View changes
Issue tags: -Needs documentation
greg.1.anderson’s picture

Add another follow-on task: update documentation once Drupal 8.8.0 is sufficiently ready.

Mixologic’s picture

  1. +++ b/composer/Template/LegacyProject/composer.json
    @@ -0,0 +1,48 @@
    +    "extra": {
    +        "composer-scaffold": {
    +            "allowed-packages": [
    +                "drupal/core"
    +            ],
    
    +++ b/composer/Template/RecommendedProject/composer.json
    @@ -0,0 +1,47 @@
    +    "extra": {
    +        "composer-scaffold": {
    +            "allowed-packages": [
    +                "drupal/core"
    +            ],
    

    Should we postpone on #3080205: Implicitly allow drupal/core and legacy scaffold projects to scaffold files. ?

  2. +++ b/core/drupalci.yml
    @@ -48,3 +48,7 @@ build:
    +      container_command.drupal_project_templates:
    +        commands:
    +          - "sudo -u www-data ${SOURCE_DIR}/core/tests/scripts/test_composer_project_templates.sh"
    +        halt-on-fail: true
    
    +++ b/core/tests/scripts/test_composer_project_templates.sh
    @@ -0,0 +1,46 @@
    +# @todo: convert to a build test after #2984031 is in.
    

    Im not really a fan of using drupalci container commands as tests - the CI system doesn't behave the same if a composer command fails vs how it treats actual testing framework things.

    Given that this is the best we can probably do until #3031379: Add a new test type to do real update testing is in, though, I wont protest very strongly, and do not believe we should postpone for those tests that we'll eventually make in #2984031: Create Build Tests For Composer and Drupal.

greg.1.anderson’s picture

I think we should not postpone on #78.1 or #78.2. Let's get this committed, as that will unblock other important work, like #3082470: Update drupal/drupal tarball generator. We can come back and make follow-on commits for those item. #78.2 already has a follow-on issue. I don't know if we need a separate follow-on for #78.1, as this issue and #3080205: Implicitly allow drupal/core and legacy scaffold projects to scaffold files. are both really close. Should the later happen to be committed first, we can adjust this issue. If this one gets committed first, we can adjust that issue.

mbaynton’s picture

greg.1.anderson’s picture

Woot, #80 addresses #78.1.

mbaynton’s picture

On everyone's favorite topic of naming things, it occurs to me that as we take a pronounced "minimum file to get you a Drupal" approach in these templates (ex: recent patches like the removal of cweagans/patches configuration in #71 and #80), we're also moving away from what I believe was an initial goal of the initiative to stop having to tell people to use community drupal-composer/drupal-project to avoid pain.

I don't mean to or want to re-examine the minimalist philosophy of the templates, official minimal project templates definitely have a place. But what about including the minimalist philosophy in the names? This might just lead to a clearer set of project template names should a future arise where we also decide to ship templates that include more of the niceties of drupal-composer/drupal-project.

drupal/recommended-minimal-project
drupal/recommended-project

Instead of

drupal/recommended-project
drupal/but-you-really-want-this-project

And if that future doesn't happen, no biggie to call it what it is anyway.

greg.1.anderson’s picture

I like the idea of #82 (and in fact was thinking similar things recently); however, today there is no difference between `drupal/recommended-project` and `drupal/recommended-minimal-project`, as we are recommending the minimum as an MVP for our first step here.

If we eventually decide that `drupal/recommended-project` should be more full-featured, then I would advise making the minimal project `drupal/minimal-project`. It would be confusing to have two recommended projects, and we'd rather recommend the one with extras, not the minimal one.

greg.1.anderson’s picture

Speaking of additions, in #45, "drupal/core": "-p2" is correct for the Recommended project, but I think it should be "drupal/core": "-p1" in the legacy project (if we later expand the scope of these projects to add more 'nice' features.)

mbaynton’s picture

I guess it's true that since they're only templates and site builders immediately take ownership of them, it's not really a b/c break to change the contents or philosophy of a template and keep calling it the same thing.

greg.1.anderson’s picture

Speaking of naming things, #37 says the consensus from a Composer Initiatives meeting was to make the relocated docroot location "docroot", but this patch still places it in "web", like drupal-composer/drupal-project does. I don't see a firm consensus on this name in the 10 July meeting minutes, and the variable that sets the name of this location is [web-root], so it is my opinion that "web" is fine.

greg.1.anderson’s picture

Status: Needs review » Postponed

#80 failed because #3080205: Implicitly allow drupal/core and legacy scaffold projects to scaffold files. did not get written out by the subtree splitter. Re-running #80 after that happens should make it go back to green. No additional work needed here, but blocked by that.

mbaynton’s picture

Issue summary: View changes

link to "the existing subtree splitter" in IS

Mixologic’s picture

Status: Postponed » Reviewed & tested by the community

#80 is back to green after fixing the splitter.

There's really not a whole lot left to do here.

Huzzah!

Ghost of Drupal Past’s picture

Status: Reviewed & tested by the community » Needs work

With a very heavy heart and apologies but I need to reset this from RTBC.

"php": ">=5.6", this is incorrect, Drupal now requires 7.0.8. See my reaction at https://twitter.com/chx/status/1109966918813794304 -- speaking of which, won't core/composer.json enforce the php version anyways? Of course, my composer-fu is not that strong, so I have no idea really.

I also believe -- but less sure -- the descriptions could be improved. RecommendedProject/composer.json has "Project template for Drupal 8 projects with composer following drupal/drupal layout" and LegacyProject/composer.json has "Project template for Drupal 8 projects with composer following drupal/drupal layout" which really looks like the exact same.

Mixologic’s picture

Status: Needs work » Needs review
FileSize
2.69 KB
10.48 KB

"php": ">=5.6", this is incorrect,

Good catch.

RecommendedProject/composer.json has "Project template for Drupal 8 projects with composer following drupal/drupal layout"

Yes. RecommendedProject appears to have copy/pasted that from Legacy, but we didnt re-word its short description.

Anyhow, attached is a patch that fixes a few more things.

1. fixes #90.1 by removing it entirely. We already specify php version requirements in drupal/core.
2. fixes #90.2 by changing description to:

"Project template for Drupal 8 projects with a relocated document root"

3. Changes the url in the README.txt to https://git.drupalcode.org -> there is no more cgit.
4. Changes the folders in .gitignore to have trailing slashes as per https://github.com/drupal-composer/drupal-project/pull/210

Mixologic’s picture

Doing a little bit deeper review, I've got some concerns about these .gitignore files.

Im really unsure as to the breadth of them, and at first glance, I cannot see what *isn't* ignored. Seems like the only thing that would end up in a git repo with these are your composer.json and composer.lock.

That seems *very* opinionated, and I don't think we want to provide that. (also, theres a phpstorm specific thing in there, and while its common, its not a universal thing afaik.)

Looking at where it came from, This doesn't tell us much:
https://github.com/drupal-composer/drupal-project/commit/fd47d6a033b81fa...

So, my suggestion is that we just use the example.gitignore that comes with drupal core now. I don't think this is the right issue to make those sort of changes.

Mixologic’s picture

And, also, did some manual testing by doing the following:

1. apply the patch
2. go into the composer/Template/RecommendedProject folder and do git init; git checkout -b 8.8.x;git add .;git commit -m "initialize"
3. add a file to that folder called packages.json with the following contents:

{
  "package": {
    "name": "drupal/recommended-project",
    "version": "8.8.x-dev",
    "source": {
      "url": ".git",
      "type": "git",
      "reference": "8.8.x"
    }
  }
}

4. Go to some other folder and composer create-project drupal/recommended-project:8.8.x-dev test-project-name -vv --repository-url=/Path/To/drupal_8/composer/Template/RecommendedProject/packages.json replacing Path/To/drupal_8 with wherever you have the patched repo.

This will create your project as if it were already on packagist.org.

My manual tests revealed two things:

1. because we left the wikimedia/composer-merge-plugin in core's composer.json and lock file for BC compatibility, it pulls it in, and uses default config and thus does unnecessary work. I think we should just exclude it from core-recommended manually in our package generator.

2. Once I had a project, I tried doing a `composer require drupal/ctools`, and I was surprised that it re-scaffolded all the files.. I dont think we want that?

➜  projectname2 composer require drupal/ctools
Using version ^3.2 for drupal/ctools
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing drupal/ctools (3.2.0): Loading from cache
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files
Scaffolding files for drupal/core:
  - Copy [web-root]/.csslintrc from assets/scaffold/files/csslintrc
  - Copy [web-root]/.editorconfig from assets/scaffold/files/editorconfig
  - Copy [web-root]/.eslintignore from assets/scaffold/files/eslintignore
  - Copy [web-root]/.eslintrc.json from assets/scaffold/files/eslintrc.json
  - Copy [web-root]/.gitattributes from assets/scaffold/files/gitattributes
  - Copy [web-root]/.ht.router.php from assets/scaffold/files/ht.router.php
  - Copy [web-root]/.htaccess from assets/scaffold/files/htaccess
  - Copy [web-root]/example.gitignore from assets/scaffold/files/example.gitignore
  - Copy [web-root]/index.php from assets/scaffold/files/index.php
  - Copy [web-root]/INSTALL.txt from assets/scaffold/files/drupal.INSTALL.txt
  - Copy [web-root]/README.txt from assets/scaffold/files/drupal.README.txt
  - Copy [web-root]/robots.txt from assets/scaffold/files/robots.txt
  - Copy [web-root]/update.php from assets/scaffold/files/update.php
  - Copy [web-root]/web.config from assets/scaffold/files/web.config
  - Copy [web-root]/sites/README.txt from assets/scaffold/files/sites.README.txt
  - Copy [web-root]/sites/development.services.yml from assets/scaffold/files/development.services.yml
  - Copy [web-root]/sites/example.settings.local.php from assets/scaffold/files/example.settings.local.php
  - Copy [web-root]/sites/example.sites.php from assets/scaffold/files/example.sites.php
  - Copy [web-root]/sites/default/default.services.yml from assets/scaffold/files/default.services.yml
  - Copy [web-root]/sites/default/default.settings.php from assets/scaffold/files/default.settings.php
  - Copy [web-root]/modules/README.txt from assets/scaffold/files/modules.README.txt
  - Copy [web-root]/profiles/README.txt from assets/scaffold/files/profiles.README.txt
  - Copy [web-root]/themes/README.txt from assets/scaffold/files/themes.README.txt

Then I tried running `php drupal quick-start demo_umami` from the scripts dir, and, well, I ran out of memory with 128mb configured.
I upped it to 256, tried again, and the umami site launched right away.

I doubt we did anything to cause drupal to need more memory, unless *just* installing ctools is enough to make it need more than 128mb. There could also be something else weird with my local config.

greg.1.anderson’s picture

@chx: It was very helpful for you to find and report these errors; it saves a lot of time when we fix errors before the core committer review, so thanks so much.

1) I agree with the fixes in #91.

2) It would not be correct to reduce .gitignore down to just example.gitignore as suggested in #92.

It is critical in a Composer-managaged project to .gitignore everything that is placed by Composer. /modules/contrib must be ignored, because that is where the Composer-managed contrib modules are placed. /modules/custom et. al. are not .gitignored, and are available if you want to commit a module or two that is custom to just this one site.

Perhaps we could enhance the documentation to explain how to manage .gitignore in a Composer-managed project?

We could remove Simpletest; that is gone / going away. We could remove the PHPStorm .idea directory. I think everything else needs to stay.

3) #93

Fixing the over-scaffolding should be a separate issue. Composer manages which files are installed so that it can avoid over-installing. Our scaffold tool started off simple, and therefore scaffolds every time. We could check mod dates or use other means to determine whether the scaffold files need to be refreshed. This might be a little complicated in terms of files that are appended, so we'd want to add this enhancement with caution. One thing that we could do is ensure that the scaffolding operation only runs once per Composer operation. Currently it is possible for it to run multiple times.

I don't think that we have done anything to increase the required memory for Drupal, but I did not try to reproduce or measure yet.

wikimedia/composer-merge-plugin is part of drupal/drupal, so I wouldn't expect to see it at all when using these templates, which should only include things from drupal/core et. al. And yet:

https://github.com/drupal/core-recommended/blob/8.8.x/composer.json#L54

So the thing is that core-recommended includes everything from the drupal/drupal composer.lock; this is always how the package generator has worked, but the intention really is that it should only include things from drupal/core. I think this would be hard to do in the general case, but we could certainly exclude wikimedia/composer-merge-plugin via special checking. It is the only thing in the root composer.json require section save for composer/installers and drupal/core at the moment.

AaronMcHale’s picture

Re #61

The reason I prefer 'traditional' over 'legacy' is that the later implies 'deprecated'.

Agree with that, I think in the context of a Composer project people will likely understand what "traditional" means.

I copied this configuration from drupal-composer/drupal-project. In general, I think that we should strip as much optional stuff out of the template as possible, and strictly speaking, cweagans/composer-patches and its configuration thereof is optional. However, it is very common for folks to need to patch their Drupal sites, so it seemed very desirable to me to have common configuration like this available in the standard template.

For me (and probably many others) I really appreciate the ability to just drop a patch into the composer.json, and I think to not have that available by default seems a little disappointing, especially since for every dev site I set up I'd then have to require the composer-patches package and make sure it's configured to work properly. Not including it by default could potential result in more support/feature queries because people using Drupal with Composer have come to expect the ability to easily apply patches, e.g. "I added patches to my composer.json but it's not find them" and "I included the dependency but patches aren't applying correctly and are failing with error messages", etc.

Perhaps we could have a no-dev/minimal/strict template which doesn't include this dependency and configuration, we already have a standard and minimal installation profile (although based on other comments it looks like that might already be the approach?)


Re #94

It is critical in a Composer-managaged project to .gitignore everything that is placed by Composer. /modules/contrib must be ignored, because that is where the Composer-managed contrib modules are placed. /modules/custom et. al. are not .gitignored, and are available if you want to commit a module or two that is custom to just this one site.

Does that cause problems though for setups where a mono-repo is used? For example in dev or test environments where the entire site (including contrib modules and Composer packages) is committed to one mono-repo then pulled down on the live site, this practice is used to ensure stability and consistency between dev, test and live.

greg.1.anderson’s picture

#95: Yes, "must" was too strong of a word. Some workflows commit everything. I still think that ignoring composer artifacts by default is the best policy, as your diffs are minimal in PRs in that instance. We are discussing options in #composer (Drupal slack), e.g perhaps we could have two example gitignore files, and let the user choose which one to rename to .gitignore.

We are going to stick with minimal-feature templates for the initial commit, and can discuss adding features in follow-on issues.

mbaynton’s picture

Re: #95

Does that cause problems though for setups where a mono-repo is used?

Yes. But you're not even .gitignore-ing /vendor if you're in that boat. I'd accept as sufficiently established best practice in the php ecosystem not committing /vendor/* to git. The paths not literally being "vendor" here is just a product of `composer/installers` being nice enough to lay out composer-sourced things in a Drupal-specific way, but to my mind the principle is the same. I'm personally comfortable with having the "official"/"recommended" default adhering to this best practice.

Although re: #94:

It would not be correct to reduce .gitignore down to just example.gitignore as suggested in #92

We should think about for tarball-shipping purposes first removing this .gitignore that assumes Composer management. Or maybe renaming to example.composer.gitignore or something.

Mixologic’s picture

I think the 'dont commit vendor' mantra isn't actually true in a lot of cases. Because the much much more important mantra of "dont run composer in production" takes precedence, and thus, somehow, you need to get a packaged vendor directory to production.

Some people have a CI build step that creates a deployable artifact, like a tarball or zipfile of the site to be deployed.

Many others, drupal.org included, have a 'site repository' that contains the entire site in git that is used for deployment purposes similar to what is described in #95

So, in those situations, absolutely, commit vendor. Its the right thing to do. This is why Im hesitant to actually agree that this is a universal best practice. What we're effectively saying is "we dont expect you to commit vendor or composer created parts of your site. We assume you're deployment strategy involves building a deployment artifact" - I don't think we can make that assumption. Nor can we assume they even *have* a deployment strategy. They might just have a simple host where they go ahead and do run composer in production, because it's totally fine if their local rockhounding club's website is down or breaks. But they keep it all in git just so they can rollback /keep track of what they did to their site.

I *do* think we can provide all of those features in the .gitignore file either commented out, or provided as an example.gitignore with explanation as to why you would want them, and I think its valueable.. I just dont think it should be the "default, you must turn it off if you dont want this" - or if it should be, I don't think we need to decide that here.

Regarding additional improved features like 'being able to patch out of the box' - that requires core to decide whether or not cweagans/composer-patches is a dependency that is something that should be part of the default experience for everybody.

Again, that might be exactly what we want, but we just don't know whether or not thats true, and we don't need to yet. We can get these templates in now without it, and discuss in a followup.

However, this is where we could also leverage other features of composer - we could put a suggests in for cweagans/composer-patches that tells users 'if you need to patch your site, try cweagans/composer-patches' - same for drush and console.

grasmash’s picture

+1 to everything @mixologic said.

mbaynton’s picture

Okay, sounds like there's established but opposing schools of thought here. Maybe in that case making core things start manifesting a preference for one or the other isn't the best.

Maybe we don't have to. Limited to the context of this morning's .gitignore discussions, all that's at issue is what the `composer create-project` user initially should have in their new, owned-by-them tree, right? We could avoid becoming opinionated on that in a few ways, like 1) giving up and not having a file called .gitignore, perhaps offering a few 'example.thisorthat.gitignore' files in the project root, or 2) asking the user which school of thought they prefer through the the `core-composer-scaffold` plugin, and giving them the appropriate pre-prepared .gitignore.

1) is simple but litters dud (ineffectual, crufty) files about in what ought to be a clean starting state for a project
2) looks pretty easy to accomplish; there's an event unique to `create-project` dispatched by composer that we can just listen for. Super rough POC here. We'd want to use Composer's I/O, setup options so it could be specified non-interactively, move things out of handler directly, probably use Drupal\Composer\Plugin\Scaffold\ManageGitIgnore somehow etc if people like this idea. The lack of interaction presently makes me wonder if there's already been a deliberate decision not to do interaction as part of our `create-project`, so I just threw super quick thing together.

greg.1.anderson’s picture

Issue summary: View changes
Status: Needs review » Needs work

Prompting, if done, should be a follow-on issue.

I had a strong opinion about an hour ago that the legacy / traditional project should have a minimal .gitignore, and the recommended project should ignore everything placed by Composer. At this point, though, especially after #98, I think that we should commit here with no .gitignore, or perhaps with a couple of .gitignore examples, and leave the decision as to whether to do anything different as follow-on work.

I updated the Issue Summary with the things that still need to be done here, including follow-on issues that need to be created.

Ghost of Drupal Past’s picture

The level of collaboration and understanding of each other in this issue is just breathtaking. Thanks everyone.

Mixologic’s picture

I like the idea behind #100.2, seems like a reasonable way to offer some setup choices. It makes me wonder if we could ask whether they want a relocated docroot also, but I have a feeling that theres a bunch of chicken and egg scenarios where that comes from the root composer.json extra etc.

Granted adding some interaction *does* add some complexity. As soon as this goes in somebody will want those questions in another language. Somebody ought to design a standard way that our command prompts interface with the user so that every command doesn't feel like its a different product (colors, formatting etc). Getting the wordsmithing correct so that people get what we're asking.

But as far as I know, we haven't really come up against too much "we should get user input to proceed" until now, so its not a deliberate decision *not* to have interaction. Most choices so far have been more of a 'offer up multiple products and the the user choose the right one' - i.e pinned-dev-dependencies vs just dev-dependencies.

But yeah, we could prompt as part of follow on as well.

mbaynton’s picture

Status: Needs work » Needs review
FileSize
2.96 KB
12.01 KB

+1 on prompting as a follow-up. I also recognized the docroot bit was a candidate for solving with prompting and was essentially previously discussed in #18, so was unsure how opposed to it folks were. I think it's fine for the docroot part to be worthy of separate templates though, that's a lot more foundational to what you're going to get overall. Prompting may be better for little details.

I started working on dealing with gitignores in the interim by offering two examples files (I think removing things is easier for people than locating the correct thing to include) but ran out of time. This is incomplete because for drupal/recommended-project there's an example.gitignore in web/, (it's always been there, not a new thing with this patch), but I think having that still there plus two in the project root is too much cruft. We should relocate it to the project root and fix up its contents for the relocated docroot. If that turns out to be too ambitious, let's remove all gitignoring from the project templates and accept the web/example.gitignore's presence.

mbaynton’s picture

Status: Needs review » Needs work
greg.1.anderson’s picture

I like #104, but I think that we should move it to a followup issue so that there is time to discuss it adequately without blocking this issue from being committed.

mbaynton’s picture

I like #104, but I think that we should move it to a followup issue

Okay so yank both the .gitignores?

No need to follow up on prompting and nuanced example files, is there?

greg.1.anderson’s picture

I think we could have one issue to discuss what to do with .gitignore, including the possibility to prompt or not prompt, but yes, I think we should defer all decisions about what to do with .gitignore to a follow-up issue, and just leave it out here. This is consistent with the current strategy of drupal/drupal and the download archives to simply not have an active .gitignore to start.

apaderno’s picture

Title: Add composer-ready project templates to Drupal core. » Add composer-ready project templates to Drupal core
AaronMcHale’s picture

I agree with @Mixologic in #98

I think the 'dont commit vendor' mantra isn't actually true in a lot of cases. Because the much much more important mantra of "dont run composer in production" takes precedence, and thus, somehow, you need to get a packaged vendor directory to production.

When you have a multi-environment setup with a mission critical web application you run composer commands in dev/test/staging, never in production, because you need to be absolutely sure that when it works in test/staging it'll work in production and that there's no risk of a nasty surprise.

However, this is where we could also leverage other features of composer - we could put a suggests in for cweagans/composer-patches that tells users 'if you need to patch your site, try cweagans/composer-patches' - same for drush and console.

Nice idea, but do we also want to find a way to ensure it's configured correctly, for example:

        "patchLevel": {
            "drupal/core": "-p2"
        },

Including these configuration by default or adding it programtically reduces the risk of people running into issues that result in support tickets for us. (Also makes my life as a developer that little bit easier)


Re #100

2) asking the user which school of thought they prefer through the the `core-composer-scaffold` plugin, and giving them the appropriate pre-prepared .gitignore.

That sounds like an interesting idea and worth exploring.

That being said, I'm currently wondering why we even need to provide a .gitignore in the first place, is it just to be helpful and support these different scenarios already described, or is there a more technical reason?


Re #101

At this point, though, especially after #98, I think that we should commit here with no .gitignore, or perhaps with a couple of .gitignore examples, and leave the decision as to whether to do anything different as follow-on work.

I think that partly hints at an answer to my question above, so if there's no technical reason to include a .gitignore, let's just discuss more in a follow-up.


Re #102

The level of collaboration and understanding of each other in this issue is just breathtaking. Thanks everyone.

😃


Re #103

Granted adding some interaction *does* add some complexity. As soon as this goes in somebody will want those questions in another language. Somebody ought to design a standard way that our command prompts interface with the user so that every command doesn't feel like its a different product (colors, formatting etc). Getting the wordsmithing correct so that people get what we're asking.

Another follow-up perhaps?


Re #104

Prompting may be better for little details.

👍

That's also the philosophy that Drupal Console seems to use when generating things, for example to generate an Entity Type there is two distinctly different commands, one for generating a Config Entity Type and the other for generating a Content Entity Type, the questions you get asked are mostly similar but are all relating to small details about the configuration of the Entity Type and what features it supports.

diff --git a/composer/Template/README.txt b/composer/Template/README.txt
index 1d0c793203..3818c709b8 100644
--- a/composer/Template/README.txt
+++ b/composer/Template/README.txt
+  example.gitignore:
+  Includes the files managed by Composer into your git repo.
+  Useful if you prefer a "monorepo" where site updates are deployed using only
+  git. This is the same example.gitignore shipped with traditional Drupal
+  archive releases.
+
+  example-composerdeployment.gitignore:
+  Excludes all files managed by Composer from your git repo.
+  Useful if you prefer keeping your repository limited to your project's code,
+  and you use a more complex deployment process to build your complete site.

I like these descriptions, concise yet clear, +1


Re #106

I like #104, but I think that we should move it to a followup issue so that there is time to discuss it adequately without blocking this issue from being committed.

+1 This issue is already very long, a follow-up would allow us to workshop a bit more as well.


Re #108

I think we could have one issue to discuss what to do with .gitignore, including the possibility to prompt or not prompt

+1

mbaynton’s picture

Status: Needs work » Needs review
FileSize
2.27 KB
8.21 KB

So all needs doing not in follow-on issues is destroying two files. I am good at destroying things. :)

This is against #91, not my last patch.

greg.1.anderson’s picture

Cool, looks good. Let's make sure all the follow-on issues are created before setting RTBC. Haven't had much time this weekend, but I'll work on typing some up if that changes.

mbaynton’s picture

Issue summary: View changes

X off .gitignore and .gitignore follow-up issue tasks. That issue is #3082958: Add gitignore(s) to Composer-ready project templates

greg.1.anderson’s picture

Issue summary: View changes

Update issue summary with links to three of the follow-on issues. Memory limit investigation remains.

greg.1.anderson’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Add cross-reference to final (for now) follow-on issue in summary.

All follow-on issues have been made, and all reviewer comments have been addressed, so back to RTBC.

AaronMcHale’s picture

Since we're talking about follow-ups, I'll just highlight part of my comment #110 which is quoting @Mixologic in #103,

Re #103

Granted adding some interaction *does* add some complexity. As soon as this goes in somebody will want those questions in another language. Somebody ought to design a standard way that our command prompts interface with the user so that every command doesn't feel like its a different product (colors, formatting etc). Getting the wordsmithing correct so that people get what we're asking.

Another follow-up perhaps?

I'm just highlighting this, since that concern was raised by @Mixologic I'm assuming it would be up to him if he feels that should be addressed in a follow-up.

j. ayen green’s picture

Perhaps a well-documented .gitignore with many popular settings (like .idea) all commented out, like many config defaults?

AaronMcHale’s picture

Perhaps a well-documented .gitignore with many popular settings (like .idea) all commented out, like many config defaults?

@j. ayen green: we're continuing the .gitignore discussing on the issue #3082958: Add gitignore(s) to Composer-ready project templates, please do share your thoughts over there as well.

greg.1.anderson’s picture

Issue summary: View changes

Update issue summary with result of memory investigation.

Mixologic’s picture

+1 on RTBC.

I believe #116 isnt exactly a followup, more of a comment that "Interaction isnt 'simple' -> its UX, and thus should have some sort of design work" - so I believe we can cover that in the context of #118.

larowlan’s picture

issue credits

  • larowlan committed ef3544a on 8.8.x
    Issue #2982680 by greg.1.anderson, mbaynton, Mixologic, jibran, webflo,...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed ef3544a and pushed to 8.8.x. Thanks!

The level of collaboration and understanding of each other in this issue is just breathtaking. Thanks everyone.

I concur

🎉

Composer intiative team: Now would be a good time to start thinking about a summary of all of the achievements in the 8.8 cycle that would go in the release notes, as I think just adding all the release note snippets together won't do it justice. Something that really fanfares all the big goals you've ticked off.

Congrats.

xjm’s picture

Not the release notes, but rather the frontpage post. (Release notes are just for disruptions). Tagging accordingly!

Mile23’s picture

Now would be a good time to start thinking about a summary of all of the achievements in the 8.8 cycle that would go in the release notes

You say that as if the initiative is finished. :-)

Next: #3047468: Create a tool to convert a non-Composer-based Drupal to a Composer-based one

jungle’s picture

Should we add a guideline or documentation officially for how to switching from the 3rd party template drupal-composer/drupal-project to this one? I think there are a lot of drupal-composer/drupal-project users.

benjifisher’s picture

Issue summary: View changes

Fix a typo in the release-notes snippet.

greg.1.anderson’s picture

@jungle: We can keep track of documentation needs in #3082601: Update Composer documentation to match Drupal 8.8.0+ capabilities

Chi’s picture

Re #127. Composer templates work as starter kits. The are only used for creating new projects. Once you've run composer create-project command the only way to switch to other template is removing everything and starting from scratch. So that existing sites created with drupal-composer/drupal-project don't have to update anything.

greg.1.anderson’s picture

@chi: That is not quite true in this instance. Drupal 8.8.x introduces a new scaffold component. The new scaffold code has some new features that are useful for site builders, but beyond that, will also greatly reduce the load on drupal.org when a new Drupal version comes out. We therefore want to encourage users of the existing scaffold component to start using the new scaffold component. In addition, the files that drupal-composer/drupal-scaffold is downloading will be removed in Drupal 9, so we expect everyone to migrate before then.

Migrating should be a simple matter of renaming some components. There's a start (a composer.json for new projects) at https://github.com/drupal-composer/drupal-project/pull/522

Status: Fixed » Closed (fixed)

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

joachim’s picture

Needs a follow-up to update documentation!

Mile23’s picture

NaheemSays’s picture

What are the chances of #3086489: Exclude development libraries from templates' composer.json by default being committed before the release of Drupal 8.8? IMO it will fix a lot of issues for less experienced users and will also simplify documentation with having the same steps for all composer supported versions of drupal instead of different instructions before and after it lands.

Mile23’s picture

It might help to mention that on the other issue rather than this closed one.

GuillaumeDuveau’s picture

I can see why Drupal wants to maintain https://github.com/drupal/recommended-project and https://github.com/drupal/legacy-project.

What I can't understand is why they are officially recommended by Drupal. They don't even have a README.

https://github.com/drupal-composer/drupal-project is light years ahead and should be officially recommended in my opinion.

Chi’s picture