comfy-pr 0.2.26 → 1.0.1
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 +258 -157
- package/bot/IdleWaiter.ts +31 -0
- package/bot/RestartManager.spec.ts +163 -0
- package/bot/RestartManager.ts +190 -0
- package/bot/WorkingTasksManager.spec.ts +154 -0
- package/bot/cli.ts +1171 -0
- package/bot/codesearch-ai-wip.ts +351 -0
- package/bot/error-collector.ts +133 -0
- package/bot/index.ts +14 -0
- package/bot/restart-example.ts +99 -0
- package/bot/slack-bolt.ts +688 -0
- package/bot/slack-bot.ts +1575 -0
- package/bot/state.ts +19 -0
- package/bot/templateLoader.test.ts +84 -0
- package/bot/templateLoader.ts +92 -0
- package/next.config.ts +26 -0
- package/package.json +161 -41
- package/post-summary.ts +44 -0
- package/src/Authors.ts +2 -2
- package/src/CMNodes.ts +3 -3
- package/src/CNRepos.ts +30 -7
- package/src/CRNodes.ts +11 -9
- package/src/CRPulls.ts +3 -0
- package/src/EmailTasks.ts +27 -9
- package/src/FORK_OWNER.ts +3 -1
- package/src/FollowRules.ts +3 -3
- package/src/GithubIssueComments.ts +1 -1
- package/src/Totals.ts +9 -8
- package/src/WorkerInstances.ts +31 -8
- package/src/addCommentAction.ts +19 -11
- package/src/analyzePullsStatus.ts +39 -17
- package/src/analyzeTotals.ts +19 -11
- package/src/bypassRepos.ts +6 -5
- package/src/checkPRsFailures.ts +13 -8
- package/src/cli.test.ts +2 -0
- package/src/cli.ts +1 -1
- package/src/constants.ts +2 -0
- package/src/createComfyRegistryPRsFromCandidates.ts +20 -12
- package/src/createComfyRegistryPullRequests.ts +35 -10
- package/src/createGithubForkForRepo.ts +36 -11
- package/src/createGithubPullRequest.ts +83 -33
- package/src/createIssueComment.ts +4 -4
- package/src/fetchComfyRegistryNodes.ts +34 -4
- package/src/fetchCurrentGeoInfo.ts +3 -1
- package/src/fetchRelatedPullWithComments.ts +1 -1
- package/src/fetchRepoDescriptionMap.ts +1 -4
- package/src/followRuleSchema.ts +10 -4
- package/src/getBranchWorkingDir.ts +3 -7
- package/src/getRepoWorkingDir.ts +2 -3
- package/src/gh.spec.ts +571 -0
- package/src/ghData.ts +13 -0
- package/src/ghPageFlow.ts +33 -0
- package/src/ghSubscriber.ts +76 -0
- package/src/ghUser.ts +28 -4
- package/src/index.ts +13 -4
- package/src/initializeFollowRules.ts +11 -4
- package/src/logger.spec.ts +95 -0
- package/src/logger.ts +46 -0
- package/src/makeGpl3LicenseBranch.ts +66 -0
- package/src/makePublishBranch.ts +21 -15
- package/src/makeTomlBranch.ts +48 -14
- package/src/makeUpdateTomlLicenseBranch.ts +40 -44
- package/src/matchRelatedPulls.ts +9 -4
- package/src/normalizeGithubUrl.spec.ts +131 -0
- package/src/normalizeGithubUrl.ts +64 -0
- package/src/parseIssueUrl.spec.ts +95 -0
- package/src/parseIssueUrl.ts +17 -3
- package/src/parseOwnerRepo.spec.ts +147 -0
- package/src/parseOwnerRepo.ts +8 -5
- package/src/parsePullsState.ts +2 -2
- package/src/parseTitleBodyOfMarkdown.ts +1 -1
- package/src/pickRepoInfo.ts +37 -0
- package/src/postSlackMessage.ts +5 -1
- package/src/preload.ts +30 -27
- package/src/readTemplateTitle.ts +1 -3
- package/src/sendEmailAction.ts +14 -10
- package/src/sendGmail.ts +3 -3
- package/src/updateAuthorsForGithub.ts +53 -35
- package/src/updateAuthorsFromCNRepo.ts +12 -5
- package/src/updateCMNodesDuplicationWarnings.ts +14 -9
- package/src/updateCMRepos.ts +1 -1
- package/src/updateCNRepos.ts +14 -14
- package/src/updateCNReposCRPullsComments.ts +7 -5
- package/src/updateCNReposInfo.ts +49 -40
- package/src/updateCNReposPRCandidate.ts +3 -3
- package/src/updateCNReposPulls.ts +9 -5
- package/src/updateCNReposPullsDashboard.ts +11 -9
- package/src/updateCNReposRelatedPulls.ts +3 -3
- package/src/updateCRNodes.ts +24 -5
- package/src/updateCRRepos.ts +1 -1
- package/src/updateComfyTotals.ts +7 -5
- package/src/updateFollowRuleSet.ts +17 -9
- package/src/updateOutdatedPullsTemplates.ts +61 -48
- package/src/updateSlackMessages.ts +8 -4
- package/tailwind.config.ts +7 -1
- package/next-env.d.ts +0 -5
- package/src/GIT_USEREMAIL.ts +0 -5
- package/src/GIT_USERNAME.ts +0 -9
- package/src/clone_modify_push_Branches.ts +0 -21
- package/src/tomlFillDescription.ts +0 -17
package/README.md
CHANGED
|
@@ -1,247 +1,348 @@
|
|
|
1
1
|
# Comfy-PR
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A comprehensive automation platform for [ComfyUI Custom Node](https://registry.comfy.org/) development and publishing. Comfy-PR helps Custom Node authors streamline their publishing workflow by automating repository setup, pull request creation, and ongoing maintenance.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- 🔄 **Automated PR Creation**: Clone repos, update `pyproject.toml`, initialize GitHub Actions, and create PRs
|
|
8
|
+
- 📊 **Analytics Dashboard**: Web-based dashboard with statistics, CSV/YAML exports, and repository insights
|
|
9
|
+
- 🔗 **GitHub Webhook Integration**: Real-time monitoring of issues, PRs, and comments
|
|
10
|
+
- ⚡ **Performance Optimized**: Cached GitHub API client with SQLite storage (5min TTL)
|
|
11
|
+
- 📋 **Task Management**: Automated task execution with progress tracking
|
|
12
|
+
- 🎯 **Rule-Based Follow-ups**: Configurable automation rules for different PR states
|
|
8
13
|
|
|
9
|
-
-
|
|
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
|
-
- [x] DOING: Export PR status into csv for @haohao
|
|
14
|
+
## Comfy-PR Project Goals
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
The Comfy-PR project aims to support and streamline the process for Custom Node Authors to publish their work in the Comfy Registry. Here's why this initiative is essential:
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- [x] Mention related prs in dashboard https://github.com/drip-art/Comfy-Registry-PR/issues/1
|
|
28
|
-
- [x] Analyze Totals
|
|
29
|
-
- [x] license schema updator
|
|
30
|
-
- [x] bypass repo
|
|
31
|
-
- [ ] Follow-up prs by state
|
|
32
|
-
- [ ] Issues Comment
|
|
33
|
-
- [ ] Slack
|
|
34
|
-
- [ ] Email
|
|
35
|
-
- [ ] Delete the forked repo which is Merged
|
|
18
|
+
1. **Simplify Node Publishing**: Provide tools and assistance to make publishing Custom Nodes straightforward, allowing authors to concentrate on development rather than the complexities of the publishing process.
|
|
19
|
+
2. **Expand Node Availability**: Streamlined publishing will increase the number of Custom Nodes in the Comfy Registry, enriching the ecosystem and offering more options to users.
|
|
20
|
+
3. **Encourage Collaboration**: Scanning GitHub repositories and providing follow-up support fosters collaboration, knowledge-sharing, and a stronger sense of community among Custom Node Authors and users.
|
|
21
|
+
4. **Ensure Quality and Compliance**: Automate checks and provide guidance to maintain high-quality standards and compliance within the Comfy Registry.
|
|
22
|
+
5. **Resolve Publishing Issues Promptly**: Address Custom Node Authors' issues during the publishing process quickly, reducing frustration and improving the overall user experience.
|
|
23
|
+
6. **Strengthen the Comfy Community**: Help solve users' problems with Custom Node uploading and publishing, contributing to a more vibrant, supportive, and engaged community.
|
|
24
|
+
7. **Promote Innovation**: Lower barriers to publishing Custom Nodes to encourage innovation and creativity within the community, leading to the development of novel and exciting nodes.
|
|
36
25
|
|
|
37
|
-
|
|
26
|
+
Through these efforts, Comfy-PR seeks to create an environment where Custom Node Authors can thrive and users can access a diverse and high-quality array of Custom Nodes.
|
|
38
27
|
|
|
39
|
-
|
|
40
|
-
- [x] pr dashboard
|
|
28
|
+
## Architecture Overview
|
|
41
29
|
|
|
42
|
-
|
|
30
|
+
### Core Components
|
|
43
31
|
|
|
44
|
-
|
|
32
|
+
1. **CLI Tool** (`src/cli.ts`): Command-line interface for processing individual repositories
|
|
33
|
+
2. **Main Service** (`src/index.ts`): Orchestrates batch processing of repositories
|
|
34
|
+
3. **Web Dashboard** (`app/`): Next.js application with analytics and management UI
|
|
35
|
+
4. **Webhook Service** (`run/index.ts`): Real-time GitHub event monitoring
|
|
36
|
+
5. **Task System** (`app/tasks/`): Automated background tasks for various operations
|
|
45
37
|
|
|
46
|
-
|
|
38
|
+
### Key Features
|
|
47
39
|
|
|
48
|
-
|
|
40
|
+
#### CLI Operations
|
|
49
41
|
|
|
50
|
-
|
|
42
|
+
- ✅ Repository forking and local cloning
|
|
43
|
+
- ✅ Automated `pyproject.toml` setup via `comfy node init`
|
|
44
|
+
- ✅ GitHub Actions workflow creation and publishing
|
|
45
|
+
- ✅ Template-based PR creation with descriptions
|
|
46
|
+
- ✅ Clean workspace management
|
|
51
47
|
|
|
52
|
-
|
|
48
|
+
#### Analytics & Monitoring
|
|
53
49
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
- ✅ Repository status tracking (private/archived/active)
|
|
51
|
+
- ✅ PR status monitoring (open/merged/closed) with comments
|
|
52
|
+
- ✅ Statistical analysis and reporting
|
|
53
|
+
- ✅ CSV/YAML data exports
|
|
54
|
+
- ✅ Related PR cross-referencing
|
|
55
|
+
|
|
56
|
+
#### Automation Engine
|
|
57
|
+
|
|
58
|
+
- ✅ Rule-based follow-up actions
|
|
59
|
+
- ✅ Slack notifications
|
|
60
|
+
- ✅ Email task management
|
|
61
|
+
- ✅ License schema updates
|
|
62
|
+
- ✅ Repository bypass logic
|
|
63
|
+
- 🔄 Auto-cleanup of merged forks (in progress)
|
|
64
|
+
|
|
65
|
+
### Web Dashboard
|
|
57
66
|
|
|
58
|
-
|
|
67
|
+
Access the dashboard at https://comfy-pr.vercel.app
|
|
59
68
|
|
|
60
|
-
|
|
69
|
+
- 📊 Repository statistics and analytics
|
|
70
|
+
- 📈 Interactive charts and visualizations
|
|
71
|
+
- 📋 Task management interface
|
|
72
|
+
- 📤 Data export tools (CSV/YAML)
|
|
73
|
+
- 🔍 PR status monitoring and filtering
|
|
61
74
|
|
|
62
|
-
|
|
63
|
-
# your github token
|
|
64
|
-
GH_TOKEN=ghp_WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
|
|
75
|
+
## Configuration
|
|
65
76
|
|
|
66
|
-
|
|
77
|
+
### Environment Variables
|
|
78
|
+
|
|
79
|
+
#### Core Settings
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# GitHub API token (required)
|
|
83
|
+
GH_TOKEN=ghp_your_github_token_here
|
|
84
|
+
|
|
85
|
+
# PR source organization (optional - defaults to your account)
|
|
67
86
|
FORK_OWNER="ComfyNodePRs"
|
|
68
87
|
|
|
69
|
-
# PR prefix
|
|
88
|
+
# PR branch prefix (optional)
|
|
70
89
|
FORK_PREFIX="PR-"
|
|
90
|
+
|
|
91
|
+
# MongoDB connection (for dashboard/analytics)
|
|
92
|
+
MONGODB_URI=mongodb://localhost:27017
|
|
71
93
|
```
|
|
72
94
|
|
|
73
|
-
####
|
|
95
|
+
#### Webhook Service (Optional)
|
|
74
96
|
|
|
75
|
-
|
|
97
|
+
```bash
|
|
98
|
+
# Enable real-time webhook monitoring
|
|
99
|
+
USE_WEBHOOKS=true
|
|
100
|
+
GITHUB_WEBHOOK_SECRET=your_secure_webhook_secret
|
|
101
|
+
WEBHOOK_BASE_URL=https://your-domain.com
|
|
102
|
+
PORT=8080
|
|
103
|
+
```
|
|
76
104
|
|
|
77
|
-
|
|
105
|
+
### GitHub Token Setup
|
|
78
106
|
|
|
79
|
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
107
|
+
1. Go to [GitHub Personal Access Tokens](https://github.com/settings/tokens?type=beta)
|
|
108
|
+
2. Create a fine-grained token with these permissions:
|
|
109
|
+
- **Pull requests**: Read and write
|
|
110
|
+
- **Workflows**: Read and write
|
|
111
|
+
- **Metadata**: Read-only
|
|
112
|
+
- **Repository hooks**: Read and write (for webhooks)
|
|
82
113
|
|
|
83
|
-
|
|
114
|
+
### SSH Key Setup
|
|
84
115
|
|
|
85
|
-
|
|
116
|
+
Required for automated git operations:
|
|
86
117
|
|
|
87
|
-
|
|
118
|
+
```bash
|
|
119
|
+
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
|
|
120
|
+
cat ~/.ssh/id_rsa.pub
|
|
121
|
+
# Add the public key to https://github.com/settings/keys
|
|
122
|
+
```
|
|
88
123
|
|
|
89
|
-
|
|
124
|
+
## Quick Start
|
|
90
125
|
|
|
91
|
-
###
|
|
126
|
+
### CLI Usage
|
|
92
127
|
|
|
93
|
-
|
|
128
|
+
```bash
|
|
129
|
+
# Install and run for specific repositories
|
|
130
|
+
bunx comfy-pr [GITHUB_REPO_URLS...]
|
|
94
131
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
3. Docker run at cloud (TODO)
|
|
132
|
+
# Process from a file list
|
|
133
|
+
bunx comfy-pr --repolist repos.txt
|
|
98
134
|
|
|
99
|
-
|
|
135
|
+
# Use environment variable
|
|
136
|
+
REPO=https://github.com/owner/repo bunx comfy-pr
|
|
137
|
+
```
|
|
100
138
|
|
|
101
|
-
|
|
139
|
+
### Examples
|
|
102
140
|
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
docker compose build
|
|
107
|
-
docker compose up
|
|
108
|
-
```
|
|
141
|
+
```bash
|
|
142
|
+
# Process a single repository
|
|
143
|
+
bunx comfy-pr https://github.com/example/my-comfy-node
|
|
109
144
|
|
|
110
|
-
|
|
145
|
+
# Process multiple repositories
|
|
146
|
+
bunx comfy-pr \
|
|
147
|
+
https://github.com/user1/node-a \
|
|
148
|
+
https://github.com/user2/node-b
|
|
111
149
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
-e REPO=https://github.com/snomiao/ComfyNode-Registry-test \
|
|
117
|
-
snomiao/comfy-registry-pr
|
|
150
|
+
# Use a repository list file
|
|
151
|
+
echo "https://github.com/example/repo1" > repos.txt
|
|
152
|
+
echo "https://github.com/example/repo2" >> repos.txt
|
|
153
|
+
bunx comfy-pr --repolist repos.txt
|
|
118
154
|
```
|
|
119
155
|
|
|
120
|
-
|
|
156
|
+
## Installation & Setup
|
|
121
157
|
|
|
122
|
-
|
|
123
|
-
git clone https://github.com/drip-art/Comfy-Registry-PR
|
|
158
|
+
### Prerequisites
|
|
124
159
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
160
|
+
- [Bun](https://bun.sh) runtime
|
|
161
|
+
- Python 3.x with `comfy-cli` installed
|
|
162
|
+
- Git with SSH key configured
|
|
163
|
+
- GitHub Personal Access Token
|
|
164
|
+
|
|
165
|
+
### Local Development
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
# Clone the repository
|
|
169
|
+
git clone https://github.com/Comfy-Org/Comfy-PR
|
|
170
|
+
cd Comfy-PR
|
|
131
171
|
|
|
172
|
+
# Install dependencies
|
|
173
|
+
bun install
|
|
174
|
+
|
|
175
|
+
# Setup Python environment for comfy-cli
|
|
176
|
+
python3 -m venv .venv
|
|
177
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
178
|
+
pip install comfy-cli
|
|
132
179
|
|
|
180
|
+
# Configure environment
|
|
181
|
+
cp .env.example .env
|
|
182
|
+
# Edit .env with your settings
|
|
133
183
|
|
|
134
|
-
#
|
|
135
|
-
|
|
136
|
-
bun i
|
|
184
|
+
# Run CLI tool
|
|
185
|
+
bun src/cli.ts https://github.com/example/my-comfy-node
|
|
137
186
|
|
|
138
|
-
#
|
|
139
|
-
bun src/
|
|
140
|
-
# for example
|
|
141
|
-
bun src/cli.ts https://github.com/snomiao/ComfyNode-Registry-test
|
|
187
|
+
# Run main service (batch processing)
|
|
188
|
+
bun src/index.ts
|
|
142
189
|
|
|
190
|
+
# Start web dashboard
|
|
191
|
+
bun run dev # Available at http://localhost:3000
|
|
143
192
|
```
|
|
144
193
|
|
|
145
|
-
|
|
194
|
+
### Production Deployment
|
|
146
195
|
|
|
147
|
-
|
|
196
|
+
#### Docker Compose (Recommended)
|
|
148
197
|
|
|
149
|
-
|
|
198
|
+
```bash
|
|
199
|
+
# Configure environment
|
|
200
|
+
cp .env.example .env
|
|
201
|
+
# Edit .env with production settings
|
|
150
202
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
.\.venv\Scripts\activate
|
|
155
|
-
pip3 install comfy-cli
|
|
203
|
+
# Deploy with Docker Compose
|
|
204
|
+
docker compose up -d
|
|
205
|
+
```
|
|
156
206
|
|
|
157
|
-
|
|
158
|
-
npx -y cross-env REPO=https://github.com/snomiao/ComfyNode-Registry-test npx -y tsx src/cli.ts
|
|
207
|
+
#### Manual Docker
|
|
159
208
|
|
|
209
|
+
```bash
|
|
210
|
+
docker run --rm -it \
|
|
211
|
+
-v $HOME/.ssh:/root/.ssh:ro \
|
|
212
|
+
-e GH_TOKEN=your_github_token \
|
|
213
|
+
-e MONGODB_URI=mongodb://localhost:27017 \
|
|
214
|
+
comfy-org/comfy-pr
|
|
160
215
|
```
|
|
161
216
|
|
|
162
|
-
####
|
|
217
|
+
#### Cloud Deployment
|
|
218
|
+
|
|
219
|
+
The webhook service can be deployed to:
|
|
163
220
|
|
|
164
|
-
|
|
221
|
+
- **Vercel**: `vercel --prod`
|
|
222
|
+
- **Google Cloud Run**: `cd run && ./deploy.sh`
|
|
223
|
+
- **Railway**: `railway deploy`
|
|
224
|
+
- **Heroku**: Standard Node.js deployment
|
|
165
225
|
|
|
166
|
-
|
|
226
|
+
## Development
|
|
167
227
|
|
|
168
|
-
|
|
169
|
-
ENV FORK_PREFIX=PR-
|
|
228
|
+
### Project Structure
|
|
170
229
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
230
|
+
```
|
|
231
|
+
Comfy-PR/
|
|
232
|
+
├── src/ # Core utilities and business logic
|
|
233
|
+
│ ├── cli.ts # Command-line interface
|
|
234
|
+
│ ├── index.ts # Main service orchestrator
|
|
235
|
+
│ ├── ghc.ts # Cached GitHub API client
|
|
236
|
+
│ ├── db/ # Database models and utilities
|
|
237
|
+
│ ├── gh/ # GitHub API wrappers
|
|
238
|
+
│ └── utils/ # Shared utilities
|
|
239
|
+
├── app/ # Next.js web dashboard
|
|
240
|
+
│ ├── (dashboard)/ # Dashboard pages and components
|
|
241
|
+
│ ├── api/ # API routes and tRPC
|
|
242
|
+
│ └── tasks/ # Background task implementations
|
|
243
|
+
├── run/ # Production services
|
|
244
|
+
│ ├── index.ts # GitHub webhook service
|
|
245
|
+
│ └── deploy.sh # Cloud deployment scripts
|
|
246
|
+
├── gh-service/ # Legacy webhook service
|
|
247
|
+
├── templates/ # PR and workflow templates
|
|
248
|
+
└── packages/ # Internal packages
|
|
249
|
+
└── mongodb-pipeline-ts/ # MongoDB aggregation utilities
|
|
174
250
|
```
|
|
175
251
|
|
|
176
|
-
|
|
252
|
+
### Development Workflow
|
|
177
253
|
|
|
178
|
-
|
|
254
|
+
```bash
|
|
255
|
+
# Install dependencies
|
|
256
|
+
bun install
|
|
179
257
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
mkdir comfy-pr
|
|
183
|
-
cd comfy-pr
|
|
258
|
+
# Start MongoDB (required for dashboard)
|
|
259
|
+
docker compose up mongodb -d
|
|
184
260
|
|
|
185
|
-
#
|
|
186
|
-
|
|
261
|
+
# Initialize database
|
|
262
|
+
bun src/index.ts
|
|
187
263
|
|
|
188
|
-
#
|
|
189
|
-
|
|
264
|
+
# Development modes:
|
|
265
|
+
bun run dev # Web dashboard (http://localhost:3000)
|
|
266
|
+
bun run dev:tsc # TypeScript compiler watch mode
|
|
267
|
+
bun run gh-service # Webhook service
|
|
190
268
|
|
|
191
|
-
#
|
|
192
|
-
bun
|
|
269
|
+
# Testing
|
|
270
|
+
bun test # Run test suite
|
|
271
|
+
bun test --watch # Watch mode
|
|
193
272
|
|
|
194
|
-
#
|
|
195
|
-
bun
|
|
273
|
+
# Linting and building
|
|
274
|
+
bun run lint # ESLint
|
|
275
|
+
bun run build # Next.js build
|
|
196
276
|
```
|
|
197
277
|
|
|
198
|
-
###
|
|
278
|
+
### Running Individual Components
|
|
199
279
|
|
|
200
|
-
|
|
280
|
+
```bash
|
|
281
|
+
# Process specific repositories
|
|
282
|
+
bun src/cli.ts https://github.com/example/repo
|
|
201
283
|
|
|
202
|
-
|
|
284
|
+
# Run specific tasks
|
|
285
|
+
bun app/tasks/coreping/coreping.ts
|
|
286
|
+
bun app/tasks/gh-bounty/gh-bounty.ts
|
|
203
287
|
|
|
204
|
-
|
|
205
|
-
|
|
288
|
+
# Update repository data
|
|
289
|
+
bun src/updateCNRepos.ts
|
|
290
|
+
bun src/updateAuthors.ts
|
|
206
291
|
```
|
|
207
292
|
|
|
208
|
-
|
|
209
|
-
services:
|
|
210
|
-
mongdb:
|
|
211
|
-
restart: always
|
|
212
|
-
image: mongo
|
|
213
|
-
ports: ["27017:27017"]
|
|
214
|
-
volumes: [./data/mongodb:/data/db]
|
|
215
|
-
```
|
|
293
|
+
## Advanced Usage
|
|
216
294
|
|
|
217
|
-
|
|
295
|
+
### Webhook Integration
|
|
218
296
|
|
|
219
|
-
|
|
220
|
-
|
|
297
|
+
For real-time GitHub event monitoring:
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Generate secure webhook secret
|
|
301
|
+
export GITHUB_WEBHOOK_SECRET=$(openssl rand -hex 32)
|
|
302
|
+
|
|
303
|
+
# Enable webhook mode
|
|
304
|
+
export USE_WEBHOOKS=true
|
|
305
|
+
export WEBHOOK_BASE_URL=https://your-domain.com
|
|
306
|
+
|
|
307
|
+
# Start webhook service
|
|
308
|
+
bun run gh-service
|
|
221
309
|
```
|
|
222
310
|
|
|
223
|
-
|
|
311
|
+
See [WEBHOOK_SETUP.md](./WEBHOOK_SETUP.md) for detailed webhook configuration.
|
|
224
312
|
|
|
225
|
-
|
|
226
|
-
# To initialize your database, run:
|
|
227
|
-
bun src/index.ts
|
|
313
|
+
### Task System
|
|
228
314
|
|
|
229
|
-
|
|
230
|
-
# Feel free to run any scripts in src/, they are safe to re-run and stop in any time.
|
|
231
|
-
bun src/THAT_FILE_YOU_WANT_TO_RUN.ts
|
|
315
|
+
The platform includes several automated tasks:
|
|
232
316
|
|
|
233
|
-
|
|
234
|
-
|
|
317
|
+
- **CorePing** (`app/tasks/coreping/`): Repository health monitoring
|
|
318
|
+
- **GitHub Bounty** (`app/tasks/gh-bounty/`): Bounty management
|
|
319
|
+
- **Design Tasks** (`app/tasks/gh-design/`): Design-related automation
|
|
320
|
+
- **Contributor Analysis** (`app/tasks/github-contributor-analyze/`): Contribution statistics
|
|
321
|
+
- **Action Updates** (`app/tasks/github-action-update/`): GitHub Actions maintenance
|
|
322
|
+
|
|
323
|
+
### Database Inspection
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
# Inspect production database (read-only)
|
|
327
|
+
echo 'MONGODB_URI_INSPECT=mongodb://prod-readonly-uri' > .env.development.local
|
|
328
|
+
echo 'MONGODB_URI=$MONGODB_URI_INSPECT' >> .env.development.local
|
|
329
|
+
|
|
330
|
+
# Run inspection scripts
|
|
331
|
+
bun src/checkPRsFailures.ts
|
|
332
|
+
bun src/analyzeTotals.ts
|
|
235
333
|
```
|
|
236
334
|
|
|
335
|
+
### Performance Optimization
|
|
237
336
|
|
|
238
|
-
|
|
337
|
+
The project uses a cached GitHub API client (`src/ghc.ts`) that:
|
|
239
338
|
|
|
240
|
-
|
|
339
|
+
- Stores responses in SQLite for 5 minutes
|
|
340
|
+
- Reduces API rate limiting
|
|
341
|
+
- Improves response times for repeated requests
|
|
241
342
|
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
MONGODB_URI=$MONGODB_URI_INSPECT_HAOHAO
|
|
245
|
-
```
|
|
343
|
+
```typescript
|
|
344
|
+
import { ghc } from "./src/ghc";
|
|
246
345
|
|
|
247
|
-
|
|
346
|
+
// Use ghc instead of gh for automatic caching
|
|
347
|
+
const repo = await ghc.repos.get({ owner, repo });
|
|
348
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A utility class to wait for idle periods based on activity pings.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* const idleWaiter = new IdleWaiter();
|
|
6
|
+
*
|
|
7
|
+
* // Somewhere in your code, when activity occurs:
|
|
8
|
+
* idleWaiter.ping();
|
|
9
|
+
*
|
|
10
|
+
* // To wait for an idle period of 5 seconds:
|
|
11
|
+
* await idleWaiter.wait(5000);
|
|
12
|
+
* console.log('System has been idle for 5 seconds');
|
|
13
|
+
*/
|
|
14
|
+
export class IdleWaiter {
|
|
15
|
+
lastActivityTime = Date.now();
|
|
16
|
+
checkInterval = 100; // Default check interval in milliseconds
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
this.ping();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
ping() {
|
|
23
|
+
this.lastActivityTime = Date.now();
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async wait(ms: number) {
|
|
28
|
+
while (this.lastActivityTime >= Date.now() - ms)
|
|
29
|
+
await new Promise((resolve) => setTimeout(resolve, this.checkInterval));
|
|
30
|
+
}
|
|
31
|
+
}
|