Skip to content

Commit c7879ff

Browse files
authored
Merge pull request #14 from link-foundation/issue-13-70de073e9970
Make it bun first and bun only
2 parents 516e850 + 238df6d commit c7879ff

File tree

9 files changed

+50
-175
lines changed

9 files changed

+50
-175
lines changed

.changeset/bun-only-runtime.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'gh-load-pull-request': minor
3+
---
4+
5+
Make tool exclusively use Bun runtime, dropping Node.js and Deno support

.github/workflows/release.yml

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -90,58 +90,30 @@ jobs:
9090
- name: Check file size limit
9191
run: npm run check:file-size
9292

93-
# Test matrix: 3 runtimes (Node.js, Bun, Deno) x 3 OS (Ubuntu, macOS, Windows)
93+
# Test matrix: Bun on 3 OS (Ubuntu, macOS, Windows)
9494
test:
95-
name: Test (${{ matrix.runtime }} on ${{ matrix.os }})
95+
name: Test (Bun on ${{ matrix.os }})
9696
runs-on: ${{ matrix.os }}
9797
needs: [changeset-check]
9898
if: always() && (github.event_name == 'push' || needs.changeset-check.result == 'success')
9999
strategy:
100100
fail-fast: false
101101
matrix:
102102
os: [ubuntu-latest, macos-latest, windows-latest]
103-
runtime: [node, bun, deno]
104103
steps:
105104
- uses: actions/checkout@v4
106105

107-
- name: Setup Node.js
108-
if: matrix.runtime == 'node'
109-
uses: actions/setup-node@v4
110-
with:
111-
node-version: '20.x'
112-
113-
- name: Install dependencies (Node.js)
114-
if: matrix.runtime == 'node'
115-
run: npm install
116-
117-
- name: Run tests (Node.js)
118-
if: matrix.runtime == 'node'
119-
run: npm test
120-
121106
- name: Setup Bun
122-
if: matrix.runtime == 'bun'
123107
uses: oven-sh/setup-bun@v2
124108
with:
125109
bun-version: latest
126110

127-
- name: Install dependencies (Bun)
128-
if: matrix.runtime == 'bun'
111+
- name: Install dependencies
129112
run: bun install
130113

131-
- name: Run tests (Bun)
132-
if: matrix.runtime == 'bun'
114+
- name: Run tests
133115
run: bun test
134116

135-
- name: Setup Deno
136-
if: matrix.runtime == 'deno'
137-
uses: denoland/setup-deno@v2
138-
with:
139-
deno-version: v2.x
140-
141-
- name: Run tests (Deno)
142-
if: matrix.runtime == 'deno'
143-
run: deno test --allow-read --allow-run --no-check
144-
145117
# Release - only runs on main after tests pass (for push events)
146118
release:
147119
name: Release

README.md

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,8 @@ gh-load-pull-request owner/private-repo#456
3636
Install globally for system-wide access:
3737

3838
```bash
39-
# Using bun
4039
bun install -g gh-load-pull-request
4140

42-
# Using npm
43-
npm install -g gh-load-pull-request
44-
4541
# After installation, use anywhere:
4642
gh-load-pull-request --help
4743
```
@@ -51,11 +47,7 @@ gh-load-pull-request --help
5147
Remove the global installation:
5248

5349
```bash
54-
# Using bun
5550
bun uninstall -g gh-load-pull-request
56-
57-
# Using npm
58-
npm uninstall -g gh-load-pull-request
5951
```
6052

6153
### Local Installation
@@ -66,7 +58,7 @@ git clone https://github.com/link-foundation/gh-load-pull-request.git
6658
cd gh-load-pull-request
6759

6860
# Install dependencies
69-
npm install
61+
bun install
7062

7163
# Make the script executable
7264
chmod +x gh-load-pull-request.mjs
@@ -174,7 +166,7 @@ gh-load-pull-request owner/repo#123 | claude-analyze
174166

175167
## Requirements
176168

