Add sqlc integration to Makefile
- Add 'sqlc' target to generate Go code from SQL queries - Make 'build-backend' depend on 'sqlc' to ensure queries are synced - Use GOBIN variable for tool paths - Update help text with sqlc installation requirement
This commit is contained in:
parent
33552aa648
commit
a64989c997
1 changed files with 15 additions and 5 deletions
20
Makefile
20
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
|
# Variables
|
||||||
APP_NAME := imc
|
APP_NAME := imc
|
||||||
FRONTEND_DIR := frontend
|
FRONTEND_DIR := frontend
|
||||||
BACKEND_DIR := backend
|
BACKEND_DIR := backend
|
||||||
BUILD_DIR := build
|
BUILD_DIR := build
|
||||||
|
GOBIN := $(shell go env GOPATH)/bin
|
||||||
|
|
||||||
# Default target
|
# Default target
|
||||||
all: build
|
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 everything (frontend + backend + embed)
|
||||||
build: build-frontend build-backend
|
build: build-frontend build-backend
|
||||||
|
|
||||||
|
|
@ -20,7 +28,7 @@ build-frontend:
|
||||||
@echo "Frontend built successfully"
|
@echo "Frontend built successfully"
|
||||||
|
|
||||||
# Build backend only (copies frontend build into embed directory)
|
# Build backend only (copies frontend build into embed directory)
|
||||||
build-backend: build-frontend
|
build-backend: sqlc build-frontend
|
||||||
@echo "Copying frontend to embed directory..."
|
@echo "Copying frontend to embed directory..."
|
||||||
rm -rf $(BACKEND_DIR)/cmd/server/embed
|
rm -rf $(BACKEND_DIR)/cmd/server/embed
|
||||||
cp -r $(FRONTEND_DIR)/build $(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
|
# Development targets
|
||||||
dev:
|
dev:
|
||||||
@echo "Starting backend dev server (hot-reload enabled)..."
|
@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..."
|
@echo "Starting frontend dev server..."
|
||||||
cd $(FRONTEND_DIR) && bun run dev
|
cd $(FRONTEND_DIR) && bun run dev
|
||||||
|
|
||||||
|
|
@ -42,7 +50,7 @@ dev-frontend:
|
||||||
|
|
||||||
dev-backend:
|
dev-backend:
|
||||||
@echo "Starting backend dev server (hot-reload enabled)..."
|
@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 build artifacts
|
||||||
clean:
|
clean:
|
||||||
|
|
@ -68,10 +76,12 @@ help:
|
||||||
@echo " all - Build frontend and backend (default)"
|
@echo " all - Build frontend and backend (default)"
|
||||||
@echo " build - Build frontend and backend"
|
@echo " build - Build frontend and backend"
|
||||||
@echo " build-frontend - Build frontend only"
|
@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 - Start both frontend and backend with hot-reload"
|
||||||
@echo " dev-frontend - Start frontend dev server"
|
@echo " dev-frontend - Start frontend dev server"
|
||||||
@echo " dev-backend - Start backend dev server (requires: go install github.com/air-verse/air@latest)"
|
@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 " clean - Remove build artifacts"
|
||||||
@echo " test - Run backend tests"
|
@echo " test - Run backend tests"
|
||||||
@echo " lint - Run Go vet"
|
@echo " lint - Run Go vet"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue