Files
yellowjacket/scripts/bindings-check.sh
T
yonluandClaude Opus 5 162c68769f feat(wails): move the frontend onto v3's generated bindings
frontend/wailsjs/ is deleted and frontend/bindings/ takes its place —
a real TypeScript module tree nested by Go import path, generated by
wails3's static analyser rather than by building the app and running
it.  The @go alias absorbs the constant prefix, so a call site imports
'@go/library/library.js' and the codemod over all 93 sites was a
specifier rewrite plus splitting @go/models' namespaces into one
import per package.

The 12 SetContext bindings and the fake `context` model are gone, as
Phase 2's ServiceStartup port promised: 272 methods across 12
services, none of them plumbing.

@runtime/runtime is now a local shim (src/wails/runtime.ts) over
@wailsio/runtime, so the 22 EventsOn imports are untouched.  It
unwraps v3's WailsEvent into v2's callback shape, which is exact here:
nothing in backend/events passes more than one data argument, and v3
only packs arguments into a slice when there is more than one.

v3 tells the truth about two things v2 lied about, and that is most of
the diff.  A Go nil slice really does arrive as JSON null, and a Go
named string type really is an enum; v2 typed them as T[] and string.
utils/binding.ts states the app's actual contract — an absent list is
an empty list — once, at the boundary where it is true, and also drops
the CancellablePromise the app never cancels.  Four test fixtures
widen an enum field back to its value union.

Not done, and Phase 5's to fix: frontend/test/support/wails-fake.ts
still fakes window.go, which v3 does not have, so `make ui-test` is
broken and harness.test.ts fails to compile on EventsEmit.  That test
also asserts v2 ordering that no longer holds — v3's Events.Emit calls
the backend and does not notify in-page listeners at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UDCbcCZQepnpSQYJ6SxxZm
2026-08-14 17:48:38 -04:00

49 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Fails when frontend/bindings/ is stale against the bound Go services.
#
# frontend/bindings/ is generated by `wails3`, not by `go generate`, so
# the pre-commit codegen check does not cover it at all. Without this, a
# renamed Go struct field or a changed method signature first shows up at
# runtime, inside a window, as a binding that never settles.
#
# v3's generator is a static analyser rather than a build-and-run of the
# app, which is what makes this cheap enough to gate a commit on — and
# also what makes the build tags matter. It sees only the configuration
# it is told about; the one that matters is the one users run, which is
# the default tag set (GTK4 + WebKitGTK 6.0). The other two
# configurations this repo builds — `indexbuild` and `dev` — add no bound
# service, so generating under them would only widen the surface past
# what ships.
set -euo pipefail
cd "$(dirname "$0")/.."
TARGET="frontend/bindings"
if [ -n "$(git status --porcelain -- "$TARGET")" ]; then
echo "bindings-check: $TARGET has uncommitted changes; stage or stash them first" >&2
git status --short -- "$TARGET" >&2
exit 1
fi
go tool wails3 generate bindings -clean=true -ts -i >/dev/null 2>&1
if ! git diff --quiet -- "$TARGET"; then
echo "bindings-check: $TARGET is out of date with the Go bindings." >&2
echo "Run 'make bindings' and stage the result." >&2
git diff --stat -- "$TARGET" >&2
exit 1
fi
# An added or removed *file* is a rename or a new service, which a diff
# of tracked paths alone does not see.
if [ -n "$(git status --porcelain -- "$TARGET")" ]; then
echo "bindings-check: $TARGET gained or lost files." >&2
git status --short -- "$TARGET" >&2
exit 1
fi
echo "bindings-check: frontend/bindings is current"