From c4c4d73389b8cfa6c5d334d029d701b4b75953dd Mon Sep 17 00:00:00 2001 From: Menghuan1918 Date: Thu, 3 Sep 2026 10:36:03 +0800 Subject: [PATCH] fix(ci): resolve consumer-type link targets to their physical path On the Windows lane the @deepseek-ai/cordis link produced TS2307 even though the link was visibly created: under pnpm its target, node_modules/@deepseek-ai/cordis, is itself a junction into .pnpm, and a native symlink pointing AT that junction does not traverse for tsc. Resolve both link targets with node's native realpath first (GetFinalPathNameByHandle also expands junctions, which bash-level resolution may leave untouched), and fail loudly with the link layer listed when a created link does not resolve to a package root. --- scripts/check-consumer-types.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/check-consumer-types.sh b/scripts/check-consumer-types.sh index 7f0e822..51b9ccd 100755 --- a/scripts/check-consumer-types.sh +++ b/scripts/check-consumer-types.sh @@ -28,11 +28,27 @@ WORK="$(mktemp -d)" trap 'rm -rf "$WORK"' EXIT mkdir -p "$WORK/node_modules" -ln -s "$(pwd)" "$WORK/node_modules/dsh-better-sidebar" +# Resolve link targets to their PHYSICAL path first: under pnpm, +# node_modules/@deepseek-ai/cordis is itself a symlink/junction into .pnpm, +# and on Windows a native symlink pointing AT a junction does not traverse +# for tsc (TS2307 on a link that visibly exists). Node's NATIVE realpath +# (GetFinalPathNameByHandle on Windows) expands junctions, which bash-level +# resolution may leave untouched; node is guaranteed here (tsc runs below). +resolve_dir() { node -e 'process.stdout.write(require("node:fs").realpathSync.native(process.argv[1]))' "$1"; } +ln -s "$(resolve_dir "$(pwd)")" "$WORK/node_modules/dsh-better-sidebar" # The vendored cordis base (and, through its realpath, cosmokit / standard-schema) # must resolve so the consumer can type `Context` against the DSH runtime scope. mkdir -p "$WORK/node_modules/@deepseek-ai" -ln -s "$(pwd)/node_modules/@deepseek-ai/cordis" "$WORK/node_modules/@deepseek-ai/cordis" +ln -s "$(resolve_dir "$(pwd)/node_modules/@deepseek-ai/cordis")" "$WORK/node_modules/@deepseek-ai/cordis" +# Loud guard: both links must resolve to a package root, or tsc below would +# report misleading module-resolution errors. +for pkg_json in "$WORK/node_modules/dsh-better-sidebar/package.json" "$WORK/node_modules/@deepseek-ai/cordis/package.json"; do + if [ ! -f "$pkg_json" ]; then + echo "[check-consumer-types] FAIL: $pkg_json does not resolve (broken link). Link layer:" >&2 + ls -la "$WORK/node_modules" "$WORK/node_modules/@deepseek-ai" >&2 || true + exit 1 + fi +done cat > "$WORK/check.ts" <<'EOF' import { SIDEBAR_FEATURES, SIDEBAR_SERVICE_VERSION } from 'dsh-better-sidebar/client/service'