# Expander Card development helpers
#
# All targets assume you are running from the repository root with an activated
# Python virtual environment (source .venv/bin/activate) and the JS already
# built (pnpm run build).
#
# Quick reference
# ---------------
#   make ha_up               Start a persistent HA container for fast iterative work
#   make doc_images_gen      Generate any missing documentation images (first-run bootstrap)
#   make doc_images_update   Regenerate ALL documentation images (use after HA/card visual changes)
#   make doc_audit           Check that all doc images are scenario-generated or explicitly excluded

.PHONY: ha_up ha-tests-up doc_images_gen doc_images_update doc_audit

# Start a persistent Home Assistant container and leave it running.
# The script prints HA_URL and HA_TOKEN and writes them to .ha_env.
# In a second terminal:  source .ha_env && pytest tests/visual/ -k <id>
# Press Ctrl-C here to stop HA.
ha_up ha-tests-up:
	HA_CONFIG_PATH=tests/ha-config HA_PLUGINS_YAML=tests/plugins.yaml python -m ha_testcontainer.ha_server

# Run the doc-image test suite.  Missing images are created automatically;
# existing images are verified against the current rendered output.
doc_images_gen:
	pytest tests/visual/test_doc_images.py

# Regenerate all documentation images, overwriting any existing files.
# Use this after an intentional visual change to the card or Home Assistant,
# then review the diff and commit the updated PNGs/GIFs.
doc_images_update:
	DOC_IMAGE_UPDATE=1 pytest tests/visual/test_doc_images.py

# Audit doc images: report any PNG/GIF referenced in docs/source/ that is
# neither generated by a scenario nor listed in tests/doc-image-audit-exclusions.txt.
# Exits non-zero (failing the test) if untracked images are found.
doc_audit:
	pytest tests/test_doc_audit.py
