Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More things to think about #5

Open
PhilETaylor opened this issue Oct 8, 2019 · 0 comments
Open

More things to think about #5

PhilETaylor opened this issue Oct 8, 2019 · 0 comments

Comments

@PhilETaylor
Copy link

PhilETaylor commented Oct 8, 2019

This is my script I use currently - some thoughts in there for you, removing files. I use this in production in a symfony app and so its not breaking my live app :-)

<?php

namespace PhilETaylor;

use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
require 'vendor/autoload.php';


$fileSystem = new Filesystem();


// remove folders not needed
$finder = (new Finder())
    ->in(__DIR__ . '/../../../../vendor')
    ->directories()
    ->path('/\/Tests\/|\/test\/|travis/i');
$folders = [];
foreach ($finder as $file) {
    $absoluteFilePath = $file->getRealPath();
    preg_match('/(.*\/Tests|.*\/travis)\//ism', $absoluteFilePath, $matches);
    if (count($matches)) {
        $folders[$matches[1]] = $matches[1];
    }
}
$folders = array_keys($folders);
if (count($folders)) {
    foreach ($folders as $folder) {
        echo 'Removing ' . $folder . "\n";
        $fileSystem->remove($folder);
    }
}


// Cleanup redundant files
$docs = ['.travis.yml','.scrutinizer.yml','phpcs.xml*','phpcs.php','phpunit.xml*','phpunit.php', 'README*', 'CHANGELOG*', 'FAQ*', 'CONTRIBUTING*', 'HISTORY*', 'UPGRADING*', 'UPGRADE*', 'package*', 'demo', 'example', 'examples', 'doc', 'docs', 'readme*', 'changelog*', 'composer*'];
$finder = (new Finder())
    ->in(__DIR__ . '/../../../../vendor')
    ->files()
    ->name($docs);
foreach ($finder as $file) {
    echo 'Removing ' . $file->getRealPath() . "\n";
    $fileSystem->remove($file->getRealPath());
}

$fileSystem->remove(__DIR__ . '/../../../../vendor/symfony/panther/chromedriver-bin');
$fileSystem->remove(__DIR__ . '/../../../../vendor/twbs/bootstrap/docs');
$fileSystem->remove(__DIR__ . '/../../../../vendor/aws/aws-sdk-php/.changes');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant