Files
sanderling/Makefile
T
pj 88db0cbea8 docs: web platform + clean URLs + dark/light mode (#37)
* chore(docs): replace d2 diagram pipeline with mermaid

Remove docs/_diagrams/ and d2 build step from Makefile. The HTML
template already initialises mermaid.js; diagrams are now inline
code fences rendered client-side.

* docs(architecture): add mermaid diagram + web/CDP platform docs

Replace SVG img tag with inline mermaid flowchart showing both native
(Maestro sidecar + in-app SDK) and web (Chrome CDP) paths. Update
Processes, Transports table, and per-step cycle sections.

* docs(design-principles): update principles 1-4 for web platform

Principles 1, 2, 3, and 4 referenced Maestro and native-only concepts.
Add web/CDP context and update driver-is-an-interface to name both
sidecar and chrome implementations.

* docs(manual): add web prerequisites and folio-web example

Update --platform flag to list android, ios, web. Add web prerequisites
section (Chrome, no SDK needed) and folio-web quick-start to
getting-started.

* chore(gitignore): untrack inspect dist/index.html build artifact

index.html is regenerated by vite on every build with a new content hash,
making it permanently dirty. Only .gitkeep is needed for //go:embed to
compile on a fresh checkout. Also remove duplicate dist/* line and stale
d2 diagram ignore entries.

* feat(docs): click-to-zoom for mermaid diagrams

* docs(architecture): change diagram layout from LR to TB

* docs(getting-started): link npm and Maven Central package headers

* update docs root

* docs(spec): rewrite npm package README

Update usage example to current API, drop stale version-compatibility
and license sections.

* build(docs): output pages as pagename/index.html for clean URLs

Split DOCS_OUT into INDEX_OUT (index.md files stay as index.html) and
PAGE_OUT (all other pages become pagename/index.html). The __ROOT__
depth computation already handles the extra directory level correctly.

* chore(docs): update sidebar links to directory-style URLs

* docs: update cross-links from .html to directory-style paths

* ci(docs): remove d2 install step

* feat(docs): dark/light mode toggle

Add theme toggle button (top-right, fixed). Persists preference in
localStorage; falls back to prefers-color-scheme. Flash-free via inline
script in <head> that sets data-theme before first paint.

* fix(docs): fix inspect image path broken by directory URL restructure

* feat(docs): click-to-fullscreen for all article images

* fix(inspect): allow AssetsFS override in ServerOptions; drop unused request param from serveIndex

* fix(inspect): use in-memory FS in tests so TestAssets_FallbackToIndexHTML passes without web build
2026-04-23 00:57:30 +07:00

127 lines
3.7 KiB
Makefile

SHELL := /bin/bash
ANDROID_HOME ?= /opt/homebrew/share/android-commandlinetools
GRADLE := ./gradlew
GO := go
BUF := buf
GO_PACKAGES := ./...
SIDECAR_JAR := sidecar/build/libs/sidecar-all.jar
SIDECAR_EMBED := internal/sidecar/assets/sidecar-all.jar
SDK_AAR := sdk/android/build/outputs/aar/sdk-android-release.aar
SANDERLING_BIN := bin/sanderling
DOCS_SRC := $(shell find docs -type f -name '*.md' -not -path 'docs/_*')
INDEX_SRC := $(filter %index.md,$(DOCS_SRC))
PAGE_SRC := $(filter-out %index.md,$(DOCS_SRC))
INDEX_OUT := $(patsubst docs/%.md,build/site/%.html,$(INDEX_SRC))
PAGE_OUT := $(patsubst docs/%.md,build/site/%/index.html,$(PAGE_SRC))
DOCS_OUT := $(INDEX_OUT) $(PAGE_OUT)
DOCS_TEMPLATE := docs/_template/page.html
INSPECT_DIST := internal/inspect/dist
WEB_DIST := inspect-ui/dist
.PHONY: bootstrap proto sidecar sdk-android sdk-android-publish sanderling install test test-go test-kotlin test-spec-api web-typecheck web-build web-dev inspect-dev docs clean release-cli release-android-local release-npm-dry
bootstrap:
$(GO) mod download
$(BUF) generate
cd pkg/spec && npm install --silent
proto:
$(BUF) lint
$(BUF) generate
sidecar: $(SIDECAR_JAR)
sdk-android:
ANDROID_HOME=$(ANDROID_HOME) $(GRADLE) :sdk-android:assembleRelease
sdk-android-publish:
ANDROID_HOME=$(ANDROID_HOME) $(GRADLE) :sdk-android:publishToMavenLocal
sanderling: $(SANDERLING_BIN)
$(SANDERLING_BIN): $(SIDECAR_EMBED) web-build
mkdir -p bin
$(GO) build -tags withsidecar -o $(SANDERLING_BIN) ./cmd/sanderling
# Installs `sanderling` into $GOBIN (or $GOPATH/bin) so it's directly on PATH for
# anyone with a standard Go toolchain setup.
install: $(SIDECAR_EMBED) web-build
$(GO) install -tags withsidecar ./cmd/sanderling
@dest="$$($(GO) env GOBIN)"; [ -n "$$dest" ] || dest="$$($(GO) env GOPATH)/bin"; echo "installed sanderling to $$dest"
web-build:
cd inspect-ui && bun install --frozen-lockfile && bun run build
mkdir -p $(INSPECT_DIST)
rm -rf $(INSPECT_DIST)/assets $(INSPECT_DIST)/fonts
cp -R $(WEB_DIST)/. $(INSPECT_DIST)/
web-dev:
cd inspect-ui && bun run dev
inspect-dev: $(SIDECAR_EMBED)
$(GO) run -tags withsidecar ./cmd/sanderling inspect --dev
web-typecheck:
cd inspect-ui && bun install --frozen-lockfile && bun run typecheck
$(SIDECAR_JAR):
ANDROID_HOME=$(ANDROID_HOME) $(GRADLE) :sidecar:shadowJar
$(SIDECAR_EMBED): $(SIDECAR_JAR)
mkdir -p $(dir $@)
cp $< $@
test: test-go test-kotlin test-spec-api web-typecheck
test-go:
$(GO) test $(GO_PACKAGES)
test-kotlin:
ANDROID_HOME=$(ANDROID_HOME) $(GRADLE) :sidecar:test :sdk-android:testDebugUnitTest
test-spec-api:
cd pkg/spec && npm test --silent
docs: $(DOCS_OUT) build/site/_assets
@echo "built $(words $(DOCS_OUT)) pages to build/site"
build/site/_assets: docs/_assets
@mkdir -p build/site
@rm -rf $@
@cp -R $< $@
define build_page
@mkdir -p $(dir $@)
@pandoc $< --from=gfm --to=html5 --standalone \
--highlight-style=tango --template=$(DOCS_TEMPLATE) -o $@
@rel=$$(echo $(patsubst build/site/%,%,$@) | awk -F/ '{for(i=1;i<NF;i++)printf "../"}'); \
sed -i.bak "s|__ROOT__|$$rel|g" $@ && rm $@.bak
endef
$(INDEX_OUT): build/site/%.html: docs/%.md $(DOCS_TEMPLATE)
$(build_page)
$(PAGE_OUT): build/site/%/index.html: docs/%.md $(DOCS_TEMPLATE)
$(build_page)
clean:
$(GO) clean
rm -rf bin dist pkg/spec-api/dist build/site
$(GRADLE) clean
# Local release dry-runs. None of these touch remote registries.
release-cli: $(SIDECAR_JAR)
goreleaser release --snapshot --clean
release-android-local:
@if [ -f .env.local ]; then set -a; . ./.env.local; set +a; fi; \
ANDROID_HOME=$(ANDROID_HOME) $(GRADLE) :sdk-android:publishToMavenLocal -Psanderling.version=0.0.0-local
release-npm-dry:
cd pkg/spec && npm ci && npm run build && npm pack --dry-run