-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
166 lines (148 loc) · 4.51 KB
/
Copy pathMakefile
File metadata and controls
166 lines (148 loc) · 4.51 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Makefile.common - Shared Makefile targets for all utilities
include Makefile.common
.PHONY: test test-unit test-integration coverage coverage-unit coverage-integration
.PHONY: watch watch-unit watch-integration watch-all badge clean help test-shared-lib watch-shared-lib
# Default target
.DEFAULT_GOAL := help
help:
@echo "Server Utilities - Makefile Commands"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Available targets:"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
build:
@echo "Building all utilities..."
@for dir in */; do \
if [ -f "$$dir/Makefile" ]; then \
echo "Building $$dir..."; \
$(MAKE) -C "$$dir" build || exit 1; \
fi \
done
@echo "✅ Build complete"
## lint: Run linters (shellcheck, etc.) - Usage: make lint [MODULE=module-name]
lint:
@if [ -n "$(MODULE)" ]; then \
if [ ! -d "$(MODULE)" ]; then \
echo "Error: Module '$(MODULE)' not found"; \
exit 1; \
fi; \
echo "Running linters on $(MODULE)..."; \
echo "Checking shell scripts with shellcheck..."; \
find "$(MODULE)" -name "*.sh" -not -path "*/\.*" -not -path "*/node_modules/*" -exec shellcheck {} + || exit 1; \
if [ -f "$(MODULE)/Makefile" ]; then \
$(MAKE) -C "$(MODULE)" lint || exit 1; \
fi; \
echo "✅ Linting complete for $(MODULE)"; \
else \
echo "Running linters on all modules..."; \
echo "Checking shell scripts with shellcheck..."; \
find . -name "*.sh" -not -path "*/\.*" -not -path "*/node_modules/*" -exec shellcheck {} + || exit 1; \
for dir in */; do \
if [ -f "$$dir/Makefile" ]; then \
$(MAKE) -C "$$dir" lint || exit 1; \
fi \
done; \
echo "✅ Linting complete"; \
fi
install:
@echo "Installing utilities..."
@for dir in */; do \
if [ -f "$$dir/Makefile" ]; then \
echo "Installing $$dir..."; \
$(MAKE) -C "$$dir" install || exit 1; \
fi \
done
@echo "✅ Installation complete"
install-deps:
@echo "Installing development dependencies..."
@command -v shellcheck >/dev/null 2>&1 || { \
echo "Installing shellcheck..."; \
if command -v brew >/dev/null 2>&1; then \
brew install shellcheck; \
elif command -v apt-get >/dev/null 2>&1; then \
sudo apt-get install -y shellcheck; \
else \
echo "Please install shellcheck manually"; \
exit 1; \
fi \
}
@command -v bats >/dev/null 2>&1 || { \
echo "Installing bats..."; \
if command -v brew >/dev/null 2>&1; then \
brew install bats-core; \
elif command -v apt-get >/dev/null 2>&1; then \
sudo apt-get install -y bats; \
else \
echo "Please install bats manually"; \
exit 1; \
fi \
}
@echo "✅ Dependencies installed"
clean:
@echo "Cleaning build artifacts..."
@for dir in */; do \
if [ -f "$$dir/Makefile" ]; then \
$(MAKE) -C "$$dir" clean || true; \
fi \
done
@find . -name "*.log" -delete
@find . -name "*.tmp" -delete
@echo "✅ Clean complete"
release:
@if [ -z "$(VERSION)" ]; then \
echo "Error: VERSION not specified"; \
echo "Usage: make release VERSION=1.2.3"; \
exit 1; \
fi
@echo "Creating release $(VERSION)..."
@git tag -a "v$(VERSION)" -m "Release version $(VERSION)"
@git push origin "v$(VERSION)"
@echo "✅ Release v$(VERSION) created"
coverage:
@echo "Generating coverage reports..."
@for dir in */; do \
if [ -f "$$dir/Makefile" ]; then \
$(MAKE) -C "$$dir" coverage || true; \
fi \
done
@echo "✅ Coverage reports generated"
docs:
@echo "Generating documentation..."
@echo "Documentation is in README.md files"
@echo "✅ Documentation complete"
format:
@echo "Formatting code..."
@find . -name "*.sh" -not -path "*/\.*" -not -path "*/node_modules/*" -exec shfmt -w {} +
@echo "✅ Formatting complete"
security:
@echo "Running security checks..."
@echo "Checking for common security issues..."
@find . -name "*.sh" -not -path "*/\.*" -exec grep -Hn "eval" {} + || true
@echo "✅ Security check complete"
update:
@echo "Updating dependencies..."
@git pull origin main
@echo "✅ Dependencies updated"
test-shared-lib:
@echo "Running shared library tests..."
@if [ -d "tests/lib" ]; then \
for test_file in tests/lib/test_*.sh; do \
if [ -f "$$test_file" ]; then \
echo "Running $$(basename $$test_file)..."; \
bash "$$test_file" || exit 1; \
fi \
done; \
echo "✅ All shared library tests passed"; \
else \
echo "⚠️ tests/lib/ directory not found"; \
exit 1; \
fi
watch-shared-lib:
@echo "Starting test watcher for shared libraries..."
@if [ -f "tests/watch.sh" ]; then \
./tests/watch.sh shared-lib; \
else \
echo "Error: tests/watch.sh not found"; \
exit 1; \
fi