comfy-pr 0.2.19 → 0.2.24
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 +225 -225
- package/next-env.d.ts +5 -5
- package/package.json +10 -2
- package/src/Authors.ts +48 -0
- package/src/CMNodes.ts +60 -60
- package/src/CNRepos.ts +74 -72
- package/src/CRNodes.ts +27 -27
- package/src/CRPulls.ts +4 -4
- 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 +9 -9
- package/src/TrackingPRs.ts +12 -12
- package/src/WorkerInstances.ts +89 -89
- package/src/addCommentAction.ts +65 -0
- package/src/analyzePullsStatus.ts +170 -125
- package/src/analyzeTotals.test.ts +5 -5
- package/src/analyzeTotals.ts +118 -120
- package/src/checkComfyActivated.ts +39 -39
- 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 +22 -22
- package/src/createGithubForkForRepo.ts +37 -37
- package/src/createGithubPullRequest.ts +94 -94
- package/src/createIssueComment.ts +29 -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 +76 -75
- package/src/getActivatedShell.ts +18 -18
- package/src/getBranchWorkingDir.ts +16 -16
- package/src/getRepoWorkingDir.ts +5 -5
- package/src/ghUser.ts +6 -6
- package/src/index.ts +22 -21
- package/src/initializeFollowRules.ts +26 -26
- package/src/makePublishBranch.ts +58 -58
- package/src/makeTomlBranch.ts +53 -53
- package/src/matchRelatedPulls.ts +60 -25
- 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/showFollowRuleSet.ts +12 -0
- package/src/summaryLastPullComment.ts +8 -8
- package/src/tomlFillDescription.ts +17 -17
- package/src/updateAuthors.ts +7 -0
- package/src/updateAuthorsForGithub.ts +50 -0
- package/src/updateAuthorsFromCNRepo.ts +30 -0
- 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 +57 -57
- package/src/updateCNReposPRCandidate.ts +85 -85
- package/src/updateCNReposPulls.ts +28 -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 +127 -182
- package/src/updateOutdatedPullsTemplates.ts +160 -156
- package/src/updateSlackMessages.ts +43 -43
- package/tailwind.config.ts +20 -20
- package/CHANGELOG.md +0 -109
|
@@ -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
|
+
}
|
package/src/followRuleSchema.ts
CHANGED
|
@@ -1,75 +1,76 @@
|
|
|
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
|
-
|
|
39
|
-
comments: mNumber,
|
|
40
|
-
created_at: mDate,
|
|
41
|
-
comments_author: mString,
|
|
42
|
-
head: mString,
|
|
43
|
-
lastwords: mString,
|
|
44
|
-
on_registry: z.boolean(),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
.strict()
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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();
|
package/src/getActivatedShell.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/getRepoWorkingDir.ts
CHANGED
|
@@ -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,21 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
import "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
await
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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,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
|
+
}
|
package/src/makePublishBranch.ts
CHANGED
|
@@ -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
|
+
}
|