-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
254 lines (213 loc) · 8.48 KB
/
Copy pathMakefile
File metadata and controls
254 lines (213 loc) · 8.48 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
.PHONY: build release test clean run help install patch minor major link unlink dev which embeddings docs deps deps-install sdk-build sdk-test sdk-coverage sdk-publish sdk-publish-dry-run sdk-publish-next sdk-publish-next-dry-run sdk-version machine-output-audit machine-output-strict
# Paths
LOCAL_BIN := $(HOME)/.local/bin
CARGO_BIN := $(HOME)/.cargo/bin
LOCAL_BINARY := $(PWD)/target/release/redblue
# Default target
help:
@echo "RedBlue CLI - Makefile"
@echo ""
@echo "Available targets:"
@echo " make build - Build debug version"
@echo " make release - Build optimized release version"
@echo " make test - Run all tests"
@echo " make clean - Clean build artifacts"
@echo " make run - Run debug version (use ARGS='...')"
@echo " make install - Install to ~/.cargo/bin"
@echo " make deps - Check/Install build dependencies (Go, Ninja)"
@echo " make fmt - Format code"
@echo " make lint - Run clippy"
@echo " make check - Quick compile check"
@echo ""
@echo "Local Development:"
@echo " make link - Use local binary (symlink to ~/.local/bin/rb)"
@echo " make unlink - Use GitHub-installed version (remove local symlink)"
@echo " make dev - Build release + link local binary"
@echo " make which - Show which rb binary is in use"
@echo " make sdk-build - Validate the npm SDK package"
@echo " make sdk-test - Run SDK package tests"
@echo " make sdk-coverage - Run SDK package coverage with 100% thresholds"
@echo " make sdk-version VERSION=0.1.1 - Set the root npm package version"
@echo " make sdk-publish-dry-run VERSION=0.1.1 - Dry-run the root npm publish"
@echo " make sdk-publish VERSION=0.1.1 - Publish the root npm package to npm"
@echo " make sdk-publish-next-dry-run VERSION=0.1.1-next.123 - Dry-run the SDK npm @next publish"
@echo " make sdk-publish-next VERSION=0.1.1-next.123 - Publish the SDK package to npm with the next dist-tag"
@echo " make machine-output-audit - Check CLI machine-output regressions against baseline"
@echo " make machine-output-strict - Fail unless all direct JSON print offenders are gone"
@echo " make embeddings - Build documentation embeddings for MCP search"
@echo " make docs - Serve documentation locally at http://localhost:3000"
@echo ""
@echo "Release:"
@echo " make patch - Bump patch version (0.1.0 → 0.1.1)"
@echo " make minor - Bump minor version (0.1.0 → 0.2.0)"
@echo " make major - Bump major version (0.1.0 → 1.0.0)"
@echo ""
@echo "Examples:"
@echo " make run ARGS='dns record lookup google.com'"
@echo " make run ARGS='network ports scan 127.0.0.1 --preset common'"
@echo " make dev # then: rb --version"
# Build debug version
build:
cargo build
# Build release version (optimized)
release:
cargo build --release
@mkdir -p ./target/release
@cp ./sdk/redblue-sdk.js ./target/release/redblue-sdk.js
@echo ""
@echo "Release binary: ./target/release/redblue"
@echo "SDK wrapper: ./target/release/redblue-sdk.js"
@echo "Size: $$(du -h ./target/release/redblue | cut -f1)"
# Run tests
test:
cargo test
# Clean build artifacts
clean:
cargo clean
# Run debug version
run:
cargo run -- $(ARGS)
# Install to system
install: release
cargo install --path .
# Format code
fmt:
cargo fmt
# Run clippy linter
lint:
cargo clippy
# Quick compile check
check:
cargo check
# Run specific examples
dns:
cargo run -- dns record lookup $(DOMAIN)
scan:
cargo run -- network ports scan $(TARGET) --preset common
http:
cargo run -- web asset get $(URL)
# Benchmarks
bench-scan:
@echo "Benchmarking port scan..."
time ./target/release/redblue network ports range 127.0.0.1 1 1000
# Version management (triggers GitHub release)
patch:
@./scripts/release.sh patch
minor:
@./scripts/release.sh minor
major:
@./scripts/release.sh major
# Build static binary (if musl is available)
static:
cargo build --release --target x86_64-unknown-linux-musl
# ============================================================================
# Dependencies (BoringSSL/Chrome-Impersonation)
# ============================================================================
# Check build dependencies
deps:
@echo "Checking build dependencies for BoringSSL..."
@which go >/dev/null || { echo "❌ Go not found. Required for BoringSSL."; echo " Run 'make deps-install' or install manually."; exit 1; }
@which ninja >/dev/null || { echo "❌ Ninja not found. Required for BoringSSL."; echo " Run 'make deps-install' or install manually."; exit 1; }
@echo "✅ All dependencies found (Go, Ninja). Ready to build!"
# Install build dependencies (Linux/macOS)
deps-install:
@echo "Detected OS: $$(uname -s)"
@if [ "$$(uname -s)" = "Linux" ]; then \
echo "Installing dependencies (Linux)..."; \
sudo apt-get update && sudo apt-get install -y golang-go ninja-build; \
elif [ "$$(uname -s)" = "Darwin" ]; then \
echo "Installing dependencies (macOS)..."; \
brew install go ninja; \
else \
echo "Unsupported OS: $$(uname -s). Please install Go and Ninja manually."; \
fi
# ============================================================================
# Documentation & Embeddings
# ============================================================================
# Build documentation embeddings for MCP search
embeddings:
@echo "Building documentation embeddings..."
@if [ ! -d "venv" ]; then \
echo "Creating virtual environment..."; \
python3 -m venv venv; \
fi
@. venv/bin/activate && pip install -q fastembed && python scripts/build-embeddings.py
@echo "✓ Embeddings built: src/mcp/data/embeddings.json"
# Serve documentation locally (requires docsify index.html in docs/)
docs:
@echo "Serving documentation at http://localhost:3000"
@echo "Press Ctrl+C to stop"
@cd docs && python3 -m http.server 3000
# ============================================================================
# Local Development Workflow
# ============================================================================
# Link local binary to ~/.local/bin/rb (takes precedence over ~/.cargo/bin)
link: release
@mkdir -p $(LOCAL_BIN)
@if [ -L "$(LOCAL_BIN)/rb" ]; then \
rm "$(LOCAL_BIN)/rb"; \
fi
@ln -sf "$(LOCAL_BINARY)" "$(LOCAL_BIN)/rb"
@echo "✓ Linked: $(LOCAL_BIN)/rb → $(LOCAL_BINARY)"
@echo ""
@echo "Now using LOCAL binary. Verify with:"
@echo " which rb"
@echo " rb --version"
# Remove local symlink to use GitHub-installed version from ~/.cargo/bin
unlink:
@if [ -L "$(LOCAL_BIN)/rb" ]; then \
rm "$(LOCAL_BIN)/rb"; \
echo "✓ Removed local symlink: $(LOCAL_BIN)/rb"; \
echo ""; \
echo "Now using INSTALLED binary from ~/.cargo/bin"; \
echo " which rb"; \
echo " rb --version"; \
else \
echo "No local symlink found at $(LOCAL_BIN)/rb"; \
echo "Already using installed version."; \
fi
# Build and link in one step
dev: link
@echo ""
@echo "Development environment ready!"
@echo "Binary: $$(which rb)"
@echo "Version: $$(rb --version 2>/dev/null || echo 'run rb --version')"
# Show which rb binary is currently in use
which:
@echo "Current rb binary:"
@which rb 2>/dev/null || echo " rb not found in PATH"
@echo ""
@if [ -L "$(LOCAL_BIN)/rb" ]; then \
echo "Local symlink: $(LOCAL_BIN)/rb → $$(readlink $(LOCAL_BIN)/rb)"; \
echo "Status: Using LOCAL development binary"; \
elif [ -f "$(CARGO_BIN)/rb" ]; then \
echo "Installed binary: $(CARGO_BIN)/rb"; \
echo "Status: Using INSTALLED binary"; \
else \
echo "Status: rb not installed"; \
fi
sdk-build:
npm run build && npm run pack-check
sdk-test:
npm test
sdk-coverage:
npm run coverage
sdk-version:
@test -n "$(VERSION)" || (echo "Usage: make sdk-version VERSION=0.1.1" && exit 1)
npm version $(VERSION) --no-git-tag-version
sdk-publish-dry-run:
@test -n "$(VERSION)" || (echo "Usage: make sdk-publish-dry-run VERSION=0.1.1" && exit 1)
npm version $(VERSION) --no-git-tag-version && npm publish --dry-run
sdk-publish:
@test -n "$(VERSION)" || (echo "Usage: make sdk-publish VERSION=0.1.1" && exit 1)
npm version $(VERSION) --no-git-tag-version && npm publish
sdk-publish-next-dry-run:
@test -n "$(VERSION)" || (echo "Usage: make sdk-publish-next-dry-run VERSION=0.1.1-next.123" && exit 1)
npm version $(VERSION) --no-git-tag-version && npm publish --tag next --dry-run
sdk-publish-next:
@test -n "$(VERSION)" || (echo "Usage: make sdk-publish-next VERSION=0.1.1-next.123" && exit 1)
npm version $(VERSION) --no-git-tag-version && npm publish --tag next
machine-output-audit:
python3 scripts/check-machine-output.py
machine-output-strict:
python3 scripts/check-machine-output.py --strict