88
99from nb_cli import _
1010from nb_cli .config import (
11- GLOBAL_CONFIG ,
1211 SimpleInfo ,
1312 PackageInfo ,
1413 NoneBotConfig ,
2322from .meta import (
2423 get_project_root ,
2524 requires_nonebot ,
25+ get_config_manager ,
2626 get_default_python ,
2727 get_nonebot_config ,
2828 requires_project_root ,
@@ -127,8 +127,8 @@ def _index_by_module_name(data: Iterable[T_info]) -> dict[str, T_info]:
127127
128128
129129@requires_project_root
130- async def upgrade_project_format () -> None :
131- bot_config = get_nonebot_config ()
130+ async def upgrade_project_format (* , cwd : Path | None = None ) -> None :
131+ bot_config = get_nonebot_config (cwd )
132132 if isinstance (bot_config , NoneBotConfig ):
133133 click .echo (_ ("Current format is already the new format." ))
134134 return
@@ -178,13 +178,14 @@ async def upgrade_project_format() -> None:
178178 builtin_plugins = bot_config .builtin_plugins ,
179179 )
180180
181- GLOBAL_CONFIG .update_nonebot_config (new_config )
182- GLOBAL_CONFIG .update_dependency (nonebot_pkg , * packages )
181+ manager = get_config_manager (cwd )
182+ manager .update_nonebot_config (new_config )
183+ manager .update_dependency (nonebot_pkg , * packages )
183184
184185
185186@requires_project_root
186- async def downgrade_project_format () -> None :
187- bot_config = get_nonebot_config ()
187+ async def downgrade_project_format (* , cwd : Path | None = None ) -> None :
188+ bot_config = get_nonebot_config (cwd )
188189 if isinstance (bot_config , LegacyNoneBotConfig ):
189190 click .echo (_ ("Current format is already the old format." ))
190191 return
@@ -196,4 +197,5 @@ async def downgrade_project_format() -> None:
196197 builtin_plugins = bot_config .builtin_plugins ,
197198 )
198199
199- GLOBAL_CONFIG .update_nonebot_config (old_config )
200+ manager = get_config_manager (cwd )
201+ manager .update_nonebot_config (old_config )
0 commit comments