refactor(API): Relspect integration
Some checks failed
CI / Test (1.23) (push) Failing after -22m46s
CI / Test (1.22) (push) Failing after -22m32s
CI / Build (push) Failing after -23m30s
CI / Lint (push) Failing after -23m12s

This commit is contained in:
Hein
2026-02-05 13:39:43 +02:00
parent 71f26c214f
commit f9773bd07f
33 changed files with 7512 additions and 58 deletions

160
Makefile
View File

@@ -1,12 +1,22 @@
.PHONY: build clean test lint lintfix run-server run-cli help
.PHONY: build clean test lint lintfix run-server run-cli help build-ui migrate generate-models install-relspecgo seed
# Variables
FRONTEND_DIR=frontend
SQL_DIR=sql
MODELS_DIR=pkg/models
# Build both server and CLI
build:
@echo "Building WhatsHooked..."
build: build-server build-cli build-ui
build-all: build ## Alias for build
# Build server and CLI
build-backend:
@echo "Building WhatsHooked backend..."
@mkdir -p bin
@go build -o bin/whatshook-server ./cmd/server
@go build -o bin/whatshook-cli ./cmd/cli
@echo "Build complete! Binaries in bin/"
@echo "Backend build complete! Binaries in bin/"
# Build server only
build-server:
@@ -48,8 +58,102 @@ deps:
@echo "Installing dependencies..."
@go mod download
@go mod tidy
@if [ -d "$(FRONTEND_DIR)" ]; then \
echo "Installing frontend dependencies..."; \
cd $(FRONTEND_DIR) && npm install; \
fi
@echo "Dependencies installed!"
# Build frontend UI
build-ui:
@echo "Building frontend..."
@if [ -d "$(FRONTEND_DIR)" ]; then \
cd $(FRONTEND_DIR) && npm run build; \
echo "Frontend built successfully"; \
else \
echo "Frontend directory not found. Skipping..."; \
fi
# Development mode for frontend
dev-ui:
@echo "Starting frontend development server..."
@if [ -d "$(FRONTEND_DIR)" ]; then \
cd $(FRONTEND_DIR) && npm run dev; \
else \
echo "Frontend directory not found"; \
exit 1; \
fi
# Database commands
generate-models: ## Generate BUN models from DBML schema
@echo "Generating models from DBML..."
@if [ ! -f "$(SQL_DIR)/schema.dbml" ]; then \
echo "Error: $(SQL_DIR)/schema.dbml not found"; \
echo "Please create the DBML schema first"; \
exit 1; \
fi
@mkdir -p $(MODELS_DIR)
@$(HOME)/go/bin/relspec convert --from dbml --from-path=$(SQL_DIR)/schema.dbml --to bun --to-path=$(MODELS_DIR) --package models
@echo "Models generated in $(MODELS_DIR)"
migrate: migrate-up ## Alias for migrate-up
migrate-up: ## Run database migrations (up)
@echo "Running migrations..."
@if [ -f "$(SQL_DIR)/migrate.sh" ]; then \
bash $(SQL_DIR)/migrate.sh up; \
else \
echo "Migration script not found. Run 'make setup-migrations' first"; \
fi
migrate-down: ## Rollback database migrations (down)
@echo "Rolling back migrations..."
@if [ -f "$(SQL_DIR)/migrate.sh" ]; then \
bash $(SQL_DIR)/migrate.sh down; \
else \
echo "Migration script not found"; \
fi
migrate-create: ## Create a new migration file (usage: make migrate-create NAME=migration_name)
@if [ -z "$(NAME)" ]; then \
echo "Error: NAME is required. Usage: make migrate-create NAME=migration_name"; \
exit 1; \
fi
@mkdir -p $(SQL_DIR)/postgres $(SQL_DIR)/sqlite
@timestamp=$$(date +%Y%m%d%H%M%S); \
echo "-- Migration: $(NAME)" > $(SQL_DIR)/postgres/$${timestamp}_$(NAME).up.sql; \
echo "-- Rollback: $(NAME)" > $(SQL_DIR)/postgres/$${timestamp}_$(NAME).down.sql; \
echo "-- Migration: $(NAME)" > $(SQL_DIR)/sqlite/$${timestamp}_$(NAME).up.sql; \
echo "-- Rollback: $(NAME)" > $(SQL_DIR)/sqlite/$${timestamp}_$(NAME).down.sql; \
echo "Migration files created in $(SQL_DIR)/postgres and $(SQL_DIR)/sqlite"
setup-migrations: ## Setup migration scripts
@echo "Setting up migration infrastructure..."
@mkdir -p $(SQL_DIR)/postgres $(SQL_DIR)/sqlite
@if [ ! -f "$(SQL_DIR)/migrate.sh" ]; then \
echo "Creating migration script..."; \
echo '#!/bin/bash' > $(SQL_DIR)/migrate.sh; \
echo 'echo "Migration script placeholder. Implement your migration logic here."' >> $(SQL_DIR)/migrate.sh; \
chmod +x $(SQL_DIR)/migrate.sh; \
fi
@echo "Migration infrastructure ready"
# Seed database
seed: ## Seed the database with initial data
@echo "Seeding database..."
@go run ./cmd/seed
# Install tools
install-relspecgo: ## Install relspecgo tool
@echo "Installing relspec..."
@go install git.warky.dev/wdevs/relspecgo/cmd/relspec@latest
@echo "relspec installed successfully"
install-tools: install-relspecgo ## Install all required tools
@echo "Installing development tools..."
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@echo "All tools installed"
release-version: ## Create and push a release with specific version (use: make release-version VERSION=v1.2.3)
@if [ -z "$(VERSION)" ]; then \
@@ -99,15 +203,39 @@ lintfix: ## Run linter
help:
@echo "WhatsHooked Makefile"
@echo ""
@echo "Usage:"
@echo " make build - Build server and CLI"
@echo " make build-server - Build server only"
@echo " make build-cli - Build CLI only"
@echo " make clean - Remove build artifacts (preserves bin directory)"
@echo " make test - Run tests with coverage"
@echo " make lint - Run linter"
@echo " make lintfix - Run linter with auto-fix"
@echo " make run-server - Run server (requires config.json)"
@echo " make run-cli ARGS='health' - Run CLI with arguments"
@echo " make deps - Install dependencies"
@echo " make help - Show this help message"
@echo "Build Commands:"
@echo " make build - Build server, CLI, and UI"
@echo " make build-backend - Build server and CLI only"
@echo " make build-server - Build server only"
@echo " make build-cli - Build CLI only"
@echo " make build-ui - Build frontend UI"
@echo ""
@echo "Development Commands:"
@echo " make run-server - Run server (requires config.json)"
@echo " make run-cli ARGS='...' - Run CLI with arguments"
@echo " make dev-ui - Run frontend in development mode"
@echo ""
@echo "Database Commands:"
@echo " make generate-models - Generate BUN models from DBML schema"
@echo " make migrate - Run database migrations (up)"
@echo " make migrate-up - Run database migrations (up)"
@echo " make migrate-down - Rollback database migrations"
@echo " make migrate-create NAME=<name> - Create new migration"
@echo " make setup-migrations - Setup migration infrastructure"
@echo " make seed - Seed database with initial data"
@echo ""
@echo "Test & Quality:"
@echo " make test - Run tests with coverage"
@echo " make lint - Run linter"
@echo " make lintfix - Run linter with auto-fix"
@echo ""
@echo "Dependencies:"
@echo " make deps - Install all dependencies"
@echo " make install-relspecgo - Install relspecgo tool"
@echo " make install-tools - Install all development tools"
@echo ""
@echo "Other:"
@echo " make clean - Remove build artifacts"
@echo " make release-version VERSION=v1.2.3 - Create release"
@echo " make help - Show this help message"