comfy-pr 0.2.24 → 0.2.26

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 (85) hide show
  1. package/README.md +247 -225
  2. package/index.ts +6 -0
  3. package/next-env.d.ts +5 -5
  4. package/package.json +52 -25
  5. package/src/Authors.ts +42 -48
  6. package/src/CMNodes.ts +60 -60
  7. package/src/CNRepos.ts +78 -74
  8. package/src/CRNodes.ts +27 -27
  9. package/src/CRPulls.ts +4 -4
  10. package/src/EmailTasks.ts +101 -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 +219 -170
  23. package/src/analyzeTotals.test.ts +5 -5
  24. package/src/analyzeTotals.ts +118 -118
  25. package/src/bypassRepos.spec.ts +10 -0
  26. package/src/bypassRepos.ts +8 -0
  27. package/src/checkComfyActivated.ts +39 -39
  28. package/src/checkPRsFailures.ts +18 -0
  29. package/src/cli.ts +40 -40
  30. package/src/clone_modify_push_Branches.ts +21 -21
  31. package/src/createComfyRegistryPRsFromCandidates.ts +55 -55
  32. package/src/createComfyRegistryPullRequests.ts +32 -22
  33. package/src/createGithubForkForRepo.ts +54 -37
  34. package/src/createGithubPullRequest.ts +157 -94
  35. package/src/createIssueComment.ts +34 -29
  36. package/src/fetchCMNodes.ts +22 -22
  37. package/src/fetchComfyRegistryNodes.ts +11 -11
  38. package/src/fetchCurrentGeoInfo.ts +6 -6
  39. package/src/fetchRelatedPullWithComments.ts +15 -15
  40. package/src/fetchRepoDescriptionMap.ts +15 -15
  41. package/src/followRuleSchema.ts +79 -76
  42. package/src/getActivatedShell.ts +18 -18
  43. package/src/getBranchWorkingDir.ts +16 -16
  44. package/src/getRepoWorkingDir.ts +5 -5
  45. package/src/ghUser.ts +9 -6
  46. package/src/index.ts +26 -22
  47. package/src/initializeFollowRules.ts +26 -26
  48. package/src/makePublishBranch.ts +58 -58
  49. package/src/makeTomlBranch.ts +53 -53
  50. package/src/makeUpdateTomlLicenseBranch.ts +245 -0
  51. package/src/matchRelatedPulls.ts +47 -60
  52. package/src/muteInstances.ts +16 -16
  53. package/src/parseIssueUrl.ts +6 -6
  54. package/src/parseOwnerRepo.ts +33 -33
  55. package/src/parsePullUrl.ts +6 -6
  56. package/src/parsePullsState.ts +6 -6
  57. package/src/parseTitleBodyOfMarkdown.ts +8 -8
  58. package/src/postSlackMessage.ts +21 -21
  59. package/src/preload.ts +30 -30
  60. package/src/pullStatusFollowSchema.ts +12 -12
  61. package/src/readTemplateTitle.ts +11 -11
  62. package/src/sendEmailAction.ts +56 -0
  63. package/src/sendGmail.ts +105 -0
  64. package/src/showFollowRuleSet.ts +12 -12
  65. package/src/summaryLastPullComment.ts +8 -8
  66. package/src/tomlFillDescription.ts +17 -17
  67. package/src/updateAuthors.ts +7 -7
  68. package/src/updateAuthorsForGithub.ts +54 -50
  69. package/src/updateAuthorsFromCNRepo.ts +30 -30
  70. package/src/updateCMNodesDuplicationWarnings.ts +56 -56
  71. package/src/updateCMRepos.ts +27 -27
  72. package/src/updateCNRepos.ts +58 -58
  73. package/src/updateCNReposCRPullsComments.ts +40 -40
  74. package/src/updateCNReposInfo.ts +58 -57
  75. package/src/updateCNReposPRCandidate.ts +85 -85
  76. package/src/updateCNReposPulls.ts +31 -28
  77. package/src/updateCNReposPullsDashboard.ts +49 -49
  78. package/src/updateCNReposRelatedPulls.ts +25 -25
  79. package/src/updateCRNodes.ts +50 -50
  80. package/src/updateCRRepos.ts +26 -26
  81. package/src/updateComfyTotals.ts +43 -43
  82. package/src/updateFollowRuleSet.ts +136 -127
  83. package/src/updateOutdatedPullsTemplates.ts +165 -160
  84. package/src/updateSlackMessages.ts +43 -43
  85. package/tailwind.config.ts +75 -20
