8000 fix: address `@octokit/rest` deprecations (#249) · IKatsuba/github@c1ae4ac · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit c1ae4ac

Browse files
authored
fix: address @octokit/rest deprecations (semantic-release#249)
1 parent e055e41 commit c1ae4ac

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

lib/get-client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const {memoize, get} = require('lodash');
2-
const Octokit = require('@octokit/rest');
2+
const {Octokit} = require('@octokit/rest');
33
const pRetry = require('p-retry');
44
const Bottleneck = require('bottleneck');
55
const urljoin = require('url-join');

lib/publish.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module.exports = async (pluginConfig, context) => {
6767
const fileName = template(asset.name || basename(filePath))(context);
6868
const upload = {
6969
url: uploadUrl,
70-
file: await readFile(resolve(cwd, filePath)),
70+
data: await readFile(resolve(cwd, filePath)),
7171
name: fileName,
7272
headers: {
7373
'content-type': mime.getType(extname(fileName)) || 'text/plain',

lib/success.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ module.exports = async (pluginConfig, context) => {
4949
const prs = await pFilter(
5050
uniqBy(flatten(await Promise.all(searchQueries)), 'number'),
5151
async ({number}) =>
52-
(await github.pullRequests.listCommits({owner, repo, pull_number: number})).data.find(({sha}) =>
53-
shas.includes(sha)
54-
) || shas.includes((await github.pullRequests.get({owner, repo, pull_number: number})).data.merge_commit_sha)
52+
(await github.pulls.listCommits({owner, repo, pull_number: number})).data.find(({sha}) => shas.includes(sha)) ||
53+
shas.includes((await github.pulls.get({owner, repo, pull_number: number})).data.merge_commit_sha)
5554
);
5655

5756
debug(

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"Gregor Martynus (https://twitter.com/gr2m)"
1717
],
1818
"dependencies": {
19-
"@octokit/rest": "^16.27.0",
19+
"@octokit/rest": "^16.43.0",
2020
"@semantic-release/error": "^2.2.0",
2121
"aggregate-error": "^3.0.0",
2222
"bottleneck": "^2.18.1",

test/get-client.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const {stub, spy} = require('sinon');
99
const proxyquire = require('proxyquire');
1010
const Proxy = require('proxy');
1111
const serverDestroy = require('server-destroy');
12-
const Octokit = require('@octokit/rest');
12+
const {Octokit} = require('@octokit/rest');
1313
const rateLimit = require('./helpers/rate-limit');
1414

1515
const getClient = proxyquire('../lib/get-client', {'./definitions/rate-limit': rateLimit});
@@ -94,7 +94,7 @@ test('Use the global throttler for all endpoints', async t => {
9494
const octokit = new Octokit();
9595
octokit.hook.wrap('request', () => Date.now());
9696
const github = proxyquire('../lib/get-client', {
97-
'@octokit/rest': stub().returns(octokit),
97+
'@octokit/rest': {Octokit: stub().returns(octokit)},
9898
'./definitions/rate-limit': {RATE_LIMITS: {search: 1, core: 1}, GLOBAL_RATE_LIMIT: rate},
9999
})({githubToken: 'token'});
100100

@@ -124,7 +124,7 @@ test('Use the same throttler for endpoints in the same rate limit group', async
124124
const octokit = new Octokit();
125125
octokit.hook.wrap('request', () => Date.now());
126126
const github = proxyquire('../lib/get-client', {
127-
'@octokit/rest': stub().returns(octokit),
127+
'@octokit/rest': {Octokit: stub().returns(octokit)},
128128
'./definitions/rate-limit': {RATE_LIMITS: {search: searchRate, core: coreRate}, GLOBAL_RATE_LIMIT: 1},
129129
})({githubToken: 'token'});
130130

@@ -155,7 +155,7 @@ test('Use different throttler for read and write endpoints', async t => {
155155
const octokit = new Octokit();
156156
octokit.hook.wrap('request', () => Date.now());
157157
const github = proxyquire('../lib/get-client', {
158-
'@octokit/rest': stub().returns(octokit),
158+
'@octokit/rest': {Octokit: stub().returns(octokit)},
159159
'./definitions/rate-limit': {RATE_LIMITS: {core: {write: writeRate, read: readRate}}, GLOBAL_RATE_LIMIT: 1},
160160
})({githubToken: 'token'});
161161

@@ -181,7 +181,7 @@ test('Use the same throttler when retrying', async t => {
181181
const octokit = new Octokit();
182182
octokit.hook.wrap('request', request);
183183
const github = proxyquire('../lib/get-client', {
184-
'@octokit/rest': stub().returns(octokit),
184+
'@octokit/rest': {Octokit: stub().returns(octokit)},
185185
'./definitions/rate-limit': {
186186
RETRY_CONF: {retries: 3, factor: 1, minTimeout: 1},
187187
RATE_LIMITS: {core: coreRate},

0 commit comments

Comments
 (0)
0