|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" |
| 5 | +tmp_root="$(mktemp -d)" |
| 6 | +trap 'rm -rf "$tmp_root"' EXIT |
| 7 | + |
| 8 | +fixture_root="$tmp_root/repo" |
| 9 | +mkdir -p "$fixture_root" |
| 10 | + |
| 11 | +rsync \ |
| 12 | + --archive \ |
| 13 | + --exclude '.git' \ |
| 14 | + "$repo_root/" \ |
| 15 | + "$fixture_root/" |
| 16 | + |
| 17 | +assert_eq() { |
| 18 | + local expected="$1" |
| 19 | + local actual="$2" |
| 20 | + local message="$3" |
| 21 | + if [[ "$expected" != "$actual" ]]; then |
| 22 | + echo "$message: expected '$expected', got '$actual'" >&2 |
| 23 | + exit 1 |
| 24 | + fi |
| 25 | +} |
| 26 | + |
| 27 | +initial_version="$( |
| 28 | + REPO_ROOT="$fixture_root" \ |
| 29 | + "$fixture_root/scripts/read_version.sh" |
| 30 | +)" |
| 31 | + |
| 32 | +python3 - "$fixture_root" <<'PY' |
| 33 | +import json |
| 34 | +import pathlib |
| 35 | +import sys |
| 36 | +
|
| 37 | +root = pathlib.Path(sys.argv[1]) |
| 38 | +marketplace_path = root / ".claude-plugin" / "marketplace.json" |
| 39 | +plugin_path = root / "plugins" / "tla-workbenches" / ".claude-plugin" / "plugin.json" |
| 40 | +
|
| 41 | +with open(marketplace_path, "r", encoding="utf-8") as f: |
| 42 | + marketplace = json.load(f) |
| 43 | +with open(plugin_path, "r", encoding="utf-8") as f: |
| 44 | + plugin = json.load(f) |
| 45 | +
|
| 46 | +with open(root / "VERSION", "r", encoding="utf-8") as f: |
| 47 | + expected = f.read().strip() |
| 48 | +
|
| 49 | +assert marketplace["metadata"]["version"] == expected |
| 50 | +assert marketplace["plugins"][0]["version"] == expected |
| 51 | +assert plugin["version"] == expected |
| 52 | +PY |
| 53 | + |
| 54 | +next_version="$( |
| 55 | + python3 - "$initial_version" <<'PY' |
| 56 | +import sys |
| 57 | +
|
| 58 | +major, minor, patch = map(int, sys.argv[1].split(".")) |
| 59 | +print(f"{major}.{minor}.{patch + 1}") |
| 60 | +PY |
| 61 | +)" |
| 62 | + |
| 63 | +printf '%s\n' "$next_version" > "$fixture_root/VERSION" |
| 64 | + |
| 65 | +if REPO_ROOT="$fixture_root" "$fixture_root/scripts/validate_claude_plugin.sh" >/dev/null 2>&1; then |
| 66 | + echo "validate_claude_plugin.sh should fail when VERSION and manifests diverge" >&2 |
| 67 | + exit 1 |
| 68 | +fi |
| 69 | + |
| 70 | +REPO_ROOT="$fixture_root" "$fixture_root/scripts/sync_version.sh" |
| 71 | +REPO_ROOT="$fixture_root" "$fixture_root/scripts/validate_claude_plugin.sh" |
| 72 | + |
| 73 | +synced_version="$( |
| 74 | + REPO_ROOT="$fixture_root" \ |
| 75 | + "$fixture_root/scripts/read_version.sh" |
| 76 | +)" |
| 77 | +assert_eq "$next_version" "$synced_version" "synced VERSION" |
| 78 | + |
| 79 | +python3 - "$fixture_root" <<'PY' |
| 80 | +import json |
| 81 | +import pathlib |
| 82 | +import sys |
| 83 | +
|
| 84 | +root = pathlib.Path(sys.argv[1]) |
| 85 | +marketplace_path = root / ".claude-plugin" / "marketplace.json" |
| 86 | +plugin_path = root / "plugins" / "tla-workbenches" / ".claude-plugin" / "plugin.json" |
| 87 | +
|
| 88 | +with open(marketplace_path, "r", encoding="utf-8") as f: |
| 89 | + marketplace = json.load(f) |
| 90 | +with open(plugin_path, "r", encoding="utf-8") as f: |
| 91 | + plugin = json.load(f) |
| 92 | +
|
| 93 | +with open(root / "VERSION", "r", encoding="utf-8") as f: |
| 94 | + expected = f.read().strip() |
| 95 | +
|
| 96 | +assert marketplace["metadata"]["version"] == expected |
| 97 | +assert marketplace["plugins"][0]["version"] == expected |
| 98 | +assert plugin["version"] == expected |
| 99 | +PY |
0 commit comments