refactor(MAKEFILE): migrate to Vite and remove sqlc dependency

This commit is contained in:
2026-01-07 18:33:59 -05:00
parent a46f8bcfec
commit 9dc64814b4
5 changed files with 103 additions and 403 deletions

View File

@@ -1,84 +1,72 @@
.PHONY: all generate build build-debug build-opt test test-cover test-plugin lint fmt vet clean tidy deps verify serve help
.PHONY: start deps build sdk dev test test-plugin lint fmt clean help
MODULE := enclave
BINARY := enclave.wasm
BUILD_DIR := example
all: generate build
# === Primary Commands ===
generate:
@sqlc generate
start: deps build sdk dev
deps:
@command -v sqlc >/dev/null || go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
@command -v golangci-lint >/dev/null || go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@bun install
@cd example && bun install
build:
@echo "Building WASM plugin..."
@GOOS=wasip1 GOARCH=wasm go build -o $(BUILD_DIR)/$(BINARY) .
@echo "Built $(BUILD_DIR)/$(BINARY)"
build-debug:
@GOOS=wasip1 GOARCH=wasm go build -gcflags="all=-N -l" -o $(BUILD_DIR)/$(BINARY) .
sdk:
@echo "Building TypeScript SDK..."
@bun run build
@echo "Built dist/enclave.js"
build-opt:
@GOOS=wasip1 GOARCH=wasm go build -ldflags="-s -w" -o $(BUILD_DIR)/$(BINARY) .
@wasm-opt -Os $(BUILD_DIR)/$(BINARY) -o $(BUILD_DIR)/$(BINARY)
dev:
@echo "Starting dev server at http://localhost:8080"
@cd example && bun run dev
# === Testing ===
test:
@go test -v ./...
test-cover:
@go test -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out -o coverage.html
test-plugin: build
@echo "Testing generate()..."
@extism call $(BUILD_DIR)/$(BINARY) generate --input '{"credential":"dGVzdC1jcmVkZW50aWFs"}' --wasi
@echo "\nTesting query()..."
@extism call $(BUILD_DIR)/$(BINARY) query --input '{"did":""}' --wasi
test-plugin:
@extism call $(BUILD_DIR)/$(BINARY) generate --input '{"credential":"dGVzdA=="}' --wasi
test-sdk: sdk
@cd example && bun run test
serve: build
@echo "Starting Vite dev server at http://localhost:8080"
@cd example && npm run dev
# === Code Quality ===
lint:
@golangci-lint run ./...
fmt:
@go fmt ./...
@gofumpt -w .
@bun run --filter '*' format 2>/dev/null || true
vet:
@go vet ./...
generate:
@sqlc generate
# === Utilities ===
clean:
@rm -f $(BUILD_DIR)/$(BINARY)
@rm -f coverage.out coverage.html
tidy:
@go mod tidy
deps:
@go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@go install mvdan.cc/gofumpt@latest
@cd example && npm install
@echo "Install Extism CLI: https://extism.org/docs/install"
verify: fmt vet lint test
@rm -rf dist
help:
@echo "Motr Enclave - Extism Plugin (Go 1.25/wasip1)"
@echo "Motr Enclave"
@echo ""
@echo "Build targets:"
@echo " build - Build WASM plugin for wasip1"
@echo " build-debug - Build with debug symbols"
@echo " build-opt - Build optimized (requires wasm-opt)"
@echo ""
@echo "Development targets:"
@echo " generate - Run sqlc to generate Go code"
@echo " test - Run tests"
@echo " test-cover - Run tests with coverage"
@echo " test-plugin - Test plugin with Extism CLI"
@echo " serve - Build and serve example/ for browser testing"
@echo " lint - Run golangci-lint"
@echo " fmt - Format code"
@echo " vet - Run go vet"
@echo " verify - Run fmt, vet, lint, and test"
@echo ""
@echo "Utility targets:"
@echo " clean - Remove build artifacts"
@echo " tidy - Run go mod tidy"
@echo " deps - Install development dependencies"
@echo " make start - Full setup + dev server (recommended)"
@echo " make build - Build WASM plugin"
@echo " make sdk - Build TypeScript SDK"
@echo " make dev - Start dev server"
@echo " make test - Run Go tests"
@echo " make test-plugin - Test plugin with Extism CLI"
@echo " make test-sdk - Run SDK tests in browser"
@echo " make clean - Remove build artifacts"