skrub icon indicating copy to clipboard operation
skrub copied to clipboard

More things to think about

Open PhilETaylor opened this issue 6 years ago • 0 comments

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');

PhilETaylor avatar Oct 08 '19 11:10 PhilETaylor