comfy-pr 0.2.24 → 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.
Files changed (81) hide show
  1. package/CHANGELOG.md +385 -0
  2. package/README.md +225 -225
  3. package/next-env.d.ts +5 -5
  4. package/package.json +12 -2
  5. package/src/Authors.ts +48 -48
  6. package/src/CMNodes.ts +60 -60
  7. package/src/CNRepos.ts +75 -74
  8. package/src/CRNodes.ts +27 -27
  9. package/src/CRPulls.ts +4 -4
  10. package/src/EmailTasks.ts +100 -0
  11. package/src/FORK_OWNER.ts +5 -5
  12. package/src/FORK_PREFIX.ts +5 -5
  13. package/src/FollowRules.ts +25 -25
  14. package/src/GIT_USEREMAIL.ts +5 -5
  15. package/src/GIT_USERNAME.ts +9 -9
  16. package/src/GithubIssueComments.ts +3 -3
  17. package/src/PushedBranch.ts +3 -3
  18. package/src/Totals.ts +24 -9
  19. package/src/TrackingPRs.ts +12 -12
  20. package/src/WorkerInstances.ts +89 -89
  21. package/src/addCommentAction.ts +73 -65
  22. package/src/analyzePullsStatus.ts +193 -170
  23. package/src/analyzeTotals.test.ts +5 -5
  24. package/src/analyzeTotals.ts +118 -118
  25. package/src/checkComfyActivated.ts +39 -39
  26. package/src/cli.ts +40 -40
  27. package/src/clone_modify_push_Branches.ts +21 -21
  28. package/src/createComfyRegistryPRsFromCandidates.ts +55 -55
  29. package/src/createComfyRegistryPullRequests.ts +22 -22
  30. package/src/createGithubForkForRepo.ts +40 -37
  31. package/src/createGithubPullRequest.ts +94 -94
  32. package/src/createIssueComment.ts +29 -29
  33. package/src/fetchCMNodes.ts +22 -22
  34. package/src/fetchComfyRegistryNodes.ts +11 -11
  35. package/src/fetchCurrentGeoInfo.ts +6 -6
  36. package/src/fetchRelatedPullWithComments.ts +15 -15
  37. package/src/fetchRepoDescriptionMap.ts +15 -15
  38. package/src/followRuleSchema.ts +78 -76
  39. package/src/getActivatedShell.ts +18 -18
  40. package/src/getBranchWorkingDir.ts +16 -16
  41. package/src/getRepoWorkingDir.ts +5 -5
  42. package/src/ghUser.ts +6 -6
  43. package/src/index.ts +24 -22
  44. package/src/initializeFollowRules.ts +26 -26
  45. package/src/makePublishBranch.ts +58 -58
  46. package/src/makeTomlBranch.ts +53 -53
  47. package/src/matchRelatedPulls.ts +60 -60
  48. package/src/muteInstances.ts +16 -16
  49. package/src/parseIssueUrl.ts +6 -6
  50. package/src/parseOwnerRepo.ts +33 -33
  51. package/src/parsePullUrl.ts +6 -6
  52. package/src/parsePullsState.ts +6 -6
  53. package/src/parseTitleBodyOfMarkdown.ts +8 -8
  54. package/src/postSlackMessage.ts +21 -21
  55. package/src/preload.ts +30 -30
  56. package/src/pullStatusFollowSchema.ts +12 -12
  57. package/src/readTemplateTitle.ts +11 -11
  58. package/src/sendEmailAction.ts +56 -0
  59. package/src/sendGmail.ts +104 -0
  60. package/src/showFollowRuleSet.ts +12 -12
  61. package/src/summaryLastPullComment.ts +8 -8
  62. package/src/tomlFillDescription.ts +17 -17
  63. package/src/updateAuthors.ts +7 -7
  64. package/src/updateAuthorsForGithub.ts +54 -50
  65. package/src/updateAuthorsFromCNRepo.ts +30 -30
  66. package/src/updateCMNodesDuplicationWarnings.ts +56 -56
  67. package/src/updateCMRepos.ts +27 -27
  68. package/src/updateCNRepos.ts +58 -58
  69. package/src/updateCNReposCRPullsComments.ts +40 -40
  70. package/src/updateCNReposInfo.ts +57 -57
  71. package/src/updateCNReposPRCandidate.ts +85 -85
  72. package/src/updateCNReposPulls.ts +28 -28
  73. package/src/updateCNReposPullsDashboard.ts +49 -49
  74. package/src/updateCNReposRelatedPulls.ts +25 -25
  75. package/src/updateCRNodes.ts +50 -50
  76. package/src/updateCRRepos.ts +26 -26
  77. package/src/updateComfyTotals.ts +43 -43
  78. package/src/updateFollowRuleSet.ts +137 -127
  79. package/src/updateOutdatedPullsTemplates.ts +160 -160
  80. package/src/updateSlackMessages.ts +43 -43
  81. package/tailwind.config.ts +20 -20
