-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
88 lines (65 loc) · 2.89 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
export RUST_LOG := "watchexec_cli=error"
set dotenv-filename := "./backend/.env"
tmpdir := `mktemp -d`
check-all:
spectral lint ./api/schema/schema.yaml --fail-severity error
cd app && npm run lint
cd app && tsc --noEmit --project tsconfig.json
cd ./backend && go test -race ./...
cd backend && staticcheck ./...
cd backend && go vet ./...
cd backend && test -z $(gofmt -l .)
cd backend && go mod tidy && git diff --exit-code -- go.mod go.sum
gen:
cd backend && test ! -f .env.local || cat .env.local | cut -d '=' -f 1 | xargs -I {} echo {}= >.env.local.example
cd app && test ! -f .env.local || cat .env.local | cut -d '=' -f 1 | xargs -I {} echo {}= >.env.local.example
cd app && npm run build:dependency-report
cd backend && mockery
just api-schema-gen
just sqlc-gen
backend-test-watch:
cd ./backend && watchexec --clear=clear --restart go test -race ./...
api-watch:
cd ./backend && watchexec --clear=clear --restart \
'go build -race -o {{tmpdir}}/plantopo-api ./cmd/api && {{tmpdir}}/plantopo-api'
api-schema-watch:
watchexec --watch ./api/schema just api-schema-gen
api-schema-gen:
spectral lint ./api/schema/schema.yaml --fail-severity error
cp api/schema/schema.yaml backend/internal/papi/schema.gen.yaml
cd backend && ogen \
-loglevel warn \
-target internal/papi -package papi \
-clean \
./internal/papi/schema.gen.yaml
cd app && npx openapi-typescript ../api/schema/schema.yaml -o ./api/v1.d.ts && npx prettier --write ./api/v1.d.ts
sqlc-watch:
cd backend && watchexec \
--watch ./sqlc.yaml --watch ./migrations --watch ./internal/psqlc/queries \
just sqlc-gen
sqlc-gen:
cd backend && sqlc generate
river-ui:
docker pull ghcr.io/riverqueue/riverui:latest
docker run -p 4003:8080 --env "DATABASE_URL=postgres://plantopo:password@host.docker.internal:5432/plantopo?sslmode=disable" ghcr.io/riverqueue/riverui:latest
migration name:
tern --migrations backend/migrations new {{name}}
migrate *args:
cd backend && tern --migrations migrations --conn-string "$DATABASE_URL" migrate {{args}}
migrate-prod-up:
#!/usr/bin/env bash
set -euox pipefail
cd backend
export PROD_DATABASE_URL=$(op read "op://plantopo/plantopo-prod/plantopo_prod/url")
river migrate-up --database-url "$PROD_DATABASE_URL"
tern migrate --conn-string "$PROD_DATABASE_URL" --migrations migrations
prod-psql:
psql $(op read "op://plantopo/plantopo-prod/plantopo_prod/url")
pre-commit:
just check-all
loc:
tokei . -e '*.sql.go' -e '*_gen.go' -e '*.gen.go' -e '*.d.ts' -t go,sql,css,tsx,typescript
deploy-geder-worker:
cd backend && GOOS=linux GOARCH=amd64 go build -o /tmp/plantopo_geder_worker ./cmd/geder_worker
rsync -aP /tmp/plantopo_geder_worker geder:/var/plantopo/worker
ssh root@geder "systemctl restart plantopo-worker && systemctl status plantopo-worker"