feat: complete Tasks 1-3 (setup, models+storage, config management)
- Task 1: Project setup (go.mod, Makefile, .gitignore, main.go) - Task 2: Core data models (Host, KeyPair, Snippet, AppConfig) + JSON storage layer - Task 3: Configuration management with cross-platform path support (macOS/Linux/Windows) - Updated PROJECT_STATE.md with progress tracking
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
.PHONY: build run test clean lint fmt vet install release help
|
||||
|
||||
# Binary name
|
||||
BINARY_NAME=hostkeeper
|
||||
BUILD_DIR=bin
|
||||
|
||||
# Go parameters
|
||||
GOCMD=go
|
||||
GOBUILD=$(GOCMD) build
|
||||
GOCLEAN=$(GOCMD) clean
|
||||
GOTEST=$(GOCMD) test
|
||||
GOGET=$(GOCMD) get
|
||||
GOFMT=$(GOCMD) fmt
|
||||
GOVET=$(GOCMD) vet
|
||||
|
||||
# Version info
|
||||
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||
BUILD_TIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
LDFLAGS := -X main.version=$(VERSION) -X main.buildTime=$(BUILD_TIME)
|
||||
|
||||
# Default target
|
||||
all: build
|
||||
|
||||
## build: Compile the binary
|
||||
build:
|
||||
$(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/hostkeeper
|
||||
|
||||
## run: Build and run
|
||||
run: build
|
||||
./$(BUILD_DIR)/$(BINARY_NAME) $(ARGS)
|
||||
|
||||
## test: Run all tests
|
||||
test:
|
||||
$(GOTEST) ./... -v
|
||||
|
||||
## test-short: Run only short tests
|
||||
test-short:
|
||||
$(GOTEST) ./... -v -short
|
||||
|
||||
## clean: Remove build artifacts
|
||||
clean:
|
||||
$(GOCLEAN)
|
||||
rm -rf $(BUILD_DIR)
|
||||
|
||||
## fmt: Format all Go files
|
||||
fmt:
|
||||
$(GOFMT) ./...
|
||||
|
||||
## vet: Run go vet
|
||||
vet:
|
||||
$(GOVET) ./...
|
||||
|
||||
## lint: Run linter (requires golangci-lint)
|
||||
lint:
|
||||
golangci-lint run ./...
|
||||
|
||||
## install: Install the binary to GOPATH/bin
|
||||
install: build
|
||||
$(GOCMD) install ./cmd/hostkeeper
|
||||
|
||||
## tidy: Run go mod tidy
|
||||
tidy:
|
||||
$(GOCMD) mod tidy
|
||||
|
||||
## deps: Download dependencies
|
||||
deps:
|
||||
$(GOCMD) mod download
|
||||
|
||||
## release: Build for multiple platforms
|
||||
release: clean
|
||||
mkdir -p $(BUILD_DIR)
|
||||
GOOS=darwin GOARCH=amd64 $(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 ./cmd/hostkeeper
|
||||
GOOS=darwin GOARCH=arm64 $(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./cmd/hostkeeper
|
||||
GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./cmd/hostkeeper
|
||||
GOOS=linux GOARCH=arm64 $(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 ./cmd/hostkeeper
|
||||
GOOS=windows GOARCH=amd64 $(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./cmd/hostkeeper
|
||||
|
||||
## help: Show this help
|
||||
help:
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
||||
Reference in New Issue
Block a user