git commit -m 'Issue #2337283 by hussainweb, Mile23, alexpott, dawehner, naveenvalecha, aditya_anurag, rakesh.gectcr: [meta] Add a composer.json file to every component (module, later)'

Problem/Motivation

Our extensions are based upon .info.yml files which works fine and I don't see a reason to change that (at least for now and this issue).
On the other hand though those doesn't provide any metadata you could use in order to use composer properly.

Contrib established now a policy (or people pushed it quite hard) to add composer.json files to every module:

With that and some other tricks you can use composer to build your Drupal together with the modules (this is not about the dependencies of each module) (see https://erdfisch.de/node/303)

We should probably start with the Drupal\Component namespace.

Components in the Drupal\Component namespace with composer.json files:

  • Plugin
  • ProxyBuilder
  • Utility

Plugin is broken, being non-valid JSON.

Utility is an interesting case because it contains a number of different one-file classes. Other components such as Bridge and DateTime also contain only one class. We should probably move the Utility classes to their own namespace.

Proposed resolution

Add a composer.json to every module sub component in core. This tells people that they should do that as well. On top of that the composer.json format
provides a lot of additional metadata you can use, like the maintainers, which would be a great replacement for MAINTAINERS.txt because the information
is much more in context.
Edit: This issue and sub-tasks coved only subcomponents. Adding composer.json to core modules is still under discussion at

Remaining tasks

  • Add composer.json files to the various components, fix existing ones which are broken.
  • Make sure they pass coding standards and have accurate information.
  • Figure out a way to test whether the composer.json files are actually meaningful.

User interface changes

API changes

Possibly changing the names of some namespaces.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Unfrozen changes Unfrozen because it only adds metadata to the project.
Disruption Minimal disruption to core.
CommentFileSizeAuthor
#98 2337283_88.patch332.14 KBalexpott
#90 interdiff-2337283-88-90.txt3.58 KBaleksip
#90 2337283_90.patch335.9 KBaleksip
#88 2337283_88.patch332.14 KBheykarthikwithu
#85 2337283_85.patch332.14 KBMile23
#84 interdiff.txt6.73 KBMile23
#84 2337283_84.patch332.59 KBMile23
#78 2337283-78.patch329.63 KBhussainweb
#78 interdiff-76-78.txt558 byteshussainweb
#76 2337283-76.patch329.63 KBhussainweb
#73 2337283-73.patch329.61 KBhussainweb
#73 interdiff-68-73.txt3.26 KBhussainweb
#68 2337283-68.patch329.63 KBhussainweb
#68 interdiff-64-68.txt913 byteshussainweb
#64 2337283-64.patch329.99 KBhussainweb
#64 interdiff-60-64.txt6.15 KBhussainweb
#60 2337283-60.patch328.8 KBhussainweb
#60 interdiff-51-60.txt3.11 KBhussainweb
#56 interdiff-49-53.txt67.99 KBhussainweb
#53 2337283-51.patch328.73 KBhussainweb
#49 2337283-49.patch265.07 KBalexpott
#47 2337283-47.patch165.09 KBalexpott
#26 interdiff.txt497 bytesMile23
#26 2337283_26.patch20.25 KBMile23
#24 interdiff.txt1.94 KBMile23
#24 2337283_24.patch20.29 KBMile23
#19 2337283_19.patch20.13 KBMile23
#2 composer-2337283-2.patch3.69 KBdawehner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Issue summary: View changes

Added a more expansive example (hosted on d.o too!)

dawehner’s picture

FileSize
3.69 KB

Here is a start, just to give people some ideas: You can distinct between original authors and current maintainers/branch maintainers/documentation maintainers (whatever you can imagine)

larowlan’s picture

Love it - should we make this a meta? I could see some components being contentious so split/smaller issues might maintain velocity

dawehner’s picture

Well, I guess first we should get a discussion rolling what we want to put into them, and figure out things like whether it is a good to drupal/module in there which is at least atm. a requirement in contrib world.

davidwbarratt’s picture

Mile23’s picture

dawehner’s picture

Title: Add a composer.json file to every module / component » [meta] Add a composer.json file to every component (module, later)

Let's follow the suggestion of @larowlan and make that a meta.

Mile23’s picture

Issue summary: View changes
dawehner’s picture

@Mile23
Thank you for adding a better issue summary. Do you want to work on this issue? I would be glad reviewing it!

Mile23’s picture

Status: Active » Needs work

This work should only proceed once a decision has been made as to how we're going to manage the tests for these namespaces as dependencies.

That is, if I do this: composer require drupal/gettext ~8 I would expect to get a package in my vendor/ directory with a README.md and a src/ directory and a tests/ directory so I could run the tests.

How will we do that?

If we're not doing that, why are we making composer.json files?

dawehner’s picture

This work should only proceed once a decision has been made as to how we're going to manage the tests for these namespaces as dependencies.

IMHO, they don't matter. If you on your own small PHP based project want to pull in some component, you won't run the uni tests of the vendor directory, especially like symfony takes actually some time. The value is in making the components itself available. By doing that, we also show that we are open to other people
out there in the PHP community.

That is, if I do this: composer require drupal/gettext ~8 I would expect to get a package in my vendor/ directory with a README.md and a src/ directory and a tests/ directory so I could run the tests.

A readme would be certainly really nice, but I think that its not a requirement to have it, don't you think so?

jhedstrom’s picture

I looked at how Symfony does this, and while there is a Tests directory for each component, there isn't a src directory in the subtree split.

https://github.com/symfony/Yaml

I don't think moving our unit tests into each component would need to block the first step of adding a composer.json file for each one.

Mile23’s picture

My point is that the first step is knowing how we'll do it. Measure twice, cut once, etc.

I realize this makes me a rebel in the Drupal world. :-)

