diff --git a/Makefile b/Makefile index 2d30a06..0e8c7f1 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,22 @@ -.PHONY: all dev dev-frontend dev-backend build build-frontend build-backend clean test lint +.PHONY: all dev dev-frontend dev-backend build build-frontend build-backend clean test lint sqlc # Variables APP_NAME := imc FRONTEND_DIR := frontend BACKEND_DIR := backend BUILD_DIR := build +GOBIN := $(shell go env GOPATH)/bin # Default target all: build +# Generate Go code from SQL queries using sqlc +# Requires: go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest +sqlc: + @echo "Generating Go code from SQL queries..." + cd $(BACKEND_DIR) && $(GOBIN)/sqlc generate + @echo "SQL code generated successfully" + # Build everything (frontend + backend + embed) build: build-frontend build-backend @@ -20,7 +28,7 @@ build-frontend: @echo "Frontend built successfully" # Build backend only (copies frontend build into embed directory) -build-backend: build-frontend +build-backend: sqlc build-frontend @echo "Copying frontend to embed directory..." rm -rf $(BACKEND_DIR)/cmd/server/embed cp -r $(FRONTEND_DIR)/build $(BACKEND_DIR)/cmd/server/embed @@ -32,7 +40,7 @@ build-backend: build-frontend # Development targets dev: @echo "Starting backend dev server (hot-reload enabled)..." - cd $(BACKEND_DIR) && USE_EMBEDDED=false $(HOME)/go/bin/air + cd $(BACKEND_DIR) && USE_EMBEDDED=false $(GOBIN)/air @echo "Starting frontend dev server..." cd $(FRONTEND_DIR) && bun run dev @@ -42,7 +50,7 @@ dev-frontend: dev-backend: @echo "Starting backend dev server (hot-reload enabled)..." - cd $(BACKEND_DIR) && USE_EMBEDDED=false $(HOME)/go/bin/air + cd $(BACKEND_DIR) && USE_EMBEDDED=false $(GOBIN)/air # Clean build artifacts clean: @@ -68,10 +76,12 @@ help: @echo " all - Build frontend and backend (default)" @echo " build - Build frontend and backend" @echo " build-frontend - Build frontend only" - @echo " build-backend - Build backend only" + @echo " build-backend - Build backend only (runs sqlc first)" + @echo " sqlc - Generate Go code from SQL queries" @echo " dev - Start both frontend and backend with hot-reload" @echo " dev-frontend - Start frontend dev server" @echo " dev-backend - Start backend dev server (requires: go install github.com/air-verse/air@latest)" + @echo " sqlc - Generate Go code from SQL queries (requires: go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest)" @echo " clean - Remove build artifacts" @echo " test - Run backend tests" @echo " lint - Run Go vet"