From 8235f91bc60388be5eabac572d52d7c68dbd5b6a Mon Sep 17 00:00:00 2001 From: OG T Date: Mon, 6 Apr 2026 12:00:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(scripts):=20generate-schemas=20=E5=90=8C?= =?UTF-8?q?=E6=99=82=E5=8A=A0=E5=85=A5=20apps/api=20=E5=92=8C=20apps/api/s?= =?UTF-8?q?rc=20=E5=88=B0=20sys.path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 問題: CI type-sync-check 持續失敗 原因: 只加 apps/api/src 不夠,模型檔內部用 from src.utils.X import Y 需要 apps/api 在 path 才能解析 src 套件 結果: 51 個型別全部正確生成 # 2026-04-06 ogt: fix CI type-sync blocking deployment Co-Authored-By: Claude Sonnet 4.6 --- scripts/generate-schemas.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/generate-schemas.py b/scripts/generate-schemas.py index a028c9ed..5f63ac04 100644 --- a/scripts/generate-schemas.py +++ b/scripts/generate-schemas.py @@ -22,9 +22,14 @@ import sys from pathlib import Path from typing import Any -# 加入 apps/api/src 到 Python path -api_src = Path(__file__).parent.parent / "apps" / "api" / "src" +# 加入 apps/api 和 apps/api/src 到 Python path +# - apps/api/src: script 內部用 `from models.X import Y` +# - apps/api: 模型檔案內部用 `from src.utils.X import Y` +# 2026-04-06 ogt: 兩個都需要,否則跨模組 import 失敗導致 CI 產生空 schema +api_root = Path(__file__).parent.parent / "apps" / "api" +api_src = api_root / "src" sys.path.insert(0, str(api_src)) +sys.path.insert(0, str(api_root)) # 輸出目錄 OUTPUT_DIR = Path(__file__).parent.parent / "packages" / "shared-types" / "schemas"