makeclean
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
.gitignorefiles even outside Git repositories. Build tools often create a.gitignorefile 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
.ignorefiles, which have the same semantics as.gitignorefiles and are supported by search tools such as ripgrep and The Silver Searcher. - Ignores hidden directories.
Currently supports the following build tools:
- Cargo
- Elm
- Flutter
- Gradle (Assumes
$buildDiris set to the default value$projectDir/build! Seegradle.rs) - Mix
- NPM
Table of contents:
Installation
Install using Cargo:
Current release: 1.3.0
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:
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:
Set --min-stale to zero to disable the check:
You can also filter by build tool using --type/-t:
Clean projects
By default, makeclean looks for any projects that haven't been touched for a month, and offers to clean them:
Use --dry-run/-n to see what would happen, without actually deleting anything:
If you run makeclean in a script and don't want the prompt, you can pass --yes to proceed automatically:
You can also specify multiple directories at once. For example, to regularly clean up some scratch directories, you could add something like this to crontab or a startup script:
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:
Note that while
--archivealso 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 variableRUST_LOGset totrace, 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):
&&
Hack it
PRs welcome! Check out the documentation on crates.io to get started. Feel free to create a GitHub issue if you have any questions.
Checklist for adding a new build tool
- Add applicable project types to the
BuildToolKindenum insrc/build_tools.rs. - Add the new module to
src/build_tools.rs, creating a file belowsrc/build_tools/. - Add
registercall toBuildToolManager::defaultinsrc/build_tool_manager.rs. - Add module and init function to
tests/util/and to thetoolsarray attests/tests/build_tools.rs.
License
MIT. Any contributions are assumed MIT-licensed as well.