.PHONY: help deploy_qa_streamlit drop_qa_streamlit deploy_prod_streamlit drop_prod_streamlit run_streamlit_locally fmt lint
.DEFAULT_GOAL := help

help:
	@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

deploy_qa_streamlit: ## Deploy Streamlit app to QA
	cd streamlit_app && poetry run snow streamlit deploy --replace --connection=artist_roster --schema=QA_STREAMLIT_ROSTER_MANAGEMENT

drop_qa_streamlit: ## Drop Streamlit app and related stage in QA
	poetry run snow streamlit drop fansifter_roster_management --connection=artist_roster --schema=QA_STREAMLIT_ROSTER_MANAGEMENT && \
	poetry run snow stage drop fansifter_roster_management_stage --connection=artist_roster --schema=QA_STREAMLIT_ROSTER_MANAGEMENT

deploy_prod_streamlit: ## Deploy Streamlit app to PROD
	cd streamlit_app && poetry run snow streamlit deploy --replace --connection=artist_roster --schema=PROD_STREAMLIT_ROSTER_MANAGEMENT

drop_prod_streamlit: ## Drop Streamlit app and related stage in PROD
	poetry run snow streamlit drop fansifter_roster_management --connection=artist_roster --schema=PROD_STREAMLIT_ROSTER_MANAGEMENT && \
	poetry run snow stage drop fansifter_roster_management_stage --connection=artist_roster --schema=PROD_STREAMLIT_ROSTER_MANAGEMENT

run_streamlit_locally: ## Run Streamlit app locally using QA (local runs are QA-only for safety)
	export target=qa && poetry run streamlit run streamlit_app/main.py

fmt: ## Run code formatters
	poetry run ruff check --fix
	poetry run ruff format

lint: ## Run code linters
	poetry run mypy
	poetry run ruff check
	poetry run ruff format --check
