# SWIFT PACKAGE MANAGER

build: ## Builds the project locally.
	@swift build -c release

clean: ## Deletes built SPM artifacts from the package.
	@swift package clean

outdated: ## Lists the SPM package dependencies that can be updated.
	@swift package update --dry-run

reset: ## Resets the complete SPM cache/build folder from the package.
	@swift package reset

run: ## Runs the project locally.
	@swift run -c release

test: ## Runs all the test cases of the project. 
	@swift test --enable-swift-testing

update: ## Updates the SPM package dependencies.
	@swift package update

# DOCKER

build-image: ## Builds a docker image out of the current source code
	@docker compose build

mount-image: ## Mounts and starts a docker container locally
	@docker compose up --detach

unmount-image: ## Stops and unmounts a docker container locally
	@docker compose down
	@make remove-image

remove-image: # Removes the generated Docker images
	@docker image rm $(shell docker image ls | grep doxy-app | awk '{print $$1 ":" $$2}')

# HELP

# Output the documentation for each of the defined tasks when `help` is called.
# Reference: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help

help: ## Prints the written documentation for all the defined tasks
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.DEFAULT_GOAL := help