129 lines
3.6 KiB
Makefile
129 lines
3.6 KiB
Makefile
.PHONY: install build clean test test-unit test-integration test-e2e test-all test-cov \
|
|
docker-build docker-up docker-down docker-test docker-test-all \
|
|
prisma-generate prisma-migrate prisma-studio lint format
|
|
|
|
# ============================================
|
|
# 基础命令
|
|
# ============================================
|
|
install:
|
|
npm install
|
|
|
|
build:
|
|
npm run build
|
|
|
|
clean:
|
|
rm -rf dist node_modules coverage .nyc_output
|
|
|
|
lint:
|
|
npm run lint
|
|
|
|
format:
|
|
npm run format
|
|
|
|
# ============================================
|
|
# Prisma 命令
|
|
# ============================================
|
|
prisma-generate:
|
|
npx prisma generate
|
|
|
|
prisma-migrate:
|
|
npx prisma migrate dev
|
|
|
|
prisma-migrate-prod:
|
|
npx prisma migrate deploy
|
|
|
|
prisma-studio:
|
|
npx prisma studio
|
|
|
|
# ============================================
|
|
# 测试命令
|
|
# ============================================
|
|
test: test-unit
|
|
|
|
test-unit:
|
|
@echo "=========================================="
|
|
@echo "Running Unit Tests..."
|
|
@echo "=========================================="
|
|
npm test
|
|
|
|
test-unit-cov:
|
|
@echo "=========================================="
|
|
@echo "Running Unit Tests with Coverage..."
|
|
@echo "=========================================="
|
|
npm run test:cov
|
|
|
|
test-integration:
|
|
@echo "=========================================="
|
|
@echo "Running Integration Tests..."
|
|
@echo "=========================================="
|
|
npm run test:integration
|
|
|
|
test-e2e:
|
|
@echo "=========================================="
|
|
@echo "Running E2E Tests..."
|
|
@echo "=========================================="
|
|
npm run test:e2e
|
|
|
|
test-all: test-unit test-integration test-e2e
|
|
@echo "=========================================="
|
|
@echo "All Tests Completed!"
|
|
@echo "=========================================="
|
|
|
|
test-cov:
|
|
@echo "=========================================="
|
|
@echo "Running All Tests with Coverage..."
|
|
@echo "=========================================="
|
|
npm run test:cov
|
|
|
|
# ============================================
|
|
# Docker 命令
|
|
# ============================================
|
|
docker-build:
|
|
docker build -t referral-service:test -f Dockerfile.test .
|
|
|
|
docker-up:
|
|
docker-compose -f docker-compose.test.yml up -d
|
|
|
|
docker-down:
|
|
docker-compose -f docker-compose.test.yml down -v
|
|
|
|
docker-test-unit:
|
|
@echo "=========================================="
|
|
@echo "Running Unit Tests in Docker..."
|
|
@echo "=========================================="
|
|
docker-compose -f docker-compose.test.yml run --rm test npm test
|
|
|
|
docker-test-integration:
|
|
@echo "=========================================="
|
|
@echo "Running Integration Tests in Docker..."
|
|
@echo "=========================================="
|
|
docker-compose -f docker-compose.test.yml run --rm test npm run test:integration
|
|
|
|
docker-test-e2e:
|
|
@echo "=========================================="
|
|
@echo "Running E2E Tests in Docker..."
|
|
@echo "=========================================="
|
|
docker-compose -f docker-compose.test.yml run --rm test npm run test:e2e
|
|
|
|
docker-test-all: docker-up
|
|
@echo "=========================================="
|
|
@echo "Running All Tests in Docker..."
|
|
@echo "=========================================="
|
|
docker-compose -f docker-compose.test.yml run --rm test make test-all
|
|
$(MAKE) docker-down
|
|
|
|
# ============================================
|
|
# 开发命令
|
|
# ============================================
|
|
dev:
|
|
npm run start:dev
|
|
|
|
start:
|
|
npm run start:prod
|
|
|
|
# ============================================
|
|
# CI/CD 命令
|
|
# ============================================
|
|
ci: install lint build test-all
|
|
@echo "CI Pipeline Completed!"
|