mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-30 13:23:41 +00:00
Major restructuring of the scripts/ directory with consistent output
formatting, improved organization, and stricter error handling.
Breaking Changes:
- Updated development environment to Home Assistant 2025.7+
- Removed Python 3.12 compatibility (HA 2025.7+ requires Python 3.13)
- Updated all HA core requirements from 2025.7 requirement files
- Added new dependencies: python-multipart, uv (for faster package management)
- Updated GitHub Actions workflows to use Python 3.13
Changes:
- Created centralized output library (scripts/.lib/output.sh)
- Unified color codes and Unicode symbols
- Consistent formatting functions (log_header, log_success, log_error, etc.)
- Support for embedded formatting codes (${BOLD}, ${GREEN}, etc.)
- Reorganized into logical subdirectories:
- scripts/setup/ - Setup and maintenance scripts
- bootstrap: Install/update dependencies (used in CI/CD)
- setup: Full DevContainer setup (pyright, copilot, HACS)
- reset: Reset config/ directory to fresh state (NEW)
- sync-hacs: Sync HACS integrations
- scripts/release/ - Release management scripts
- prepare: Version bump and tagging
- suggest-version: Semantic version suggestion
- generate-notes: Release notes generation
- check-if-released: Check release status
- hassfest: Local integration validation
- Updated all scripts with:
- set -euo pipefail for stricter error handling
- Consistent SCRIPT_DIR pattern for reliable sourcing
- Professional output with colors and emojis
- Unified styling across all 17 scripts
- Removed redundant scripts:
- scripts/update (was just wrapper around bootstrap)
- scripts/json_schemas/ (moved to schemas/json/)
- Enhanced clean script:
- Improved artifact cleanup
- Better handling of accidental package installations
- Hints for reset and deep clean options
- New reset script features:
- Standard mode: Keep configuration.yaml
- Full mode (--full): Reset configuration.yaml from git
- Automatic re-setup after reset
- Updated documentation:
- AGENTS.md: Updated script references and workflow guidance
- docs/development/: Updated all references to new script structure
Impact: Development environment now requires Python 3.13 and Home Assistant
2025.7+. Developers get consistent, professional script output with better
error handling and logical organization. Single source of truth for styling
makes future updates trivial.
103 lines
3 KiB
Bash
Executable file
103 lines
3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# script/clean: Clean up development artifacts and caches
|
|
#
|
|
# Removes build artifacts, test caches, and accidental package installations.
|
|
# Use --minimal for critical cleanup only, --deep to also remove __pycache__.
|
|
#
|
|
# Usage:
|
|
# ./scripts/clean [--minimal|--deep]
|
|
#
|
|
# Examples:
|
|
# ./scripts/clean # Standard cleanup (recommended)
|
|
# ./scripts/clean --deep # Also remove __pycache__
|
|
# ./scripts/clean --minimal # Only critical issues (.egg-info)
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
cd "$SCRIPT_DIR/.."
|
|
|
|
# shellcheck source=scripts/.lib/output.sh
|
|
source "$SCRIPT_DIR/.lib/output.sh"
|
|
|
|
MINIMAL_MODE=false
|
|
DEEP_MODE=false
|
|
|
|
if [[ ${1:-} == --minimal ]]; then
|
|
MINIMAL_MODE=true
|
|
elif [[ ${1:-} == --deep ]]; then
|
|
DEEP_MODE=true
|
|
fi
|
|
|
|
if [[ $MINIMAL_MODE == false ]]; then
|
|
log_header "Cleaning development artifacts"
|
|
fi
|
|
|
|
# Clean up accidental package installation (always, even in minimal mode)
|
|
if [[ -d tibber_prices.egg-info ]]; then
|
|
if [[ $MINIMAL_MODE == false ]]; then
|
|
log_step "Removing tibber_prices.egg-info"
|
|
fi
|
|
rm -rf tibber_prices.egg-info
|
|
fi
|
|
|
|
# Uninstall if accidentally installed (always, even in minimal mode)
|
|
# Try both pip and uv pip for maximum compatibility
|
|
PACKAGE_INSTALLED=false
|
|
if pip show tibber_prices >/dev/null 2>&1 || uv pip show tibber_prices >/dev/null 2>&1; then
|
|
PACKAGE_INSTALLED=true
|
|
if [[ $MINIMAL_MODE == false ]]; then
|
|
log_step "Uninstalling accidentally installed package"
|
|
fi
|
|
# Use regular pip (cleaner output, always works in venv)
|
|
pip uninstall -y tibber_prices >/dev/null 2>&1 || true
|
|
# Also try uv pip as fallback
|
|
uv pip uninstall tibber_prices >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
# Exit early if minimal mode
|
|
if [[ $MINIMAL_MODE == true ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
# Clean pytest cache
|
|
if [[ -d .pytest_cache ]]; then
|
|
log_step "Removing .pytest_cache"
|
|
rm -rf .pytest_cache
|
|
fi
|
|
|
|
# Clean coverage files
|
|
if [[ -f .coverage ]]; then
|
|
log_step "Removing .coverage"
|
|
rm -f .coverage
|
|
fi
|
|
if [[ -f coverage.xml ]]; then
|
|
log_step "Removing coverage.xml"
|
|
rm -f coverage.xml
|
|
fi
|
|
|
|
# Clean ruff cache
|
|
if [[ -d .ruff_cache ]]; then
|
|
log_step "Removing .ruff_cache"
|
|
rm -rf .ruff_cache
|
|
fi
|
|
|
|
# Optional: Clean __pycache__ (normally not needed, but useful for troubleshooting)
|
|
if [[ $DEEP_MODE == true ]]; then
|
|
log_step "Deep clean: Removing all __pycache__ directories"
|
|
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
|
|
log_step "Deep clean: Removing all .pyc files"
|
|
find . -type f -name "*.pyc" -delete 2>/dev/null || true
|
|
fi
|
|
|
|
log_success "Cleanup complete"
|
|
|
|
if [[ $DEEP_MODE == false ]]; then
|
|
echo ""
|
|
log_info "Tip: Use './scripts/clean --deep' to also remove __pycache__ directories"
|
|
log_step "(normally not needed - __pycache__ speeds up Home Assistant startup)"
|
|
echo ""
|
|
log_info "Tip: Use './scripts/setup/reset' to reset config/ to fresh HA installation"
|
|
log_step "(removes everything, restores configuration.yaml, re-runs setup)"
|
|
fi
|