mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-30 05:13:40 +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.
87 lines
2 KiB
Bash
87 lines
2 KiB
Bash
#!/bin/bash
|
||
# Output formatting library for consistent script styling
|
||
# Source this file in your scripts with: source "$(dirname "$0")/../.lib/output.sh"
|
||
|
||
# Color codes
|
||
readonly RED='\033[0;31m'
|
||
readonly GREEN='\033[0;32m'
|
||
readonly YELLOW='\033[1;33m'
|
||
readonly BLUE='\033[0;34m'
|
||
readonly MAGENTA='\033[0;35m'
|
||
readonly CYAN='\033[0;36m'
|
||
readonly BOLD='\033[1m'
|
||
readonly DIM='\033[2m'
|
||
readonly NC='\033[0m' # No Color
|
||
|
||
# Unicode symbols (work in most modern terminals)
|
||
readonly CHECK='✓'
|
||
readonly CROSS='✗'
|
||
readonly ARROW='→'
|
||
readonly INFO='ℹ'
|
||
readonly WARNING='⚠'
|
||
readonly ROCKET='🚀'
|
||
readonly PACKAGE='📦'
|
||
readonly WRENCH='🔧'
|
||
readonly SPARKLES='✨'
|
||
readonly BUG='🐛'
|
||
readonly BOOKS='📚'
|
||
|
||
# Formatted output functions
|
||
log_header() {
|
||
printf "\n%b==> %b%b\n" "$BOLD$BLUE" "$1" "$NC"
|
||
}
|
||
|
||
log_success() {
|
||
printf "%b%s %b%b\n" "$GREEN" "$CHECK" "$1" "$NC"
|
||
}
|
||
|
||
log_error() {
|
||
printf "%b%s %b%b\n" "$RED" "$CROSS" "$1" "$NC" >&2
|
||
}
|
||
|
||
log_warning() {
|
||
printf "%b%s %b%b\n" "$YELLOW" "$WARNING" "$1" "$NC"
|
||
}
|
||
|
||
log_info() {
|
||
printf "%b%s %b%b\n" "$CYAN" "$INFO" "$1" "$NC"
|
||
}
|
||
|
||
log_step() {
|
||
printf " %b%s%b %b\n" "$DIM" "$ARROW" "$NC" "$1"
|
||
}
|
||
|
||
log_result() {
|
||
local status=$1
|
||
shift
|
||
if [[ $status -eq 0 ]]; then
|
||
printf " %b%s %s%b\n" "$GREEN" "$CHECK" "$*" "$NC"
|
||
else
|
||
printf " %b%s %s%b\n" "$RED" "$CROSS" "$*" "$NC"
|
||
fi
|
||
}
|
||
|
||
# Separator lines
|
||
log_separator() {
|
||
printf "%b%s%b\n" "$DIM" "────────────────────────────────────────────────────────────" "$NC"
|
||
}
|
||
|
||
# Exit with error message
|
||
die() {
|
||
log_error "$1"
|
||
exit "${2:-1}"
|
||
}
|
||
|
||
# Check command availability
|
||
require_command() {
|
||
local cmd=$1
|
||
local install_hint=${2:-""}
|
||
|
||
if ! command -v "$cmd" >/dev/null 2>&1; then
|
||
log_error "Required command not found: $cmd"
|
||
if [[ -n $install_hint ]]; then
|
||
log_info "Install with: $install_hint"
|
||
fi
|
||
exit 1
|
||
fi
|
||
}
|