SAIL := ./vendor/bin/sail

# Start the application
up:
	$(SAIL) up -d

# Stop the application
down:
	$(SAIL) down

# Restart the application
restart:
	$(SAIL) restart

# Stop containers without removing them
stop:
	$(SAIL) stop

# Run database migrations
migrate:
	$(SAIL) artisan migrate

# Run database migrations with seed
fresh:
	$(SAIL) artisan migrate:fresh --seed

# Open a shell in the container
shell:
	$(SAIL) shell

# Run tests
test:
	$(SAIL) test

# Run composer commands (usage: make composer command="install")
composer:
	$(SAIL) composer $(command)

# Run artisan commands (usage: make artisan command="route:list")
artisan:
	$(SAIL) artisan $(command)

# View logs (usage: make logs [service="laravel.test"])
logs:
	$(SAIL) logs -f $(service)

# Setup the project from scratch
setup:
	@make build
	@make up
	@make composer command="install"
	@make migrate

# Rebuild docker images
build:
	$(SAIL) build --no-cache

# Run endpoint tests (bash script)
test-endpoints:
	@bash test-endpoints.sh

# Run API feature tests (PHPUnit)
test-api:
	$(SAIL) test tests/Feature/BudgetingApiTest.php
