mirror of
https://github.com/daylinmorgan/viv.git
synced 2024-12-21 18:20:45 -06:00
build: why make when we can do
This commit is contained in:
parent
8c8bd616af
commit
726cef3092
3 changed files with 45 additions and 34 deletions
|
@ -1,6 +0,0 @@
|
|||
USAGE={a.bold}{a.cyan} viv tasks{a.end}:\n
|
||||
PHONIFY=1
|
||||
HELP_SEP={a.b_blue}>>>{a.end}
|
||||
|
||||
-include .task.mk
|
||||
$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v23.1.2/task.mk -o .task.mk)
|
28
Makefile
28
Makefile
|
@ -1,28 +0,0 @@
|
|||
VERSION ?= $(shell git describe --tags --always --dirty=-dev | sed 's/^v//g')
|
||||
|
||||
venv: ## generate environment
|
||||
pdm install
|
||||
|
||||
assets/viv-help.svg:
|
||||
FORCE_COLOR=1 viv --help | yartsu -t 'viv --help' -w 70 -o $@
|
||||
|
||||
.PHONY: dev-install
|
||||
dev-install:
|
||||
ln -sf $(PWD)/src/viv/viv.py ~/.local/share/viv/viv.py
|
||||
|
||||
examples/black: .FORCE
|
||||
rm -f $@
|
||||
viv shim black -y -s -f -o $@
|
||||
|
||||
clean: ## remove build artifacts
|
||||
rm -rf build dist
|
||||
|
||||
EXAMPLES = cli.py sys_path.py exe_specific.py frozen_import.py named_env.py scrape.py
|
||||
generate-example-vivens: ##
|
||||
for f in $(EXAMPLES); \
|
||||
do python examples/$$f; done
|
||||
|
||||
|
||||
.FORCE:
|
||||
.PHONY: .FORCE
|
||||
-include .task.cfg.mk
|
45
task
Executable file
45
task
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# VERSION = $(git describe --tags --always --dirty=-dev | sed 's/^v//g')
|
||||
|
||||
function task:venv {
|
||||
: "setup up pdm venv"
|
||||
pdm install
|
||||
}
|
||||
|
||||
function task:dev-install {
|
||||
: "symlink development version"
|
||||
ln -sf "$(PWD)/src/viv/viv.py" ~/.local/share/viv/viv.py
|
||||
}
|
||||
|
||||
function task:_black {
|
||||
: "generate black example shim"
|
||||
rm -f examples/black
|
||||
viv shim black -y -s -f -o examples/black
|
||||
}
|
||||
|
||||
function task:clean {
|
||||
: "clean build artifacts"
|
||||
rm -rf build dist
|
||||
}
|
||||
|
||||
function task:examples {
|
||||
: "run examples to generate vivenvs"
|
||||
examples="cli sys_path exe_specific frozen_import named_env scrape"
|
||||
for f in $examples; do
|
||||
python "examples/$f.py"
|
||||
done
|
||||
}
|
||||
|
||||
function task:_help-logo {
|
||||
FORCE_COLOR=1 viv --help | yartsu -t 'viv --help' -w 70 -o assets/viv-help.svg
|
||||
}
|
||||
|
||||
# ---- do-task boilerplate ----
|
||||
function task:help {
|
||||
: "Show this help"
|
||||
echo "do:";w=$(("$(compgen -A function | wc -L)" - 3));while read -r name; do [[ ! $name =~ ^task:_ ]] && [[ $name =~ ^task: ]] && paste <(printf '\033[1;32m%*s\033[0m\n' "$w" "${name#task:}") <(type "$name" | sed -nEe 's/^[[:space:]]*: ?"(.*)";/\1/p'); done < <(compgen -A function)
|
||||
}
|
||||
while read -r name; do [[ $name == "task:$1" ]] && { shift; task="$name"; }; done < <(compgen -A function)
|
||||
[[ -n "$1" && -z "$task" ]] && printf "\033[1;31m%s\033\0[m is not a task\n" "$1"
|
||||
"${task:-task:help}" "$@" && exit "$?"
|
Loading…
Reference in a new issue