feat: add initial project configuration and smoke tests
- Created pnpm workspace configuration to manage packages. - Added a placeholder .gitkeep file in the scripts directory. - Implemented a smoke test script to validate core API and web endpoints. - Established TypeScript base configuration for consistent compilation settings. - Introduced Turbo configuration for task management and build processes.
This commit is contained in:
138
Makefile
Normal file
138
Makefile
Normal file
@@ -0,0 +1,138 @@
|
||||
# Davinci Platform — Developer Commands
|
||||
#
|
||||
# Unified monorepo: packages/api (NestJS), packages/web (Next.js), packages/shared.
|
||||
#
|
||||
# Dev stack: persistent data, ports 4300 (api) / 4000 (web) / 55434 (pg)
|
||||
# Test stack: ephemeral (always fresh DB), ports 4301 (api) / 4001 (web) / 45434 (pg)
|
||||
#
|
||||
# Usage:
|
||||
# make help Show all commands
|
||||
# make dev Start full dev stack
|
||||
# make test Full isolated smoke test
|
||||
|
||||
.PHONY: dev dev-build dev-logs dev-stop dev-reset dev-seed build test test-up test-down test\:unit test\:e2e test\:cov lint format format\:check db\:migrate db\:studio db\:push docker\:build docker\:up smoke down help
|
||||
|
||||
TEST = docker compose -p davinci-platform-test -f docker-compose.test.yml
|
||||
|
||||
# ─── Dev Stack ────────────────────────────────────────────────────
|
||||
|
||||
dev: ## Start docker-compose postgres + API + web in watch mode
|
||||
docker compose up db -d --wait
|
||||
pnpm dev
|
||||
@echo ""
|
||||
@echo " API: http://localhost:4300"
|
||||
@echo " Web: http://localhost:4000"
|
||||
@echo " Postgres: localhost:55434"
|
||||
@echo ""
|
||||
|
||||
dev-build: ## Rebuild and start dev stack (docker)
|
||||
docker compose up -d --build
|
||||
|
||||
dev-logs: ## Tail API container logs
|
||||
docker compose logs -f api
|
||||
|
||||
dev-stop: ## Stop dev containers (data preserved)
|
||||
docker compose down
|
||||
|
||||
dev-reset: ## Stop, destroy data, restart fresh
|
||||
docker compose down -v
|
||||
docker compose up -d --build
|
||||
@echo ""
|
||||
@echo " Dev stack reset with fresh database"
|
||||
@echo ""
|
||||
|
||||
dev-seed: ## Seed dev database with test data
|
||||
@echo "Seeding dev database..."
|
||||
DATABASE_URL=postgresql://davinci:davinci@localhost:55434/davinci_platform_dev \
|
||||
pnpm --filter @davinci/api exec prisma db seed
|
||||
@echo "Done."
|
||||
|
||||
# ─── Build ────────────────────────────────────────────────────────
|
||||
|
||||
build: ## Build all packages
|
||||
pnpm build
|
||||
|
||||
# ─── Testing ──────────────────────────────────────────────────────
|
||||
|
||||
test\:unit: ## Run unit tests only
|
||||
pnpm test:unit
|
||||
|
||||
test\:e2e: ## Run e2e tests only
|
||||
pnpm test:e2e
|
||||
|
||||
test\:cov: ## Run tests with coverage report
|
||||
pnpm test:cov
|
||||
|
||||
# ─── Test Stack (Isolated) ────────────────────────────────────────
|
||||
|
||||
test-up: ## Start isolated test environment (fresh DB, ephemeral)
|
||||
$(TEST) down -v 2>/dev/null || true
|
||||
$(TEST) up -d --build
|
||||
@echo ""
|
||||
@echo " Test API: http://localhost:4301"
|
||||
@echo " Test Web: http://localhost:4001"
|
||||
@echo " Test DB: localhost:45434"
|
||||
@echo ""
|
||||
|
||||
test-down: ## Tear down test environment (destroy data)
|
||||
$(TEST) down -v 2>/dev/null || true
|
||||
|
||||
test: test-up ## Run smoke tests in isolated test environment
|
||||
@echo "Waiting for services to be ready..."
|
||||
@sleep 10
|
||||
@API_PORT=4301 WEB_PORT=4001 bash smoke-test.sh; \
|
||||
EXIT_CODE=$$?; \
|
||||
$(MAKE) test-down; \
|
||||
exit $$EXIT_CODE
|
||||
|
||||
# ─── Smoke (against running dev stack) ────────────────────────────
|
||||
|
||||
smoke: ## Run smoke tests against dev stack (must be running)
|
||||
bash smoke-test.sh
|
||||
|
||||
# ─── Code Quality ─────────────────────────────────────────────────
|
||||
|
||||
lint: ## Lint all packages
|
||||
pnpm lint
|
||||
|
||||
format: ## Format all files with Prettier
|
||||
pnpm format
|
||||
|
||||
format\:check: ## Check formatting without writing
|
||||
pnpm format:check
|
||||
|
||||
# ─── Database ─────────────────────────────────────────────────────
|
||||
|
||||
db\:migrate: ## Create a new Prisma migration after schema changes
|
||||
@read -p "Migration name: " name; \
|
||||
DATABASE_URL=postgresql://davinci:davinci@localhost:55434/davinci_platform_dev \
|
||||
pnpm --filter @davinci/api exec prisma migrate dev --name $$name
|
||||
|
||||
db\:studio: ## Open Prisma Studio
|
||||
DATABASE_URL=postgresql://davinci:davinci@localhost:55434/davinci_platform_dev \
|
||||
pnpm --filter @davinci/api exec prisma studio
|
||||
|
||||
db\:push: ## Push schema changes (no migration — quick prototyping only)
|
||||
DATABASE_URL=postgresql://davinci:davinci@localhost:55434/davinci_platform_dev \
|
||||
pnpm --filter @davinci/api exec prisma db push
|
||||
|
||||
# ─── Docker ───────────────────────────────────────────────────────
|
||||
|
||||
docker\:build: ## Build production Docker image
|
||||
docker build -t davinci-platform .
|
||||
|
||||
docker\:up: ## Run full stack via docker-compose
|
||||
docker compose up -d
|
||||
|
||||
# ─── Cleanup ──────────────────────────────────────────────────────
|
||||
|
||||
down: ## Stop everything (dev + test)
|
||||
docker compose down 2>/dev/null || true
|
||||
$(TEST) down -v 2>/dev/null || true
|
||||
|
||||
# ─── Help ─────────────────────────────────────────────────────────
|
||||
|
||||
help: ## Show this help
|
||||
@grep -E '^[a-zA-Z_\\:-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
Reference in New Issue
Block a user