fix: add init-db CLI for host install/upgrade metadata seed
All checks were successful
技能自动化发布 / release (push) Successful in 6s
All checks were successful
技能自动化发布 / release (push) Successful in 6s
This commit is contained in:
@@ -38,6 +38,7 @@ from service.account_service import (
|
||||
cmd_delete_by_platform,
|
||||
cmd_delete_by_platform_phone,
|
||||
cmd_get,
|
||||
cmd_init_db,
|
||||
cmd_lease_cleanup,
|
||||
cmd_lease_list,
|
||||
cmd_lease_release,
|
||||
@@ -60,6 +61,9 @@ from util.runtime_paths import _maybe_print_paths_debug_cli
|
||||
|
||||
_USAGE = """account-manager v2 — Credential & Browser Profile Manager
|
||||
|
||||
运行时 / 数据管理:
|
||||
init-db # 幂等初始化本地库与数据管理中文元数据(宿主安装/升级会调用)
|
||||
|
||||
平台管理:
|
||||
platform list [--domain logistics|llm|content]
|
||||
platform get <platform>
|
||||
@@ -217,6 +221,10 @@ def main() -> None:
|
||||
# Determine if first arg is a platform key (for legacy shorthand)
|
||||
plat_from_first = resolve_platform_key(cmd)
|
||||
|
||||
# ---- init-db(宿主 install/upgrade 标准入口)----
|
||||
if cmd == "init-db":
|
||||
sys.exit(cmd_init_db())
|
||||
|
||||
# ---- platform subcommand ----
|
||||
if cmd == "platform":
|
||||
if len(av) < 3:
|
||||
|
||||
@@ -39,7 +39,12 @@ from service.legacy_commands import (
|
||||
cmd_list,
|
||||
)
|
||||
from service.lease_commands import cmd_lease_cleanup, cmd_lease_list, cmd_lease_release
|
||||
from service.platform_commands import cmd_platform_ensure, cmd_platform_get, cmd_platform_list
|
||||
from service.platform_commands import (
|
||||
cmd_init_db,
|
||||
cmd_platform_ensure,
|
||||
cmd_platform_get,
|
||||
cmd_platform_list,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"PlatformCallerMeta",
|
||||
@@ -60,6 +65,7 @@ __all__ = [
|
||||
"cmd_delete_by_platform",
|
||||
"cmd_delete_by_platform_phone",
|
||||
"cmd_get",
|
||||
"cmd_init_db",
|
||||
"cmd_lease_cleanup",
|
||||
"cmd_lease_list",
|
||||
"cmd_lease_release",
|
||||
|
||||
@@ -6,8 +6,38 @@ from typing import Optional
|
||||
from db.accounts_repo import get_platform_from_db, list_platforms_from_db, upsert_platform
|
||||
from db.connection import get_conn, init_db
|
||||
from service._svc_common import _err_json, _ok_json, _resolve_or_fail, _say
|
||||
from util.constants import SKILL_SLUG
|
||||
from util.logging_config import get_skill_logger
|
||||
from util.platforms import DEFAULT_CAPABILITIES_JSON, is_valid_platform_key_format, seed_platforms
|
||||
from util.runtime_paths import get_db_path
|
||||
|
||||
|
||||
def cmd_init_db() -> int:
|
||||
"""幂等创建/迁移本地 SQLite 与数据管理元数据(宿主 install/upgrade 可调用)。"""
|
||||
log = get_skill_logger()
|
||||
log.info("cli_start subcommand=init_db")
|
||||
try:
|
||||
init_db()
|
||||
except Exception as exc: # noqa: BLE001 — CLI 边界,统一成可机读失败
|
||||
log.exception("init_db_failure")
|
||||
print(
|
||||
json.dumps(
|
||||
{"ok": False, "skill": SKILL_SLUG, "error": str(exc)},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
)
|
||||
return 1
|
||||
print(
|
||||
json.dumps(
|
||||
{
|
||||
"ok": True,
|
||||
"skill": SKILL_SLUG,
|
||||
"db_path": get_db_path(),
|
||||
},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_platform_list(domain: Optional[str] = None) -> None:
|
||||
|
||||
Reference in New Issue
Block a user