.PHONY: default
default: help

INFISICAL_PROJECT_ID_URL_COLLECTION = fc449ba7-ca78-46fd-a826-7548115fdd44
_MISE_EN_PLACE_PACKAGE_NAME = @meistrari/mise-en-place
MISE_EN_PLACE_INSTALL_DIR ?= .

# region Public commands

.PHONY: update-meistrari-libs
update-meistrari-libs: ## Update @meistrari/* packages recursively in the workspace
	@npx exec mise-en-place update-meistrari-libraries

.PHONY: mise-en-place
mise-en-place: .editorconfig ## Setup the mise en place to start cooking
	@npx mise-en-place postinstall
	@echo "Mise en place is ready! 🍳"

.PHONY: url-collection-envs
url-collection-envs:
	@infisical export --env development --projectId $(INFISICAL_PROJECT_ID_URL_COLLECTION)
# endregion

# region Hidden

.PHONY: help
help:
	@echo "Make tasks:"
	@sed -nE 's/^([^:]+: )?([%a-zA-Z_-]+):.*##\s?(.*)/\2:## \3/p' Makefile $(MISE_EN_PLACE_INSTALL_DIR)/node_modules/$(_MISE_EN_PLACE_PACKAGE_NAME)/Makefile | awk 'BEGIN {FS = ":## "}; {if (length($$1) > max) max = length($$1); lines[NR] = $$1; descs[NR] = $$2; n = NR} END {for (i = 1; i <= n; i++) printf "\033[36m  %-" max "s\033[0m %s\n", lines[i], descs[i]}'
	@echo ""

# endregion
