-
Notifications
You must be signed in to change notification settings - Fork 4
/
justfile
82 lines (61 loc) · 1.98 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
set dotenv-load
# 你可以在项目根目录创建`.env`文件,写入`PYTHON = "./.venv/Scripts/python.exe"`等。
# 这样能跳过 poetry 使用虚拟环境,稍快一些。
python := env_var_or_default("PYTHON", "python")
is_dev := if env_var_or_default("DJANGO_PRODUCTION", "") == "" {
"true"
} else {
"false"
}
poetry_install_additional_args := if env_var_or_default("CI", "") == "" {
""
} else {
"--sync"
}
src_dir := "contest"
# 列出可用任务
@default:
just --list
# 调用 Django 的 manage.py
[private]
manage *ARGS:
{{ python }} {{ src_dir }}/manage.py {{ ARGS }}
# 启动 Django 服务器
serve: (manage "runserver")
# 运行 Python 交互解释器,可操作数据库
shell: (manage "shell")
# 检查类型
[private]
mypy:
{{ python }} -m mypy .
# 运行测试
[private]
test: (manage "test" "quiz")
# 检查所有
check-all: mypy test (manage "check") (manage "makemigrations" "--check")
# (部署)检查
check-deploy: && test (manage "check" "--deploy")
@echo \$DJANGO_PRODUCTION: {{ env_var("DJANGO_PRODUCTION") }}
# 更新依赖
[private]
update-dependencies:
poetry install --no-root {{ if is_dev == "false" { "--without dev" } else { "" } }} {{ poetry_install_additional_args }}
{{ if is_dev == "true" { "pnpm --dir " + src_dir + "/theme/static_src/ install" } else { "" } }}
{{ if is_dev == "true" { "pnpm --dir " + src_dir + "/js/static_src/ install" } else { "" } }}
# 更新依赖、数据库等(拉取他人提交后建议运行)
update: update-dependencies (manage "migrate")
# 监视 theme 并随时构建
watch-theme: (manage "tailwind start")
# 构建 theme
build-theme: (manage "tailwind build")
# 监视 js 并随时构建
watch-js:
pnpm --dir {{ src_dir }}/js/static_src/ run watch
# 构建 js
build-js:
pnpm --dir {{ src_dir }}/js/static_src/ run build
# celery
task-beat:
cd {{ src_dir }} ; celery -A contest beat -l info
task-worker:
cd {{ src_dir }} ; celery -A contest worker -P eventlet -l info