a minimal blog cms for your pds
1# Convenience targets for fair. The actual CLI is `fair`; targets
2# below are sugar for the common flows.
3#
4# Profile is required by every fair command. Default is sandbox; override
5# with `make publish-post POST=path/to/index.md PROFILE=prod`.
6
7PROFILE ?= sandbox
8CA_BUNDLE := $(shell mkcert -CAROOT 2>/dev/null)/rootCA.pem
9CA_FLAG := $(if $(wildcard $(CA_BUNDLE)),--ca-bundle $(CA_BUNDLE),)
10
11.PHONY: help
12help:
13 @echo "Usage: make <target> [PROFILE=<name>] [POST=<path>]"
14 @echo
15 @echo "Targets:"
16 @echo " build Compile ./fair"
17 @echo " test Run go test ./..."
18 @echo " vet Run go vet ./..."
19 @echo " install Build and install to \$$GOBIN"
20 @echo
21 @echo " sandbox-up Bootstrap the local PDS + create test account"
22 @echo " sandbox-down Stop the sandbox containers (keeps volume)"
23 @echo " sandbox-reset Wipe sandbox data (volume + state + sessions)"
24 @echo
25 @echo " ls fair ls"
26 @echo " doctor fair doctor"
27 @echo " publish-post fair publish POST=<path>"
28 @echo " build-site fair build"
29 @echo " preview Run a static server over dist.\$$(PROFILE)/"
30 @echo
31 @echo "Current PROFILE=$(PROFILE)"
32
33.PHONY: build
34build: fair
35
36fair: $(shell find cmd internal -name '*.go' 2>/dev/null) go.mod go.sum
37 go build -o fair ./cmd/fair
38
39.PHONY: test
40test:
41 go test ./...
42
43.PHONY: vet
44vet:
45 go vet ./...
46
47.PHONY: install
48install:
49 go install ./cmd/fair
50
51# --- Sandbox lifecycle -------------------------------------------------------
52
53.PHONY: sandbox-up
54sandbox-up:
55 bash sandbox/seed.sh
56
57.PHONY: sandbox-down
58sandbox-down:
59 docker compose -f sandbox/compose.yaml --env-file sandbox/.env down
60
61.PHONY: sandbox-reset
62sandbox-reset:
63 bash sandbox/reset.sh
64
65# --- Blog operations --------------------------------------------------------
66
67.PHONY: ls
68ls: fair
69 ./fair --profile $(PROFILE) ls $(CA_FLAG)
70
71.PHONY: doctor
72doctor: fair
73 ./fair --profile $(PROFILE) doctor $(CA_FLAG)
74
75.PHONY: publish-post
76publish-post: fair
77 @if [ -z "$(POST)" ]; then \
78 echo "Usage: make publish-post POST=path/to/index.md"; exit 1; \
79 fi
80 ./fair --profile $(PROFILE) publish $(POST) $(CA_FLAG)
81
82.PHONY: build-site
83build-site: fair
84 ./fair --profile $(PROFILE) build $(CA_FLAG)
85
86.PHONY: preview
87preview: build-site
88 @echo "Serving dist.$(PROFILE)/ at http://localhost:8000/"
89 python3 -m http.server 8000 --directory dist.$(PROFILE)
90
91# --- Tangled push (after the remote is configured) -------------------------
92
93.PHONY: push-tangled
94push-tangled:
95 git push tangled --all
96 git push tangled --tags
97
98# --- Cleanup ---------------------------------------------------------------
99
100.PHONY: clean
101clean:
102 rm -f fair
103 rm -rf dist dist.tmp dist.sandbox dist.sandbox.tmp
104 rm -rf images-mirror images-mirror.sandbox images-mirror.prod