forked from wieslawsoltes/XamlToCSharpGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserve-docs.sh
More file actions
executable file
·45 lines (35 loc) · 1.21 KB
/
serve-docs.sh
File metadata and controls
executable file
·45 lines (35 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HOST="${DOCS_HOST:-127.0.0.1}"
PORT="${DOCS_PORT:-8080}"
clean_docs_outputs() {
find "${SCRIPT_DIR}/src" -path '*/obj/Release/*/*.api.json' -delete
rm -rf "${SCRIPT_DIR}/site/.lunet/build/cache/api/dotnet" \
"${SCRIPT_DIR}/site/.lunet/build/www"
}
cd "${SCRIPT_DIR}"
dotnet tool restore
dotnet build "${SCRIPT_DIR}/XamlToCSharpGenerator.CI.slnf" -c Release --nologo -m:1 /nodeReuse:false --disable-build-servers
clean_docs_outputs
cd site
if command -v python3 >/dev/null 2>&1; then
PYTHON_BIN="python3"
elif command -v python >/dev/null 2>&1; then
PYTHON_BIN="python"
else
echo "Python runtime not found (python3/python). Falling back to 'lunet serve'." >&2
dotnet tool run lunet --stacktrace serve
exit 0
fi
dotnet tool run lunet --stacktrace build --dev
dotnet tool run lunet --stacktrace build --dev --watch &
LUNET_WATCH_PID=$!
cleanup() {
kill "${LUNET_WATCH_PID}" >/dev/null 2>&1 || true
}
trap cleanup EXIT INT TERM
echo "Serving docs at http://${HOST}:${PORT}"
echo "Watching docs with Lunet (dev mode)..."
cd .lunet/build/www
"${PYTHON_BIN}" -m http.server "${PORT}" --bind "${HOST}"