Comparing version 12.0.1 to 12.0.2
@@ -108,11 +108,5 @@ /** section: github | ||
var className = toCamelCase(defaultMsg) | ||
var className = defaultMsg.replace(/\s/g, '') | ||
exports[className] = error | ||
exports[status] = error | ||
} | ||
function toCamelCase (str) { | ||
return str.toLowerCase().replace(/(?:(^.)|(\s+.))/g, function (match) { | ||
return match.charAt(match.length - 1).toUpperCase() | ||
}) | ||
} |
'use strict' | ||
var error = require('./error') | ||
var fs = require('fs') | ||
var Path = require('path') | ||
var HttpsProxyAgent = require('https-proxy-agent') | ||
var mime = require('mime') | ||
var netrc = require('netrc') | ||
var toCamelCase = require('lodash/camelCase') | ||
var error = require('./error') | ||
var Url = require('url') | ||
var Util = require('./util') | ||
var Url = require('url') | ||
var Promise = require('./promise') | ||
var ROUTES = require('./routes.json') | ||
var DEFINITIONS = require('./definitions.json') | ||
/** section: github | ||
@@ -59,5 +64,5 @@ * class Client | ||
* the `params` block, it's a variable that first needs to be looked up in the | ||
* `params` block of the `defines` section (at the top of the JSON file). Params | ||
* `params` block of `definitions.json`. Params | ||
* that start with a `$` sign will be substituted with the param with the same | ||
* name from the `defines/params` section. | ||
* name from the `params` section of `definitions.json`. | ||
* There we see that it is a required parameter (needs to hold a value). In other | ||
@@ -84,7 +89,5 @@ * words, if the validation requirements are not met, an HTTP error is passed as | ||
this.config = config | ||
this.debug = Util.isTrue(config.debug) | ||
this.debug = config.debug | ||
this.Promise = config.Promise || config.promise || Promise | ||
this.routes = JSON.parse(fs.readFileSync(Path.join(__dirname, '/routes.json'), 'utf8')) | ||
var pathPrefix = '' | ||
@@ -98,3 +101,3 @@ // Check if a prefix is passed in the config and strip any leading or trailing slashes from it. | ||
// store mapping of accept header to preview api endpoints | ||
var mediaHash = this.routes.defines.acceptTree | ||
var mediaHash = DEFINITIONS.acceptTree | ||
var mediaTypes = {} | ||
@@ -143,12 +146,8 @@ | ||
var self = this | ||
var routes = this.routes | ||
var defines = routes.defines | ||
this.constants = defines.constants | ||
this.requestHeaders = defines['request-headers'].map(function (header) { | ||
this.requestHeaders = DEFINITIONS['request-headers'].map(function (header) { | ||
return header.toLowerCase() | ||
}) | ||
this.responseHeaders = defines['response-headers'].map(function (header) { | ||
this.responseHeaders = DEFINITIONS['response-headers'].map(function (header) { | ||
return header.toLowerCase() | ||
}) | ||
delete routes.defines | ||
@@ -162,7 +161,7 @@ function parseParams (msg, paramsStruct) { | ||
paramName = paramName.substr(1) | ||
if (!defines.params[paramName]) { | ||
if (!DEFINITIONS.params[paramName]) { | ||
throw new error.BadRequest("Invalid variable parameter name substitution; param '" + | ||
paramName + "' not found in defines block", 'fatal') | ||
paramName + "' not found in definitions.json", 'fatal') | ||
} else { | ||
def = paramsStruct[paramName] = defines.params[paramName] | ||
def = paramsStruct[paramName] = DEFINITIONS.params[paramName] | ||
delete paramsStruct['$' + paramName] | ||
@@ -239,5 +238,5 @@ } | ||
var parts = messageType.split('/') | ||
var section = Util.toCamelCase(parts[1].toLowerCase()) | ||
var section = toCamelCase(parts[1].toLowerCase()) | ||
parts.splice(0, 2) | ||
var funcName = Util.toCamelCase(parts.join('-')) | ||
var funcName = toCamelCase(parts.join('-')) | ||
@@ -248,3 +247,3 @@ if (!self[section]) { | ||
// section to which functions are attached. | ||
self[Util.toCamelCase('get-' + section + '-api')] = function () { | ||
self[toCamelCase('get-' + section + '-api')] = function () { | ||
return self[section] | ||
@@ -305,3 +304,3 @@ } | ||
prepareApi(routes) | ||
prepareApi(ROUTES) | ||
} | ||
@@ -555,3 +554,3 @@ | ||
if (hasBody) { | ||
return block.requestFormat || this.constants.requestFormat | ||
return block.requestFormat || DEFINITIONS.constants.requestFormat | ||
} | ||
@@ -649,5 +648,5 @@ return 'query' | ||
var format = getRequestFormat.call(this, hasBody, block) | ||
var protocol = this.config.protocol || this.constants.protocol || 'http' | ||
var protocol = this.config.protocol || DEFINITIONS.constants.protocol || 'http' | ||
var port = this.config.port || (protocol === 'https' ? 443 : 80) | ||
var host = block.host || this.config.host || this.constants.host | ||
var host = block.host || this.config.host || DEFINITIONS.constants.host | ||
@@ -657,3 +656,3 @@ // Edge case for github enterprise uploadAsset: | ||
// 2) In enterprise, the pathPrefix changes from: /api/v3 to /api/uploads. | ||
if ((this.config.host && this.config.host !== this.constants.host) && | ||
if ((this.config.host && this.config.host !== DEFINITIONS.constants.host) && | ||
(block.host && block.host === 'uploads.github.com')) { // enterprise uploadAsset | ||
@@ -756,3 +755,3 @@ host = this.config.host | ||
} | ||
addCustomHeaders(Util.extend(msg.headers || {}, this.config.headers)) | ||
addCustomHeaders(Object.assign(msg.headers || {}, this.config.headers)) | ||
@@ -764,3 +763,3 @@ if (!headers['user-agent']) { | ||
if (!('accept' in headers)) { | ||
headers['accept'] = this.acceptUrls[block.url] || this.config.requestMedia || this.constants.requestMedia | ||
headers['accept'] = this.acceptUrls[block.url] || this.config.requestMedia || DEFINITIONS.constants.requestMedia | ||
} | ||
@@ -767,0 +766,0 @@ |
@@ -14,85 +14,2 @@ /** section: github | ||
/** | ||
* Util#extend(dest, src, noOverwrite) -> Object | ||
* - dest (Object): destination object | ||
* - src (Object): source object | ||
* - noOverwrite (Boolean): set to `true` to overwrite values in `src` | ||
* | ||
* Shallow copy of properties from the `src` object to the `dest` object. If the | ||
* `noOverwrite` argument is set to to `true`, the value of a property in `src` | ||
* will not be overwritten if it already exists. | ||
**/ | ||
exports.extend = function (dest, src, noOverwrite) { | ||
for (var prop in src) { | ||
if (!noOverwrite || typeof dest[prop] === 'undefined') { | ||
dest[prop] = src[prop] | ||
} | ||
} | ||
return dest | ||
} | ||
/** | ||
* Util#escapeRegExp(str) -> String | ||
* - str (String): string to escape | ||
* | ||
* Escapes characters inside a string that will an error when it is used as part | ||
* of a regex upon instantiation like in `new RegExp("[0-9" + str + "]")` | ||
**/ | ||
exports.escapeRegExp = function (str) { | ||
return str.replace(/([.*+?^${}()|[\]/\\])/g, '\\$1') | ||
} | ||
/** | ||
* Util#toCamelCase(str, [upper]) -> String | ||
* - str (String): string to transform | ||
* - upper (Boolean): set to `true` to transform to CamelCase | ||
* | ||
* Transform a string that contains spaces or dashes to camelCase. If `upper` is | ||
* set to `true`, the string will be transformed to CamelCase. | ||
* | ||
* Example: | ||
* | ||
* Util.toCamelCase("why U no-work"); // returns 'whyUNoWork' | ||
* Util.toCamelCase("I U no-work", true); // returns 'WhyUNoWork' | ||
**/ | ||
exports.toCamelCase = function (str, upper) { | ||
str = str.toLowerCase().replace(/(?:(^.)|(\s+.)|(-.))/g, function (match) { | ||
return match.charAt(match.length - 1).toUpperCase() | ||
}) | ||
if (upper) { | ||
return str | ||
} | ||
return str.charAt(0).toLowerCase() + str.substr(1) | ||
} | ||
/** | ||
* Util#isTrue(c) -> Boolean | ||
* - c (mixed): value the variable to check. Possible values: | ||
* true The function returns true. | ||
* 'true' The function returns true. | ||
* 'on' The function returns true. | ||
* 1 The function returns true. | ||
* '1' The function returns true. | ||
* | ||
* Determines whether a string is true in the html attribute sense. | ||
**/ | ||
exports.isTrue = function (c) { | ||
return (c === true || c === 'true' || c === 'on' || (typeof c === 'number' && c > 0) || c === '1') | ||
} | ||
/** | ||
* Util#isFalse(c) -> Boolean | ||
* - c (mixed): value the variable to check. Possible values: | ||
* false The function returns true. | ||
* 'false' The function returns true. | ||
* 'off' The function returns true. | ||
* 0 The function returns true. | ||
* '0' The function returns true. | ||
* | ||
* Determines whether a string is false in the html attribute sense. | ||
**/ | ||
exports.isFalse = function (c) { | ||
return (c === false || c === 'false' || c === 'off' || c === 0 || c === '0') | ||
} | ||
var levels = { | ||
@@ -99,0 +16,0 @@ 'info': ['\u001b[90m', '\u001b[39m'], // grey |
@@ -1,1 +0,1 @@ | ||
{"name":"github","version":"12.0.1","description":"NodeJS wrapper for the GitHub API","author":"Mike de Boer <info@mikedeboer.nl>","contributors":[{"name":"Mike de Boer","email":"info@mikedeboer.nl"},{"name":"Fabian Jakobs","email":"fabian@c9.io"},{"name":"Joe Gallo","email":"joe@brassafrax.com"},{"name":"Gregor Martynus","url":"https://github.com/gr2m"}],"repository":"https://github.com/octokit/node-github","engines":{"node":">=4"},"dependencies":{"follow-redirects":"1.2.5","https-proxy-agent":"^2.1.0","mime":"^2.0.3","netrc":"^0.1.4"},"devDependencies":{"@octokit/fixtures":"^3.0.0","chai":"^4.1.2","coveralls":"^3.0.0","mocha":"^4.0.1","mustache":"^2.2.1","npm-run-all":"^4.1.1","nyc":"^11.2.1","standard":"^10.0.3","standard-markdown":"^4.0.2","semantic-release":"^8.2.0"},"main":"lib","types":"lib/index.d.ts","scripts":{"coverage":"nyc report --reporter=html && open coverage/index.html","coverage:upload":"nyc report --reporter=text-lcov | coveralls","pretest":"standard && standard-markdown","test":"nyc mocha test/**/*-test.js","build":"npm-run-all build:*","build:flow":"node lib/generateFlowTypes","build:ts":"node lib/generateTypeScriptTypes","semantic-release":"semantic-release pre && npm publish && semantic-release post"},"license":"MIT","licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"files":["lib"],"apidoc":{"title":"node-github","name":"node-github","version":"11.0.0","template":{"withCompare":true}}} | ||
{"name":"github","version":"12.0.2","description":"NodeJS wrapper for the GitHub API","author":"Mike de Boer <info@mikedeboer.nl>","contributors":[{"name":"Mike de Boer","email":"info@mikedeboer.nl"},{"name":"Fabian Jakobs","email":"fabian@c9.io"},{"name":"Joe Gallo","email":"joe@brassafrax.com"},{"name":"Gregor Martynus","url":"https://github.com/gr2m"}],"repository":"https://github.com/octokit/node-github","engines":{"node":">=4"},"dependencies":{"dotenv":"^4.0.0","follow-redirects":"1.2.5","https-proxy-agent":"^2.1.0","lodash":"^4.17.4","mime":"^2.0.3","netrc":"^0.1.4"},"devDependencies":{"@octokit/fixtures":"^4.1.0","chai":"^4.1.2","coveralls":"^3.0.0","glob":"^7.1.2","mocha":"^4.0.1","mustache":"^2.2.1","npm-run-all":"^4.1.1","nyc":"^11.2.1","proxyquire":"^1.8.0","semantic-release":"^8.2.0","standard":"^10.0.3","standard-markdown":"^4.0.2"},"main":"lib","types":"lib/index.d.ts","scripts":{"coverage":"nyc report --reporter=html && open coverage/index.html","coverage:upload":"nyc report --reporter=text-lcov | coveralls","pretest":"standard && standard-markdown","test":"nyc mocha test/**/*-test.js","build":"npm-run-all build:*","build:flow":"node scripts/generateFlowTypes","build:ts":"node scripts/generateTypeScriptTypes","presemantic-release":"npm run -s build","semantic-release":"semantic-release pre && npm publish && semantic-release post"},"license":"MIT","licenses":[{"type":"The MIT License","url":"http://www.opensource.org/licenses/mit-license.php"}],"files":["lib"],"apidoc":{"title":"node-github","name":"node-github","version":"11.0.0","template":{"withCompare":true}},"nyc":{"ignore":["examples","test"]}} |
@@ -164,13 +164,2 @@ # node-github | ||
## Create test auth file | ||
Create test auth file for running tests/examples. | ||
```bash | ||
$ > testAuth.json | ||
{ | ||
"token": "<TOKEN>" | ||
} | ||
``` | ||
## Promises | ||
@@ -192,5 +181,8 @@ | ||
```bash | ||
$ npm test test/issuesTest.js | ||
$ ./node_modules/.bin/mocha test/test/integration/get-repository-test.js | ||
``` | ||
The examples are run as part of the tests. You can set an `EXAMPLES_GITHUB_TOKEN` environment | ||
variable (or set it in a `.env` file) to avoid running against GitHub's rate limit. | ||
## Preview APIs | ||
@@ -197,0 +189,0 @@ |
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
4
545214
6
12
11
12216
230
+ Addeddotenv@^4.0.0
+ Addedlodash@^4.17.4
+ Addeddotenv@4.0.0(transitive)
+ Addedlodash@4.17.21(transitive)