devjanitor 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- devjanitor-0.1.0/.github/workflows/ci.yml +21 -0
- devjanitor-0.1.0/.github/workflows/publish.yml +27 -0
- devjanitor-0.1.0/.gitignore +7 -0
- devjanitor-0.1.0/LICENSE +21 -0
- devjanitor-0.1.0/PKG-INFO +143 -0
- devjanitor-0.1.0/README.md +124 -0
- devjanitor-0.1.0/demo.tape +12 -0
- devjanitor-0.1.0/pyproject.toml +36 -0
- devjanitor-0.1.0/src/devjanitor/__init__.py +3 -0
- devjanitor-0.1.0/src/devjanitor/__main__.py +3 -0
- devjanitor-0.1.0/src/devjanitor/caches.py +123 -0
- devjanitor-0.1.0/src/devjanitor/cli.py +268 -0
- devjanitor-0.1.0/src/devjanitor/scanner.py +188 -0
- devjanitor-0.1.0/src/devjanitor/targets.py +119 -0
- devjanitor-0.1.0/src/devjanitor/utils.py +93 -0
- devjanitor-0.1.0/tests/test_devjanitor.py +271 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
jobs:
|
|
4
|
+
test:
|
|
5
|
+
strategy:
|
|
6
|
+
fail-fast: false # one broken runner shouldn't cancel the others
|
|
7
|
+
matrix:
|
|
8
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
9
|
+
python: ["3.10", "3.14"]
|
|
10
|
+
include:
|
|
11
|
+
# 3.9 is what macOS ships as /usr/bin/python3; newer Ubuntu images no longer have it.
|
|
12
|
+
- os: ubuntu-24.04
|
|
13
|
+
python: "3.9"
|
|
14
|
+
runs-on: ${{ matrix.os }}
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v7
|
|
17
|
+
- uses: actions/setup-python@v7
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python }}
|
|
20
|
+
- run: pip install -e ".[dev]"
|
|
21
|
+
- run: pytest -q
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Publishes to PyPI when a tag like v0.1.0 is pushed.
|
|
2
|
+
# One-time setup: on pypi.org > Your account > Publishing, add a "pending publisher"
|
|
3
|
+
# project: devjanitor, owner: boring89, repo: devjanitor, workflow: publish.yml, environment: pypi
|
|
4
|
+
name: Publish
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
tags: ["v*"]
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment: pypi
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write # PyPI trusted publishing, no API token needed
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v7
|
|
16
|
+
- uses: actions/setup-python@v7
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
- name: Test
|
|
20
|
+
run: pip install -e ".[dev]" && pytest -q
|
|
21
|
+
- name: Check tag matches version
|
|
22
|
+
run: |
|
|
23
|
+
v=$(python -c "import devjanitor; print(devjanitor.__version__)")
|
|
24
|
+
[ "v$v" = "$GITHUB_REF_NAME" ] || { echo "tag $GITHUB_REF_NAME != version $v"; exit 1; }
|
|
25
|
+
- name: Build
|
|
26
|
+
run: pip install build && python -m build
|
|
27
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
devjanitor-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 YuanChi Hsieh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: devjanitor
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Find and delete node_modules, .venv, target/ and other dev junk to free disk space.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: cleanup,cli,developer-tools,disk-space,node_modules,venv
|
|
8
|
+
Classifier: Environment :: Console
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: System :: Filesystems
|
|
13
|
+
Classifier: Topic :: Utilities
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Requires-Dist: rich>=13
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# devjanitor 🧹
|
|
21
|
+
|
|
22
|
+
[](https://github.com/boring89/devjanitor/actions/workflows/ci.yml)
|
|
23
|
+
[](https://pypi.org/project/devjanitor/)
|
|
24
|
+
[](https://pypi.org/project/devjanitor/)
|
|
25
|
+
[](LICENSE)
|
|
26
|
+
|
|
27
|
+
**Find the projects you forgot about and delete their `node_modules`, `.venv`, `target/` and build output. Every language, one command.**
|
|
28
|
+
|
|
29
|
+
<!-- Demo GIF: run `vhs demo.tape`, commit demo.gif, then uncomment:
|
|
30
|
+

|
|
31
|
+
-->
|
|
32
|
+
|
|
33
|
+
```console
|
|
34
|
+
$ devjanitor ~/code --older-than 90
|
|
35
|
+
# ┃ Path ┃ Type ┃ Size ┃ Last activity
|
|
36
|
+
━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━
|
|
37
|
+
1 │ ml-experiments/.venv │ .venv │ 2.1 GB │ 5 months ago
|
|
38
|
+
2 │ old-hackathon/node_modules │ node_modules │ 1.2 GB │ 2 years ago
|
|
39
|
+
3 │ rust-playground/target │ target │ 890.3 MB │ 8 months ago
|
|
40
|
+
4 │ portfolio-v1/.next │ .next │ 412.7 MB │ 1 year ago
|
|
41
|
+
5 │ flutter-todo/.dart_tool │ .dart_tool │ 301.5 MB │ 7 months ago
|
|
42
|
+
…
|
|
43
|
+
|
|
44
|
+
23 directories, 9.4 GB reclaimable
|
|
45
|
+
|
|
46
|
+
Delete which? (e.g. 1,3-5 · all · enter to quit): all
|
|
47
|
+
Permanently delete 23 directories (9.4 GB)? [y/n]: y
|
|
48
|
+
|
|
49
|
+
✨ You freed 9.4 GB!
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Why
|
|
53
|
+
|
|
54
|
+
Every side project leaves hundreds of MB of dependencies and build output behind, long after you stopped working on it. devjanitor walks your code folders, finds those leftovers **in every ecosystem** (Node, Python, Rust, Java/Kotlin, Flutter, iOS, Elixir, .NET, Terraform), and shows **when each project was last touched**, so you can clear out the dead ones and leave active work alone.
|
|
55
|
+
|
|
56
|
+
- [npkill](https://github.com/voidcosmos/npkill) only handles `node_modules`.
|
|
57
|
+
- Cache cleaners only clear global caches, not the folders inside your projects.
|
|
58
|
+
- devjanitor does projects first and global caches too (`--global`: npm, pip, cargo, Gradle, Xcode DerivedData, ...).
|
|
59
|
+
|
|
60
|
+
## Install
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pipx install devjanitor # or: uv tool install devjanitor
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Or run it once without installing:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
uvx devjanitor ~/code
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Usage
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
devjanitor # scan the current directory
|
|
76
|
+
devjanitor ~/code ~/work # scan several places
|
|
77
|
+
devjanitor --global # npm/pip/cargo/gradle caches, Xcode DerivedData, ...
|
|
78
|
+
devjanitor ~/code -g # projects and global caches together
|
|
79
|
+
devjanitor ~/code -o 90 # only projects untouched for 90+ days
|
|
80
|
+
devjanitor ~/code -m 100MB # hide anything smaller than 100 MB
|
|
81
|
+
devjanitor ~/code --only node # only node_modules, .next, npm cache, ...
|
|
82
|
+
devjanitor ~/code -n # dry run: list, never delete
|
|
83
|
+
devjanitor ~/code --json # machine-readable output
|
|
84
|
+
devjanitor --list-targets # everything devjanitor recognises
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## What it cleans
|
|
88
|
+
|
|
89
|
+
### Project folders
|
|
90
|
+
|
|
91
|
+
| Ecosystem | Directories |
|
|
92
|
+
|---|---|
|
|
93
|
+
| Node | `node_modules`, `.next`, `.nuxt`, `.svelte-kit`, `.turbo`, `.parcel-cache`, `.angular` |
|
|
94
|
+
| Python | `.venv`, `venv`, `__pycache__`, `.pytest_cache`, `.mypy_cache`, `.ruff_cache`, `.tox`, `.nox` |
|
|
95
|
+
| Rust | `target` |
|
|
96
|
+
| JVM | `build`, `.gradle` (Gradle), `target` (Maven) |
|
|
97
|
+
| Flutter / Dart | `.dart_tool` |
|
|
98
|
+
| iOS | `Pods` |
|
|
99
|
+
| Elixir | `_build`, `deps` |
|
|
100
|
+
| .NET | `obj` |
|
|
101
|
+
| Terraform | `.terraform` |
|
|
102
|
+
|
|
103
|
+
### Global caches (`--global`)
|
|
104
|
+
|
|
105
|
+
| Ecosystem | Caches |
|
|
106
|
+
|---|---|
|
|
107
|
+
| Node | npm, Yarn, pnpm store, Bun, Deno, Playwright browsers, Electron |
|
|
108
|
+
| Python | pip, uv, Poetry |
|
|
109
|
+
| Rust | cargo registry, cargo git checkouts |
|
|
110
|
+
| Go | build cache |
|
|
111
|
+
| JVM | Gradle caches, Maven `~/.m2/repository` |
|
|
112
|
+
| Apple | Xcode DerivedData, iOS DeviceSupport, CocoaPods, Homebrew |
|
|
113
|
+
| Dart / Flutter | pub cache |
|
|
114
|
+
| PHP | Composer |
|
|
115
|
+
|
|
116
|
+
Locations follow each tool's defaults on macOS, Linux (`$XDG_CACHE_HOME`) and Windows (`%LOCALAPPDATA%`).
|
|
117
|
+
|
|
118
|
+
## Safety first
|
|
119
|
+
|
|
120
|
+
Deleting folders is serious, so devjanitor is careful:
|
|
121
|
+
|
|
122
|
+
- **Marker checks.** A folder named `target` is only offered if a `Cargo.toml` or `pom.xml` sits next to it. `.venv` must contain `pyvenv.cfg`. `build` needs a Gradle file. A random folder that happens to share a name is never touched.
|
|
123
|
+
- **Never follows symlinks**, and skips `.git`, `~/Library` and system folders when scanning projects.
|
|
124
|
+
- **Nothing is deleted without your choice and a final `y/N` confirmation** (unless you pass `--yes`).
|
|
125
|
+
- **"Last activity" ignores the junk folder itself**, so a fresh `npm install` won't make a 2-year-old project look recent.
|
|
126
|
+
|
|
127
|
+
Everything devjanitor removes is rebuilt or re-downloaded on demand by `npm install`, `pip install`, `cargo build` and friends.
|
|
128
|
+
|
|
129
|
+
## Contributing
|
|
130
|
+
|
|
131
|
+
Missing an ecosystem? Adding one is a single line in [`src/devjanitor/targets.py`](src/devjanitor/targets.py) (project folders) or [`src/devjanitor/caches.py`](src/devjanitor/caches.py) (global caches). PRs welcome!
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
git clone https://github.com/boring89/devjanitor && cd devjanitor
|
|
135
|
+
python -m venv .venv && .venv/bin/pip install -e ".[dev]"
|
|
136
|
+
.venv/bin/pytest
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
If devjanitor freed some space for you, a ⭐ would make my day!
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# devjanitor 🧹
|
|
2
|
+
|
|
3
|
+
[](https://github.com/boring89/devjanitor/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/devjanitor/)
|
|
5
|
+
[](https://pypi.org/project/devjanitor/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
**Find the projects you forgot about and delete their `node_modules`, `.venv`, `target/` and build output. Every language, one command.**
|
|
9
|
+
|
|
10
|
+
<!-- Demo GIF: run `vhs demo.tape`, commit demo.gif, then uncomment:
|
|
11
|
+

|
|
12
|
+
-->
|
|
13
|
+
|
|
14
|
+
```console
|
|
15
|
+
$ devjanitor ~/code --older-than 90
|
|
16
|
+
# ┃ Path ┃ Type ┃ Size ┃ Last activity
|
|
17
|
+
━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━
|
|
18
|
+
1 │ ml-experiments/.venv │ .venv │ 2.1 GB │ 5 months ago
|
|
19
|
+
2 │ old-hackathon/node_modules │ node_modules │ 1.2 GB │ 2 years ago
|
|
20
|
+
3 │ rust-playground/target │ target │ 890.3 MB │ 8 months ago
|
|
21
|
+
4 │ portfolio-v1/.next │ .next │ 412.7 MB │ 1 year ago
|
|
22
|
+
5 │ flutter-todo/.dart_tool │ .dart_tool │ 301.5 MB │ 7 months ago
|
|
23
|
+
…
|
|
24
|
+
|
|
25
|
+
23 directories, 9.4 GB reclaimable
|
|
26
|
+
|
|
27
|
+
Delete which? (e.g. 1,3-5 · all · enter to quit): all
|
|
28
|
+
Permanently delete 23 directories (9.4 GB)? [y/n]: y
|
|
29
|
+
|
|
30
|
+
✨ You freed 9.4 GB!
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Why
|
|
34
|
+
|
|
35
|
+
Every side project leaves hundreds of MB of dependencies and build output behind, long after you stopped working on it. devjanitor walks your code folders, finds those leftovers **in every ecosystem** (Node, Python, Rust, Java/Kotlin, Flutter, iOS, Elixir, .NET, Terraform), and shows **when each project was last touched**, so you can clear out the dead ones and leave active work alone.
|
|
36
|
+
|
|
37
|
+
- [npkill](https://github.com/voidcosmos/npkill) only handles `node_modules`.
|
|
38
|
+
- Cache cleaners only clear global caches, not the folders inside your projects.
|
|
39
|
+
- devjanitor does projects first and global caches too (`--global`: npm, pip, cargo, Gradle, Xcode DerivedData, ...).
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pipx install devjanitor # or: uv tool install devjanitor
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or run it once without installing:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
uvx devjanitor ~/code
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
devjanitor # scan the current directory
|
|
57
|
+
devjanitor ~/code ~/work # scan several places
|
|
58
|
+
devjanitor --global # npm/pip/cargo/gradle caches, Xcode DerivedData, ...
|
|
59
|
+
devjanitor ~/code -g # projects and global caches together
|
|
60
|
+
devjanitor ~/code -o 90 # only projects untouched for 90+ days
|
|
61
|
+
devjanitor ~/code -m 100MB # hide anything smaller than 100 MB
|
|
62
|
+
devjanitor ~/code --only node # only node_modules, .next, npm cache, ...
|
|
63
|
+
devjanitor ~/code -n # dry run: list, never delete
|
|
64
|
+
devjanitor ~/code --json # machine-readable output
|
|
65
|
+
devjanitor --list-targets # everything devjanitor recognises
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## What it cleans
|
|
69
|
+
|
|
70
|
+
### Project folders
|
|
71
|
+
|
|
72
|
+
| Ecosystem | Directories |
|
|
73
|
+
|---|---|
|
|
74
|
+
| Node | `node_modules`, `.next`, `.nuxt`, `.svelte-kit`, `.turbo`, `.parcel-cache`, `.angular` |
|
|
75
|
+
| Python | `.venv`, `venv`, `__pycache__`, `.pytest_cache`, `.mypy_cache`, `.ruff_cache`, `.tox`, `.nox` |
|
|
76
|
+
| Rust | `target` |
|
|
77
|
+
| JVM | `build`, `.gradle` (Gradle), `target` (Maven) |
|
|
78
|
+
| Flutter / Dart | `.dart_tool` |
|
|
79
|
+
| iOS | `Pods` |
|
|
80
|
+
| Elixir | `_build`, `deps` |
|
|
81
|
+
| .NET | `obj` |
|
|
82
|
+
| Terraform | `.terraform` |
|
|
83
|
+
|
|
84
|
+
### Global caches (`--global`)
|
|
85
|
+
|
|
86
|
+
| Ecosystem | Caches |
|
|
87
|
+
|---|---|
|
|
88
|
+
| Node | npm, Yarn, pnpm store, Bun, Deno, Playwright browsers, Electron |
|
|
89
|
+
| Python | pip, uv, Poetry |
|
|
90
|
+
| Rust | cargo registry, cargo git checkouts |
|
|
91
|
+
| Go | build cache |
|
|
92
|
+
| JVM | Gradle caches, Maven `~/.m2/repository` |
|
|
93
|
+
| Apple | Xcode DerivedData, iOS DeviceSupport, CocoaPods, Homebrew |
|
|
94
|
+
| Dart / Flutter | pub cache |
|
|
95
|
+
| PHP | Composer |
|
|
96
|
+
|
|
97
|
+
Locations follow each tool's defaults on macOS, Linux (`$XDG_CACHE_HOME`) and Windows (`%LOCALAPPDATA%`).
|
|
98
|
+
|
|
99
|
+
## Safety first
|
|
100
|
+
|
|
101
|
+
Deleting folders is serious, so devjanitor is careful:
|
|
102
|
+
|
|
103
|
+
- **Marker checks.** A folder named `target` is only offered if a `Cargo.toml` or `pom.xml` sits next to it. `.venv` must contain `pyvenv.cfg`. `build` needs a Gradle file. A random folder that happens to share a name is never touched.
|
|
104
|
+
- **Never follows symlinks**, and skips `.git`, `~/Library` and system folders when scanning projects.
|
|
105
|
+
- **Nothing is deleted without your choice and a final `y/N` confirmation** (unless you pass `--yes`).
|
|
106
|
+
- **"Last activity" ignores the junk folder itself**, so a fresh `npm install` won't make a 2-year-old project look recent.
|
|
107
|
+
|
|
108
|
+
Everything devjanitor removes is rebuilt or re-downloaded on demand by `npm install`, `pip install`, `cargo build` and friends.
|
|
109
|
+
|
|
110
|
+
## Contributing
|
|
111
|
+
|
|
112
|
+
Missing an ecosystem? Adding one is a single line in [`src/devjanitor/targets.py`](src/devjanitor/targets.py) (project folders) or [`src/devjanitor/caches.py`](src/devjanitor/caches.py) (global caches). PRs welcome!
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
git clone https://github.com/boring89/devjanitor && cd devjanitor
|
|
116
|
+
python -m venv .venv && .venv/bin/pip install -e ".[dev]"
|
|
117
|
+
.venv/bin/pytest
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
If devjanitor freed some space for you, a ⭐ would make my day!
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Record the README GIF with https://github.com/charmbracelet/vhs : vhs demo.tape
|
|
2
|
+
Output demo.gif
|
|
3
|
+
Set FontSize 16
|
|
4
|
+
Set Width 1100
|
|
5
|
+
Set Height 600
|
|
6
|
+
Set Theme "Catppuccin Mocha"
|
|
7
|
+
Type "devjanitor ~/code" Sleep 500ms Enter
|
|
8
|
+
Sleep 4s
|
|
9
|
+
Type "all" Sleep 500ms Enter
|
|
10
|
+
Sleep 1s
|
|
11
|
+
Type "y" Sleep 300ms Enter
|
|
12
|
+
Sleep 4s
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "devjanitor"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Find and delete node_modules, .venv, target/ and other dev junk to free disk space."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
dependencies = ["rich>=13"]
|
|
13
|
+
keywords = ["cli", "disk-space", "cleanup", "node_modules", "venv", "developer-tools"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Topic :: System :: Filesystems",
|
|
20
|
+
"Topic :: Utilities",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
dev = ["pytest>=7"]
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
devjanitor = "devjanitor.cli:run"
|
|
28
|
+
|
|
29
|
+
[tool.hatch.build.targets.wheel]
|
|
30
|
+
packages = ["src/devjanitor"]
|
|
31
|
+
|
|
32
|
+
[tool.pytest.ini_options]
|
|
33
|
+
testpaths = ["tests"]
|
|
34
|
+
|
|
35
|
+
[tool.hatch.version]
|
|
36
|
+
path = "src/devjanitor/__init__.py"
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""Global (per-user) caches that package managers and toolchains keep.
|
|
2
|
+
|
|
3
|
+
Unlike project folders these live at fixed locations, so there is no marker
|
|
4
|
+
check: a location is offered only if it exists. Every entry here is safe to
|
|
5
|
+
delete because the owning tool re-downloads or rebuilds it on demand.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Callable, List, Tuple
|
|
14
|
+
|
|
15
|
+
from .targets import Target, _always
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass(frozen=True)
|
|
19
|
+
class Cache:
|
|
20
|
+
name: str
|
|
21
|
+
ecosystem: str
|
|
22
|
+
description: str
|
|
23
|
+
# Called at scan time (not import time) so HOME and env vars are current.
|
|
24
|
+
locations: Callable[[], List[Path]]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _home(*parts: str) -> Path:
|
|
28
|
+
return Path.home().joinpath(*parts)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _xdg_cache(*parts: str) -> Path:
|
|
32
|
+
base = os.environ.get("XDG_CACHE_HOME") or str(_home(".cache"))
|
|
33
|
+
return Path(base).joinpath(*parts)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _mac_cache(*parts: str) -> Path:
|
|
37
|
+
return _home("Library", "Caches", *parts)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _win_local(*parts: str) -> List[Path]:
|
|
41
|
+
base = os.environ.get("LOCALAPPDATA")
|
|
42
|
+
return [Path(base).joinpath(*parts)] if base else []
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _cache_dirs(*parts: str) -> Callable[[], List[Path]]:
|
|
46
|
+
"""The usual cache folder for a tool on macOS, Linux and Windows."""
|
|
47
|
+
return lambda: [_mac_cache(*parts), _xdg_cache(*parts), *_win_local(*parts)]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _paths(*parts_list: Tuple[str, ...]) -> Callable[[], List[Path]]:
|
|
51
|
+
return lambda: [_home(*parts) for parts in parts_list]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
CACHES: List[Cache] = [
|
|
55
|
+
# JavaScript
|
|
56
|
+
Cache("npm cache", "node", "npm download cache", _paths((".npm", "_cacache"))),
|
|
57
|
+
Cache("yarn cache", "node", "Yarn download cache",
|
|
58
|
+
lambda: [_mac_cache("Yarn"), _xdg_cache("yarn"), *_win_local("Yarn", "Cache")]),
|
|
59
|
+
Cache("pnpm store", "node", "pnpm content-addressable store",
|
|
60
|
+
lambda: [_home("Library", "pnpm", "store"),
|
|
61
|
+
_home(".local", "share", "pnpm", "store"),
|
|
62
|
+
*_win_local("pnpm", "store")]),
|
|
63
|
+
Cache("bun cache", "node", "Bun install cache", _paths((".bun", "install", "cache"))),
|
|
64
|
+
Cache("deno cache", "node", "Deno module cache", _cache_dirs("deno")),
|
|
65
|
+
Cache("playwright", "node", "Playwright browser downloads",
|
|
66
|
+
lambda: [_mac_cache("ms-playwright"), _xdg_cache("ms-playwright"),
|
|
67
|
+
*_win_local("ms-playwright")]),
|
|
68
|
+
Cache("electron", "node", "Electron binary downloads", _cache_dirs("electron")),
|
|
69
|
+
# Python
|
|
70
|
+
Cache("pip cache", "python", "pip download and wheel cache",
|
|
71
|
+
lambda: [_mac_cache("pip"), _xdg_cache("pip"), *_win_local("pip", "Cache")]),
|
|
72
|
+
Cache("uv cache", "python", "uv package cache",
|
|
73
|
+
lambda: [_xdg_cache("uv"), *_win_local("uv", "cache")]),
|
|
74
|
+
Cache("poetry cache", "python", "Poetry package cache", _cache_dirs("pypoetry")),
|
|
75
|
+
# Rust
|
|
76
|
+
Cache("cargo registry", "rust", "downloaded crate archives and sources",
|
|
77
|
+
_paths((".cargo", "registry", "cache"), (".cargo", "registry", "src"))),
|
|
78
|
+
Cache("cargo git", "rust", "git dependency checkouts",
|
|
79
|
+
_paths((".cargo", "git", "checkouts"))),
|
|
80
|
+
# Go
|
|
81
|
+
Cache("go build cache", "go", "compiled package cache",
|
|
82
|
+
lambda: [_mac_cache("go-build"), _xdg_cache("go-build"),
|
|
83
|
+
*_win_local("go-build")]),
|
|
84
|
+
# JVM
|
|
85
|
+
Cache("gradle caches", "jvm", "Gradle dependency and build cache",
|
|
86
|
+
_paths((".gradle", "caches"))),
|
|
87
|
+
Cache("maven repo", "jvm", "Maven local repository", _paths((".m2", "repository"))),
|
|
88
|
+
# Apple
|
|
89
|
+
Cache("xcode derived data", "ios", "Xcode build products and indexes",
|
|
90
|
+
_paths(("Library", "Developer", "Xcode", "DerivedData"))),
|
|
91
|
+
Cache("ios device support", "ios", "debug symbols, re-copied when a device connects",
|
|
92
|
+
_paths(("Library", "Developer", "Xcode", "iOS DeviceSupport"))),
|
|
93
|
+
Cache("cocoapods cache", "ios", "CocoaPods download cache", _cache_dirs("CocoaPods")),
|
|
94
|
+
Cache("homebrew cache", "system", "downloaded bottles and source archives",
|
|
95
|
+
_cache_dirs("Homebrew")),
|
|
96
|
+
# Dart / Flutter
|
|
97
|
+
Cache("pub cache", "dart", "Dart/Flutter package cache (run pub get afterwards)",
|
|
98
|
+
lambda: [_home(".pub-cache"), *_win_local("Pub", "Cache")]),
|
|
99
|
+
# PHP
|
|
100
|
+
Cache("composer cache", "php", "Composer download cache",
|
|
101
|
+
lambda: [_home(".composer", "cache"), _xdg_cache("composer"),
|
|
102
|
+
*_win_local("Composer")]),
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def find_caches(ecosystems=None):
|
|
107
|
+
"""Yield ``(path, Target)`` for every cache location that exists."""
|
|
108
|
+
seen = set()
|
|
109
|
+
for cache in CACHES:
|
|
110
|
+
if ecosystems and cache.ecosystem not in ecosystems:
|
|
111
|
+
continue
|
|
112
|
+
target = Target(cache.name, cache.ecosystem, cache.description, _always)
|
|
113
|
+
for path in cache.locations():
|
|
114
|
+
try:
|
|
115
|
+
if path.is_symlink() or not path.is_dir():
|
|
116
|
+
continue
|
|
117
|
+
key = path.resolve()
|
|
118
|
+
except OSError:
|
|
119
|
+
continue
|
|
120
|
+
if key in seen:
|
|
121
|
+
continue
|
|
122
|
+
seen.add(key)
|
|
123
|
+
yield path, target
|