-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathjustfile
More file actions
125 lines (99 loc) · 2.83 KB
/
justfile
File metadata and controls
125 lines (99 loc) · 2.83 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
125
set quiet := true
export CGO_ENABLED := '0'
export PORT := '8282'
export DATABASE := 'tmp/pkgstats.db'
export GEOIP_DATABASE := 'tmp/GeoIP2-Country.mmdb'
[private]
default:
just --list
# first-time setup: install dependencies, build and generate fixtures
init: install build-assets build-templates fixtures
# install dependencies and test data
install:
curl -sf 'https://raw.githubusercontent.com/maxmind/MaxMind-DB/main/test-data/GeoIP2-Country-Test.mmdb' -o '{{ GEOIP_DATABASE }}'
go mod download
pnpm install
# compile frontend assets
build-assets:
pnpm run build
# generate Go code and templ templates
build-templates:
go generate ./...
go tool templ generate
# build the production binary
build: build-assets build-templates
go build -tags production -o pkgstatsd -ldflags="-s -w" -trimpath
# run the application locally
run:
go run -tags development .
# open the local dev server in the default browser
open:
xdg-open 'http://localhost:{{ PORT }}'
# watch for template and Go changes and rebuild automatically
[parallel]
dev: dev-assets dev-server
[private]
dev-assets:
pnpm exec vite build --watch
[private]
dev-server:
air
# run all tests
test:
go test ./...
# run all linters
lint:
pnpm run lint
golangci-lint run
just --fmt --unstable --check
# validate the OpenAPI spec
check-spec:
#!/usr/bin/env bash
set -euo pipefail
spec=$(mktemp --suffix=.json)
trap 'rm -f "$spec"' EXIT
go run ./cmd/spec > "$spec"
vacuum lint -bx -r vacuum.conf.yaml "$spec"
# auto-format all code
fmt:
pnpm run format
go tool templ fmt .
golangci-lint fmt
just --fmt --unstable
# remove all untracked and ignored files
clean:
git clean -fdqx -e .idea
# remove untracked files, reinstall dependencies, rebuild and load fixtures
rebuild: clean install build-assets build-templates fixtures
# list outdated direct dependencies
outdated:
pnpm outdated
go list -u -m -json all | jq -r 'select(.Update and (.Indirect | not)) | "\(.Path): \(.Version) -> \(.Update.Version)"'
# audit dependencies for known vulnerabilities
audit:
pnpm audit --prod
# update Go toolchain and module dependencies
update-go:
go mod edit -go=$(go env GOVERSION | sed 's/go//; s/-.*//')
go get -u ./...
go mod tidy
go get -u -t all
go mod tidy
# update pnpm dependencies
update-pnpm:
pnpm update --latest
# update all dependencies to latest versions
update: update-go update-pnpm
# generate test coverage report
coverage:
#!/usr/bin/env bash
set -euo pipefail
go test -coverpkg=./... -coverprofile coverage.out ./...
go tool cover -func=coverage.out
# go tool cover -html=coverage.out
# generate Go fixtures for local development
fixtures:
go run ./cmd/fixtures
# detect anomalies in submission data
detect-anomalies:
go run . detect-anomalies