# GitData 本地开发入口(Windows / macOS / Linux)。 # # Windows:直接在 Windows 上跑 Rust/前端,依赖服务(PostgreSQL / Redis / RustFS / # Meilisearch)由 WSL(Ubuntu) 的 systemd 托管(just infra)。 # macOS/Linux:原生跑 Rust/前端,依赖服务由 docker compose 托管(just infra)。 # # 配置沿用 config/local.toml(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、bun、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) / Meilisearch infra: @{{ invoke }}"{{ dev }}" infra # 停止依赖服务 infra-down: @{{ invoke }}"{{ dev }}" infra-down # 生成 githost 使用的本地 SSH host key(target/dev/ssh_host_ed25519) hostkey: @{{ invoke }}"{{ dev }}" hostkey # 同步数据库 schema migrate: @{{ invoke }}"{{ dev }}" migrate # 构建全部后端二进制(web 前端由 build.rs 构建并内嵌) # 遵循 CARGO_TARGET_DIR;just up 从同一目录取二进制。 build: @cargo build --bins # 构建全部后端 release 二进制 build-release: @cargo build --release --bins # 启动全部服务(后端 + web) # 二进制目录 = $CARGO_TARGET_DIR/debug(未设置则 target/debug)。 up *svc='': @{{ invoke }}"{{ dev }}" up {{ svc }} # 仅启动后端服务(apihost/githost/im/synchost/webhook) up-backend: @{{ invoke }}"{{ dev }}" up backends # 仅启动前端 web(5173) up-frontend: @{{ invoke }}"{{ dev }}" up frontends # 停止全部服务,或指定:just down apihost im down *svc='': @{{ invoke }}"{{ dev }}" down {{ svc }} # 重启全部服务,或指定:just restart apihost restart *svc='': @{{ invoke }}"{{ dev }}" restart {{ svc }} # 最近日志:just logs / just logs apihost / just logs "apihost im" 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 " apihost http://127.0.0.1:4081 (Swagger: /api/docs)" @echo " githost http://127.0.0.1:9418 ssh://git@127.0.0.1:4022" @echo " im ws://127.0.0.1:4082" @echo " synchost http://127.0.0.1:4083/healthz" @echo " webhook http://127.0.0.1:3005" @echo " web http://127.0.0.1:5173" # 重新生成 openapi.json openapi: @cargo run -p openapi # 校验 openapi 是否与源码一致 openapi-check: @cargo run -p openapi -- --check # web 前端单独构建(cargo 构建时会自动执行) web-build: @bun run --cwd web build # web 前端 lint(oxlint + FSD 导航守卫) web-lint: @bun run --cwd web lint # cargo fmt --all fmt: @cargo fmt --all # cargo clippy 全 workspace clippy: @cargo clippy --workspace --all-targets --all-features # 清理构建产物 clean: @cargo clean