Removes generated and downloaded files from code projects to free up space

Related tags

Utilities makeclean
Overview

makeclean

Crates.io docs.rs

Removes generated and downloaded files from code projects to free up space.

Features:

  • List, cleans and archives projects depending on how long you haven't touched them.
  • Respects .gitignore files even outside Git repositories. Build tools often create a .gitignore file when initializing a new project, so this makes sure that the dependencies are not traversed even in case you have not initialized the Git repository yet.
  • Supports .ignore files, which have the same semantics as .gitignore files and are supported by search tools such as ripgrep and The Silver Searcher.
  • Ignores hidden directories.

Currently supports the following build tools:

  • Cargo
  • Elm
  • Gradle
  • Maven
  • Mix
  • NPM

Table of contents:

Installation

makeclean should work on Linux, MacOS and Windows. Only tested on Linux and Mac though.

Install using Cargo:

cargo install makeclean

Usage

Run makeclean --help to see all available options.

List projects

List all projects that are "stale", that is, have not been changed recently, under a given path, using --list/-l:

makeclean --list ~/projects

By default, a project is considered stale if there weren't any changed for at least a month. You can change this by using --min-stale/-m; for example, to consider all projects that have not been modified within the last 2 weeks:

makeclean --list --min-stale=2w ~/projects

Set --min-stale to zero to disable the check:

makeclean --list --min-stale=0 ~/projects

You can also filter by build tool using --type/-t:

makeclean --list --type npm ~/projects

Clean projects

By default, makeclean looks for any projects that haven't been touched for a month, and offers to clean them:

makeclean ~/projects

Use --dry-run/-n to see what would happen, without actually deleting anything:

makeclean --dry-run ~/projects

If you run makeclean in a script and don't want the prompt, you can pass --yes to proceed automatically:

makeclean --yes ~/projects

Clean + archive projects

If you also want to archive the projects after cleaning them up, pass --archive. For example, the following command would replace the contents of ~/projects/foo with ~/projects/foo.tar.xz, after cleaning it:

makeclean --archive ~/projects/foo

Note that while --archive also considers cleaned projects, it still respects --min-stale. If makeclean doesn't find your project but you think it should, try again with the environment variable RUST_LOG set to trace, e.g., RUST_LOG=trace makeclean --archive ~/projects/foo. You should see a hint as to why the project was not considered. If the logs don't tell you what's going on, please consider creating a GitHub issue.

To restore the project, use tar (which is probably already installed on your system):

cd ~/projects/foo
tar -xaf foo.tar.xz && rm foo.tar.xz

Use case: automatically run for multiple project directories

Let's say you have a list of directories where you know you'll create a lot of one-off projects you don't need to keep around in a ready state. You can use the following command to automically process them:

$ cat playground.txt
~/code/rust-playground
~/code/elm-playground
~/code/flutter-playground

$ # Replacing newlines with zero-bytes is needed to process whitespace correctly without fiddling around with IFS...
$ xargs -0 -n 1 makeclean --min-stale=7d --yes < <(tr \\n \\0 <playground.txt)

Hack it

Check out the documentation on crates.io. PRs welcome!

License

MIT. Any contributions are assumed MIT-licensed as well.

You might also like...
Framework is a detector for different frameworks in one projects

Framework is a detector for different frameworks in one projects Usage use

A simple string interner / symbol table for Rust projects.

Symbol Interner A small Rust crate that provides a naïve string interner. Consult the documentation to learn about the types that are exposed. Install

A bundler (mainly for TypeScript projects) made in Rust

TSAR A bundler (mainly for TypeScript projects) made in Rust. Also my first Rust Project! What does TSAR stand for Like phar (PHP Archive) or JAR (Jav

Bindings to the Tauri API for projects using wasm-bindgen

tauri-sys Raw bindings to the Tauri API for projects using wasm-bindgen Installation This crate is not yet published to crates.io, so you need to use

Graceful shutdown util for Rust projects using the Tokio Async runtime.

Shutdown management for graceful shutdown of tokio applications. Guard creating and usage is lock-free and the crate only locks when: the shutdown sig

Clean up the lines of files in your code repository

lineman Clean up the lines of files in your code repository NOTE: While lineman does have tests in place to ensure it operates in a specific way, I st

UnTeX is both a library and an executable that allows you to manipulate and understand TeX files.

UnTeX UnTeX is both a library and an executable that allows you to manipulate and understand TeX files. Usage Executable If you wish to use the execut

Czkawka is a simple, fast and easy to use app to remove unnecessary files from your computer.
Czkawka is a simple, fast and easy to use app to remove unnecessary files from your computer.

Multi functional app to find duplicates, empty folders, similar images etc.

Ruplacer - Find and replace text in source files

Ruplacer - Find and replace text in source files

Comments
  • Add dotnet

    Add dotnet

    Thanks for the project! Used it to clean up a bunch of old C# and JS projects. Am a bit unsure how to add the tests for dotnet tho. Hope this contribution is useful.

    opened by Azer0s 4
Owner
Kevin Bader
Master Builder.
Kevin Bader
A cargo subcommand that displays the assembly generated for Rust source code

cargo-show-asm A cargo subcommand that displays the assembly generated for Rust source code.

null 193 Dec 29, 2022
A code coverage tool for Rust projects

Tarpaulin Tarpaulin is a code coverage reporting tool for the Cargo build system, named for a waterproof cloth used to cover cargo on a ship. Currentl

null 1.8k Jan 2, 2023
Common utilities code used across Fulcrum Genomics Rust projects

fgoxide Common utilities code used across Fulcrum Genomics Rust projects. Why? There are many helper functions that are used repeatedly across project

Fulcrum Genomics 2 Nov 2, 2022
A program written in Rust, that allows the user to find the current location of the International Space Station and see it on a map.

ISS Location ViewFinder A program written in Rust, that allows the user to find the current location of the International Space Station and see it on

Suvaditya Mukherjee 2 Nov 8, 2021
A tiling window manager for Windows 10 based on binary space partitioning

yatta BSP Tiling Window Manager for Windows 10 Getting Started This project is still heavily under development and there are no prebuilt binaries avai

Jade 143 Nov 12, 2022
Free and open-source reimplementation of Native Mouse Lock (display_mouse_lock) in rust.

dml-rs display_mouse_lock in rust. Free, open-source reimplementation of display_mouse_lock (Native Mouse Lock) in Rust. Written because I felt like i

Tomat 4 Feb 12, 2023
A group of Rust projects for interacting with and producing software bill of materials (SBOMs).

sbom-rs A group of Rust projects for interacting with and producing software bill of materials (SBOMs). Examples cargo-sbom Create a SPDX SBOM for a C

Paul Sastrasinh 2 Jul 10, 2023
Rust library to scan files and expand multi-file crates source code as a single tree

syn-file-expand This library allows you to load full source code of multi-file crates into a single syn::File. Features: Based on syn crate. Handling

Vitaly Shukela 11 Jul 27, 2022
transmute-free Rust library to work with the Arrow format

Arrow2: Transmute-free Arrow This repository contains a Rust library to work with the Arrow format. It is a re-write of the official Arrow crate using

Jorge Leitao 708 Dec 30, 2022
An efficient async condition variable for lock-free algorithms

async-event An efficient async condition variable for lock-free algorithms, a.k.a. "eventcount". Overview Eventcount-like primitives are useful to mak

Asynchronics 3 Jul 10, 2023