Comparing version 1.1.2 to 1.2.0
# History | ||
## v1.2.0 2018 November 28 | ||
- Updated [base files](https://github.com/bevry/base) and [editions](https://editions.bevry.me) using [boundation](https://github.com/bevry/boundation) | ||
## v1.1.2 2017 February 28 | ||
- Updated dependencies | ||
- Updated dependencies | ||
## v1.1.1 2017 February 28 | ||
- Internal: explicit use of GitHub API version | ||
- Internal: explicit use of GitHub API version | ||
## v1.1.0 2017 February 27 | ||
- Converted from CoffeeScript to JavaScript | ||
- Fixed rate limit errors not being caught | ||
- Added technical API documentation | ||
- Updated dependencies | ||
## v1.0.7 December 11, 2014 | ||
- Repackaged | ||
- Converted from CoffeeScript to JavaScript | ||
- Fixed rate limit errors not being caught | ||
- Added technical API documentation | ||
- Updated dependencies | ||
## v1.0.6 December 11, 2014 | ||
- Updated dependencies | ||
## v1.0.7 2014 December 11 | ||
## v1.0.5 November 27, 2013 | ||
- Updated GitHub Search API header from `preview` to `beta` | ||
- Updated dependencies | ||
- Repackaged | ||
## v1.0.4 October 4, 2013 | ||
- Fetch repositories individually instead of by search by default | ||
- Updated dependencies | ||
## v1.0.6 2014 December 11 | ||
## v1.0.3 October 3, 2013 | ||
- Updated dependencies | ||
- Updated dependencies | ||
## v1.0.2 October 2, 2013 | ||
- Fixed v1.0.1 | ||
## v1.0.5 2013 November 27 | ||
## v1.0.1 October 2, 2013 | ||
- Fixed paging limits | ||
- Updated GitHub Search API header from `preview` to `beta` | ||
- Updated dependencies | ||
## v1.0.0 October 2, 2013 | ||
- Initial working release | ||
## v1.0.4 2013 October 4 | ||
- Fetch repositories individually instead of by search by default | ||
- Updated dependencies | ||
## v1.0.3 2013 October 3 | ||
- Updated dependencies | ||
## v1.0.2 2013 October 2 | ||
- Fixed v1.0.1 | ||
## v1.0.1 2013 October 2 | ||
- Fixed paging limits | ||
## v1.0.0 2013 October 2 | ||
- Initial working release |
135
package.json
{ | ||
"name": "getrepos", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "Fetch the specified repositories, or those that match a particular github user or search query", | ||
@@ -27,20 +27,21 @@ "homepage": "https://github.com/bevry/getrepos", | ||
"patreon", | ||
"flattr", | ||
"liberapay", | ||
"thanksapp", | ||
"boostlab", | ||
"buymeacoffee", | ||
"opencollective", | ||
"gratipay", | ||
"flattr", | ||
"crypto", | ||
"paypal", | ||
"bitcoin", | ||
"wishlist", | ||
"---", | ||
"slackin" | ||
"wishlist" | ||
], | ||
"config": { | ||
"buymeacoffeeUsername": "balupton", | ||
"cryptoURL": "https://bevry.me/crypto", | ||
"flattrUsername": "balupton", | ||
"liberapayUsername": "bevry", | ||
"opencollectiveUsername": "bevry", | ||
"patreonUsername": "bevry", | ||
"opencollectiveUsername": "bevry", | ||
"gratipayUsername": "bevry", | ||
"flattrUsername": "balupton", | ||
"paypalURL": "https://bevry.me/paypal", | ||
"bitcoinURL": "https://bevry.me/bitcoin", | ||
"wishlistURL": "https://bevry.me/wishlist", | ||
"slackinURL": "https://slack.bevry.me" | ||
"wishlistURL": "https://bevry.me/wishlist" | ||
} | ||
@@ -60,77 +61,75 @@ }, | ||
"type": "git", | ||
"url": "http://github.com/bevry/getrepos.git" | ||
"url": "https://github.com/bevry/getrepos.git" | ||
}, | ||
"engines": { | ||
"node": ">=0.8" | ||
"node": ">=6" | ||
}, | ||
"editions": [ | ||
{ | ||
"description": "Source + ESNext + Require", | ||
"description": "esnext source code with require for modules", | ||
"directory": "source", | ||
"entry": "index.js", | ||
"syntaxes": [ | ||
"tags": [ | ||
"javascript", | ||
"esnext", | ||
"require", | ||
"const", | ||
"let", | ||
"arrows", | ||
"classes", | ||
"defaults", | ||
"destructuring", | ||
"rest", | ||
"spread", | ||
"template strings", | ||
"shorthand" | ||
] | ||
}, | ||
{ | ||
"description": "Babel Compiled + ES2015 + Require", | ||
"directory": "es2015", | ||
"entry": "index.js", | ||
"syntaxes": [ | ||
"javascript", | ||
"es2015", | ||
"require" | ||
] | ||
], | ||
"engines": { | ||
"node": "6 || 8 || 10 || 11", | ||
"browsers": false | ||
} | ||
} | ||
], | ||
"main": "index.js", | ||
"main": "source/index.js", | ||
"dependencies": { | ||
"extendr": "^3.2.2", | ||
"feedr": "^3.0.0", | ||
"taskgroup": "^5.0.1", | ||
"typechecker": "^4.4.1" | ||
}, | ||
"devDependencies": { | ||
"assert-helpers": "^4.5.1", | ||
"eslint": "^5.9.0", | ||
"eslint-config-bevry": "^1.0.1", | ||
"eslint-config-prettier": "^3.3.0", | ||
"eslint-plugin-prettier": "^3.0.0", | ||
"joe": "^2.0.2", | ||
"joe-reporter-console": "^2.0.2", | ||
"jsdoc": "^3.5.5", | ||
"minami": "^1.2.3", | ||
"prettier": "^1.15.2", | ||
"projectz": "^1.5.3", | ||
"surge": "^0.20.1", | ||
"valid-directory": "^1.0.0" | ||
}, | ||
"scripts": { | ||
"our:setup": "npm install", | ||
"our:clean": "rm -Rf ./docs ./es2015", | ||
"our:compile": "npm run our:compile:es2015", | ||
"our:compile:es2015": "babel ./source --out-dir ./es2015 --presets es2015", | ||
"our:clean": "rm -Rf ./docs ./edition* ./es2015 ./es5 ./out", | ||
"our:compile": "echo no need for this project", | ||
"our:deploy": "echo no need for this project", | ||
"our:meta": "npm run our:meta:docs && npm run our:meta:projectz", | ||
"our:meta:docs": "documentation build -f html -o ./docs -g --shallow ./source/**.js", | ||
"our:meta:docs": "rm -Rf ./docs && jsdoc --recurse --pedantic --access all --destination ./docs --package ./package.json --readme ./README.md --template ./node_modules/minami ./source && mv ./docs/$npm_package_name/$npm_package_version/* ./docs/ && rm -Rf ./docs/$npm_package_name/$npm_package_version", | ||
"our:meta:projectz": "projectz compile", | ||
"our:verify": "npm run our:verify:eslint ", | ||
"our:verify:eslint": "eslint --fix ./source", | ||
"our:test": "npm run our:verify && npm test", | ||
"our:release": "npm run our:release:prepare && npm run our:release:check && npm run our:release:tag && npm run our:release:push", | ||
"our:release": "npm run our:release:prepare && npm run our:release:check-changelog && npm run our:release:check-dirty && npm run our:release:tag && npm run our:release:push", | ||
"our:release:check-changelog": "cat ./HISTORY.md | grep v$npm_package_version || (echo add a changelog entry for v$npm_package_version && exit -1)", | ||
"our:release:check-dirty": "git diff --exit-code", | ||
"our:release:prepare": "npm run our:clean && npm run our:compile && npm run our:test && npm run our:meta", | ||
"our:release:check": "npm run our:release:check:changelog && npm run our:release:check:dirty", | ||
"our:release:check:changelog": "cat ./HISTORY.md | grep v$npm_package_version || (echo add a changelog entry for v$npm_package_version && exit -1)", | ||
"our:release:check:dirty": "git diff --exit-code", | ||
"our:release:push": "git push origin master && git push origin --tags", | ||
"our:release:tag": "export MESSAGE=$(cat ./HISTORY.md | sed -n \"/## v$npm_package_version/,/##/p\" | sed 's/## //' | awk 'NR>1{print buf}{buf = $0}') && test \"$MESSAGE\" || (echo 'proper changelog entry not found' && exit -1) && git tag v$npm_package_version -am \"$MESSAGE\"", | ||
"our:release:push": "git push origin master && git push origin --tags", | ||
"test": "node --harmony ./test.js --joe-reporter=console" | ||
"our:setup": "npm run our:setup:npm", | ||
"our:setup:npm": "npm install", | ||
"our:test": "npm run our:verify && npm test", | ||
"our:verify": "npm run our:verify:directory && npm run our:verify:eslint", | ||
"our:verify:directory": "npx valid-directory", | ||
"our:verify:eslint": "eslint --fix --ignore-pattern '**/*.d.ts' './source/**'", | ||
"test": "node --harmony ./source/test.js --joe-reporter=console" | ||
}, | ||
"dependencies": { | ||
"editions": "^1.3.3", | ||
"extendr": "^3.2.2", | ||
"feedr": "^2.13.5", | ||
"taskgroup": "^5.0.1", | ||
"typechecker": "^4.4.1" | ||
"eslintConfig": { | ||
"extends": [ | ||
"bevry" | ||
] | ||
}, | ||
"devDependencies": { | ||
"assert-helpers": "^4.5.0", | ||
"babel-cli": "^6.23.0", | ||
"babel-preset-es2015": "^6.22.0", | ||
"documentation": "^4.0.0-beta.18", | ||
"eslint": "^3.16.1", | ||
"joe": "^2.0.2", | ||
"joe-reporter-console": "^2.0.1", | ||
"projectz": "^1.3.2" | ||
"prettier": { | ||
"semi": false, | ||
"singleQuote": true | ||
} | ||
} |
@@ -17,10 +17,11 @@ <!-- TITLE/ --> | ||
<span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span> | ||
<span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span> | ||
<span class="badge-liberapay"><a href="https://liberapay.com/bevry" title="Donate to this project using Liberapay"><img src="https://img.shields.io/badge/liberapay-donate-yellow.svg" alt="Liberapay donate button" /></a></span> | ||
<span class="badge-thanksapp"><a href="https://givethanks.app/donate/npm/getrepos" title="Donate to this project using Thanks App"><img src="https://img.shields.io/badge/thanksapp-donate-yellow.svg" alt="Thanks App donate button" /></a></span> | ||
<span class="badge-boostlab"><a href="https://boost-lab.app/bevry/getrepos" title="Donate to this project using Boost Lab"><img src="https://img.shields.io/badge/boostlab-donate-yellow.svg" alt="Boost Lab donate button" /></a></span> | ||
<span class="badge-buymeacoffee"><a href="https://buymeacoffee.com/balupton" title="Donate to this project using Buy Me A Coffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg" alt="Buy Me A Coffee donate button" /></a></span> | ||
<span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span> | ||
<span class="badge-gratipay"><a href="https://www.gratipay.com/bevry" title="Donate weekly to this project using Gratipay"><img src="https://img.shields.io/badge/gratipay-donate-yellow.svg" alt="Gratipay donate button" /></a></span> | ||
<span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span> | ||
<span class="badge-crypto"><a href="https://bevry.me/crypto" title="Donate to this project using Cryptocurrency"><img src="https://img.shields.io/badge/crypto-donate-yellow.svg" alt="crypto donate button" /></a></span> | ||
<span class="badge-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span> | ||
<span class="badge-bitcoin"><a href="https://bevry.me/bitcoin" title="Donate once-off to this project using Bitcoin"><img src="https://img.shields.io/badge/bitcoin-donate-yellow.svg" alt="Bitcoin donate button" /></a></span> | ||
<span class="badge-wishlist"><a href="https://bevry.me/wishlist" title="Buy an item on our wishlist for us"><img src="https://img.shields.io/badge/wishlist-donate-yellow.svg" alt="Wishlist browse button" /></a></span> | ||
<br class="badge-separator" /> | ||
<span class="badge-slackin"><a href="https://slack.bevry.me" title="Join this project's slack community"><img src="https://slack.bevry.me/badge.svg" alt="Slack community badge" /></a></span> | ||
@@ -49,5 +50,4 @@ <!-- /BADGES --> | ||
<ul><li><code>getrepos</code> aliases <code>getrepos/index.js</code> which uses <a href="https://github.com/bevry/editions" title="Editions are the best way to produce and consume packages you care about.">Editions</a> to automatically select the correct edition for the consumers environment</li> | ||
<li><code>getrepos/source/index.js</code> is Source + <a href="https://babeljs.io/docs/learn-es2015/" title="ECMAScript Next">ESNext</a> + <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a></li> | ||
<li><code>getrepos/es2015/index.js</code> is <a href="https://babeljs.io" title="The compiler for writing next generation JavaScript">Babel</a> Compiled + <a href="http://babeljs.io/docs/plugins/preset-es2015/" title="ECMAScript 2015">ES2015</a> + <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a></li></ul> | ||
<ul><li><code>getrepos</code> aliases <code>getrepos/source/index.js</code></li> | ||
<li><code>getrepos/source/index.js</code> is esnext source code with require for modules</li></ul> | ||
@@ -119,7 +119,10 @@ <p>Older environments may need <a href="https://babeljs.io/docs/usage/polyfill/" title="A polyfill that emulates missing ECMAScript environment features">Babel's Polyfill</a> or something similar.</p> | ||
<span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span> | ||
<span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span> | ||
<span class="badge-liberapay"><a href="https://liberapay.com/bevry" title="Donate to this project using Liberapay"><img src="https://img.shields.io/badge/liberapay-donate-yellow.svg" alt="Liberapay donate button" /></a></span> | ||
<span class="badge-thanksapp"><a href="https://givethanks.app/donate/npm/getrepos" title="Donate to this project using Thanks App"><img src="https://img.shields.io/badge/thanksapp-donate-yellow.svg" alt="Thanks App donate button" /></a></span> | ||
<span class="badge-boostlab"><a href="https://boost-lab.app/bevry/getrepos" title="Donate to this project using Boost Lab"><img src="https://img.shields.io/badge/boostlab-donate-yellow.svg" alt="Boost Lab donate button" /></a></span> | ||
<span class="badge-buymeacoffee"><a href="https://buymeacoffee.com/balupton" title="Donate to this project using Buy Me A Coffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg" alt="Buy Me A Coffee donate button" /></a></span> | ||
<span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span> | ||
<span class="badge-gratipay"><a href="https://www.gratipay.com/bevry" title="Donate weekly to this project using Gratipay"><img src="https://img.shields.io/badge/gratipay-donate-yellow.svg" alt="Gratipay donate button" /></a></span> | ||
<span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span> | ||
<span class="badge-crypto"><a href="https://bevry.me/crypto" title="Donate to this project using Cryptocurrency"><img src="https://img.shields.io/badge/crypto-donate-yellow.svg" alt="crypto donate button" /></a></span> | ||
<span class="badge-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span> | ||
<span class="badge-bitcoin"><a href="https://bevry.me/bitcoin" title="Donate once-off to this project using Bitcoin"><img src="https://img.shields.io/badge/bitcoin-donate-yellow.svg" alt="Bitcoin donate button" /></a></span> | ||
<span class="badge-wishlist"><a href="https://bevry.me/wishlist" title="Buy an item on our wishlist for us"><img src="https://img.shields.io/badge/wishlist-donate-yellow.svg" alt="Wishlist browse button" /></a></span> | ||
@@ -126,0 +129,0 @@ |
@@ -7,3 +7,3 @@ 'use strict' | ||
const extendr = require('extendr') | ||
const {TaskGroup} = require('taskgroup') | ||
const { TaskGroup } = require('taskgroup') | ||
@@ -17,12 +17,10 @@ /** | ||
*/ | ||
function nameComparator (a, b) { | ||
function nameComparator(a, b) { | ||
const A = a.name.toLowerCase() | ||
const B = b.name.toLowerCase() | ||
if ( A === B ) { | ||
if (A === B) { | ||
return 0 | ||
} | ||
else if ( A < B ) { | ||
} else if (A < B) { | ||
return -1 | ||
} | ||
else { | ||
} else { | ||
return 1 | ||
@@ -53,3 +51,3 @@ } | ||
*/ | ||
static create (...args) { | ||
static create(...args) { | ||
return new this(...args) | ||
@@ -66,3 +64,3 @@ } | ||
*/ | ||
constructor (opts = {}) { | ||
constructor(opts = {}) { | ||
// Prepare | ||
@@ -92,4 +90,4 @@ this.config = { | ||
*/ | ||
log (...args) { | ||
if ( this.config.log ) { | ||
log(...args) { | ||
if (this.config.log) { | ||
this.config.log(...args) | ||
@@ -100,3 +98,2 @@ } | ||
// ================================= | ||
@@ -111,3 +108,3 @@ // Add | ||
*/ | ||
addRepo (repo) { | ||
addRepo(repo) { | ||
// Log | ||
@@ -117,3 +114,3 @@ this.log('debug', 'Adding the repo:', repo) | ||
// Check | ||
if ( !repo || !repo.full_name ) { | ||
if (!repo || !repo.full_name) { | ||
return null | ||
@@ -123,3 +120,3 @@ } | ||
// Update references in database | ||
if ( this.reposMap[repo.full_name] == null ) { | ||
if (this.reposMap[repo.full_name] == null) { | ||
this.reposMap[repo.full_name] = repo | ||
@@ -132,3 +129,2 @@ } | ||
// ================================= | ||
@@ -143,3 +139,3 @@ // Format | ||
*/ | ||
getRepos (repos) { | ||
getRepos(repos) { | ||
// Log | ||
@@ -149,3 +145,3 @@ this.log('debug', 'Get repos') | ||
// Allow the user to pass in their own array or object | ||
if ( repos == null ) { | ||
if (repos == null) { | ||
repos = this.reposMap | ||
@@ -155,6 +151,6 @@ } | ||
// Remove duplicates from array | ||
else if ( typeChecker.isArray(repos) ) { | ||
else if (typeChecker.isArray(repos)) { | ||
const exists = {} | ||
repos = repos.filter(function (repo) { | ||
if ( exists[repo.full_name] == null ) { | ||
repos = repos.filter(function(repo) { | ||
if (exists[repo.full_name] == null) { | ||
exists[repo.full_name] = 0 | ||
@@ -168,4 +164,4 @@ } | ||
// Convert objects to arrays | ||
if ( typeChecker.isPlainObject(repos) ) { | ||
repos = Object.keys(repos).map((key) => repos[key]) | ||
if (typeChecker.isPlainObject(repos)) { | ||
repos = Object.keys(repos).map(key => repos[key]) | ||
} | ||
@@ -181,3 +177,2 @@ | ||
// ================================= | ||
@@ -196,3 +191,3 @@ // Fetch Directly | ||
*/ | ||
fetchRepos (repoFullNames, next) { | ||
fetchRepos(repoFullNames, next) { | ||
// Log | ||
@@ -204,4 +199,4 @@ this.log('debug', 'Fetch repositories:', repoFullNames) | ||
const result = [] | ||
const tasks = TaskGroup.create({concurrency: 0}).done(function (err) { | ||
if ( err ) { | ||
const tasks = TaskGroup.create({ concurrency: 0 }).done(function(err) { | ||
if (err) { | ||
return next(err, []) | ||
@@ -213,6 +208,6 @@ } | ||
// Add the tasks | ||
repoFullNames.forEach(function (repoFullName) { | ||
tasks.addTask(`fetch repo data for ${repoFullName}`, function (complete) { | ||
me.requestRepo(repoFullName, function (err, repo) { | ||
if ( err ) { | ||
repoFullNames.forEach(function(repoFullName) { | ||
tasks.addTask(`fetch repo data for ${repoFullName}`, function(complete) { | ||
me.requestRepo(repoFullName, function(err, repo) { | ||
if (err) { | ||
return complete(err) | ||
@@ -243,7 +238,9 @@ } | ||
*/ | ||
requestRepo (repoFullName, next) { | ||
requestRepo(repoFullName, next) { | ||
// Prepare | ||
const me = this | ||
const feedOptions = { | ||
url: `https://api.github.com/repos/${repoFullName}?client_id=${this.config.githubClientId}&client_secret=${this.config.githubClientSecret}`, | ||
url: `https://api.github.com/repos/${repoFullName}?client_id=${ | ||
this.config.githubClientId | ||
}&client_secret=${this.config.githubClientSecret}`, | ||
parse: 'json', | ||
@@ -258,12 +255,9 @@ requestOptions: { | ||
// Read the user's repository feeds | ||
this.feedr.readFeed(feedOptions, function (err, responseData) { | ||
this.feedr.readFeed(feedOptions, function(err, responseData) { | ||
// Check | ||
if ( err ) { | ||
if (err) { | ||
return next(err, []) | ||
} | ||
else if ( responseData.message ) { | ||
} else if (responseData.message) { | ||
return next(new Error(responseData.message), []) | ||
} | ||
else if ( !responseData.full_name ) { | ||
} else if (!responseData.full_name) { | ||
return next(new Error('response was not a repository'), []) | ||
@@ -283,3 +277,2 @@ } | ||
// ================================= | ||
@@ -298,3 +291,3 @@ // Fetch from Search | ||
*/ | ||
fetchReposFromUsers (users, next) { | ||
fetchReposFromUsers(users, next) { | ||
// Log | ||
@@ -304,3 +297,3 @@ this.log('debug', 'Fetch repos from users:', users) | ||
// Prepare | ||
const query = users.map((name) => `@${name}`).join('%20') | ||
const query = users.map(name => `@${name}`).join('%20') | ||
@@ -321,3 +314,3 @@ // Forward | ||
*/ | ||
fetchReposFromSearch (query, next) { | ||
fetchReposFromSearch(query, next) { | ||
// Prepare | ||
@@ -327,4 +320,4 @@ const me = this | ||
// Check | ||
if ( typeChecker.isArray(query) ) { | ||
query = query.map((name) => `@${name}`).join('%20') | ||
if (typeChecker.isArray(query)) { | ||
query = query.map(name => `@${name}`).join('%20') | ||
} | ||
@@ -336,4 +329,4 @@ | ||
// Read the user's repository feeds | ||
this.requestReposFromSearch(query, {page: 1}, function (err, repos) { | ||
if ( err ) { | ||
this.requestReposFromSearch(query, { page: 1 }, function(err, repos) { | ||
if (err) { | ||
return next(err, []) | ||
@@ -361,10 +354,14 @@ } | ||
*/ | ||
requestReposFromSearch (query, opts = {}, next) { | ||
requestReposFromSearch(query, opts = {}, next) { | ||
// Prepare | ||
const me = this | ||
if ( opts.page == null ) { | ||
if (opts.page == null) { | ||
opts.page = 1 | ||
} | ||
const feedOptions = { | ||
url: `https://api.github.com/search/repositories?page=${opts.page}&per_page=100&q=${query}&client_id=${this.config.githubClientId}&client_secret=${this.config.githubClientSecret}`, | ||
url: `https://api.github.com/search/repositories?page=${ | ||
opts.page | ||
}&per_page=100&q=${query}&client_id=${ | ||
this.config.githubClientId | ||
}&client_secret=${this.config.githubClientSecret}`, | ||
parse: 'json', | ||
@@ -379,17 +376,20 @@ requestOptions: { | ||
// Log | ||
this.log('debug', 'Requesting repositories from search:', query, opts, feedOptions.url) | ||
this.log( | ||
'debug', | ||
'Requesting repositories from search:', | ||
query, | ||
opts, | ||
feedOptions.url | ||
) | ||
// Read the user's repository feeds | ||
this.feedr.readFeed(feedOptions, function (err, responseData) { | ||
this.feedr.readFeed(feedOptions, function(err, responseData) { | ||
// Check | ||
if ( err ) { | ||
if (err) { | ||
return next(err, []) | ||
} | ||
else if ( responseData.message ) { | ||
} else if (responseData.message) { | ||
return next(new Error(responseData.message), []) | ||
} | ||
else if ( !responseData || !Array.isArray(responseData.items) ) { | ||
} else if (!responseData || !Array.isArray(responseData.items)) { | ||
return next(new Error('response was not the format we expected'), []) | ||
} | ||
else if ( responseData.items.length === 0 ) { | ||
} else if (responseData.items.length === 0) { | ||
return next(null, []) | ||
@@ -400,5 +400,5 @@ } | ||
const addedRepos = [] | ||
responseData.items.forEach(function (repo) { | ||
responseData.items.forEach(function(repo) { | ||
const addedRepo = me.addRepo(repo) | ||
if ( addedRepo ) { | ||
if (addedRepo) { | ||
addedRepos.push(addedRepo) | ||
@@ -409,7 +409,7 @@ } | ||
// Success | ||
if ( responseData.items.length === 100 ) { | ||
if (responseData.items.length === 100) { | ||
// Page | ||
opts.page += 1 | ||
me.requestReposFromSearch(query, opts, function (err, moreAddedRepos) { | ||
if ( err ) { | ||
me.requestReposFromSearch(query, opts, function(err, moreAddedRepos) { | ||
if (err) { | ||
return next(err, []) | ||
@@ -420,4 +420,3 @@ } | ||
}) | ||
} | ||
else { | ||
} else { | ||
// Return | ||
@@ -424,0 +423,0 @@ return next(null, addedRepos) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
4
151
2
26356
13
5
351
2
+ Addedcson@5.1.0(transitive)
+ Addedfeedr@3.0.0(transitive)
- Removededitions@^1.3.3
- Removedcson@4.1.0(transitive)
- Removedfeedr@2.13.5(transitive)
- Removedsafeps@6.4.0(transitive)
Updatedfeedr@^3.0.0