@@ -1,29 +1,29 @@
1
- import DIE from "@snomiao/die";
2
- import { gh } from "./gh";
3
- import { ghUser } from "./ghUser";
4
- import { parseIssueUrl } from "./parseIssueUrl";
5
-
6
- if (import.meta.main) {
7
- const url = "https://github.com/snomiao/ComfyNode-Registry-test/pull/1";
8
- const body = "Hello World @snomiao";
9
- const result = await createIssueComment(url, body, ghUser.login);
10
- console.log(result.comment.html_url);
11
- console.log(result.comments.map((e) => e.html_url));
12
- }
13
-
14
- export async function createIssueComment(issueUrl: string, body: string, by: string) {
15
- const comments = (
16
- await gh.issues.listComments({
17
- ...parseIssueUrl(issueUrl),
18
- })
19
- ).data;
20
- const result = await (async function () {
21
- const commentExisted = comments.find((e) => e.body === body);
22
- if (commentExisted) return { comment: commentExisted, comments };
23
- if (by !== ghUser.login) DIE("Fails to creating issue: user not match");
24
- const comment = (await gh.issues.createComment({ ...parseIssueUrl(issueUrl), body })).data;
25
- console.log("comment created: " + comment.html_url);
26
- return { comment, comments: [...comments, comment] };
27
- })();
28
- return result;
29
- }
1
+ import DIE from "@snomiao/die";
2
+ import { gh } from "./gh";
3
+ import { ghUser } from "./ghUser";
4
+ import { parseIssueUrl } from "./parseIssueUrl";
5
+
6
+ if (import.meta.main) {
7
+ const url = "https://github.com/snomiao/ComfyNode-Registry-test/pull/1";
8
+ const body = "Hello World @snomiao";
9
+ const result = await createIssueComment(url, body, ghUser.login);
10
+ console.log(result.comment.html_url);
11
+ console.log(result.comments.map((e) => e.html_url));
12
+ }
13
+
14
+ export async function createIssueComment(issueUrl: string, body: string, by: string) {
15
+ const comments = (
16
+ await gh.issues.listComments({
17
+ ...parseIssueUrl(issueUrl),
18
+ })
19
+ ).data;
20
+ const result = await (async function () {
21
+ const commentExisted = comments.find((e) => e.body === body);
22
+ if (commentExisted) return { comment: commentExisted, comments };
23
+ if (by !== ghUser.login) DIE("Fails to creating issue: user not match");
24
+ const comment = (await gh.issues.createComment({ ...parseIssueUrl(issueUrl), body })).data;
25
+ console.log("comment created: " + comment.html_url);
26
+ return { comment, comments: [...comments, comment] };
27
+ })();
28
+ return result;
29
+ }
@@ -1,22 +1,22 @@
1
- import { fetchJson } from "./utils/fetchJson";
2
-
3
- if (import.meta.main) {
4
- console.log(await fetchCMNodes());
5
- }
6
- export async function fetchCMNodes() {
7
- const customNodeListSource =
8
- process.env.CUSTOM_LIST_SOURCE ||
9
- "https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json";
10
- const nodeList = (await fetchJson(customNodeListSource)) as {
11
- custom_nodes: {
12
- author: "Dr.Lt.Data" | string;
13
- title: "ComfyUI-Manager" | string;
14
- id: "manager" | string;
15
- reference: "https://github.com/ltdrdata/ComfyUI-Manager" | string;
16
- files: ["https://github.com/ltdrdata/ComfyUI-Manager"] | string[];
17
- install_type: "git-clone" | string;
18
- description: "ComfyUI-Manager itself is also a custom node." | string;
19
- }[];
20
- };
21
- return nodeList.custom_nodes;
22
- }
1
+ import { fetchJson } from "./utils/fetchJson";
2
+
3
+ if (import.meta.main) {
4
+ console.log(await fetchCMNodes());
5
+ }
6
+ export async function fetchCMNodes() {
7
+ const customNodeListSource =
8
+ process.env.CUSTOM_LIST_SOURCE ||
9
+ "https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json";
10
+ const nodeList = (await fetchJson(customNodeListSource)) as {
11
+ custom_nodes: {
12
+ author: "Dr.Lt.Data" | string;
13
+ title: "ComfyUI-Manager" | string;
14
+ id: "manager" | string;
15
+ reference: "https://github.com/ltdrdata/ComfyUI-Manager" | string;
16
+ files: ["https://github.com/ltdrdata/ComfyUI-Manager"] | string[];
17
+ install_type: "git-clone" | string;
18
+ description: "ComfyUI-Manager itself is also a custom node." | string;
19
+ }[];
20
+ };
21
+ return nodeList.custom_nodes;
22
+ }
@@ -1,11 +1,11 @@
1
- import type { mockPublishedNodes } from "../mocks/mockPublishedNodes";
2
- import DIE from "@snomiao/die";
3
- import { fetchJson } from "./utils/fetchJson";
4
-
5
- export async function fetchCRNodes() {
6
- const r = (await fetchJson<typeof mockPublishedNodes>(
7
- "https://api.comfy.org/nodes?page=1&limit=99999999"
8
- )) as typeof mockPublishedNodes;
9
- r.totalPages === 1 || DIE("FAIL TO FETCH ALL NODES");
10
- return r.nodes;
11
- }
1
+ import type { mockPublishedNodes } from "../mocks/mockPublishedNodes";
2
+ import DIE from "@snomiao/die";
3
+ import { fetchJson } from "./utils/fetchJson";
4
+
5
+ export async function fetchCRNodes() {
6
+ const r = (await fetchJson<typeof mockPublishedNodes>(
7
+ "https://api.comfy.org/nodes?page=1&limit=99999999"
8
+ )) as typeof mockPublishedNodes;
9
+ r.totalPages === 1 || DIE("FAIL TO FETCH ALL NODES");
10
+ return r.nodes;
11
+ }
@@ -1,6 +1,6 @@
1
- import { fetchJson } from "./utils/fetchJson";
2
- export async function fetchCurrentGeoInfo() {
3
- const { query, city, iat, lon, countryCode, region, regionName } = (await fetchJson("http://ip-api.com/json")) as any;
4
- const geo = { ip: query, city, iat, lon, countryCode, region, regionName };
5
- return geo;
6
- }
1
+ import { fetchJson } from "./utils/fetchJson";
2
+ export async function fetchCurrentGeoInfo() {
3
+ const { query, city, iat, lon, countryCode, region, regionName } = (await fetchJson("http://ip-api.com/json")) as any;
4
+ const geo = { ip: query, city, iat, lon, countryCode, region, regionName };
5
+ return geo;
6
+ }
@@ -1,15 +1,15 @@
1
- import pMap from "p-map";
2
- import { fetchIssueComments } from "./gh/fetchIssueComments";
3
- import { matchRelatedPulls } from "./matchRelatedPulls";
4
- import type { GithubPullParsed } from "./parsePullsState";
5
- import { summaryLastPullComment } from "./summaryLastPullComment";
6
- /** @deprecated */
7
- export async function fetchRelatedPullWithComments(repository: string, pulls: GithubPullParsed[]) {
8
- const relatedPulls = await matchRelatedPulls(pulls);
9
- const relatedPullsWithComment = await pMap(relatedPulls, async (data) => {
10
- const comments = await fetchIssueComments(repository, data.pull);
11
- const lastText = summaryLastPullComment(comments);
12
- return { ...data, comments, lastText };
13
- });
14
- return relatedPullsWithComment;
15
- }
1
+ import pMap from "p-map";
2
+ import { fetchIssueComments } from "./gh/fetchIssueComments";
3
+ import { matchRelatedPulls } from "./matchRelatedPulls";
4
+ import type { GithubPullParsed } from "./parsePullsState";
5
+ import { summaryLastPullComment } from "./summaryLastPullComment";
6
+ /** @deprecated */
7
+ export async function fetchRelatedPullWithComments(repository: string, pulls: GithubPullParsed[]) {
8
+ const relatedPulls = await matchRelatedPulls(pulls);
9
+ const relatedPullsWithComment = await pMap(relatedPulls, async (data) => {
10
+ const comments = await fetchIssueComments(repository, data.pull);
11
+ const lastText = summaryLastPullComment(comments);
12
+ return { ...data, comments, lastText };
13
+ });
14
+ return relatedPullsWithComment;
15
+ }
@@ -1,15 +1,15 @@
1
- import { fromPairs } from "rambda";
2
- import { fetchCMNodes } from "./fetchCMNodes";
3
-
4
-
5
- export async function fetchRepoDescriptionMap() {
6
- const nodeList = await fetchCMNodes();
7
- const repoDescriptionMap = fromPairs(
8
- nodeList.map((e) => [e.reference, e.description])
9
- );
10
- repoDescriptionMap["https://github.com/snomiao/ComfyNode-Registry-test"] =
11
- "ComfyNode-Registry-test-description";
12
-
13
- console.log("Fetched " + nodeList.length + " CustomNode descriptions");
14
- return repoDescriptionMap;
15
- }
1
+ import { fromPairs } from "rambda";
2
+ import { fetchCMNodes } from "./fetchCMNodes";
3
+
4
+
5
+ export async function fetchRepoDescriptionMap() {
6
+ const nodeList = await fetchCMNodes();
7
+ const repoDescriptionMap = fromPairs(
8
+ nodeList.map((e) => [e.reference, e.description])
9
+ );
10
+ repoDescriptionMap["https://github.com/snomiao/ComfyNode-Registry-test"] =
11
+ "ComfyNode-Registry-test-description";
12
+
13
+ console.log("Fetched " + nodeList.length + " CustomNode descriptions");
14
+ return repoDescriptionMap;
15
+ }
@@ -1,76 +1,78 @@
1
- import { $before, $fresh, $stale } from "@/packages/mongodb-pipeline-ts/$fresh";
2
- import { tryCatch } from "rambda";
3
- import { z } from "zod";
4
-
5
- const znot_include = z.object({ "not-include": z.string() }).transform((x) => ({ $nin: x["not-include"] }));
6
- const mString = z.string().transform((x) =>
7
- tryCatch<string, string | RegExp>(
8
- (x) => new RegExp(x) as RegExp,
9
- (x) => x as string | RegExp,
10
- )(x),
11
- );
12
- const zbefore = z
13
- .object({ $before: z.coerce.date().or(z.string()).or(z.number()) })
14
- .transform((x) => $before(x.$before));
15
- const zfresh = z.object({ $fresh: z.coerce.date().or(z.string()).or(z.number()) }).transform((x) => $fresh(x.$fresh));
16
- const mstale = z.object({ $stale: z.coerce.date().or(z.string()).or(z.number()) }).transform((x) => $stale(x.$stale));
17
- const mDate = z.date().or(zbefore).or(zfresh).or(mstale);
18
- const mAny = z.number().or(znot_include).or(mString).or(zbefore).or(zfresh);
19
- const mNumber = z
20
- .number()
21
- .or(z.object({ $gt: z.number() }))
22
- .or(z.object({ $lt: z.number() }))
23
- .or(z.object({ $eq: z.number() }))
24
- .or(z.object({ $ne: z.number() }))
25
- .or(z.object({ $gte: z.number() }))
26
- .or(z.object({ $lte: z.number() }));
27
- export const zAddCommentAction = z
28
- .object({
29
- by: z.string(),
30
- body: z.string(),
31
- })
32
- .strict();
33
- const zFollowUpRule = z.object({
34
- name: z.string(),
35
- $match: z
36
- .object({
37
- actived_at: mDate,
38
- email: mString,
39
- comments: mNumber,
40
- created_at: mDate,
41
- comments_author: mString,
42
- head: mString,
43
- lastwords: mString,
44
- on_registry: z.boolean(),
45
- nickName: mString,
46
- ownername: mString,
47
- state: z.enum(["OPEN", "CLOSED", "MERGED"]),
48
- updated_at: mDate,
49
- url: mString,
50
- })
51
- .strict()
52
- .partial(),
53
- action: z
54
- .object({
55
- "add-comment": zAddCommentAction,
56
- "send-email": z
57
- .object({
58
- provider: z.string(),
59
- from: z.string(),
60
- to: z.string(),
61
- subject: z.string(),
62
- body: z.string(),
63
- })
64
- .strict(), // WARN: not implementd
65
- "update-issue": z
66
- .object({
67
- tags: mAny,
68
- })
69
- .strict(),
70
- // close: z.any(),
71
- })
72
- .strict()
73
- .partial(),
74
- });
75
- // zPullsStatus
76
- export const zFollowUpRules = zFollowUpRule.array();
1
+ import { $before, $fresh, $stale } from "@/packages/mongodb-pipeline-ts/$fresh";
2
+ import { tryCatch } from "rambda";
3
+ import { z } from "zod";
4
+
5
+ const znot_include = z.object({ "not-include": z.string() }).transform((x) => ({ $nin: x["not-include"] }));
6
+ const mString = z.string().transform((x) =>
7
+ tryCatch<string, string | RegExp>(
8
+ (x) => new RegExp(x) as RegExp,
9
+ (x) => x as string | RegExp,
10
+ )(x),
11
+ );
12
+ const zbefore = z
13
+ .object({ $before: z.coerce.date().or(z.string()).or(z.number()) })
14
+ .transform((x) => $before(x.$before));
15
+ const zfresh = z.object({ $fresh: z.coerce.date().or(z.string()).or(z.number()) }).transform((x) => $fresh(x.$fresh));
16
+ const mstale = z.object({ $stale: z.coerce.date().or(z.string()).or(z.number()) }).transform((x) => $stale(x.$stale));
17
+ const mDate = z.date().or(zbefore).or(zfresh).or(mstale);
18
+ const mAny = z.number().or(znot_include).or(mString).or(zbefore).or(zfresh);
19
+ const mNumber = z
20
+ .number()
21
+ .or(z.object({ $gt: z.number() }))
22
+ .or(z.object({ $lt: z.number() }))
23
+ .or(z.object({ $eq: z.number() }))
24
+ .or(z.object({ $ne: z.number() }))
25
+ .or(z.object({ $gte: z.number() }))
26
+ .or(z.object({ $lte: z.number() }));
27
+ export const zAddCommentAction = z
28
+ .object({
29
+ by: z.string(),
30
+ body: z.string(),
31
+ })
32
+ .strict();
33
+ export const zSendEmailAction = z
34
+ .object({
35
+ provider: z.enum(["google"]),
36
+ name: z.string(),
37
+ from: z.string(),
38
+ to: z.string(),
39
+ subject: z.string(),
40
+ body: z.string(),
41
+ })
42
+ .strict();
43
+ const zFollowUpRule = z.object({
44
+ name: z.string(),
45
+ $match: z
46
+ .object({
47
+ actived_at: mDate,
48
+ email: mString,
49
+ comments: mNumber,
50
+ created_at: mDate,
51
+ comments_author: mString,
52
+ head: mString,
53
+ lastwords: mString,
54
+ on_registry: z.boolean(),
55
+ nickName: mString,
56
+ ownername: mString,
57
+ state: z.enum(["OPEN", "CLOSED", "MERGED"]),
58
+ updated_at: mDate,
59
+ url: mString,
60
+ })
61
+ .strict()
62
+ .partial(),
63
+ action: z
64
+ .object({
65
+ "add-comment": zAddCommentAction,
66
+ "send-email": zSendEmailAction, // WARN: not implementd
67
+ "update-issue": z
68
+ .object({
69
+ tags: mAny,
70
+ })
71
+ .strict(),
72
+ // close: z.any(),
73
+ })
74
+ .strict()
75
+ .partial(),
76
+ });
77
+ // zPullsStatus
78
+ export const zFollowUpRules = zFollowUpRule.array();
@@ -1,18 +1,18 @@
1
- import { $ as zx } from "zx";
2
- import { getActivateCMD } from "./cli/getActivateCMD";
3
-
4
- if (import.meta.main) {
5
- // await checkComfyActivated();
6
- zx.verbose = true;
7
- const $ = getActivatedShell();
8
- const p = await $`comfy-cli --version`;
9
- console.log(p.stdout);
10
- // zx({ prefix: })`comfy-cli --help`;
11
- }
12
-
13
- export function getActivatedShell() {
14
- const activate = getActivateCMD();
15
- return zx({
16
- prefix: `echo Comfy CLI version: $(comfy-cli --version) || (apt-get install -y python3-venv && python -m venv .venv && ${activate} && pip install comfy-cli); `,
17
- });
18
- }
1
+ import { $ as zx } from "zx";
2
+ import { getActivateCMD } from "./cli/getActivateCMD";
3
+
4
+ if (import.meta.main) {
5
+ // await checkComfyActivated();
6
+ zx.verbose = true;
7
+ const $ = getActivatedShell();
8
+ const p = await $`comfy-cli --version`;
9
+ console.log(p.stdout);
10
+ // zx({ prefix: })`comfy-cli --help`;
11
+ }
12
+
13
+ export function getActivatedShell() {
14
+ const activate = getActivateCMD();
15
+ return zx({
16
+ prefix: `echo Comfy CLI version: $(comfy-cli --version) || (apt-get install -y python3-venv && python -m venv .venv && ${activate} && pip install comfy-cli); `,
17
+ });
18
+ }
@@ -1,16 +1,16 @@
1
- import { rm } from "fs/promises";
2
- import { getRepoWorkingDir } from "./getRepoWorkingDir";
3
- import { parseUrlRepoOwner } from "./parseOwnerRepo";
4
-
5
- export async function getBranchWorkingDir(
6
- upstreamUrl: string,
7
- forkUrl: string,
8
- branch: string
9
- ) {
10
- const src = parseUrlRepoOwner(upstreamUrl);
11
- const dir = getRepoWorkingDir(forkUrl);
12
- const packageName = src.repo;
13
- const cwd = `${dir}/${branch}/${packageName}`;
14
- await rm(cwd, { recursive: true }).catch(() => null);
15
- return cwd;
16
- }
1
+ import { rm } from "fs/promises";
2
+ import { getRepoWorkingDir } from "./getRepoWorkingDir";
3
+ import { parseUrlRepoOwner } from "./parseOwnerRepo";
4
+
5
+ export async function getBranchWorkingDir(
6
+ upstreamUrl: string,
7
+ forkUrl: string,
8
+ branch: string
9
+ ) {
10
+ const src = parseUrlRepoOwner(upstreamUrl);
11
+ const dir = getRepoWorkingDir(forkUrl);
12
+ const packageName = src.repo;
13
+ const cwd = `${dir}/${branch}/${packageName}`;
14
+ await rm(cwd, { recursive: true }).catch(() => null);
15
+ return cwd;
16
+ }
@@ -1,6 +1,6 @@
1
- import { parseUrlRepoOwner } from "./parseOwnerRepo";
2
-
3
- export function getRepoWorkingDir(forkUrl: string) {
4
- return `prs/${parseUrlRepoOwner(forkUrl).repo}`;
5
- }
1
+ import { parseUrlRepoOwner } from "./parseOwnerRepo";
2
+
3
+ export function getRepoWorkingDir(forkUrl: string) {
4
+ return `prs/${parseUrlRepoOwner(forkUrl).repo}`;
5
+ }
6
6
 
