#!/bin/bash

# Extract versions
TS_VERSION=$(grep "const VERSION =" icalendar.ts | cut -d'"' -f2)
YAML_VERSION=$(grep "version:" icalendar.plug.yaml | head -n 1 | awk '{print $2}')
PLUG_MD_VERSION=$(grep "version:" PLUG.md | head -n 1 | awk '{print $2}')

echo "Checking versions..."
echo "icalendar.ts:      $TS_VERSION"
echo "icalendar.plug.yaml: $YAML_VERSION"
echo "PLUG.md:           $PLUG_MD_VERSION"

if [ "$TS_VERSION" == "$YAML_VERSION" ] && [ "$YAML_VERSION" == "$PLUG_MD_VERSION" ]; then
    echo "✅ All versions match."
    exit 0
else
    echo "❌ Version mismatch detected!"
    exit 1
fi
