-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
154 lines (131 loc) · 4.54 KB
/
Copy pathMakefile
File metadata and controls
154 lines (131 loc) · 4.54 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
.PHONY: build install install-local clean clean-all clean-profiles test run-ingest run-worklog run-onboard fmt lint tools uninstall-all
BINARY_NAME=devlog
BUILD_DIR=./bin
INSTALL_DIR=/usr/local/bin
GOBIN=$(shell go env GOPATH)/bin
build:
go build -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/devlog
# Install to $GOPATH/bin (usually ~/go/bin)
install:
go install ./cmd/devlog
# Install to /usr/local/bin (requires sudo)
install-local: build
sudo cp $(BUILD_DIR)/$(BINARY_NAME) $(INSTALL_DIR)/$(BINARY_NAME)
@echo "Installed to $(INSTALL_DIR)/$(BINARY_NAME)"
# Uninstall from /usr/local/bin
uninstall:
sudo rm -f $(INSTALL_DIR)/$(BINARY_NAME)
@echo "Removed $(INSTALL_DIR)/$(BINARY_NAME)"
# Uninstall from all locations (for testing releases)
uninstall-all:
@echo "Uninstalling devlog from all locations..."
@# Remove from /usr/local/bin
@if [ -f "$(INSTALL_DIR)/$(BINARY_NAME)" ]; then \
sudo rm -f $(INSTALL_DIR)/$(BINARY_NAME) && echo "✓ Removed $(INSTALL_DIR)/$(BINARY_NAME)"; \
else \
echo "- Not found in $(INSTALL_DIR)"; \
fi
@# Remove from $GOPATH/bin
@if [ -f "$(GOBIN)/$(BINARY_NAME)" ]; then \
rm -f $(GOBIN)/$(BINARY_NAME) && echo "✓ Removed $(GOBIN)/$(BINARY_NAME)"; \
else \
echo "- Not found in $(GOBIN)"; \
fi
@# Remove npm global package
@if npm list -g @ishaan812/devlog >/dev/null 2>&1; then \
npm uninstall -g @ishaan812/devlog && echo "✓ Uninstalled npm package @ishaan812/devlog"; \
else \
echo "- npm package @ishaan812/devlog not installed"; \
fi
@# Check if any devlog binaries remain in PATH
@echo ""
@echo "Checking for remaining devlog installations..."
@if command -v devlog >/dev/null 2>&1; then \
echo "⚠ devlog still found in PATH at: $$(which devlog)"; \
echo " You may need to manually remove it or restart your shell."; \
else \
echo "✓ No devlog binary found in PATH"; \
fi
clean:
rm -rf $(BUILD_DIR)
rm -rf ~/.devlog/devlog.db
clean-all:
rm -rf $(BUILD_DIR)
rm -rf ~/.devlog
clean-profiles:
@echo "Deleting all devlog profiles and config..."
rm -rf ~/.devlog/profiles
rm -f ~/.devlog/config.json
@echo "All profiles deleted. Run 'devlog onboard' to set up again."
test:
go test -v ./...
# Development helpers
run-ingest:
go run ./cmd/devlog ingest .
run-worklog:
go run ./cmd/devlog worklog --days 7 --no-llm
run-onboard:
go run ./cmd/devlog onboard
# Build for multiple platforms
build-all:
GOOS=darwin GOARCH=amd64 go build -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 ./cmd/devlog
GOOS=darwin GOARCH=arm64 go build -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./cmd/devlog
GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./cmd/devlog
GOOS=windows GOARCH=amd64 go build -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./cmd/devlog
# Tidy dependencies
tidy:
go mod tidy
# Install dev tools (goimports, golangci-lint)
tools:
@echo "Installing goimports..."
go install golang.org/x/tools/cmd/goimports@latest
@echo "Installing golangci-lint..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@echo "Tools installed. Make sure $(shell go env GOPATH)/bin is in your PATH."
# Format code
fmt:
@echo "Running gofmt..."
@gofmt -s -w .
@if [ -x "$(GOBIN)/goimports" ]; then \
echo "Running goimports..."; \
$(GOBIN)/goimports -w -local github.com/ishaan812/devlog .; \
elif command -v goimports >/dev/null 2>&1; then \
echo "Running goimports..."; \
goimports -w -local github.com/ishaan812/devlog .; \
else \
echo "goimports not found. Run 'make tools' to install."; \
fi
# Lint code
lint:
@if [ -x "$(GOBIN)/golangci-lint" ]; then \
$(GOBIN)/golangci-lint run ./...; \
elif command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not found. Run 'make tools' to install."; \
echo "Running go vet as fallback..."; \
go vet ./...; \
fi
# Lint and fix
lint-fix:
@if [ -x "$(GOBIN)/golangci-lint" ]; then \
$(GOBIN)/golangci-lint run --fix ./...; \
elif command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run --fix ./...; \
else \
echo "golangci-lint not found. Run 'make tools' to install."; \
fi
# Check formatting without modifying
fmt-check:
@test -z "$$(gofmt -l .)" || (echo "Files need formatting:" && gofmt -l . && exit 1)
# Run all checks
check: fmt-check lint test
# Pre-commit hook setup
pre-commit:
@echo "Installing pre-commit hook..."
@echo '#!/bin/sh\nmake fmt-check && make lint' > .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
@echo "Pre-commit hook installed"
# Verbose build
build-verbose:
go build -v -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/devlog