chore: makefile utilities

This commit is contained in:
2025-12-20 16:09:15 +01:00
parent f324854d42
commit 6f3ac01245
3 changed files with 46 additions and 2 deletions
+40
View File
@@ -0,0 +1,40 @@
ifeq ($(shell which bun &>/dev/null && echo 1 || echo 0), 1)
NPM ?= bun
endif
NPM ?= npm
.PHONY: help
help: ## show this message
@echo "Usage: make [target1] (target2) ..."
@echo ""
@echo "Commands/Targets:"
@grep -E '(^[a-zA-Z0-9_%-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-20s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
@echo ""
@echo "Environment:"
@grep -E '^[a-zA-Z0-9_-]+\s*[?:]?=.*$$' $(MAKEFILE_LIST) | grep -Eo '^[a-zA-Z0-9_-]+' | xargs -I {} make -s print-{}
.PHONY: print-%
print-%:
@echo -e '\033[32m$*\033[0m = $($*)'
build: ## build static site in "dist"
@$(NPM) run build
.PHONY: run
def: ## run dev version of static site
@$(NPM) run dev
lint: ## lint code
@$(NPM) run lint
fix: ## fix and reformat code
@$(NPM) run format
@$(NPM) run lint-fix
rebase-template: ## update code from template
@(git remote | grep template &>/dev/null) || git remote add template https://github.com/klemek/vue-boilerplate.git
git fetch template
git rebase template/master