# Makefile for {{project_name}}
# Generated by Pragmatic AI Labs MCP Agent Toolkit

.PHONY: all fmt lint type-check test coverage clean run dev bundle help

# Default target
all: fmt lint type-check test

# Format code
fmt:
	@echo "Formatting code..."
	deno fmt src/
{{#if has_tests}}
	deno fmt tests/
{{/if}}

# Lint code
lint:
	@echo "Linting code..."
	deno lint src/
{{#if has_tests}}
	deno lint tests/
{{/if}}

# Type check
type-check:
	@echo "Type checking..."
	deno check src/{{entry_point}}

{{#if has_tests}}
# Run tests
test:
	@echo "Running tests..."
	deno test --allow-read --allow-write

# Run tests with coverage
coverage:
	@echo "Running tests with coverage..."
	deno test --allow-read --allow-write --coverage=coverage
	deno coverage coverage --lcov --output=coverage.lcov
{{/if}}

# Clean build artifacts
clean:
	@echo "Cleaning build artifacts..."
	rm -rf coverage
	rm -rf dist
	rm -f coverage.lcov

# Run the application
run:
	@echo "Running {{project_name}}..."
	deno run {{#each permissions}}{{this}} {{/each}}src/{{entry_point}}

# Run in development mode with watch
dev:
	@echo "Running in development mode..."
	deno run --watch {{#each permissions}}{{this}} {{/each}}src/{{entry_point}}

# Bundle the application
bundle:
	@echo "Bundling application..."
	deno bundle src/{{entry_point}} dist/{{project_name}}.js

# Show help
help:
	@echo "Available targets:"
	@echo "  all        - Run fmt, lint, type-check, and test"
	@echo "  fmt        - Format code"
	@echo "  lint       - Lint code"
	@echo "  type-check - Type check"
{{#if has_tests}}
	@echo "  test       - Run tests"
	@echo "  coverage   - Run tests with coverage"
{{/if}}
	@echo "  clean      - Clean build artifacts"
	@echo "  run        - Run the application"
	@echo "  dev        - Run in development mode with watch"
	@echo "  bundle     - Bundle the application"
	@echo "  help       - Show this help message"