Files
Yggdrasil/Justfile
T
Klagarge 9ffc6a14d2 fix: apply fresh-start review findings
Independent review (second attempt) passed all 7 verification steps at
19f6007, including the fresh-clone embed check, full build from clean
state (9.7s), server curl matrix (public 200, protected + all theme
sidecars 503, searchindex 404, no content in 503 bodies), and just check.

Findings applied:
- README: prerequisite Go version corrected to 1.27.1+ to match go.mod
  (a Go 1.22-1.27 user got a hard 'requires go >= 1.27.1' failure).
- CI: upload-artifact v3 -> v4 with a fallback note for older runners;
  CI now also runs the gofmt guard like 'just check'.
- Justfile: curl -fsSL so a bad download fails at curl instead of tar;
  comment clarifying that --dest-dir is resolved relative to docs/.
- AGENT.md: version-pairing trap now covers both pin locations
  (Justfile and .gitea/workflows/build.yml).
2026-10-10 19:05:34 +02:00

53 lines
2.1 KiB
Makefile

# Yggdrasil: Typst documentation behind an authenticated Go server.
# Pinned shiroa toolchain, self-managed under tools/ (no global install).
# The CLI and the @preview/shiroa package version must match (see AGENT.md).
shiroa-version := "v0.4.0-rc2"
shiroa-target := if arch() == "x86_64" { "x86_64-unknown-linux-musl" } else if arch() == "aarch64" { "aarch64-unknown-linux-musl" } else { error("unsupported architecture " + arch()) }
shiroa-dir := "tools/shiroa"
shiroa-bin := shiroa-dir + "/shiroa-" + shiroa-target + "/shiroa"
shiroa-url := "https://github.com/Myriad-Dreamin/shiroa/releases/download/" + shiroa-version + "/shiroa-" + shiroa-target + ".tar.gz"
# Show the available commands.
default:
@just --list
# Build everything: acl.json, the static site, and the server binary.
build: parse build-docs build-server
# Scan docs/ for access-groups tags and regenerate acl.json.
parse:
go run ./cmd/parser -in docs -out acl.json
# Download the pinned shiroa into tools/ if missing.
tools:
@mkdir -p {{shiroa-dir}}
@test -x {{shiroa-bin}} || { echo "Downloading shiroa {{shiroa-version}} ({{shiroa-target}})..."; curl -fsSL -o {{shiroa-dir}}/shiroa.tar.gz {{shiroa-url}}; tar -xzf {{shiroa-dir}}/shiroa.tar.gz -C {{shiroa-dir}}; rm {{shiroa-dir}}/shiroa.tar.gz; {{shiroa-bin}} --version; }
# Compile the Typst book into dist/.
# (--dest-dir is resolved relative to the book directory, docs/, hence ../dist)
build-docs: tools
{{shiroa-bin}} build docs --dest-dir ../dist
# Build the server binary (embeds dist/ and acl.json).
build-server:
CGO_ENABLED=0 go build -trimpath -o server ./cmd/server
# Rebuild everything and run the server locally.
run: build
./server
# Live-preview the book without authentication (shiroa dev server).
preview-docs: tools
{{shiroa-bin}} serve docs
# Run static checks and tests.
check:
go vet ./...
go test ./...
@test -z "$(gofmt -l cmd internal embed.go)" || { echo 'gofmt needed:'; gofmt -l cmd internal embed.go; exit 1; }
# Remove build artifacts (keeps tools/ and the committed dist/.gitkeep).
clean:
rm -rf dist server && mkdir -p dist && touch dist/.gitkeep