RESET := \033[0m
BOLD := \033[1m
RED := \033[31m
GREEN := \033[32m
YELLOW := \033[33m
BLUE := \033[34m
MAGENTA := \033[35m
CYAN := \033[36m
PROJECT_NAME := telemetry-kit
VERSION := $(shell grep '^version' Cargo.toml | head -1 | cut -d '"' -f 2)
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS_TYPE := linux
endif
ifeq ($(UNAME_S),Darwin)
OS_TYPE := macos
endif
.DEFAULT_GOAL := help
.PHONY: help
help:
@echo ""
@echo " $(BOLD)$(CYAN)๐ญ $(PROJECT_NAME) v$(VERSION)$(RESET)"
@echo " $(YELLOW)Privacy-first telemetry toolkit for Rust$(RESET)"
@echo ""
@awk 'BEGIN {FS = ":.*##"; printf "$(BOLD)Usage:$(RESET)\n make $(CYAN)<target>$(RESET)\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " $(CYAN)%-20s$(RESET) %s\n", $$1, $$2 } /^##@/ { printf "\n$(BOLD)%s$(RESET)\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
@echo ""
.PHONY: info
info:
@echo "$(BOLD)$(CYAN)Project Information$(RESET)"
@echo " Name: $(PROJECT_NAME)"
@echo " Version: $(VERSION)"
@echo " OS: $(OS_TYPE)"
@echo " Rust: $(shell rustc --version 2>/dev/null || echo 'not installed')"
@echo " Cargo: $(shell cargo --version 2>/dev/null || echo 'not installed')"
@echo ""
.PHONY: setup
setup:
@echo "$(CYAN)๐ Setting up development environment...$(RESET)"
@chmod +x scripts/*.sh
@./scripts/dev-setup.sh
.PHONY: dev
dev:
@echo "$(CYAN)๐ Starting development mode with auto-reload...$(RESET)"
@cargo watch -x 'test --lib' -x 'clippy'
.PHONY: build
build:
@echo "$(CYAN)๐จ Building project...$(RESET)"
@cargo build
@echo "$(GREEN)โ
Build complete$(RESET)"
.PHONY: build-release
build-release:
@echo "$(CYAN)๐ Building release binary...$(RESET)"
@cargo build --release
@echo "$(GREEN)โ
Release build complete$(RESET)"
@ls -lh target/release/$(PROJECT_NAME) 2>/dev/null || true
.PHONY: build-all
build-all:
@echo "$(CYAN)๐๏ธ Building all targets...$(RESET)"
@cargo build --all-targets
@echo "$(GREEN)โ
All targets built$(RESET)"
.PHONY: clean
clean:
@echo "$(CYAN)๐งน Cleaning build artifacts...$(RESET)"
@cargo clean
@rm -rf coverage/
@echo "$(GREEN)โ
Clean complete$(RESET)"
.PHONY: test
test:
@echo "$(CYAN)๐งช Running tests...$(RESET)"
@cargo test
@echo "$(GREEN)โ
Tests passed$(RESET)"
.PHONY: test-all
test-all:
@echo "$(CYAN)๐ฌ Running comprehensive test suite...$(RESET)"
@./scripts/test-all.sh
.PHONY: test-unit
test-unit:
@echo "$(CYAN)๐งช Running unit tests...$(RESET)"
@cargo test --lib
@echo "$(GREEN)โ
Unit tests passed$(RESET)"
.PHONY: test-integration
test-integration:
@echo "$(CYAN)๐ Running integration tests...$(RESET)"
@cargo test --test '*'
@echo "$(GREEN)โ
Integration tests passed$(RESET)"
.PHONY: test-doc
test-doc:
@echo "$(CYAN)๐ Running documentation tests...$(RESET)"
@cargo test --doc
@echo "$(GREEN)โ
Doc tests passed$(RESET)"
.PHONY: test-watch
test-watch:
@echo "$(CYAN)๐ Watching for changes and running tests...$(RESET)"
@cargo watch -x test
.PHONY: coverage
coverage:
@echo "$(CYAN)๐ Generating code coverage...$(RESET)"
@cargo tarpaulin --out Html --output-dir coverage
@echo "$(GREEN)โ
Coverage report generated: coverage/index.html$(RESET)"
.PHONY: fmt
fmt:
@echo "$(CYAN)๐จ Formatting code...$(RESET)"
@cargo fmt
@echo "$(GREEN)โ
Code formatted$(RESET)"
.PHONY: fmt-check
fmt-check:
@echo "$(CYAN)๐ Checking code formatting...$(RESET)"
@cargo fmt -- --check
@echo "$(GREEN)โ
Formatting check passed$(RESET)"
.PHONY: lint
lint:
@echo "$(CYAN)๐ Running clippy lints...$(RESET)"
@cargo clippy --all-features --all-targets -- -D warnings
@echo "$(GREEN)โ
Lints passed$(RESET)"
.PHONY: lint-fix
lint-fix:
@echo "$(CYAN)๐ง Auto-fixing clippy warnings...$(RESET)"
@cargo clippy --fix --allow-dirty --allow-staged
@echo "$(GREEN)โ
Fixes applied$(RESET)"
.PHONY: check
check:
@echo "$(CYAN)โ
Running cargo check...$(RESET)"
@cargo check --all-features --all-targets
@echo "$(GREEN)โ
Check passed$(RESET)"
.PHONY: doc
doc:
@echo "$(CYAN)๐ Building documentation...$(RESET)"
@cargo doc --no-deps --document-private-items
@echo "$(GREEN)โ
Documentation built$(RESET)"
.PHONY: doc-open
doc-open:
@echo "$(CYAN)๐ Building and opening documentation...$(RESET)"
@cargo doc --no-deps --document-private-items --open
.PHONY: doc-check
doc-check:
@echo "$(CYAN)๐ Checking documentation...$(RESET)"
@RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --document-private-items
@echo "$(GREEN)โ
Documentation check passed$(RESET)"
.PHONY: audit
audit:
@echo "$(CYAN)๐ Running security audit...$(RESET)"
@cargo audit
@echo "$(GREEN)โ
Security audit complete$(RESET)"
.PHONY: deny-check
deny-check:
@echo "$(CYAN)๐ซ Checking dependency policy...$(RESET)"
@cargo deny check
@echo "$(GREEN)โ
Dependency policy check passed$(RESET)"
.PHONY: outdated
outdated:
@echo "$(CYAN)๐ฆ Checking for outdated dependencies...$(RESET)"
@cargo outdated
@echo "$(GREEN)โ
Outdated check complete$(RESET)"
.PHONY: update
update:
@echo "$(CYAN)๐ Updating dependencies...$(RESET)"
@cargo update
@echo "$(GREEN)โ
Dependencies updated$(RESET)"
.PHONY: example-basic
example-basic:
@echo "$(CYAN)๐ฏ Running basic example...$(RESET)"
@cargo run --example basic
.PHONY: example-local
example-local:
@echo "$(CYAN)๐พ Running local-only example...$(RESET)"
@cargo run --example local_only
.PHONY: example-sync
example-sync:
@echo "$(CYAN)๐ Running sync example...$(RESET)"
@cargo run --example sync_example
.PHONY: example-e2e
example-e2e:
@echo "$(CYAN)๐ Running end-to-end sync test...$(RESET)"
@echo "$(YELLOW)โ ๏ธ Make sure server is running: cd server && docker compose up -d$(RESET)"
@cargo run --example e2e_sync_test
.PHONY: examples
examples:
@echo "$(CYAN)๐ฆ Building all examples...$(RESET)"
@cargo build --examples
@echo "$(GREEN)โ
All examples built$(RESET)"
.PHONY: server-up
server-up:
@echo "$(CYAN)๐ Starting server...$(RESET)"
@cd server && docker compose up -d
@echo "$(GREEN)โ
Server started$(RESET)"
@echo "$(YELLOW)๐ Server running at http://localhost:8080$(RESET)"
.PHONY: server-down
server-down:
@echo "$(CYAN)โฌ๏ธ Stopping server...$(RESET)"
@cd server && docker compose down
@echo "$(GREEN)โ
Server stopped$(RESET)"
.PHONY: server-logs
server-logs:
@echo "$(CYAN)๐ Server logs (Ctrl+C to exit):$(RESET)"
@cd server && docker compose logs -f
.PHONY: server-restart
server-restart:
@echo "$(CYAN)๐ Restarting server...$(RESET)"
@cd server && docker compose restart
@echo "$(GREEN)โ
Server restarted$(RESET)"
.PHONY: server-build
server-build:
@echo "$(CYAN)๐จ Building server Docker image...$(RESET)"
@cd server && docker compose build
@echo "$(GREEN)โ
Server image built$(RESET)"
.PHONY: server-clean
server-clean:
@echo "$(CYAN)๐งน Cleaning server data...$(RESET)"
@cd server && docker compose down -v
@echo "$(GREEN)โ
Server data cleaned$(RESET)"
.PHONY: check-sync
check-sync:
@echo "$(CYAN)๐ Checking schema synchronization...$(RESET)"
@./scripts/check-sync.sh
.PHONY: sync-status
sync-status:
@echo "$(CYAN)๐ Sync status:$(RESET)"
@echo ""
@echo "$(BOLD)Public Repo:$(RESET) $(shell pwd)"
@echo " Version: $(VERSION)"
@echo " Schema: $(shell grep -o 'SCHEMA_VERSION.*=.*"[0-9.]*"' src/event.rs | grep -o '[0-9.]*' || echo 'unknown')"
@echo ""
@if [ -d "$$HOME/Dev/telemetry-kit.dev" ]; then \
echo "$(BOLD)Private Repo:$(RESET) $$HOME/Dev/telemetry-kit.dev"; \
echo " Status: Found โ
"; \
else \
echo "$(BOLD)Private Repo:$(RESET) Not found โ ๏ธ"; \
fi
@echo ""
.PHONY: git-status
git-status:
@echo "$(CYAN)๐ Git status:$(RESET)"
@git status
.PHONY: commit-phase1
commit-phase1:
@echo "$(CYAN)๐พ Committing Phase 1 changes...$(RESET)"
@git add .
@git commit -m "feat: Phase 1 complete - foundation & infrastructure\n\nBREAKING CHANGE: Version bump from 0.0.1 to 0.2.0-alpha.1\n\nThis is the first functional alpha release with working SDK and\nsync protocol. Not suitable for production use yet.\n\nInfrastructure:\n- CI/CD pipeline fixed and enhanced (6 jobs)\n- Security scanning and vulnerability disclosure\n- Development tooling and helper scripts\n- Comprehensive documentation and roadmap\n\nSee PRODUCTION_PLAN.md for roadmap to v1.0.0."
@echo "$(GREEN)โ
Changes committed$(RESET)"
@echo "$(YELLOW)๐ก Run 'make push' to push to remote$(RESET)"
.PHONY: push
push:
@echo "$(CYAN)โฌ๏ธ Pushing to remote...$(RESET)"
@git push origin main
@echo "$(GREEN)โ
Pushed to remote$(RESET)"
.PHONY: tag
tag:
@echo "$(CYAN)๐ท๏ธ Creating tag v$(VERSION)...$(RESET)"
@git tag -a v$(VERSION) -m "Release v$(VERSION)"
@git push origin v$(VERSION)
@echo "$(GREEN)โ
Tag v$(VERSION) created and pushed$(RESET)"
MACROS_VERSION := $(shell grep '^version' telemetry-kit-macros/Cargo.toml | head -1 | cut -d '"' -f 2)
.PHONY: publish-check
publish-check:
@echo "$(CYAN)โ
Checking if ready to publish...$(RESET)"
@cargo publish --dry-run
@echo "$(GREEN)โ
Publish check passed$(RESET)"
.PHONY: publish-macros-check
publish-macros-check:
@echo "$(CYAN)โ
Checking macros crate...$(RESET)"
@cargo publish -p telemetry-kit-macros --dry-run
@echo "$(GREEN)โ
Macros publish check passed$(RESET)"
.PHONY: publish-macros
publish-macros:
@echo "$(CYAN)๐ฆ Publishing telemetry-kit-macros v$(MACROS_VERSION) to crates.io...$(RESET)"
@echo "$(YELLOW)โ ๏ธ This will publish telemetry-kit-macros v$(MACROS_VERSION)$(RESET)"
@read -p "Continue? [y/N] " -n 1 -r; \
echo; \
if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
cargo publish -p telemetry-kit-macros; \
echo "$(GREEN)โ
telemetry-kit-macros published$(RESET)"; \
else \
echo "$(YELLOW)โ Publish cancelled$(RESET)"; \
fi
.PHONY: publish
publish:
@echo "$(CYAN)๐ฆ Publishing to crates.io...$(RESET)"
@echo "$(YELLOW)โ ๏ธ This will publish version $(VERSION) to crates.io$(RESET)"
@read -p "Continue? [y/N] " -n 1 -r; \
echo; \
if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
cargo publish; \
echo "$(GREEN)โ
Published to crates.io$(RESET)"; \
else \
echo "$(YELLOW)โ Publish cancelled$(RESET)"; \
fi
.PHONY: publish-all
publish-all:
@echo "$(BOLD)$(CYAN)๐ Publishing all crates to crates.io$(RESET)"
@echo ""
@echo "$(BOLD)Step 1: Sync versions$(RESET)"
@echo " Main crate: v$(VERSION)"
@echo " Macros crate: v$(MACROS_VERSION)"
@echo ""
@if [ "$(VERSION)" != "$(MACROS_VERSION)" ]; then \
echo "$(RED)โ Version mismatch! Please ensure both crates have the same version.$(RESET)"; \
echo "$(YELLOW) Update telemetry-kit-macros/Cargo.toml version to $(VERSION)$(RESET)"; \
exit 1; \
fi
@echo "$(GREEN)โ
Versions match$(RESET)"
@echo ""
@echo "$(BOLD)Step 2: Pre-publish checks$(RESET)"
@cargo publish -p telemetry-kit-macros --dry-run
@echo "$(GREEN)โ
Macros crate ready$(RESET)"
@echo ""
@echo "$(BOLD)Step 3: Publish telemetry-kit-macros$(RESET)"
@echo "$(YELLOW)โ ๏ธ About to publish telemetry-kit-macros v$(VERSION) to crates.io$(RESET)"
@read -p "Publish macros crate? [y/N] " -n 1 -r; \
echo; \
if [[ ! $$REPLY =~ ^[Yy]$$ ]]; then \
echo "$(YELLOW)โ Publish cancelled$(RESET)"; \
exit 1; \
fi
@cargo publish -p telemetry-kit-macros
@echo "$(GREEN)โ
telemetry-kit-macros v$(VERSION) published$(RESET)"
@echo ""
@echo "$(BOLD)Step 4: Wait for crates.io to index (30 seconds)...$(RESET)"
@echo "$(YELLOW)โณ Waiting for crates.io to index the macros crate...$(RESET)"
@sleep 30
@echo "$(GREEN)โ
Wait complete$(RESET)"
@echo ""
@echo "$(BOLD)Step 5: Publish telemetry-kit$(RESET)"
@echo "$(YELLOW)โ ๏ธ About to publish telemetry-kit v$(VERSION) to crates.io$(RESET)"
@read -p "Publish main crate? [y/N] " -n 1 -r; \
echo; \
if [[ ! $$REPLY =~ ^[Yy]$$ ]]; then \
echo "$(YELLOW)โ Publish cancelled$(RESET)"; \
exit 1; \
fi
@cargo publish
@echo ""
@echo "$(GREEN)$(BOLD)๐ All crates published successfully!$(RESET)"
@echo ""
@echo " ๐ฆ telemetry-kit-macros v$(VERSION)"
@echo " ๐ฆ telemetry-kit v$(VERSION)"
@echo ""
@echo "$(CYAN)View on crates.io:$(RESET)"
@echo " https://crates.io/crates/telemetry-kit-macros"
@echo " https://crates.io/crates/telemetry-kit"
@echo ""
.PHONY: publish-status
publish-status:
@echo "$(BOLD)$(CYAN)๐ Publish Status$(RESET)"
@echo ""
@echo "$(BOLD)Local versions:$(RESET)"
@echo " telemetry-kit: v$(VERSION)"
@echo " telemetry-kit-macros: v$(MACROS_VERSION)"
@echo ""
@if [ "$(VERSION)" = "$(MACROS_VERSION)" ]; then \
echo "$(GREEN)โ
Versions are in sync$(RESET)"; \
else \
echo "$(RED)โ Version mismatch - sync before publishing$(RESET)"; \
fi
@echo ""
@echo "$(BOLD)Crates.io status:$(RESET)"
@echo " Check: https://crates.io/crates/telemetry-kit"
@echo " Check: https://crates.io/crates/telemetry-kit-macros"
@echo ""
.PHONY: version-sync
version-sync:
@echo "$(CYAN)๐ Syncing versions...$(RESET)"
@echo " Main crate version: $(VERSION)"
@echo " Updating telemetry-kit-macros to v$(VERSION)..."
@sed -i '' 's/^version = ".*"/version = "$(VERSION)"/' telemetry-kit-macros/Cargo.toml
@echo "$(GREEN)โ
Macros version updated to $(VERSION)$(RESET)"
@echo ""
@echo "$(YELLOW)๐ Also update the dependency version in main Cargo.toml:$(RESET)"
@grep "telemetry-kit-macros" Cargo.toml
@echo ""
.PHONY: bench
bench:
@echo "$(CYAN)๐ Running benchmarks...$(RESET)"
@cargo bench
@echo "$(GREEN)โ
Benchmarks complete$(RESET)"
.PHONY: ci
ci: fmt-check lint test doc-check
@echo ""
@echo "$(GREEN)โ
CI simulation passed$(RESET)"
.PHONY: ci-full
ci-full: fmt-check lint test doc-check audit deny-check
@echo ""
@echo "$(GREEN)โ
Full CI simulation passed$(RESET)"
.PHONY: install-tools
install-tools:
@echo "$(CYAN)๐ ๏ธ Installing development tools...$(RESET)"
@cargo install cargo-audit cargo-deny cargo-tarpaulin cargo-watch cargo-outdated
@echo "$(GREEN)โ
Tools installed$(RESET)"
.PHONY: deps
deps:
@echo "$(CYAN)๐ฆ Dependency tree:$(RESET)"
@cargo tree
.PHONY: bloat
bloat:
@echo "$(CYAN)๐ Analyzing binary size...$(RESET)"
@cargo bloat --release
.PHONY: lines
lines:
@echo "$(CYAN)๐ Lines of code:$(RESET)"
@echo ""
@echo "$(BOLD)Source code:$(RESET)"
@find src -name '*.rs' | xargs wc -l | tail -1
@echo ""
@echo "$(BOLD)Server code:$(RESET)"
@find server/src -name '*.rs' 2>/dev/null | xargs wc -l 2>/dev/null | tail -1 || echo " N/A"
@echo ""
@echo "$(BOLD)Tests:$(RESET)"
@find tests -name '*.rs' 2>/dev/null | xargs wc -l 2>/dev/null | tail -1 || echo " N/A"
@echo ""
@echo "$(BOLD)Total:$(RESET)"
@find . -name '*.rs' -not -path "./target/*" -not -path "./server/target/*" | xargs wc -l | tail -1
.PHONY: todos
todos:
@echo "$(CYAN)๐ TODO comments:$(RESET)"
@grep -rn "TODO\|FIXME\|XXX\|HACK" src/ --color=always || echo " None found โ
"
.PHONY: workspace-build
workspace-build:
@echo "$(CYAN)๐๏ธ Building workspace...$(RESET)"
@cargo build --workspace
@echo "$(GREEN)โ
Workspace built$(RESET)"
.PHONY: workspace-test
workspace-test:
@echo "$(CYAN)๐งช Testing workspace...$(RESET)"
@cargo test --workspace
@echo "$(GREEN)โ
Workspace tests passed$(RESET)"
.PHONY: workspace-clean
workspace-clean:
@echo "$(CYAN)๐งน Cleaning workspace...$(RESET)"
@cargo clean
@cd server && cargo clean
@echo "$(GREEN)โ
Workspace cleaned$(RESET)"
.PHONY: quick-test
quick-test: fmt lint test
@echo ""
@echo "$(GREEN)โ
Quick test passed$(RESET)"
.PHONY: quick-fix
quick-fix: fmt lint-fix
@echo ""
@echo "$(GREEN)โ
Code fixed$(RESET)"
.PHONY: pre-commit
pre-commit: fmt-check lint test
@echo ""
@echo "$(GREEN)โ
Pre-commit checks passed$(RESET)"
.PHONY: pre-push
pre-push: ci
@echo ""
@echo "$(GREEN)โ
Pre-push checks passed$(RESET)"
.PHONY: ascii-art
ascii-art:
@echo ""
@echo "$(CYAN)"
@echo " โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
@echo " โ โ"
@echo " โ ๐ญ telemetry-kit ๐ญ โ"
@echo " โ โ"
@echo " โ Privacy-first telemetry for Rust apps โ"
@echo " โ โ"
@echo " โ Version $(VERSION) โ"
@echo " โ โ"
@echo " โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
@echo "$(RESET)"
@echo ""
.PHONY: coffee
coffee:
@echo ""
@echo "$(YELLOW)โ Time for a coffee break!$(RESET)"
@echo "$(CYAN)You've been working hard. Take 5 minutes.$(RESET)"
@echo ""
@sleep 1
@echo "$(GREEN)โ
Back to coding in 5... 4... 3... 2... 1...$(RESET)"
@echo ""
.PHONY: stats
stats:
@echo "$(BOLD)$(CYAN)๐ Project Statistics$(RESET)"
@echo ""
@echo "$(BOLD)Version:$(RESET) $(VERSION)"
@echo "$(BOLD)Rust Files:$(RESET) $(shell find src -name '*.rs' | wc -l | xargs)"
@echo "$(BOLD)Lines of Code:$(RESET) $(shell find src -name '*.rs' | xargs wc -l | tail -1 | awk '{print $$1}')"
@echo "$(BOLD)Tests:$(RESET) $(shell grep -r "^#\[test\]" src tests 2>/dev/null | wc -l | xargs)"
@echo "$(BOLD)Examples:$(RESET) $(shell ls examples/*.rs 2>/dev/null | wc -l | xargs)"
@echo "$(BOLD)Dependencies:$(RESET) $(shell cargo tree --depth 1 | grep -v "telemetry" | wc -l | xargs)"
@echo "$(BOLD)Git Commits:$(RESET) $(shell git rev-list --count HEAD 2>/dev/null || echo 'N/A')"
@echo ""
.PHONY: all
all: build test
@echo "$(GREEN)โ
Build and test complete$(RESET)"