-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
87 lines (63 loc) · 3.11 KB
/
Makefile
File metadata and controls
87 lines (63 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.PHONY: help install-backend install-agent install-mobile install-all dev dev-backend dev-mobile test test-backend test-unit test-integration test-mobile lint lint-fix docker-up docker-down docker-build docker-logs docker-ps migrate-gen migrate migrate-down clean
# 默认目标
help: ## 查看所有可用命令
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
# ===== 安装 =====
install-backend: ## 安装后端依赖
cd app/backend/server && uv sync --index-url https://mirrors.aliyun.com/pypi/simple/
install-agent: ## 安装 AI Agent 依赖
cd app/backend/ai-agent && uv sync --index-url https://mirrors.aliyun.com/pypi/simple/
install-mobile: ## 安装客户端依赖
cd app/frontend/mobile && flutter pub get
install-all: install-backend install-agent install-mobile ## 安装所有依赖
# ===== 开发 =====
dev: ## 本地启动所有服务(需先 docker-up 启动基础设施)
@echo "启动后端..."
cd app/backend/server && uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 &
@echo "启动客户端..."
cd app/frontend/mobile && flutter run
@echo "所有服务已启动"
dev-backend: ## 仅启动后端(开发模式)
cd app/backend/server && uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
dev-mobile: ## 仅启动客户端
cd app/frontend/mobile && flutter run
# ===== 测试 =====
test: test-backend test-mobile ## 运行全部测试
test-backend: ## 运行后端测试
cd app/backend/server && uv run pytest -v
test-unit: ## 运行后端单元测试
cd app/backend/server && uv run pytest tests/unit -v
test-integration: ## 运行后端集成测试
cd app/backend/server && uv run pytest tests/integration -v
test-mobile: ## 运行客户端测试
cd app/frontend/mobile && flutter test
# ===== 代码检查 =====
lint: ## 代码检查
cd app/backend/server && uv run ruff check src/
cd app/frontend/mobile && flutter analyze
lint-fix: ## 自动修复代码风格问题
cd app/backend/server && uv run ruff check --fix src/
cd app/frontend/mobile && dart fix --apply
# ===== Docker =====
docker-up: ## Docker 启动所有服务
cd app/deploy && docker compose up -d
docker-down: ## Docker 停止所有服务
cd app/deploy && docker compose down
docker-build: ## Docker 构建镜像
cd app/deploy && docker compose build
docker-logs: ## 查看 Docker 日志
cd app/deploy && docker compose logs -f
docker-ps: ## 查看 Docker 服务状态
cd app/deploy && docker compose ps
# ===== 数据库迁移 =====
migrate-gen: ## 生成数据库迁移(用法:make migrate-gen msg="描述")
cd app/backend/server && uv run alembic revision --autogenerate -m "$(msg)"
migrate: ## 执行数据库迁移
cd app/backend/server && uv run alembic upgrade head
migrate-down: ## 回退最近一次迁移
cd app/backend/server && uv run alembic downgrade -1
# ===== 清理 =====
clean: ## 清理生成文件
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type d -name .pytest_cache -exec rm -rf {} + 2>/dev/null || true
find . -name "*.pyc" -delete 2>/dev/null || true