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.
- package/CHANGELOG.md +385 -0
- package/README.md +225 -225
- package/next-env.d.ts +5 -5
- package/package.json +12 -2
- package/src/Authors.ts +48 -48
- package/src/CMNodes.ts +60 -60
- package/src/CNRepos.ts +75 -74
- package/src/CRNodes.ts +27 -27
- package/src/CRPulls.ts +4 -4
- package/src/EmailTasks.ts +100 -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 +193 -170
- package/src/analyzeTotals.test.ts +5 -5
- package/src/analyzeTotals.ts +118 -118
- 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 +40 -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 +78 -76
- 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 +24 -22
- package/src/initializeFollowRules.ts +26 -26
- package/src/makePublishBranch.ts +58 -58
- package/src/makeTomlBranch.ts +53 -53
- package/src/matchRelatedPulls.ts +60 -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 +104 -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 +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 +137 -127
- package/src/updateOutdatedPullsTemplates.ts +160 -160
- package/src/updateSlackMessages.ts +43 -43
- package/tailwind.config.ts +20 -20
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
|
+
}
|
package/src/makeTomlBranch.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/matchRelatedPulls.ts
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import pMap from "p-map";
|
|
2
|
-
import { match } from "ts-pattern";
|
|
3
|
-
import { fetchRelatedPullWithComments } from "./fetchRelatedPullWithComments";
|
|
4
|
-
import type { GithubPullParsed } from "./parsePullsState";
|
|
5
|
-
import { readTemplateTitle } from "./readTemplateTitle";
|
|
6
|
-
|
|
7
|
-
export type RelatedPullsWithComments = Awaited<ReturnType<typeof fetchRelatedPullWithComments>>;
|
|
8
|
-
export type RelatedPull = Awaited<ReturnType<typeof matchRelatedPulls>>[number];
|
|
9
|
-
export async function matchRelatedPulls(pulls: GithubPullParsed[]): Promise<
|
|
10
|
-
(
|
|
11
|
-
| {
|
|
12
|
-
type: "pyproject";
|
|
13
|
-
pull: {
|
|
14
|
-
title: string;
|
|
15
|
-
number: number;
|
|
16
|
-
url: string;
|
|
17
|
-
html_url: string;
|
|
18
|
-
user: { login: string; html_url: string };
|
|
19
|
-
body: string | null;
|
|
20
|
-
prState: "closed" | "open" | "merged";
|
|
21
|
-
updatedAt: Date;
|
|
22
|
-
createdAt: Date;
|
|
23
|
-
updated_at: Date;
|
|
24
|
-
created_at: Date;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
| {
|
|
28
|
-
type: "publishcr";
|
|
29
|
-
pull: {
|
|
30
|
-
title: string;
|
|
31
|
-
number: number;
|
|
32
|
-
url: string;
|
|
33
|
-
html_url: string;
|
|
34
|
-
user: { login: string; html_url: string };
|
|
35
|
-
body: string | null;
|
|
36
|
-
prState: "closed" | "open" | "merged";
|
|
37
|
-
updatedAt: Date;
|
|
38
|
-
createdAt: Date;
|
|
39
|
-
updated_at: Date;
|
|
40
|
-
created_at: Date;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
)[]
|
|
44
|
-
> {
|
|
45
|
-
const pyproject = await readTemplateTitle("add-toml.md");
|
|
46
|
-
const publishcr = await readTemplateTitle("add-action.md");
|
|
47
|
-
const relatedPulls = await pMap(pulls, async (pull) =>
|
|
48
|
-
match(pull)
|
|
49
|
-
.with({ title: pyproject }, (pull) => ({
|
|
50
|
-
type: "pyproject" as const,
|
|
51
|
-
pull,
|
|
52
|
-
}))
|
|
53
|
-
.with({ title: publishcr }, (pull) => ({
|
|
54
|
-
type: "publishcr" as const,
|
|
55
|
-
pull,
|
|
56
|
-
}))
|
|
57
|
-
.otherwise(() => null),
|
|
58
|
-
);
|
|
59
|
-
return relatedPulls.flatMap((e) => (e ? [e] : []));
|
|
60
|
-
}
|
|
1
|
+
import pMap from "p-map";
|
|
2
|
+
import { match } from "ts-pattern";
|
|
3
|
+
import { fetchRelatedPullWithComments } from "./fetchRelatedPullWithComments";
|
|
4
|
+
import type { GithubPullParsed } from "./parsePullsState";
|
|
5
|
+
import { readTemplateTitle } from "./readTemplateTitle";
|
|
6
|
+
|
|
7
|
+
export type RelatedPullsWithComments = Awaited<ReturnType<typeof fetchRelatedPullWithComments>>;
|
|
8
|
+
export type RelatedPull = Awaited<ReturnType<typeof matchRelatedPulls>>[number];
|
|
9
|
+
export async function matchRelatedPulls(pulls: GithubPullParsed[]): Promise<
|
|
10
|
+
(
|
|
11
|
+
| {
|
|
12
|
+
type: "pyproject";
|
|
13
|
+
pull: {
|
|
14
|
+
title: string;
|
|
15
|
+
number: number;
|
|
16
|
+
url: string;
|
|
17
|
+
html_url: string;
|
|
18
|
+
user: { login: string; html_url: string };
|
|
19
|
+
body: string | null;
|
|
20
|
+
prState: "closed" | "open" | "merged";
|
|
21
|
+
updatedAt: Date;
|
|
22
|
+
createdAt: Date;
|
|
23
|
+
updated_at: Date;
|
|
24
|
+
created_at: Date;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
| {
|
|
28
|
+
type: "publishcr";
|
|
29
|
+
pull: {
|
|
30
|
+
title: string;
|
|
31
|
+
number: number;
|
|
32
|
+
url: string;
|
|
33
|
+
html_url: string;
|
|
34
|
+
user: { login: string; html_url: string };
|
|
35
|
+
body: string | null;
|
|
36
|
+
prState: "closed" | "open" | "merged";
|
|
37
|
+
updatedAt: Date;
|
|
38
|
+
createdAt: Date;
|
|
39
|
+
updated_at: Date;
|
|
40
|
+
created_at: Date;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
)[]
|
|
44
|
+
> {
|
|
45
|
+
const pyproject = await readTemplateTitle("add-toml.md");
|
|
46
|
+
const publishcr = await readTemplateTitle("add-action.md");
|
|
47
|
+
const relatedPulls = await pMap(pulls, async (pull) =>
|
|
48
|
+
match(pull)
|
|
49
|
+
.with({ title: pyproject }, (pull) => ({
|
|
50
|
+
type: "pyproject" as const,
|
|
51
|
+
pull,
|
|
52
|
+
}))
|
|
53
|
+
.with({ title: publishcr }, (pull) => ({
|
|
54
|
+
type: "publishcr" as const,
|
|
55
|
+
pull,
|
|
56
|
+
}))
|
|
57
|
+
.otherwise(() => null),
|
|
58
|
+
);
|
|
59
|
+
return relatedPulls.flatMap((e) => (e ? [e] : []));
|
|
60
|
+
}
|
package/src/muteInstances.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
import { readFile, writeFile } from "fs/promises";
|
|
3
|
-
import { globby } from "globby";
|
|
4
|
-
import pMap from "p-map";
|
|
5
|
-
if (import.meta.main) {
|
|
6
|
-
const files = await globby("node_modules/**/*instance*.js");
|
|
7
|
-
await pMap(files, async (file) => {
|
|
8
|
-
const x = await readFile(file, "utf8");
|
|
9
|
-
const y = x.replace(/console.warn/, ";");
|
|
10
|
-
if (x !== y) {
|
|
11
|
-
await writeFile(file, y);
|
|
12
|
-
console.log("muted: " + file);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
console.log("done");
|
|
16
|
-
}
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { readFile, writeFile } from "fs/promises";
|
|
3
|
+
import { globby } from "globby";
|
|
4
|
+
import pMap from "p-map";
|
|
5
|
+
if (import.meta.main) {
|
|
6
|
+
const files = await globby("node_modules/**/*instance*.js");
|
|
7
|
+
await pMap(files, async (file) => {
|
|
8
|
+
const x = await readFile(file, "utf8");
|
|
9
|
+
const y = x.replace(/console.warn/, ";");
|
|
10
|
+
if (x !== y) {
|
|
11
|
+
await writeFile(file, y);
|
|
12
|
+
console.log("muted: " + file);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
console.log("done");
|
|
16
|
+
}
|
package/src/parseIssueUrl.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export function parseIssueUrl(issueUrl: string) {
|
|
2
|
-
const [owner, repo, strNumber] = issueUrl
|
|
3
|
-
.match(/^https:\/\/github\.com\/([\w-]+)\/([\w-]+)\/(?:pull|issues)\/(\d+)$/)!
|
|
4
|
-
.slice(1);
|
|
5
|
-
return { owner, repo, issue_number: Number(strNumber) };
|
|
6
|
-
}
|
|
1
|
+
export function parseIssueUrl(issueUrl: string) {
|
|
2
|
+
const [owner, repo, strNumber] = issueUrl
|
|
3
|
+
.match(/^https:\/\/github\.com\/([\w-]+)\/([\w-]+)\/(?:pull|issues)\/(\d+)$/)!
|
|
4
|
+
.slice(1);
|
|
5
|
+
return { owner, repo, issue_number: Number(strNumber) };
|
|
6
|
+
}
|
package/src/parseOwnerRepo.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { basename, dirname } from "path";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Parse owner and repo obj
|
|
5
|
-
* @param gitUrl git@github.ocm:owner/repo or https://github.ocm/owner/repo
|
|
6
|
-
*/
|
|
7
|
-
export function parseUrlRepoOwner(gitUrl: string) {
|
|
8
|
-
return {
|
|
9
|
-
owner: basename(dirname(gitUrl.replace(/:/, "/"))),
|
|
10
|
-
repo: basename(gitUrl.replace(/:/, "/")).replace(/\.git$/, ""),
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export function stringifyOwnerRepo({ owner, repo }: ReturnType<typeof parseUrlRepoOwner>) {
|
|
14
|
-
return owner + "/" + repo;
|
|
15
|
-
}
|
|
16
|
-
export function stringifyGithubRepoUrl({ owner, repo }: ReturnType<typeof parseUrlRepoOwner>) {
|
|
17
|
-
return "https://github.com/" + owner + "/" + repo;
|
|
18
|
-
}
|
|
19
|
-
export async function stringifyGithubOrigin({ owner, repo }: ReturnType<typeof parseUrlRepoOwner>) {
|
|
20
|
-
const PR_TOKEN = process.env.GH_TOKEN_COMFY_PR;
|
|
21
|
-
if (PR_TOKEN) {
|
|
22
|
-
// fails: maybe permission issue
|
|
23
|
-
// const USERNAME = (
|
|
24
|
-
// await new Octokit({
|
|
25
|
-
// auth: PR_TOKEN,
|
|
26
|
-
// }).rest.users.getAuthenticated()
|
|
27
|
-
// ).data.login;
|
|
28
|
-
// return `https://${USERNAME}:${PR_TOKEN}@github.com/${owner}/${repo}`;
|
|
29
|
-
|
|
30
|
-
return `git@github.com:${owner}/${repo}`;
|
|
31
|
-
}
|
|
32
|
-
return `git@github.com:${owner}/${repo}`;
|
|
33
|
-
}
|
|
1
|
+
import { basename, dirname } from "path";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parse owner and repo obj
|
|
5
|
+
* @param gitUrl git@github.ocm:owner/repo or https://github.ocm/owner/repo
|
|
6
|
+
*/
|
|
7
|
+
export function parseUrlRepoOwner(gitUrl: string) {
|
|
8
|
+
return {
|
|
9
|
+
owner: basename(dirname(gitUrl.replace(/:/, "/"))),
|
|
10
|
+
repo: basename(gitUrl.replace(/:/, "/")).replace(/\.git$/, ""),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function stringifyOwnerRepo({ owner, repo }: ReturnType<typeof parseUrlRepoOwner>) {
|
|
14
|
+
return owner + "/" + repo;
|
|
15
|
+
}
|
|
16
|
+
export function stringifyGithubRepoUrl({ owner, repo }: ReturnType<typeof parseUrlRepoOwner>) {
|
|
17
|
+
return "https://github.com/" + owner + "/" + repo;
|
|
18
|
+
}
|
|
19
|
+
export async function stringifyGithubOrigin({ owner, repo }: ReturnType<typeof parseUrlRepoOwner>) {
|
|
20
|
+
const PR_TOKEN = process.env.GH_TOKEN_COMFY_PR;
|
|
21
|
+
if (PR_TOKEN) {
|
|
22
|
+
// fails: maybe permission issue
|
|
23
|
+
// const USERNAME = (
|
|
24
|
+
// await new Octokit({
|
|
25
|
+
// auth: PR_TOKEN,
|
|
26
|
+
// }).rest.users.getAuthenticated()
|
|
27
|
+
// ).data.login;
|
|
28
|
+
// return `https://${USERNAME}:${PR_TOKEN}@github.com/${owner}/${repo}`;
|
|
29
|
+
|
|
30
|
+
return `git@github.com:${owner}/${repo}`;
|
|
31
|
+
}
|
|
32
|
+
return `git@github.com:${owner}/${repo}`;
|
|
33
|
+
}
|
package/src/parsePullUrl.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export function parsePullUrl(issueUrl: string) {
|
|
2
|
-
const [owner, repo, strNumber] = issueUrl
|
|
3
|
-
.match(/^https:\/\/github\.com\/([\w-]+)\/([\w-]+)\/(?:pull)\/(\d+)$/)!
|
|
4
|
-
.slice(1);
|
|
5
|
-
return { owner, repo, pull_number: Number(strNumber) };
|
|
6
|
-
}
|
|
1
|
+
export function parsePullUrl(issueUrl: string) {
|
|
2
|
+
const [owner, repo, strNumber] = issueUrl
|
|
3
|
+
.match(/^https:\/\/github\.com\/([\w-]+)\/([\w-]+)\/(?:pull)\/(\d+)$/)!
|
|
4
|
+
.slice(1);
|
|
5
|
+
return { owner, repo, pull_number: Number(strNumber) };
|
|
6
|
+
}
|
package/src/parsePullsState.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { GithubPull } from "./gh/GithubPull";
|
|
2
|
-
import { parsePull } from "./gh/parsePull";
|
|
3
|
-
export type GithubPullParsed = ReturnType<typeof parsePulls>[number];
|
|
4
|
-
export function parsePulls(data: GithubPull[]) {
|
|
5
|
-
return data.map((e) => parsePull(e));
|
|
6
|
-
}
|
|
1
|
+
import type { GithubPull } from "./gh/GithubPull";
|
|
2
|
+
import { parsePull } from "./gh/parsePull";
|
|
3
|
+
export type GithubPullParsed = ReturnType<typeof parsePulls>[number];
|
|
4
|
+
export function parsePulls(data: GithubPull[]) {
|
|
5
|
+
return data.map((e) => parsePull(e));
|
|
6
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import DIE from "@snomiao/die";
|
|
2
|
-
|
|
3
|
-
export function parseTitleBodyOfMarkdown(tmpl: string) {
|
|
4
|
-
tmpl.startsWith("# ") || DIE("Unrecognized template format:" + tmpl);
|
|
5
|
-
const title = tmpl.split("\n")[0].slice(1).trim();
|
|
6
|
-
const body = tmpl.split("\n").slice(1).join("\n").trim();
|
|
7
|
-
return { title, body };
|
|
8
|
-
}
|
|
1
|
+
import DIE from "@snomiao/die";
|
|
2
|
+
|
|
3
|
+
export function parseTitleBodyOfMarkdown(tmpl: string) {
|
|
4
|
+
tmpl.startsWith("# ") || DIE("Unrecognized template format:" + tmpl);
|
|
5
|
+
const title = tmpl.split("\n")[0].slice(1).trim();
|
|
6
|
+
const body = tmpl.split("\n").slice(1).join("\n").trim();
|
|
7
|
+
return { title, body };
|
|
8
|
+
}
|
package/src/postSlackMessage.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import DIE from "@snomiao/die";
|
|
2
|
-
import { slack } from "./slack";
|
|
3
|
-
|
|
4
|
-
export async function postSlackMessage(text: string) {
|
|
5
|
-
const channel = process.env.SLACK_BOT_CHANNEL || DIE(new Error("missing env.SLACK_BOT_CHANNEL"));
|
|
6
|
-
// this api will auto retry if failed
|
|
7
|
-
const response = await slack.chat.postMessage({
|
|
8
|
-
channel,
|
|
9
|
-
text,
|
|
10
|
-
blocks: [
|
|
11
|
-
{
|
|
12
|
-
type: "section",
|
|
13
|
-
text: {
|
|
14
|
-
type: "mrkdwn",
|
|
15
|
-
text: text,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
});
|
|
20
|
-
return { channel, ts: response.ts, text };
|
|
21
|
-
}
|
|
1
|
+
import DIE from "@snomiao/die";
|
|
2
|
+
import { slack } from "./slack";
|
|
3
|
+
|
|
4
|
+
export async function postSlackMessage(text: string) {
|
|
5
|
+
const channel = process.env.SLACK_BOT_CHANNEL || DIE(new Error("missing env.SLACK_BOT_CHANNEL"));
|
|
6
|
+
// this api will auto retry if failed
|
|
7
|
+
const response = await slack.chat.postMessage({
|
|
8
|
+
channel,
|
|
9
|
+
text,
|
|
10
|
+
blocks: [
|
|
11
|
+
{
|
|
12
|
+
type: "section",
|
|
13
|
+
text: {
|
|
14
|
+
type: "mrkdwn",
|
|
15
|
+
text: text,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
});
|
|
20
|
+
return { channel, ts: response.ts, text };
|
|
21
|
+
}
|
package/src/preload.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
await Bun.plugin({
|
|
2
|
-
name: "YAML",
|
|
3
|
-
async setup(build) {
|
|
4
|
-
const { load } = await import("js-yaml");
|
|
5
|
-
|
|
6
|
-
// when a .yaml file is imported...
|
|
7
|
-
build.onLoad({ filter: /\.(yaml|yml)$/ }, async (args) => {
|
|
8
|
-
// read and parse the file
|
|
9
|
-
const text = await Bun.file(args.path).text();
|
|
10
|
-
const exports = load(text) as Record<string, any>;
|
|
11
|
-
|
|
12
|
-
// and returns it as a module
|
|
13
|
-
return {
|
|
14
|
-
exports,
|
|
15
|
-
loader: "object", // special loader for JS objects
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
Bun.plugin({
|
|
22
|
-
name: "preload-plugin",
|
|
23
|
-
setup(builder) {
|
|
24
|
-
builder.onLoad({ filter: /\.ts$/ }, async (args) => {
|
|
25
|
-
const text = await Bun.file(args.path).text();
|
|
26
|
-
// console.log("text", text);
|
|
27
|
-
return { contents: text, loader: args.loader };
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
});
|
|
1
|
+
await Bun.plugin({
|
|
2
|
+
name: "YAML",
|
|
3
|
+
async setup(build) {
|
|
4
|
+
const { load } = await import("js-yaml");
|
|
5
|
+
|
|
6
|
+
// when a .yaml file is imported...
|
|
7
|
+
build.onLoad({ filter: /\.(yaml|yml)$/ }, async (args) => {
|
|
8
|
+
// read and parse the file
|
|
9
|
+
const text = await Bun.file(args.path).text();
|
|
10
|
+
const exports = load(text) as Record<string, any>;
|
|
11
|
+
|
|
12
|
+
// and returns it as a module
|
|
13
|
+
return {
|
|
14
|
+
exports,
|
|
15
|
+
loader: "object", // special loader for JS objects
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
Bun.plugin({
|
|
22
|
+
name: "preload-plugin",
|
|
23
|
+
setup(builder) {
|
|
24
|
+
builder.onLoad({ filter: /\.ts$/ }, async (args) => {
|
|
25
|
+
const text = await Bun.file(args.path).text();
|
|
26
|
+
// console.log("text", text);
|
|
27
|
+
return { contents: text, loader: args.loader };
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
export const zPullStatusFollow = z.array(
|
|
4
|
-
z.object({
|
|
5
|
-
updated: z.string(),
|
|
6
|
-
state: z.string(),
|
|
7
|
-
url: z.string(),
|
|
8
|
-
head: z.string(),
|
|
9
|
-
comments: z.number(),
|
|
10
|
-
lastwords: z.string(),
|
|
11
|
-
}),
|
|
12
|
-
);
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const zPullStatusFollow = z.array(
|
|
4
|
+
z.object({
|
|
5
|
+
updated: z.string(),
|
|
6
|
+
state: z.string(),
|
|
7
|
+
url: z.string(),
|
|
8
|
+
head: z.string(),
|
|
9
|
+
comments: z.number(),
|
|
10
|
+
lastwords: z.string(),
|
|
11
|
+
}),
|
|
12
|
+
);
|
package/src/readTemplateTitle.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { readFile } from "fs/promises";
|
|
2
|
-
import { parseTitleBodyOfMarkdown } from "./parseTitleBodyOfMarkdown";
|
|
3
|
-
|
|
4
|
-
export async function readTemplateTitle(filename: string) {
|
|
5
|
-
return await readTemplate(filename).then((e) => e.title);
|
|
6
|
-
}
|
|
7
|
-
export async function readTemplate(filename: string) {
|
|
8
|
-
return readFile("./templates/" + filename, "utf8").then(
|
|
9
|
-
parseTitleBodyOfMarkdown,
|
|
10
|
-
);
|
|
11
|
-
}
|
|
1
|
+
import { readFile } from "fs/promises";
|
|
2
|
+
import { parseTitleBodyOfMarkdown } from "./parseTitleBodyOfMarkdown";
|
|
3
|
+
|
|
4
|
+
export async function readTemplateTitle(filename: string) {
|
|
5
|
+
return await readTemplate(filename).then((e) => e.title);
|
|
6
|
+
}
|
|
7
|
+
export async function readTemplate(filename: string) {
|
|
8
|
+
return readFile("./templates/" + filename, "utf8").then(
|
|
9
|
+
parseTitleBodyOfMarkdown,
|
|
10
|
+
);
|
|
11
|
+
}
|