- Merge request !1880changing Composer Scaffold plugin calls from dispatch to dispatchScript β (Open) created by beatrizrodrigues
- π¦πΊAustralia alex.skrypnyk Melbourne
To expand on the above comments: the `Event` passed depends on how the callback was called. If it was called from the `scripts` section of the `composer.json` - it will be of a type `Composer\EventDispatcher\Event` (the most basic event type). If it was called from the plugin - it will be of a type `Composer\Script\Event`, which has access to IO and Composer.
So the passing of the event itself works correctly. I do not see how the ask to change it to `dispatchScript()` can be fulfilled.
Note that there is a different issue related to this block of code: https://www.drupal.org/project/drupal/issues/3438034 π Composer Scaffold plugin event listeners do not receive event dispatch" is mostly correct but could be clearer. Hereβs a revised version for better clarity: "Event listeners in the Composer Scaffold plugin do not receive event dispatches Active
- π¦πΊAustralia alex.skrypnyk Melbourne
I've extensive experimenting on using Drupal Core Scaffold to distribute additional files from my project skeleton (what the Scaffold package promotes).
The requested change would indeed provide additional functionality described in https://www.drupal.org/project/drupal/issues/3182391#comment-15540532 β¨ Allow pre-drupal-scaffold-cmd event to modify composer object/scaffold options Needs work
That issue, if the approach from my comment is confirmed by the core maintainers, will become a duplicate of this one.
Note that this issue's MR does not have tests yet. I suggest to wait for https://www.drupal.org/project/drupal/issues/3438034 π Composer Scaffold plugin event listeners do not receive event dispatch" is mostly correct but could be clearer. Hereβs a revised version for better clarity: "Event listeners in the Composer Scaffold plugin do not receive event dispatches Active to get merged as it provides test fixtures for the subscriber plugins and we can then add more tests for the change suggested here.
I will be happy to pick this one up once the core maintainers approve the approach.
- π¦πΊAustralia alex.skrypnyk Melbourne
This is quite important as it will allow to access the composer object and modify scaffold items as needed.
For example, skeletons may be able to exclude their own `require` sections from the dependency pool in cases were those `require` items are used to initially create the project.
Another example is packages to be able to provide scaffold mappings for other packages.
I've described this in more detail in https://www.drupal.org/project/drupal/issues/3182391#comment-15540532 β¨ Allow pre-drupal-scaffold-cmd event to modify composer object/scaffold options Needs work
@joachim
Do you mind if I take this one on?@alexpott
Will you accept an MR with this change and tests? - π¬π§United Kingdom alexpott πͺπΊπ
@alex.skrypnyk probably - what you are saying makes sense but we can't pre-commit to accepting an MR before we've had a chance to review it and consider it in detail.
- First commit to issue fork.
- last update
9 months ago Patch Failed to Apply - π¦πΊAustralia alex.skrypnyk Melbourne
alex.skrypnyk β changed the visibility of the branch 3266160-composer-scaffold-plugin-with-tests to hidden.
- Status changed to Needs review
9 months ago 4:49am 12 April 2024 - Status changed to Needs work
9 months ago 5:32pm 14 April 2024 - πΊπΈUnited States smustgrave
Haven't reviewed but issue summary update still appears to be needed.
- Status changed to Needs review
9 months ago 8:16pm 14 April 2024 - Status changed to Needs work
8 months ago 4:37pm 19 April 2024 - πΊπΈUnited States smustgrave
Ran test-only feature and it passed when I would expect it to fail https://git.drupalcode.org/issue/drupal-3266160/-/jobs/1375079
- πΊπΈUnited States smustgrave
Adding back tests tag from @alexpott in #6
- Status changed to Needs review
8 months ago 1:48am 30 April 2024 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
The test only pipeline isn't working here because there's no changes to *Test.php files so we need to run locally to verify, I'll do that.
@alex.skrypnyk - which test are you expecting to fail with the changes to the fixture?
The changes look good to me, the new event dispatched (
\Composer\Script\Event
) is a subclass of the old event (\Composer\EventDispatcher\Event
) so there should be no BC breaks here, just more power to event subscribers - as mentioned in the issue summary - e.g. the ability to use IO. - πΊπΈUnited States smustgrave
Tried opening a test-only branch but can't tell if anything is failing because of the change or if HEAD is broken :(
- π¦πΊAustralia alex.skrypnyk Melbourne
@smustgrave
Thank you. Really appreciate your help here.HEAD is failing because of https://www.drupal.org/project/drupal/issues/3417066 π Upgrade PHPUnit to 10, drop Symfony PHPUnit-bridge dependency Fixed
Hoping it will be fixed soon.
- π¦πΊAustralia alex.skrypnyk Melbourne
@larowlan
The test only pipeline isn't working here because there's no changes to *Test.php files so we need to run locally to verify, I'll do that.
This is what I was trying to explain to @smustgrave in Slack, but failed since I do not understand fully how GitLab tests these test-only VS full test (I do understand @smustgrave's point that a test need to be proving that it would test an actual change and really appreciate that he explained all that to me).
It looks like that would not work as per your comment.
So, just going to wait for the HEAD of 11.x to become unblocked.
- π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Yeah,.we just need to know which test fails so someone can run it locally - thanks!
- πΊπΈUnited States smustgrave
So does appear to be failing Unit composer test with just the fixture change. So maybe that counts?
@larowlan what do you think? - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Oh, a second PR with test only changes? Thanks @smustgrave - nice one
- πΊπΈUnited States smustgrave
So think that should be enough? Sorry @alex.skrypnyk didn't think of that approach before.
- Status changed to RTBC
8 months ago 7:54pm 10 May 2024 - π¦πΊAustralia alex.skrypnyk Melbourne
Ok, seeing that the updated MR passed testing and that the test-only PR has failed. Also tested this locally and all looks good.
Marking RTBC.
-
alexpott β
committed d3adef26 on 10.3.x
Issue #3266160 by smustgrave, alex.skrypnyk, tannguyenhn,...
-
alexpott β
committed d3adef26 on 10.3.x
- π¬π§United Kingdom alexpott πͺπΊπ
Committed and pushed a61eee36d2 to 11.x and 7201816d30 to 11.0.x and b676d86b91 to 10.4.x and d3adef268d to 10.3.x. Thanks!
-
alexpott β
committed b676d86b on 10.4.x
Issue #3266160 by smustgrave, alex.skrypnyk, tannguyenhn,...
-
alexpott β
committed b676d86b on 10.4.x
-
alexpott β
committed 7201816d on 11.0.x
Issue #3266160 by smustgrave, alex.skrypnyk, tannguyenhn,...
-
alexpott β
committed 7201816d on 11.0.x
- Status changed to Fixed
8 months ago 8:23am 11 May 2024 -
alexpott β
committed a61eee36 on 11.x
Issue #3266160 by smustgrave, alex.skrypnyk, tannguyenhn,...
-
alexpott β
committed a61eee36 on 11.x
Automatically closed - issue fixed for 2 weeks with no activity.