Skip to content

Commit a9639ea

Browse files
feat(config): 支持配置文件 1.3
1 parent 37d00bc commit a9639ea

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/function/maintain/config.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
class 配置信息:
1010
默认配置: dict[str, Any] = {
11-
"$schema": "https://duckduckstudio.github.io/yazicbs.github.io/Tools/Sundry/config/schema/1.2.json",
12-
"version": "1.2",
11+
"$schema": "https://duckduckstudio.github.io/yazicbs.github.io/Tools/Sundry/config/schema/1.3.json",
12+
"version": "1.3",
1313
"debug": False,
1414
"paths": {
1515
"winget-pkgs": "",
@@ -26,9 +26,13 @@ class 配置信息:
2626
"pr": {
2727
"maintainer_can_modify": False,
2828
"mention_self_when_reviewer": False
29-
}
29+
},
30+
"token": "glm",
3031
},
3132
"tools": {
33+
"autoremove": {
34+
"open_in_browser": False
35+
},
3236
"prune": {
3337
"remote": {
3438
"prune_merged_branches": False,
@@ -53,6 +57,7 @@ class 配置信息:
5357
"debug",
5458
"git.signature",
5559
"github.pr.maintainer_can_modify", "github.pr.mention_self_when_reviewer",
60+
"tools.autoremove.open_in_browser",
5661
"tools.prune.remote.prune_merged_branches", "tools.prune.remote.prune_closed_branches",
5762
"tools.verify.show_warning_on_non-clean_windows",
5863
"cache.validate.schema"
@@ -65,7 +70,7 @@ class 配置信息:
6570
"repos.winget-tools"
6671
]
6772

68-
最新版本: str = "1.2"
73+
最新版本: str = "1.3"
6974

7075
所在位置: str = os.path.join(os.path.expanduser("~"), ".config", "DuckStudio", "Sundry", "config.json")
7176

@@ -113,6 +118,9 @@ def 验证配置(配置项: str, 配置值: str | bool) -> str | None:
113118
elif (配置项 == "i18n.lang") and (配置值 not in ["zh-cn", "en-us"]):
114119
return f"不支持的语言 {Fore.BLUE}{配置值}{Fore.RESET}"
115120

121+
elif (配置项 == "github.token") and (配置值 not in ["glm", "komac", "env"]):
122+
return "未知的 Token 读取源"
123+
116124
else:
117125
return None
118126

src/tools/maintain/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from typing import Any
55
from colorama import Fore
66
from catfood.functions.print import 消息头
7-
from pygments import highlight # type: ignore
87
from catfood.functions.files import open_file
8+
from pygments import highlight # type: ignore
99
from pygments.lexers import JsonLexer # type: ignore
1010
from pygments.formatters import TerminalFormatter
1111
from function.maintain.config import 读取配置, 验证配置, 读取配置项, 配置信息, 获取当前配置版本, 获取配置schema
@@ -24,6 +24,10 @@ def 获取用户输入(键路径: str) -> str | bool:
2424
# github.pr.*
2525
"github.pr.maintainer_can_modify": f"{消息头.问题} 是否允许维护者修改您的 PR 内容? (默认为{Fore.YELLOW}{Fore.RESET}): ",
2626
"github.pr.mention_self_when_reviewer": f"{消息头.问题} 创建 PR 时,如果自己在 Auth.csv 中作为包修改的审查者时,是否在 PR 中请求自己审查? (默认为{Fore.YELLOW}{Fore.RESET}): ",
27+
# github.token
28+
"github.token": f"{消息头.问题} 我该从哪里读取 GitHub Token? [{Fore.GREEN}glm(默认){Fore.RESET}, 环境变量 GITHUB_TOKEN (env), komac]: ",
29+
# tools.autoremove.*
30+
"tools.autoremove.open_in_browser": f"{消息头.问题} 在自动移除 (autoremove) 时,是否要在浏览器中打开清单中的安装程序链接 (InstallerUrl) 以供检查? (默认为{Fore.YELLOW}{Fore.RESET}): ",
2731
# tools.prune.*
2832
"tools.prune.remote.prune_merged_branches": f"{消息头.问题} prune 时清理远程中{Fore.YELLOW}已合并{Fore.RESET}的 PR 的分支? (默认为{Fore.YELLOW}{Fore.RESET}): ",
2933
"tools.prune.remote.prune_closed_branches": f"{消息头.问题} prune 时清理远程中{Fore.YELLOW}已关闭{Fore.RESET}的 PR 的分支? (默认为{Fore.YELLOW}{Fore.RESET}): ",

0 commit comments

Comments
 (0)