dawehner’s picture

My point is that the first step is knowing how we'll do it. Measure twice, cut once, etc.

So do you totally disagree with doing it or not? Your last answer kinda opened up multiple ways of interpretation.

jhedstrom’s picture

My point is that the first step is knowing how we'll do it.

Is there any reason not to just follow Symfony's example? Specifically, target-dir and autoload directives from the various composer.json files:

    "autoload": {
        "psr-0": { "Symfony\\Component\\Yaml\\": "" }
    },
    "target-dir": "Symfony/Component/Yaml",

(we'd use psr-4 instead).

dawehner’s picture

Is there any reason not to just follow Symfony's example? Specifically, target-dir and autoload directives from the various composer.json files:

I don't see a reason why not in general.

Crell’s picture

We've already done this for one component. Do it for the others and move on. If we want to add a README to each component that's fine, but don't worry about the tests. We expect anyone using the components stand-alone to come back to core to submit patches anyway, so if the tests aren't in the split repos for now, meh, who cares?

Let's stop talking and just move forward. We need to do more of that.

Mile23’s picture

Assigned: Unassigned » Mile23

Making template versions.

Mile23’s picture

Assigned: Mile23 » Unassigned
FileSize
20.13 KB

This is for Gettext. Presented here for your perusal and criticism.

Let's refine the template and then we can repro it into all the sub-issues.

Also: I updated the issue summary on #1826054: [Meta] Expose Drupal Components outside of Drupal

Mile23’s picture

+++ b/core/lib/Drupal/Component/Gettext/TESTING.txt
@@ -0,0 +1,12 @@
+You'll find the tests under core/lib/Drupal/Tests/Component.

Derp.

Mile23’s picture

Status: Needs work » Needs review

The last submitted patch, 2: composer-2337283-2.patch, failed testing.

dawehner’s picture

Thank you for posting a first example!

I agree that we should ship with the license file, its just the way how its supposed to work.

+++ b/core/lib/Drupal/Component/Gettext/composer.json
@@ -0,0 +1,18 @@
+    "source": "https://www.drupal.org/project/drupal/git-instructions",
+    "source": "http://cgit.drupalcode.org/drupal"

Can you define the same key in json twice?

Mile23’s picture

FileSize
20.29 KB
1.94 KB

Changed tests path.

Removed duplicate 'source' key.

Added information about how to test only the component in question.

Crell’s picture

+++ b/core/lib/Drupal/Component/Gettext/composer.json
@@ -0,0 +1,17 @@
+  "autoload": {
+    "psr-0": {
+      "Drupal\\Component\\Gettext": ""
+    }

Everything else we have specifies PSR-4. No need to use PSR-0 on this one. For a split repo we would probably want to remove a few layers of directory, too, so the composer file should reflect that.

Mile23’s picture

FileSize
20.25 KB
497 bytes

Using PSR-4, no target-dir.

Makes me itch to not have src/ and test/ :-)

dawehner’s picture

This looks pretty sold for me, but I guess someone has to try out whether a subtree split package can actually be done.

Mile23’s picture

dawehner’s picture

Right, but you agree we would need one for the plugins as well ...

Mile23’s picture

Also in the issue summary for the meta: #1826054: [Meta] Expose Drupal Components outside of Drupal

Who wants to volunteer? :-)

davidwbarratt’s picture

Mile23’s picture

Mile23’s picture

This issue adds a test to check the integrity of composer.json files: #2472269: Fix syntax errors in Drupal\Component\Plugin's composer.json, Add test

jibran queued 26: 2337283_26.patch for re-testing.

dawehner’s picture

