@@ -61,11 +61,23 @@ resolve_timeout_bin() {
6161 return 1
6262}
6363
64- if command -v vitepress > /dev/null 2>&1 ; then
64+ build_docs_once () {
65+ local vitepress_build_log=" $1 "
66+
6567 rm -rf docs/.vitepress/.temp docs/.vitepress/.cache
68+ vitepress build docs > " $vitepress_build_log " 2>&1
69+ }
70+
71+ if command -v vitepress > /dev/null 2>&1 ; then
6672 vitepress_build_log=" $( mktemp " ${TMPDIR:-/ tmp} /animus-vitepress.XXXXXX" ) "
67- if ! vitepress build docs > " $vitepress_build_log " 2>&1 ; then
68- if rg -q ' @rollup/rollup-darwin-arm64|ERR_DLOPEN_FAILED|Team IDs' " $vitepress_build_log " ; then
73+ if ! build_docs_once " $vitepress_build_log " ; then
74+ if rg -q " ERR_MODULE_NOT_FOUND.*docs/.vitepress/.temp.*\\ .md\\ .js|Cannot find module '.*/docs/.vitepress/.temp/.*\\ .md\\ .js'" " $vitepress_build_log " ; then
75+ echo " VitePress hit the transient missing-temp-module render failure; retrying once after a clean temp/cache reset." >&2
76+ if ! build_docs_once " $vitepress_build_log " ; then
77+ cat " $vitepress_build_log " >&2
78+ exit 1
79+ fi
80+ elif rg -q ' @rollup/rollup-darwin-arm64|ERR_DLOPEN_FAILED|Team IDs' " $vitepress_build_log " ; then
6981 echo " Local VitePress build is blocked by the known Rollup macOS native-module signing issue." >&2
7082 echo " Continuing to Vercel so the remote build can validate and publish the docs." >&2
7183 else
8294echo " Deploying docs with Vercel..."
8395echo " Prerequisites: network access for Vercel and a valid Vercel login."
8496
85- npx_bin=" $( resolve_node_package_manager_bin npx) " || {
86- echo " Unable to find npx. Install Node tooling or expose an existing Node install." >&2
87- exit 1
88- }
97+ vercel_bin=" "
98+ vercel_runner=()
99+
100+ if command -v vercel > /dev/null 2>&1 ; then
101+ vercel_bin=" $( command -v vercel) "
102+ vercel_runner=(" $vercel_bin " --yes --prod)
103+ else
104+ npx_bin=" $( resolve_node_package_manager_bin npx) " || {
105+ echo " Unable to find npx. Install Node tooling or expose an existing Node install." >&2
106+ exit 1
107+ }
108+ vercel_bin=" $npx_bin "
109+ vercel_runner=(" $npx_bin " vercel --yes --prod)
110+ fi
89111
90112npx_cache_dir=" $( mktemp -d " ${TMPDIR:-/ tmp} /animus-vercel.XXXXXX" ) "
91113trap ' rm -rf "$npx_cache_dir"' EXIT
@@ -96,7 +118,7 @@ timeout_bin="$(resolve_timeout_bin)" || {
96118 exit 1
97119}
98120vercel_timeout_seconds=" ${ANIMUS_VERCEL_TIMEOUT_SECONDS:- 300} "
99- echo " Using npx via $npx_bin ."
121+ echo " Using Vercel command via $vercel_bin ."
100122echo " Using temporary npm cache at $npx_cache_dir ."
101123echo " Bounding Vercel deploy to ${vercel_timeout_seconds} s via $timeout_bin ."
102124
@@ -107,7 +129,7 @@ npm_config_fetch_retries=0 \
107129npm_config_fetch_timeout=10000 \
108130npm_config_fetch_retry_maxtimeout=10000 \
109131 " $timeout_bin " --foreground " ${vercel_timeout_seconds} s" \
110- " $npx_bin " vercel --yes --prod > " $vercel_deploy_log " 2>&1
132+ " ${vercel_runner[@]} " > " $vercel_deploy_log " 2>&1
111133vercel_exit_code=$?
112134set -e
113135
0 commit comments