ghpulls 1.2.0 → 2.0.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.
@@ -0,0 +1,20 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'weekly'
7
+ commit-message:
8
+ prefix: 'chore'
9
+ include: 'scope'
10
+ cooldown:
11
+ default-days: 5
12
+ - package-ecosystem: 'npm'
13
+ directory: '/'
14
+ schedule:
15
+ interval: 'weekly'
16
+ commit-message:
17
+ prefix: 'chore'
18
+ include: 'scope'
19
+ cooldown:
20
+ default-days: 5
@@ -0,0 +1,56 @@
1
+ name: Test & Maybe Release
2
+ on: [push, pull_request]
3
+
4
+ jobs:
5
+ test:
6
+ strategy:
7
+ fail-fast: false
8
+ matrix:
9
+ node: [lts/*, current]
10
+ os: [macos-latest, ubuntu-latest, windows-latest]
11
+ runs-on: ${{ matrix.os }}
12
+ steps:
13
+ - name: Checkout Repository
14
+ uses: actions/checkout@v6
15
+ - name: Use Node.js ${{ matrix.node }}
16
+ uses: actions/setup-node@v6
17
+ with:
18
+ node-version: ${{ matrix.node }}
19
+ - name: Install Dependencies
20
+ run: npm install --no-progress
21
+ - name: Check build is up to date
22
+ run: |
23
+ npm run build
24
+ git diff --exit-code || (echo "::error::Build artifacts not committed. Run 'npm run build' and commit the changes." && exit 1)
25
+ - name: Run tests
26
+ run: npm test
27
+
28
+ release:
29
+ name: Release
30
+ needs: test
31
+ runs-on: ubuntu-latest
32
+ if: github.event_name == 'push' && github.ref == 'refs/heads/master'
33
+ permissions:
34
+ contents: write
35
+ issues: write
36
+ pull-requests: write
37
+ id-token: write
38
+ steps:
39
+ - name: Checkout
40
+ uses: actions/checkout@v6
41
+ with:
42
+ fetch-depth: 0
43
+ - name: Setup Node.js
44
+ uses: actions/setup-node@v6
45
+ with:
46
+ node-version: lts/*
47
+ registry-url: 'https://registry.npmjs.org'
48
+ - name: Install dependencies
49
+ run: npm install --no-progress --no-package-lock --no-save
50
+ - name: Build
51
+ run: npm run build
52
+ - name: Release
53
+ env:
54
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55
+ NPM_CONFIG_PROVENANCE: true
56
+ run: npx semantic-release
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ ## [2.0.0](https://github.com/rvagg/ghpulls/compare/v1.2.0...v2.0.0) (2026-01-27)
2
+
3
+ ### ⚠ BREAKING CHANGES
4
+
5
+ * modernise, ESM, promises, update deps, GHA, auto-release (#3)
6
+
7
+ ### Bug Fixes
8
+
9
+ * add release config ([63600ad](https://github.com/rvagg/ghpulls/commit/63600adf898ac3ccbb51d13b6b70b97605f45ca2))
10
+
11
+ ### Trivial Changes
12
+
13
+ * modernise, ESM, promises, update deps, GHA, auto-release ([#3](https://github.com/rvagg/ghpulls/issues/3)) ([efcd330](https://github.com/rvagg/ghpulls/commit/efcd330eeb0c95293705800583b3072bc0242a7f))
package/README.md CHANGED
@@ -1,46 +1,79 @@
1
1
  # ghpulls
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/rvagg/ghpulls.png)](http://travis-ci.org/rvagg/ghpulls)
3
+ **A Node.js library to interact with the GitHub pull requests API**
4
4
 
5
- **A node library to interact with the GitHub pull requests API**
5
+ [![NPM](https://nodei.co/npm/ghpulls.svg?style=flat&data=n,v&color=blue)](https://nodei.co/npm/ghpulls/)
6
6
 
7
- [![NPM](https://nodei.co/npm/ghpulls.png?mini=true)](https://nodei.co/npm/ghpulls/)
7
+ ## Requirements
8
+
9
+ - Node.js >= 20
8
10
 
9
11
  ## Example usage
10
12
 
11
13
  ```js
12
- const ghpulls = require('ghpulls')
13
- , authOptions = { user: 'rvagg', token: '24d5dee258c64aef38a66c0c5eca459c379901c2' }
14
+ import * as ghpulls from 'ghpulls'
14
15
 
15
- // list all pulls in a repo
16
- ghpulls.list(authOptions, 'rvagg', 'jsonist', function (err, pullslist) {
17
- // Array of pulls data for 'rvagg/jsonist'
18
- console.log(pullslist)
19
- })
16
+ const auth = { token: 'your-github-token' }
17
+
18
+ // list all pull requests in a repo
19
+ const pulls = await ghpulls.list(auth, 'rvagg', 'jsonist')
20
+ console.log(pulls)
21
+
22
+ // list review comments on a pull request
23
+ const comments = await ghpulls.listComments(auth, 'rvagg', 'jsonist', 42)
24
+ console.log(comments)
25
+
26
+ // list reviews on a pull request
27
+ const reviews = await ghpulls.listReviews(auth, 'rvagg', 'jsonist', 42)
28
+ console.log(reviews)
20
29
  ```
21
30
 
22
- The auth data is compatible with [ghauth](https://github.com/rvagg/ghauth) so you can just connect them together to make a simple command-line application:
31
+ The auth data is compatible with [ghauth](https://github.com/rvagg/ghauth) so you can connect them together:
23
32
 
24
33
  ```js
25
- const ghauth = require('ghauth')
26
- , ghpulls = require('ghpulls')
27
- , authOptions = {
28
- configName : 'pulls-lister'
29
- , scopes : [ 'user' ]
30
- }
31
-
32
- ghauth(authOptions, function (err, authData) {
33
- ghpulls.list(authData, 'rvagg', 'node-levelup', function (err, list) {
34
- console.log('Pull requests in rvagg/node-levelup:')
35
- list.forEach(function (i) {
36
- console.log('#%s: %s', i.number, i.title)
37
- })
38
- })
34
+ import ghauth from 'ghauth'
35
+ import * as ghpulls from 'ghpulls'
36
+
37
+ const auth = await ghauth({
38
+ configName: 'pulls-lister',
39
+ scopes: ['user']
40
+ })
41
+
42
+ const pulls = await ghpulls.list(auth, 'rvagg', 'node-levelup')
43
+ console.log('Pull requests in rvagg/node-levelup:')
44
+ pulls.forEach((p) => {
45
+ console.log('#%s: %s', p.number, p.title)
39
46
  })
40
47
  ```
41
48
 
42
- There is also a `ghpulls.listComments(auth, org, repo, num, options, callback)` API for review comments, currently doesn't seem like the end-point is quite complete, however.
49
+ ## API
50
+
51
+ All methods return Promises.
52
+
53
+ ### ghpulls.list(auth, org, repo, options)
54
+
55
+ List pull requests for an org/user and repo combination.
56
+
57
+ ### ghpulls.listComments(auth, org, repo, num, options)
58
+
59
+ List review comments for a given pull request number.
60
+
61
+ ### ghpulls.listReviews(auth, org, repo, num, options)
62
+
63
+ List reviews for a given pull request number.
64
+
65
+ ## Authentication
66
+
67
+ See [ghauth](https://github.com/rvagg/ghauth) for an easy way to obtain and cache GitHub authentication tokens. The `auth` object returned by ghauth is directly compatible with all ghpulls methods.
68
+
69
+ ## See also
70
+
71
+ * [ghissues](https://github.com/rvagg/ghissues) - interact with the GitHub issues API
72
+ * [ghusers](https://github.com/rvagg/ghusers) - interact with the GitHub users API
73
+ * [ghteams](https://github.com/rvagg/ghteams) - interact with the GitHub teams API
74
+ * [ghrepos](https://github.com/rvagg/ghrepos) - interact with the GitHub repos API
75
+ * [ghauth](https://github.com/rvagg/ghauth) - GitHub authentication
43
76
 
44
77
  ## License
45
78
 
46
- **ghpulls** is Copyright (c) 2015 Rod Vagg [@rvagg](https://github.com/rvagg) and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
79
+ **ghpulls** is Copyright (c) 2015-2025 Rod Vagg [@rvagg](https://github.com/rvagg) and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
package/ghpulls.js CHANGED
@@ -1,24 +1,21 @@
1
- const ghutils = require('ghutils')
1
+ import { lister } from 'ghutils'
2
2
 
3
- module.exports.list = function list (auth, org, repo, options, callback) {
4
- if (typeof options == 'function') {
5
- callback = options
6
- options = {}
7
- }
3
+ const defaultApiUrl = 'https://api.github.com'
8
4
 
9
- var url = 'https://api.github.com/repos/' + org + '/' + repo + '/pulls?page=1'
10
- ghutils.lister(auth, url, options, callback)
5
+ export async function list (auth, org, repo, options = {}) {
6
+ const apiUrl = options._apiUrl || defaultApiUrl
7
+ const url = `${apiUrl}/repos/${org}/${repo}/pulls`
8
+ return lister(auth, url, options)
11
9
  }
12
10
 
13
-
14
- function listComments (auth, org, repo, num, options, callback) {
15
- if (typeof options == 'function') {
16
- callback = options
17
- options = {}
18
- }
19
-
20
- var url = 'https://api.github.com/repos/' + org + '/' + repo + '/pulls/' + num + '/comments?page=1'
21
- ghutils.lister(auth, url, options, callback)
11
+ export async function listComments (auth, org, repo, num, options = {}) {
12
+ const apiUrl = options._apiUrl || defaultApiUrl
13
+ const url = `${apiUrl}/repos/${org}/${repo}/pulls/${num}/comments`
14
+ return lister(auth, url, options)
22
15
  }
23
16
 
24
- module.exports.listComments = listComments
17
+ export async function listReviews (auth, org, repo, num, options = {}) {
18
+ const apiUrl = options._apiUrl || defaultApiUrl
19
+ const url = `${apiUrl}/repos/${org}/${repo}/pulls/${num}/reviews`
20
+ return lister(auth, url, options)
21
+ }
package/package.json CHANGED
@@ -1,10 +1,17 @@
1
1
  {
2
2
  "name": "ghpulls",
3
- "version": "1.2.0",
3
+ "version": "2.0.0",
4
4
  "description": "Interact with the GitHub pull requests API",
5
- "main": "ghpulls.js",
5
+ "type": "module",
6
+ "exports": "./ghpulls.js",
7
+ "engines": {
8
+ "node": ">=20"
9
+ },
6
10
  "scripts": {
7
- "test": "node test.js | faucet"
11
+ "lint": "standard",
12
+ "build": "true",
13
+ "test:unit": "node --test test.js",
14
+ "test": "npm run lint && npm run test:unit"
8
15
  },
9
16
  "repository": {
10
17
  "type": "git",
@@ -21,14 +28,98 @@
21
28
  },
22
29
  "homepage": "https://github.com/rvagg/ghpulls",
23
30
  "dependencies": {
24
- "ghutils": "~3.2.1"
31
+ "ghutils": "^5.0.2"
25
32
  },
26
33
  "devDependencies": {
27
- "bl": "~1.0.0",
28
- "faucet": "0.0.1",
29
- "hyperquest": "~1.2.0",
30
- "require-subvert": "~0.1.0",
31
- "tape": "~4.2.2",
32
- "xtend": "~4.0.1"
34
+ "@semantic-release/changelog": "^6.0.3",
35
+ "@semantic-release/commit-analyzer": "^13.0.1",
36
+ "@semantic-release/git": "^10.0.1",
37
+ "@semantic-release/github": "^12.0.2",
38
+ "@semantic-release/npm": "^13.1.3",
39
+ "@semantic-release/release-notes-generator": "^14.1.0",
40
+ "conventional-changelog-conventionalcommits": "^9.1.0",
41
+ "semantic-release": "^25.0.2",
42
+ "standard": "^17.1.2"
43
+ },
44
+ "release": {
45
+ "branches": [
46
+ "master"
47
+ ],
48
+ "plugins": [
49
+ [
50
+ "@semantic-release/commit-analyzer",
51
+ {
52
+ "preset": "conventionalcommits",
53
+ "releaseRules": [
54
+ {
55
+ "breaking": true,
56
+ "release": "major"
57
+ },
58
+ {
59
+ "revert": true,
60
+ "release": "patch"
61
+ },
62
+ {
63
+ "type": "feat",
64
+ "release": "minor"
65
+ },
66
+ {
67
+ "type": "fix",
68
+ "release": "patch"
69
+ },
70
+ {
71
+ "type": "chore",
72
+ "release": "patch"
73
+ },
74
+ {
75
+ "type": "docs",
76
+ "release": "patch"
77
+ },
78
+ {
79
+ "type": "test",
80
+ "release": "patch"
81
+ },
82
+ {
83
+ "scope": "no-release",
84
+ "release": false
85
+ }
86
+ ]
87
+ }
88
+ ],
89
+ [
90
+ "@semantic-release/release-notes-generator",
91
+ {
92
+ "preset": "conventionalcommits",
93
+ "presetConfig": {
94
+ "types": [
95
+ {
96
+ "type": "feat",
97
+ "section": "Features"
98
+ },
99
+ {
100
+ "type": "fix",
101
+ "section": "Bug Fixes"
102
+ },
103
+ {
104
+ "type": "chore",
105
+ "section": "Trivial Changes"
106
+ },
107
+ {
108
+ "type": "docs",
109
+ "section": "Trivial Changes"
110
+ },
111
+ {
112
+ "type": "test",
113
+ "section": "Tests"
114
+ }
115
+ ]
116
+ }
117
+ }
118
+ ],
119
+ "@semantic-release/changelog",
120
+ "@semantic-release/npm",
121
+ "@semantic-release/github",
122
+ "@semantic-release/git"
123
+ ]
33
124
  }
34
125
  }
package/test.js CHANGED
@@ -1,152 +1,131 @@
1
- const http = require('http')
2
- , ghutils = require('ghutils/test-util')
3
- , test = require('tape')
4
- , xtend = require('xtend')
5
- , bl = require('bl')
6
- , ghpulls = require('./')
7
-
8
-
9
- test('test list pulls', function (t) {
10
- t.plan(10)
11
-
12
- var auth = { user: 'authuser', token: 'authtoken' }
13
- , org = 'testorg'
14
- , repo = 'testrepo'
15
- , testData = [
16
- {
17
- response : [ { test1: 'data1' }, { test2: 'data2' } ]
18
- , headers : { link: '<https://api.github.com/repos/testorg/testrepo/pulls?page=2>; rel="next"' }
19
- }
20
- , { response: [] }
21
- ]
22
- , server
23
-
24
- server = ghutils.makeServer(testData)
25
- .on('ready', function () {
26
- ghpulls.list(xtend(auth), org, repo, ghutils.verifyData(t, testData[0].response))
1
+ import { test } from 'node:test'
2
+ import assert from 'node:assert'
3
+ import { createMockServer, createMockServerWithHandler } from 'ghutils/test-util'
4
+ import * as ghpulls from './ghpulls.js'
5
+
6
+ test('list pulls', async () => {
7
+ const auth = { token: 'test-token' }
8
+ const testData = [{ id: 1, title: 'PR 1' }, { id: 2, title: 'PR 2' }]
9
+
10
+ const server = await createMockServer({ response: testData })
11
+ try {
12
+ const results = await ghpulls.list(auth, 'testorg', 'testrepo', {
13
+ _apiUrl: server.baseUrl
27
14
  })
28
- .on('request', ghutils.verifyRequest(t, auth))
29
- .on('get', ghutils.verifyUrl(t, [
30
- 'https://api.github.com/repos/testorg/testrepo/pulls?page=1'
31
- , 'https://api.github.com/repos/testorg/testrepo/pulls?page=2'
32
- ]))
33
- .on('close' , ghutils.verifyClose(t))
15
+ assert.deepStrictEqual(results, testData)
16
+ assert.ok(server.requests[0].url.includes('/repos/testorg/testrepo/pulls'))
17
+ assert.strictEqual(server.requests[0].headers.authorization, 'Bearer test-token')
18
+ } finally {
19
+ await server.close()
20
+ }
34
21
  })
35
22
 
36
-
37
- test('test list multi-page pulls', function (t) {
38
- t.plan(13)
39
-
40
- var auth = { user: 'authuser', token: 'authtoken' }
41
- , org = 'testorg'
42
- , repo = 'testrepo'
43
- , testData = [
44
- {
45
- response : [ { test1: 'data1' }, { test2: 'data2' } ]
46
- , headers : { link: '<https://api.github.com/repos/testorg/testrepo/pulls?page=2>; rel="next"' }
47
- }
48
- , {
49
- response : [ { test1: 'data3' }, { test2: 'data4' } ]
50
- , headers : { link: '<https://api.github.com/repos/testorg/testrepo/pulls?page=3>; rel="next"' }
51
- }
52
- , { response: [] }
53
- ]
54
- , server
55
-
56
- server = ghutils.makeServer(testData)
57
- .on('ready', function () {
58
- ghpulls.list(xtend(auth), org, repo, ghutils.verifyData(t, testData[0].response.concat(testData[1].response)))
23
+ test('list pulls with pagination', async () => {
24
+ const auth = { token: 'test-token' }
25
+ const page1 = [{ id: 1 }, { id: 2 }]
26
+ const page2 = [{ id: 3 }, { id: 4 }]
27
+
28
+ let requestCount = 0
29
+ const mock = await createMockServerWithHandler((req, res) => {
30
+ requestCount++
31
+ const port = mock.address().port
32
+ if (requestCount === 1) {
33
+ res.setHeader('link', `<http://127.0.0.1:${port}/page2>; rel="next"`)
34
+ res.end(JSON.stringify(page1))
35
+ } else {
36
+ res.end(JSON.stringify(page2))
37
+ }
38
+ })
39
+
40
+ try {
41
+ const results = await ghpulls.list(auth, 'testorg', 'testrepo', {
42
+ _apiUrl: mock.baseUrl
59
43
  })
60
- .on('request', ghutils.verifyRequest(t, auth))
61
- .on('get', ghutils.verifyUrl(t, [
62
- 'https://api.github.com/repos/testorg/testrepo/pulls?page=1'
63
- , 'https://api.github.com/repos/testorg/testrepo/pulls?page=2'
64
- , 'https://api.github.com/repos/testorg/testrepo/pulls?page=3'
65
- ]))
66
- .on('close' , ghutils.verifyClose(t))
44
+ assert.deepStrictEqual(results, [...page1, ...page2])
45
+ assert.strictEqual(requestCount, 2)
46
+ } finally {
47
+ await mock.close()
48
+ }
67
49
  })
68
50
 
51
+ test('list pulls returns empty array', async () => {
52
+ const auth = { token: 'test-token' }
69
53
 
70
- test('test list no pulls', function (t) {
71
- t.plan(7)
72
-
73
- var auth = { user: 'authuser', token: 'authtoken' }
74
- , org = 'testorg'
75
- , repo = 'testrepo'
76
- , testData = [ [] ]
77
- , server
78
-
79
- server = ghutils.makeServer(testData)
80
- .on('ready', function () {
81
- ghpulls.list(xtend(auth), org, repo, ghutils.verifyData(t, []))
54
+ const server = await createMockServer({ response: [] })
55
+ try {
56
+ const results = await ghpulls.list(auth, 'testorg', 'testrepo', {
57
+ _apiUrl: server.baseUrl
82
58
  })
83
- .on('request', ghutils.verifyRequest(t, auth))
84
- .on('get', ghutils.verifyUrl(t, [
85
- 'https://api.github.com/repos/testorg/testrepo/pulls?page=1'
86
- ]))
87
- .on('close' , ghutils.verifyClose(t))
59
+ assert.deepStrictEqual(results, [])
60
+ } finally {
61
+ await server.close()
62
+ }
88
63
  })
89
64
 
90
- test('test list multi-page pulls, options.afterDate includes all', function (t) {
91
- t.plan(13)
92
-
93
- var auth = { user: 'authuser', token: 'authtoken' }
94
- , org = 'testorg'
95
- , repo = 'testrepo'
96
- , testData = [
97
- {
98
- response : [ { test1: 'data1', created_at: new Date('2015-12-14T05:58:14.421Z').toISOString() }, { test2: 'data2', created_at: new Date('2015-12-13T05:58:14.421Z').toISOString() } ]
99
- , headers : { link: '<https://api.github.com/repos/testorg/testrepo/pulls?page=2>; rel="next"' }
100
- }
101
- , {
102
- response : [ { test1: 'data3', created_at: new Date('2015-12-12T05:58:14.421Z').toISOString() }, { test2: 'data4', created_at: new Date('2015-12-11T05:58:14.421Z').toISOString() } ]
103
- , headers : { link: '<https://api.github.com/repos/testorg/testrepo/pulls?page=3>; rel="next"' }
104
- }
105
- , { response: [] }
106
- ]
107
- , server
65
+ test('list pull comments', async () => {
66
+ const auth = { token: 'test-token' }
67
+ const comments = [{ id: 1, body: 'Comment 1' }]
108
68
 
109
- server = ghutils.makeServer(testData)
110
- .on('ready', function () {
111
- ghpulls.list(xtend(auth), org, repo, { afterDate: new Date('2015-12-10T05:58:14.421Z') }, ghutils.verifyData(t, testData[0].response.concat(testData[1].response)))
69
+ const server = await createMockServer({ response: comments })
70
+ try {
71
+ const results = await ghpulls.listComments(auth, 'testorg', 'testrepo', 42, {
72
+ _apiUrl: server.baseUrl
112
73
  })
113
- .on('request', ghutils.verifyRequest(t, auth))
114
- .on('get', ghutils.verifyUrl(t, [
115
- 'https://api.github.com/repos/testorg/testrepo/pulls?page=1'
116
- , 'https://api.github.com/repos/testorg/testrepo/pulls?page=2'
117
- , 'https://api.github.com/repos/testorg/testrepo/pulls?page=3'
118
- ]))
119
- .on('close' , ghutils.verifyClose(t))
74
+ assert.deepStrictEqual(results, comments)
75
+ assert.ok(server.requests[0].url.includes('/repos/testorg/testrepo/pulls/42/comments'))
76
+ } finally {
77
+ await server.close()
78
+ }
120
79
  })
121
80
 
81
+ test('list pull reviews', async () => {
82
+ const auth = { token: 'test-token' }
83
+ const reviews = [{ id: 1, state: 'APPROVED' }]
122
84
 
123
- test('test list multi-page pulls, options.afterDate includes partial', function (t) {
124
- t.plan(10)
125
-
126
- var auth = { user: 'authuser', token: 'authtoken' }
127
- , org = 'testorg'
128
- , repo = 'testrepo'
129
- , testData = [
130
- {
131
- response : [ { test1: 'data1', created_at: new Date('2015-12-14T05:58:14.421Z').toISOString() }, { test2: 'data2', created_at: new Date('2015-12-13T05:58:14.421Z').toISOString() } ]
132
- , headers : { link: '<https://api.github.com/repos/testorg/testrepo/pulls?page=2>; rel="next"' }
133
- }
134
- , {
135
- response : [ { test1: 'data3', created_at: new Date('2015-12-12T05:58:14.421Z').toISOString() }, { test2: 'data4', created_at: new Date('2015-12-11T05:58:14.421Z').toISOString() } ]
136
- , headers : { link: '<https://api.github.com/repos/testorg/testrepo/pulls?page=3>; rel="next"' }
137
- }
138
- // also tests that we don't fetch any more beyond this point, i.e. only 2 requests needed
139
- ]
140
- , server
85
+ const server = await createMockServer({ response: reviews })
86
+ try {
87
+ const results = await ghpulls.listReviews(auth, 'testorg', 'testrepo', 42, {
88
+ _apiUrl: server.baseUrl
89
+ })
90
+ assert.deepStrictEqual(results, reviews)
91
+ assert.ok(server.requests[0].url.includes('/repos/testorg/testrepo/pulls/42/reviews'))
92
+ } finally {
93
+ await server.close()
94
+ }
95
+ })
141
96
 
142
- server = ghutils.makeServer(testData)
143
- .on('ready', function () {
144
- ghpulls.list(xtend(auth), org, repo, { afterDate: new Date('2015-12-11T15:58:14.421Z') }, ghutils.verifyData(t, testData[0].response.concat([ testData[1].response[0] ])))
97
+ test('list pulls with afterDate', async () => {
98
+ const auth = { token: 'test-token' }
99
+ const page1 = [
100
+ { id: 1, created_at: '2024-01-15T00:00:00Z' },
101
+ { id: 2, created_at: '2024-01-14T00:00:00Z' }
102
+ ]
103
+ const page2 = [
104
+ { id: 3, created_at: '2024-01-13T00:00:00Z' },
105
+ { id: 4, created_at: '2024-01-10T00:00:00Z' }
106
+ ]
107
+
108
+ let requestCount = 0
109
+ const mock = await createMockServerWithHandler((req, res) => {
110
+ requestCount++
111
+ const port = mock.address().port
112
+ if (requestCount === 1) {
113
+ res.setHeader('link', `<http://127.0.0.1:${port}/page2>; rel="next"`)
114
+ res.end(JSON.stringify(page1))
115
+ } else {
116
+ res.end(JSON.stringify(page2))
117
+ }
118
+ })
119
+
120
+ try {
121
+ const afterDate = new Date('2024-01-12T00:00:00Z')
122
+ const results = await ghpulls.list(auth, 'testorg', 'testrepo', {
123
+ _apiUrl: mock.baseUrl,
124
+ afterDate
145
125
  })
146
- .on('request', ghutils.verifyRequest(t, auth))
147
- .on('get', ghutils.verifyUrl(t, [
148
- 'https://api.github.com/repos/testorg/testrepo/pulls?page=1'
149
- , 'https://api.github.com/repos/testorg/testrepo/pulls?page=2'
150
- ]))
151
- .on('close' , ghutils.verifyClose(t))
126
+ assert.strictEqual(results.length, 3)
127
+ assert.deepStrictEqual(results.map(r => r.id), [1, 2, 3])
128
+ } finally {
129
+ await mock.close()
130
+ }
152
131
  })
package/.jshintrc DELETED
@@ -1,59 +0,0 @@
1
- {
2
- "predef": [ ]
3
- , "bitwise": false
4
- , "camelcase": false
5
- , "curly": false
6
- , "eqeqeq": false
7
- , "forin": false
8
- , "immed": false
9
- , "latedef": false
10
- , "noarg": true
11
- , "noempty": true
12
- , "nonew": true
13
- , "plusplus": false
14
- , "quotmark": true
15
- , "regexp": false
16
- , "undef": true
17
- , "unused": true
18
- , "strict": false
19
- , "trailing": true
20
- , "maxlen": 120
21
- , "asi": true
22
- , "boss": true
23
- , "debug": true
24
- , "eqnull": true
25
- , "esnext": true
26
- , "evil": true
27
- , "expr": true
28
- , "funcscope": false
29
- , "globalstrict": false
30
- , "iterator": false
31
- , "lastsemic": true
32
- , "laxbreak": true
33
- , "laxcomma": true
34
- , "loopfunc": true
35
- , "multistr": false
36
- , "onecase": false
37
- , "proto": false
38
- , "regexdash": false
39
- , "scripturl": true
40
- , "smarttabs": false
41
- , "shadow": false
42
- , "sub": true
43
- , "supernew": false
44
- , "validthis": true
45
- , "browser": true
46
- , "couch": false
47
- , "devel": false
48
- , "dojo": false
49
- , "mootools": false
50
- , "node": true
51
- , "nonstandard": true
52
- , "prototypejs": false
53
- , "rhino": false
54
- , "worker": true
55
- , "wsh": false
56
- , "nomen": false
57
- , "onevar": false
58
- , "passfail": false
59
- }
package/.npmignore DELETED
@@ -1,2 +0,0 @@
1
- node_modules
2
- ex.js
package/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - "0.10"
4
- branches:
5
- only:
6
- - master
7
- notifications:
8
- email:
9
- - rod@vagg.org
10
- script: npm test