# SALAM — raccourcis développement
.DEFAULT_GOAL := help
DC = docker compose
PHP = $(DC) exec php

help: ## Liste les commandes
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN{FS=":.*?## "}{printf "  \033[36m%-16s\033[0m %s\n",$$1,$$2}'

up: ## Démarre les conteneurs
	$(DC) up -d

down: ## Arrête les conteneurs
	$(DC) down

build: ## (Re)construit les images
	$(DC) build

sh: ## Shell dans le conteneur php
	$(PHP) bash

install: ## composer install + npm install
	$(PHP) composer install
	$(PHP) npm install

migrate: ## Applique les migrations
	$(PHP) php bin/console doctrine:migrations:migrate --no-interaction

fixtures: ## Charge les fixtures
	$(PHP) php bin/console doctrine:fixtures:load --no-interaction

cc: ## Vide le cache
	$(PHP) php bin/console cache:clear

stan: ## PHPStan niveau 6
	$(PHP) vendor/bin/phpstan analyse

cs: ## PHP-CS-Fixer (dry-run)
	$(PHP) vendor/bin/php-cs-fixer fix --dry-run --diff

cs-fix: ## PHP-CS-Fixer (applique)
	$(PHP) vendor/bin/php-cs-fixer fix

test: ## PHPUnit
	$(DC) exec -e APP_ENV=test php php bin/phpunit

.PHONY: help up down build sh install migrate fixtures cc stan cs cs-fix test
