forked from kiwifs/kiwifs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (39 loc) · 1.32 KB
/
Makefile
File metadata and controls
53 lines (39 loc) · 1.32 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
BINARY := kiwifs
ROOT := ./knowledge
PORT := 3333
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
.PHONY: build run test clean tidy ui ui-install dev-ui swagger
# Run swag init to generate REST API documentation
swagger:
swag init
# Full build: bundle the UI first, then compile the Go binary so
# `//go:embed ui/dist` picks up the latest assets.
build: ui
go build -ldflags "-s -w -X main.version=$(VERSION)" -o $(BINARY) .
# Build only the Go binary. Use this when the UI hasn't changed — the
# previously-built ui/dist is still embedded.
go-build:
go build -ldflags "-s -w -X main.version=$(VERSION)" -o $(BINARY) .
# Build just the UI. Runs `npm install` lazily on first use.
ui:
@if [ ! -d ui/node_modules ]; then $(MAKE) ui-install; fi
cd ui && npm run build
ui-install:
cd ui && npm install
run: build
./$(BINARY) serve --root $(ROOT) --port $(PORT)
dev:
go run . serve --root $(ROOT) --port $(PORT)
dev-docker:
docker compose -f docker-compose.dev.yml up --build
# Run the UI dev server against a running kiwifs on :3333. Useful when
# iterating on the UI without rebuilding the Go binary between edits.
dev-ui:
cd ui && npm run dev
test:
go test ./...
tidy:
go mod tidy
clean:
rm -f $(BINARY)
rm -rf ui/dist/assets ui/dist/*.html ui/dist/favicon.svg 2>/dev/null || true