mirror of
https://github.com/daylinmorgan/task.mk.git
synced 2025-02-05 09:14:17 -06:00
build: update project's make with a bunch of features
This commit is contained in:
parent
33eca2b52d
commit
3f32756fb4
1 changed files with 37 additions and 20 deletions
57
Makefile
57
Makefile
|
@ -2,13 +2,14 @@ VERSION ?= $(shell git describe --tags --always --dirty | sed s'/dirty/dev/')
|
||||||
TEMPLATES := $(shell find src/ -type f)
|
TEMPLATES := $(shell find src/ -type f)
|
||||||
.DEFAULT_GOAL := help
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
header = $(call tprint,{c.b_magenta}==>{c.end} {c.bold}$(1){c.end} {c.b_magenta}<=={c.end})
|
header = $(call tprint,{a.b_magenta}==>{a.end} {a.bold}$(1){a.end} {a.b_magenta}<=={a.end})
|
||||||
|
|
||||||
## bootstrap | generate local conda environment
|
## bootstrap | generate local dev environment
|
||||||
.PHONY: bootstrap
|
.PHONY: bootstrap
|
||||||
bootstrap:
|
bootstrap:
|
||||||
$(call header,Bootstrap Environment)
|
$(call header,Bootstrap Environment)
|
||||||
@mamba create -p ./env python jinja2 black
|
@mamba create -p ./env python jinja2 black -y
|
||||||
|
@mamba run -p ./env pip install yartsu
|
||||||
|
|
||||||
## lint | lint the python
|
## lint | lint the python
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
|
@ -16,7 +17,22 @@ lint:
|
||||||
@black generate.py
|
@black generate.py
|
||||||
@black src/*.py --fast
|
@black src/*.py --fast
|
||||||
|
|
||||||
## release | make new release of project
|
## assets | generate assets
|
||||||
|
.PHONY: assets
|
||||||
|
assets:
|
||||||
|
yartsu -o assets/help.svg -t "make help" -- make --no-print-directory help
|
||||||
|
|
||||||
|
define list_files_py
|
||||||
|
from pathlib import Path
|
||||||
|
print("files in $(2)")
|
||||||
|
print([f.name for f in (Path("$(2)").iterdir())])
|
||||||
|
endef
|
||||||
|
|
||||||
|
## list-% | use pathlib.Path to list files
|
||||||
|
list-%:
|
||||||
|
$(call py,list_files_py,$*)
|
||||||
|
|
||||||
|
## release | release new version of task.mk
|
||||||
.PHONY: release
|
.PHONY: release
|
||||||
release: version-check
|
release: version-check
|
||||||
$(call header,Release Project)
|
$(call header,Release Project)
|
||||||
|
@ -25,49 +41,50 @@ release: version-check
|
||||||
@git add task.mk README.md
|
@git add task.mk README.md
|
||||||
@git commit -m "release: v$(VERSION)"
|
@git commit -m "release: v$(VERSION)"
|
||||||
|
|
||||||
## clean | remove the generated files
|
## c, clean | remove the generated files
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
c clean:
|
||||||
@rm -f task.mk .task.mk
|
@rm -f task.mk .task.mk
|
||||||
|
|
||||||
|
|
||||||
.PHONY: version-check
|
.PHONY: version-check
|
||||||
version-check:
|
version-check:
|
||||||
@if [[ "${VERSION}" == *'-'* ]]; then\
|
@if [[ "${VERSION}" == *'-'* ]]; then\
|
||||||
$(call tprint-sh,{c.red}VERSION INVALID! Uncommited Work{c.end});\
|
$(call tprint-sh,{a.red}VERSION INVALID! Uncommited Work{a.end});\
|
||||||
echo ">> version: $(VERSION)"; exit 1;\
|
echo ">> version: $(VERSION)"; exit 1;\
|
||||||
elif [[ $(shell echo "${VERSION}" | awk -F. '{ print NF }') -lt 3 ]];then\
|
elif [[ $(shell echo "${VERSION}" | awk -F. '{ print NF }') -lt 3 ]];then\
|
||||||
$(call tprint-sh,{c.red}VERSION INVALID! Expected CalVer string{c.end});\
|
$(call tprint-sh,{a.red}VERSION INVALID! Expected CalVer string{a.end});\
|
||||||
echo ">> version: $(VERSION)"; exit 1;\
|
echo ">> version: $(VERSION)"; exit 1;\
|
||||||
else \
|
else \
|
||||||
$(call tprint-sh,{c.green}VERSION LOOKS GOOD!{c.end});\
|
$(call tprint-sh,{a.green}VERSION LOOKS GOOD!{a.end});\
|
||||||
fi
|
fi
|
||||||
|
|
||||||
define msg
|
define msg
|
||||||
{c.b_yellow}
|
{a.b_yellow}
|
||||||
It can even be multiline!{c.end}
|
It can even be multiline!{a.end}
|
||||||
and styles can be defined{c.end}
|
and styles can be defined{a.end}
|
||||||
as python {c.bold}f-string{c.end} literals
|
as python {a.bold}f-string{a.end} literals
|
||||||
{c.end}
|
{a.end}
|
||||||
endef
|
endef
|
||||||
|
|
||||||
## info | demonstarte usage of tprint
|
## info | demonsrtate usage of tprint
|
||||||
.PHONY: task
|
.PHONY: task
|
||||||
info:
|
info:
|
||||||
$(call header, Info Message)
|
$(call header, Info Message)
|
||||||
$(call tprint,{c.b_magenta}This is task-print output:{c.end})
|
$(call tprint,{a.b_magenta}This is task-print output:{a.end})
|
||||||
$(call tprint,$(msg))
|
$(call tprint,$(msg))
|
||||||
|
|
||||||
|
|
||||||
define USAGE
|
define USAGE
|
||||||
{c.$(HEADER_COLOR)}usage:{c.end}
|
{a.$(HEADER_COLOR)}usage:{a.end}
|
||||||
make <recipe>
|
make <recipe>
|
||||||
|
|
||||||
A usage statement...with {c.b_green}COLOR{c.end}
|
Turn your {a.b_magenta}`Makefile`{a.end} into
|
||||||
|
the {a.italic}{a.underline}task runner{a.end} you always needed.
|
||||||
|
See the example output below.
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
EPILOG = \nAn epilog...\nfor more help: see github.com/daylinmorgan/task.mk
|
EPILOG = \nfor more info: see github.com/daylinmorgan/task.mk
|
||||||
PRINT_VARS := VERSION
|
PRINT_VARS := VERSION
|
||||||
|
|
||||||
-include .task.mk
|
-include .task.mk
|
||||||
|
|
Loading…
Reference in a new issue