This issue adds a test to check the integrity of composer.json files: #2472269: Fix syntax errors in Drupal\Component\Plugin's composer.json, Add test

Nice.

Yeah I think adding those composer.json files would still be a nice thing, it makes it clearer who maintains what, and enables people to reuse the components,
which you simply can't overestimate in the result.

Fabianx’s picture

Category: Feature request » Task

So to be clear this is blocked on someone trying to push a subtree-split of a component to GH and see if its installable via composer?

Mile23’s picture

I think #2472269: Fix syntax errors in Drupal\Component\Plugin's composer.json, Add test gives us tests as to whether the composer.json files are valid, so we could proceed per component.

Making it so everyone can just use composer to grab these components will require the subtree split, but we can proceed with making the files now. The only difficulty will be determining dependencies and then checking them for patch review.

One clue might be use statements. For instance, \Drupal\Component\Annotation\Plugin says use Drupal\Component\Utility\NestedArray;, which shows us the dependencies.

Any errors here will become much more apparent as people start using them. :-)

dawehner’s picture

So to be clear this is blocked on someone trying to push a subtree-split of a component to GH and see if its installable via composer?

I don't think so. What we want to is agree which information we should put into it and then someone writing a patch to include them.
The subtree splits can be done later independently.

davidwbarratt’s picture

Mile23’s picture

Template composer.json in #26.

Mile23’s picture

Ready for review: #2474903: Add composer.json to \Drupal\Component\Gettext\ component.

That issue is also set up so you can clone it (using dreditor) for the other child issues.

xjm’s picture

Tagging for framework manager review. Thanks for the meta issues.

alexpott’s picture

Version: 8.0.x-dev » 8.1.x-dev

Discussed with @xjm - I don't think that there is a case for adding this to 8.0.x since that is patch release branch and only should include fixes to stable code and all of Drupal/lib is stable.

Note that including composer.json files has been approved by Dries in #2176065-33: Introduce a composer.json for Drupal\Component\Utility

alexpott’s picture

alexpott’s picture

Status: Needs review » Needs work
  1. git commit -m 'Issue #2600728 by marvin_B8, RobLoach, rakesh.gectcr: Add composer.json to \Drupal\Component\EventDispatcher component'
  2. git commit -m 'Issue #2600720 by rakesh.gectcr: Add composer.json to \Drupal\Component\Datetime component'
  3. git commit -m 'Issue #2600722 by rakesh.gectcr: Add composer.json to \Drupal\Component\Diff component'
  4. git commit -m 'Issue #2600726 by naveenvalecha, aditya_anurag, rakesh.gectcr: Add composer.json to \Drupal\Component\Discovery component'
  5. git commit -m 'Issue #2600734 by rakesh.gectcr: Add composer.json to \Drupal\Component\HttpFoundation component'
  6. git commit -m 'Issue #2600738 by rakesh.gectcr: Add composer.json to \Drupal\Component\Render component'
  7. git commit -m 'Issue #2600740 by rakesh.gectcr: Add composer.json to \Drupal\Component\Serialization component'
  8. git commit -m 'Issue #2600742 by rakesh.gectcr: Add composer.json to \Drupal\Component\Transliteration component'
  9. git commit -m 'Issue #2600744 by rakesh.gectcr: Add composer.json to \Drupal\Component\Utility component'
  10. git commit -m 'Issue #2600746 by rakesh.gectcr: Add composer.json to \Drupal\Component\Uuid component'

All the people mentioned in the above potential commit messages need credit on this issue when it lands

alexpott’s picture

Status: Needs work » Needs review
FileSize
165.09 KB

Here is a start of merging all the patches together...

We need to ensure that all components that are missing a composer.json have one and that all the expected files are present - for example TESTING.txt is missing from UUID. Plus there are components which still need to be addressed...

alexpott’s picture

  1. git commit -m 'Issue #2600714 by rakesh.gectcr, naveenvalecha: Add composer.json to \Drupal\Component\Annotation component'
  2. git commit -m 'Issue #2600716 by rakesh.gectcr, naveenvalecha: Add composer.json to \Drupal\Component\Assertion component'
  3. git commit -m 'Issue #2600726 by naveenvalecha, aditya_anurag, rakesh.gectcr: Add composer.json to \Drupal\Component\Discovery component'
  4. git commit -m 'Issue #2600730 by rakesh.gectcr: Add composer.json to \Drupal\Component\FileCache component'
  5. git commit -m 'Issue #2600732 by rakesh.gectcr: Add composer.json to \Drupal\Component\Graph component'
  6. git commit -m 'Issue #2600736 by rakesh.gectcr: Add composer.json to \Drupal\Component\PhpStorage component'
  7. git commit -m 'Issue #2600744 by rakesh.gectcr: Add composer.json to \Drupal\Component\Utility component'

