1#!/bin/bash
2# scripts/update-lexicons.sh
3# Update script for ATProto lexicons from upstream
4
5set -e
6
7echo "Updating ATProto lexicons..."
8
9# Check if we're in the right directory
10if [ ! -f "package.json" ] || [ ! -d "vendor/atproto" ]; then
11 echo "Error: This script must be run from the project root directory"
12 echo "Make sure vendor/atproto submodule exists"
13 exit 1
14fi
15
16# Save current directory
17PROJECT_ROOT=$(pwd)
18
19# Update the submodule
20echo "Fetching latest changes from atproto repository..."
21cd vendor/atproto
22
23# Fetch latest changes
24git fetch origin
25
26# Get current commit
27CURRENT_COMMIT=$(git rev-parse HEAD)
28CURRENT_SHORT=$(git rev-parse --short HEAD)
29
30# Get latest commit on main
31LATEST_COMMIT=$(git rev-parse origin/main)
32LATEST_SHORT=$(git rev-parse --short origin/main)
33
34if [ "$CURRENT_COMMIT" = "$LATEST_COMMIT" ]; then
35 echo "Already up to date (${CURRENT_SHORT})"
36 cd "$PROJECT_ROOT"
37 exit 0
38fi
39
40echo "Updating from ${CURRENT_SHORT} to ${LATEST_SHORT}..."
41
42# Pull latest changes
43git pull origin main
44
45# Go back to project root
46cd "$PROJECT_ROOT"
47
48# Stage the submodule update
49git add vendor/atproto
50
51# Show what changed
52echo ""
53echo "Submodule updated successfully!"
54echo "Changes:"
55git diff --cached --submodule=log vendor/atproto
56
57echo ""
58echo "To complete the update, commit the changes:"
59echo " git commit -m \"Update atproto lexicons to ${LATEST_SHORT}\""
60echo ""
61echo "Or to see what lexicon files changed:"
62echo " cd vendor/atproto && git log --oneline ${CURRENT_SHORT}..${LATEST_SHORT} -- lexicons/"