名称: 任务执行器 描述: “使用just运行项目命令。检查项目根目录是否存在justfile,列出可用任务,执行常见操作如测试、构建、代码检查。触发场景:运行测试、构建项目、列出任务、检查可用命令、运行脚本、项目命令。” 兼容性: “需要just CLI工具。安装方法:brew install just (macOS) 或 cargo install just (跨平台)。” 允许工具: “Bash Glob”
任务执行器
目的
使用just执行项目特定命令,just是一个比make更简单且跨平台的现代命令运行器。
工具
| 工具 | 命令 | 用途 |
|---|---|---|
| just | just |
列出可用配方 |
| just | just test |
运行特定配方 |
使用示例
基础用法
# 列出所有可用配方
just
# 运行一个配方
just test
just build
just lint
# 带参数运行配方
just deploy production
# 从子目录运行特定配方
just --justfile backend/justfile test
常见justfile配方
# 示例justfile
# 运行测试
test:
pytest tests/
# 构建项目
build:
npm run build
# 代码检查
lint:
ruff check .
eslint src/
# 启动开发服务器
dev:
npm run dev
# 清理构建产物
clean:
rm -rf dist/ build/ *.egg-info/
# 部署到环境
deploy env:
./scripts/deploy.sh {{env}}
发现
# 检查justfile是否存在
just --summary
# 显示配方详情
just --show test
# 列出带描述的配方
just --list
何时使用
- 首次检查:
just查看可用项目命令 - 运行测试:
just test - 构建:
just build - 任何项目特定任务
- 跨平台命令运行
最佳实践
进入新项目时始终检查justfile:
just --list
这样无需阅读文档就能查看可用命令。