Found some more issues to close and merge :)

alexpott’s picture

Merged those patches in

naveenvalecha’s picture

Status: Needs review » Needs work

Thanks for merging all those.

  1. +++ b/core/lib/Drupal/Component/Assertion/TESTING.txt
    @@ -0,0 +1,19 @@
    +$ cd ./core
    

    We don't need cd core here.

  2. +++ b/core/lib/Drupal/Component/Assertion/TESTING.txt
    @@ -0,0 +1,19 @@
    +$ ./vendor/bin/phpunit -c core/ --group Assertion
    

    The group name is Inspector in the test class(InspectorTest.php) Annotation.
    $ ./vendor/bin/phpunit -c core --group Inspector

  3. +++ b/core/lib/Drupal/Component/Datetime/TESTING.txt
    @@ -0,0 +1,19 @@
    +$ cd ./core
    

    Same as above we don't need cd into core here.

  4. +++ b/core/lib/Drupal/Component/Diff/TESTING.txt
    @@ -0,0 +1,19 @@
    +$ cd ./core
    +$ ./vendor/bin/phpunit --group Diff
    

    There is no group available "Diff" in any tests. So need to replace it with correct one.

  5. +++ b/core/lib/Drupal/Component/EventDispatcher/TESTING.txt
    @@ -0,0 +1,19 @@
    +$ cd ./core
    +$ ./vendor/bin/phpunit -c core/ --group EventDispatcher
    

    Remove cd core from here.
    Also the group name is Symfony in ContainerAwareEventDispatcherTest.php

    $ ./vendor/bin/phpunit -c core --group Symfony

    Can we update the group name in the tests file in this issue or should we create a follow up later to not disturb this one.

  6. +++ b/core/lib/Drupal/Component/FileCache/TESTING.txt
    @@ -0,0 +1,19 @@
    +$ cd ./core
    +$ ./vendor/bin/phpunit --group FileCache
    

    We don't need cd core here.
    $ ./vendor/bin/phpunit -c core --group FileCache

  7. +++ b/core/lib/Drupal/Component/Gettext/README.txt
    @@ -1,4 +1,4 @@
    +The Drupal Discovery Component
    

    Why this change ? irrelevant change

  8. +++ b/core/lib/Drupal/Component/Graph/TESTING.txt
    @@ -0,0 +1,19 @@
    +$ cd ./core
    +$ ./vendor/bin/phpunit --group Graph
    

    Similar as above.
    $ ./vendor/bin/phpunit -c core --group Graph

  9. +++ b/core/lib/Drupal/Component/HttpFoundation/TESTING.txt
    @@ -0,0 +1,19 @@
    +You can find more information about running PHPUnit tests with Drupal here:
    ...
    +$ cd ./core
    +$ ./vendor/bin/phpunit --group HttpFoundation
    

    Remove the cd core here.
    The group name is "Routing" in SecuredRedirectResponseTest.php so change & question is as above above.

  10. +++ b/core/lib/Drupal/Component/PhpStorage/TESTING.txt
    @@ -0,0 +1,19 @@
    +$ cd ./core
    +$ ./vendor/bin/phpunit --group PhpStorage
    

    $ ./vendor/bin/phpunit -c core --group PhpStorage

  11. +++ b/core/lib/Drupal/Component/Render/TESTING.txt
    @@ -0,0 +1,19 @@
    +$ cd ./core
    

    Take care as above.
    the test group name is "utility".so same question and change as above.
    $ ./vendor/bin/phpunit -c core --group utility

  12. +++ b/core/lib/Drupal/Component/Serialization/TESTING.txt
    @@ -0,0 +1,19 @@
    +$ cd ./core
    +$ ./vendor/bin/phpunit --group Serialization
    

    $ ./vendor/bin/phpunit -c core --group Serialization

  13. +++ b/core/lib/Drupal/Component/Transliteration/composer.json
    @@ -0,0 +1,16 @@
    \ No newline at end of file
    

    Need a new line :)

  14. +++ b/core/lib/Drupal/Component/Utility/README.txt
    @@ -1,4 +1,4 @@
    +The Drupal Utility Component
    ...
     Thanks for using this Drupal component.
    

    This Should be in the Uuid compononent ?

  15. +++ b/core/lib/Drupal/Component/Utility/README.txt
    --- /dev/null
    +++ b/core/lib/Drupal/Component/Uuid/LICENSE.txt
    

    This file should be in Uuid component ?

  16. +++ b/core/tests/Drupal/Tests/ComposerIntegrationTest.php
    @@ -49,10 +49,23 @@ protected function getPaths() {
           $this->root . '/core/lib/Drupal/Component/Utility',
    

    We do need to include Uuid component as well.

dawehner’s picture

The group name is Inspector in the test class(InspectorTest.php) Annotation.
$ ./vendor/bin/phpunit -c core --group Inspector

Sounds like we should add a follow up to fix that.

hussainweb’s picture

Regarding 2, 5 and similar comments, I have made the changes but I think followup is needed to fix the group name. The massive file size difference is because LICENSE.txt was missing in couple of components (DependencyInjection, Plugin, ProxyBuilder).

hussainweb’s picture

Status: Needs work » Needs review
FileSize
328.73 KB

Of course, it helps if I actually upload the file. ;)

