waymaker-client/scripts/sync-protos.sh

57 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Sync the canonical .proto files from the waymaker server repo into this
# client repo's proto/ directory.
#
# The waymaker server repo is the SOURCE OF TRUTH for the wire contract.
# This repo vendors copies so the Go / TS / Rust clients can each generate
# stubs without depending on the server's Cargo workspace. Run this whenever
# the server's protos change, then re-run codegen and tag at the SAME version
# as the waymaker release (see VERSION).
#
# Usage:
# WAYMAKER_REPO=/path/to/waymaker ./scripts/sync-protos.sh
# Defaults to ../waymaker relative to this repo.
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
WAYMAKER_REPO="${WAYMAKER_REPO:-$here/../waymaker}"
if [[ ! -d "$WAYMAKER_REPO/crates" ]]; then
echo "ERROR: waymaker repo not found at '$WAYMAKER_REPO'." >&2
echo " Set WAYMAKER_REPO=/path/to/waymaker and re-run." >&2
exit 1
fi
# canonical path in waymaker -> filename in proto/
# NOTE: crates/locks/proto/internal_proxy.proto (the server-internal
# node-to-node ProxyService + lease replication) is intentionally NOT
# vendored — it is a server concern, not part of any client.
protos=(
"crates/locks/proto/waymaker_locks.proto"
"crates/streams/proto/waymaker_streams.proto"
"crates/kv/proto/kv.proto"
"crates/collections/proto/collections.proto"
"crates/sketches/proto/sketches.proto"
"crates/cache/proto/cache.proto"
)
dest="$here/proto"
mkdir -p "$dest"
for rel in "${protos[@]}"; do
src="$WAYMAKER_REPO/$rel"
[[ -f "$src" ]] || { echo "ERROR: missing $src" >&2; exit 1; }
cp "$src" "$dest/$(basename "$rel")"
echo "synced $(basename "$rel")"
done
# Keep VERSION in lockstep with the waymaker workspace version.
wm_version="$(grep -m1 '^version' "$WAYMAKER_REPO/Cargo.toml" | sed -E 's/.*"([^"]+)".*/\1/')"
if [[ -n "$wm_version" ]]; then
echo "$wm_version" > "$here/VERSION"
echo "VERSION -> $wm_version (matched waymaker workspace)"
fi
echo "Done. Re-run codegen (scripts/gen-*.sh) and tag at v$(cat "$here/VERSION")."