Makefile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. .PHONY: build run test clean lint fmt tidy dev
  2. # Go parameters
  3. GOCMD=go
  4. GOBUILD=$(GOCMD) build
  5. GORUN=$(GOCMD) run
  6. GOTEST=$(GOCMD) test
  7. GOCLEAN=$(GOCMD) clean
  8. GOGET=$(GOCMD) get
  9. GOMOD=$(GOCMD) mod
  10. GOFMT=gofmt
  11. # Binary name
  12. BINARY_NAME=claude-code-hub
  13. BINARY_DIR=bin
  14. # Main package
  15. MAIN_PACKAGE=./cmd/server
  16. # Build the project
  17. build:
  18. @echo "Building..."
  19. @mkdir -p $(BINARY_DIR)
  20. $(GOBUILD) -o $(BINARY_DIR)/$(BINARY_NAME) $(MAIN_PACKAGE)
  21. # Run the project
  22. run:
  23. $(GORUN) $(MAIN_PACKAGE)
  24. # Run with hot reload (requires air: go install github.com/air-verse/air@latest)
  25. dev:
  26. air
  27. # Run tests
  28. test:
  29. $(GOTEST) -v ./...
  30. # Run tests with coverage
  31. test-coverage:
  32. $(GOTEST) -v -coverprofile=coverage.out ./...
  33. $(GOCMD) tool cover -html=coverage.out -o coverage.html
  34. # Clean build artifacts
  35. clean:
  36. @echo "Cleaning..."
  37. $(GOCLEAN)
  38. rm -rf $(BINARY_DIR)
  39. rm -f coverage.out coverage.html
  40. # Run linter (requires golangci-lint)
  41. lint:
  42. golangci-lint run ./...
  43. # Format code
  44. fmt:
  45. $(GOFMT) -s -w .
  46. # Tidy dependencies
  47. tidy:
  48. $(GOMOD) tidy
  49. # Download dependencies
  50. deps:
  51. $(GOMOD) download
  52. # Generate mocks (requires mockgen)
  53. mocks:
  54. go generate ./...
  55. # Build for multiple platforms
  56. build-all:
  57. @echo "Building for multiple platforms..."
  58. @mkdir -p $(BINARY_DIR)
  59. GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_DIR)/$(BINARY_NAME)-linux-amd64 $(MAIN_PACKAGE)
  60. GOOS=linux GOARCH=arm64 $(GOBUILD) -o $(BINARY_DIR)/$(BINARY_NAME)-linux-arm64 $(MAIN_PACKAGE)
  61. GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BINARY_DIR)/$(BINARY_NAME)-darwin-amd64 $(MAIN_PACKAGE)
  62. GOOS=darwin GOARCH=arm64 $(GOBUILD) -o $(BINARY_DIR)/$(BINARY_NAME)-darwin-arm64 $(MAIN_PACKAGE)
  63. GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BINARY_DIR)/$(BINARY_NAME)-windows-amd64.exe $(MAIN_PACKAGE)
  64. # Docker build
  65. docker-build:
  66. docker build -t $(BINARY_NAME):latest .
  67. # Docker run
  68. docker-run:
  69. docker run -p 8080:8080 $(BINARY_NAME):latest