[
  {
    "path": ".gitignore",
    "content": "/vendor\r\n/.idea\r\ncomposer.phar\r\ncomposer.lock\r\n.DS_Store"
  },
  {
    "path": "README.md",
    "content": "Composer Cleanup Plugin\n=======================\n\nRemove tests & documentation from the vendor dir. Based on [laravel-vendor-cleanup](https://github.com/barryvdh/laravel-vendor-cleanup) but implemented as a Composer Plugin instead of a Laravel command.\n\nUsually disk size shouldn't be a problem, but when you have to use FTP to deploy or have very limited disk space,\nyou can use this package to cut down the vendor directory by deleting files that aren't used in production (tests/docs etc).\n\n> **Note:** This package is abandoned. Packages should add files they want to exclude to .gitattributes \n\n## Install\n\nRequire this package in your composer.json:\n\n      \"barryvdh/composer-cleanup-plugin\": \"0.4.x\"\n      \n## Usage\n\nThis plugin will work automatically on any packages installed as `dist`. Therefore, if you are using it to build a package archive, simply run `composer install` with the `--prefer-dist` option.\n\n## What does it do?\n\nFor every installed or updated package in the default list, in general:\n\n1. Remove documentation, such as README files, docs folders, etc.\n2. Remove tests, PHPUnit configs, and other build/CI configuration.\n\nSome packages don't obey the general rules, and remove more/less files. Packages that do not have\nrules added are ignored.\n\n## Adding rules\n\nPlease submit a PR to [src/CleanupRules.php] to add more rules for packages.\nMake sure you test them first, sometimes tests dirs are classmapped and will error when deleted.\n\n[src/CleanupRules.php]:                               ./src/CleanupRules.php\n"
  },
  {
    "path": "composer.json",
    "content": "{\n    \"name\": \"barryvdh/composer-cleanup-plugin\",\n    \"type\": \"composer-plugin\",\n    \"description\": \"A composer cleanup plugin, to remove tests and documentation to save space\",\n    \"license\": \"MIT\",\n    \"authors\": [\n        {\n            \"name\": \"Barry vd. Heuvel\",\n            \"email\": \"barryvdh@gmail.com\"\n        }\n    ],\n    \"require\": {\n        \"composer-plugin-api\": \"^2.0\"\n\t},\n\t\"require-dev\": {\n\t\t\"composer/composer\": \"^2.0\"\n\t},\n    \"autoload\": {\n        \"psr-4\": {\n            \"Barryvdh\\\\Composer\\\\\": \"src/\"\n        }\n    },\n    \"extra\": {\n        \"branch-alias\": {\n            \"dev-master\": \"0.3-dev\"\n        },\n        \"class\": \"Barryvdh\\\\Composer\\\\CleanupPlugin\"\n    }\n}\n"
  },
  {
    "path": "src/CleanupPlugin.php",
    "content": "<?php\n\nnamespace Barryvdh\\Composer;\n\nuse Composer\\Composer;\nuse Composer\\EventDispatcher\\EventSubscriberInterface;\nuse Composer\\IO\\IOInterface;\nuse Composer\\Plugin\\PluginInterface;\nuse Composer\\Script\\ScriptEvents;\nuse Composer\\Installer\\PackageEvent;\nuse Composer\\Script\\CommandEvent;\nuse Composer\\Util\\Filesystem;\nuse Composer\\Package\\BasePackage;\n\nclass CleanupPlugin implements PluginInterface, EventSubscriberInterface\n{\n    /** @var  \\Composer\\Composer $composer */\n    protected $composer;\n    /** @var  \\Composer\\IO\\IOInterface $io */\n    protected $io;\n    /** @var  \\Composer\\Config $config */\n    protected $config;\n    /** @var  \\Composer\\Util\\Filesystem $filesystem */\n    protected $filesystem;\n    /** @var  array $rules */\n    protected $rules;\n\n    /**\n     * {@inheritDoc}\n     */\n    public function activate(Composer $composer, IOInterface $io)\n    {\n        $this->composer = $composer;\n        $this->io = $io;\n        $this->config = $composer->getConfig();\n        $this->filesystem = new Filesystem();\n        $this->rules = CleanupRules::getRules();\n\t}\n\t\n\t/**\n     * {@inheritDoc}\n     */\n\tpublic function deactivate(Composer $composer, IOInterface $io)\n\t{\n\t\t//\n\t}\n\n\t/**\n     * {@inheritDoc}\n     */\n\tpublic function uninstall(Composer $composer, IOInterface $io)\n\t{\n\t\t//\n\t}\n\n    /**\n     * {@inheritDoc}\n     */\n    public static function getSubscribedEvents()\n    {\n        return array(\n\t\t\t'post-package-install'\t=> 'onPostPackageInstall',\n\t\t\t'post-package-update'\t=> 'onPostPackageUpdate',\n            /*ScriptEvents::POST_INSTALL_CMD  => array(\n                array('onPostInstallUpdateCmd', 0)\n            ),\n            ScriptEvents::POST_UPDATE_CMD  => array(\n                array('onPostInstallUpdateCmd', 0)\n            ),*/\n        );\n    }\n\n    /**\n     * Function to run after a package has been installed\n     */\n    public function onPostPackageInstall(PackageEvent $event)\n    {\n        /** @var \\Composer\\Package\\CompletePackage $package */\n        $package = $event->getOperation()->getPackage();\n\n        $this->cleanPackage($package);\n    }\n\n    /**\n     * Function to run after a package has been updated\n     */\n    public function onPostPackageUpdate(PackageEvent $event)\n    {\n        /** @var \\Composer\\Package\\CompletePackage $package */\n        $package = $event->getOperation()->getTargetPackage();\n\n        $this->cleanPackage($package);\n    }\n\n    /**\n     * Function to run after a package has been updated\n     *\n     * @param CommandEvent $event\n     */\n    public function onPostInstallUpdateCmd(CommandEvent $event)\n    {\n        /** @var \\Composer\\Repository\\WritableRepositoryInterface $repository */\n        $repository = $this->composer->getRepositoryManager()->getLocalRepository();\n\n        /** @var \\Composer\\Package\\CompletePackage $package */\n        foreach($repository->getPackages() as $package){\n            if ($package instanceof BasePackage) {\n                $this->cleanPackage($package);\n            }\n        }\n    }\n\n    /**\n     * Clean a package, based on its rules.\n     *\n     * @param BasePackage  $package  The package to clean\n     * @return bool True if cleaned\n     */\n    protected function cleanPackage(BasePackage $package)\n    {\n        // Only clean 'dist' packages\n        if ($package->getInstallationSource() !== 'dist') {\n            return false;\n        }\n\n        $vendorDir = $this->config->get('vendor-dir');\n        $targetDir = $package->getTargetDir();\n        $packageName = $package->getPrettyName();\n        $packageDir = $targetDir ? $packageName . '/' . $targetDir : $packageName ;\n\n        $rules = isset($this->rules[$packageName]) ? $this->rules[$packageName] : null;\n        if(!$rules){\n            return;\n        }\n\n        $dir = $this->filesystem->normalizePath(realpath($vendorDir . '/' . $packageDir));\n        if (!is_dir($dir)) {\n            return false;\n        }\n\n        foreach((array) $rules as $part) {\n            // Split patterns for single globs (should be max 260 chars)\n            $patterns = explode(' ', trim($part));\n            \n            foreach ($patterns as $pattern) {\n                try {\n                    foreach (glob($dir.'/'.$pattern) as $file) {\n                        $this->filesystem->remove($file);\n                    }\n                } catch (\\Exception $e) {\n                    $this->io->write(\"Could not parse $packageDir ($pattern): \".$e->getMessage());\n                }\n            }\n        }\n\n        return true;\n    }\n}\n"
  },
  {
    "path": "src/CleanupRules.php",
    "content": "<?php\n\nnamespace Barryvdh\\Composer;\n\nclass CleanupRules\n{\n    public static function getRules()\n    {\n        // Default patterns for common files\n        $docs = 'README* CHANGELOG* FAQ* CONTRIBUTING* HISTORY* UPGRADING* UPGRADE* package* demo example examples doc docs readme* changelog* composer*';\n        $tests = '.travis.yml .scrutinizer.yml phpcs.xml* phpcs.php phpunit.xml* phpunit.php test tests Tests travis patchwork.json';\n\n        return array(\n            'tecnickcom/tcpdf'                     => array($docs, $tests, 'fonts'),\n            'anahkiasen/former'                     => array($docs, $tests),\n            'anahkiasen/html-object'                => array($docs, 'phpunit.xml* tests/*'),\n            'anahkiasen/rocketeer'                  => array($docs, $tests),\n            'anahkiasen/underscore-php'             => array($docs, $tests),\n            'aws/aws-sdk-php'                 \t    => array($docs, $tests),\n            'barryvdh/composer-cleanup-plugin'      => array($docs, $tests),\n            'barryvdh/laravel-debugbar'             => array($docs, $tests),\n            'barryvdh/laravel-ide-helper'           => array($docs, $tests),\n            'bllim/datatables'                      => array($docs, $tests),\n            'cartalyst/sentry'                      => array($docs, $tests),\n            'classpreloader/classpreloader'         => array($docs, $tests),\n            'd11wtq/boris'                          => array($docs, $tests),\n            'danielstjules/stringy'                 => array($docs, $tests),\n            'dflydev/markdown'                      => array($docs, $tests),\n            'dnoegel/php-xdg-base-dir'              => array($docs, $tests),\n            'doctrine/annotations'                  => array($docs, $tests, 'bin'),\n            'doctrine/cache'                        => array($docs, $tests, 'bin'),\n            'doctrine/collections'                  => array($docs, $tests),\n            'doctrine/common'                       => array($docs, $tests, 'bin lib/vendor'),\n            'doctrine/dbal'                         => array($docs, $tests, 'bin build* docs2 lib/vendor'),\n            'doctrine/inflector'                    => array($docs, $tests),\n            'dompdf/dompdf'                         => array($docs, $tests, 'www'),\n            'filp/whoops'                           => array($docs, $tests),\n            'guzzle/guzzle'                         => array($docs, $tests),\n            'guzzlehttp/guzzle'                     => array($docs, $tests),\n            'guzzlehttp/oauth-subscriber'           => array($docs, $tests),\n            'guzzlehttp/streams'                    => array($docs, $tests),\n            'imagine/imagine'                       => array($docs, $tests, 'lib/Imagine/Test'),\n            'intervention/image'                    => array($docs, $tests, 'public'),\n            'ircmaxell/password-compat'             => array($docs, $tests),\n            'jakub-onderka/php-console-color'       => array($docs, $tests, 'build.xml example.php'),\n            'jakub-onderka/php-console-highlighter' => array($docs, $tests, 'build.xml'),\n            'jasonlewis/basset'                     => array($docs, $tests),\n            'jeremeamia/SuperClosure'               => array($docs, $tests, 'demo'),\n            'kriswallsmith/assetic'                 => array($docs, $tests),\n            'laravel/framework'                     => array($docs, $tests, 'build'),\n            'leafo/lessphp'                         => array($docs, $tests, 'Makefile package.sh'),\n            'league/flysystem'                      => array($docs, $tests),\n            'league/stack-robots'                   => array($docs, $tests),\n            'maximebf/debugbar'                     => array($docs, $tests, 'demo'),\n            'mccool/laravel-auto-presenter'         => array($docs, $tests),\n            'mockery/mockery'                       => array($docs, $tests),\n            'monolog/monolog'                       => array($docs, $tests),\n            'mrclay/minify'                         => array($docs, $tests, 'MIN.txt min_extras min_unit_tests min/builder min/config* min/quick-test* min/utils.php min/groupsConfig.php min/index.php'),\n            'mtdowling/cron-expression'             => array($docs, $tests),\n            'mustache/mustache'                     => array($docs, $tests, 'bin'),\n            'nesbot/carbon'                         => array($docs, $tests),\n            'nikic/php-parser'                      => array($docs, $tests, 'test_old'),\n            'oyejorge/less.php'                     => array($docs, $tests),\n            'patchwork/utf8'                        => array($docs, $tests),\n            'phenx/php-font-lib'                    => array($docs, $tests. 'www'),\n            'phpdocumentor/reflection-docblock'     => array($docs, $tests),\n            'phpoffice/phpexcel'                    => array($docs, $tests, 'Examples unitTests changelog.txt'),\n            'phpoffice/phpspreadsheet'              => array($docs, $tests, 'samples'),\n            'phpseclib/phpseclib'                   => array($docs, $tests, 'build'),\n            'predis/predis'                         => array($docs, $tests, 'bin'),\n            'psr/log'                               => array($docs, $tests),\n            'psy/psysh'                             => array($docs, $tests),\n            'quickbooks/v3-php-sdk'                 => array($docs, $tests, 'docs docs/* src/XSD2PHP/test src/XSD2PHP/test/*'),\n            'rcrowe/twigbridge'                     => array($docs, $tests),\n            'simplepie/simplepie'                   => array($docs, $tests, 'build compatibility_test ROADMAP.md'),\n            'stack/builder'                         => array($docs, $tests),\n            'swiftmailer/swiftmailer'               => array($docs, $tests, 'build* notes test-suite create_pear_package.php'),\n            'symfony/browser-kit'                   => array($docs, $tests),\n            'symfony/class-loader'                  => array($docs, $tests),\n            'symfony/console'                       => array($docs, $tests),\n            'symfony/css-selector'                  => array($docs, $tests),\n            'symfony/debug'                         => array($docs, $tests),\n            'symfony/dom-crawler'                   => array($docs, $tests),\n            'symfony/event-dispatcher'              => array($docs, $tests),\n            'symfony/filesystem'                    => array($docs, $tests),\n            'symfony/finder'                        => array($docs, $tests),\n            'symfony/http-foundation'               => array($docs, $tests),\n            'symfony/http-kernel'                   => array($docs, $tests),\n            'symfony/process'                       => array($docs, $tests),\n            'symfony/routing'                       => array($docs, $tests),\n            'symfony/security'                      => array($docs, $tests),\n            'symfony/security-core'                 => array($docs, $tests),\n            'symfony/translation'                   => array($docs, $tests),\n            'symfony/var-dumper'                    => array($docs, $tests),\n            'tijsverkoyen/css-to-inline-styles'     => array($docs, $tests),\n            'twig/twig'                             => array($docs, $tests),\n            'venturecraft/revisionable'             => array($docs, $tests),\n            'vlucas/phpdotenv'                      => array($docs, $tests),\n            'willdurand/geocoder'                   => array($docs, $tests),\n            'willdurand/geocoder'                   => array($docs, $tests),\n            \n\n        );\n    }\n}\n"
  }
]