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.

127 lines
3.1 KiB
Markdown

# iti-flask-cli
`iticli` 是 iTi-Flask 框架项目和模板生成业务项目共用的命令行工具。
它是独立工具。
框架项目和新生成的业务项目都不需要内置 `.sh` / `.cmd` 脚本。
## 安装
私有 Git 安装:
```bash
uv tool install git+https://git.noahlan.cn/iti-framework/iti-flask-cli.git
```
或:
```bash
pipx install git+https://git.noahlan.cn/iti-framework/iti-flask-cli.git
```
本地开发安装:
```bash
cd iti-flask-cli
uv tool install -e .
```
## 项目识别
`iticli` 会从当前目录向上查找 `pyproject.toml`,并识别两类项目:
- 框架项目:`project.name = "iti-flask"`,且包含 `iti/app.py`、`copier.yml`。
- 业务项目:包含 `main.py`、`app/`、`migrations/alembic.ini`,且依赖 `iti-flask`
`create` 不要求当前目录是项目目录。
默认从私有 Git 里的 iTi-Flask Copier 模板生成业务项目。
## 常用命令
```bash
iticli help
iticli install
iticli install dev
iticli install odbc
iticli test
iticli run dev 8000
iticli serve dev 8000
iticli run prod 8000
iticli migrate
iticli migrate heads
iticli migrate current
iticli migrate revision "alice add order table"
```
业务项目:
```bash
iticli update framework
iticli update system
iticli update all
iticli template check
iticli template update
iticli init
iticli init system
iticli docker build
iticli docker up
iticli docker up --db
iticli docker logs
iticli docker down
```
CLI 自身:
```bash
iticli update self
```
框架项目:
```bash
iticli release
iticli release v0.2.5
```
任意目录生成业务项目:
```bash
iticli create my-business-app
iticli create --with-system my-system-app
```
使用当前框架工作区作为模板源:
```bash
cd iTi-Flask
iticli create --local ../my-business-app
```
## 旧项目迁移
旧仓库或旧业务项目里如果还保留脚本,可以按下面迁移:
| 旧命令 | 新命令 |
| --- | --- |
| `./iti.sh install` / `./app.sh install` | `iticli install` |
| `./iti.sh test` / `./app.sh test` | `iticli test` |
| `./iti.sh serve 8000` / `./app.sh serve dev 8000` | `iticli run dev 8000``iticli serve dev 8000` |
| `./iti.sh migrate` / `./app.sh migrate` | `iticli migrate` |
| `./iti.sh heads` / `./app.sh heads` | `iticli migrate heads` |
| `./iti.sh current` / `./app.sh current` | `iticli migrate current` |
| `./iti.sh migration "msg"` / `./app.sh migration "msg"` | `iticli migrate revision "msg"` |
| `./iti.sh make-app ../app app` | `iticli create app` |
| `./iti.sh make-system-app ../app app` | `iticli create --with-system app` |
| `./iti.sh release` | `iticli release` |
| `./app.sh framework-sync` | `iticli update framework` |
| `./app.sh system-sync` | `iticli update system` |
| `./app.sh template-check` | `iticli template check` |
| `./app.sh template-update` | `iticli template update` |
| `./app.sh init` | `iticli init` |
| `./app.sh init-system` | `iticli init system` |
| `./app.sh docker-up` | `iticli docker up` |
| `./app.sh docker-up-db` | `iticli docker up --db` |
`install odbc` 会同步开发依赖,并把 `pyodbc` 安装进当前项目虚拟环境。
ODBC 系统驱动仍由操作系统或镜像负责安装。