gh-load-pull-request 0.4.0 → 0.5.0
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# gh-
|
|
1
|
+
# gh-load-pull-request
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/gh-load-pull-request)
|
|
4
4
|
|
|
5
5
|
Download GitHub pull request and convert it to markdown - perfect for AI review and analysis.
|
|
6
6
|
|
|
@@ -17,16 +17,16 @@ Download GitHub pull request and convert it to markdown - perfect for AI review
|
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
19
|
# Download a PR and display as markdown
|
|
20
|
-
gh-
|
|
20
|
+
gh-load-pull-request https://github.com/owner/repo/pull/123
|
|
21
21
|
|
|
22
22
|
# Using shorthand format
|
|
23
|
-
gh-
|
|
23
|
+
gh-load-pull-request owner/repo#123
|
|
24
24
|
|
|
25
25
|
# Save to file
|
|
26
|
-
gh-
|
|
26
|
+
gh-load-pull-request owner/repo#123 -o pr.md
|
|
27
27
|
|
|
28
28
|
# Download private PR (uses gh CLI auth automatically)
|
|
29
|
-
gh-
|
|
29
|
+
gh-load-pull-request owner/private-repo#456
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
## Installation
|
|
@@ -36,14 +36,10 @@ gh-download-pull-request owner/private-repo#456
|
|
|
36
36
|
Install globally for system-wide access:
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
|
|
40
|
-
bun install -g gh-download-pull-request
|
|
41
|
-
|
|
42
|
-
# Using npm
|
|
43
|
-
npm install -g gh-download-pull-request
|
|
39
|
+
bun install -g gh-load-pull-request
|
|
44
40
|
|
|
45
41
|
# After installation, use anywhere:
|
|
46
|
-
gh-
|
|
42
|
+
gh-load-pull-request --help
|
|
47
43
|
```
|
|
48
44
|
|
|
49
45
|
### Uninstall
|
|
@@ -51,34 +47,30 @@ gh-download-pull-request --help
|
|
|
51
47
|
Remove the global installation:
|
|
52
48
|
|
|
53
49
|
```bash
|
|
54
|
-
|
|
55
|
-
bun uninstall -g gh-download-pull-request
|
|
56
|
-
|
|
57
|
-
# Using npm
|
|
58
|
-
npm uninstall -g gh-download-pull-request
|
|
50
|
+
bun uninstall -g gh-load-pull-request
|
|
59
51
|
```
|
|
60
52
|
|
|
61
53
|
### Local Installation
|
|
62
54
|
|
|
63
55
|
```bash
|
|
64
56
|
# Clone the repository
|
|
65
|
-
git clone https://github.com/link-foundation/gh-
|
|
66
|
-
cd gh-
|
|
57
|
+
git clone https://github.com/link-foundation/gh-load-pull-request.git
|
|
58
|
+
cd gh-load-pull-request
|
|
67
59
|
|
|
68
60
|
# Install dependencies
|
|
69
|
-
|
|
61
|
+
bun install
|
|
70
62
|
|
|
71
63
|
# Make the script executable
|
|
72
|
-
chmod +x gh-
|
|
64
|
+
chmod +x gh-load-pull-request.mjs
|
|
73
65
|
|
|
74
66
|
# Run it
|
|
75
|
-
./gh-
|
|
67
|
+
./gh-load-pull-request.mjs --help
|
|
76
68
|
```
|
|
77
69
|
|
|
78
70
|
## Usage
|
|
79
71
|
|
|
80
72
|
```
|
|
81
|
-
Usage: gh-
|
|
73
|
+
Usage: gh-load-pull-request <pr-url> [options]
|
|
82
74
|
|
|
83
75
|
Options:
|
|
84
76
|
-t, --token GitHub personal access token (optional for public PRs)
|
|
@@ -108,7 +100,7 @@ If you have [GitHub CLI](https://cli.github.com/) installed and authenticated, t
|
|
|
108
100
|
gh auth login
|
|
109
101
|
|
|
110
102
|
# Tool automatically detects and uses gh CLI authentication
|
|
111
|
-
gh-
|
|
103
|
+
gh-load-pull-request owner/private-repo#123
|
|
112
104
|
```
|
|
113
105
|
|
|
114
106
|
### 2. Environment Variable
|
|
@@ -117,7 +109,7 @@ Set the `GITHUB_TOKEN` environment variable:
|
|
|
117
109
|
|
|
118
110
|
```bash
|
|
119
111
|
export GITHUB_TOKEN=ghp_your_token_here
|
|
120
|
-
gh-
|
|
112
|
+
gh-load-pull-request owner/repo#123
|
|
121
113
|
```
|
|
122
114
|
|
|
123
115
|
### 3. Command Line Token
|
|
@@ -125,7 +117,7 @@ gh-download-pull-request owner/repo#123
|
|
|
125
117
|
Pass the token directly with `--token`:
|
|
126
118
|
|
|
127
119
|
```bash
|
|
128
|
-
gh-
|
|
120
|
+
gh-load-pull-request owner/repo#123 --token ghp_your_token_here
|
|
129
121
|
```
|
|
130
122
|
|
|
131
123
|
### Authentication Priority
|
|
@@ -154,27 +146,27 @@ The markdown output includes:
|
|
|
154
146
|
|
|
155
147
|
```bash
|
|
156
148
|
# Basic usage - download and display PR
|
|
157
|
-
gh-
|
|
149
|
+
gh-load-pull-request https://github.com/facebook/react/pull/28000
|
|
158
150
|
|
|
159
151
|
# Using shorthand format
|
|
160
|
-
gh-
|
|
152
|
+
gh-load-pull-request facebook/react#28000
|
|
161
153
|
|
|
162
154
|
# Save to file
|
|
163
|
-
gh-
|
|
155
|
+
gh-load-pull-request facebook/react#28000 -o react-pr-28000.md
|
|
164
156
|
|
|
165
157
|
# Download private PR using gh CLI auth
|
|
166
|
-
gh-
|
|
158
|
+
gh-load-pull-request myorg/private-repo#42
|
|
167
159
|
|
|
168
160
|
# Download with explicit token
|
|
169
|
-
gh-
|
|
161
|
+
gh-load-pull-request myorg/repo#123 --token ghp_your_token_here
|
|
170
162
|
|
|
171
163
|
# Pipe to other tools (e.g., AI for review)
|
|
172
|
-
gh-
|
|
164
|
+
gh-load-pull-request owner/repo#123 | claude-analyze
|
|
173
165
|
```
|
|
174
166
|
|
|
175
167
|
## Requirements
|
|
176
168
|
|
|
177
|
-
- [Bun](https://bun.sh/) (>=1.2.0)
|
|
169
|
+
- [Bun](https://bun.sh/) (>=1.2.0) runtime
|
|
178
170
|
- For private repositories (optional):
|
|
179
171
|
- [GitHub CLI](https://cli.github.com/) (recommended) OR
|
|
180
172
|
- GitHub personal access token (via `--token` or `GITHUB_TOKEN` env var)
|
|
@@ -191,34 +183,30 @@ gh-download-pull-request owner/repo#123 | claude-analyze
|
|
|
191
183
|
|
|
192
184
|
```bash
|
|
193
185
|
# Run all tests
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
# Or run test files directly
|
|
197
|
-
node tests/all.test.mjs
|
|
198
|
-
node tests/cli.test.mjs
|
|
186
|
+
bun test
|
|
199
187
|
```
|
|
200
188
|
|
|
201
189
|
## Development
|
|
202
190
|
|
|
203
191
|
```bash
|
|
204
192
|
# Clone the repository
|
|
205
|
-
git clone https://github.com/link-foundation/gh-
|
|
206
|
-
cd gh-
|
|
193
|
+
git clone https://github.com/link-foundation/gh-load-pull-request.git
|
|
194
|
+
cd gh-load-pull-request
|
|
207
195
|
|
|
208
196
|
# Install dependencies
|
|
209
|
-
|
|
197
|
+
bun install
|
|
210
198
|
|
|
211
199
|
# Make executable
|
|
212
|
-
chmod +x gh-
|
|
200
|
+
chmod +x gh-load-pull-request.mjs
|
|
213
201
|
|
|
214
202
|
# Test locally
|
|
215
|
-
./gh-
|
|
203
|
+
./gh-load-pull-request.mjs owner/repo#123
|
|
216
204
|
|
|
217
205
|
# Run tests
|
|
218
|
-
|
|
206
|
+
bun test
|
|
219
207
|
|
|
220
208
|
# Run linting
|
|
221
|
-
|
|
209
|
+
bun run lint
|
|
222
210
|
|
|
223
211
|
# Bump version
|
|
224
212
|
./version.mjs patch # or minor, major
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gh-load-pull-request",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Download GitHub pull request and convert it to markdown",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "src/gh-
|
|
6
|
+
"main": "src/gh-load-pull-request.mjs",
|
|
7
7
|
"bin": {
|
|
8
|
-
"gh-
|
|
8
|
+
"gh-load-pull-request": "./src/gh-load-pull-request.mjs"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "node --test tests/",
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"license": "Unlicense",
|
|
38
38
|
"repository": {
|
|
39
39
|
"type": "git",
|
|
40
|
-
"url": "git+https://github.com/link-foundation/gh-
|
|
40
|
+
"url": "git+https://github.com/link-foundation/gh-load-pull-request.git"
|
|
41
41
|
},
|
|
42
42
|
"bugs": {
|
|
43
|
-
"url": "https://github.com/link-foundation/gh-
|
|
43
|
+
"url": "https://github.com/link-foundation/gh-load-pull-request/issues"
|
|
44
44
|
},
|
|
45
|
-
"homepage": "https://github.com/link-foundation/gh-
|
|
45
|
+
"homepage": "https://github.com/link-foundation/gh-load-pull-request#readme",
|
|
46
46
|
"engines": {
|
|
47
|
-
"
|
|
47
|
+
"bun": ">=1.2.0"
|
|
48
48
|
},
|
|
49
49
|
"files": [
|
|
50
50
|
"src/",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
':'; // # ; exec "$(command -v bun || command -v node)" "$0" "$@"
|
|
1
|
+
#!/usr/bin/env bun
|
|
3
2
|
|
|
4
3
|
// Import built-in Node.js modules
|
|
5
4
|
import path from 'node:path';
|
|
@@ -240,7 +239,7 @@ function downloadFile(url, token, maxRedirects = 5) {
|
|
|
240
239
|
const protocol = parsedUrl.protocol === 'https:' ? https : http;
|
|
241
240
|
|
|
242
241
|
const headers = {
|
|
243
|
-
'User-Agent': 'gh-
|
|
242
|
+
'User-Agent': 'gh-load-pull-request',
|
|
244
243
|
};
|
|
245
244
|
|
|
246
245
|
// Add auth for GitHub URLs
|
|
@@ -821,6 +820,17 @@ async function main() {
|
|
|
821
820
|
// Set verbose mode
|
|
822
821
|
verboseMode = verbose;
|
|
823
822
|
|
|
823
|
+
// Parse PR input first (before potentially slow gh CLI token fetch)
|
|
824
|
+
const prInfo = parsePrUrl(prInput);
|
|
825
|
+
if (!prInfo) {
|
|
826
|
+
log('red', `❌ Invalid PR URL or format: ${prInput}`);
|
|
827
|
+
log('yellow', '💡 Supported formats:');
|
|
828
|
+
log('yellow', ' - https://github.com/owner/repo/pull/123');
|
|
829
|
+
log('yellow', ' - owner/repo#123');
|
|
830
|
+
log('yellow', ' - owner/repo/123');
|
|
831
|
+
process.exit(1);
|
|
832
|
+
}
|
|
833
|
+
|
|
824
834
|
let token = tokenArg;
|
|
825
835
|
|
|
826
836
|
// If no token provided, try to get it from gh CLI
|
|
@@ -832,17 +842,6 @@ async function main() {
|
|
|
832
842
|
}
|
|
833
843
|
}
|
|
834
844
|
|
|
835
|
-
// Parse PR input
|
|
836
|
-
const prInfo = parsePrUrl(prInput);
|
|
837
|
-
if (!prInfo) {
|
|
838
|
-
log('red', `❌ Invalid PR URL or format: ${prInput}`);
|
|
839
|
-
log('yellow', '💡 Supported formats:');
|
|
840
|
-
log('yellow', ' - https://github.com/owner/repo/pull/123');
|
|
841
|
-
log('yellow', ' - owner/repo#123');
|
|
842
|
-
log('yellow', ' - owner/repo/123');
|
|
843
|
-
process.exit(1);
|
|
844
|
-
}
|
|
845
|
-
|
|
846
845
|
const { owner, repo, prNumber } = prInfo;
|
|
847
846
|
|
|
848
847
|
// Fetch PR data
|
package/src/version.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
':'; // # ; exec "$(command -v bun || command -v node)" "$0" "$@"
|
|
1
|
+
#!/usr/bin/env bun
|
|
3
2
|
|
|
4
3
|
import fs from 'node:fs';
|
|
5
4
|
import path from 'node:path';
|
|
@@ -24,7 +23,7 @@ function updatePackageJson(newVersion) {
|
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
function updateMainScript(newVersion) {
|
|
27
|
-
const scriptPath = path.join(__dirname, 'gh-
|
|
26
|
+
const scriptPath = path.join(__dirname, 'gh-load-pull-request.mjs');
|
|
28
27
|
const content = fs.readFileSync(scriptPath, 'utf8');
|
|
29
28
|
const updatedContent = content.replace(
|
|
30
29
|
/let version = '[^']+'/,
|
|
@@ -82,7 +81,7 @@ function main() {
|
|
|
82
81
|
|
|
83
82
|
console.log('✅ Version updated successfully!');
|
|
84
83
|
console.log(` 📄 package.json: ${newVersion}`);
|
|
85
|
-
console.log(` 📄 gh-
|
|
84
|
+
console.log(` 📄 gh-load-pull-request.mjs: ${newVersion}`);
|
|
86
85
|
console.log('');
|
|
87
86
|
|
|
88
87
|
// Automatically commit and push changes
|