Files
DjangoAdmin_Flask_EleVue/Makefile
T
DjangoAdmin DevandClaude 8691412ec6 chore: P1 工程化工具链
- pyproject.toml:pytest/black/isort/mypy 统一配置
- requirements-dev.txt:测试与代码规范开发依赖
- .flake8 / .editorconfig:PEP8 与编辑器统一
- .pre-commit-config.yaml:提交前钩子
- Makefile:常用命令集
- .env.example:环境变量模板(76 键)
- tests/:pytest 骨架 + R 响应格式冒烟测试

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-07 12:14:51 +08:00

70 lines
2.3 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ============================================================
# DjangoAdmin Flask+EleVue 常用命令集
# 用法:make help / make lint / make test / ...
# ============================================================
PYTHON ?= python
PIP ?= $(PYTHON) -m pip
FLASK ?= $(PYTHON) -m flask
.PHONY: help install install-dev dev lint format type-check test test-cov \
db-migrate db-upgrade db-downgrade docker-up docker-down clean
help: ## 显示全部命令帮助
@grep -E '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
# ---- 依赖 ----
install: ## 安装生产依赖
$(PIP) install -r requirements.txt
install-dev: ## 安装开发依赖(含生产依赖 + 测试/规范工具)
$(PIP) install -r requirements-dev.txt
# ---- 运行 ----
dev: ## 启动开发服务器(127.0.0.1:8021)
$(PYTHON) app.py
# ---- 代码质量 ----
lint: ## 静态检查(flake8 + black + isort)
flake8 application utils extensions config src tests scripts
black --check --line-length 120 application utils extensions config src tests scripts
isort --check-only application utils extensions config src tests scripts
format: ## 自动格式化(black + isort)
black --line-length 120 application utils extensions config src tests scripts
isort application utils extensions config src tests scripts
type-check: ## 类型检查(mypy)
mypy application src
# ---- 测试 ----
test: ## 运行全部测试
pytest
test-cov: ## 带覆盖率运行测试
pytest --cov=application --cov-report=term-missing
# ---- 数据库迁移 ----
db-migrate: ## 生成迁移脚本(模型变更后)
$(FLASK) db migrate
db-upgrade: ## 应用迁移到最新
$(FLASK) db upgrade
db-downgrade: ## 回滚一次迁移
$(FLASK) db downgrade
# ---- Docker ----
docker-up: ## 启动 Docker 服务
cd docker && docker-compose up -d
docker-down: ## 停止 Docker 服务
cd docker && docker-compose down
# ---- 清理 ----
clean: ## 清理缓存与临时文件
find . -type d -name __pycache__ -not -path "*/ui/*" -exec rm -rf {} +
find . -type f -name "*.pyc" -not -path "*/ui/*" -delete
rm -rf .pytest_cache .mypy_cache