Commit 6472890 accidentally deleted the committed dist/.gitkeep: the
clean-state test ran 'rm -rf dist' (which contains the tracked .gitkeep)
and the following 'git add -A' recorded the deletion. Fresh clones then
had no dist/ and 'go build'/'just check' failed before the first shiroa
run ('pattern all:dist: no matching files found').
- Justfile: 'clean' now recreates dist/.gitkeep, so the tracked file
survives clean/build cycles.
- AGENT.md: clean-state procedure uses 'just clean' and requires a clean
'git status' after test cycles, with the reason documented.
- Verified: with dist/ holding only .gitkeep, 'go build' and 'go vet'
succeed (fresh-clone state).
52 lines
2.0 KiB
Makefile
52 lines
2.0 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 -sSL -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/.
|
|
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
|