naveenvalecha’s picture

Thanks for updated the changes. An interdiff would help a lot here to review the updated changes. interdiff please!

  1. +++ b/core/lib/Drupal/Component/Bridge/TESTING.txt
    @@ -15,5 +15,4 @@ Each component in the Drupal\Component namespace has its own annotated test
    -$ cd ./core
    

    Irrelevant change. Should we take care of it in this or a followup ?

naveenvalecha’s picture

hussainweb’s picture

FileSize
67.99 KB

Sorry about the interdiff. I realized too late. I needed to use some git magic but got it.

naveenvalecha’s picture

Status: Needs review » Needs work

we are very close to RTBC! Some more nitpicks! Reviewed the interdiff.

  1. +++ b/core/lib/Drupal/Component/EventDispatcher/TESTING.txt
    @@ -15,5 +15,4 @@ Each component in the Drupal\Component namespace has its own annotated test
    +$ ./vendor/bin/phpunit -c core/ --group Symfony
    

    Please remove the trailing "/" from core/ to make consistency over all Testing.txt files.see others components TESTING.txt

  2. +++ b/core/lib/Drupal/Component/Gettext/TESTING.txt
    @@ -15,5 +15,4 @@ Each component in the Drupal\Component namespace has its own annotated test
     $ ./vendor/bin/phpunit --group Gettext
    

    Please make it to
    $ ./vendor/bin/phpunit -c core --group Gettext

  3. +++ b/core/lib/Drupal/Component/Graph/TESTING.txt
    @@ -15,5 +15,4 @@ Each component in the Drupal\Component namespace has its own annotated test
     $ ./vendor/bin/phpunit --group Graph
    

    $ ./vendor/bin/phpunit -c core --group Graph

  4. +++ b/core/lib/Drupal/Component/HttpFoundation/TESTING.txt
    @@ -15,5 +15,4 @@ Each component in the Drupal\Component namespace has its own annotated test
     $ ./vendor/bin/phpunit --group HttpFoundation
    

    Make it to $ ./vendor/bin/phpunit -c core --group HttpFoundation

    Also we need to update the group name in SecureRedirectResponseTest.php that we can do in followup.

  5. +++ b/core/lib/Drupal/Component/PhpStorage/TESTING.txt
    @@ -15,5 +15,4 @@ Each component in the Drupal\Component namespace has its own annotated test
     $ ./vendor/bin/phpunit --group PhpStorage
    

    same as above.

  6. +++ b/core/lib/Drupal/Component/ProxyBuilder/TESTING.txt
    @@ -0,0 +1,18 @@
    +$ ./vendor/bin/phpunit -c core --group ProxyBuilder
    

    The group name is proxy_builder in test.so change it to "proxy_builder"

Crell’s picture

