Files
cflmy eff273f7f2 feat: consume the WEB-03 handoff with output-relative source links
Bump the fixed Design revision to the handoff/graph/slice/drift candidate and
make web handoff use handoff_relative_to with the output directory, so source
links stay relative when the delivery file is written elsewhere. CI asserts the
links are relative (no absolute/file targets) and that sources are present.

Refs cflmy/marqdo-web-preview#1, cflmy/marqdo-web-design#2, cflmy/marqdo#6
2026-11-27 08:57:22 +08:00

48 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# WEB-02 independent entry: real CLI, installed web Tool, offline artifact checks.
set -eu
: "${MARQDO_BIN:?set MARQDO_BIN to the verified marqdo executable}"
cd "$(dirname "$0")/.."
cargo fmt --all -- --check
cargo clippy --all-targets --locked -- -D warnings
scripts/package.sh
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
export MARQDO_TOOL_HOME="$work/tool-home"
cli_before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
"$MARQDO_BIN" tool install "$PWD/dist/marqdo-web-preview/tool.json"
"$MARQDO_BIN" web check tests/fixture/index.mq.md --unit 工作台
preview="$work/preview"
"$MARQDO_BIN" web preview tests/fixture/index.mq.md --unit 工作台 --out "$preview" --theme light
test -f "$preview/index.html"
grep -q "Content-Security-Policy" "$preview/index.html"
grep -q "default-src 'none'" "$preview/index.html"
grep -q "原型 / 模拟" "$preview/index.html"
grep -q "raw HTML as inert text" "$preview/index.html"
grep -q "模拟保存" "$preview/index.html"
grep -q "data-scenario" "$preview/index.html"
! grep -q "href=\"javascript:" "$preview/index.html"
! grep -q "<script src" "$preview/index.html"
handoff="$work/handoff.md"
"$MARQDO_BIN" web handoff tests/fixture/index.mq.md --unit 工作台 --out "$handoff"
test -s "$handoff"
grep -q "Design handoff" "$handoff"
grep -q "components/nav.mq.md#导航" "$handoff"
python3 - "$handoff" <<'PY'
import pathlib, sys, re
text = pathlib.Path(sys.argv[1]).read_text()
assert "](" in text
for target in re.findall(r"\]\(([^)]+)\)", text):
assert not target.startswith("/"), target
assert not target.startswith("file:"), target
print("handoff links are relative")
PY
if "$MARQDO_BIN" web preview tests/fixture/index.mq.md --unit 工作台 --out "$preview" 2>/dev/null; then
echo "preview overwrote an existing directory" >&2
exit 1
fi
cli_after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
test "$cli_before" = "$cli_after"
"$MARQDO_BIN" tool remove web
echo "PASS: marqdo web Tool check/preview/handoff/remove"