feat: switch config to JSONC + split secrets.json

Load business config as JSONC (comments + trailing commas) via an
in-repo stripper then stdlib json — no new deps. Default path prefers
config.jsonc, falls back to legacy config.json. Auth write-back targets
only sibling secrets.json so JSONC comments are never wiped; secrets
overlay merges on load. Examples, compose, Docker, docs, favsort and
tools all share the same loader. Phase A only — no DB settings migration.
This commit was merged in pull request #4.
This commit is contained in:
bot-ci committed 2026-11-02 12:58:20 +08:00
1 parent b4f0f45c4e
commit 8e7ead1669
21 files changed
+652 -182

No files matched your search

+4 -3
View File
@@ -31,6 +31,7 @@ from typing import Any, Mapping, Sequence
ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT))
from reaction_board.config import default_config_path # noqa: E402
from reaction_board.database import Database # noqa: E402
from reaction_board.repository import Repository # noqa: E402
from reaction_board.timeutil import SHANGHAI_TZ # noqa: E402
@@ -226,19 +227,19 @@ def _database_path(config_path: str, override: str | None) -> Path:
return Path(override)
from reaction_board.config import ConfigStore
candidates = [Path(config_path), Path("/config/config.json")]
candidates = [Path(config_path), Path("/config/config.jsonc"), Path("/config/config.json")]
for candidate in candidates:
if candidate.exists():
return ConfigStore(str(candidate), require_auth=False).get().storage.database_path
raise ValueError(
"找不到配置文件;请用 --db /data/app.db 或 --config /config/config.json"
"找不到配置文件;请用 --db /data/app.db 或 --config /config/config.jsonc"
)
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser(description="从 B 站粉丝历史 CSV 回填 up_stat")
parser.add_argument("--csv", required=True, help="粉丝历史 CSV 路径")
parser.add_argument("--config", default=str(ROOT / "config.json"), help="配置文件")
parser.add_argument("--config", default=str(default_config_path(ROOT)), help="配置文件")
parser.add_argument("--db", default=None, help="直接指定数据库(覆盖配置)")
parser.add_argument("--mid", type=int, default=DEFAULT_MID, help="写入的 B 站 mid")
parser.add_argument("--force", action="store_true", help="覆盖同日期已有 ok=1 记录")