Skip to content

Commit ba636a2

Browse files
authored
chore: Improve doc build error handling and local build ucp-schema version checking (Universal-Commerce-Protocol#224)
* fix: Image (core-concepts diagram) and spec link URLs broken after site/spec version refactor. * fix: revert the spec link update from core-concepts * fix: Improve error handling of ucp-schema returned errors during doc build. * chore: linter reformat * chore: Add ucp-schema tool version check to build_local script. * chore: Bash lint updates * fix: Apply Shfmt to build_local.sh
1 parent bdbebfa commit ba636a2

2 files changed

Lines changed: 42 additions & 15 deletions

File tree

main.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _resolve_schema(
101101
hyperlink generation in documentation.
102102
103103
Returns:
104-
Resolved schema as dict, or None if resolution fails.
104+
Resolved schema as dict, or raises RuntimeError if ucp-schema fails.
105105
106106
"""
107107
bundle_suffix = ":bundled" if bundle else ""
@@ -121,20 +121,18 @@ def _resolve_schema(
121121
if bundle:
122122
cmd.append("--bundle")
123123

124-
try:
125-
result = subprocess.run(
126-
cmd,
127-
capture_output=True,
128-
text=True,
129-
check=False,
130-
)
131-
if result.returncode == 0:
132-
data = json.loads(result.stdout)
133-
_resolved_schema_cache[cache_key] = data
134-
return data
135-
except subprocess.SubprocessError:
136-
pass
137-
return None
124+
result = subprocess.run(
125+
cmd,
126+
capture_output=True,
127+
text=True,
128+
check=False,
129+
)
130+
if result.returncode == 0:
131+
data = json.loads(result.stdout)
132+
_resolved_schema_cache[cache_key] = data
133+
return data
134+
else:
135+
raise RuntimeError(f"ucp-schema execution error: result = {result}")
138136

139137

140138
# Backward compatibility alias

scripts/build_local.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22
set -e
33

4+
# When did we run this build?
5+
date
6+
47
# Ensure we are running from the project root (parent of scripts/)
58
cd "$(dirname "$0")/.."
69
PROJECT_ROOT=$(pwd)
@@ -15,6 +18,32 @@ GH_PAGES_BRANCH="gh-pages"
1518
# Also add ucp-schema binary from sibling directory
1619
export PATH="$PROJECT_ROOT/.venv/bin:$PROJECT_ROOT/../ucp-schema/target/release:$PATH:$HOME/.cargo/bin"
1720

21+
# Check UCP-Schema CLI version vs current Crates.io version and prompt
22+
PURPLE='\033[1;35m'
23+
NC='\033[0m' # No Color
24+
echo "Using ucp-schema CLI: $(which ucp-schema)"
25+
UCP_CLI_VERSION=$(ucp-schema --version | sed 's/ucp-schema //')
26+
echo "Local ucp-schema version: '$UCP_CLI_VERSION'"
27+
UCP_CRATES_VERSION=$(cargo search ucp-schema -q | sed 's/ucp-schema = "//' | sed 's/".*$//')
28+
echo "Crates ucp-schema version: '$UCP_CRATES_VERSION'"
29+
if [[ $UCP_CLI_VERSION != "$UCP_CRATES_VERSION" ]]; then
30+
while true; do
31+
echo -e "${PURPLE}*ucp-schema version mismatch*${NC}"
32+
read -r -p " Continue? (y/n) " yn
33+
case $yn in
34+
[Yy]*)
35+
echo "proceed..."
36+
break
37+
;;
38+
[Nn]*)
39+
echo "exiting..."
40+
exit
41+
;;
42+
*) echo "invalid response" ;;
43+
esac
44+
done
45+
fi
46+
1847
if ! command -v mike >/dev/null 2>&1; then
1948
echo "Error: mike executable not found in PATH."
2049
echo "Please ensure you have run 'uv sync' in the root."

0 commit comments

Comments
 (0)