项目作者: liborm85

项目描述 :
Composer Vendor Cleaner removes unnecessary development files and directories from vendor directory.
高级语言: PHP
项目地址: git://github.com/liborm85/composer-vendor-cleaner.git
创建时间: 2019-10-26T09:24:57Z
项目社区:https://github.com/liborm85/composer-vendor-cleaner

开源协议:MIT License

下载


Composer Vendor Cleaner Packagist

This composer plugin removes unnecessary development files and directories from vendor directory.

Installation

Local installation to project:

  1. composer require liborm85/composer-vendor-cleaner

Global installation:

  1. composer global require liborm85/composer-vendor-cleaner

Requirements

  • PHP 5.6.0+

Configuration

Development files and directories to remove can be defined in composer.json file
in extra data attribute per new key dev-files.
Glob pattern syntax is fully supported.

Example:

  1. "extra": {
  2. "dev-files": {
  3. "/": [ // means: find in all library packages directories and bin directory
  4. "tests/", // means: tests directory whatever
  5. "docs/",
  6. ".travis.yml" // means: .travis.yml file whatever
  7. ],
  8. "*/*": [ // means: find in all library packages directories, but NOT in bin directory
  9. "*.sh"
  10. ],
  11. "bin": [ // means: find in composer bin directory
  12. "*.bat"
  13. ],
  14. "twig/twig": [ // means: find only in twig/twig package directory
  15. "doc/",
  16. "/drupal_test.sh" // means: only file in root directory of twig/twig package
  17. ],
  18. "symfony/*": [ // means: find in all symfony packages
  19. "Tests/"
  20. ],
  21. "other/package": [
  22. "/src/**/*.md" // means: find whatever all md files in src directory, eg.: /src/dir1/test.md, /src/dir1/dir2/readme.md
  23. ],
  24. "example/package": [ // means: remove all files and directories in language directory without cs.php file
  25. "languages/*",
  26. "!languages/cs.php" // means: exclude cs.php file from remove
  27. ]
  28. }
  29. }

Development files and directories can also be defined in an external json file, by specifying the relative path to
this file in the dev-files key in the root composer.json. The format is the same as above.

  1. "extra": {
  2. "dev-files": "composer.dev-files.json"
  3. }

Example of composer.dev-files.json file:

  1. {
  2. "/": [
  3. ".github/"
  4. ],
  5. "twig/twig": [
  6. "doc/"
  7. ]
  8. }

For additional configuration can be used config attribute.

  • match-case (default: true) - Match case of name files and directories.
  • remove-empty-dirs (default: true) - Removes empty directories.
  • no-dev-only (default: false) - If is set true start the cleanup only if the composer command is run with --no-dev.

Example:

  1. "config": {
  2. "dev-files": {
  3. "match-case": false,
  4. "remove-empty-dirs": false
  5. }
  6. }

Why a new plugin?

Some composer packages contain files and directories that do not belong to production servers, but composer
does not solve this.

Exists a lot of plugins for composer trying to solve this issue, they don’t have advanced patterns to filtering
or they are not user definable. Or some have no configuration and it works automatically and delete almost everything
and then the package does not work.

That’s why I created a new one that allows advanced filtering by glob patterns.

If you miss a feature or find bug, please, create an issue.

License

MIT