barryvdh / composer-cleanup-plugin Goto Github PK
View Code? Open in Web Editor NEWComposer plugin for cleaning up unused files from packages.
Composer plugin for cleaning up unused files from packages.
Improved enough to tag a Release?
Hi barry,
as a user of the former laravel cleanup plugin, i now tried your new composer cleanup plugin.
I run composer under win7 with git bash, and there the path length is limited to 260 chars:
Could not parse symfony/translation/Symfony/Component/Translation
({README*,CHANGELOG*,FAQ*,CONTRIBUTING*,HISTORY*,UPGRADING*,UPGRADE*,package*,demo,example,examples,doc,docs,readme*,.travis.yml,.scrutinizer.yml,phpunit.xml*,phpunit.php,test,tests,Tests}):
glob(): Pattern exceeds the maximum allowed length of 260 characters
I think a solution could be splitting patterns into multiple glob's? Might be a little slower, but composer operations aren't perfomance critical i think?
Would you change the glob code to work on win or accept a pr?
When using docker images EVERYTHING should be done to reduce docker image size, so the statement
In normal circumstances, you shouldn't care about disk space
is actually incorrect for many of us :)
Test sources are in most libraries declared in the composer "autoload-dev"
section. So technically it should be enough to just check if there is no overlap with the normal "autoload"
section and then remove everything inside the dev folders.
Can not install after moving to Composer2.
- Installing barryvdh/composer-cleanup-plugin (dev-master e123550): Extracting archive
PHP Fatal error: Uncaught Error: Undefined constant Composer\Script\ScriptEvents::POST_PACKAGE_INSTALL in /htdocs/vendor/barryvdh/composer-cleanup-plugin/src/CleanupPlugin.php:62
Stack trace:
#0 phar:///htdocs/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(435): Barryvdh\Composer\CleanupPlugin::getSubscribedEvents()
#1 phar:///htdocs/composer.phar/src/Composer/Plugin/PluginManager.php(415): Composer\EventDispatcher\EventDispatcher->addSubscriber()
#2 phar:///htdocs/composer.phar/src/Composer/Plugin/PluginManager.php(293): Composer\Plugin\PluginManager->addPlugin()
#3 phar:///htdocs/composer.phar/src/Composer/Installer/PluginInstaller.php(79): Composer\Plugin\PluginManager->registerPackage()
#4 [internal function]: Composer\Installer\PluginInstaller->Composer\Installer\{closure}()
#5 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func()
#6 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(74): React\Promise\FulfilledPromise->then()
#7 [internal function]: React\Promise\Deferred->React\Promise\{closure}()
#8 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(166): call_user_func()
#9 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(95): React\Promise\Deferred->processQueue()
#10 [internal function]: React\Promise\Deferred->resolve()
#11 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func()
#12 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(76): React\Promise\FulfilledPromise->then()
#13 [internal function]: React\Promise\Deferred->React\Promise\{closure}()
#14 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(166): call_user_func()
#15 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(95): React\Promise\Deferred->processQueue()
#16 [internal function]: React\Promise\Deferred->resolve()
#17 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func()
#18 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(74): React\Promise\FulfilledPromise->then()
#19 [internal function]: React\Promise\Deferred->React\Promise\{closure}()
#20 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(166): call_user_func()
#21 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(95): React\Promise\Deferred->processQueue()
#22 [internal function]: React\Promise\Deferred->resolve()
#23 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func()
#24 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(76): React\Promise\FulfilledPromise->then()
#25 [internal function]: React\Promise\Deferred->React\Promise\{closure}()
#26 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(166): call_user_func()
#27 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(95): React\Promise\Deferred->processQueue()
#28 [internal function]: React\Promise\Deferred->resolve()
#29 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func()
#30 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(76): React\Promise\FulfilledPromise->then()
#31 [internal function]: React\Promise\Deferred->React\Promise\{closure}()
#32 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(166): call_user_func()
#33 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(95): React\Promise\Deferred->processQueue()
#34 [internal function]: React\Promise\Deferred->resolve()
#35 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func()
#36 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(76): React\Promise\FulfilledPromise->then()
#37 [internal function]: React\Promise\Deferred->React\Promise\{closure}()
#38 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(166): call_user_func()
#39 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(95): React\Promise\Deferred->processQueue()
#40 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Promise.php(42): React\Promise\Deferred->resolve()
#41 [internal function]: React\Promise\Promise->React\Promise\{closure}()
#42 phar:///htdocs/composer.phar/src/Composer/Util/ProcessExecutor.php(322): call_user_func()
#43 phar:///htdocs/composer.phar/src/Composer/Util/Loop.php(98): Composer\Util\ProcessExecutor->countActiveJobs()
#44 phar:///htdocs/composer.phar/src/Composer/Installer/InstallationManager.php(497): Composer\Util\Loop->wait() [28/1832]
#45 phar:///htdocs/composer.phar/src/Composer/Installer/InstallationManager.php(470): Composer\Installer\InstallationManager->waitOnPromises()
#46 phar:///htdocs/composer.phar/src/Composer/Installer/InstallationManager.php(390): Composer\Installer\InstallationManager->executeBatch()
#47 phar:///htdocs/composer.phar/src/Composer/Installer/InstallationManager.php(282): Composer\Installer\InstallationManager->downloadAndExecuteBatch()
#48 phar:///htdocs/composer.phar/src/Composer/Installer.php(754): Composer\Installer\InstallationManager->execute()
#49 phar:///htdocs/composer.phar/src/Composer/Installer.php(583): Composer\Installer->doInstall()
#50 phar:///htdocs/composer.phar/src/Composer/Installer.php(279): Composer\Installer->doUpdate()
#51 phar:///htdocs/composer.phar/src/Composer/Command/UpdateCommand.php(248): Composer\Installer->run()
#52 phar:///htdocs/composer.phar/vendor/symfony/console/Command/Command.php(245): Composer\Command\UpdateCommand->execute()
#53 phar:///htdocs/composer.phar/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run()
#54 phar:///htdocs/composer.phar/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand()
#55 phar:///htdocs/composer.phar/src/Composer/Console/Application.php(336): Symfony\Component\Console\Application->doRun()
#56 phar:///htdocs/composer.phar/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun()
#57 phar:///htdocs/composer.phar/src/Composer/Console/Application.php(131): Symfony\Component\Console\Application->run()
#58 phar:///htdocs/composer.phar/bin/composer(83): Composer\Console\Application->run()
#59 /htdocs/composer.phar(29): require('...')
#60 {main}
thrown in /htdocs/vendor/barryvdh/composer-cleanup-plugin/src/CleanupPlugin.php on line 62
Fatal error: Uncaught Error: Undefined constant Composer\Script\ScriptEvents::POST_PACKAGE_INSTALL in /htdocs/vendor/barryvdh/composer-cleanup-plugin/src/CleanupPlugin.php
:62
Stack trace:
#0 phar:///htdocs/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(435): Barryvdh\Composer\CleanupPlugin::getSubscribedEvents()
#1 phar:///htdocs/composer.phar/src/Composer/Plugin/PluginManager.php(415): Composer\EventDispatcher\EventDispatcher->addSubscriber()
#2 phar:///htdocs/composer.phar/src/Composer/Plugin/PluginManager.php(293): Composer\Plugin\PluginManager->addPlugin()
#3 phar:///htdocs/composer.phar/src/Composer/Installer/PluginInstaller.php(79): Composer\Plugin\PluginManager->registerPackage()
#4 [internal function]: Composer\Installer\PluginInstaller->Composer\Installer\{closure}()
#5 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func()
#6 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(74): React\Promise\FulfilledPromise->then()
#7 [internal function]: React\Promise\Deferred->React\Promise\{closure}()
#8 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(166): call_user_func()
#9 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(95): React\Promise\Deferred->processQueue()
#10 [internal function]: React\Promise\Deferred->resolve()
#11 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func()
#12 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(76): React\Promise\FulfilledPromise->then()
#13 [internal function]: React\Promise\Deferred->React\Promise\{closure}()
#14 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(166): call_user_func()
#15 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(95): React\Promise\Deferred->processQueue()
#16 [internal function]: React\Promise\Deferred->resolve()
#17 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func()
#18 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(74): React\Promise\FulfilledPromise->then()
#19 [internal function]: React\Promise\Deferred->React\Promise\{closure}()
#20 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(166): call_user_func()
#21 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(95): React\Promise\Deferred->processQueue()
#22 [internal function]: React\Promise\Deferred->resolve()
#23 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func()
#24 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(76): React\Promise\FulfilledPromise->then()
#25 [internal function]: React\Promise\Deferred->React\Promise\{closure}()
#26 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(166): call_user_func()
#27 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(95): React\Promise\Deferred->processQueue()
#28 [internal function]: React\Promise\Deferred->resolve()
#29 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func()
#30 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(76): React\Promise\FulfilledPromise->then()
#31 [internal function]: React\Promise\Deferred->React\Promise\{closure}()
#32 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(166): call_user_func()
#33 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(95): React\Promise\Deferred->processQueue()
#34 [internal function]: React\Promise\Deferred->resolve()
#35 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func()
#36 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(76): React\Promise\FulfilledPromise->then()
#37 [internal function]: React\Promise\Deferred->React\Promise\{closure}()
#38 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(166): call_user_func()
#39 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Deferred.php(95): React\Promise\Deferred->processQueue()
#40 phar:///htdocs/composer.phar/vendor/react/promise/src/React/Promise/Promise.php(42): React\Promise\Deferred->resolve()
#41 [internal function]: React\Promise\Promise->React\Promise\{closure}()
#42 phar:///htdocs/composer.phar/src/Composer/Util/ProcessExecutor.php(322): call_user_func()
#43 phar:///htdocs/composer.phar/src/Composer/Util/Loop.php(98): Composer\Util\ProcessExecutor->countActiveJobs()
#44 phar:///htdocs/composer.phar/src/Composer/Installer/InstallationManager.php(497): Composer\Util\Loop->wait()
#45 phar:///htdocs/composer.phar/src/Composer/Installer/InstallationManager.php(470): Composer\Installer\InstallationManager->waitOnPromises()
#46 phar:///htdocs/composer.phar/src/Composer/Installer/InstallationManager.php(390): Composer\Installer\InstallationManager->executeBatch()
#47 phar:///htdocs/composer.phar/src/Composer/Installer/InstallationManager.php(282): Composer\Installer\InstallationManager->downloadAndExecuteBatch()
#48 phar:///htdocs/composer.phar/src/Composer/Installer.php(754): Composer\Installer\InstallationManager->execute()
#49 phar:///htdocs/composer.phar/src/Composer/Installer.php(583): Composer\Installer->doInstall()
#50 phar:///htdocs/composer.phar/src/Composer/Installer.php(279): Composer\Installer->doUpdate()
#51 phar:///htdocs/composer.phar/src/Composer/Command/UpdateCommand.php(248): Composer\Installer->run()
#52 phar:///htdocs/composer.phar/vendor/symfony/console/Command/Command.php(245): Composer\Command\UpdateCommand->execute()
#53 phar:///htdocs/composer.phar/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run()
#54 phar:///htdocs/composer.phar/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand()
#55 phar:///htdocs/composer.phar/src/Composer/Console/Application.php(336): Symfony\Component\Console\Application->doRun()
#56 phar:///htdocs/composer.phar/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun()
#57 phar:///htdocs/composer.phar/src/Composer/Console/Application.php(131): Symfony\Component\Console\Application->run()
#58 phar:///htdocs/composer.phar/bin/composer(83): Composer\Console\Application->run()
#59 /htdocs/composer.phar(29): require('...')
#60 {main}
thrown in /htdocs/vendor/barryvdh/composer-cleanup-plugin/src/CleanupPlugin.php on line 62
The catch all rule would clean all other packages which do not match an existing rule, by using a default rule; such as array($docs, $tests)
This would allow all packages to be cleaned
I have composer 2.1.5 and PHP 7.4. When I run:
composer require βdev barryvdh/composer-cleanup-plugin
I get this error:
PHP Fatal error: Uncaught Error: Undefined class constant 'POST_PACKAGE_INSTALL' in .../vendor/barryvdh/composer-cleanup-plugin/src/CleanupPlugin.php:62
Please create a new version to be used with composer.
Some additions:
.git
from resulting package? how to add my own rules to config without forking/PR'ing project?
After installing composer packadge docs still in vendor.
For example, vendor/monolog/monolog/doc
How to activate plugin?
When I suggested this plugin to my team, they had the following questions, which I think are valid, but are not mentioned in the readme:
Does this plugin only work for a pre-defined list of packages?
Just state that in the docs.
Which packages does it work for?
Link to this list.
Which files will it remove?
Explain that it knows which specific files to remove, in addition to these.
Can it also remove docs and tests from all other packages, at least by default?
Just mention that it cannot. But this would be a nice feature.
Can I configure which files to include/exclude from removal, in addition to the pre-configured ones?
Explain that this is not possible. But again, this is a feature that would be great to see.
Hi barry,
the github repo is named composer-cleanup-plugin, the composer.json name is composer-cleanup-login. Perhaps you like to normalize this to avoid confusion?
composer-cleanup-plugin/composer.json
Line 13 in dd3bef7
In my test project some files aren't deleted (former laravel-vendor-cleanup did):
vendor/laravel/framework/src/Illuminate/Database/README.md
vendor/laravel/framework/src/Illuminate/Queue/README.md
vendor/laravel/framework/src/Illuminate/Workbench/stubs/phpunit.xml
vendor/nikic/php-parser/grammar/README.md
what should we do about it? README default rules - is it secure? Package specific rules?
There is an ugly warning for every package when using composer update in shell:
Deprecation Notice: The callback Barryvdh\Composer\CleanupPlugin::onPostPackageUpdate declared at D:\repositories\rehab-app\vendor\barryvdh\composer-cleanup-plugin\src\CleanupPlugin.php accepts a Composer\Script\PackageEvent but post-package-update events use a Composer\Installer\PackageEvent instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes in phar://D:/repositories/tools/vendor/composer/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:320
with Composer version 1.3.2 2017-01-27 18:23:41
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.