177-
- [Bun](https://bun.sh/) (>=1.2.0) or [Node.js](https://nodejs.org/) (>=22.17.0) runtime
169+
- [Bun](https://bun.sh/) (>=1.2.0) runtime
178170
- For private repositories (optional):
179171
- [GitHub CLI](https://cli.github.com/) (recommended) OR
180172
- GitHub personal access token (via `--token` or `GITHUB_TOKEN` env var)
@@ -191,11 +183,7 @@ gh-load-pull-request owner/repo#123 | claude-analyze
191183

192184
```bash
193185
# Run all tests
194-
npm test
195-
196-
# Or run test files directly
197-
node tests/all.test.mjs
198-
node tests/cli.test.mjs
186+
bun test
199187
```
200188

201189
## Development
@@ -206,7 +194,7 @@ git clone https://github.com/link-foundation/gh-load-pull-request.git
206194
cd gh-load-pull-request
207195

208196
# Install dependencies
209-
npm install
197+
bun install
210198

211199
# Make executable
212200
chmod +x gh-load-pull-request.mjs
@@ -215,10 +203,10 @@ chmod +x gh-load-pull-request.mjs
215203
./gh-load-pull-request.mjs owner/repo#123
216204

217205
# Run tests
218-
npm test
206+
bun test
219207

220208
# Run linting
221-
npm run lint
209+
bun run lint
222210

223211
# Bump version
224212
./version.mjs patch # or minor, major

deno.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
"homepage": "https://github.com/link-foundation/gh-load-pull-request#readme",
4646
"engines": {
47-
"node": ">=20.0.0"
47+
"bun": ">=1.2.0"
4848
},
4949
"files": [
5050
"src/",

src/gh-load-pull-request.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env sh
2-
':'; // # ; exec "$(command -v bun || command -v node)" "$0" "$@"
1+
#!/usr/bin/env bun
32

43
// Import built-in Node.js modules
54
import path from 'node:path';

src/version.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env sh
2-
':'; // # ; exec "$(command -v bun || command -v node)" "$0" "$@"
1+
#!/usr/bin/env bun
32

43
import fs from 'node:fs';
54
import path from 'node:path';

tests/cli.test.mjs

Lines changed: 31 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
1-
#!/usr/bin/env sh
2-
':'; // # ; exec "$(command -v bun || command -v deno run -A || command -v node)" "$0" "$@"
1+
#!/usr/bin/env bun
32

43
/**
54
* CLI tests for gh-load-pull-request
65
*
7-
* Uses test-anywhere for multi-runtime support (Node.js, Bun, Deno)
6+
* Uses test-anywhere for Bun runtime
87
*
98
* Run with:
10-
* node --test tests/cli.test.mjs
119
* bun test tests/cli.test.mjs
12-
* deno test --allow-read --allow-run tests/cli.test.mjs
1310
*/
1411

15-
/* global TextDecoder */
16-
17-
import {
18-
describe,
19-
it,
20-
assert,
21-
getRuntime,
22-
setDefaultTimeout,
23-
} from 'test-anywhere';
12+
import { describe, it, assert, setDefaultTimeout } from 'test-anywhere';
2413
import { readFileSync } from 'node:fs';
2514
import path from 'node:path';
2615
import { fileURLToPath } from 'node:url';
16+
import { execSync } from 'node:child_process';
2717

2818
// Set timeout to 20 seconds for slow tests on Windows
2919
setDefaultTimeout(20000);
@@ -37,108 +27,41 @@ const scriptPath = path.join(
3727
);
3828

3929
/**
40-
* Cross-runtime command execution helper
41-
* Works in Node.js, Bun, and Deno
42-
*/
43-
async function execCommand(command, args) {
44-
const runtime = getRuntime();
45-
46-
if (runtime === 'deno') {
47-
// Use Deno.Command for Deno runtime
48-
const cmd = new Deno.Command(command, {
49-
args,
50-
stdout: 'piped',
51-
stderr: 'piped',
52-
});
53-
const output = await cmd.output();
54-
const stdout = new TextDecoder().decode(output.stdout);
55-
const stderr = new TextDecoder().decode(output.stderr);
56-
57-
if (!output.success) {
58-
const error = new Error(`Command failed with exit code ${output.code}`);
59-
error.stdout = stdout;
60-
error.stderr = stderr;
61-
error.status = output.code;
62-
throw error;
63-
}
64-
65-
return { stdout, stderr };
66-
} else {
67-
// Use child_process for Node.js and Bun
68-
const { execSync } = await import('node:child_process');
69-
try {
70-
const stdout = execSync(
71-
`${command} ${args.map((a) => `"${a}"`).join(' ')}`,
72-
{
73-
encoding: 'utf8',
74-
stdio: 'pipe',
75-
}
76-
);
77-
return { stdout, stderr: '' };
78-
} catch (error) {
79-
const err = new Error(error.message);
80-
err.stdout = error.stdout || '';
81-
err.stderr = error.stderr || '';
82-
err.status = error.status;
83-
throw err;
84-
}
85-
}
86-
}
87-
88-
/**
89-
* Get the runtime command for executing JavaScript files
90-
*/
91-
function getRuntimeCommand() {
92-
const runtime = getRuntime();
93-
switch (runtime) {
94-
case 'deno':
95-
return 'deno';
96-
case 'bun':
97-
return 'bun';
98-
default:
99-
return 'node';
100-
}
101-
}
102-
103-
/**
104-
* Get runtime-specific arguments for running a script
30+
* Command execution helper for Bun
10531
*/
106-
function getRuntimeArgs(scriptPath) {
107-
const runtime = getRuntime();
108-
switch (runtime) {
109-
case 'deno':
110-
return [
111-
'run',
112-
'--allow-read',
113-
'--allow-net',
114-
'--allow-env',
115-
'--allow-run',
116-
'--no-check',
117-
scriptPath,
118-
];
119-
case 'bun':
120-
return ['run', scriptPath];
121-
default:
122-
return [scriptPath];
32+
function execCommand(command, args) {
33+
try {
34+
const stdout = execSync(
35+
`${command} ${args.map((a) => `"${a}"`).join(' ')}`,
36+
{
37+
encoding: 'utf8',
38+
stdio: 'pipe',
39+
}
40+
);
41+
return { stdout, stderr: '' };
42+
} catch (error) {
43+
const err = new Error(error.message);
44+
err.stdout = error.stdout || '';
45+
err.stderr = error.stderr || '';
46+
err.status = error.status;
47+
throw err;
12348
}
12449
}
12550

12651
describe('gh-load-pull-request CLI', () => {
12752
it('Script should have shebang and be readable', () => {
12853
const content = readFileSync(scriptPath, 'utf8');
12954
assert.ok(
130-
content.startsWith('#!/usr/bin/env sh'),
55+
content.startsWith('#!/usr/bin/env bun'),
13156
'Missing or incorrect shebang'
13257
);
13358
});
13459

135-
it('--help flag should display help', async () => {
136-
const cmd = getRuntimeCommand();
137-
const baseArgs = getRuntimeArgs(scriptPath);
138-
const args = [...baseArgs, '--help'];
60+
it('--help flag should display help', () => {
61+
const args = ['run', scriptPath, '--help'];
13962

14063
try {
141-
const result = await execCommand(cmd, args);
64+
const result = execCommand('bun', args);
14265
// yargs --help should include "Usage:"
14366
assert.ok(
14467
result.stdout.includes('Usage:') || result.stderr.includes('Usage:'),
@@ -154,13 +77,11 @@ describe('gh-load-pull-request CLI', () => {
15477
}
15578
});
15679

157-
it('--version flag should display version', async () => {
158-
const cmd = getRuntimeCommand();
159-
const baseArgs = getRuntimeArgs(scriptPath);
160-
const args = [...baseArgs, '--version'];
80+
it('--version flag should display version', () => {
81+
const args = ['run', scriptPath, '--version'];
16182

16283
try {
163-
const result = await execCommand(cmd, args);
84+
const result = execCommand('bun', args);
16485
const output = result.stdout + result.stderr;
16586
assert.ok(
16687
output.match(/\d+\.\d+\.\d+/),
@@ -175,13 +96,11 @@ describe('gh-load-pull-request CLI', () => {
17596
}
17697
});
17798

178-
it('Invalid PR format should show helpful error', async () => {
179-
const cmd = getRuntimeCommand();
180-
const baseArgs = getRuntimeArgs(scriptPath);
181-
const args = [...baseArgs, 'invalid-pr-format'];
99+
it('Invalid PR format should show helpful error', () => {
100+
const args = ['run', scriptPath, 'invalid-pr-format'];
182101

183102
try {
184-
await execCommand(cmd, args);
103+
execCommand('bun', args);
185104
// If it doesn't throw, that's unexpected
186105
assert.ok(false, 'Should have failed with invalid format');
187106
} catch (error) {

0 commit comments

Comments
 (0)