From 16bd4a8b204c46bc001046297600372794beae2d Mon Sep 17 00:00:00 2001 From: William Valentin Date: Tue, 23 Sep 2025 11:39:30 -0700 Subject: [PATCH] chore(makefile): add parity targets and seeding --- Makefile | 55 ++++++++++++++++++++++++++++++++++++++++++++++++- package.json | 1 + scripts/seed.ts | 14 +++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 scripts/seed.ts diff --git a/Makefile b/Makefile index 15993c3..ffec403 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,12 @@ DOCKER_IMAGE ?= $(APP_NAME):latest export -.PHONY: help install clean dev build test docker-build docker-buildx docker-run docker-clean info couchdb-up couchdb-down +.PHONY: help install clean \ + dev preview build \ + test test-watch test-coverage test-fast test-services test-integration \ + lint lint-fix format format-check type-check \ + docker-build docker-buildx docker-run docker-clean \ + seed couchdb-up couchdb-down info # Default target .DEFAULT_GOAL := help @@ -53,6 +58,10 @@ dev: ## Start development server @echo "Starting $(APP_NAME) development server..." @bun run dev +preview: ## Serve production build locally + @echo "Starting $(APP_NAME) preview server..." + @bun run preview + build: ## Build the application @echo "Building $(APP_NAME) application..." @bun run build @@ -67,6 +76,44 @@ test-watch: ## Run unit tests in watch mode @echo "Running $(APP_NAME) tests in watch mode..." @bun run test:watch +test-coverage: ## Run tests with coverage report + @echo "Running $(APP_NAME) tests with coverage..." + @bun run test:coverage + +test-fast: ## Run fast unit test subset + @echo "Running fast unit test subset..." + @bun run test:fast + +test-services: ## Run service layer tests only + @echo "Running service layer tests..." + @bun run test:services + +test-integration: ## Run integration tests + @echo "Running integration tests..." + @bun run test:integration + +##@ Quality + +lint: ## Run ESLint + @echo "Linting $(APP_NAME)..." + @bun run lint + +lint-fix: ## Run ESLint with autofix + @echo "Linting $(APP_NAME) with auto-fix..." + @bun run lint:fix + +format: ## Format code with Prettier + @echo "Formatting $(APP_NAME) code..." + @bun run format + +format-check: ## Check code formatting without writing changes + @echo "Checking $(APP_NAME) formatting..." + @bun run format:check + +type-check: ## Run TypeScript type checking + @echo "Type-checking $(APP_NAME)..." + @bun run type-check + ##@ Docker docker-build: ## Build Docker image for local development @@ -102,6 +149,12 @@ docker-clean: ## Clean Docker resources and containers @docker image prune -f 2>/dev/null || true @docker container prune -f 2>/dev/null || true +##@ Database + +seed: ## Seed default admin user into CouchDB + @echo "Seeding default admin account..." + @bun run seed + ##@ Test Services couchdb-up: ## Start local CouchDB for integration tests diff --git a/package.json b/package.json index 3d73ed9..5566f2b 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "test:unit": "jest --testPathPatterns='(utils|types).*test\\.(ts|js)$'", "test:services": "jest --testPathPatterns='services.*test\\.(ts|js)$'", "test:integration": "jest --testPathPatterns='(tests/integration/.*\\.test\\.(ts|js)|services/.*/__tests__/integration/.*\\.test\\.(ts|js))$'", + "seed": "bun run scripts/seed.ts", "lint:markdown": "markdownlint-cli2 \"**/*.md\"", "lint:markdown:fix": "markdownlint-cli2 --fix \"**/*.md\"", "check:secrets": "secretlint \"**/*\"", diff --git a/scripts/seed.ts b/scripts/seed.ts new file mode 100644 index 0000000..8f4e7b2 --- /dev/null +++ b/scripts/seed.ts @@ -0,0 +1,14 @@ +import { databaseSeeder } from '../services/database.seeder'; + +const run = async () => { + try { + await databaseSeeder.seedDatabase(); + console.log('✅ Database seeding complete'); + process.exit(0); + } catch (error) { + console.error('❌ Database seeding failed', error); + process.exit(1); + } +}; + +run();