@octokit/rest
Advanced tools
Comparing version 15.7.0 to 15.8.0
@@ -13,2 +13,4 @@ module.exports = getRequestAgent | ||
const deprecate = require('./deprecate') | ||
function getRequestAgent (baseUrl, options) { | ||
@@ -25,3 +27,3 @@ if (options.agent) { | ||
agentOptionNames.forEach(option => { | ||
console.warn(`options.${option} is deprecated. Use "options.agent" instead`) | ||
deprecate(`options.${option} (use "options.agent" instead)`) | ||
}) | ||
@@ -33,2 +35,3 @@ | ||
/* istanbul ignore if */ | ||
if ('proxy' in options) { | ||
@@ -35,0 +38,0 @@ const proxyAgentOptions = merge( |
@@ -6,2 +6,3 @@ module.exports = parseOptions | ||
const deprecate = require('./deprecate') | ||
const getRequestAgent = require('./get-request-agent') | ||
@@ -22,23 +23,23 @@ const DEFAULTS = require('./defaults') | ||
if ('followRedirects' in userOptions) { | ||
console.warn('DEPRECATED: followRedirects option is no longer supported. All redirects are followed correctly') | ||
deprecate('followRedirects option is no longer supported. All redirects are followed correctly') | ||
} | ||
if ('protocol' in userOptions) { | ||
console.warn('DEPRECATED: protocol option is no longer supported') | ||
deprecate('protocol option is no longer supported') | ||
} | ||
if ('host' in userOptions) { | ||
console.warn('DEPRECATED: host option is no longer supported') | ||
deprecate('host option is no longer supported') | ||
} | ||
if ('port' in userOptions) { | ||
console.warn('DEPRECATED: port option is no longer supported') | ||
deprecate('port option is no longer supported') | ||
} | ||
if ('pathPrefix' in userOptions) { | ||
console.warn('DEPRECATED: pathPrefix option is no longer supported') | ||
deprecate('pathPrefix option is no longer supported') | ||
} | ||
if ('Promise' in userOptions) { | ||
console.warn('DEPRECATED: Promise option is no longer supported. The native Promise API is used') | ||
deprecate('Promise option is no longer supported. The native Promise API is used') | ||
} | ||
@@ -58,2 +59,3 @@ | ||
/* istanbul ignore else */ | ||
if (userOptions.port) { | ||
@@ -64,2 +66,3 @@ clientDefaults.baseUrl += `:${userOptions.port}` | ||
// Check if a prefix is passed in the options and strip any leading or trailing slashes from it. | ||
/* istanbul ignore else */ | ||
if (userOptions.pathPrefix) { | ||
@@ -66,0 +69,0 @@ clientDefaults.baseUrl += '/' + userOptions.pathPrefix.replace(/(^[/]+|[/]+$)/g, '') |
@@ -6,2 +6,4 @@ module.exports = authenticationBeforeRequest | ||
const deprecate = require('../../deprecate') | ||
function authenticationBeforeRequest (state, options) { | ||
@@ -25,3 +27,3 @@ if (!state.auth.type) { | ||
if (state.auth.type === 'integration') { | ||
console.warn('authentication type "integration" is deprecated. Use "app" instead.') | ||
deprecate('authentication type "integration" is deprecated. Use "app" instead.') | ||
state.auth.type = 'app' | ||
@@ -28,0 +30,0 @@ } |
module.exports = deprecate | ||
const logDeprecationMessage = require('../../deprecate') | ||
function deprecate (func, message) { | ||
return function () { | ||
const caller = (new Error()).stack.split('\n')[2] | ||
console.warn('DEPRECATED: ' + message) | ||
console.warn(caller) | ||
logDeprecationMessage(message) | ||
return func.apply(null, arguments) | ||
} | ||
} |
@@ -7,2 +7,3 @@ module.exports = apiMethod | ||
const deprecate = require('../../deprecate') | ||
const validate = require('./validate') | ||
@@ -18,3 +19,3 @@ | ||
if (endpointDefaults.deprecated) { | ||
console.warn(endpointDefaults.deprecated) | ||
deprecate(endpointDefaults.deprecated) | ||
delete endpointDefaults.deprecated | ||
@@ -21,0 +22,0 @@ } |
@@ -8,2 +8,3 @@ 'use strict' | ||
const HttpError = require('../../request/http-error') | ||
const deprecate = require('../../deprecate') | ||
@@ -28,3 +29,3 @@ function validate (endpointParams, options) { | ||
if (endpointParams[optionName].deprecated) { | ||
console.warn(`DEPRECATED: ${endpointParams[optionName].deprecated}`) | ||
deprecate(`"${optionName}" parameter has been renamed to "${endpointParams[optionName].alias}"`) | ||
} | ||
@@ -31,0 +32,0 @@ }) |
module.exports = getPageLinks | ||
function getPageLinks (link) { | ||
link = link.link || link.meta.link || '' | ||
link = link.link || link.headers.link || '' | ||
@@ -6,0 +6,0 @@ const links = {} |
@@ -38,3 +38,3 @@ module.exports = getPage | ||
function applyAcceptHeader (res, headers) { | ||
const previous = res.meta && res.meta['x-github-media-type'] | ||
const previous = res.headers && res.headers['x-github-media-type'] | ||
@@ -41,0 +41,0 @@ if (!previous || (headers && headers.accept)) { |
@@ -11,2 +11,3 @@ 'use strict' | ||
const deprecate = require('../deprecate') | ||
const getBuffer = require('./get-buffer-response') | ||
@@ -46,2 +47,3 @@ const HttpError = require('./http-error') | ||
let headers = {} | ||
let status | ||
@@ -51,2 +53,3 @@ return fetch(requestOptions.url, pick(requestOptions, 'method', 'body', 'headers', 'timeout', 'agent')) | ||
.then(response => { | ||
status = response.status | ||
for (const keyAndValue of response.headers.entries()) { | ||
@@ -56,3 +59,3 @@ headers[keyAndValue[0]] = keyAndValue[1] | ||
if (response.status === 204 || response.status === 205) { | ||
if (status === 204 || status === 205) { | ||
return | ||
@@ -63,19 +66,19 @@ } | ||
if (requestOptions.method === 'HEAD') { | ||
if (response.status < 400) { | ||
if (status < 400) { | ||
return | ||
} | ||
throw new HttpError(response.statusText, response.status, headers) | ||
throw new HttpError(response.statusText, status, headers) | ||
} | ||
if (response.status === 304) { | ||
if (status === 304) { | ||
requestOptions.url = response.headers.location | ||
throw new HttpError('Not modified', response.status, headers) | ||
throw new HttpError('Not modified', status, headers) | ||
} | ||
if (response.status >= 400) { | ||
if (status >= 400) { | ||
return response.text() | ||
.then(message => { | ||
throw new HttpError(message, response.status, headers) | ||
throw new HttpError(message, status, headers) | ||
}) | ||
@@ -99,3 +102,8 @@ } | ||
data, | ||
meta: headers | ||
status, | ||
headers, | ||
get meta () { | ||
deprecate('response.meta – use response.headers instead (#896)') | ||
return headers | ||
} | ||
} | ||
@@ -102,0 +110,0 @@ }) |
{ | ||
"name": "@octokit/rest", | ||
"version": "15.7.0", | ||
"version": "15.8.0", | ||
"publishConfig": { | ||
@@ -51,4 +51,4 @@ "access": "public", | ||
"@octokit/fixtures-server": "^2.0.1", | ||
"@octokit/routes": "7.4.0", | ||
"@types/node": "^9.4.6", | ||
"@octokit/routes": "8.0.1", | ||
"@types/node": "^10.1.2", | ||
"apidoc": "^0.17.6", | ||
@@ -109,3 +109,3 @@ "bundlesize": "^0.17.0", | ||
"validate:ts": "tsc --target es6 index.d.ts", | ||
"postvalidate:ts": "tsc --noEmit test/typescript-validate.ts", | ||
"postvalidate:ts": "tsc --noEmit --target es6 test/typescript-validate.ts", | ||
"deploy-docs": "gh-pages-with-token -d doc", | ||
@@ -112,0 +112,0 @@ "semantic-release": "semantic-release", |
@@ -23,3 +23,3 @@ # rest.js | ||
type: 'public' | ||
}).then(({data}) => { | ||
}).then(({data, headers, status}) => { | ||
// handle data | ||
@@ -48,3 +48,3 @@ }) | ||
type: 'public' | ||
}).then(({data}) => { | ||
}).then(({data, headers, status}) => { | ||
// handle data | ||
@@ -51,0 +51,0 @@ }) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
553620
42
16066