-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
96 lines (80 loc) · 2.62 KB
/
Makefile
File metadata and controls
96 lines (80 loc) · 2.62 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
.PHONY: build test clean install uninstall dev lint lint-fix
# Variables
BINARY_NAME=proj
VERSION?=dev
LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION)"
GO?=$(shell which go || echo /home/cjennings/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.12.linux-amd64/bin/go)
GOFLAGS=-trimpath
PREFIX?=$(HOME)/.local
INSTALL_DIR=$(PREFIX)/bin
# Build for current platform
build:
$(GO) build $(GOFLAGS) $(LDFLAGS) -o $(BINARY_NAME) ./cmd/proj
# Build for all supported platforms
build-all:
GOOS=linux GOARCH=amd64 $(GO) build $(GOFLAGS) $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-amd64 ./cmd/proj
GOOS=linux GOARCH=arm64 $(GO) build $(GOFLAGS) $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-arm64 ./cmd/proj
GOOS=darwin GOARCH=amd64 $(GO) build $(GOFLAGS) $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-amd64 ./cmd/proj
GOOS=darwin GOARCH=arm64 $(GO) build $(GOFLAGS) $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-arm64 ./cmd/proj
# Run tests
test:
$(GO) test -v -race -cover ./...
# Run tests with coverage
test-coverage:
$(GO) test -v -race -coverprofile=coverage.out ./...
$(GO) tool cover -html=coverage.out -o coverage.html
# Clean build artifacts
clean:
rm -f $(BINARY_NAME)
rm -rf dist/
rm -f coverage.out coverage.html
# Install to ~/.local/bin (or custom PREFIX)
install: build
@./scripts/install-helper.sh $(INSTALL_DIR) $(BINARY_NAME)
@echo ""
@echo "Make sure $(INSTALL_DIR) is in your PATH:"
@echo " export PATH=\"$(INSTALL_DIR):\$$PATH\""
@echo ""
@echo "To enable shell integration (cd command), add to ~/.bashrc or ~/.zshrc:"
@echo " # proj - TUI project navigator"
@echo " proj() {"
@echo " local output=\$$(mktemp)"
@echo " PROJ_CD_FILE=\"\$$output\" command $(INSTALL_DIR)/$(BINARY_NAME) \"\$$@\""
@echo " if [ -s \"\$$output\" ]; then"
@echo " cd \"\$$(cat \"\$$output\")\""
@echo " fi"
@echo " rm -f \"\$$output\""
@echo " }"
# Uninstall from installation directory
uninstall:
@echo "Uninstalling $(BINARY_NAME) from $(INSTALL_DIR)..."
@rm -f $(INSTALL_DIR)/$(BINARY_NAME)
@echo "✓ Uninstalled"
@echo ""
@echo "To remove configuration:"
@echo " rm -rf ~/.config/proj"
# Run in development mode (use: make dev ARGS="--list" or make dev ARGS="--set-path ~/code")
dev:
$(GO) run ./cmd/proj $(ARGS)
# Lint code
lint:
golangci-lint run
# Lint and auto-fix issues
lint-fix:
golangci-lint run --fix
# Format code
fmt:
$(GO) fmt ./...
gofmt -s -w .
# Tidy dependencies
tidy:
$(GO) mod tidy
# Download dependencies
deps:
$(GO) mod download
# Release using commitizen (test mode)
release-dry-run:
@./scripts/release.sh --dry-run
# Release using commitizen (creates tag and pushes)
release:
@./scripts/release.sh