comfy-pr 0.2.20 → 0.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +267 -0
- package/package.json +20 -2
- package/src/Authors.ts +48 -0
- package/src/CNRepos.ts +3 -0
- package/src/EmailTasks.ts +100 -0
- package/src/Totals.ts +15 -0
- package/src/addCommentAction.ts +73 -0
- package/src/analyzePullsStatus.ts +79 -20
- package/src/analyzeTotals.ts +2 -4
- package/src/createGithubForkForRepo.ts +4 -1
- package/src/followRuleSchema.ts +14 -12
- package/src/index.ts +4 -1
- package/src/sendEmailAction.ts +56 -0
- package/src/sendGmail.ts +104 -0
- package/src/showFollowRuleSet.ts +12 -0
- package/src/updateAuthors.ts +7 -0
- package/src/updateAuthorsForGithub.ts +54 -0
- package/src/updateAuthorsFromCNRepo.ts +30 -0
- package/src/updateComfyTotals.ts +9 -9
- package/src/updateFollowRuleSet.ts +33 -78
- package/src/updateOutdatedPullsTemplates.ts +4 -0
|
@@ -1,42 +1,38 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
import { $elemMatch } from "@/packages/mongodb-pipeline-ts/$elemMatch";
|
|
3
|
-
import { $pipeline } from "@/packages/mongodb-pipeline-ts/$pipeline";
|
|
4
2
|
import { TaskDataOrNull } from "@/packages/mongodb-pipeline-ts/Task";
|
|
5
3
|
import DIE from "@snomiao/die";
|
|
6
4
|
import pMap from "p-map";
|
|
7
5
|
import { peekYaml } from "peek-log";
|
|
8
|
-
import { TaskError, TaskOK
|
|
9
|
-
import { CNRepos
|
|
6
|
+
import { TaskError, TaskOK } from "../packages/mongodb-pipeline-ts/Task";
|
|
7
|
+
import { CNRepos } from "./CNRepos";
|
|
10
8
|
import { FollowRuleSets } from "./FollowRules";
|
|
11
|
-
import
|
|
9
|
+
import { addCommentAction } from "./addCommentAction";
|
|
12
10
|
import { analyzePullsStatus, analyzePullsStatusPipeline } from "./analyzePullsStatus";
|
|
13
|
-
import { createIssueComment } from "./createIssueComment";
|
|
14
11
|
import { $filaten } from "./db";
|
|
15
|
-
import { zAddCommentAction, zFollowUpRules } from "./followRuleSchema";
|
|
12
|
+
import { zAddCommentAction, zFollowUpRules, zSendEmailAction } from "./followRuleSchema";
|
|
16
13
|
import { fetchIssueComments } from "./gh/fetchIssueComments";
|
|
17
|
-
import { ghUser } from "./ghUser";
|
|
18
14
|
import { initializeFollowRules } from "./initializeFollowRules";
|
|
19
15
|
import { stringifyGithubRepoUrl } from "./parseOwnerRepo";
|
|
20
16
|
import { parsePullUrl } from "./parsePullUrl";
|
|
21
|
-
import {
|
|
17
|
+
import { sendEmailAction } from "./sendEmailAction";
|
|
22
18
|
import { yaml } from "./utils/yaml";
|
|
23
19
|
|
|
24
20
|
if (import.meta.main) {
|
|
25
|
-
//
|
|
26
|
-
await
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
await updateFollowRuleSet({ name: "default", enable: true, yaml: defaultRuleSet.yaml });
|
|
30
|
-
await runFollowRuleSet();
|
|
21
|
+
// const defaultRuleSet = await initializeFollowRules();
|
|
22
|
+
// await updateFollowRuleSet({ name: "default", enable: true, yaml: defaultRuleSet.yaml });
|
|
23
|
+
// await runFollowRuleSet();
|
|
31
24
|
}
|
|
32
25
|
|
|
33
26
|
export async function runFollowRuleSet({ name = "default" } = {}) {
|
|
34
27
|
const ruleset = (await FollowRuleSets.findOne({ name })) ?? DIE("default ruleset not found");
|
|
28
|
+
|
|
29
|
+
console.log("RUNNING ruleset:");
|
|
30
|
+
console.log(ruleset.yamlWhenEnabled);
|
|
35
31
|
return peekYaml(
|
|
36
32
|
await updateFollowRuleSet({
|
|
37
33
|
name: ruleset.name,
|
|
38
|
-
enable: ruleset.enabled
|
|
39
|
-
yaml: ruleset.yamlWhenEnabled
|
|
34
|
+
enable: ruleset.enabled || DIE(new Error("Ruleset is not enabled")),
|
|
35
|
+
yaml: ruleset.yamlWhenEnabled || DIE("Enabled yaml is not found"),
|
|
40
36
|
runAction: true,
|
|
41
37
|
}),
|
|
42
38
|
);
|
|
@@ -48,23 +44,24 @@ export async function updateFollowRuleSet({
|
|
|
48
44
|
enable,
|
|
49
45
|
runAction = false,
|
|
50
46
|
}: {
|
|
47
|
+
/** 'default' */
|
|
51
48
|
name: string;
|
|
52
|
-
/** update yaml if provided */
|
|
49
|
+
/** update yaml if provided, unchange if undefined */
|
|
53
50
|
yaml?: string;
|
|
54
|
-
/** update enable if provided */
|
|
51
|
+
/** update enable if provided, unchange if undefined */
|
|
55
52
|
enable?: boolean | undefined;
|
|
56
|
-
/** run action if
|
|
53
|
+
/** run action if true */
|
|
57
54
|
runAction?: boolean;
|
|
58
55
|
}) {
|
|
59
56
|
"use server";
|
|
60
57
|
return await (async function () {
|
|
61
58
|
if (enable === false) {
|
|
62
59
|
await FollowRuleSets.updateOne({ name }, { $set: { enabled: false, yamlWhenEnabled: "" } });
|
|
63
|
-
DIE
|
|
60
|
+
DIE`ruleset is disabled, no need to run`;
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
// must parse while run, because the date in code is dynamic generated
|
|
67
|
-
const rules = zFollowUpRules.parse(yaml.parse(code || DIE
|
|
64
|
+
const rules = zFollowUpRules.parse(yaml.parse(code || DIE`yaml is empty`));
|
|
68
65
|
// save if parse succ
|
|
69
66
|
// await FollowRuleSets.updateOne({ name }, { $set: { yaml: code, rules } });
|
|
70
67
|
const parseResult = await pMap(
|
|
@@ -104,60 +101,11 @@ export async function updateFollowRuleSet({
|
|
|
104
101
|
async ([name, _action]) => {
|
|
105
102
|
if (name === "add-comment") {
|
|
106
103
|
const action = zAddCommentAction.parse(_action);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
action: "add-comment",
|
|
113
|
-
url: payload.url,
|
|
114
|
-
by: action.by,
|
|
115
|
-
body: action.body.replace(
|
|
116
|
-
/{{\$(\w+)}}/,
|
|
117
|
-
(_, key: string) =>
|
|
118
|
-
(payload as any)[key] ||
|
|
119
|
-
DIE("Missing key: " + key + " in payload: " + JSON.stringify(payload)),
|
|
120
|
-
),
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
if (runAction && loadedAction.by === ghUser.login) {
|
|
124
|
-
const existedCommentsTask =
|
|
125
|
-
(await $pipeline(CNRepos)
|
|
126
|
-
.unwind("$crPulls.data")
|
|
127
|
-
.match({ "crPulls.data.pull.html_url": loadedAction.url })
|
|
128
|
-
.with<{ "crPulls.data": CRPull }>()
|
|
129
|
-
.replaceRoot({ newRoot: "$crPulls.data.comments" })
|
|
130
|
-
.as<Task<GithubIssueComment[]>>()
|
|
131
|
-
.aggregate()
|
|
132
|
-
.next()) ??
|
|
133
|
-
DIE("comments is not fetched before, plz check " + loadedAction.url + " in CNRepos");
|
|
134
|
-
|
|
135
|
-
const existedComments =
|
|
136
|
-
TaskDataOrNull(existedCommentsTask) ??
|
|
137
|
-
DIE("NO-COMMENTS-FOUND should never happen here, bcz pipeline filtered at first");
|
|
138
|
-
const existedComment = existedComments.find((e) => e.body === loadedAction.body);
|
|
139
|
-
|
|
140
|
-
if (!existedComment) {
|
|
141
|
-
const { comments, comment } = await createIssueComment(
|
|
142
|
-
loadedAction.url,
|
|
143
|
-
loadedAction.body,
|
|
144
|
-
loadedAction.by,
|
|
145
|
-
);
|
|
146
|
-
const updateResult = await CNRepos.updateOne(
|
|
147
|
-
$filaten({ crPulls: { data: $elemMatch({ pull: { html_url: loadedAction.url } }) } }),
|
|
148
|
-
{ $set: { "crPulls.data.$.comments": comments } },
|
|
149
|
-
);
|
|
150
|
-
if (!updateResult.matchedCount) DIE("created issue not matched");
|
|
151
|
-
await notifySlackLinks("A New issue comment are created from rule " + rule.name, [
|
|
152
|
-
comment.html_url,
|
|
153
|
-
]);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return loadedAction;
|
|
158
|
-
},
|
|
159
|
-
{ concurrency: 1 },
|
|
160
|
-
);
|
|
104
|
+
return await addCommentAction({ matched, action, runAction, rule });
|
|
105
|
+
}
|
|
106
|
+
if (name === "send-email") {
|
|
107
|
+
const action = zSendEmailAction.parse(_action);
|
|
108
|
+
return await sendEmailAction({ matched, action, runAction, rule });
|
|
161
109
|
}
|
|
162
110
|
},
|
|
163
111
|
{ concurrency: 1 },
|
|
@@ -170,8 +118,15 @@ export async function updateFollowRuleSet({
|
|
|
170
118
|
},
|
|
171
119
|
{ concurrency: 1 },
|
|
172
120
|
);
|
|
173
|
-
|
|
174
|
-
|
|
121
|
+
|
|
122
|
+
if (enable === true) {
|
|
123
|
+
await FollowRuleSets.updateOne(
|
|
124
|
+
{ name },
|
|
125
|
+
{
|
|
126
|
+
$set: { enabled: true, yamlWhenEnabled: code, yaml: code },
|
|
127
|
+
$push: { enableHistory: { mtime: new Date(), yaml: code } },
|
|
128
|
+
},
|
|
129
|
+
);
|
|
175
130
|
} else {
|
|
176
131
|
await FollowRuleSets.updateOne({ name }, { $set: { yaml: code } });
|
|
177
132
|
}
|
|
@@ -25,6 +25,7 @@ export async function updateOutdatedPullsTemplates() {
|
|
|
25
25
|
const outdated_publishcr_v2 = await readTemplate("outdated/add-action-v2.md");
|
|
26
26
|
const outdated_pyproject_v3 = await readTemplate("outdated/add-toml-v3.md");
|
|
27
27
|
const outdated_publishcr_v3 = await readTemplate("outdated/add-action-v3.md");
|
|
28
|
+
const outdated_pyproject_v4 = await readTemplate("outdated/add-toml-v4.md");
|
|
28
29
|
const outdateTitles = [
|
|
29
30
|
outdated_pyproject.title,
|
|
30
31
|
outdated_publishcr.title,
|
|
@@ -32,6 +33,7 @@ export async function updateOutdatedPullsTemplates() {
|
|
|
32
33
|
outdated_publishcr_v2.title,
|
|
33
34
|
outdated_pyproject_v3.title,
|
|
34
35
|
outdated_publishcr_v3.title,
|
|
36
|
+
outdated_pyproject_v4.title,
|
|
35
37
|
];
|
|
36
38
|
const outdateBodies = [
|
|
37
39
|
outdated_pyproject.body,
|
|
@@ -40,6 +42,7 @@ export async function updateOutdatedPullsTemplates() {
|
|
|
40
42
|
outdated_publishcr_v2.body,
|
|
41
43
|
outdated_pyproject_v3.body,
|
|
42
44
|
outdated_publishcr_v3.body,
|
|
45
|
+
outdated_pyproject_v4.body,
|
|
43
46
|
];
|
|
44
47
|
|
|
45
48
|
// const templateOutdate = new Date("2024-06-13T09:02:56.630Z");
|
|
@@ -109,6 +112,7 @@ export async function updateOutdatedPullsTemplates() {
|
|
|
109
112
|
.with(outdated_pyproject, () => pyproject)
|
|
110
113
|
.with(outdated_pyproject_v2, () => pyproject)
|
|
111
114
|
.with(outdated_pyproject_v3, () => pyproject)
|
|
115
|
+
.with(outdated_pyproject_v4, () => pyproject)
|
|
112
116
|
.with(outdated_publishcr, () => publishcr)
|
|
113
117
|
.with(outdated_publishcr_v2, () => publishcr)
|
|
114
118
|
.with(outdated_publishcr_v3, () => publishcr)
|