# Makefile for Nostr Poster # Variables BINARY_NAME=nostr-poster BUILD_DIR=./build BIN_DIR=$(BUILD_DIR)/bin CONFIG_DIR=$(BUILD_DIR)/config CONTENT_DIR=$(BUILD_DIR)/content ARCHIVE_DIR=$(BUILD_DIR)/archive DB_DIR=$(BUILD_DIR)/db # Go parameters GOCMD=go GOBUILD=$(GOCMD) build GOCLEAN=$(GOCMD) clean GOTEST=$(GOCMD) test GOGET=$(GOCMD) get # Main package MAIN_PKG=./cmd/server # Default target .PHONY: all all: clean build # Build binary .PHONY: build build: mkdir -p $(BIN_DIR) mkdir -p $(CONFIG_DIR) mkdir -p $(CONTENT_DIR) mkdir -p $(ARCHIVE_DIR) mkdir -p $(DB_DIR) # Copy config file if it exists if [ -f ./config/config.yaml ]; then cp ./config/config.yaml $(CONFIG_DIR)/config.yaml; fi $(GOBUILD) -o $(BIN_DIR)/$(BINARY_NAME) $(MAIN_PKG) # Run the application .PHONY: run run: build $(BIN_DIR)/$(BINARY_NAME) --config=$(CONFIG_DIR)/config.yaml --db=$(DB_DIR)/nostr-poster.db # Clean build artifacts .PHONY: clean clean: $(GOCLEAN) rm -rf $(BUILD_DIR) # Run tests .PHONY: test test: $(GOTEST) -v ./... # Update dependencies .PHONY: deps deps: $(GOGET) -u # Install required tools .PHONY: tools tools: go install golang.org/x/tools/cmd/goimports@latest go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest # Lint the code .PHONY: lint lint: golangci-lint run ./... # Format the code .PHONY: fmt fmt: goimports -w . # Show help .PHONY: help help: @echo "make - Build the application" @echo "make build - Build the application" @echo "make run - Run the application" @echo "make clean - Clean build artifacts" @echo "make test - Run tests" @echo "make deps - Update dependencies" @echo "make tools - Install required tools" @echo "make lint - Lint the code" @echo "make fmt - Format the code"