微信小程序页面迁移校验之前 P5任务处理之前

This commit is contained in:
Neo
2026-03-09 01:19:21 +08:00
parent 263bf96035
commit 6e20987d2f
1112 changed files with 153824 additions and 219694 deletions

View File

@@ -28,6 +28,37 @@ if _FEIQIU_ENV.exists():
load_dotenv(_FEIQIU_ENV, override=False)
def ensure_repo_root() -> Path:
"""校验 cwd 是否为仓库根目录,不是则自动切换。
委托给 neozqyy_shared.repo_root共享包
未安装时 fallback 到本地实现。
"""
try:
from neozqyy_shared.repo_root import ensure_repo_root as _shared
return _shared()
except ImportError:
pass
# fallback共享包未安装时的本地实现
cwd = Path.cwd()
if (cwd / "pyproject.toml").is_file() and (cwd / ".kiro").is_dir():
return cwd
root = Path(__file__).resolve().parents[2]
if (root / "pyproject.toml").is_file() and (root / ".kiro").is_dir():
os.chdir(root)
import warnings
warnings.warn(
f"cwd 不是仓库根目录,已自动切换: {cwd}{root}",
stacklevel=2,
)
return root
raise RuntimeError(
f"无法定位仓库根目录。当前 cwd={cwd}"
f"推断 root={root},均未找到 pyproject.toml + .kiro。"
f"请在仓库根目录下运行脚本。"
)
def get_output_path(env_var: str) -> Path:
"""
从环境变量读取输出路径。