You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iTi-Flask/docs/COPIER_TEMPLATE.md

91 lines
1.7 KiB
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Copier 模板
`copier-template` 生成 FastAPI 业务后端骨架。
模板只引用框架包,不复制框架源码。
## 生成
```bash
./scripts/iti.sh make-app ../my-business-app my_business_app
cd ../my-business-app
./scripts/app.sh init
./scripts/app.sh serve 8000
```
Windows
```bat
scripts\iti.cmd make-app ..\my-business-app my_business_app
cd ..\my-business-app
scripts\app.cmd init
scripts\app.cmd serve 8000
```
## 参数
| 参数 | 说明 |
| --- | --- |
| `project_name` | 业务项目显示名称 |
| `project_slug` | 业务项目 Python 包名 |
| `framework_git` | iTi-Flask Git 地址 |
| `framework_tag` | iTi-Flask Git tag |
| `include_system` | 是否引入 iTi-System |
| `system_git` | iTi-System Git 地址 |
| `system_tag` | iTi-System Git tag |
默认推荐私有 Git tag。
允许改成 branch 或 `file://`,但多人协作项目不建议依赖本机路径。
## 生成内容
- `app.py`
- `config.py`
- `pyproject.toml`
- `migrations/`
- 示例 FastAPI 模块
- 示例 SQLAlchemy 模型
- 示例测试
- `scripts/app.sh`
- `scripts/app.cmd`
## 系统业务
选择 `include_system=true` 时,模板会注册 `create_system_module()`
生成后执行:
```bash
./scripts/app.sh init-system
```
Windows
```bat
scripts\app.cmd init-system
```
## 生成项目脚本
模板会生成两份脚本:
- `scripts/app.sh`Linux / macOS / Git Bash。
- `scripts/app.cmd`Windows CMD。
常用命令:
```bash
./scripts/app.sh help
./scripts/app.sh install
./scripts/app.sh test
./scripts/app.sh serve 8000
./scripts/app.sh migration "alice add order table"
./scripts/app.sh migrate
```
`iti-system` 的项目还会有:
```bash
./scripts/app.sh system-sync
./scripts/app.sh system-seed
./scripts/app.sh init-system
```