-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Justfile
95 lines (75 loc) · 2.5 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
83
84
85
86
87
88
89
90
91
92
93
94
95
set dotenv-load
# show available recipes.
list:
@just --list
# detect before running cli and install it if it doesn't exist.
_cargo_ cli *args:
#!/bin/sh
if [ -z $(which {{cli}}) ]; then
cargo install {{cli}}
fi
case {{cli}} in
cargo-*) cargo $(echo {{cli}} | sed "s/^cargo-//") {{args}} ;;
* ) {{cli}} {{args}} ;;
esac
# running dev server.
run:
just _cargo_ cargo-watch -x run
# building production.
build:
cargo build --release
# building multi-arch production.
buildx:
just _build x86_64-unknown-linux-gnu
just _build x86_64-unknown-linux-musl
just _zigbuild aarch64-unknown-linux-gnu
just _zigbuild aarch64-unknown-linux-musl
_build target:
rustup target add {{target}}
cargo build --release --target {{target}}
_zigbuild target:
rustup target add {{target}}
just _cargo_ cargo-zigbuild --release --target {{target}}
# format code. (args example: just fmt --check)
fmt *args='':
cargo fmt --all {{args}}
# check code. (args example: just check --quiet)
check *args='':
cargo check --all {{args}}
# lint code. (args example: just lint --fix)
lint *args='':
cargo clippy {{args}} -- -W clippy::pedantic -W clippy::nursery -A clippy::missing-errors-doc -A clippy::module_name_repetitions
# running tests via cargo-nextest.
test *args='':
cargo nextest run --all {{args}}
# running tests.
test-cargo *args='':
cargo test --all {{args}}
# update dependencies.
up:
cargo update
# create and remove account (method: create/remove) (name: example.com)
account method name:
#!/bin/sh
if [ -z ${HATSU_ACCESS_TOKEN+x} ]; then
echo "env HATSU_ACCESS_TOKEN must be set"
else
just _account {{method}} {{name}}
fi
_account method name:
curl -X POST "http://localhost:${HATSU_LISTEN_PORT}/api/v0/admin/{{method}}-account?name={{name}}&token=${HATSU_ACCESS_TOKEN}"
# /api/v0/admin/block-url
block-url url:
curl -X POST "http://localhost:${HATSU_LISTEN_PORT}/api/v0/admin/block-url?url={{url}}&token=${HATSU_ACCESS_TOKEN}"
# /api/v0/admin/unblock-url
unblock-url url:
curl -X POST "http://localhost:${HATSU_LISTEN_PORT}/api/v0/admin/unblock-url?url={{url}}&token=${HATSU_ACCESS_TOKEN}"
# use db_* without underscores.
db *args='migration up':
just db_{{args}}
# apply migrations to database.
db_migration *args='up':
just _cargo_ sea-orm-cli migrate {{args}} -d crates/db_migration -u $HATSU_DATABASE_URL
# generate entities from database.
db_schema: (db_migration 'fresh')
just _cargo_ sea-orm-cli generate entity -l -o crates/db_schema/src -u $HATSU_DATABASE_URL