e6afa91e09
kage renders every page in headless Chrome, snapshots the final DOM, strips all JavaScript, and localises CSS, images, and fonts so a site can be browsed offline as a plain folder of files. The engine is split into small packages: urlx deterministic URL to local-path mapping and scope rules sanitize remove scripts, on* handlers, and javascript: URLs asset rewrite HTML and CSS references, download assets browser headless Chrome pool over the DevTools protocol robots robots.txt matcher clone the orchestrator: a polite resumable breadth-first crawl The cli package wires a cobra and fang command surface with two commands, clone and serve. Every pure package has table tests; the browser and clone packages add Chrome-driven end-to-end tests that skip when no browser is present or under -short. CI runs gofmt, vet, build, race tests, golangci-lint, govulncheck, and a tidy check on Linux and macOS. A goreleaser config fans one tag out to archives, deb/rpm/apk, a Chromium-bundled GHCR image, and the package managers. A tago docs site builds to Pages and Cloudflare.
40 lines
883 B
Makefile
40 lines
883 B
Makefile
BIN := kage
|
|
PKG := ./cmd/kage
|
|
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
|
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
|
|
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
LDFLAGS := -s -w \
|
|
-X github.com/tamnd/kage/cli.Version=$(VERSION) \
|
|
-X github.com/tamnd/kage/cli.Commit=$(COMMIT) \
|
|
-X github.com/tamnd/kage/cli.Date=$(DATE)
|
|
|
|
export CGO_ENABLED := 0
|
|
|
|
.PHONY: build install test test-short vet tidy clean run
|
|
|
|
build:
|
|
go build -ldflags "$(LDFLAGS)" -o bin/$(BIN) $(PKG)
|
|
|
|
install:
|
|
go install -ldflags "$(LDFLAGS)" $(PKG)
|
|
|
|
# Full suite, including the Chrome-driven end-to-end tests.
|
|
test:
|
|
go test -race ./...
|
|
|
|
# Skip the tests that launch a real browser (CI without Chrome, quick loops).
|
|
test-short:
|
|
go test -short ./...
|
|
|
|
vet:
|
|
go vet ./...
|
|
|
|
tidy:
|
|
go mod tidy
|
|
|
|
clean:
|
|
rm -rf bin
|
|
|
|
run: build
|
|
./bin/$(BIN)
|