2023-01-19 13:43:29 -06:00
|
|
|
VERSION ?= $(shell git describe --tags --always --dirty=dev)
|
2022-09-05 12:23:17 -05:00
|
|
|
TEMPLATES := $(shell find src/ -type f)
|
|
|
|
.DEFAULT_GOAL := help
|
2022-09-22 10:39:53 -05:00
|
|
|
msg = $(if $(tprint),$(call tprint,{a.bold}==> {a.magenta}$(1){a.end}),@echo '==> $(1)')
|
2022-09-05 12:23:17 -05:00
|
|
|
|
2023-01-19 12:54:57 -06:00
|
|
|
### task.mk development |> -d -ms b_green --align center
|
2022-09-22 10:49:14 -05:00
|
|
|
.PHONY: bootstrap env hooks
|
2023-01-19 19:38:49 -06:00
|
|
|
bootstrap: env hooks ## generate local dev environment |> -ms b_magenta -gs b_cyan
|
2022-09-22 10:49:14 -05:00
|
|
|
env:
|
|
|
|
$(call msg,Bootstrapping Environment)
|
2022-09-05 18:02:16 -05:00
|
|
|
@mamba create -p ./env python jinja2 black -y
|
|
|
|
@mamba run -p ./env pip install yartsu
|
2022-09-22 10:49:14 -05:00
|
|
|
hooks:
|
2022-09-07 15:48:46 -05:00
|
|
|
@git config core.hooksPath .githooks
|
2022-09-24 17:55:52 -05:00
|
|
|
docs-env:
|
|
|
|
@mamba run -p ./env pip install mkdocs-material mkdocs-git-revision-date-localized-plugin
|
2023-01-19 12:54:57 -06:00
|
|
|
|
2022-09-13 16:40:07 -05:00
|
|
|
.PHONY: l lint
|
2023-01-19 19:38:49 -06:00
|
|
|
l lint: ## lint the python
|
2022-09-13 16:40:07 -05:00
|
|
|
$(call msg,Linting)
|
2022-09-05 12:23:17 -05:00
|
|
|
@black generate.py
|
|
|
|
@black src/*.py --fast
|
|
|
|
|
2023-01-19 19:38:49 -06:00
|
|
|
|
2022-09-05 18:02:16 -05:00
|
|
|
.PHONY: assets
|
2023-01-19 19:38:49 -06:00
|
|
|
assets: ## generate assets
|
2022-09-14 00:03:29 -05:00
|
|
|
@yartsu -o assets/help.svg -t "make help" -- make --no-print-directory help
|
2022-09-05 18:02:16 -05:00
|
|
|
|
2023-01-19 14:32:20 -06:00
|
|
|
define release_sh
|
|
|
|
./generate.py $(subst v,,$(VERSION)) > task.mk
|
|
|
|
sed -i 's/task.mk\/.*\/task.mk/task.mk\/$(VERSION)\/task.mk/g' README.md docs/index.md
|
|
|
|
git add task.mk README.md docs/index.md
|
|
|
|
git commit -m "release: $(VERSION)" --no-verify
|
|
|
|
git tag $(VERSION)
|
|
|
|
endef
|
|
|
|
|
2022-09-05 12:23:17 -05:00
|
|
|
.PHONY: release
|
2023-01-19 19:38:49 -06:00
|
|
|
release: version-check ## release new version of task.mk
|
2022-09-07 00:11:26 -05:00
|
|
|
$(call msg,Release Project)
|
2023-01-19 14:32:20 -06:00
|
|
|
$(call tbash,release_sh)
|
2022-09-05 12:23:17 -05:00
|
|
|
|
|
|
|
.PHONY: clean
|
2023-01-19 19:38:49 -06:00
|
|
|
c clean: ## remove the generated files
|
2022-09-05 12:23:17 -05:00
|
|
|
@rm -f task.mk .task.mk
|
2022-09-14 00:03:29 -05:00
|
|
|
|
2023-01-19 13:43:29 -06:00
|
|
|
define version_check_sh
|
|
|
|
if [[ "${VERSION}" == *'-'* ]]; then
|
|
|
|
$(call tprint-sh,{a.red}VERSION INVALID! Uncommited or untagged work{a.end})
|
|
|
|
exit 1
|
|
|
|
elif [[ $(shell echo "${VERSION}" | awk -F. '{ print NF }') -lt 3 ]];then\
|
|
|
|
$(call tprint-sh,{a.red}VERSION INVALID! Expected CalVer string{a.end})
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
2022-09-05 12:23:17 -05:00
|
|
|
.PHONY: version-check
|
|
|
|
version-check:
|
2023-01-19 13:43:29 -06:00
|
|
|
@$(call tprint,>> version: {a.green}$(VERSION){a.end})
|
|
|
|
@$(call tbash,version_check_sh)
|
|
|
|
@$(call tprint,>> {a.green}VERSION LOOKS GOOD!{a.end})
|
2022-09-05 12:23:17 -05:00
|
|
|
|
|
|
|
.PHONY: task
|
2023-01-19 19:38:49 -06:00
|
|
|
info: ## demonstrate usage of tprint
|
2022-09-12 00:16:25 -05:00
|
|
|
$(call msg,Info Message)
|
2022-09-05 23:48:32 -05:00
|
|
|
$(call tprint,{a.black_on_cyan}This is task-print output:{a.end})
|
2022-09-07 00:11:26 -05:00
|
|
|
$(call tprint,$(mlmsg))
|
|
|
|
$(call tprint,{a.custom(fg=(148, 255, 15),bg=(103, 2, 15))}Custom Colors TOO!{a.end})
|
2022-09-05 12:23:17 -05:00
|
|
|
|
2022-09-07 15:48:46 -05:00
|
|
|
task.mk: $(TEMPLATES) generate.py
|
|
|
|
./generate.py $(VERSION) > task.mk
|
2022-09-05 12:23:17 -05:00
|
|
|
|
|
|
|
-include .task.mk
|
|
|
|
.task.mk: $(TEMPLATES) generate.py
|
2022-09-22 10:39:53 -05:00
|
|
|
$(call msg,re-jinjaing the local .task.mk)
|
2022-09-14 13:49:25 -05:00
|
|
|
@./generate.py $(VERSION) > .task.mk || (echo "generator failed!!" && rm .task.mk)
|