-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
132 lines (110 loc) · 3.75 KB
/
Copy pathMakefile
File metadata and controls
132 lines (110 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
.ONESHELL:
DEBUG ?= false
VERBOSE ?= false
ifeq ($(DEBUG),true)
MAKEFLAGS += --debug=v
RM_FLAGS = -v
else
ifeq ($(VERBOSE),true)
MAKEFLAGS += --verbose
RM_FLAGS := -v
else
MAKEFLAGS += --silent
endif
endif
RM_FLAGS := -rf$(if $(or $(DEBUG),$(VERBOSE)),v,)
RM := rm $(RM_FLAGS)
PRECOMMIT ?= pre-commit
ifneq ($(shell command -v prek >/dev/null 2>&1 && echo y),)
PRECOMMIT := prek
ifneq ($(filter true,$(DEBUG) $(VERBOSE)),)
$(info Using prek for pre-commit checks)
ifeq ($(DEBUG),true)
PRECOMMIT := $(PRECOMMIT) -v
endif
endif
endif
# Terminal formatting (tput with fallbacks to ANSI codes)
_COLOR := $(shell tput sgr0 2>/dev/null || printf '\033[0m')
BOLD := $(shell tput bold 2>/dev/null || printf '\033[1m')
CYAN := $(shell tput setaf 6 2>/dev/null || printf '\033[0;36m')
GREEN := $(shell tput setaf 2 2>/dev/null || printf '\033[0;32m')
YELLOW := $(shell tput setaf 3 2>/dev/null || printf '\033[0;33m')
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show this help message
@echo "$(BOLD)Available targets:$(_COLOR)"
@grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "; max = 0} \
{if (length($$1) > max) max = length($$1)} \
{targets[NR] = $$0} \
END {for (i = 1; i <= NR; i++) { \
split(targets[i], arr, FS); \
printf "$(CYAN)%-*s$(_COLOR) %s\n", max + 2, arr[1], arr[2]}}'
@echo
@echo "$(BOLD)Environment variables:$(_COLOR)"
@echo " $(YELLOW)DEBUG$(_COLOR) = true|false Set to true to enable debug output (default: false)"
@echo " $(YELLOW)VERBOSE$(_COLOR) = true|false Set to true to enable verbose output (default: false)"
#######################
## Build and install ##
#######################
.PHONY: install
install: ## Install npm dependencies
npm install
.PHONY: develop
WITH_HOOKS ?= true
develop: install ## Set up for development (WITH_HOOKS={true|false}, default=true)
@if [ "$(WITH_HOOKS)" = "true" ]; then \
$(MAKE) enable-pre-commit; \
fi
.PHONY: build
build: install ## Build the action with ncc
npm run build
.PHONY: rebuild
rebuild: clean build ## Clean and build from scratch
#############
## Testing ##
#############
.PHONY: test
test: ## Run tests once
npm run test
.PHONY: test-watch
test-watch: ## Run tests in watch mode
npm run test:watch
.PHONY: lint
lint: ## Run ESLint
npm run lint
.PHONY: type-check
type-check: ## Run TypeScript type checking
npm run type-check
.PHONY: check
check: install run-pre-commit lint type-check test ## Run all checks (lint, type-check, tests)
.PHONY: clean
TO_REMOVE := \
coverage \
dist \
node_modules
clean: ## Remove build artifacts and temporary files
@echo $(TO_REMOVE) | xargs -n 1 -P 3 $(RM)
######################
## Pre-commit hooks ##
######################
.PHONY: enable-pre-commit
enable-pre-commit: ## Enable pre-commit hooks (along with commit-msg and pre-push hooks)
@if command -v pre-commit >/dev/null 2>&1; then \
pre-commit install; \
else \
echo "$(YELLOW)Warning: pre-commit is not installed. Skipping hook installation.$(_COLOR)"; \
echo "Install it with: pip install pre-commit (or brew install pre-commit on macOS)"; \
fi
.PHONY: disable-pre-commit
disable-pre-commit: ## Disable pre-commit hooks (removes commit-msg, pre-commit, pre-push, and prepare-commit-msg hooks)
@if command -v pre-commit >/dev/null 2>&1; then \
$(UV) run pre-commit uninstall; \
echo "$(BOLD)$(GREEN)Pre-commit hooks disabled.$(_COLOR)"; \
else \
echo "$(YELLOW)Warning: pre-commit is not installed. Nothing to disable.$(_COLOR)"; \
fi
.PHONY: run-pre-commit
run-pre-commit: ## Run the pre-commit checks
$(PRECOMMIT) run --all-files