From 53a603d4ee64c7f1d44d49ddb34a5c0a5c45282e Mon Sep 17 00:00:00 2001 From: snowykami Date: Tue, 17 Sep 2024 15:26:21 +0800 Subject: [PATCH] =?UTF-8?q?:package:=20docs:=20=E8=B5=84=E6=BA=90=E5=95=86?= =?UTF-8?q?=E5=BA=97=E6=96=B0=E5=A2=9E=E5=8F=91=E5=B8=83=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/components/ResStore.vue | 2 +- liteyuki_flow/markdown_parser.py | 3 +++ liteyuki_flow/resource_handler.py | 13 +++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/components/ResStore.vue b/docs/components/ResStore.vue index e8a1da67..d192b9c8 100644 --- a/docs/components/ResStore.vue +++ b/docs/components/ResStore.vue @@ -48,7 +48,7 @@ function closePublishWindow() { const submitForm = () => { const title = encodeURI(`Resource: ${newRes.value.name}`) let body = encodeURI(`---\nname: ${newRes.value.name}\ndesc: ${newRes.value.desc}\nauthor: ${newRes.value.author}\nhomepage: ${newRes.value.homepage}\nlink: ${newRes.value.link}\n---\n`) - const issueURL = `${RepoUrl}/issues/new?labels=Resource&title=${title}&body=${body}` + const issueURL = `${RepoUrl}/issues/new?title=${title}&body=${body}` window.open(issueURL, '_blank') } diff --git a/liteyuki_flow/markdown_parser.py b/liteyuki_flow/markdown_parser.py index 1e77e44a..faf1cfcc 100644 --- a/liteyuki_flow/markdown_parser.py +++ b/liteyuki_flow/markdown_parser.py @@ -78,6 +78,9 @@ class MarkdownParser: self.front_matters[key.strip()] = value.strip() return nil + def build_front_matters(self) -> str: + return "---\n" + str(self.front_matters) + "\n---" + def _parse_content(self) -> tuple[list[Any], err]: content: list[Any] = [] while self.lineno < len(self.content_lines): diff --git a/liteyuki_flow/resource_handler.py b/liteyuki_flow/resource_handler.py index 3742cfe5..134acb87 100644 --- a/liteyuki_flow/resource_handler.py +++ b/liteyuki_flow/resource_handler.py @@ -26,7 +26,14 @@ headers = { # closed: 审核通过,修改json并提交 # reopened: 重新打开,无操作 def on_first_open(github: Github, issue: Issue, repo: Repository): - issue.create_comment("已收到资源包发布请求,我会马上开始预检. " + edit_tip) + cid = issue.create_comment("已收到资源包发布请求,我会马上开始预检. " + edit_tip).id + parser = MarkdownParser(issue.body) + parser.parse_front_matters() + parser.front_matters["cid"] = str(cid) + + new_issue_body = parser.build_front_matters() + issue.add_to_labels("Resource") + issue.edit(body=new_issue_body) # opened | edited @@ -38,6 +45,7 @@ def pre_check(github: Github, issue: Issue, repo: Repository) -> err: link = parser.front_matters.get("link") homepage = parser.front_matters.get("homepage") # optional author = parser.front_matters.get("author") + cid = parser.front_matters.get("cid") # optional auto if not all((name, desc, link, author)): issue.create_comment("name, desc, link, homepage 及 author 为必填字段.") return ValueError("name, desc, link, homepage 及 author 为必填字段.") @@ -86,7 +94,8 @@ def pre_check(github: Github, issue: Issue, repo: Repository) -> err: if k not in ("name", "description", "version"): new_issue_body += f"**{k}**: {v}\n" - issue.edit(new_issue_body) + issue.edit(body=new_issue_body) + issue.add_to_labels("pre-checked") issue.create_comment("✅ 预检查通过\n## 元数据\n" + metadata_markdown) return nil