- Add Go TUI with bubbletea for WireGuard management - Implement client CRUD operations with QR code generation - Add configuration and validation modules - Install/update scripts for client setup - Update Makefile to build binaries to bin/ directory - Add .gitignore for Go projects
87 lines
2.4 KiB
Makefile
87 lines
2.4 KiB
Makefile
# WireGuard Admin TUI
|
|
.PHONY: help build clean install test fmt lint run deps
|
|
|
|
# Project root (where go.mod is located)
|
|
ROOTDIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
|
|
|
# Binary name
|
|
BINARY=wg-tui
|
|
CMD_PATH=$(ROOTDIR)/cmd/$(BINARY)
|
|
|
|
# Build directory
|
|
BUILD_DIR=bin
|
|
BINARY_PATH=$(BUILD_DIR)/$(BINARY)
|
|
|
|
# Go parameters
|
|
GOCMD=go
|
|
GOBUILD=$(GOCMD) build
|
|
GOCLEAN=$(GOCMD) clean
|
|
GOTEST=$(GOCMD) test
|
|
GOGET=$(GOCMD) get
|
|
GOMOD=$(GOCMD) mod
|
|
|
|
help: ## Show this help message
|
|
@echo 'Usage: make [target]'
|
|
@echo ''
|
|
@echo 'Available targets:'
|
|
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
|
|
|
build: ## Build the binary
|
|
@echo "Building $(BINARY)..."
|
|
@mkdir -p $(BUILD_DIR)
|
|
@$(GOBUILD) -C $(ROOTDIR) -o $(BINARY_PATH) cmd/$(BINARY)/main.go
|
|
@echo "Build complete: $(BINARY_PATH)"
|
|
|
|
build-all: ## Build all binaries
|
|
@echo "Building all binaries..."
|
|
@mkdir -p $(BUILD_DIR)
|
|
@$(GOBUILD) -C $(ROOTDIR) -o $(BINARY_PATH) ./...
|
|
|
|
clean: ## Clean build artifacts
|
|
@echo "Cleaning..."
|
|
@$(GOCLEAN)
|
|
@rm -rf $(BUILD_DIR)
|
|
@echo "Clean complete"
|
|
|
|
install: ## Install the binary to $GOPATH/bin
|
|
@echo "Installing $(BINARY)..."
|
|
@$(GOBUILD) -C $(ROOTDIR) -o $$($(GOCMD) env GOPATH)/bin/$(BINARY) cmd/$(BINARY)/main.go
|
|
@echo "Install complete: $$($(GOCMD) env GOPATH)/bin/$(BINARY)"
|
|
|
|
test: ## Run tests
|
|
@echo "Running tests..."
|
|
@$(GOTEST) -C $(ROOTDIR) -v ./...
|
|
|
|
test-coverage: ## Run tests with coverage
|
|
@echo "Running tests with coverage..."
|
|
@$(GOTEST) -C $(ROOTDIR) -v -coverprofile=coverage.out ./...
|
|
@$(GOCMD) tool -C $(ROOTDIR) cover -html=coverage.out -o coverage.html
|
|
|
|
fmt: ## Format Go code
|
|
@echo "Formatting code..."
|
|
@$(GOCMD) fmt -C $(ROOTDIR) ./...
|
|
|
|
lint: ## Run golangci-lint (if installed)
|
|
@echo "Running linter..."
|
|
@cd $(ROOTDIR) && if command -v golangci-lint > /dev/null; then \
|
|
golangci-lint run; \
|
|
else \
|
|
echo "golangci-lint not found. Install from https://golangci-lint.run/usage/install/"; \
|
|
fi
|
|
|
|
deps: ## Download dependencies
|
|
@echo "Downloading dependencies..."
|
|
@$(GOMOD) -C $(ROOTDIR) download
|
|
@$(GOMOD) -C $(ROOTDIR) tidy
|
|
|
|
run: build ## Build and run the binary
|
|
@echo "Running $(BINARY)..."
|
|
@./$(BINARY_PATH)
|
|
|
|
dev: ## Run in development mode with hot reload (requires air)
|
|
@if command -v air > /dev/null; then \
|
|
air; \
|
|
else \
|
|
echo "air not found. Install with: go install github.com/cosmtrek/air@latest"; \
|
|
fi
|