Git Product home page Git Product logo

skrub's Introduction

Skrub.

Skrub is a composer plugin that will remove useless files and free up some space, especially useful when trying to keep Docker images small. A lot of OSS project owners use .gitattributes to strip junk out but the majority don't.

Installation

Just run composer require ssx/skrub and you're good to go.

Usage

composer skrub will list the files Skrub feels it can safely remove and the total disk space that can be regained.

Adding --perform to the command will actually delete the files & directories from your system.

asciicast

Warranty, Disclaimer etc.

This is a plugin that will perform a deletion command on your system. The author is in no way liable for any data loss arising from its use or if it deletes unexpected files. Pay attention to the files Skrub lists.

Security Issues

If you discover a security issue with Skrub, please email [email protected] and I'll response as soon as possible.

skrub's People

Contributors

pataar avatar sarelvdwalt avatar ssx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

skrub's Issues

More things to think about

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

`stub` directory

Some packages use the stub directory in their file generators (Laravel Dusk (when generating a new test), Laravel Horizon (on installation; for customizing who can access), Laravel Telescope (on installation; for customizing who can access), etc.). An option to ignore removing this directory would be awesome.

Example paths:

path: ./vendor/laravel/telescope/stubs
name: stubs
is directory: ./vendor/laravel/telescope/stubs
 
path: ./vendor/laravel/horizon/stubs
name: stubs
is directory: ./vendor/laravel/horizon/stubs
 
path: ./vendor/laravel/dusk/stubs
name: stubs
is directory: ./vendor/laravel/dusk/stubs

Drop removed stuff from autoloader

The tool should also remove things from autoloader, especially from the class map. Such missing files produce errors on every composer call:

composer require name/redacted
Could not scan for classes inside "/path/redacted/friendsofphp/php-cs-fixer/tests/Test/AbstractFixerTestCase.php" which does not appear to be a file nor a folder
Could not scan for classes inside "/path/redacted/friendsofphp/php-cs-fixer/tests/Test/AbstractIntegrationCaseFactory.php" which does not appear to be a file nor a folder
Could not scan for classes inside "/path/redacted/friendsofphp/php-cs-fixer/tests/Test/AbstractIntegrationTestCase.php" which does not appear to be a file nor a folder
Could not scan for classes inside "/path/redacted/friendsofphp/php-cs-fixer/tests/Test/Assert/AssertTokensTrait.php" which does not appear to be a file nor a folder
Could not scan for classes inside "/path/redacted/friendsofphp/php-cs-fixer/tests/Test/IntegrationCase.php" which does not appear to be a file nor a folder
Could not scan for classes inside "/path/redacted/friendsofphp/php-cs-fixer/tests/Test/IntegrationCaseFactory.php" which does not appear to be a file nor a folder
Could not scan for classes inside "/path/redacted/friendsofphp/php-cs-fixer/tests/Test/IntegrationCaseFactoryInterface.php" which does not appear to be a file nor a folder
Could not scan for classes inside "/path/redacted/friendsofphp/php-cs-fixer/tests/Test/InternalIntegrationCaseFactory.php" which does not appear to be a file nor a folder
Could not scan for classes inside "/path/redacted/friendsofphp/php-cs-fixer/tests/TestCase.php" which does not appear to be a file nor a folder
    1/1:        https://repo.packagist.org/p/provider-latest$c7ca06476ab8ecb0cc6ceef2014da81f720cf5007b793f5709cb26fe63e9169b.json
    Finished: success: 1, skipped: 0, failure: 0, total: 1

As you can see, I have friendsofphp/php-cs-fixer in require-dev section.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.