-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
181 lines (146 loc) · 5.58 KB
/
Makefile
File metadata and controls
181 lines (146 loc) · 5.58 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
# Goca Makefile
.PHONY: help build test clean install release dev-setup lint fmt version
# Variables
VERSION ?= $(shell git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "dev")
BUILD_TIME := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
LDFLAGS := -X github.com/sazardev/goca/cmd.Version=$(VERSION) -X github.com/sazardev/goca/cmd.BuildTime=$(BUILD_TIME) -X github.com/sazardev/goca/cmd.GitCommit=$(GIT_COMMIT)
# Default target
help: ## Show this help message
@echo "Available commands:"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
# Build
build: ## Build the CLI binary with version info
@echo "Building Goca CLI v$(VERSION)..."
go build -ldflags "$(LDFLAGS)" -o goca .
build-all: ## Build for all platforms with version info
@echo "Building for all platforms..."
@mkdir -p dist
GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o dist/goca-windows-amd64.exe
GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o dist/goca-linux-amd64
GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o dist/goca-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o dist/goca-darwin-arm64
@echo "Binaries built in dist/ directory"
@ls -la dist/
version: ## Show version information
@echo "Version: $(VERSION)"
@echo "Build Time: $(BUILD_TIME)"
@echo "Git Commit: $(GIT_COMMIT)"
# Test
test: ## Run tests
@echo "Running tests..."
go test -v ./...
test-coverage: ## Run tests with coverage
@echo "Running tests with coverage..."
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# Development
dev-setup: ## Setup development environment
@echo "Setting up development environment..."
go mod tidy
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@echo "Development environment ready!"
fmt: ## Format code
@echo "Formatting code..."
go fmt ./...
gofmt -s -w .
lint: ## Run linter
@echo "Running linter..."
golangci-lint run
# Release
release-patch: ## Create a patch release (x.y.Z)
@echo "Creating patch release..."
./scripts/release.sh patch
release-minor: ## Create a minor release (x.Y.0)
@echo "Creating minor release..."
./scripts/release.sh minor
release-major: ## Create a major release (X.0.0)
@echo "Creating major release..."
./scripts/release.sh major
release-auto: ## Auto-detect release type from commits
@echo "Auto-detecting release type..."
./scripts/release.sh auto
release: release-auto ## Alias for release-auto
# CLI Testing
test-cli-comprehensive: ## Run CLI comprehensive tests
@echo "Running comprehensive CLI tests..."
go run internal/testing/test_runner.go -type=all -v
test-cli-init: ## Test only goca init command
@echo "Testing goca init command..."
go run internal/testing/test_runner.go -type=init -v
test-cli-feature: ## Test only goca feature command
@echo "Testing goca feature command..."
go run internal/testing/test_runner.go -type=feature -v
test-cli-entity: ## Test only goca entity command
@echo "Testing goca entity command..."
go run internal/testing/test_runner.go -type=entity -v
test-cli-quality: ## Test code quality of generated code
@echo "Testing generated code quality..."
go run internal/testing/test_runner.go -type=quality -v
test-cli-fast: ## Run fast CLI tests (compilation only)
@echo "Running fast CLI tests..."
go test ./internal/testing -run TestGocaInitCommand -v
go test ./internal/testing -run TestCodeQuality -v
test-cli-benchmark: ## Run CLI performance benchmarks
@echo "Running CLI benchmarks..."
go test ./internal/testing -bench=. -benchmem -v
test-all: ## Run all tests (unit + CLI)
@echo "Running all tests..."
$(MAKE) test
$(MAKE) test-cli-comprehensive
test-cli-basic: build ## Test basic CLI functionality
@echo "Testing basic CLI functionality..."
./goca version
./goca help
@echo "Basic CLI tests passed!"
# Installation
install: ## Install CLI to GOPATH/bin
@echo "Installing Goca CLI..."
go install .
@echo "Goca CLI installed successfully!"
# Release
release: ## Create a new release (usage: make release VERSION=1.0.1)
ifndef VERSION
@echo "Error: VERSION is required. Usage: make release VERSION=1.0.1"
@exit 1
endif
@echo "Creating release $(VERSION)..."
./scripts/release.sh $(VERSION)
# Maintenance
clean: ## Clean build artifacts
@echo "Cleaning up..."
rm -f goca goca.exe
rm -rf dist/
rm -f coverage.out coverage.html
go clean
@echo "Clean completed!"
deps: ## Download dependencies
@echo "Downloading dependencies..."
go mod download
go mod tidy
# Quick development workflow
dev: fmt lint test build ## Format, lint, test, and build
# Documentation
docs: ## Generate documentation
@echo "Documentation available at:"
@echo "- README.md: Main documentation"
@echo "- GUIDE.md: Complete command guide"
@echo "- rules.md: Clean Architecture rules"
# Version info
show-version: ## Show current version from git tags
@echo "Current git version: $(VERSION)"
# Git helpers
status: ## Show git status and current version
@echo "Current version: $(VERSION)"
@echo "Git status:"
@git status --short
# Docker (if needed in future)
docker-build: ## Build Docker image
@echo "Building Docker image..."
docker build -t sazardev/goca:latest .
# Check if everything is ready for release
pre-release-check: fmt lint test test-cli ## Check if everything is ready for release
@echo "✅ All checks passed! Ready for release."
@echo "Current version: $(VERSION)"
@echo "To create a release, run: make release [patch|minor|major|auto]"