package/src/ghUser.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { gh } from "./gh";
2
-
3
- export const ghUser = (await gh.users.getAuthenticated()).data;
4
-
5
- console.log("Fetch Current Github User...");
6
- console.log(`Current Github User: ${ghUser.login} <${ghUser.email}>`);
1
+ import { gh } from "./gh";
2
+
3
+ export const ghUser = (await gh.users.getAuthenticated()).data;
4
+
5
+ console.log("Fetch Current Github User...");
6
+ console.log(`Current Github User: ${ghUser.login} <${ghUser.email}>`);
package/src/index.ts CHANGED
@@ -1,22 +1,24 @@
1
- import "dotenv/config";
2
- import { checkComfyActivated } from "./checkComfyActivated";
3
- import { initializeFollowRules } from "./initializeFollowRules";
4
- import { updateAuthors } from "./updateAuthors";
5
- import { updateCNRepos } from "./updateCNRepos";
6
- import { runFollowRuleSet } from "./updateFollowRuleSet";
7
- import { updateSlackMessages } from "./updateSlackMessages";
8
- import { tLog } from "./utils/tLog";
9
-
10
- if (import.meta.main) {
11
- await Promise.all([
12
- // try send msgs that didn't send in last run
13
- updateSlackMessages(),
14
- checkComfyActivated(), // needed if make pr
15
- updateCNRepos(),
16
- updateAuthors(),
17
- ]);
18
- await initializeFollowRules();
19
- await tLog("runFollowRuleSet", runFollowRuleSet);
20
- console.log("All done");
21
- process.exit(0);
22
- }
1
+ import "dotenv/config";
2
+ import { checkComfyActivated } from "./checkComfyActivated";
3
+ import { updateEmailTasks } from "./EmailTasks";
4
+ import { initializeFollowRules } from "./initializeFollowRules";
5
+ import { updateAuthors } from "./updateAuthors";
6
+ import { updateCNRepos } from "./updateCNRepos";
7
+ import { runFollowRuleSet } from "./updateFollowRuleSet";
8
+ import { updateSlackMessages } from "./updateSlackMessages";
9
+ import { tLog } from "./utils/tLog";
10
+
11
+ if (import.meta.main) {
12
+ await Promise.all([
13
+ // try send msgs that didn't send in last run
14
+ updateSlackMessages(),
15
+ checkComfyActivated(), // needed if make pr
16
+ updateCNRepos(),
17
+ updateAuthors(),
18
+ updateEmailTasks(),
19
+ ]);
20
+ await initializeFollowRules();
21
+ await tLog("runFollowRuleSet", runFollowRuleSet);
22
+ console.log("All done");
23
+ process.exit(0);
24
+ }
@@ -1,26 +1,26 @@
1
- import DIE from "@snomiao/die";
2
- import { readFile } from "fs/promises";
3
- import { FollowRuleSets } from "./FollowRules";
4
-
5
- if (import.meta.main) {
6
- const followRules = await initializeFollowRules();
7
- const ruleset = (await FollowRuleSets.findOne({ name: "default" })) ?? DIE("default ruleset not found");
8
- if (!ruleset?.enabled) DIE("default ruleset not enabled");
9
-
10
- console.log("initialized follow rules");
11
- }
12
- /**
13
- *
14
- * @author: snomiao <snomiao@gmail.com>
15
- */
16
- export async function initializeFollowRules() {
17
- return await updateFollowRules("default", await readFile("./templates/follow-rules.yaml", "utf8"));
18
- }
19
-
20
- export async function updateFollowRules(name: string, rawRuleYaml: string) {
21
- return (await FollowRuleSets.findOneAndUpdate(
22
- { name },
23
- { $setOnInsert: { yaml: rawRuleYaml, enabled: false } },
24
- { upsert: true, returnDocument: "after" },
25
- ))!;
26
- }
1
+ import DIE from "@snomiao/die";
2
+ import { readFile } from "fs/promises";
3
+ import { FollowRuleSets } from "./FollowRules";
4
+
5
+ if (import.meta.main) {
6
+ const followRules = await initializeFollowRules();
7
+ const ruleset = (await FollowRuleSets.findOne({ name: "default" })) ?? DIE("default ruleset not found");
8
+ if (!ruleset?.enabled) DIE("default ruleset not enabled");
9
+
10
+ console.log("initialized follow rules");
11
+ }
12
+ /**
13
+ *
14
+ * @author: snomiao <snomiao@gmail.com>
15
+ */
16
+ export async function initializeFollowRules() {
17
+ return await updateFollowRules("default", await readFile("./templates/follow-rules.yaml", "utf8"));
18
+ }
19
+
20
+ export async function updateFollowRules(name: string, rawRuleYaml: string) {
21
+ return (await FollowRuleSets.findOneAndUpdate(
22
+ { name },
23
+ { $setOnInsert: { yaml: rawRuleYaml, enabled: false } },
24
+ { upsert: true, returnDocument: "after" },
25
+ ))!;
26
+ }