8000 fix: address `@octokit/rest` deprecations by gr2m · Pull Request #249 · semantic-release/github · GitHub
[go: up one dir, main page]

Skip to content

fix: address @octokit/rest deprecations #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/get-client.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const {memoize, get} = require('lodash');
const Octokit = require('@octokit/rest');
const {Octokit} = require('@octokit/rest');
const pRetry = require('p-retry');
const Bottleneck = require('bottleneck');
const urljoin = require('url-join');
Expand Down
2 changes: 1 addition & 1 deletion lib/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = async (pluginConfig, context) => {
const fileName = template(asset.name || basename(filePath))(context);
const upload = {
url: uploadUrl,
file: await readFile(resolve(cwd, filePath)),
data: await readFile(resolve(cwd, filePath)),
name: fileName,
headers: {
'content-type': mime.getType(extname(fileName)) || 'text/plain',
Expand Down
5 changes: 2 additions & 3 deletions lib/success.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ module.exports = async (pluginConfig, context) => {
const prs = await pFilter(
uniqBy(flatten(await Promise.all(searchQueries)), 'number'),
async ({number}) =>
(await github.pullRequests.listCommits({owner, repo, pull_number: number})).data.find(({sha}) =>
shas.includes(sha)
) || shas.includes((await github.pullRequests.get({owner, repo, pull_number: number})).data.merge_commit_sha)
(await github.pulls.listCommits({owner, repo, pull_number: number})).data.find(({sha}) => shas.includes(sha)) ||
shas.includes((await github.pulls.get({owner, repo, pull_number: number})).data.merge_commit_sha)
);

debug(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Gregor Martynus (https://twitter.com/gr2m)"
],
"dependencies": {
"@octokit/rest": "^16.27.0",
"@octokit/rest": "^16.43.0",
"@semantic-release/error": "^2.2.0",
"aggregate-error": "^3.0.0",
"bottleneck": "^2.18.1",
Expand Down
10 changes: 5 additions & 5 deletions test/get-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {stub, spy} = require('sinon');
const proxyquire = require('proxyquire');
const Proxy = require('proxy');
const serverDestroy = require('server-destroy');
const Octokit = require('@octokit/rest');
const {Octokit} = require('@octokit/rest');
const rateLimit = require('./helpers/rate-limit');

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

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

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

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