Repository navigation
Expand file tree
/
Copy pathjustfile
More file actions
124 lines (112 loc) · 4.02 KB
/
Copy pathjustfile
File metadata and controls
124 lines (112 loc) · 4.02 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
set shell := ["bash", "-eu", "-o", "pipefail", "-c"]
setup:
cargo --version
bun --version
just --version
cd apps/web && bun install --frozen-lockfile
cd apps/web && bun run build
dev:
#!/usr/bin/env bash
set -euo pipefail
if [ -f .env.local ]; then
set -a
source .env.local
set +a
fi
api_port="${ORBIT_DEV_API_PORT:-8080}"
web_port="${ORBIT_DEV_WEB_PORT:-8888}"
server_pid=""
web_pid=""
cleanup() {
for pid in "$server_pid" "$web_pid"; do
[ -z "$pid" ] || kill "$pid" 2>/dev/null || true
done
for pid in "$server_pid" "$web_pid"; do
[ -z "$pid" ] || wait "$pid" 2>/dev/null || true
done
}
trap cleanup EXIT
trap 'exit 0' INT TERM
ORBIT_DEV_API_PORT="${api_port}" ORBIT_DEV_WEB_PORT="${web_port}" scripts/dev-server-watch.sh &
server_pid=$!
(cd apps/web && VITE_API_PROXY="http://127.0.0.1:${api_port}" bun run dev -- --host 127.0.0.1 --port "${web_port}" --strictPort) &
web_pid=$!
wait -n "$server_pid" "$web_pid"
test:
just version-check
cargo test --workspace
cd apps/web && bun run test
version-check:
#!/usr/bin/env bash
set -euo pipefail
cargo_version=$(sed -n 's/^version = "\([^"]*\)"$/\1/p' Cargo.toml)
web_version=$(bun -e 'console.log(require("./apps/web/package.json").version)')
test -n "$cargo_version"
test "$web_version" = "$cargo_version" || {
echo "version mismatch: Cargo workspace is $cargo_version, web app is $web_version" >&2
exit 1
}
check:
just version-check
cd apps/web && bun run build
cargo fmt --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace
cd apps/web && bun run lint
cd apps/web && bun run test
just api-check
cargo build --release --workspace
api:
cargo run -p orbit-server -- openapi --output apps/web/src/api/generated/openapi.json
cd apps/web && bun run api:generate
api-check:
#!/usr/bin/env bash
set -euo pipefail
first=$(mktemp -d)
second=$(mktemp -d)
trap 'rm -rf "$first" "$second"' EXIT
generate() {
local output=$1
cargo run -q -p orbit-server -- openapi --output "$output/openapi.json" >/dev/null
(cd apps/web && bun run scripts/generate-api.ts "$output/openapi.json" "$output")
}
generate "$first"
generate "$second"
diff -ru "$first" "$second"
diff -ru apps/web/src/api/generated "$first"
db-reset:
ORBIT_ENV=development ORBIT__ENVIRONMENT=development cargo run -p orbit-server -- db-reset --yes
seed:
ORBIT_ENV=development ORBIT__ENVIRONMENT=development cargo run -p orbit-server -- seed
e2e:
#!/usr/bin/env bash
set -euo pipefail
data_dir=$(mktemp -d)
server_pid=""
e2e_pid=""
cleanup() {
for pid in "$server_pid" "$e2e_pid"; do
[ -z "$pid" ] || kill "$pid" 2>/dev/null || true
done
for pid in "$server_pid" "$e2e_pid"; do
[ -z "$pid" ] || wait "$pid" 2>/dev/null || true
done
rm -rf "$data_dir"
}
trap cleanup EXIT
trap 'exit 0' INT TERM
setup_url=$(ORBIT__ENVIRONMENT=development cargo run -q -p orbit-server -- --database "$data_dir/orbit.sqlite" setup-token init --origin http://127.0.0.1:8888)
ORBIT__ENVIRONMENT=development cargo run -p orbit-server -- --database "$data_dir/orbit.sqlite" --attachments "$data_dir/attachments" --backups "$data_dir/backups" serve --listen 127.0.0.1:18080 --origin http://127.0.0.1:8888 &
server_pid=$!
(cd apps/web && ORBIT_SETUP_URL="$setup_url" bun x playwright test) &
e2e_pid=$!
wait -n "$server_pid" "$e2e_pid"
build:
#!/usr/bin/env bash
set -euo pipefail
revision=$(git rev-parse HEAD)
(cd apps/web && ORBIT_BUILD_REVISION="$revision" bun run build)
ORBIT_BUILD_REVISION="$revision" cargo build --release --workspace
release-image tag="orbit:milestone-1":
docker build --build-arg ORBIT_BUILD_REVISION="$(git rev-parse HEAD)" -t "{{ tag }}" .
docker run --rm "{{ tag }}" --help