.PHONY: up down restart shell test lint analyze coverage check fresh logs

# ─── Docker ──────────────────────────────────────────────────────────────────

up:
	docker-compose up -d --build

down:
	docker-compose down

restart:
	docker-compose restart

shell:
	docker exec -it markatty_api_app bash

logs:
	docker-compose logs -f --tail=100

# ─── Testing ─────────────────────────────────────────────────────────────────

test:
	php artisan test --parallel

coverage:
	php artisan test --coverage --min=80

# ─── Static Analysis & Formatting ────────────────────────────────────────────

lint:
	./vendor/bin/pint

lint-check:
	./vendor/bin/pint --test

analyze:
	./vendor/bin/phpstan analyse --memory-limit=512M

# ─── Full CI check (pint → phpstan → tests) ──────────────────────────────────

check: lint-check analyze test

# ─── Laravel ─────────────────────────────────────────────────────────────────

fresh:
	php artisan config:clear && \
	php artisan route:clear && \
	php artisan cache:clear

cache:
	php artisan config:cache && \
	php artisan route:cache

# ─── Postman (Newman) ─────────────────────────────────────────────────────────

postman:
	python3 scripts/convert-postman-v3.py
	npx --yes newman run docs/markatty-v3.postman_collection.json \
		--env-var "url=$${URL:-http://127.0.0.1:8090/mobikulhttp/v3/}" \
		--env-var "domain=$${DOMAIN:-demo.markatty.com}" \
		--env-var "api_token=$${API_TOKEN:-a197869e3439f6afbcc17c87152466f7}" \
		--timeout-request 30000 \
		--reporters cli,json \
		--reporter-json-export docs/newman-report.json

up-dev:
	docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build
