2023-01-20 12:35:52 -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
|
2023-01-19 19:38:49 -06:00
|
|
|
bootstrap: env hooks ## generate local dev environment |> -ms b_magenta -gs b_cyan
|
2023-01-21 00:38:31 -06:00
|
|
|
env: ##
|
2022-09-22 10:49:14 -05:00
|
|
|
$(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
|
2023-01-21 00:38:31 -06:00
|
|
|
hooks: ##
|
2022-09-07 15:48:46 -05:00
|
|
|
@git config core.hooksPath .githooks
|
2023-01-21 00:38:31 -06:00
|
|
|
docs-env: ##
|
2022-09-24 17:55:52 -05:00
|
|
|
@mamba run -p ./env pip install mkdocs-material mkdocs-git-revision-date-localized-plugin
|
2023-01-19 12:54:57 -06:00
|
|
|
|
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
|
|
|
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
|
2023-01-20 13:29:42 -06:00
|
|
|
sed -i 's/TASKMK_VERSION=.*/TASKMK_VERSION=$(VERSION)/' docs/init
|
2023-01-19 14:32:20 -06:00
|
|
|
git add task.mk README.md docs/index.md
|
|
|
|
git commit -m "release: $(VERSION)" --no-verify
|
|
|
|
git tag $(VERSION)
|
|
|
|
endef
|
|
|
|
|
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
|
|
|
|
2023-01-19 19:38:49 -06:00
|
|
|
c clean: ## remove the generated files
|
2023-01-21 00:38:31 -06:00
|
|
|
@rm -f .task.mk
|
2022-09-14 00:03:29 -05:00
|
|
|
|
2023-01-19 13:43:29 -06:00
|
|
|
define version_check_sh
|
2023-01-20 12:45:36 -06:00
|
|
|
if git rev-parse -q --verify "refs/tags/${VERSION}" >/dev/null; then
|
|
|
|
$(call tprint-verbose,{a.red}VERSION INVALID!{a.end} tag already exists); exit 1;
|
|
|
|
elif [[ "${VERSION}" == *'-'* ]]; then
|
|
|
|
$(call tprint-verbose,{a.red}VERSION INVALID!{a.end} Uncommited or untagged work); exit 1;
|
2023-01-19 13:43:29 -06:00
|
|
|
exit 1
|
|
|
|
elif [[ $(shell echo "${VERSION}" | awk -F. '{ print NF }') -lt 3 ]];then\
|
2023-01-20 12:37:00 -06:00
|
|
|
$(call tprint-verbose,{a.red}VERSION INVALID!{a.end} Expected CalVer string)
|
2023-01-19 13:43:29 -06:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
endef
|
|
|
|
|
2023-01-21 00:38:31 -06:00
|
|
|
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
|
|
|
|
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
|
|
|
|
2023-01-20 12:19:35 -06:00
|
|
|
-include .task.cfg.mk .task.mk
|
2022-09-05 12:23:17 -05:00
|
|
|
.task.mk: $(TEMPLATES) generate.py
|
2023-01-21 00:38:31 -06:00
|
|
|
$(call msg,re-jinjaing the local {a.b_cyan}.task.mk{a.end})
|
2022-09-14 13:49:25 -05:00
|
|
|
@./generate.py $(VERSION) > .task.mk || (echo "generator failed!!" && rm .task.mk)
|