-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (49 loc) · 1.91 KB
/
Copy pathMakefile
File metadata and controls
62 lines (49 loc) · 1.91 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
# Makefile for Crater Monorepo
# 颜色定义
RED := \033[31m
GREEN := \033[32m
YELLOW := \033[33m
BLUE := \033[34m
MAGENTA := \033[35m
CYAN := \033[36m
WHITE := \033[37m
RESET := \033[0m
.PHONY: help
help: ## Display this help message
@echo "$(CYAN)🌋 Crater Monorepo Commands$(RESET)"
@echo ""
@awk 'BEGIN {FS = ":.*##"; category = ""} \
/^## / { category = substr($$0, 4); printf "\n$(BLUE)%s$(RESET)\n", category; next } \
/^[a-zA-Z_-]+:.*?##/ { printf " $(GREEN)%-20s$(RESET) %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
##@ Git Hooks
## Location to install git hooks to
GIT_HOOKS_DIR ?= $(shell git rev-parse --git-path hooks 2>/dev/null || echo ".git/hooks")
$(GIT_HOOKS_DIR):
@echo "$(BLUE)Creating git hooks directory...$(RESET)"
@mkdir -p $(GIT_HOOKS_DIR)
.PHONY: install-hooks
install-hooks: $(GIT_HOOKS_DIR)/pre-commit ## Install git hooks from .githook directory.
$(GIT_HOOKS_DIR)/pre-commit: $(GIT_HOOKS_DIR) .githook/pre-commit
@echo "$(BLUE)Installing git pre-commit hook...$(RESET)"
@cp .githook/pre-commit $(GIT_HOOKS_DIR)/pre-commit
@chmod +x $(GIT_HOOKS_DIR)/pre-commit
@echo "$(GREEN)✅ Git pre-commit hook installed successfully!$(RESET)"
.PHONY: pre-commit-check
pre-commit-check: install-hooks ## Run the installed pre-commit hook.
@echo "$(BLUE)Running pre-commit hook...$(RESET)"
@$(GIT_HOOKS_DIR)/pre-commit
##@ Configuration Management
.PHONY: config-link
config-link: ## Create symlinks for configuration files (usage: make config-link CONFIG_DIR=~/develop/crater/config)
@bash hack/config.sh link $(CONFIG_DIR)
.PHONY: config-status
config-status: ## Show status of configuration files
@bash hack/config.sh status
.PHONY: config-unlink
config-unlink: ## Remove configuration symlinks (only symlinks, not regular files)
@bash hack/config.sh unlink
.PHONY: config-restore
config-restore: ## Restore configuration files from .bak backups
@bash hack/config.sh restore
# 默认目标
.DEFAULT_GOAL := help