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/copier-template
NoahLan 3f41f4a2d1 chore: release v0.3.0 1 week ago
..
.codex/skills/{{ project_slug | lower | replace('_', '-') }}-project chore: cli tools 1 week ago
.vscode chore: 部署、启动参数模板 1 week ago
app chore: 部署、启动参数模板 1 week ago
migrations chore: 部署、启动参数模板 1 week ago
tests chore: directory changed 1 week ago
.dockerignore chore: 部署、启动参数模板 1 week ago
.env.example.jinja chore: 部署、启动参数模板 1 week ago
.gitignore chore: v0.2.2 1 week ago
Dockerfile.jinja chore: 部署、启动参数模板 1 week ago
README.md.jinja chore: cli tools 1 week ago
config.py.jinja chore: 部署、启动参数模板 1 week ago
docker-compose.with-db.yml.jinja chore: 部署、启动参数模板 1 week ago
docker-compose.yml.jinja chore: 部署、启动参数模板 1 week ago
main.py.jinja chore: 部署、启动参数模板 1 week ago
pyproject.toml.jinja chore: release v0.3.0 1 week ago
{{ _copier_conf.answers_file }}.jinja Add project template sync workflow 2 weeks ago

README.md.jinja

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.

# {{ project_name }}

FastAPI 业务后端项目。
由 iTi-Flask Copier 模板生成。

AI 修改本项目时优先读:

```text
.codex/skills/{{ project_slug | lower | replace('_', '-') }}-project/SKILL.md
```

该 skill 只描述本项目的通用工程规则。
具体业务知识写在本项目自己的 README/docs。

## 依赖

默认使用私有 Git 依赖。
推荐固定 tag也允许 branch。
`file://` 只建议框架开发者本机验证模板时使用。

## 初始化

```bash
cp .env.example .env
iticli init
```

Windows

```bat
iticli init
```

{% if include_system %}
同步系统 migration 和 seed

```bash
iticli init system
```

Windows

```bat
iticli init system
```
{% endif %}

## 开发

```bash
iticli run dev
iticli test
```

不同环境直接在命令前设 `APP_ENV`,或把环境名作为 `run` 的第一个参数:

```bash
iticli run dev
iticli run test 8000
APP_ENV=prod iticli migrate
```

## Docker

```bash
cp .env.example .env
iticli docker up
iticli docker logs
iticli docker down
```

`docker-compose.yml` 默认只启动应用,数据库使用外部 MySQL。
需要本地 MySQL 时使用:

```bash
iticli docker up --db
iticli docker down --db
```

应用容器启动时会先执行 migration{% if include_system %} 和系统 seed{% endif %}。
本地运行数据写入 `runtime/`MySQL 数据写入 Compose volume。

## 同步更新

同步框架包:

```bash
iticli sync flask
```

检查模板:

```bash
iticli template check
```

按模板更新项目骨架:

```bash
iticli template update
```

模板更新会改 `main.py`、`app/app_factory.py`、`config.py`、`Dockerfile`、`docker-compose.yml`、`docker-compose.with-db.yml`、`.dockerignore`、`.env.example`、`.vscode/launch.json`、示例模块、测试和项目 skill 等模板拥有的文件。
该命令跟随模板仓库 `HEAD`。
执行前先提交或暂存当前项目改动,执行后检查 diff。

## VSCode 调试

模板内置 `.vscode/launch.json`。
选择 `{{ project_name }}: FastAPI` 即可用 `uvicorn main:app --reload` 调试。

## 数据库迁移

```bash
iticli migrate revision "alice add example table"
iticli migrate
```

规则:

- `migrations/versions` 必须提交。
- migration message 第一个词写作者名。
- 生产只从 `main` 执行 `alembic -c migrations/alembic.ini upgrade head`。