@@ -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,9 @@
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 type { Task } from "@/packages/mongodb-pipeline-ts/Task";
2
+ import { gh } from "./gh";
3
+ import type { AwaitedReturnType } from "./types/AwaitedReturnType";
4
+
5
+ export const ghUser = (await gh.users.getAuthenticated()).data;
6
+
7
+ console.log("Fetch Current Github User...");
8
+ console.log(`Current Github User: ${ghUser.login} <${ghUser.email}>`);
9
+ export type GHUser = Task<AwaitedReturnType<typeof gh.users.getByUsername>["data"]>;
package/src/index.ts CHANGED
@@ -1,22 +1,26 @@
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 { updateTomlLicenseTasks } from "./makeUpdateTomlLicenseBranch";
6
+ import { updateAuthors } from "./updateAuthors";
7
+ import { updateCNRepos } from "./updateCNRepos";
8
+ import { runFollowRuleSet } from "./updateFollowRuleSet";
9
+ import { updateSlackMessages } from "./updateSlackMessages";
10
+ import { tLog } from "./utils/tLog";
11
+
12
+ if (import.meta.main) {
13
+ await Promise.all([
14
+ // try send msgs that didn't send in last run
15
+ updateSlackMessages(),
16
+ checkComfyActivated(), // needed if make pr
17
+ updateCNRepos(),
18
+ updateAuthors(),
19
+ updateEmailTasks(),
20
+ updateTomlLicenseTasks(),
21
+ ]);
22
+ await initializeFollowRules();
23
+ await tLog("runFollowRuleSet", runFollowRuleSet);
24
+ console.log("All done");
25
+ process.exit(0);
26
+ }
@@ -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
+ }
@@ -1,58 +1,58 @@
1
- import { readFile } from "fs/promises";
2
- import { dirname } from "path";
3
- import { GIT_USEREMAIL } from "./GIT_USEREMAIL";
4
- import { GIT_USERNAME } from "./GIT_USERNAME";
5
- import { $ } from "./cli/echoBunShell";
6
- import { getBranchWorkingDir } from "./getBranchWorkingDir";
7
- import { gh } from "./gh";
8
- import { parseUrlRepoOwner, stringifyGithubOrigin, stringifyGithubRepoUrl } from "./parseOwnerRepo";
9
- import { parseTitleBodyOfMarkdown } from "./parseTitleBodyOfMarkdown";
10
-
11
- /**
12
- * Clone from upstream
13
- * push to fork url
14
- * @param dir
15
- * @param upstreamUrl
16
- * @param origin
17
- * @returns
18
- */
19
- export async function makePublishcrBranch(upstreamUrl: string, forkUrl: Readonly<string>) {
20
- const type = "publishcr" as const;
21
-
22
- const origin = await stringifyGithubOrigin(parseUrlRepoOwner(forkUrl));
23
- const branch = "publish";
24
- const tmpl = await readFile("./templates/add-action.md", "utf8");
25
- const { title, body } = parseTitleBodyOfMarkdown(tmpl);
26
- const repo = parseUrlRepoOwner(origin);
27
-
28
- if (await gh.repos.getBranch({ ...repo, branch }).catch(() => null)) {
29
- console.log("Skip changes as branch existed: " + branch);
30
- return { type, title, body, branch };
31
- }
32
-
33
- const cwd = await getBranchWorkingDir(upstreamUrl, forkUrl, branch);
34
-
35
- const file = `${cwd}/.github/workflows/publish.yml`;
36
- const publishYmlPath = "./templates/publish.yaml";
37
-
38
- // commit & push changes
39
- await $`
40
- git clone ${upstreamUrl} ${cwd}
41
-
42
- mkdir -p ${dirname(file)}
43
- cat ${publishYmlPath} > ${file}
44
-
45
- cd ${cwd}
46
-
47
- git config user.name ${GIT_USERNAME} && \
48
- git config user.email ${GIT_USEREMAIL} && \
49
- git checkout -b ${branch} && \
50
- git add . && \
51
- git commit -am "chore(${branch}): ${title}" && \
52
- git push "${origin}" ${branch}:${branch}
53
- `;
54
-
55
- const branchUrl = `${stringifyGithubRepoUrl(repo)}/tree/${branch}`;
56
- console.log(`Branch Push OK: ${branchUrl}`);
57
- return { type, title, body, branch };
58
- }
1
+ import { readFile } from "fs/promises";
2
+ import { dirname } from "path";
3
+ import { GIT_USEREMAIL } from "./GIT_USEREMAIL";
4
+ import { GIT_USERNAME } from "./GIT_USERNAME";
5
+ import { $ } from "./cli/echoBunShell";
6
+ import { getBranchWorkingDir } from "./getBranchWorkingDir";
7
+ import { gh } from "./gh";
8
+ import { parseUrlRepoOwner, stringifyGithubOrigin, stringifyGithubRepoUrl } from "./parseOwnerRepo";
9
+ import { parseTitleBodyOfMarkdown } from "./parseTitleBodyOfMarkdown";
10
+
11
+ /**
12
+ * Clone from upstream
13
+ * push to fork url
14
+ * @param dir
15
+ * @param upstreamUrl
16
+ * @param origin
17
+ * @returns
18
+ */
19
+ export async function makePublishcrBranch(upstreamUrl: string, forkUrl: Readonly<string>) {
20
+ const type = "publishcr" as const;
21
+
22
+ const origin = await stringifyGithubOrigin(parseUrlRepoOwner(forkUrl));
23
+ const branch = "publish";
24
+ const tmpl = await readFile("./templates/add-action.md", "utf8");
25
+ const { title, body } = parseTitleBodyOfMarkdown(tmpl);
26
+ const repo = parseUrlRepoOwner(origin);
27
+
28
+ if (await gh.repos.getBranch({ ...repo, branch }).catch(() => null)) {
29
+ console.log("Skip changes as branch existed: " + branch);
30
+ return { type, title, body, branch };
31
+ }
32
+
33
+ const cwd = await getBranchWorkingDir(upstreamUrl, forkUrl, branch);
34
+
35
+ const file = `${cwd}/.github/workflows/publish.yml`;
36
+ const publishYmlPath = "./templates/publish.yaml";
37
+
38
+ // commit & push changes
39
+ await $`
40
+ git clone ${upstreamUrl} ${cwd}
41
+
42
+ mkdir -p ${dirname(file)}
43
+ cat ${publishYmlPath} > ${file}
44
+
45
+ cd ${cwd}
46
+
47
+ git config user.name ${GIT_USERNAME} && \
48
+ git config user.email ${GIT_USEREMAIL} && \
49
+ git checkout -b ${branch} && \
50
+ git add . && \
51
+ git commit -am "chore(${branch}): ${title}" && \
52
+ git push "${origin}" ${branch}:${branch}
53
+ `;
54
+
55
+ const branchUrl = `${stringifyGithubRepoUrl(repo)}/tree/${branch}`;
56
+ console.log(`Branch Push OK: ${branchUrl}`);
57
+ return { type, title, body, branch };
58
+ }
@@ -1,53 +1,53 @@
1
- import { readFile } from "fs/promises";
2
- import { GIT_USEREMAIL } from "./GIT_USEREMAIL";
3
- import { GIT_USERNAME } from "./GIT_USERNAME";
4
- import { $ } from "./cli/echoBunShell";
5
- import { getBranchWorkingDir } from "./getBranchWorkingDir";
6
- import { gh } from "./gh";
7
- import { parseUrlRepoOwner, stringifyGithubOrigin } from "./parseOwnerRepo";
8
- import { parseTitleBodyOfMarkdown } from "./parseTitleBodyOfMarkdown";
9
- import { tomlFillDescription } from "./tomlFillDescription";
10
-
11
- export async function makePyprojectBranch(upstreamUrl: string, forkUrl: string) {
12
- const type = "pyproject" as const;
13
- const origin = await stringifyGithubOrigin(parseUrlRepoOwner(forkUrl));
14
- const branch = "pyproject";
15
- const tmpl = await readFile("./templates/add-toml.md", "utf8");
16
- const { title, body } = parseTitleBodyOfMarkdown(tmpl);
17
- const repo = parseUrlRepoOwner(forkUrl);
18
-
19
- if (await gh.repos.getBranch({ ...repo, branch }).catch(() => null)) {
20
- console.log("Skip changes as branch existed: " + branch);
21
- return { type, title, body, branch };
22
- }
23
- const src = parseUrlRepoOwner(upstreamUrl);
24
- const cwd = await getBranchWorkingDir(upstreamUrl, forkUrl, branch);
25
-
26
- // commit changes
27
- await $`
28
- git clone ${upstreamUrl} ${cwd}
29
-
30
- cd ${cwd}
31
- echo N | comfy node init
32
- `;
33
-
34
- // Try fill description from ComfyUI-manager
35
- const referenceUrl = `https://github.com/${src.owner}/${src.repo}`;
36
- const pyprojectToml = cwd + "/pyproject.toml";
37
- await tomlFillDescription(referenceUrl, pyprojectToml).catch((e) => {
38
- console.error(e);
39
- });
40
-
41
- await $`
42
- cd ${cwd}
43
- git config user.name ${GIT_USERNAME} && \
44
- git config user.email ${GIT_USEREMAIL} && \
45
- git checkout -b ${branch} && \
46
- git add . && \
47
- git commit -am ${`chore(${branch}): ${title}`} && \
48
- git push "${origin}" ${branch}:${branch}
49
- `;
50
- const branchUrl = `https://github.com/${repo.owner}/${repo.repo}/tree/${branch}`;
51
- console.log(`Branch Push OK: ${branchUrl}`);
52
- return { type, title, body, branch };
53
- }
1
+ import { readFile } from "fs/promises";
2
+ import { GIT_USEREMAIL } from "./GIT_USEREMAIL";
3
+ import { GIT_USERNAME } from "./GIT_USERNAME";
4
+ import { $ } from "./cli/echoBunShell";
5
+ import { getBranchWorkingDir } from "./getBranchWorkingDir";
6
+ import { gh } from "./gh";
7
+ import { parseUrlRepoOwner, stringifyGithubOrigin } from "./parseOwnerRepo";
8
+ import { parseTitleBodyOfMarkdown } from "./parseTitleBodyOfMarkdown";
9
+ import { tomlFillDescription } from "./tomlFillDescription";
10
+
11
+ export async function makePyprojectBranch(upstreamUrl: string, forkUrl: string) {
12
+ const type = "pyproject" as const;
13
+ const origin = await stringifyGithubOrigin(parseUrlRepoOwner(forkUrl));
14
+ const branch = "pyproject";
15
+ const tmpl = await readFile("./templates/add-toml.md", "utf8");
16
+ const { title, body } = parseTitleBodyOfMarkdown(tmpl);
17
+ const repo = parseUrlRepoOwner(forkUrl);
18
+
19
+ if (await gh.repos.getBranch({ ...repo, branch }).catch(() => null)) {
20
+ console.log("Skip changes as branch existed: " + branch);
21
+ return { type, title, body, branch };
22
+ }
23
+ const src = parseUrlRepoOwner(upstreamUrl);
24
+ const cwd = await getBranchWorkingDir(upstreamUrl, forkUrl, branch);
25
+
26
+ // commit changes
27
+ await $`
28
+ git clone ${upstreamUrl} ${cwd}
29
+
30
+ cd ${cwd}
31
+ echo N | comfy node init
32
+ `;
33
+
34
+ // Try fill description from ComfyUI-manager
35
+ const referenceUrl = `https://github.com/${src.owner}/${src.repo}`;
36
+ const pyprojectToml = cwd + "/pyproject.toml";
37
+ await tomlFillDescription(referenceUrl, pyprojectToml).catch((e) => {
38
+ console.error(e);
39
+ });
40
+
41
+ await $`
42
+ cd ${cwd}
43
+ git config user.name ${GIT_USERNAME} && \
44
+ git config user.email ${GIT_USEREMAIL} && \
45
+ git checkout -b ${branch} && \
46
+ git add . && \
47
+ git commit -am ${`chore(${branch}): ${title}`} && \
48
+ git push "${origin}" ${branch}:${branch}
49
+ `;
50
+ const branchUrl = `https://github.com/${repo.owner}/${repo.repo}/tree/${branch}`;
51
+ console.log(`Branch Push OK: ${branchUrl}`);
52
+ return { type, title, body, branch };
53
+ }