Initial implementation of pluginctl CLI tool
- Add comprehensive info command with plugin manifest parsing - Implement global --plugin-path flag and PLUGINCTL_PLUGIN_PATH env var - Add full test suite with fixtures for various plugin configurations - Set up build system with Makefile, goreleaser, and golangci-lint - Include development tools with pinned versions for reproducible builds 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
commit
fd6e4a4513
21 changed files with 4949 additions and 0 deletions
159
Makefile
Normal file
159
Makefile
Normal file
|
@ -0,0 +1,159 @@
|
|||
# pluginctl Makefile
|
||||
# Based on common Go project patterns
|
||||
|
||||
# Build information
|
||||
VERSION ?= $(shell git describe --tags --always --dirty)
|
||||
COMMIT ?= $(shell git rev-parse --short HEAD)
|
||||
BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
# Go build variables
|
||||
GO_VERSION ?= $(shell awk '/^go / {print $$2}' go.mod)
|
||||
GOOS ?= $(shell go env GOOS)
|
||||
GOARCH ?= $(shell go env GOARCH)
|
||||
|
||||
# Tool versions
|
||||
GOLANGCI_LINT_VERSION ?= v1.62.2
|
||||
GORELEASER_VERSION ?= v2.10.2
|
||||
|
||||
# Project variables
|
||||
BINARY_NAME = pluginctl
|
||||
MAIN_PACKAGE = ./cmd/pluginctl
|
||||
DIST_DIR = dist
|
||||
|
||||
# Build flags
|
||||
LDFLAGS = -ldflags="-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(BUILD_DATE)"
|
||||
|
||||
# Default target
|
||||
.PHONY: all
|
||||
all: clean lint test build
|
||||
|
||||
# Help target
|
||||
.PHONY: help
|
||||
help: ## Show this help message
|
||||
@echo "Available targets:"
|
||||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
||||
|
||||
# Clean build artifacts
|
||||
.PHONY: clean
|
||||
clean: ## Clean build artifacts
|
||||
@echo "Cleaning build artifacts..."
|
||||
@rm -rf $(DIST_DIR)
|
||||
@rm -f $(BINARY_NAME)
|
||||
@go clean -cache
|
||||
|
||||
# Install dependencies
|
||||
.PHONY: deps
|
||||
deps: ## Install/update dependencies
|
||||
@echo "Installing dependencies..."
|
||||
@go mod download
|
||||
@go mod tidy
|
||||
|
||||
# Run tests
|
||||
.PHONY: test
|
||||
test: ## Run tests
|
||||
@echo "Running tests..."
|
||||
@go test -v ./...
|
||||
|
||||
# Run tests with coverage
|
||||
.PHONY: test-coverage
|
||||
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"
|
||||
|
||||
# Lint code
|
||||
.PHONY: lint
|
||||
lint: ## Run linter
|
||||
@echo "Running linter..."
|
||||
@golangci-lint run
|
||||
|
||||
# Fix linting issues
|
||||
.PHONY: lint-fix
|
||||
lint-fix: ## Fix linting issues
|
||||
@echo "Fixing linting issues..."
|
||||
@golangci-lint run --fix
|
||||
|
||||
# Build for all platforms using goreleaser
|
||||
.PHONY: build-all
|
||||
build: clean ## Build for all platforms using goreleaser
|
||||
@echo "Building for all platforms using goreleaser..."
|
||||
@goreleaser build --clean
|
||||
|
||||
# Install binary
|
||||
.PHONY: install
|
||||
install:
|
||||
@echo "Installing $(BINARY_NAME)..."
|
||||
@go install $(LDFLAGS) $(MAIN_PACKAGE)
|
||||
|
||||
# Run the application
|
||||
.PHONY: run
|
||||
run: ## Run the application
|
||||
@go run $(MAIN_PACKAGE) $(ARGS)
|
||||
|
||||
# Format code
|
||||
.PHONY: fmt
|
||||
fmt: ## Format code
|
||||
@echo "Formatting code..."
|
||||
@go fmt ./...
|
||||
|
||||
# Generate code
|
||||
.PHONY: generate
|
||||
generate: ## Generate code
|
||||
@echo "Generating code..."
|
||||
@go generate ./...
|
||||
|
||||
# Check for updates
|
||||
.PHONY: check-updates
|
||||
check-updates: ## Check for dependency updates
|
||||
@echo "Checking for dependency updates..."
|
||||
@go list -u -m all
|
||||
|
||||
# Release (requires goreleaser)
|
||||
.PHONY: release
|
||||
release: ## Create a release
|
||||
@echo "Creating release..."
|
||||
@goreleaser release --clean
|
||||
|
||||
# Snapshot release (for testing)
|
||||
.PHONY: snapshot
|
||||
snapshot: ## Create a snapshot release
|
||||
@echo "Creating snapshot release..."
|
||||
@goreleaser release --snapshot --clean
|
||||
|
||||
# Development setup
|
||||
.PHONY: dev-setup
|
||||
dev-setup: ## Set up development environment
|
||||
@echo "Setting up development environment..."
|
||||
@go get -tool github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
|
||||
@go get -tool github.com/goreleaser/goreleaser/v2@$(GORELEASER_VERSION)
|
||||
@echo "Development tools installed"
|
||||
|
||||
# Verify build
|
||||
.PHONY: verify
|
||||
verify: clean lint test build ## Verify build (clean, lint, test, build)
|
||||
@echo "Build verification complete"
|
||||
|
||||
# Quick development build
|
||||
.PHONY: dev
|
||||
dev: fmt lint build ## Quick development build (fmt, lint, build)
|
||||
|
||||
# Check changes target
|
||||
.PHONY: check-changes
|
||||
check-changes: lint test ## Check changes (lint, test)
|
||||
|
||||
# CI target
|
||||
.PHONY: ci
|
||||
ci: deps verify ## CI target (deps, verify)
|
||||
|
||||
# Print build info
|
||||
.PHONY: version
|
||||
version: ## Print version information
|
||||
@echo "Version: $(VERSION)"
|
||||
@echo "Commit: $(COMMIT)"
|
||||
@echo "Build Date: $(BUILD_DATE)"
|
||||
@echo "Go Version: $(GO_VERSION)"
|
||||
@echo "OS/Arch: $(GOOS)/$(GOARCH)"
|
||||
@echo "Tool Versions:"
|
||||
@echo " golangci-lint: $(GOLANGCI_LINT_VERSION)"
|
||||
@echo " goreleaser: $(GORELEASER_VERSION)"
|
Loading…
Add table
Add a link
Reference in a new issue