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.
- package/README.md +247 -225
- package/index.ts +6 -0
- package/next-env.d.ts +5 -5
- package/package.json +52 -25
- package/src/Authors.ts +42 -48
- package/src/CMNodes.ts +60 -60
- package/src/CNRepos.ts +78 -74
- package/src/CRNodes.ts +27 -27
- package/src/CRPulls.ts +4 -4
- package/src/EmailTasks.ts +101 -0
- package/src/FORK_OWNER.ts +5 -5
- package/src/FORK_PREFIX.ts +5 -5
- package/src/FollowRules.ts +25 -25
- package/src/GIT_USEREMAIL.ts +5 -5
- package/src/GIT_USERNAME.ts +9 -9
- package/src/GithubIssueComments.ts +3 -3
- package/src/PushedBranch.ts +3 -3
- package/src/Totals.ts +24 -9
- package/src/TrackingPRs.ts +12 -12
- package/src/WorkerInstances.ts +89 -89
- package/src/addCommentAction.ts +73 -65
- package/src/analyzePullsStatus.ts +219 -170
- package/src/analyzeTotals.test.ts +5 -5
- package/src/analyzeTotals.ts +118 -118
- package/src/bypassRepos.spec.ts +10 -0
- package/src/bypassRepos.ts +8 -0
- package/src/checkComfyActivated.ts +39 -39
- package/src/checkPRsFailures.ts +18 -0
- package/src/cli.ts +40 -40
- package/src/clone_modify_push_Branches.ts +21 -21
- package/src/createComfyRegistryPRsFromCandidates.ts +55 -55
- package/src/createComfyRegistryPullRequests.ts +32 -22
- package/src/createGithubForkForRepo.ts +54 -37
- package/src/createGithubPullRequest.ts +157 -94
- package/src/createIssueComment.ts +34 -29
- package/src/fetchCMNodes.ts +22 -22
- package/src/fetchComfyRegistryNodes.ts +11 -11
- package/src/fetchCurrentGeoInfo.ts +6 -6
- package/src/fetchRelatedPullWithComments.ts +15 -15
- package/src/fetchRepoDescriptionMap.ts +15 -15
- package/src/followRuleSchema.ts +79 -76
- package/src/getActivatedShell.ts +18 -18
- package/src/getBranchWorkingDir.ts +16 -16
- package/src/getRepoWorkingDir.ts +5 -5
- package/src/ghUser.ts +9 -6
- package/src/index.ts +26 -22
- package/src/initializeFollowRules.ts +26 -26
- package/src/makePublishBranch.ts +58 -58
- package/src/makeTomlBranch.ts +53 -53
- package/src/makeUpdateTomlLicenseBranch.ts +245 -0
- package/src/matchRelatedPulls.ts +47 -60
- package/src/muteInstances.ts +16 -16
- package/src/parseIssueUrl.ts +6 -6
- package/src/parseOwnerRepo.ts +33 -33
- package/src/parsePullUrl.ts +6 -6
- package/src/parsePullsState.ts +6 -6
- package/src/parseTitleBodyOfMarkdown.ts +8 -8
- package/src/postSlackMessage.ts +21 -21
- package/src/preload.ts +30 -30
- package/src/pullStatusFollowSchema.ts +12 -12
- package/src/readTemplateTitle.ts +11 -11
- package/src/sendEmailAction.ts +56 -0
- package/src/sendGmail.ts +105 -0
- package/src/showFollowRuleSet.ts +12 -12
- package/src/summaryLastPullComment.ts +8 -8
- package/src/tomlFillDescription.ts +17 -17
- package/src/updateAuthors.ts +7 -7
- package/src/updateAuthorsForGithub.ts +54 -50
- package/src/updateAuthorsFromCNRepo.ts +30 -30
- package/src/updateCMNodesDuplicationWarnings.ts +56 -56
- package/src/updateCMRepos.ts +27 -27
- package/src/updateCNRepos.ts +58 -58
- package/src/updateCNReposCRPullsComments.ts +40 -40
- package/src/updateCNReposInfo.ts +58 -57
- package/src/updateCNReposPRCandidate.ts +85 -85
- package/src/updateCNReposPulls.ts +31 -28
- package/src/updateCNReposPullsDashboard.ts +49 -49
- package/src/updateCNReposRelatedPulls.ts +25 -25
- package/src/updateCRNodes.ts +50 -50
- package/src/updateCRRepos.ts +26 -26
- package/src/updateComfyTotals.ts +43 -43
- package/src/updateFollowRuleSet.ts +136 -127
- package/src/updateOutdatedPullsTemplates.ts +165 -160
- package/src/updateSlackMessages.ts +43 -43
- package/tailwind.config.ts +75 -20
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isRepoBypassed } from "./bypassRepos";
|
|
2
|
+
|
|
3
|
+
it("bypass", async () => {
|
|
4
|
+
const bypassRepo = "https://github.com/loopyd/ComfyUI-FD-Tagger";
|
|
5
|
+
expect(isRepoBypassed(bypassRepo)).toBeTruthy();
|
|
6
|
+
});
|
|
7
|
+
it("allow", async () => {
|
|
8
|
+
const allowRepo = "https://github.com/snomiao/ComfyUI-FD-Tagger";
|
|
9
|
+
expect(isRepoBypassed(allowRepo)).toBeFalsy();
|
|
10
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { yaml } from "./utils/yaml";
|
|
3
|
+
|
|
4
|
+
export const bypassRepos = z
|
|
5
|
+
.string()
|
|
6
|
+
.array()
|
|
7
|
+
.parse(yaml.parse(await Bun.file("./bypass.yaml").text()).bypass_repos);
|
|
8
|
+
export const isRepoBypassed = (repo: string) => bypassRepos.some((reg) => repo.match(reg));
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import DIE from "@snomiao/die";
|
|
2
|
-
import { $ as bunSh } from "bun";
|
|
3
|
-
import { os } from "zx";
|
|
4
|
-
import { getActivateCMD } from "./cli/getActivateCMD";
|
|
5
|
-
|
|
6
|
-
export async function checkComfyActivated() {
|
|
7
|
-
console.log("Checking ComfyUI Activated...");
|
|
8
|
-
|
|
9
|
-
if (!(await bunSh`comfy --help`.quiet().catch(() => null))) {
|
|
10
|
-
const activate = getActivateCMD();
|
|
11
|
-
// apt-get install -y python3 python3-venv
|
|
12
|
-
const installPython =
|
|
13
|
-
os.platform() === "win32"
|
|
14
|
-
? "python3 --version || winget install python3 || choco install -y python3"
|
|
15
|
-
: "apt-get install -y python3 python3-venv";
|
|
16
|
-
|
|
17
|
-
await bunSh`
|
|
18
|
-
${installPython}
|
|
19
|
-
python -m venv .venv
|
|
20
|
-
${activate}
|
|
21
|
-
pip install comfy-cli
|
|
22
|
-
comfy-cli --help
|
|
23
|
-
`.catch(console.error);
|
|
24
|
-
|
|
25
|
-
DIE(
|
|
26
|
-
`
|
|
27
|
-
Cound not found comfy-cli.
|
|
28
|
-
Please install comfy-cli before run "bunx comfy-pr" here.
|
|
29
|
-
|
|
30
|
-
$ >>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
31
|
-
${installPython}
|
|
32
|
-
python -m venv .venv
|
|
33
|
-
${activate}
|
|
34
|
-
pip install comfy-cli
|
|
35
|
-
comfy-cli --help
|
|
36
|
-
`.trim(),
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
import DIE from "@snomiao/die";
|
|
2
|
+
import { $ as bunSh } from "bun";
|
|
3
|
+
import { os } from "zx";
|
|
4
|
+
import { getActivateCMD } from "./cli/getActivateCMD";
|
|
5
|
+
|
|
6
|
+
export async function checkComfyActivated() {
|
|
7
|
+
console.log("Checking ComfyUI Activated...");
|
|
8
|
+
|
|
9
|
+
if (!(await bunSh`comfy --help`.quiet().catch(() => null))) {
|
|
10
|
+
const activate = getActivateCMD();
|
|
11
|
+
// apt-get install -y python3 python3-venv
|
|
12
|
+
const installPython =
|
|
13
|
+
os.platform() === "win32"
|
|
14
|
+
? "python3 --version || winget install python3 || choco install -y python3"
|
|
15
|
+
: "apt-get install -y python3 python3-venv";
|
|
16
|
+
|
|
17
|
+
await bunSh`
|
|
18
|
+
${installPython}
|
|
19
|
+
python -m venv .venv
|
|
20
|
+
${activate}
|
|
21
|
+
pip install comfy-cli
|
|
22
|
+
comfy-cli --help
|
|
23
|
+
`.catch(console.error);
|
|
24
|
+
|
|
25
|
+
DIE(
|
|
26
|
+
`
|
|
27
|
+
Cound not found comfy-cli.
|
|
28
|
+
Please install comfy-cli before run "bunx comfy-pr" here.
|
|
29
|
+
|
|
30
|
+
$ >>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
31
|
+
${installPython}
|
|
32
|
+
python -m venv .venv
|
|
33
|
+
${activate}
|
|
34
|
+
pip install comfy-cli
|
|
35
|
+
comfy-cli --help
|
|
36
|
+
`.trim(),
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { $pipeline } from "@/packages/mongodb-pipeline-ts/$pipeline";
|
|
2
|
+
import { csvFormatBody } from "d3";
|
|
3
|
+
import sflow from "sflow";
|
|
4
|
+
import { CNRepos } from "./CNRepos";
|
|
5
|
+
|
|
6
|
+
if (import.meta.main) {
|
|
7
|
+
const pipeline = $pipeline(CNRepos)
|
|
8
|
+
.match({ "createdPulls.state": "error" })
|
|
9
|
+
.set({ error: "$createdPulls.error" })
|
|
10
|
+
.project({ _id: 0, repository: 1, error: 1 })
|
|
11
|
+
.as<{ repository: string; error: string }>()
|
|
12
|
+
.aggregate();
|
|
13
|
+
const csv = await sflow(pipeline)
|
|
14
|
+
.map((e, i) => ((!i && "repository,error\n") || "") + csvFormatBody([e]) + "\n")
|
|
15
|
+
.log()
|
|
16
|
+
.text();
|
|
17
|
+
await Bun.write(".cache/pr-errors.csv", csv);
|
|
18
|
+
}
|
package/src/cli.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
#!bun
|
|
2
|
-
import DIE from "@snomiao/die";
|
|
3
|
-
import { readFile } from "fs/promises";
|
|
4
|
-
import { argv, $ as zx } from "zx";
|
|
5
|
-
import { checkComfyActivated } from "./checkComfyActivated";
|
|
6
|
-
import { createComfyRegistryPullRequests } from "./createComfyRegistryPullRequests";
|
|
7
|
-
zx.verbose = true;
|
|
8
|
-
|
|
9
|
-
if (argv.help) {
|
|
10
|
-
console.log(
|
|
11
|
-
`
|
|
12
|
-
bunx comfy-pr --repolist repos.txt one repo per-line
|
|
13
|
-
bunx comfy-pr [...GITHUB_REPO_URLS] github repos
|
|
14
|
-
bunx cross-env REPO=https://github.com/OWNER/REPO bunx comfy-pr
|
|
15
|
-
`.trim(),
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
{
|
|
20
|
-
await checkComfyActivated();
|
|
21
|
-
|
|
22
|
-
const envRepos =
|
|
23
|
-
process.env.REPO?.split("\n")
|
|
24
|
-
.map((e) => e.trim())
|
|
25
|
-
.filter(Boolean) || [];
|
|
26
|
-
const argvRepos = argv._.filter((a) => !a.endsWith(import.meta.filename));
|
|
27
|
-
const listRepos =
|
|
28
|
-
(argv.repolist &&
|
|
29
|
-
(await readFile(argv.repolist, "utf8").catch(() => ""))
|
|
30
|
-
.split("\n")
|
|
31
|
-
.map((e) => e.trim())
|
|
32
|
-
.filter(Boolean)) ||
|
|
33
|
-
[];
|
|
34
|
-
const repos = (listRepos.length && listRepos) ||
|
|
35
|
-
(argvRepos.length && argvRepos) ||
|
|
36
|
-
(envRepos.length && envRepos) || [DIE("Missing PR target, please set env.REPO")];
|
|
37
|
-
for await (const upstreamUrl of repos) {
|
|
38
|
-
await createComfyRegistryPullRequests(upstreamUrl);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
#!bun
|
|
2
|
+
import DIE from "@snomiao/die";
|
|
3
|
+
import { readFile } from "fs/promises";
|
|
4
|
+
import { argv, $ as zx } from "zx";
|
|
5
|
+
import { checkComfyActivated } from "./checkComfyActivated";
|
|
6
|
+
import { createComfyRegistryPullRequests } from "./createComfyRegistryPullRequests";
|
|
7
|
+
zx.verbose = true;
|
|
8
|
+
|
|
9
|
+
if (argv.help) {
|
|
10
|
+
console.log(
|
|
11
|
+
`
|
|
12
|
+
bunx comfy-pr --repolist repos.txt one repo per-line
|
|
13
|
+
bunx comfy-pr [...GITHUB_REPO_URLS] github repos
|
|
14
|
+
bunx cross-env REPO=https://github.com/OWNER/REPO bunx comfy-pr
|
|
15
|
+
`.trim(),
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
await checkComfyActivated();
|
|
21
|
+
|
|
22
|
+
const envRepos =
|
|
23
|
+
process.env.REPO?.split("\n")
|
|
24
|
+
.map((e) => e.trim())
|
|
25
|
+
.filter(Boolean) || [];
|
|
26
|
+
const argvRepos = argv._.filter((a) => !a.endsWith(import.meta.filename));
|
|
27
|
+
const listRepos =
|
|
28
|
+
(argv.repolist &&
|
|
29
|
+
(await readFile(argv.repolist, "utf8").catch(() => ""))
|
|
30
|
+
.split("\n")
|
|
31
|
+
.map((e) => e.trim())
|
|
32
|
+
.filter(Boolean)) ||
|
|
33
|
+
[];
|
|
34
|
+
const repos = (listRepos.length && listRepos) ||
|
|
35
|
+
(argvRepos.length && argvRepos) ||
|
|
36
|
+
(envRepos.length && envRepos) || [DIE("Missing PR target, please set env.REPO")];
|
|
37
|
+
for await (const upstreamUrl of repos) {
|
|
38
|
+
await createComfyRegistryPullRequests(upstreamUrl);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { makePublishcrBranch } from "./makePublishBranch";
|
|
2
|
-
import { makePyprojectBranch } from "./makeTomlBranch";
|
|
3
|
-
|
|
4
|
-
export async function clone_modify_push_Branches(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
])
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
1
|
+
import { makePublishcrBranch } from "./makePublishBranch";
|
|
2
|
+
import { makePyprojectBranch } from "./makeTomlBranch";
|
|
3
|
+
|
|
4
|
+
export async function clone_modify_push_Branches(upstreamUrl: string, forkUrl: string) {
|
|
5
|
+
return (
|
|
6
|
+
await Promise.all([
|
|
7
|
+
makePyprojectBranch(upstreamUrl, forkUrl),
|
|
8
|
+
makePublishcrBranch(upstreamUrl, forkUrl),
|
|
9
|
+
// makeLicenseUpdateBranch(upstreamUrl, forkUrl),
|
|
10
|
+
])
|
|
11
|
+
)
|
|
12
|
+
.flatMap((e) => (e ? [e] : []))
|
|
13
|
+
.map(({ body, branch, title, type }) => ({
|
|
14
|
+
body,
|
|
15
|
+
branch,
|
|
16
|
+
title,
|
|
17
|
+
type,
|
|
18
|
+
srcUrl: forkUrl,
|
|
19
|
+
dstUrl: upstreamUrl,
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { $pipeline } from "@/packages/mongodb-pipeline-ts/$pipeline";
|
|
2
|
-
import pMap from "p-map";
|
|
3
|
-
import { match } from "ts-pattern";
|
|
4
|
-
import { $OK, TaskError, TaskOK } from "../packages/mongodb-pipeline-ts/Task";
|
|
5
|
-
import { CNRepos } from "./CNRepos";
|
|
6
|
-
import { createComfyRegistryPullRequests } from "./createComfyRegistryPullRequests";
|
|
7
|
-
import { $filaten, $stale } from "./db";
|
|
8
|
-
import { parseUrlRepoOwner, stringifyOwnerRepo } from "./parseOwnerRepo";
|
|
9
|
-
import { notifySlackLinks } from "./slack/notifySlackLinks";
|
|
10
|
-
import { tLog } from "./utils/tLog";
|
|
11
|
-
if (import.meta.main) {
|
|
12
|
-
await tLog("createComfyRegistryPRsFromCandidates", createComfyRegistryPRsFromCandidates);
|
|
13
|
-
console.log("all done");
|
|
14
|
-
}
|
|
15
|
-
export async function createComfyRegistryPRsFromCandidates() {
|
|
16
|
-
await CNRepos.createIndex($filaten({ candidate: { data: 1 } }));
|
|
17
|
-
await CNRepos.createIndex(
|
|
18
|
-
$filaten({
|
|
19
|
-
candidate: { data: 1 },
|
|
20
|
-
createdPulls: { state: 1, mtime: 1 },
|
|
21
|
-
}),
|
|
22
|
-
);
|
|
23
|
-
return await pMap(
|
|
24
|
-
$pipeline(CNRepos)
|
|
25
|
-
.match(
|
|
26
|
-
$filaten({
|
|
27
|
-
candidate: { data: { $eq: true } },
|
|
28
|
-
createdPulls: { state: { $ne: "ok" }, mtime: $stale("5m") },
|
|
29
|
-
}),
|
|
30
|
-
)
|
|
31
|
-
.aggregate(),
|
|
32
|
-
async (repo) => {
|
|
33
|
-
const { repository } = repo;
|
|
34
|
-
console.log("Making PRs for " + repository);
|
|
35
|
-
const createdPulls = await createComfyRegistryPullRequests(repository).then(TaskOK).catch(TaskError);
|
|
36
|
-
match(createdPulls).with($OK, async ({ data }) => {
|
|
37
|
-
const links = data.map((e) => ({
|
|
38
|
-
href: e.html_url,
|
|
39
|
-
name: stringifyOwnerRepo(parseUrlRepoOwner(e.html_url.replace(/\/pull\/.*$/, ""))) + " #" + e.title,
|
|
40
|
-
}));
|
|
41
|
-
await notifySlackLinks("PR just Created, @HaoHao check plz", links);
|
|
42
|
-
await pMap(data, async (pull) => {
|
|
43
|
-
const { html_url } = pull;
|
|
44
|
-
// also update to crPulls
|
|
45
|
-
await CNRepos.updateOne($filaten({ repository, crPulls: { data: { pull: { html_url } } } }), {
|
|
46
|
-
$set: { "crPulls.data.$.pull": pull },
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return await CNRepos.updateOne({ repository }, { $set: { createdPulls } });
|
|
52
|
-
},
|
|
53
|
-
{ concurrency: 2, stopOnError: false },
|
|
54
|
-
);
|
|
55
|
-
}
|
|
1
|
+
import { $pipeline } from "@/packages/mongodb-pipeline-ts/$pipeline";
|
|
2
|
+
import pMap from "p-map";
|
|
3
|
+
import { match } from "ts-pattern";
|
|
4
|
+
import { $OK, TaskError, TaskOK } from "../packages/mongodb-pipeline-ts/Task";
|
|
5
|
+
import { CNRepos } from "./CNRepos";
|
|
6
|
+
import { createComfyRegistryPullRequests } from "./createComfyRegistryPullRequests";
|
|
7
|
+
import { $filaten, $stale } from "./db";
|
|
8
|
+
import { parseUrlRepoOwner, stringifyOwnerRepo } from "./parseOwnerRepo";
|
|
9
|
+
import { notifySlackLinks } from "./slack/notifySlackLinks";
|
|
10
|
+
import { tLog } from "./utils/tLog";
|
|
11
|
+
if (import.meta.main) {
|
|
12
|
+
await tLog("createComfyRegistryPRsFromCandidates", createComfyRegistryPRsFromCandidates);
|
|
13
|
+
console.log("all done");
|
|
14
|
+
}
|
|
15
|
+
export async function createComfyRegistryPRsFromCandidates() {
|
|
16
|
+
await CNRepos.createIndex($filaten({ candidate: { data: 1 } }));
|
|
17
|
+
await CNRepos.createIndex(
|
|
18
|
+
$filaten({
|
|
19
|
+
candidate: { data: 1 },
|
|
20
|
+
createdPulls: { state: 1, mtime: 1 },
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
return await pMap(
|
|
24
|
+
$pipeline(CNRepos)
|
|
25
|
+
.match(
|
|
26
|
+
$filaten({
|
|
27
|
+
candidate: { data: { $eq: true } },
|
|
28
|
+
createdPulls: { state: { $ne: "ok" }, mtime: $stale("5m") },
|
|
29
|
+
}),
|
|
30
|
+
)
|
|
31
|
+
.aggregate(),
|
|
32
|
+
async (repo) => {
|
|
33
|
+
const { repository } = repo;
|
|
34
|
+
console.log("Making PRs for " + repository);
|
|
35
|
+
const createdPulls = await createComfyRegistryPullRequests(repository).then(TaskOK).catch(TaskError);
|
|
36
|
+
match(createdPulls).with($OK, async ({ data }) => {
|
|
37
|
+
const links = data.map((e) => ({
|
|
38
|
+
href: e.html_url,
|
|
39
|
+
name: stringifyOwnerRepo(parseUrlRepoOwner(e.html_url.replace(/\/pull\/.*$/, ""))) + " #" + e.title,
|
|
40
|
+
}));
|
|
41
|
+
await notifySlackLinks("PR just Created, @HaoHao check plz", links);
|
|
42
|
+
await pMap(data, async (pull) => {
|
|
43
|
+
const { html_url } = pull;
|
|
44
|
+
// also update to crPulls
|
|
45
|
+
await CNRepos.updateOne($filaten({ repository, crPulls: { data: { pull: { html_url } } } }), {
|
|
46
|
+
$set: { "crPulls.data.$.pull": pull },
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return await CNRepos.updateOne({ repository }, { $set: { createdPulls } });
|
|
52
|
+
},
|
|
53
|
+
{ concurrency: 2, stopOnError: false },
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -1,22 +1,32 @@
|
|
|
1
|
-
import pMap from "p-map";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import { parsePulls } from "./parsePullsState";
|
|
9
|
-
|
|
10
|
-
export async function createComfyRegistryPullRequests(upstreamRepoUrl: string) {
|
|
11
|
-
const forkedRepo = await createGithubForkForRepo(upstreamRepoUrl);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import pMap from "p-map";
|
|
2
|
+
// import { chalk } from "zx";
|
|
3
|
+
import { clone_modify_push_Branches } from "./clone_modify_push_Branches";
|
|
4
|
+
import { createGithubForkForRepo } from "./createGithubForkForRepo";
|
|
5
|
+
import { createGithubPullRequest } from "./createGithubPullRequest";
|
|
6
|
+
import type { GithubPull } from "./gh/GithubPull";
|
|
7
|
+
import { makeUpdateTomlLicenseBranch } from "./makeUpdateTomlLicenseBranch";
|
|
8
|
+
import { parsePulls } from "./parsePullsState";
|
|
9
|
+
|
|
10
|
+
export async function createComfyRegistryPullRequests(upstreamRepoUrl: string) {
|
|
11
|
+
const forkedRepo = await createGithubForkForRepo(upstreamRepoUrl);
|
|
12
|
+
|
|
13
|
+
const PR_REQUESTS = await clone_modify_push_Branches(upstreamRepoUrl, forkedRepo.html_url);
|
|
14
|
+
const prs = await pMap(PR_REQUESTS, async ({ type, ...prInfo }) => await createGithubPullRequest({ ...prInfo }));
|
|
15
|
+
|
|
16
|
+
console.log("Registry PRs DONE");
|
|
17
|
+
|
|
18
|
+
return ([...prs] as GithubPull[]).map((e) => parsePulls([e])[0]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function clone_modify_push_Branches_for_updateTomlLicense(upstreamUrl: string, forkUrl: string) {
|
|
22
|
+
return (await Promise.all([makeUpdateTomlLicenseBranch(upstreamUrl, forkUrl)]))
|
|
23
|
+
.flatMap((e) => (e ? [e] : []))
|
|
24
|
+
.map(({ body, branch, title, type }) => ({
|
|
25
|
+
body,
|
|
26
|
+
branch,
|
|
27
|
+
title,
|
|
28
|
+
type,
|
|
29
|
+
srcUrl: forkUrl,
|
|
30
|
+
dstUrl: upstreamUrl,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
@@ -1,37 +1,54 @@
|
|
|
1
|
-
import DIE from "@snomiao/die";
|
|
2
|
-
import md5 from "md5";
|
|
3
|
-
import minimist from "minimist";
|
|
4
|
-
import { FORK_OWNER } from "./FORK_OWNER";
|
|
5
|
-
import { FORK_PREFIX } from "./FORK_PREFIX";
|
|
6
|
-
import { createGithubFork } from "./gh/createGithubFork";
|
|
7
|
-
import { ghUser } from "./ghUser";
|
|
8
|
-
import { parseUrlRepoOwner } from "./parseOwnerRepo";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
import DIE from "@snomiao/die";
|
|
2
|
+
import md5 from "md5";
|
|
3
|
+
import minimist from "minimist";
|
|
4
|
+
import { FORK_OWNER } from "./FORK_OWNER";
|
|
5
|
+
import { FORK_PREFIX } from "./FORK_PREFIX";
|
|
6
|
+
import { createGithubFork } from "./gh/createGithubFork";
|
|
7
|
+
import { ghUser } from "./ghUser";
|
|
8
|
+
import { parseUrlRepoOwner } from "./parseOwnerRepo";
|
|
9
|
+
|
|
10
|
+
if (import.meta.main) {
|
|
11
|
+
console.log(await createGithubForkForRepo("https://github.com/comfyanonymous/ComfyUI_TensorRT"));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* this function creates a fork of the upstream repo,
|
|
16
|
+
* fork to the FORK_OWNER, and add a prefix to the repo name
|
|
17
|
+
* - the prefix is optional, if not provided, the repo name will be the same as the upstream repo
|
|
18
|
+
* - the prefix is useful to distinguish the forked repo from the other repo in the same owner
|
|
19
|
+
* SALT is used to generate a unique repo name, so that the forked repo will not conflict with other forks
|
|
20
|
+
*
|
|
21
|
+
* @author snomiao <snomiao@gmail.com>
|
|
22
|
+
* @param upstreamRepoUrl
|
|
23
|
+
* @returns forked repo info
|
|
24
|
+
*/
|
|
25
|
+
export async function createGithubForkForRepo(
|
|
26
|
+
upstreamRepoUrl: string,
|
|
27
|
+
{ forkUrl = createGithubForkUrlForRepo(upstreamRepoUrl) } = {},
|
|
28
|
+
) {
|
|
29
|
+
console.debug(
|
|
30
|
+
`
|
|
31
|
+
Forking ${upstreamRepoUrl}
|
|
32
|
+
into ${forkUrl}
|
|
33
|
+
`.trim(),
|
|
34
|
+
);
|
|
35
|
+
const forked = await createGithubFork(upstreamRepoUrl, forkUrl);
|
|
36
|
+
if (forked.html_url !== forkUrl)
|
|
37
|
+
DIE(
|
|
38
|
+
new Error(
|
|
39
|
+
"forked url not expected, it's likely you already forked this repo in your account before, and now trying to fork it again with different salt. To recovery you could delete that repo forked before by manual. (the repo forked before is listed in FORK OK: .....)",
|
|
40
|
+
),
|
|
41
|
+
);
|
|
42
|
+
return forked;
|
|
43
|
+
}
|
|
44
|
+
export function createGithubForkUrlForRepo(upstreamRepoUrl: string) {
|
|
45
|
+
// console.log(`* Change env.SALT=${salt} will fork into a different repo`);
|
|
46
|
+
const upstream = parseUrlRepoOwner(upstreamRepoUrl);
|
|
47
|
+
const argv = minimist(process.argv.slice(2));
|
|
48
|
+
const salt = argv.salt || process.env.SALT || "m3KMgZ2AeZGWYh7W";
|
|
49
|
+
const repo_hash = md5(`${salt}-${ghUser.name}-${upstream.owner}/${upstream.repo}`).slice(0, 8);
|
|
50
|
+
const forkRepoName = (FORK_PREFIX && `${FORK_PREFIX}${upstream.repo}-${repo_hash}`) || upstream.repo;
|
|
51
|
+
const forkDst = `${FORK_OWNER}/${forkRepoName}`;
|
|
52
|
+
const forkUrl = `https://github.com/${forkDst}`;
|
|
53
|
+
return forkUrl;
|
|
54
|
+
}
|