+++ b/core/lib/Drupal/Component/Graph/composer.json
@@ -0,0 +1,15 @@
+    "psr-0": {

The autoloaders should be defined to use PSR-4, not PSR-0. PSR-4 can handle full-path without a directory prefix just fine; but PSR-0 and PSR-4 have slightly different parsing rules. Better to just use PSR-4 everywhere.

hussainweb’s picture

I think it was psr-0 because we copied it from one of the components which already had a composer.json. Functionally, there will be no difference if we just change it. But should we do it in a follow up to keep a cleaner history?

hussainweb’s picture

Status: Needs work » Needs review
FileSize
3.11 KB
328.8 KB

Fixing for comments in #57. Thanks for the review and getting the group names, @naveenvalecha.

I am still not changing it to psr-4 yet as @Crell pointed out. I am not sure if we should do that here or in a follow-up.

naveenvalecha’s picture

Status: Needs review » Reviewed & tested by the community

I am still not changing it to psr-4 yet as @Crell pointed out. I am not sure if we should do that here or in a follow-up.

sounds we should add a follow up to fix that.
Rest looks good, we can initially ship with this code.

hussainweb’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Component/FileCache/TESTING.txt
@@ -0,0 +1,18 @@
+$ ./vendor/bin/phpunit --group FileCache

Missing -c core.

I think we should make the change to PSR-4 as Crell suggests since doing that in a followup is pointless.

hussainweb’s picture

Status: Needs work » Needs review
FileSize
6.15 KB
329.99 KB

The idea was to keep a cleaner history if possible. But yes, the changes are not functional, so it's fine.

naveenvalecha’s picture

Status: Needs review » Needs work

@alexpott,
Should we also update the tests group name in this as well b/c those are not functional changes, is that fine if we also keep that as well instead of the followups #2630986: Update the test group name in InspectorTest.php to Assertion,#2630988: Update the test group name in ContainerAwareEventDispatcherTest.php Annotation to EventDispatcher

  1. +++ b/core/lib/Drupal/Component/EventDispatcher/TESTING.txt
    @@ -0,0 +1,18 @@
    +$ ./vendor/bin/phpunit -c core --group Symfony
    

    Shouldn't we change the group name of the test as well b/c there are lots of tests that fall under Symfony groups in core tests ?

  2. +++ b/core/lib/Drupal/Component/Gettext/README.txt
    @@ -1,4 +1,4 @@
    +The Drupal Discovery Component
    

    Irrelevant change. Please revert it.

  3. +++ b/core/lib/Drupal/Component/HttpFoundation/TESTING.txt
    @@ -0,0 +1,18 @@
    +$ ./vendor/bin/phpunit -c core --group HttpFoundation
    

    The group name is "Routing" in test files.Have question regarding same in the comment above.

alexpott’s picture

@naveenvalecha let's not make test changes in this issue.

naveenvalecha’s picture

#66, Thanks for confirming!
From #66, Please ignore #65.1
In #65.3 Please do change to $ ./vendor/bin/phpunit -c core --group Routing we will do the changes of group names in followups.

hussainweb’s picture

FileSize
913 bytes
329.63 KB

Changed as per #65 and #67. Thanks!

hussainweb’s picture

Status: Needs work » Needs review
naveenvalecha’s picture

Issue summary: View changes

Back to RTBC as all mine & alex suggested changes has been addressed.
Added proposed commit message as well from #2337283-48: Add a composer.json file to every component

naveenvalecha’s picture

Status: Needs review » Reviewed & tested by the community
Mile23’s picture

Status: Reviewed & tested by the community » Needs work

Hmm....

$ cd Annotation/
$ composer validate
./composer.json is valid, but with a few warnings
See https://getcomposer.org/doc/04-schema.md for details on the schema
require.drupal/core-plugin : unbound version constraints (>=8.0.0) should be avoided
require.drupal/core-utility : unbound version constraints (>=8.0.0) should be avoided

Suggest ~8 instead. This would be in all places where we declare an interdependency such as this.

  1. +++ b/core/lib/Drupal/Component/Assertion/TESTING.txt
    @@ -0,0 +1,18 @@
    +$ ./vendor/bin/phpunit -c core --group Inspector
    

    Inspector is the group name of the test, but it should be Assertion.

    Should be a follow-up. EDIT: Ahh, there it is: #2630986: Update the test group name in InspectorTest.php to Assertion

  2. +++ b/core/lib/Drupal/Component/Diff/composer.json
    @@ -0,0 +1,16 @@
    +    "php": ">=5.5.9",
    

    Some of these packages don't actually require PHP 5.5.9, but we'd prefer they have the same requirement as D8 core. So no change needed.

hussainweb’s picture

Status: Needs work » Needs review
FileSize
3.26 KB
329.61 KB

#2630986: Update the test group name in InspectorTest.php to Assertion is in and I have changed the test group for that in Assertion\TESTING.txt. It will be a good idea to get the other issue in as well - #2630988: Update the test group name in ContainerAwareEventDispatcherTest.php Annotation to EventDispatcher , which is already RTBC.

I also changed all instances of >=8.0.0 to ~8.0 as per #72. While it's not strictly in scope of the issue, it is similar to the change we did in #64 to change everything to psr-4. It is not functional yet so we might as well change it here.

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC - I guess.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 73: 2337283-73.patch, failed testing.

hussainweb’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
329.63 KB

It's just a reroll due to #2550519: Crypt::randomBytes()/drupal_random_bytes() doesn't actually return cryptographically secure random bytes. Setting back to RTBC.

This is the only difference between the two patches:

 --- a/core/lib/Drupal/Component/Utility/composer.json
 +++ b/core/lib/Drupal/Component/Utility/composer.json
-@@ -8,7 +8,7 @@
-     "php": ">=5.5.9"
+@@ -9,7 +9,7 @@
+     "paragonie/random_compat": "~1.0"
    },
    "autoload": {
 -    "psr-0": {
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
diff --git a/core/lib/Drupal/Component/EventDispatcher/TESTING.txt b/core/lib/Drupal/Component/EventDispatcher/TESTING.txt
index 0d9c291..6ea7b34 100644
--- a/core/lib/Drupal/Component/EventDispatcher/TESTING.txt
+++ b/core/lib/Drupal/Component/EventDispatcher/TESTING.txt
@@ -15,4 +15,4 @@ Each component in the Drupal\Component namespace has its own annotated test
 group. You can use this group to run only the tests for this component. Like
 this:
 
-$ ./vendor/bin/phpunit -c core --group Symfony
+$ ./vendor/bin/phpunit -c core --group EventDispatcher

We need to make this change - I would have fixed on commit but I've contributed to it so I can't commit.

hussainweb’s picture

Status: Needs work » Needs review
FileSize
558 bytes
329.63 KB

Changing as per #77. If that was the only issue, it is good to go to RTBC but keeping it as "Needs Review" just in case.

alexpott’s picture

Status: Needs review » Reviewed & tested by the community

Has someone checked that all the dependencies are correct as this is where mistakes are most likely to be made.

Mile23’s picture

I looked at the Diff dependencies for this, and they seem correct: #2472633: Expand PHPUnit test coverage of the Diff component

Mile23’s picture

Status: Reviewed & tested by the community » Needs work

Has someone checked that all the dependencies are correct as this is where mistakes are most likely to be made.

That's why they were separate issues. :-)

Here's an easy review. I'm poking through the dependencies now, and will add another review.

  1. +++ b/core/lib/Drupal/Component/Annotation/composer.json
    @@ -0,0 +1,19 @@
    +    "drupal/core-plugin": "~8.0",
    +    "drupal/core-utility": "~8.0"
    

    Should be ~8.1

  2. +++ b/core/lib/Drupal/Component/Datetime/composer.json
    @@ -0,0 +1,16 @@
    +    "drupal/core-utility": "~8.0"
    

    Should be ~8.1

  3. +++ b/core/lib/Drupal/Component/Diff/composer.json
    @@ -0,0 +1,16 @@
    +    "drupal/utility": "~8.0"
    

    Should be ~8.1

  4. +++ b/core/lib/Drupal/Component/Discovery/composer.json
    @@ -0,0 +1,17 @@
    +    "drupal/core-utility": "~8.0",
    +    "drupal/core-serialisation": "~8.0"
    

    Should be ~8.1

  5. +++ b/core/lib/Drupal/Component/Render/composer.json
    @@ -0,0 +1,16 @@
    +    "drupal/core-utility": "~8.0"
    

    Should be ~8.1

  6. +++ b/core/lib/Drupal/Component/Uuid/composer.json
    @@ -0,0 +1,20 @@
    +    "drupal/core-utility": "~8.0"
    

    Should be ~8.1

Mile23’s picture

I searched each component for use statements and then compared those to the composer.json file dependencies.

Annotation: good.

Assertion: good.

Bridge: Needs symfony/dependency-injection, uses Zend\Feed, which I believe is in zendframework/zend-feed (there are a couple of different zend feed packages on packagist, which is why I'm not sure.)

Datetime: good.

DependencyInjection: Needs symfony/dependency-injection, symfony/expression-language

Diff: good (see above).

Discovery: Needs drupal/core-filecache, doesn't use core-utility.

EventDispatcher: good.

FileCache: good

Gettext: Needs drupal/core-utility.

Graph: good.

HttpFoundation: good.

PhpStorage: good.

Plugin: Needs symfony/validator.

ProxyBuilder: Doesn't need symfony/dependency-injection afaict. Might need more investigation.

Render: good.

Serialization: good.

Transliteration: good.

Utility: Needs drupal/core-render.

Uuid: good.

Mile23’s picture

Title: [meta] Add a composer.json file to every component (module, later) » Add a composer.json file to every component
Mile23’s picture

Status: Needs work » Needs review
FileSize
332.59 KB
6.73 KB

Added changes from #81, #82.

Mile23’s picture

Needed a reroll.

tstoeckler’s picture

Status: Needs review » Needs work

Not on my watch will the British invade Drupal core...

"name": "drupal/core-discovery",
...
"require": {
...
"drupal/core-serialisation": "~8.1"
},

should be

"name": "drupal/core-discovery",
...
"require": {
...
"drupal/core-serialization": "~8.1"
},

(Note that the component (and the namespace) is already named "correctly".)

heykarthikwithu’s picture

Assigned: Unassigned » heykarthikwithu

working on this.

heykarthikwithu’s picture

Assigned: heykarthikwithu » Unassigned
Status: Needs work » Needs review
FileSize
332.14 KB

Changes as per #86

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

aleksip’s picture

Bumped ~8.1 to ~8.2. Really hope to see this issue land in 8.2!

Crell’s picture

Version: 8.2.x-dev » 8.1.x-dev
Status: Needs review » Reviewed & tested by the community

The composer.json files don't have any bug-impact. Why can't this still be done in 8.1?

(Looks like both patches would need to be applied, as they do differ in version numbers but are otherwise the same I believe.)

xjm’s picture

So the current patch on this issue is only for 8.2.x. Either it is not for 8.1.x, or it is not RTBC.

The issue was made a minor version target by @alexpott back in #44. We discussed whether or not it should be today, but personally, I would be fine with this going into 8.2.x now or whenever.

Crell’s picture

xjm: The patch in #88 is for 8.1. The patch in #90 is for 8.2. Other than changing that reference for component-dependencies, there's no difference between them. Thus, this issue contains an RTBC patch for both 8.1 and for 8.2, either or both of which can (IMO) be committed. (I would favor both.)

xjm’s picture

Version: 8.1.x-dev » 8.2.x-dev

BTW, I belatedly remembered the exact reasoning for this being a minor version target. It was not about any risk particularly, but that it is equivalent to a coding standards change, which we only do in minors.

So marking against 8.2.x for now. Let's get the committer review and potentially a commit there while it is up to date, since 8.2.x is not frozen (8.1.x is in commit freeze and about to go into RC). Then, if there are strong feelings that it should go into 8.1.x as well that could be discussed.

aleksip’s picture

Personally I'd love to see this in 8.1 already! Making these components available to the larger PHP community is an important part of 'getting off the island'. I'm involved in a Drupal/Pattern Lab integration project and we need to use several Drupal Components. October and 8.2 seem such a long way away... :)

If this is considered for 8.1 there is also #2664570: Move Attribute classes under Drupal\Component where the 8.2 patch applies cleanly on 8.1 as well (the patch only moves the classes without any functional changes).

alexpott’s picture

Version: 8.2.x-dev » 8.1.x-dev

Committed 28c46c2 and pushed to 8.2.x. Thanks! I've creditted everyone who commented on the issue because the rolling the patches was the simple part of this one.

Personally, I think given @xjm's explanation that this is equivalent to a coding standards change then actually RC is the perfect time to commit this as that is when we target large coding standards changes. So I'm moving this issue back to 8.1.x and will wait for @xjm's opinion as release manager. But I can see no good reason for not committing this to 8.1.x.

  • alexpott committed 28c46c2 on 8.2.x
    Issue #2337283 by hussainweb, Mile23, alexpott, aleksip, dawehner,...
alexpott’s picture

Re-uploading #88 so the 8.1.x patch is last on the issue.

xjm’s picture

Issue tags: +rc target triage

Personally, I think given @xjm's explanation that this is equivalent to a coding standards change then actually RC is the perfect time to commit this as that is when we target large coding standards changes. So I'm moving this issue back to 8.1.x and will wait for @xjm's opinion as release manager. But I can see no good reason for not committing this to 8.1.x.

@alexpott has a good point about RC and big coding standards changes. (E.g. we just removed @file from a zillion classes during RC for the same reason.) I can see the case for it being an RC target; I feel far more comfortable with that than with a patch release. I want to think about it overnight, but adding to the RC target triage queue to make sure we don't miss the window.

xjm’s picture

I see there is already a change record, but is there anywhere in the handbook or API documentation that we should also document this best practice?

Mile23’s picture

I think there'll be more documentation needed, and more opportunities to add it, as we move on with the parent #1826054: [Meta] Expose Drupal Components outside of Drupal

Unless there was a specific best practice you had in mind...

xjm’s picture

Issue tags: -rc target triage +rc target, +8.1.0 release notes

@Mile23, thanks! I think some overall dev docs make sense to add as a step in the meta but not needed here. I also just checked and it actually looks like the README for Drupal\Component does cover it already:

In other words, only dependencies that can be specified in a composer.json file
of the Component are acceptable dependencies. Every Drupal Component presents a
valid dependency, because it is assumed to contain a composer.json file (even

So I think my comment in #100 is already addressed. Tagging as an RC target so we can ship this in 8.1.x too, and also marking for the release notes so I remember to include it in the section about DX and coding standards improvements for the minor. I'll leave for @alexpott to commit though since he already reviewed it for 8.2.x.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 68b6639 and pushed to 8.1.x. Thanks!

  • alexpott committed 68b6639 on 8.1.x
    Issue #2337283 by hussainweb, Mile23, alexpott, aleksip, dawehner,...

Status: Fixed » Closed (fixed)

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

fgm’s picture

Issue summary: View changes
fgm’s picture

Issue summary: View changes
vijaycs85’s picture