Skip to content

Commit

Permalink
feat(license-updator): ready
Browse files Browse the repository at this point in the history
ready
  • Loading branch information
snomiao committed Jul 31, 2024
1 parent fcef6df commit 9f367ee
Show file tree
Hide file tree
Showing 19 changed files with 354 additions and 159 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "next/core-web-vitals"
"extends": "next/core-web-vitals",
"rules":{
"@typescript-eslint/explicit-function-return-type": "warn"

}
}
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Comfy-PR

Make PRs that publishes ComfyUI Custom Nodes to [ComfyUI Registry](https://www.comfyregistry.org/).
Make PRs that helps comfy community grow with [Comfy.org](https://comfy.org/).

## Project Goals: (aka roadmap)

Expand All @@ -13,9 +13,9 @@ Make PRs that publishes ComfyUI Custom Nodes to [ComfyUI Registry](https://www.c
- [x] create PR to original repository with template PR description.
- [x] Submit PR
- [x] Clean local debris before clone
- [/] DOING: Export PR status into csv for @haohao
- [x] DOING: Export PR status into csv for @haohao

### Github Actions Worker
### Github Actions Workerds

- [x] Fetch repos from CM & CR list
- [x] Make diff
Expand All @@ -26,6 +26,8 @@ Make PRs that publishes ComfyUI Custom Nodes to [ComfyUI Registry](https://www.c
- [x] Automaticaly find candidates, and do the cli does
- [x] Mention related prs in dashboard https://github.com/drip-art/Comfy-Registry-PR/issues/1
- [x] Analyze Totals
- [x] license schema updator
- [x] bypass repo
- [ ] Follow-up prs by state
- [ ] Issues Comment
- [ ] Slack
Expand All @@ -35,7 +37,7 @@ Make PRs that publishes ComfyUI Custom Nodes to [ComfyUI Registry](https://www.c
### Web Site https://comfy-pr.vercel.app

- [x] A dashboard csv/yaml exporter site for @haohao
- [ ]
- [x] pr dashboard

## Usages

Expand Down
2 changes: 1 addition & 1 deletion app/(dashboard)/details/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function DetailsPage({ searchParams: { skip = 0, limit = 0 } }) {
1. [Admin: Check Default Follow-up rule](/rules/default)
`}</Markdown>

<UseSWRComponent props={{ skip, limit }} Component={DetailsTable} refreshInterval={60e3}>
<UseSWRComponent props={{ skip, limit }} Component={DetailsTable} refreshInterval={60e3}>
{<DetailsTable {...{ skip, limit }} />}
</UseSWRComponent>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/(dashboard)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Link from "next/link";
import { Suspense } from "react";
import DetailsTable from "./DetailsTable";
import TotalsPage from "./totals/page";
export const dynamic = "force-dynamic";
export const revalidate = 60; // seconds
export default async function DashboardPage() {
return (
<main className="flex flex-wrap">
Expand Down
8 changes: 8 additions & 0 deletions bypass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file provide a list to bypass ComfyPR interact with some repos.
#
# Want to remove your repo from bypass list? make a pr here to remove.

bypass_repos:
- https://github.com/loopyd # bypass reason: https://github.com/loopyd/ComfyUI-FD-Tagger/pull/1


11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
volumes:
venv:
test_db_data:

# dev server
services:
comfy-pr:
# image: oven/bun
# command: bun dev
# volumes: [ ./:/home/bun/app ]
image: node
command: npx -y bun dev
working_dir: /home/bun/app
volumes: [ ./:/home/bun/app ]
environment: [ PORT=80 ]
# comfy-pr:
# restart: always
# image: snomiao/comfy-registry-pr
Expand Down
58 changes: 30 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"vercel:build": "vercel build",
"build": "next build",
"build:worker": "bun build . --define 'import.meta.main=false' --define 'import.meta.env.IS_BUNDLE=true' --target=bun > dist/index.js",
"predev": "bun i",
"dev": "next dev",
"lint": "next lint",
"prerelease": "bun run build && bun run test && vercel --prod",
Expand All @@ -33,28 +34,29 @@
"test": "bun test"
},
"dependencies": {
"@auth/mongodb-adapter": "^3.2.0",
"@auth/mongodb-adapter": "^3.4.2",
"@ctrl/mac-address": "^3.0.3",
"@kbox-labs/react-echarts": "^1.2.0",
"@monaco-editor/react": "^4.6.0",
"@slack/web-api": "^7.2.0",
"@snomiao/die": "^1.1.0",
"@slack/web-api": "^7.3.1",
"@snomiao/die": "^1.2.3",
"@trpc/server": "^10.45.2",
"@types/d3": "^7.4.3",
"@types/file-saver": "^2.0.7",
"@types/markdown-it": "^14.1.1",
"@types/jest": "^29.5.12",
"@types/markdown-it": "^14.1.2",
"@types/open": "^6.2.1",
"bun": "^1.1.20",
"bun": "^1.1.21",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"d3": "^7.9.0",
"daisyui": "^4.12.7",
"daisyui": "^4.12.10",
"dotenv": "^16.4.5",
"enhanced-ms": "^3.0.0",
"file-saver": "^2.0.5",
"flat": "^6.0.1",
"globby": "^14.0.1",
"google-auth-library": "^9.11.0",
"globby": "^14.0.2",
"google-auth-library": "^9.12.0",
"googleapis": "^140.0.1",
"js-yaml": "^4.1.0",
"json-stable-stringify": "^1.1.1",
Expand All @@ -67,23 +69,23 @@
"md5": "^2.3.0",
"minimist": "^1.2.8",
"monaco-editor": "^0.50.0",
"mongodb": "^6.7.0",
"next-auth": "^5.0.0-beta.19",
"mongodb": "^6.8.0",
"next-auth": "^5.0.0-beta.20",
"nodemailer": "^6.9.14",
"octokit": "^4.0.2",
"open": "^10.1.0",
"openai": "^4.52.7",
"openai": "^4.53.2",
"p-map": "^7.0.2",
"peek-log": "^0.0.8",
"polyfill-text-decoder-stream": "^0.0.9",
"pretty-ms": "^9.0.0",
"promise-all-properties": "^4.0.0",
"pretty-ms": "^9.1.0",
"promise-all-properties": "^4.0.4",
"rambda": "^9.2.1",
"react-api-doc": "^0.0.9",
"react-hook-form": "^7.52.0",
"react-hook-form": "^7.52.1",
"react-hot-toast": "^2.4.1",
"react-markdown": "^9.0.1",
"sflow": "^1.11.2",
"sflow": "^1.15.20",
"snoflow": "^1.9.1",
"sparse-bitfield": "^3.0.3",
"tailwind-merge": "^2.4.0",
Expand All @@ -93,33 +95,33 @@
"ts-pattern": "^5.2.0",
"unwind-array": "^1.1.4",
"use-swr-component": "^0.0.5",
"vercel": "^34.3.0",
"yaml": "^2.4.5",
"vercel": "^34.4.0",
"yaml": "^2.5.0",
"zod": "^3.23.8",
"zx": "^8.1.3"
"zx": "^8.1.4"
},
"devDependencies": {
"@types/bun": "^1.1.5",
"@types/bun": "^1.1.6",
"@types/js-yaml": "^4.0.9",
"@types/json-stable-stringify": "^1.0.36",
"@types/lodash-es": "^4.17.12",
"@types/md5": "^2.3.5",
"@types/minimist": "^1.2.5",
"@types/node": "^20",
"@types/node": "^20.14.13",
"@types/nodemailer": "^6.4.15",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"eslint": "^8.57.0",
"eslint-config-next": "14.2.4",
"next": "^14.2.4",
"postcss": "^8",
"next": "^14.2.5",
"postcss": "^8.4.40",
"prettier-plugin-organize-imports": "^3.2.4",
"prettier-plugin-packagejson": "^2.5.0",
"prettier-plugin-packagejson": "^2.5.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"tailwindcss": "^3.4.1",
"tailwindcss": "^3.4.7",
"ts-toolbelt": "^9.6.0",
"typescript": "^5.5.2"
"typescript": "^5.5.4"
},
"peerDependencies": {
"typescript": "^5.4.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/mongodb-pipeline-ts/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function TaskError(error: any) {
return {
state: "error" as const,
mtime: new Date(),
error: String(error.message || error),
error: (String(error) + "\n" + String(error.stack ?? "")).trim(),
};
}
export function TaskDataOrNull<T>(e?: Task<T>) {
Expand Down
10 changes: 10 additions & 0 deletions src/bypassRepos.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { isRepoBypassed } from "./bypassRepos";

it("bypass", async () => {
const bypassRepo = "https://github.com/loopyd/ComfyUI-FD-Tagger";
expect(isRepoBypassed(bypassRepo)).toBeTruthy();
});
it("allow", async () => {
const allowRepo = "https://github.com/snomiao/ComfyUI-FD-Tagger";
expect(isRepoBypassed(allowRepo)).toBeFalsy();
});
8 changes: 8 additions & 0 deletions src/bypassRepos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { z } from "zod";
import { yaml } from "./utils/yaml";

export const bypassRepos = z
.string()
.array()
.parse(yaml.parse(await Bun.file("./bypass.yaml").text()).bypass_repos);
export const isRepoBypassed = (repo: string) => bypassRepos.some((reg) => repo.match(reg));
20 changes: 10 additions & 10 deletions src/createComfyRegistryPullRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ import { parsePulls } from "./parsePullsState";
export async function createComfyRegistryPullRequests(upstreamRepoUrl: string) {
const forkedRepo = await createGithubForkForRepo(upstreamRepoUrl);

const PR_REQUESTS_updateTomlLicense = await clone_modify_push_Branches_for_updateTomlLicense(
upstreamRepoUrl,
forkedRepo.html_url,
);
const prs_updateTomlLicense = await pMap(
PR_REQUESTS_updateTomlLicense,
async ({ type, ...prInfo }) => await createGithubPullRequest({ ...prInfo }),
);
// const PR_REQUESTS_updateTomlLicense = await clone_modify_push_Branches_for_updateTomlLicense(
// upstreamRepoUrl,
// forkedRepo.html_url,
// );
// const prs_updateTomlLicense = await pMap(
// PR_REQUESTS_updateTomlLicense,
// async ({ type, ...prInfo }) => await createGithubPullRequest({ ...prInfo }),
// );

console.log("prs_updateTomlLicense PRs DONE");
// console.log("prs_updateTomlLicense PRs DONE");

const PR_REQUESTS = await clone_modify_push_Branches(upstreamRepoUrl, forkedRepo.html_url);
const prs = await pMap(PR_REQUESTS, async ({ type, ...prInfo }) => await createGithubPullRequest({ ...prInfo }));

console.log("Registry PRs DONE");

return ([...prs, ...prs_updateTomlLicense] as GithubPull[]).map((e) => parsePulls([e])[0]);
return ([...prs] as GithubPull[]).map((e) => parsePulls([e])[0]);
}

export async function clone_modify_push_Branches_for_updateTomlLicense(upstreamUrl: string, forkUrl: string) {
Expand Down
37 changes: 25 additions & 12 deletions src/createGithubForkForRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { createGithubFork } from "./gh/createGithubFork";
import { ghUser } from "./ghUser";
import { parseUrlRepoOwner } from "./parseOwnerRepo";

if (import.meta.main) {
console.log(await createGithubForkForRepo("https://github.com/comfyanonymous/ComfyUI_TensorRT"));
}

/**
* this function creates a fork of the upstream repo,
* fork to the FORK_OWNER, and add a prefix to the repo name
Expand All @@ -18,8 +22,26 @@ import { parseUrlRepoOwner } from "./parseOwnerRepo";
* @param upstreamRepoUrl
* @returns forked repo info
*/
export async function createGithubForkForRepo(upstreamRepoUrl: string) {
// debug
export async function createGithubForkForRepo(
upstreamRepoUrl: string,
{ forkUrl = createGithubForkUrlForRepo(upstreamRepoUrl) } = {},
) {
console.debug(
`
Forking ${upstreamRepoUrl}
into ${forkUrl}
`.trim(),
);
const forked = await createGithubFork(upstreamRepoUrl, forkUrl);
if (forked.html_url !== forkUrl)
DIE(
new Error(
"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: .....)",
),
);
return forked;
}
export function createGithubForkUrlForRepo(upstreamRepoUrl: string) {
// console.log(`* Change env.SALT=${salt} will fork into a different repo`);
const upstream = parseUrlRepoOwner(upstreamRepoUrl);
const argv = minimist(process.argv.slice(2));
Expand All @@ -28,14 +50,5 @@ export async function createGithubForkForRepo(upstreamRepoUrl: string) {
const forkRepoName = (FORK_PREFIX && `${FORK_PREFIX}${upstream.repo}-${repo_hash}`) || upstream.repo;
const forkDst = `${FORK_OWNER}/${forkRepoName}`;
const forkUrl = `https://github.com/${forkDst}`;
console.debug(`
Forking ${upstreamRepoUrl}
into ${forkUrl}
`.trim());
const forked = await createGithubFork(upstreamRepoUrl, forkUrl);
if (forked.html_url !== forkUrl)
DIE(
"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: .....)",
);
return forked;
return forkUrl;
}
Loading

0 comments on commit 9f367ee

Please sign in to comment.