| 1 |
#!/usr/bin/env bash |
| 2 |
set -euo pipefail |
| 3 |
|
| 4 |
echo "🚀 Starting Python + Node dev cleanup..." |
| 5 |
|
| 6 |
# ----- Python bytecode ----- |
| 7 |
echo "Removing __pycache__ and *.py[co]..." |
| 8 |
find . -type d -name "__pycache__" -exec rm -rf {} + |
| 9 |
find . -type f -name "*.py[co]" -delete |
| 10 |
find . -type f -name '*$py.class' -delete |
| 11 |
|
| 12 |
# ----- Tool caches ----- |
| 13 |
echo "Removing Python tool caches..." |
| 14 |
for cache in .mypy_cache .ruff_cache .pytest_cache .hypothesis .pytype .isort_cache .tox .nox .cache .pyre .pybuilder cython_debug __pypackages__; do |
| 15 |
[ -d "$cache" ] && rm -rf "$cache" |
| 16 |
done |
| 17 |
|
| 18 |
for file in .dmypy.json dmypy.json; do |
| 19 |
[ -f "$file" ] && rm -f "$file" |
| 20 |
done |
| 21 |
|
| 22 |
# ----- Build artifacts ----- |
| 23 |
echo "Removing build artifacts..." |
| 24 |
for build in .Python build develop-eggs dist downloads eggs .eggs lib lib64 parts sdist var wheels share/python-wheels target out site docs/_build *.egg; do |
| 25 |
[ -e "$build" ] && rm -rf "$build" |
| 26 |
done |
| 27 |
|
| 28 |
for file in .installed.cfg MANIFEST; do |
| 29 |
[ -e "$file" ] && rm -rf "$file" |
| 30 |
done |
| 31 |
|
| 32 |
find . -type f \( -name '*.so' -o -name '*.manifest' -o -name '*.spec' \) -delete |
| 33 |
find . -type d -name "*.egg-info" -exec rm -rf {} + |
| 34 |
|
| 35 |
# ----- IDE / project folders ----- |
| 36 |
echo "Removing IDE folders..." |
| 37 |
for ide in .idea .ipynb_checkpoints profile_default .spyderproject .spyproject .ropeproject; do |
| 38 |
[ -d "$ide" ] && rm -rf "$ide" |
| 39 |
done |
| 40 |
|
| 41 |
# Remove transient files generated by workspace-scoped zsh config. |
| 42 |
if [ -d ".vscode/zsh" ]; then |
| 43 |
echo "Removing zsh transient files (.zcompdump*, .zsh_sessions*)..." |
| 44 |
find .vscode/zsh -maxdepth 1 -type f \( -name '.zcompdump*' -o -name '.zsh_sessions*' \) -delete |
| 45 |
fi |
| 46 |
|
| 47 |
[ -f ipython_config.py ] && rm -f ipython_config.py |
| 48 |
|
| 49 |
# ----- Coverage files ----- |
| 50 |
echo "Removing coverage files..." |
| 51 |
for coverage in .coverage coverage.xml nosetests.xml; do |
| 52 |
[ -f "$coverage" ] && rm -f "$coverage" |
| 53 |
done |
| 54 |
|
| 55 |
for coverage_dir in htmlcov cover; do |
| 56 |
[ -e "$coverage_dir" ] && rm -rf "$coverage_dir" |
| 57 |
done |
| 58 |
|
| 59 |
find . -maxdepth 1 -type f \( -name '.coverage.*' -o -name '*.cover' -o -name '*.py,cover' \) -delete |
| 60 |
|
| 61 |
# ----- Runtime / local files ----- |
| 62 |
echo "Removing runtime and local files..." |
| 63 |
for runtime_dir in instance .webassets-cache .scrapy; do |
| 64 |
[ -d "$runtime_dir" ] && rm -rf "$runtime_dir" |
| 65 |
done |
| 66 |
|
| 67 |
for runtime_file in celerybeat-schedule celerybeat.pid db.sqlite3 db.sqlite3-journal pip-log.txt pip-delete-this-directory.txt; do |
| 68 |
[ -e "$runtime_file" ] && rm -rf "$runtime_file" |
| 69 |
done |
| 70 |
|
| 71 |
find . -type f \( -name '*.mo' -o -name '*.pot' -o -name '*.log' \) -delete |
| 72 |
|
| 73 |
# ----- Local config files ----- |
| 74 |
if [ -f .env ] || [ -f local_settings.py ]; then |
| 75 |
echo "" |
| 76 |
read -p "Do you want to purge local config files (.env, local_settings.py)? (y/n) " -n 1 -r |
| 77 |
echo |
| 78 |
if [[ $REPLY =~ ^[Yy]$ ]]; then |
| 79 |
echo "Removing local config files..." |
| 80 |
rm -f .env local_settings.py |
| 81 |
fi |
| 82 |
fi |
| 83 |
|
| 84 |
# ----- Node.js ----- |
| 85 |
echo "Removing Node.js..." |
| 86 |
if [ -d "node_modules" ]; then |
| 87 |
rm -rf node_modules |
| 88 |
fi |
| 89 |
|
| 90 |
echo "✅ Cleanup complete!" |