Skip to content
Clone
b6f7f73
125 lines 3.4 KB
# GitData 本地开发入口(Windows / macOS / Linux)。
#
# Windows:直接在 Windows 上跑 Rust/前端,依赖服务(PostgreSQL / Redis / RustFS)
# 由 WSL(Ubuntu) 的 systemd 托管(just infra)。
# macOS/Linux:原生跑 Rust/前端,依赖服务由 docker compose 托管(just infra)。
#
# 配置沿用 config/local/(gitignore)。首次使用:
# just check -> just infra -> just build -> just up
# 常用:just up / just down / just status / just tail apihost
#
# 二进制目录跟随 cargo 的 CARGO_TARGET_DIR(just build 与 just up 一致读同一个变量):
# CARGO_TARGET_DIR=/tmp/kenapi just up
# 日志 / pid / 本地 git 仓库仍固定在 target/dev,不随 CARGO_TARGET_DIR 搬家。
#
# 依赖工具:cargo、ssh-keygen;Windows 额外需要 WSL 的 Ubuntu 发行版,
# macOS/Linux 额外需要 docker + docker compose。
# 需要 just >= 1.21。
set shell := ["bash", "-cu"]
set windows-shell := ["powershell.exe", "-NoLogo", "-NoProfile", "-Command"]
root := justfile_directory()
dev := if os() == "windows" {
root + "\\scripts\\dev.ps1"
} else {
root + "/scripts/dev.sh"
}
# PowerShell 调用脚本需要 & 前缀;POSIX shell 直接执行
invoke := if os() == "windows" { "& " } else { "" }
# 查看服务状态(默认)
status:
@{{ invoke }}"{{ dev }}" status
# 自检:工具链 / 依赖服务 / 后端二进制
check:
@{{ invoke }}"{{ dev }}" check
# 启动依赖服务:PostgreSQL / Redis / RustFS(S3)
infra:
@{{ invoke }}"{{ dev }}" infra
# 停止依赖服务
infra-down:
@{{ invoke }}"{{ dev }}" infra-down
# 同步数据库 schema
migrate:
@{{ invoke }}"{{ dev }}" migrate
# 构建全部后端二进制
# 遵循 CARGO_TARGET_DIR;just up 从同一目录取二进制。
build:
@cargo build --bins
# 构建全部后端 release 二进制
build-release:
@cargo build --release --bins
# 启动全部服务(后端)
# 二进制目录 = $CARGO_TARGET_DIR/debug(未设置则 target/debug)。
up *svc='':
@{{ invoke }}"{{ dev }}" up {{ svc }}
# 仅启动后端服务(apihost)
up-backend:
@{{ invoke }}"{{ dev }}" up backends
# 停止全部服务,或指定:just down apihost
down *svc='':
@{{ invoke }}"{{ dev }}" down {{ svc }}
# 重启全部服务,或指定:just restart apihost
restart *svc='':
@{{ invoke }}"{{ dev }}" restart {{ svc }}
# 最近日志:just logs / just logs apihost
logs *svc="apihost":
@{{ invoke }}"{{ dev }}" logs {{ svc }}
# 跟踪日志:just tail / just tail apihost
tail svc="apihost":
@{{ invoke }}"{{ dev }}" logs {{ svc }} -f
# 进入 PostgreSQL 交互终端
psql:
@{{ invoke }}"{{ dev }}" psql
# 进入 redis-cli 交互终端
redis:
@{{ invoke }}"{{ dev }}" redis
# URL 速查
urls:
@echo " kenapi http://127.0.0.1:7051 (Swagger: /api/docs)"
@echo " identity http://127.0.0.1:7021 (gRPC: 127.0.0.1:7022)"
# 重新生成 openapi.json
openapi:
@cargo run -p kenapi -- openapi
# 校验 openapi 是否与源码一致
openapi-check:
@cargo run -p kenapi -- openapi --check
# cargo fmt --all
fmt:
@cargo fmt --all
# cargo clippy 全 workspace
clippy:
@cargo clippy --workspace --all-targets --all-features
# 清理构建产物
clean:
@cargo clean
# 登录前端随 kenapi 发布。
identity-web-build:
npm ci && npm run build
identity-web-dev:
npm run dev
identity-openapi:
cargo run -p kenapi -- identity-openapi