-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (78 loc) · 3.26 KB
/
Makefile
File metadata and controls
102 lines (78 loc) · 3.26 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
.PHONY: help install install-dev lint format test race coverage check fuzz build-go build build-fast bundle bundle-watch bundle-clean clean clean-all build-all typecheck bump-patch push
GO_DIR = .
STATIC_JS_DIR = webterm/static/js
TERMINAL_TS = $(STATIC_JS_DIR)/terminal.ts
TERMINAL_JS = $(STATIC_JS_DIR)/terminal.js
GHOSTTY_WASM = $(STATIC_JS_DIR)/ghostty-vt.wasm
VERSION_FILE = VERSION
VERSION = $(shell test -f $(VERSION_FILE) && cat $(VERSION_FILE) || echo dev)
GO_VERSION_LDFLAGS = -X github.com/rcarmo/webterm/webterm.Version=$(VERSION)
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}'
install: ## Download Go dependencies
cd $(GO_DIR) && go mod download
install-dev: install node_modules ## Install Go and frontend dependencies
lint: ## Run Go vet
cd $(GO_DIR) && go vet ./...
format: ## Format Go code
cd $(GO_DIR) && gofmt -w ./cmd ./internal ./webterm
test: ## Run Go tests
cd $(GO_DIR) && go test ./...
race: ## Run Go race tests
cd $(GO_DIR) && go test -race ./...
coverage: ## Run Go coverage for runtime package
cd $(GO_DIR) && go test ./webterm -coverprofile=coverage.out && go tool cover -func=coverage.out
check: lint test coverage ## Run lint + tests + coverage
fuzz: ## Run all fuzz tests briefly
cd $(GO_DIR) && go test ./... -run=^$$ -fuzz=Fuzz -fuzztime=1s
node_modules: package.json
bun install
@touch node_modules
typecheck: node_modules ## Run TypeScript type checking
bun run typecheck
build: node_modules ## Build frontend (typecheck + bundle)
bun run build
build-fast: node_modules ## Build frontend without typecheck
bun run build:fast
@test -f $(GHOSTTY_WASM) || bun run copy-wasm
bundle: build ## Alias for build
bundle-watch: node_modules ## Watch mode for frontend development
@test -f $(GHOSTTY_WASM) || bun run copy-wasm
bun run watch
build-go: ## Build Go CLI binary
cd $(GO_DIR) && mkdir -p bin && go build -ldflags "$(GO_VERSION_LDFLAGS)" -o ./bin/webterm ./cmd/webterm
clean: ## Remove coverage artifacts
rm -f $(GO_DIR)/coverage.out
bundle-clean: ## Remove frontend dependencies
rm -rf node_modules bun.lock
clean-all: clean bundle-clean ## Remove all generated artifacts
build-all: clean-all install-dev build check build-go ## Full reproducible build from scratch
@echo "Build complete!"
bump-patch: ## Bump patch version in VERSION and create git tag
@if [ ! -f $(VERSION_FILE) ]; then echo "VERSION file not found"; exit 1; fi
@OLD=$$(cat $(VERSION_FILE)); \
MAJOR=$$(echo $$OLD | cut -d. -f1); \
MINOR=$$(echo $$OLD | cut -d. -f2); \
PATCH=$$(echo $$OLD | cut -d. -f3); \
NEW="$$MAJOR.$$MINOR.$$((PATCH + 1))"; \
echo $$NEW > $(VERSION_FILE); \
git add $(VERSION_FILE); \
git commit -m "Bump version to $$NEW"; \
git tag "v$$NEW"; \
echo "Bumped version: $$OLD -> $$NEW (tagged v$$NEW)"
push: ## Push current branch and tags pointing at HEAD
@BRANCH=$$(git rev-parse --abbrev-ref HEAD); \
if [ "$$BRANCH" = "HEAD" ]; then \
echo "Detached HEAD; refusing to push"; \
exit 1; \
fi; \
git push origin "$$BRANCH"; \
TAGS=$$(git tag --points-at HEAD); \
if [ -n "$$TAGS" ]; then \
for TAG in $$TAGS; do \
echo "Pushing tag $$TAG"; \
git push origin "$$TAG"; \
done; \
else \
echo "No tags on current commit"; \
fi