comfy-pr 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +225 -0
  3. package/next-env.d.ts +5 -0
  4. package/package.json +115 -0
  5. package/src/CMNodes.ts +60 -0
  6. package/src/CNRepos.ts +72 -0
  7. package/src/CRNodes.ts +26 -0
  8. package/src/CRPulls.ts +4 -0
  9. package/src/FORK_OWNER.ts +5 -0
  10. package/src/FORK_PREFIX.ts +5 -0
  11. package/src/FollowRules.ts +25 -0
  12. package/src/GIT_USEREMAIL.ts +5 -0
  13. package/src/GIT_USERNAME.ts +9 -0
  14. package/src/GithubIssueComments.ts +3 -0
  15. package/src/PushedBranch.ts +3 -0
  16. package/src/Totals.ts +9 -0
  17. package/src/TrackingPRs.ts +12 -0
  18. package/src/WorkerInstances.ts +89 -0
  19. package/src/analyzePullsStatus.ts +115 -0
  20. package/src/analyzeTotals.test.ts +5 -0
  21. package/src/analyzeTotals.ts +114 -0
  22. package/src/checkComfyActivated.ts +39 -0
  23. package/src/cli.test.ts +0 -0
  24. package/src/cli.ts +40 -0
  25. package/src/clone_modify_push_Branches.ts +21 -0
  26. package/src/createComfyRegistryPRsFromCandidates.ts +55 -0
  27. package/src/createComfyRegistryPullRequests.ts +22 -0
  28. package/src/createGithubForkForRepo.ts +37 -0
  29. package/src/createGithubPullRequest.ts +94 -0
  30. package/src/createIssueComment.ts +29 -0
  31. package/src/fetchCMNodes.ts +22 -0
  32. package/src/fetchComfyRegistryNodes.ts +11 -0
  33. package/src/fetchCurrentGeoInfo.ts +6 -0
  34. package/src/fetchRelatedPullWithComments.ts +15 -0
  35. package/src/fetchRepoDescriptionMap.ts +15 -0
  36. package/src/followRuleSchema.ts +69 -0
  37. package/src/getActivatedShell.ts +18 -0
  38. package/src/getBranchWorkingDir.ts +16 -0
  39. package/src/getRepoWorkingDir.ts +6 -0
  40. package/src/ghUser.ts +6 -0
  41. package/src/index.ts +22 -0
  42. package/src/initializeFollowRules.ts +26 -0
  43. package/src/makePublishBranch.ts +58 -0
  44. package/src/makeTomlBranch.ts +53 -0
  45. package/src/matchRelatedPulls.ts +25 -0
  46. package/src/muteInstances.ts +16 -0
  47. package/src/parseIssueUrl.ts +6 -0
  48. package/src/parseOwnerRepo.ts +33 -0
  49. package/src/parsePullUrl.ts +6 -0
  50. package/src/parsePullsState.ts +6 -0
  51. package/src/parseTitleBodyOfMarkdown.ts +8 -0
  52. package/src/postSlackMessage.ts +21 -0
  53. package/src/preload.ts +30 -0
  54. package/src/pullStatusFollowSchema.ts +12 -0
  55. package/src/readTemplateTitle.ts +11 -0
  56. package/src/summaryLastPullComment.ts +8 -0
  57. package/src/tomlFillDescription.ts +17 -0
  58. package/src/updateCMNodesDuplicationWarnings.ts +56 -0
  59. package/src/updateCMRepos.ts +27 -0
  60. package/src/updateCNRepos.ts +58 -0
  61. package/src/updateCNReposCRPullsComments.ts +41 -0
  62. package/src/updateCNReposInfo.ts +57 -0
  63. package/src/updateCNReposPRCandidate.ts +85 -0
  64. package/src/updateCNReposPulls.ts +28 -0
  65. package/src/updateCNReposPullsDashboard.ts +49 -0
  66. package/src/updateCNReposRelatedPulls.ts +25 -0
  67. package/src/updateCRNodes.ts +50 -0
  68. package/src/updateCRRepos.ts +26 -0
  69. package/src/updateComfyTotals.ts +40 -0
  70. package/src/updateFollowRuleSet.ts +153 -0
  71. package/src/updateOutdatedPullsTemplates.ts +137 -0
  72. package/src/updateSlackMessages.ts +43 -0
  73. package/tailwind.config.ts +20 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,52 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [0.2.7](https://github.com/drip-art/Comfy-Registry-PR/compare/v0.2.5...v0.2.7) (2024-06-20)
6
+
7
+ ### Features
8
+
9
+ - **details:** show pr status details ([df100f1](https://github.com/drip-art/Comfy-Registry-PR/commit/df100f1706f66b5865e06b37bc8e0012c7ee14a8))
10
+ - **details:** show pr status details ([a8ce595](https://github.com/drip-art/Comfy-Registry-PR/commit/a8ce59567e95be57d85d6364212d14fd46233ee6))
11
+ - **dump:** api ok ([9f0e9f5](https://github.com/drip-art/Comfy-Registry-PR/commit/9f0e9f5c2c0577df01b9b8ab9f6d3a06bf6b533b))
12
+ - **dump:** api ok ([700fb33](https://github.com/drip-art/Comfy-Registry-PR/commit/700fb33efe1f445846ec3405a1cef25ee830ccfd))
13
+ - **dump:** build ok ([bc70604](https://github.com/drip-art/Comfy-Registry-PR/commit/bc706044d4e901140105bb1f065d653024bb1908))
14
+ - **dump:** build ok ([c42f399](https://github.com/drip-art/Comfy-Registry-PR/commit/c42f399ec79e3ea5e9b294e21ec4a56a3560e0b3))
15
+ - **feat-activate-in-bun:** got activated shell ([552ab4f](https://github.com/drip-art/Comfy-Registry-PR/commit/552ab4f2a14577786fc6a9a51d75bef5533be81b))
16
+ - **feat-activate-in-bun:** got activated shell ([5661ca9](https://github.com/drip-art/Comfy-Registry-PR/commit/5661ca9c2e9509f3b457a124927865ec45a083dc))
17
+ - **follow-up-rules:** editor ([a8003de](https://github.com/drip-art/Comfy-Registry-PR/commit/a8003deec8607f579715f8765ae46871f5150740))
18
+ - **follow-up-rules:** editor ([8555441](https://github.com/drip-art/Comfy-Registry-PR/commit/8555441d7a4d823ea020d91693d3fea02c5fd7e7))
19
+ - **follow:** rule editor ([db71370](https://github.com/drip-art/Comfy-Registry-PR/commit/db713706adb58ce8630b06d09b7120b296f2a032))
20
+ - **follow:** rule editor ([93c56c0](https://github.com/drip-art/Comfy-Registry-PR/commit/93c56c08fe1c0c9f6361964347276e78912019ba))
21
+
22
+ ### Bug Fixes
23
+
24
+ - **follow-rule:** allow head match ([2ffe576](https://github.com/drip-art/Comfy-Registry-PR/commit/2ffe57675ea172ccc1fb45296cd2229a6b3171ab))
25
+ - **main:** adjust crpulls fresh span, enable r ([63369d3](https://github.com/drip-art/Comfy-Registry-PR/commit/63369d3ae79f573343fe54594a74f105634088fe))
26
+ - **main:** allow yaml update ([326b7a4](https://github.com/drip-art/Comfy-Registry-PR/commit/326b7a4bddb8ececd1617a0796d82f1fcb989143))
27
+ - **main:** candidates and error show ([93994ec](https://github.com/drip-art/Comfy-Registry-PR/commit/93994ec843e11909c37c2601baa0b72da141e6d6))
28
+ - **main:** candidates and error show ([49cccde](https://github.com/drip-art/Comfy-Registry-PR/commit/49cccde43c07023ec8506a75d7970d705efb275c))
29
+ - **main:** deprecate zx ([c27d1ef](https://github.com/drip-art/Comfy-Registry-PR/commit/c27d1efb6b305633f3577a013b1b9075f0a8146a))
30
+ - **main:** deprecate zx ([e72e335](https://github.com/drip-art/Comfy-Registry-PR/commit/e72e3357d7b6e476d83cabc7ff7b616d6d4237b9))
31
+ - **main:** optimize updateCNReposPulls index ([8416678](https://github.com/drip-art/Comfy-Registry-PR/commit/8416678a4817d1fa98ee53a92862e2a6beec8b46))
32
+ - **main:** optimize updateCNReposPulls index ([6321885](https://github.com/drip-art/Comfy-Registry-PR/commit/6321885f0c91d2ecad6defaf4f26f87193503d96))
33
+ - **main:** second round ([0b08f2a](https://github.com/drip-art/Comfy-Registry-PR/commit/0b08f2a343232dba1741376c12a91b6121eee7c9))
34
+ - **main:** second round ([83c791e](https://github.com/drip-art/Comfy-Registry-PR/commit/83c791e202d888e56f44a7c6bd65d89faeb89039))
35
+ - **main:** stage ([162bee0](https://github.com/drip-art/Comfy-Registry-PR/commit/162bee02999731fcb45e0d5fd01c9c4426e202a3))
36
+ - **main:** stage ([c930f6e](https://github.com/drip-art/Comfy-Registry-PR/commit/c930f6e7ea4b55d14b9a3f1909222e158d1c63a9))
37
+ - **main:** swagger ([96c6878](https://github.com/drip-art/Comfy-Registry-PR/commit/96c6878f5bb68f8540c845621c226d8867e24c94))
38
+ - **main:** swagger ([8c2b217](https://github.com/drip-art/Comfy-Registry-PR/commit/8c2b2170e37e0176f7a7194fbb57db553a1beaba))
39
+ - **misc:** fix vars ([501145a](https://github.com/drip-art/Comfy-Registry-PR/commit/501145af13966727b4df45c11bbffa3be71ae552))
40
+ - **misc:** fix vars ([14b0d6c](https://github.com/drip-art/Comfy-Registry-PR/commit/14b0d6c10c009ccac6b9276d8689142163f98d9f))
41
+ - **mongodb-pipeline-ts:** add satisfies ([a08c7f8](https://github.com/drip-art/Comfy-Registry-PR/commit/a08c7f8bae341beceacb4c974cb59e59bb951b0b))
42
+ - **mongodb-pipeline-ts:** expression ([2ad8563](https://github.com/drip-art/Comfy-Registry-PR/commit/2ad8563e5799a0ec2b069a1afe4332dd5c5023cc))
43
+ - **mongodb-pipeline-ts:** use partial for stage ([239802a](https://github.com/drip-art/Comfy-Registry-PR/commit/239802ae02d2581904890483aa95c54e2a11d996))
44
+ - **pipeline:** types use array-path ([fa3ba69](https://github.com/drip-art/Comfy-Registry-PR/commit/fa3ba6965a729a16a0f5858c2dc69230d6ecc644))
45
+ - **pipeline:** types use array-path ([647279c](https://github.com/drip-art/Comfy-Registry-PR/commit/647279c5a55c2719e1d269477e19c9dffc3723a4))
46
+ - **pipeline:** use PipelineLauncher ([4c3d37e](https://github.com/drip-art/Comfy-Registry-PR/commit/4c3d37e35436442a114847d902f6a204b6c8f042))
47
+ - **pr-comments:** value typo ([57a6dc4](https://github.com/drip-art/Comfy-Registry-PR/commit/57a6dc41b551cb797315c9d855fb629f8e98bd8f))
48
+ - **src:** simplify pipeline ([0ce3810](https://github.com/drip-art/Comfy-Registry-PR/commit/0ce3810b62a6be9444114fb204fde38b0ae336d0))
49
+ - **src:** simplify pipeline ([b0316b0](https://github.com/drip-art/Comfy-Registry-PR/commit/b0316b09cf9aa1bc4eeccb4e43502a53eaa3ae96))
50
+ - **src:** sort totals ([126977d](https://github.com/drip-art/Comfy-Registry-PR/commit/126977d2ab08e12ebc6e3e61edacb279d968fd57))
51
+ - **workflows:** run tests ([e8109b0](https://github.com/drip-art/Comfy-Registry-PR/commit/e8109b0cdd3e8f3433817f9218ae230243551cb1))
52
+ - **zx:** restore zx ([dd5bc17](https://github.com/drip-art/Comfy-Registry-PR/commit/dd5bc1700b64d68a0a08ca8c5ed3f72c997f3c9f))
package/README.md ADDED
@@ -0,0 +1,225 @@
1
+ # Comfy-PR
2
+
3
+ Make PRs that publishes ComfyUI Custom Nodes to [ComfyUI Registry](https://www.comfyregistry.org/).
4
+
5
+ ## Project Goals: (aka roadmap)
6
+
7
+ ### Cli usage:
8
+
9
+ - [x] fork repo
10
+ - [x] clone repo locally
11
+ - [x] create pyproject branch, run comfy node init . Push branch.
12
+ - [x] create publish branch, create in a Github workflow file. Push branch.
13
+ - [x] create PR to original repository with template PR description.
14
+ - [x] Submit PR
15
+ - [x] Clean local debris before clone
16
+ - [/] DOING: Export PR status into csv for @haohao
17
+
18
+ ### Github Actions Worker
19
+
20
+ - [x] Fetch repos from CM & CR list
21
+ - [x] Make diff
22
+ - [x] Notify to slack channel
23
+ - [x] Fetch repo status (private or archived or ...)
24
+ - [x] Fetch pr status (open / merged / closed) + comments
25
+ - [x] Fetch pr comments
26
+ - [x] Automaticaly find candidates, and do the cli does
27
+ - [x] Mention related prs in dashboard https://github.com/drip-art/Comfy-Registry-PR/issues/1
28
+ - [x] Analyze Totals
29
+ - [ ] Follow-up prs by state
30
+ - [ ] Issues Comment
31
+ - [ ] Slack
32
+ - [ ] Email
33
+ - [ ] Delete the forked repo which is Merged
34
+
35
+ ### Web Site https://comfy-pr.vercel.app
36
+
37
+ - [x] A dashboard csv/yaml exporter site for @haohao
38
+ - [ ]
39
+
40
+ ## Usages
41
+
42
+ ### CLI Usage: Get Started by
43
+
44
+ ```
45
+ bunx comfy-pr [...GITHUB_REPO_URLS]
46
+ ```
47
+
48
+ ### 1. Setup Envs
49
+
50
+ A demo .env should be sth like:
51
+
52
+ ```sh
53
+ # your github token
54
+ GH_TOKEN=ghp_WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
55
+
56
+ # the pr source organization/ leave it blank to use yourself's account.
57
+ FORK_OWNER="ComfyNodePRs"
58
+
59
+ # PR prefix
60
+ FORK_PREFIX="PR-"
61
+ ```
62
+
63
+ #### Github API Token (GH_TOKEN)
64
+
65
+ GO https://github.com/settings/tokens?type=beta to get an Github Access key
66
+
67
+ Check 3 permissions for all of your repositories
68
+
69
+ - Pull requests Access: Read and write
70
+ - Workflows Access: Read and write
71
+ - Metadata Access: Read-only
72
+
73
+ And save your GH_TOKEN into .env file
74
+
75
+ #### Github SSH Key (.ssh/id_rsa, .ssh/id_rsa.pub)
76
+
77
+ Must provide to push code automaticaly, btw prob. you've already setup.
78
+
79
+ Run `ssh-keygen`, got `id_rsa.pub`, Then add into here https://github.com/settings/keys
80
+
81
+ ### 2. Run!
82
+
83
+ Ways to run this script
84
+
85
+ 1. Local run
86
+ 2. Docker run (also local)
87
+ 3. Docker run at cloud (TODO)
88
+
89
+ #### 1. Launch by Docker Compose
90
+
91
+ After configured your .env file, run docker compose build and up.
92
+
93
+ ```sh
94
+ git clone https://github.com/drip-art/Comfy-Registry-PR
95
+ cd Comfy-Registry-PR
96
+ docker compose build
97
+ docker compose up
98
+ ```
99
+
100
+ #### 2. Docker usage (not stable)
101
+
102
+ ```sh
103
+ docker run --rm -it \
104
+ -v $HOME/.ssh:/root/.ssh:ro \
105
+ -e GH_TOKEN=ghp_WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW \
106
+ -e REPO=https://github.com/snomiao/ComfyNode-Registry-test \
107
+ snomiao/comfy-registry-pr
108
+ ```
109
+
110
+ #### 3. Run native in Unix/Linux/MacOS/WSL
111
+
112
+ ```sh
113
+ git clone https://github.com/drip-art/Comfy-Registry-PR
114
+
115
+ # setup comfy-cli environment
116
+ cd Comfy-Registry-PR
117
+ python3 -m venv .venv
118
+ chmod +x ./.venv/bin/*
119
+ source ./.venv/bin/activate
120
+ pip3 install comfy-cli
121
+
122
+
123
+
124
+ # setup bun for js-script
125
+ curl -fsSL https://bun.sh/install | bash
126
+ bun i
127
+
128
+ # and
129
+ bun src/cli.ts [REPO_PATH_NEED_TO_PR]
130
+ # for example
131
+ bun src/cli.ts https://github.com/snomiao/ComfyNode-Registry-test
132
+
133
+ ```
134
+
135
+ #### 4. Run natively in Windows
136
+
137
+ ```bat
138
+
139
+ git clone https://github.com/drip-art/Comfy-Registry-PR
140
+
141
+ @REM setup comfy-cli environment
142
+ cd Comfy-Registry-PR
143
+ python3 -m venv .venv
144
+ .\.venv\Scripts\activate
145
+ pip3 install comfy-cli
146
+
147
+ @REM run with tsx
148
+ npx -y cross-env REPO=https://github.com/snomiao/ComfyNode-Registry-test npx -y tsx src/cli.ts
149
+
150
+ ```
151
+
152
+ #### Other Configurations in dockerfile
153
+
154
+ Don't change it unless you know what you are doing.
155
+
156
+ ```dockerfile
157
+
158
+ ENV FORK_OWNER=drip-art
159
+ ENV FORK_PREFIX=PR-
160
+
161
+ # Unset it into current authorized user's name and email (from your github api token).
162
+ ENV GIT_USEREMAIL=comfy-ci@drip.art
163
+ ENV GIT_USERNAME=comfy-ci
164
+ ```
165
+
166
+ ## Development
167
+
168
+ ### Cli
169
+
170
+ ```sh
171
+ # Create comfy pr dir and go into it
172
+ mkdir comfy-pr
173
+ cd comfy-pr
174
+
175
+ # Prepare code and environments
176
+ git clone https://github.com/drip-art/Comfy-Registry-PR .
177
+
178
+ # Prepare bun
179
+ # go here - [Installation \| Bun Docs]( https://bun.sh/docs/installation )
180
+
181
+ # Install project
182
+ bun i
183
+
184
+ # Prepare bun
185
+ bun i
186
+ ```
187
+
188
+ ### Github Action Worker & server
189
+
190
+ 1. Setup envs in the usages section above (plz check bun src/cli.ts runnable first)
191
+
192
+ 2. Run mongodb with docker compose
193
+
194
+ ```sh
195
+ docker compose -f docker-compose.mongodb.yml up
196
+ ```
197
+
198
+ ```yaml
199
+ services:
200
+ mongdb:
201
+ restart: always
202
+ image: mongo
203
+ ports: ["27017:27017"]
204
+ volumes: [./data/mongodb:/data/db]
205
+ ```
206
+
207
+ And fill URI into env
208
+
209
+ ```env
210
+ MONGODB_URI=mongodb://localhost:27017
211
+ ```
212
+
213
+ 3. Play with codes...
214
+
215
+ ```sh
216
+ # To initialize your database, run:
217
+ bun src/index.ts
218
+
219
+ # To start develop in any of other scripts:
220
+ # Feel free to run any scripts in src/, they are safe to re-run and stop in any time.
221
+ bun src/THAT_FILE_YOU_WANT_TO_RUN.ts
222
+
223
+ # To check if you didn't break anything?
224
+ bun test --watch
225
+ ```
package/next-env.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+
4
+ // NOTE: This file should not be edited
5
+ // see https://nextjs.org/docs/basic-features/typescript for more information.
package/package.json ADDED
@@ -0,0 +1,115 @@
1
+ {
2
+ "name": "comfy-pr",
3
+ "version": "0.2.7",
4
+ "description": "Make PRs that publishes ComfyUI Custom Nodes to [ComfyUI Registry]( https://www.comfyregistry.org/ ).",
5
+ "keywords": [],
6
+ "license": "ISC",
7
+ "author": "snomiao <snomiao@gmail.com>",
8
+ "type": "module",
9
+ "exports": {
10
+ "import": "./src/index.ts",
11
+ "types": "./index.ts"
12
+ },
13
+ "main": "index.ts",
14
+ "module": "index.ts",
15
+ "bin": {
16
+ "comfy-pr": "./src/cli.ts"
17
+ },
18
+ "files": [
19
+ "*.ts"
20
+ ],
21
+ "scripts": {
22
+ "_postinstall": "bun ./src/muteInstances.ts",
23
+ "build": "next build",
24
+ "dev": "next dev",
25
+ "lint": "next lint",
26
+ "prerelease": "bun run build && bun run test && vercel --prod",
27
+ "release": "bunx standard-version && npm publish",
28
+ "start": "next start",
29
+ "test": "bun test"
30
+ },
31
+ "dependencies": {
32
+ "@auth/mongodb-adapter": "^3.2.0",
33
+ "@ctrl/mac-address": "^3.0.3",
34
+ "@keyv/mongo": "^2.2.8",
35
+ "@keyv/sqlite": "^3.6.7",
36
+ "@monaco-editor/react": "^4.6.0",
37
+ "@slack/web-api": "^7.0.4",
38
+ "@snomiao/die": "^1.0.6",
39
+ "@trpc/server": "^10.45.2",
40
+ "@types/d3": "^7.4.3",
41
+ "@types/jest": "^29.5.12",
42
+ "@types/js-yaml": "^4.0.9",
43
+ "@types/minimist": "^1.2.5",
44
+ "@types/swagger-ui-react": "^4.18.3",
45
+ "@types/uuid": "^9.0.8",
46
+ "chatgpt-template": "^1.1.3",
47
+ "d3": "^7.9.0",
48
+ "daisyui": "^4.12.2",
49
+ "dotenv": "^16.4.5",
50
+ "enhanced-ms": "^3.0.0",
51
+ "execa": "^9.1.0",
52
+ "flat": "^6.0.1",
53
+ "js-yaml": "^4.1.0",
54
+ "json-stable-stringify": "^1.1.1",
55
+ "json-to-zod": "^1.1.2",
56
+ "keyv": "^4.5.4",
57
+ "keyv-cached-with": "^0.0.13",
58
+ "keyv-dir-store": "^0.0.3",
59
+ "lefthook": "^1.6.15",
60
+ "lodash-es": "^4.17.21",
61
+ "md5": "^2.3.0",
62
+ "minimist": "^1.2.8",
63
+ "mongodb": "^6.7.0",
64
+ "mongodb-altas-api-sdk": "^0.1.1",
65
+ "next-auth": "^5.0.0-beta.19",
66
+ "nodemailer": "^6.9.13",
67
+ "octokit": "^4.0.2",
68
+ "p-map": "^7.0.2",
69
+ "peek-log": "^0.0.4",
70
+ "promise-all-properties": "^4.0.0",
71
+ "rambda": "^9.2.0",
72
+ "react-hook-form": "^7.51.5",
73
+ "react-markdown": "^9.0.1",
74
+ "react-use": "^17.5.0",
75
+ "snorun": "^1.4.0",
76
+ "swagger-ui-react": "^5.17.14",
77
+ "swr": "^2.2.5",
78
+ "timing-with": "^0.0.4",
79
+ "toml": "^3.0.0",
80
+ "trpc-openapi": "^1.2.0",
81
+ "trpc-swagger": "^1.2.6",
82
+ "ts-pattern": "^5.2.0",
83
+ "use-swr-component": "^0.0.5",
84
+ "uuid": "^10.0.0",
85
+ "yaml": "^2.4.5",
86
+ "yargs": "^17.7.2",
87
+ "zod": "^3.23.8",
88
+ "zx": "^8.1.2"
89
+ },
90
+ "devDependencies": {
91
+ "@tanstack/react-table": "^8.17.3",
92
+ "@types/bun": "^1.1.5",
93
+ "@types/json-stable-stringify": "^1.0.36",
94
+ "@types/lodash-es": "^4.17.12",
95
+ "@types/md5": "^2.3.5",
96
+ "@types/node": "^20",
97
+ "@types/react": "^18",
98
+ "@types/react-dom": "^18",
99
+ "axios": "^1.6.8",
100
+ "eslint": "^8",
101
+ "eslint-config-next": "14.2.4",
102
+ "next": "^14.2.4",
103
+ "postcss": "^8",
104
+ "prettier-plugin-organize-imports": "^3.2.4",
105
+ "prettier-plugin-packagejson": "^2.5.0",
106
+ "react": "^18.3.1",
107
+ "react-dom": "^18.3.1",
108
+ "tailwindcss": "^3.4.1",
109
+ "typescript": "^5.4.5"
110
+ },
111
+ "peerDependencies": {
112
+ "typescript": "^5.4.5"
113
+ },
114
+ "title": "Comfy-PR"
115
+ }
package/src/CMNodes.ts ADDED
@@ -0,0 +1,60 @@
1
+ import jsonStableStringify from "json-stable-stringify";
2
+ import md5 from "md5";
3
+ import type { ObjectId } from "mongodb";
4
+ import { db } from "./db";
5
+ import { fetchCMNodes } from "./fetchCMNodes";
6
+ import { type SlackMsg } from "./slack/SlackMsgs";
7
+ import { updateCMNodesDuplicationWarnings } from "./updateCMNodesDuplicationWarnings";
8
+
9
+ // Raw version maybe duplicated with id or reference
10
+ type CMNodeRaw = Awaited<ReturnType<typeof fetchCMNodesWithHash>>[number];
11
+ export type CMNode = CMNodeRaw & {
12
+ repo_id?: ObjectId;
13
+ duplicated?: {
14
+ [k: string]: { hashes: string[]; slackNotification: SlackMsg };
15
+ };
16
+ };
17
+ export const CMNodes = db.collection<CMNode>("CMNodes");
18
+ await CMNodes.createIndex({ mtime: -1 });
19
+ await CMNodes.createIndex({ hash: 1 }, { unique: true }).catch(() => {});
20
+
21
+ if (import.meta.main) {
22
+ console.time("CMNodes");
23
+ console.log(await updateCMNodes());
24
+ // check dups
25
+ console.timeLog("CMNodes");
26
+ const all = await CMNodes.countDocuments({});
27
+ console.timeLog("CMNodes");
28
+ const dups = await CMNodes.countDocuments({ duplicated: { $exists: true } });
29
+ console.timeEnd("CMNodes");
30
+ console.log("CMNodes updated, duplicates:", dups, "all:", all);
31
+ }
32
+ export async function updateCMNodes() {
33
+ const nodes = await fetchCMNodesWithHash();
34
+ console.log("CMNodes updating (" + nodes.length + " nodes)");
35
+
36
+ // updating nodes
37
+ const updateResult = await CMNodes.bulkWrite(
38
+ nodes.flatMap((node) => ({
39
+ updateOne: {
40
+ filter: { hash: node.hash },
41
+ update: { $set: node },
42
+ upsert: true,
43
+ },
44
+ })),
45
+ { ordered: false },
46
+ );
47
+ // delete outdated
48
+ // await CMNodes.deleteMany({ hash: { $nin: nodes.map(prop("hash")) } });
49
+
50
+ await updateCMNodesDuplicationWarnings(nodes);
51
+
52
+ return [updateResult];
53
+ }
54
+
55
+ async function fetchCMNodesWithHash() {
56
+ return (await fetchCMNodes()).map((e) => ({
57
+ ...e,
58
+ hash: md5("SALT=Bvxmh8mGYh6qzLGE " + jsonStableStringify(e)),
59
+ }));
60
+ }
package/src/CNRepos.ts ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env bun
2
+ /*
3
+ bun index.ts
4
+ */
5
+ import type { ObjectId, WithId } from "mongodb";
6
+ import "react-hook-form";
7
+ import { type CMNode } from "./CMNodes";
8
+ import { type CRNode } from "./CRNodes";
9
+ import { db } from "./db";
10
+ import { gh } from "./gh";
11
+ import { type RelatedPull } from "./matchRelatedPulls";
12
+ import type { GithubPullParsed } from "./parsePullsState";
13
+ import { type SlackMsg } from "./slack/SlackMsgs";
14
+ import { type Task } from "./utils/Task";
15
+
16
+ type Email = {
17
+ from?: string;
18
+ title: string;
19
+ body: string;
20
+ to: string;
21
+ };
22
+
23
+ type Sent = {
24
+ slack?: SlackMsg;
25
+ emails?: Email[];
26
+ };
27
+
28
+ type GithubIssueComment = Awaited<ReturnType<typeof gh.issues.getComment>>["data"];
29
+ type GithubIssue = Awaited<ReturnType<typeof gh.issues.get>>["data"];
30
+ type GithubRepo = Awaited<ReturnType<typeof gh.repos.get>>["data"];
31
+ export type CRType = "pyproject" | "publichcr";
32
+ export type CRPull = RelatedPull & {
33
+ edited?: Task<boolean>;
34
+ comments?: Task<Pick<GithubIssueComment, "body">[]>;
35
+ issue?: Task<Pick<GithubIssue, "number" | "html_url" | "body" | "updated_at">>;
36
+ };
37
+
38
+ export type CustomNodeRepo = {
39
+ repository: string;
40
+ info?: Task<Pick<GithubRepo, "html_url" | "archived" | "default_branch" | "private">>;
41
+
42
+ /** @deprecated use cr_ids or on_registry */
43
+ cr?: Pick<WithId<CRNode>, "_id" | "id" | "name">;
44
+
45
+ cr_ids?: ObjectId[];
46
+ on_registry?: Task<boolean>; // check if cr_ids is not empty
47
+
48
+ /** @deprecated use cm_ids */
49
+ cm?: Pick<WithId<CMNode>, "_id" | "id" | "title">;
50
+ cm_ids?: ObjectId[];
51
+
52
+ // cache
53
+ pulls?: Task<GithubPullParsed[]>;
54
+
55
+ crPulls?: Task<CRPull[]>;
56
+
57
+ /** @deprecated TODO: NOT IMPLEMENTD */
58
+ crPull_ids: ObjectId[];
59
+
60
+ candidate?: Task<boolean>;
61
+ // createFork?: Task<GithubRepo>;
62
+ // createBranches?: Task<{ type: CRType; assigned: Worker } & PushedBranch>[];
63
+
64
+ /** @deprecated use CRPulls.pull */
65
+ createdPulls?: Task<GithubPullParsed[]>;
66
+ };
67
+ export type CNRepo = CustomNodeRepo;
68
+ export const CNRepos = db.collection<CNRepo>("CNRepos");
69
+ await CNRepos.createIndex({ repository: 1 }, { unique: true });
70
+
71
+ // fix cr null, it should be not exists
72
+ await CNRepos.updateMany({ cr: null as unknown as WithId<CRNode> }, { $unset: { cr: 1 } });
package/src/CRNodes.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { $pipeline } from "@/packages/mongodb-pipeline-ts/$pipeline";
2
+ import type { ObjectId } from "mongodb";
3
+ import pMap from "p-map";
4
+ import { peekYaml } from "peek-log";
5
+ import { CNRepos } from "./CNRepos";
6
+ import { db } from "./db";
7
+ import { fetchCRNodes } from "./fetchComfyRegistryNodes";
8
+ import { type SlackMsg } from "./slack/SlackMsgs";
9
+
10
+ export type CRNode = Awaited<ReturnType<typeof fetchCRNodes>>[number] & {
11
+ sent?: { slack?: SlackMsg };
12
+ repo_id?: ObjectId;
13
+ };
14
+ export const CRNodes = db.collection<CRNode>("CRNodes");
15
+ await CRNodes.createIndex({ id: 1 }, { unique: true });
16
+ await CRNodes.createIndex({ repository: 1 }, { unique: false }); // WARN: duplicate is allowed
17
+ if (import.meta.main) {
18
+ const r = await pMap(
19
+ $pipeline(CNRepos)
20
+ .match({ cr: { $exists: true } })
21
+ .replaceRoot({ newRoot: "$cr" })
22
+ .aggregate(),
23
+ (e) => e,
24
+ );
25
+ peekYaml({ r, len: r.length });
26
+ }
package/src/CRPulls.ts ADDED
@@ -0,0 +1,4 @@
1
+ import type { CRPull } from "./CNRepos";
2
+ import { db } from "./db";
3
+
4
+ export const CRPulls = db.collection<CRPull>("CRPulls");
@@ -0,0 +1,5 @@
1
+ import DIE from "@snomiao/die";
2
+ import { ghUser } from "./ghUser";
3
+
4
+ export const FORK_OWNER =
5
+ process.env.FORK_OWNER?.replace(/"/g, "")?.trim() || ghUser.login || DIE("Missing env.FORK_OWNER");
@@ -0,0 +1,5 @@
1
+ import DIE from "@snomiao/die";
2
+
3
+ export const FORK_PREFIX =
4
+ process.env.FORK_PREFIX?.replace(/"/g, "")?.trim() ||
5
+ DIE('Missing env.FORK_PREFIX, if you want empty maybe try FORK_PREFIX=""');
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ import type { PullsStatus } from "./analyzePullsStatus";
3
+ import { db } from "./db";
4
+ import type { zFollowUpRules } from "./followRuleSchema";
5
+ import { type Task } from "./utils/Task";
6
+
7
+ // migrate data
8
+ // await db.renameCollection("FollowRules", "FollowRuleSets").catch(() => null);
9
+ export type FollowRule = z.infer<typeof zFollowUpRules>[number];
10
+ export type FollowRuleSet = {
11
+ // rules?: Task<FollowRule[]>;
12
+ name: string;
13
+ yaml: string;
14
+ rules?: FollowRule[];
15
+ matched?: Task<PullsStatus>;
16
+ action_results?: {
17
+ name: string;
18
+ action: any;
19
+ result: Task<any>;
20
+ }[];
21
+ enabled?: boolean;
22
+ yamlWhenEnabled?: string;
23
+ };
24
+ export const FollowRuleSets = db.collection<FollowRuleSet>("FollowRuleSets");
25
+ await FollowRuleSets.createIndex("name", { unique: true });
@@ -0,0 +1,5 @@
1
+ import DIE from "@snomiao/die";
2
+ import { ghUser } from "./ghUser";
3
+
4
+ export const GIT_USEREMAIL =
5
+ process.env.GIT_USEREMAIL || (ghUser.email && ghUser.email) || DIE("Missing env.GIT_USEREMAIL");
@@ -0,0 +1,9 @@
1
+ import DIE from "@snomiao/die";
2
+ import { GIT_USEREMAIL } from "./GIT_USEREMAIL";
3
+ import { ghUser } from "./ghUser";
4
+
5
+ export const GIT_USERNAME =
6
+ process.env.GIT_USERNAME || (ghUser.email && ghUser.name) || DIE("Missing env.GIT_USERNAME");
7
+
8
+ // read env/parameters
9
+ console.log(`GIT COMMIT USER: ${GIT_USERNAME} <${GIT_USEREMAIL}>`);
@@ -0,0 +1,3 @@
1
+ import { fetchIssueComments } from "./gh/fetchIssueComments";
2
+
3
+ export type GithubIssueComment = Awaited<ReturnType<typeof fetchIssueComments>>[number];
@@ -0,0 +1,3 @@
1
+ import { makePublishcrBranch } from "./makePublishBranch";
2
+
3
+ export type PushedBranch = Awaited<ReturnType<typeof makePublishcrBranch>>;
package/src/Totals.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { analyzeTotals } from "./analyzeTotals";
2
+ import { db } from "./db";
3
+ import { type AwaitedReturnType } from "./types/AwaitedReturnType";
4
+ import { type Task } from "./utils/Task";
5
+ export type Totals = AwaitedReturnType<typeof analyzeTotals>;
6
+ export const Totals = db.collection<{
7
+ today?: string;
8
+ totals?: Task<Totals>;
9
+ }>("Totals");
@@ -0,0 +1,12 @@
1
+ import { db } from "./db";
2
+
3
+ // 2) tracking the statuses of the PRs we've sent out (edited)
4
+ // "status [open, closed, merged]",
5
+ // "comments [int]",
6
+ // "last active [date]",
7
+ // "last updated [date]",
8
+
9
+ export const TrackingPulls = db.collection("TrackingPulls");
10
+ // bun --env-file .env.production.local src/dump.ts > dump.log
11
+ if (import.meta.main) {
12
+ }