devsweep-cli 0.2.0__tar.gz → 0.3.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.
- {devsweep_cli-0.2.0/devsweep_cli.egg-info → devsweep_cli-0.3.0}/PKG-INFO +14 -7
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/README.md +13 -6
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep/__init__.py +1 -1
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep/cli.py +41 -1
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep/scanner.py +85 -13
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0/devsweep_cli.egg-info}/PKG-INFO +14 -7
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/pyproject.toml +1 -1
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/tests/test_cli.py +38 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/tests/test_scanner.py +38 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/LICENSE +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep/__main__.py +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep/cleaner.py +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep/display.py +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep/docker.py +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep/ignore.py +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep/models.py +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep/utils.py +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep_cli.egg-info/SOURCES.txt +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep_cli.egg-info/dependency_links.txt +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep_cli.egg-info/entry_points.txt +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep_cli.egg-info/requires.txt +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/devsweep_cli.egg-info/top_level.txt +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/setup.cfg +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/tests/test_cleaner.py +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/tests/test_display.py +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/tests/test_docker.py +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/tests/test_edge_cases.py +0 -0
- {devsweep_cli-0.2.0 → devsweep_cli-0.3.0}/tests/test_ignore.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: devsweep-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: CLI tool to scan and safely clean developer build artifacts, dependencies, caches, and unused Docker resources.
|
|
5
5
|
Author-email: Vũ Lộc <vuloc668165@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -37,9 +37,9 @@ Dynamic: license-file
|
|
|
37
37
|
# 🧹 DevSweep
|
|
38
38
|
|
|
39
39
|
[](https://github.com/vuloc080611/DevSweep/actions/workflows/ci.yml)
|
|
40
|
-
[](https://pypi.org/project/devsweep-cli/)
|
|
41
41
|
[](https://www.python.org/)
|
|
42
|
-
[](LICENSE)
|
|
42
|
+
[](https://github.com/vuloc080611/DevSweep/blob/main/LICENSE)
|
|
43
43
|
[](https://typer.tiangolo.com/)
|
|
44
44
|
|
|
45
45
|
**DevSweep** is a fast, safe, cross-platform Python CLI that scans your workspaces and reclaims gigabytes of disk space from forgotten build artifacts, dependency folders (`node_modules`, `.venv`, `target`, `.next`, `__pycache__`, …), and unused Docker resources — with built-in dry-run previews, interactive selection, `.devsweepignore` rules, and strict safety guardrails.
|
|
@@ -49,7 +49,7 @@ Dynamic: license-file
|
|
|
49
49
|
## Demo
|
|
50
50
|
|
|
51
51
|
<p align="center">
|
|
52
|
-
<img src="assets/demo.gif" alt="DevSweep CLI Demo" width="760" />
|
|
52
|
+
<img src="https://raw.githubusercontent.com/vuloc080611/DevSweep/main/assets/demo.gif" alt="DevSweep CLI Demo" width="760" />
|
|
53
53
|
</p>
|
|
54
54
|
|
|
55
55
|
---
|
|
@@ -74,7 +74,7 @@ Dynamic: license-file
|
|
|
74
74
|
- **Python 3.10+**
|
|
75
75
|
- Optional: **Docker CLI** (only required for `devsweep docker ...` commands)
|
|
76
76
|
|
|
77
|
-
### Install from PyPI
|
|
77
|
+
### Install from PyPI (Recommended)
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
80
|
pip install devsweep-cli
|
|
@@ -134,6 +134,9 @@ devsweep scan ./projects --dry-run --no-color
|
|
|
134
134
|
|
|
135
135
|
# Machine-readable JSON output for jq, CI pipelines, or dashboards
|
|
136
136
|
devsweep scan ./projects --json | jq '.total_reclaimable_bytes'
|
|
137
|
+
|
|
138
|
+
# Filter by specific artifact types (repeatable or comma-separated)
|
|
139
|
+
devsweep scan ./projects --type node_modules --type pycache
|
|
137
140
|
```
|
|
138
141
|
|
|
139
142
|
### Cleaning Folders Safely
|
|
@@ -150,6 +153,9 @@ devsweep clean ./web ./api --exclude legacy --interactive
|
|
|
150
153
|
|
|
151
154
|
# Non-interactive cleanup (skips confirmation prompt)
|
|
152
155
|
devsweep clean ./projects --yes
|
|
156
|
+
|
|
157
|
+
# Clean only specific artifact categories
|
|
158
|
+
devsweep clean ./projects --type node_modules --type __pycache__ --yes
|
|
153
159
|
```
|
|
154
160
|
|
|
155
161
|
### Cleaning Unused Docker Resources
|
|
@@ -201,6 +207,7 @@ devsweep docker clean --yes
|
|
|
201
207
|
| :--- | :---: | :--- | :--- |
|
|
202
208
|
| `--max-depth INT` | `-d` | `scan`, `clean` | Maximum directory depth to descend (`0` scans nothing inside root) |
|
|
203
209
|
| `--exclude PATTERN` | `-e` | `scan`, `clean` | Exclude matching folder name or relative glob pattern (repeatable) |
|
|
210
|
+
| `--type CATEGORY` | `-t` | `scan`, `clean` | Filter by artifact category, e.g. `node_modules`, `pycache`, `venv` (repeatable or comma-separated) |
|
|
204
211
|
| `--ignore-file PATH` | | `scan`, `clean` | Use a custom ignore file instead of auto-discovered `.devsweepignore` |
|
|
205
212
|
| `--dry-run` | `-n` | `scan`, `clean`, `docker` | Show what would be targeted without deleting anything |
|
|
206
213
|
| `--json` | | `scan`, `docker scan` | Emit pure machine-readable JSON (suppresses spinners and banners) |
|
|
@@ -240,10 +247,10 @@ packages/**/legacy
|
|
|
240
247
|
|
|
241
248
|
## Contributing
|
|
242
249
|
|
|
243
|
-
Contributions, bug reports, and feature ideas are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, test commands, and commit guidelines, and [SECURITY.md](SECURITY.md) for reporting safety or security issues.
|
|
250
|
+
Contributions, bug reports, and feature ideas are welcome! Please read [CONTRIBUTING.md](https://github.com/vuloc080611/DevSweep/blob/main/CONTRIBUTING.md) for development setup, test commands, and commit guidelines, and [SECURITY.md](https://github.com/vuloc080611/DevSweep/blob/main/SECURITY.md) for reporting safety or security issues.
|
|
244
251
|
|
|
245
252
|
---
|
|
246
253
|
|
|
247
254
|
## License
|
|
248
255
|
|
|
249
|
-
Released under the [MIT License](LICENSE).
|
|
256
|
+
Released under the [MIT License](https://github.com/vuloc080611/DevSweep/blob/main/LICENSE).
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# 🧹 DevSweep
|
|
2
2
|
|
|
3
3
|
[](https://github.com/vuloc080611/DevSweep/actions/workflows/ci.yml)
|
|
4
|
-
[](https://pypi.org/project/devsweep-cli/)
|
|
5
5
|
[](https://www.python.org/)
|
|
6
|
-
[](LICENSE)
|
|
6
|
+
[](https://github.com/vuloc080611/DevSweep/blob/main/LICENSE)
|
|
7
7
|
[](https://typer.tiangolo.com/)
|
|
8
8
|
|
|
9
9
|
**DevSweep** is a fast, safe, cross-platform Python CLI that scans your workspaces and reclaims gigabytes of disk space from forgotten build artifacts, dependency folders (`node_modules`, `.venv`, `target`, `.next`, `__pycache__`, …), and unused Docker resources — with built-in dry-run previews, interactive selection, `.devsweepignore` rules, and strict safety guardrails.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
## Demo
|
|
14
14
|
|
|
15
15
|
<p align="center">
|
|
16
|
-
<img src="assets/demo.gif" alt="DevSweep CLI Demo" width="760" />
|
|
16
|
+
<img src="https://raw.githubusercontent.com/vuloc080611/DevSweep/main/assets/demo.gif" alt="DevSweep CLI Demo" width="760" />
|
|
17
17
|
</p>
|
|
18
18
|
|
|
19
19
|
---
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
- **Python 3.10+**
|
|
39
39
|
- Optional: **Docker CLI** (only required for `devsweep docker ...` commands)
|
|
40
40
|
|
|
41
|
-
### Install from PyPI
|
|
41
|
+
### Install from PyPI (Recommended)
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
44
|
pip install devsweep-cli
|
|
@@ -98,6 +98,9 @@ devsweep scan ./projects --dry-run --no-color
|
|
|
98
98
|
|
|
99
99
|
# Machine-readable JSON output for jq, CI pipelines, or dashboards
|
|
100
100
|
devsweep scan ./projects --json | jq '.total_reclaimable_bytes'
|
|
101
|
+
|
|
102
|
+
# Filter by specific artifact types (repeatable or comma-separated)
|
|
103
|
+
devsweep scan ./projects --type node_modules --type pycache
|
|
101
104
|
```
|
|
102
105
|
|
|
103
106
|
### Cleaning Folders Safely
|
|
@@ -114,6 +117,9 @@ devsweep clean ./web ./api --exclude legacy --interactive
|
|
|
114
117
|
|
|
115
118
|
# Non-interactive cleanup (skips confirmation prompt)
|
|
116
119
|
devsweep clean ./projects --yes
|
|
120
|
+
|
|
121
|
+
# Clean only specific artifact categories
|
|
122
|
+
devsweep clean ./projects --type node_modules --type __pycache__ --yes
|
|
117
123
|
```
|
|
118
124
|
|
|
119
125
|
### Cleaning Unused Docker Resources
|
|
@@ -165,6 +171,7 @@ devsweep docker clean --yes
|
|
|
165
171
|
| :--- | :---: | :--- | :--- |
|
|
166
172
|
| `--max-depth INT` | `-d` | `scan`, `clean` | Maximum directory depth to descend (`0` scans nothing inside root) |
|
|
167
173
|
| `--exclude PATTERN` | `-e` | `scan`, `clean` | Exclude matching folder name or relative glob pattern (repeatable) |
|
|
174
|
+
| `--type CATEGORY` | `-t` | `scan`, `clean` | Filter by artifact category, e.g. `node_modules`, `pycache`, `venv` (repeatable or comma-separated) |
|
|
168
175
|
| `--ignore-file PATH` | | `scan`, `clean` | Use a custom ignore file instead of auto-discovered `.devsweepignore` |
|
|
169
176
|
| `--dry-run` | `-n` | `scan`, `clean`, `docker` | Show what would be targeted without deleting anything |
|
|
170
177
|
| `--json` | | `scan`, `docker scan` | Emit pure machine-readable JSON (suppresses spinners and banners) |
|
|
@@ -204,10 +211,10 @@ packages/**/legacy
|
|
|
204
211
|
|
|
205
212
|
## Contributing
|
|
206
213
|
|
|
207
|
-
Contributions, bug reports, and feature ideas are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, test commands, and commit guidelines, and [SECURITY.md](SECURITY.md) for reporting safety or security issues.
|
|
214
|
+
Contributions, bug reports, and feature ideas are welcome! Please read [CONTRIBUTING.md](https://github.com/vuloc080611/DevSweep/blob/main/CONTRIBUTING.md) for development setup, test commands, and commit guidelines, and [SECURITY.md](https://github.com/vuloc080611/DevSweep/blob/main/SECURITY.md) for reporting safety or security issues.
|
|
208
215
|
|
|
209
216
|
---
|
|
210
217
|
|
|
211
218
|
## License
|
|
212
219
|
|
|
213
|
-
Released under the [MIT License](LICENSE).
|
|
220
|
+
Released under the [MIT License](https://github.com/vuloc080611/DevSweep/blob/main/LICENSE).
|
|
@@ -41,7 +41,7 @@ from devsweep.docker import (
|
|
|
41
41
|
scan_docker_resources,
|
|
42
42
|
)
|
|
43
43
|
from devsweep.models import ScanResult
|
|
44
|
-
from devsweep.scanner import expand_scan_roots, scan_paths
|
|
44
|
+
from devsweep.scanner import expand_scan_roots, parse_folder_types, scan_paths
|
|
45
45
|
from devsweep.utils import resolve_user_path
|
|
46
46
|
|
|
47
47
|
app = typer.Typer(
|
|
@@ -99,12 +99,23 @@ def _run_scan(
|
|
|
99
99
|
ignore_file: Path | None,
|
|
100
100
|
console: Console,
|
|
101
101
|
*,
|
|
102
|
+
folder_types: list[str] | None = None,
|
|
102
103
|
quiet: bool = False,
|
|
103
104
|
) -> tuple[list[Path], Path | None, list[ScanResult]]:
|
|
104
105
|
"""Validate target directories, handle smart home scan, and return discovered items."""
|
|
105
106
|
raw_paths = paths if paths else [Path(".")]
|
|
106
107
|
home_norm = os.path.normcase(str(Path.home().expanduser().resolve()))
|
|
107
108
|
|
|
109
|
+
try:
|
|
110
|
+
parsed_types = parse_folder_types(folder_types)
|
|
111
|
+
except ValueError as exc:
|
|
112
|
+
show_error(
|
|
113
|
+
str(exc),
|
|
114
|
+
console=console,
|
|
115
|
+
hint="Use repeatable --type values such as: --type node_modules --type pycache.",
|
|
116
|
+
)
|
|
117
|
+
raise typer.Exit(code=1) from exc
|
|
118
|
+
|
|
108
119
|
if ignore_file is not None:
|
|
109
120
|
resolved_ignore = ignore_file.expanduser()
|
|
110
121
|
if not resolved_ignore.exists():
|
|
@@ -142,6 +153,7 @@ def _run_scan(
|
|
|
142
153
|
exclude_patterns=exclude or (),
|
|
143
154
|
ignore_file=ignore_file,
|
|
144
155
|
smart_home=True,
|
|
156
|
+
folder_types=parsed_types,
|
|
145
157
|
)
|
|
146
158
|
else:
|
|
147
159
|
if requested_home:
|
|
@@ -156,6 +168,7 @@ def _run_scan(
|
|
|
156
168
|
ignore_file=ignore_file,
|
|
157
169
|
smart_home=True,
|
|
158
170
|
on_root_progress=on_root_progress,
|
|
171
|
+
folder_types=parsed_types,
|
|
159
172
|
)
|
|
160
173
|
else:
|
|
161
174
|
label = expanded_roots[0].name or str(expanded_roots[0])
|
|
@@ -166,6 +179,7 @@ def _run_scan(
|
|
|
166
179
|
exclude_patterns=exclude or (),
|
|
167
180
|
ignore_file=ignore_file,
|
|
168
181
|
smart_home=True,
|
|
182
|
+
folder_types=parsed_types,
|
|
169
183
|
)
|
|
170
184
|
|
|
171
185
|
single_base = expanded_roots[0] if len(expanded_roots) == 1 else None
|
|
@@ -217,6 +231,7 @@ def version(
|
|
|
217
231
|
" devsweep scan .\n\n"
|
|
218
232
|
" devsweep scan ./web ./api --max-depth 2\n\n"
|
|
219
233
|
" devsweep scan ~ --exclude '*backup*' --dry-run\n\n"
|
|
234
|
+
" devsweep scan ./workspace --type node_modules --type pycache\n\n"
|
|
220
235
|
" devsweep scan ./workspace --json\n\n"
|
|
221
236
|
" devsweep scan ./workspace --no-color"
|
|
222
237
|
)
|
|
@@ -244,6 +259,17 @@ def scan(
|
|
|
244
259
|
help="Directory name or glob pattern to exclude (can be repeated).",
|
|
245
260
|
),
|
|
246
261
|
] = None,
|
|
262
|
+
folder_types: Annotated[
|
|
263
|
+
list[str] | None,
|
|
264
|
+
typer.Option(
|
|
265
|
+
"--type",
|
|
266
|
+
"-t",
|
|
267
|
+
help=(
|
|
268
|
+
"Only include specific artifact types (repeatable or comma-separated, "
|
|
269
|
+
"e.g. --type node_modules --type pycache)."
|
|
270
|
+
),
|
|
271
|
+
),
|
|
272
|
+
] = None,
|
|
247
273
|
ignore_file: Annotated[
|
|
248
274
|
Path | None,
|
|
249
275
|
typer.Option(
|
|
@@ -282,6 +308,7 @@ def scan(
|
|
|
282
308
|
exclude=exclude,
|
|
283
309
|
ignore_file=ignore_file,
|
|
284
310
|
console=active_console,
|
|
311
|
+
folder_types=folder_types,
|
|
285
312
|
quiet=json_output,
|
|
286
313
|
)
|
|
287
314
|
if json_output:
|
|
@@ -301,6 +328,7 @@ def scan(
|
|
|
301
328
|
"Examples:\n\n"
|
|
302
329
|
" devsweep clean . --dry-run\n\n"
|
|
303
330
|
" devsweep clean ./web ./api --max-depth 2 --interactive\n\n"
|
|
331
|
+
" devsweep clean ./workspace --type node_modules --type pycache --yes\n\n"
|
|
304
332
|
" devsweep clean ./projects --exclude vendor --yes"
|
|
305
333
|
)
|
|
306
334
|
)
|
|
@@ -327,6 +355,17 @@ def clean(
|
|
|
327
355
|
help="Directory name or glob pattern to exclude (can be repeated).",
|
|
328
356
|
),
|
|
329
357
|
] = None,
|
|
358
|
+
folder_types: Annotated[
|
|
359
|
+
list[str] | None,
|
|
360
|
+
typer.Option(
|
|
361
|
+
"--type",
|
|
362
|
+
"-t",
|
|
363
|
+
help=(
|
|
364
|
+
"Only clean specific artifact types (repeatable or comma-separated, "
|
|
365
|
+
"e.g. --type node_modules --type pycache)."
|
|
366
|
+
),
|
|
367
|
+
),
|
|
368
|
+
] = None,
|
|
330
369
|
ignore_file: Annotated[
|
|
331
370
|
Path | None,
|
|
332
371
|
typer.Option(
|
|
@@ -374,6 +413,7 @@ def clean(
|
|
|
374
413
|
exclude=exclude,
|
|
375
414
|
ignore_file=ignore_file,
|
|
376
415
|
console=active_console,
|
|
416
|
+
folder_types=folder_types,
|
|
377
417
|
)
|
|
378
418
|
|
|
379
419
|
if not results:
|
|
@@ -65,6 +65,69 @@ _CLEANABLE_FOLDER_MAP: dict[str, FolderType] = {
|
|
|
65
65
|
".ruff_cache": FolderType.RUFF_CACHE,
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
SUPPORTED_FOLDER_TYPES: tuple[FolderType, ...] = (
|
|
69
|
+
FolderType.NODE_MODULES,
|
|
70
|
+
FolderType.VENV,
|
|
71
|
+
FolderType.RUST_TARGET,
|
|
72
|
+
FolderType.DIST,
|
|
73
|
+
FolderType.BUILD,
|
|
74
|
+
FolderType.PYCACHE,
|
|
75
|
+
FolderType.NEXT,
|
|
76
|
+
FolderType.NUXT,
|
|
77
|
+
FolderType.COVERAGE,
|
|
78
|
+
FolderType.PYTEST_CACHE,
|
|
79
|
+
FolderType.GRADLE,
|
|
80
|
+
FolderType.TURBO,
|
|
81
|
+
FolderType.PARCEL_CACHE,
|
|
82
|
+
FolderType.MYPY_CACHE,
|
|
83
|
+
FolderType.RUFF_CACHE,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
_FOLDER_TYPE_ALIASES: dict[str, FolderType] = {
|
|
87
|
+
**{ft.value.lower(): ft for ft in SUPPORTED_FOLDER_TYPES},
|
|
88
|
+
**{name.lower(): ft for name, ft in _CLEANABLE_FOLDER_MAP.items()},
|
|
89
|
+
"rust_target": FolderType.RUST_TARGET,
|
|
90
|
+
"pycache": FolderType.PYCACHE,
|
|
91
|
+
"next": FolderType.NEXT,
|
|
92
|
+
"nuxt": FolderType.NUXT,
|
|
93
|
+
"pytest_cache": FolderType.PYTEST_CACHE,
|
|
94
|
+
"gradle": FolderType.GRADLE,
|
|
95
|
+
"turbo": FolderType.TURBO,
|
|
96
|
+
"parcel-cache": FolderType.PARCEL_CACHE,
|
|
97
|
+
"parcel_cache": FolderType.PARCEL_CACHE,
|
|
98
|
+
"mypy_cache": FolderType.MYPY_CACHE,
|
|
99
|
+
"ruff_cache": FolderType.RUFF_CACHE,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def parse_folder_types(raw_types: Sequence[str] | None) -> set[FolderType] | None:
|
|
104
|
+
"""Parse CLI `--type` values (repeatable or comma-separated) into a set of FolderType."""
|
|
105
|
+
if not raw_types:
|
|
106
|
+
return None
|
|
107
|
+
|
|
108
|
+
parsed: set[FolderType] = set()
|
|
109
|
+
invalid: list[str] = []
|
|
110
|
+
|
|
111
|
+
for raw_item in raw_types:
|
|
112
|
+
for token in raw_item.split(","):
|
|
113
|
+
cleaned = token.strip()
|
|
114
|
+
if not cleaned:
|
|
115
|
+
continue
|
|
116
|
+
matched = _FOLDER_TYPE_ALIASES.get(cleaned.lower())
|
|
117
|
+
if matched is None:
|
|
118
|
+
invalid.append(cleaned)
|
|
119
|
+
else:
|
|
120
|
+
parsed.add(matched)
|
|
121
|
+
|
|
122
|
+
if invalid:
|
|
123
|
+
supported_list = ", ".join(ft.value for ft in SUPPORTED_FOLDER_TYPES)
|
|
124
|
+
bad_str = ", ".join(invalid)
|
|
125
|
+
raise ValueError(
|
|
126
|
+
f"Unknown folder type(s): {bad_str}. Supported types: {supported_list}"
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
return parsed or None
|
|
130
|
+
|
|
68
131
|
_VENV_MARKERS: tuple[tuple[str, ...], ...] = (
|
|
69
132
|
("pyvenv.cfg",),
|
|
70
133
|
("Scripts", "python.exe"),
|
|
@@ -161,6 +224,7 @@ def _walk_subdirectories(
|
|
|
161
224
|
matcher: IgnoreMatcher,
|
|
162
225
|
results: list[ScanResult],
|
|
163
226
|
skipped_errors: list[tuple[Path, str]] | None = None,
|
|
227
|
+
allowed_types: set[FolderType] | None = None,
|
|
164
228
|
) -> None:
|
|
165
229
|
"""Walk directories in streaming scandir passes with depth and ignore pruning."""
|
|
166
230
|
# Stop descending once max_depth is reached (depth=0 means scan children at depth=1).
|
|
@@ -185,20 +249,23 @@ def _walk_subdirectories(
|
|
|
185
249
|
|
|
186
250
|
folder_type = _classify_dir_entry(entry)
|
|
187
251
|
if folder_type is not None:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if
|
|
192
|
-
skipped_errors
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
252
|
+
if allowed_types is None or folder_type in allowed_types:
|
|
253
|
+
mtime = entry.stat(follow_symlinks=False).st_mtime
|
|
254
|
+
dir_size = _calculate_dir_size_str(entry.path)
|
|
255
|
+
if dir_size is None:
|
|
256
|
+
if skipped_errors is not None:
|
|
257
|
+
skipped_errors.append(
|
|
258
|
+
(Path(entry.path), "Permission denied")
|
|
259
|
+
)
|
|
260
|
+
continue
|
|
261
|
+
results.append(
|
|
262
|
+
ScanResult(
|
|
263
|
+
path=Path(entry.path),
|
|
264
|
+
size_bytes=dir_size,
|
|
265
|
+
folder_type=folder_type,
|
|
266
|
+
modified_time=datetime.fromtimestamp(mtime, tz=timezone.utc),
|
|
267
|
+
)
|
|
200
268
|
)
|
|
201
|
-
)
|
|
202
269
|
# Prune traversal inside cleanable folders to prevent double counting.
|
|
203
270
|
continue
|
|
204
271
|
|
|
@@ -210,6 +277,7 @@ def _walk_subdirectories(
|
|
|
210
277
|
matcher,
|
|
211
278
|
results,
|
|
212
279
|
skipped_errors,
|
|
280
|
+
allowed_types,
|
|
213
281
|
)
|
|
214
282
|
except (PermissionError, OSError) as exc:
|
|
215
283
|
if skipped_errors is not None:
|
|
@@ -296,6 +364,7 @@ def scan_directory(
|
|
|
296
364
|
ignore_file: Path | None = None,
|
|
297
365
|
ignore_matcher: IgnoreMatcher | None = None,
|
|
298
366
|
extra_default_ignores: Sequence[str] = (),
|
|
367
|
+
folder_types: set[FolderType] | None = None,
|
|
299
368
|
) -> list[ScanResult]:
|
|
300
369
|
"""Scan a single directory recursively for cleanable developer folders."""
|
|
301
370
|
if max_depth is not None and max_depth < 0:
|
|
@@ -323,6 +392,7 @@ def scan_directory(
|
|
|
323
392
|
max_depth,
|
|
324
393
|
matcher,
|
|
325
394
|
results,
|
|
395
|
+
allowed_types=folder_types,
|
|
326
396
|
)
|
|
327
397
|
results.sort(key=lambda item: item.path)
|
|
328
398
|
return results
|
|
@@ -338,6 +408,7 @@ def scan_paths(
|
|
|
338
408
|
smart_home: bool = True,
|
|
339
409
|
home_dir: Path | None = None,
|
|
340
410
|
on_root_progress: Callable[[Path, int, int], None] | None = None,
|
|
411
|
+
folder_types: set[FolderType] | None = None,
|
|
341
412
|
) -> list[ScanResult]:
|
|
342
413
|
"""Scan multiple root paths and deduplicate discovered cleanable folders."""
|
|
343
414
|
if max_depth is not None and max_depth < 0:
|
|
@@ -391,6 +462,7 @@ def scan_paths(
|
|
|
391
462
|
use_default_ignores=use_default_ignores,
|
|
392
463
|
ignore_file=ignore_file,
|
|
393
464
|
extra_default_ignores=extra_defaults,
|
|
465
|
+
folder_types=folder_types,
|
|
394
466
|
):
|
|
395
467
|
norm_key = os.path.normcase(str(item.path.resolve()))
|
|
396
468
|
if norm_key not in seen_items:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: devsweep-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: CLI tool to scan and safely clean developer build artifacts, dependencies, caches, and unused Docker resources.
|
|
5
5
|
Author-email: Vũ Lộc <vuloc668165@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -37,9 +37,9 @@ Dynamic: license-file
|
|
|
37
37
|
# 🧹 DevSweep
|
|
38
38
|
|
|
39
39
|
[](https://github.com/vuloc080611/DevSweep/actions/workflows/ci.yml)
|
|
40
|
-
[](https://pypi.org/project/devsweep-cli/)
|
|
41
41
|
[](https://www.python.org/)
|
|
42
|
-
[](LICENSE)
|
|
42
|
+
[](https://github.com/vuloc080611/DevSweep/blob/main/LICENSE)
|
|
43
43
|
[](https://typer.tiangolo.com/)
|
|
44
44
|
|
|
45
45
|
**DevSweep** is a fast, safe, cross-platform Python CLI that scans your workspaces and reclaims gigabytes of disk space from forgotten build artifacts, dependency folders (`node_modules`, `.venv`, `target`, `.next`, `__pycache__`, …), and unused Docker resources — with built-in dry-run previews, interactive selection, `.devsweepignore` rules, and strict safety guardrails.
|
|
@@ -49,7 +49,7 @@ Dynamic: license-file
|
|
|
49
49
|
## Demo
|
|
50
50
|
|
|
51
51
|
<p align="center">
|
|
52
|
-
<img src="assets/demo.gif" alt="DevSweep CLI Demo" width="760" />
|
|
52
|
+
<img src="https://raw.githubusercontent.com/vuloc080611/DevSweep/main/assets/demo.gif" alt="DevSweep CLI Demo" width="760" />
|
|
53
53
|
</p>
|
|
54
54
|
|
|
55
55
|
---
|
|
@@ -74,7 +74,7 @@ Dynamic: license-file
|
|
|
74
74
|
- **Python 3.10+**
|
|
75
75
|
- Optional: **Docker CLI** (only required for `devsweep docker ...` commands)
|
|
76
76
|
|
|
77
|
-
### Install from PyPI
|
|
77
|
+
### Install from PyPI (Recommended)
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
80
|
pip install devsweep-cli
|
|
@@ -134,6 +134,9 @@ devsweep scan ./projects --dry-run --no-color
|
|
|
134
134
|
|
|
135
135
|
# Machine-readable JSON output for jq, CI pipelines, or dashboards
|
|
136
136
|
devsweep scan ./projects --json | jq '.total_reclaimable_bytes'
|
|
137
|
+
|
|
138
|
+
# Filter by specific artifact types (repeatable or comma-separated)
|
|
139
|
+
devsweep scan ./projects --type node_modules --type pycache
|
|
137
140
|
```
|
|
138
141
|
|
|
139
142
|
### Cleaning Folders Safely
|
|
@@ -150,6 +153,9 @@ devsweep clean ./web ./api --exclude legacy --interactive
|
|
|
150
153
|
|
|
151
154
|
# Non-interactive cleanup (skips confirmation prompt)
|
|
152
155
|
devsweep clean ./projects --yes
|
|
156
|
+
|
|
157
|
+
# Clean only specific artifact categories
|
|
158
|
+
devsweep clean ./projects --type node_modules --type __pycache__ --yes
|
|
153
159
|
```
|
|
154
160
|
|
|
155
161
|
### Cleaning Unused Docker Resources
|
|
@@ -201,6 +207,7 @@ devsweep docker clean --yes
|
|
|
201
207
|
| :--- | :---: | :--- | :--- |
|
|
202
208
|
| `--max-depth INT` | `-d` | `scan`, `clean` | Maximum directory depth to descend (`0` scans nothing inside root) |
|
|
203
209
|
| `--exclude PATTERN` | `-e` | `scan`, `clean` | Exclude matching folder name or relative glob pattern (repeatable) |
|
|
210
|
+
| `--type CATEGORY` | `-t` | `scan`, `clean` | Filter by artifact category, e.g. `node_modules`, `pycache`, `venv` (repeatable or comma-separated) |
|
|
204
211
|
| `--ignore-file PATH` | | `scan`, `clean` | Use a custom ignore file instead of auto-discovered `.devsweepignore` |
|
|
205
212
|
| `--dry-run` | `-n` | `scan`, `clean`, `docker` | Show what would be targeted without deleting anything |
|
|
206
213
|
| `--json` | | `scan`, `docker scan` | Emit pure machine-readable JSON (suppresses spinners and banners) |
|
|
@@ -240,10 +247,10 @@ packages/**/legacy
|
|
|
240
247
|
|
|
241
248
|
## Contributing
|
|
242
249
|
|
|
243
|
-
Contributions, bug reports, and feature ideas are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, test commands, and commit guidelines, and [SECURITY.md](SECURITY.md) for reporting safety or security issues.
|
|
250
|
+
Contributions, bug reports, and feature ideas are welcome! Please read [CONTRIBUTING.md](https://github.com/vuloc080611/DevSweep/blob/main/CONTRIBUTING.md) for development setup, test commands, and commit guidelines, and [SECURITY.md](https://github.com/vuloc080611/DevSweep/blob/main/SECURITY.md) for reporting safety or security issues.
|
|
244
251
|
|
|
245
252
|
---
|
|
246
253
|
|
|
247
254
|
## License
|
|
248
255
|
|
|
249
|
-
Released under the [MIT License](LICENSE).
|
|
256
|
+
Released under the [MIT License](https://github.com/vuloc080611/DevSweep/blob/main/LICENSE).
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "devsweep-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "CLI tool to scan and safely clean developer build artifacts, dependencies, caches, and unused Docker resources."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -338,3 +338,41 @@ def test_cli_scan_json_output_and_empty_state(tmp_path: Path) -> None:
|
|
|
338
338
|
assert payload["items"][0]["size_bytes"] == 3072
|
|
339
339
|
assert payload["items"][1]["folder_type"] == "venv"
|
|
340
340
|
assert payload["items"][1]["size_bytes"] == 1024
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def test_cli_scan_and_clean_with_type_filter(tmp_path: Path) -> None:
|
|
344
|
+
"""Verify repeatable `--type` filters work on scan, scan --json, and clean."""
|
|
345
|
+
nm = tmp_path / "web" / "node_modules"
|
|
346
|
+
pycache = tmp_path / "api" / "__pycache__"
|
|
347
|
+
dist = tmp_path / "web" / "dist"
|
|
348
|
+
venv = tmp_path / "api" / ".venv"
|
|
349
|
+
for p in (nm, pycache, dist, venv):
|
|
350
|
+
p.mkdir(parents=True)
|
|
351
|
+
(nm / "pkg.js").write_bytes(b"a" * 1024)
|
|
352
|
+
(pycache / "mod.pyc").write_bytes(b"b" * 512)
|
|
353
|
+
(dist / "out.js").write_bytes(b"c" * 2048)
|
|
354
|
+
|
|
355
|
+
scan_res = runner.invoke(
|
|
356
|
+
app,
|
|
357
|
+
["scan", str(tmp_path), "--type", "node_modules", "--type", "pycache", "--json"],
|
|
358
|
+
)
|
|
359
|
+
assert scan_res.exit_code == 0
|
|
360
|
+
payload = json.loads(scan_res.stdout)
|
|
361
|
+
assert payload["count"] == 2
|
|
362
|
+
assert {item["folder_type"] for item in payload["items"]} == {"node_modules", "__pycache__"}
|
|
363
|
+
|
|
364
|
+
clean_res = runner.invoke(
|
|
365
|
+
app,
|
|
366
|
+
["clean", str(tmp_path), "-t", "pycache,dist", "--yes"],
|
|
367
|
+
)
|
|
368
|
+
assert clean_res.exit_code == 0
|
|
369
|
+
assert "Deleted: 2 folder(s)" in clean_res.stdout
|
|
370
|
+
assert not pycache.exists()
|
|
371
|
+
assert not dist.exists()
|
|
372
|
+
assert nm.exists()
|
|
373
|
+
assert venv.exists()
|
|
374
|
+
|
|
375
|
+
bad_res = runner.invoke(app, ["scan", str(tmp_path), "--type", "invalid_category"])
|
|
376
|
+
assert bad_res.exit_code == 1
|
|
377
|
+
assert "Unknown folder type" in bad_res.stdout
|
|
378
|
+
assert "Hint:" in bad_res.stdout
|
|
@@ -14,6 +14,7 @@ from devsweep.scanner import (
|
|
|
14
14
|
classify_folder,
|
|
15
15
|
get_smart_home_roots,
|
|
16
16
|
is_cleanable_folder,
|
|
17
|
+
parse_folder_types,
|
|
17
18
|
scan_directory,
|
|
18
19
|
scan_paths,
|
|
19
20
|
summarize_scan,
|
|
@@ -370,3 +371,40 @@ def test_scan_directory_detects_additional_cache_dirs(tmp_path: Path) -> None:
|
|
|
370
371
|
for folder, (expected_type, expected_size) in targets.items():
|
|
371
372
|
assert by_path[folder].folder_type == expected_type
|
|
372
373
|
assert by_path[folder].size_bytes == expected_size
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
def test_parse_folder_types_supports_aliases_commas_and_rejects_invalid() -> None:
|
|
377
|
+
"""Verify parse_folder_types resolves canonical names, aliases, commas, and errors."""
|
|
378
|
+
assert parse_folder_types(None) is None
|
|
379
|
+
assert parse_folder_types([]) is None
|
|
380
|
+
assert parse_folder_types(["node_modules", "pycache"]) == {
|
|
381
|
+
FolderType.NODE_MODULES,
|
|
382
|
+
FolderType.PYCACHE,
|
|
383
|
+
}
|
|
384
|
+
assert parse_folder_types([".venv,ruff_cache,NEXT", "gradle"]) == {
|
|
385
|
+
FolderType.VENV,
|
|
386
|
+
FolderType.RUFF_CACHE,
|
|
387
|
+
FolderType.NEXT,
|
|
388
|
+
FolderType.GRADLE,
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
with pytest.raises(ValueError, match="Unknown folder type"):
|
|
392
|
+
parse_folder_types(["node_modules", "not_a_real_type"])
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
def test_scan_directory_filters_by_folder_types_and_preserves_pruning(tmp_path: Path) -> None:
|
|
396
|
+
"""Verify folder_types filter returns only matching types without descending into skipped ones."""
|
|
397
|
+
nm = tmp_path / "web" / "node_modules"
|
|
398
|
+
venv = tmp_path / "api" / ".venv"
|
|
399
|
+
venv_inner_pycache = venv / "lib" / "__pycache__"
|
|
400
|
+
app_pycache = tmp_path / "api" / "app" / "__pycache__"
|
|
401
|
+
dist = tmp_path / "web" / "dist"
|
|
402
|
+
|
|
403
|
+
for p in (nm, venv_inner_pycache, app_pycache, dist):
|
|
404
|
+
p.mkdir(parents=True)
|
|
405
|
+
|
|
406
|
+
results = scan_directory(
|
|
407
|
+
tmp_path,
|
|
408
|
+
folder_types={FolderType.NODE_MODULES, FolderType.PYCACHE},
|
|
409
|
+
)
|
|
410
|
+
assert {item.path for item in results} == {nm, app_pycache}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|