52 lines
1.8 KiB
Bash
Executable File
52 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Sync the canonical .proto files from the st-peter server repo into this
|
|
# client repo's proto/ directory.
|
|
#
|
|
# The st-peter 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 st-peter release (see VERSION).
|
|
#
|
|
# Usage:
|
|
# ST_PETER_REPO=/path/to/st-peter-lib ./scripts/sync-protos.sh
|
|
# Defaults to ../st-peter-lib relative to this repo.
|
|
|
|
set -euo pipefail
|
|
|
|
here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
ST_PETER_REPO="${ST_PETER_REPO:-$here/../st-peter-lib}"
|
|
|
|
if [[ ! -f "$ST_PETER_REPO/Cargo.toml" ]]; then
|
|
echo "ERROR: st-peter repo not found at '$ST_PETER_REPO'." >&2
|
|
echo " Set ST_PETER_REPO=/path/to/st-peter-lib and re-run." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# canonical path in st-peter-lib -> filename in proto/
|
|
# NOTE: st-peter-admin.proto (the admin surface) and health.proto are
|
|
# intentionally NOT vendored — services authenticate users; they do not
|
|
# administer st-peter.
|
|
protos=(
|
|
"proto/st-peter-auth.proto"
|
|
)
|
|
|
|
dest="$here/proto"
|
|
mkdir -p "$dest"
|
|
for rel in "${protos[@]}"; do
|
|
src="$ST_PETER_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 st-peter workspace version.
|
|
sp_version="$(grep -m1 '^version' "$ST_PETER_REPO/Cargo.toml" | sed -E 's/.*"([^"]+)".*/\1/')"
|
|
if [[ -n "$sp_version" ]]; then
|
|
echo "$sp_version" > "$here/VERSION"
|
|
echo "VERSION -> $sp_version (matched st-peter workspace)"
|
|
fi
|
|
|
|
echo "Done. Re-run codegen (scripts/gen-*.sh) and tag at v$(cat "$here/VERSION")."
|