Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently implementation of vendorTestCodeCleanup() from core/lib/Drupal/Core/Composer/Composer.php
coming with some room of space for improvement:
- It is now hardcode mapping the cleanup target directories with static::$packageToCleanup, so will not cleanup other else vendor package's test code if possible
- Custom implementation of findPackageKey() can be replaced by the use of symfony/finder, plus the use of regex for matching
- Custom implementation of deleteRecursive() can be replaced by the use of symfony/filesystem
Original implementation cloned from (ok these 2 files are just identical):
- https://github.com/drustack/drustack-standard/blob/7.44.x/src/Composer/S...
- https://github.com/drustack/drustack-standard/blob/develop/src/Composer/...
Usage example:
Comment | File | Size | Author |
---|---|---|---|
#8 | drupal-8.2.x-composer_php_improve_vendorTestCodeCleanup-2760467-8.patch | 10.37 KB | hswong3i |
Comments
Comment #2
hswong3i CreditAttribution: hswong3i commentedComment #3
hswong3i CreditAttribution: hswong3i commentedComment #4
hswong3i CreditAttribution: hswong3i commentedComment #5
Mile23This kind of change would definitely be in 8.2.x.
+1 on using symfony/finder, but it's not a dependency of core.
-1 on tossing away the big array of directories. We made that in order to be specific about what we're removing.
We also need to have a way to show whether the directory is missing or has otherwise changed. See the conversation here: #2664274: Combination of --prefer-dist and .gitattributes confuses our vendor test cleanup
Comment #6
hswong3i CreditAttribution: hswong3i commentedsymfony/filesystem
andsymfony/finder
as core dependency. Actually there must be room of space for utilize these 2 package in order to replace some of our legacy core code with manual folder/file handling.symfony/finder
.Moreover, after a quick check with original though for #2664274: Combination of --prefer-dist and .gitattributes confuses our vendor test cleanup:
Now we will not hit such exception anymore, because of the use of
symfony/finder
;-)Comment #8
hswong3i CreditAttribution: hswong3i commentedFix typo during translate original big array with regex...
Comment #15
Mile23vendorTestCodeCleanup() has been moved to a Composer plugin: https://www.drupal.org/node/3059717
We didn't use the symfony components, though it would still make sense to do so.
The plugin is configurable: https://www.drupal.org/docs/develop/using-composer/using-drupals-vendor-...
Closing here. Thanks, @hswong3i.