From b092440a3495a14a161795f25d39e456e2ce7376 Mon Sep 17 00:00:00 2001 From: Charlike Mike Reagent <5038030+olstenlarck@users.noreply.github.com> Date: Fri, 9 Feb 2018 18:18:25 +0200 Subject: [PATCH 01/20] add @tunnckoCore / @olstenlarck to authors And if you accept these packages that I added, would be great. They are pretty old, stable and just most used by many and starred. Won't add more. --- index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4410ff4..c8c2312 100644 --- a/index.js +++ b/index.js @@ -25,7 +25,8 @@ const authors = { staltz: 'https://en.liberapay.com/andrestaltz/', thlorenz: 'https://www.patreon.com/thlorenz', yyx990803: 'https://www.patreon.com/evanyou', - juliangruber: 'https://www.patreon.com/juliangruber' + juliangruber: 'https://www.patreon.com/juliangruber', + olstenlarck: 'https://www.paypal.me/tunnckoCore' } /* @@ -58,7 +59,16 @@ const packages = { tachyons: 'https://opencollective.com/tachyons', webpack: 'https://opencollective.com/webpack', yo: 'https://opencollective.com/yeoman', - levelup: 'https://opencollective.com/level' + levelup: 'https://opencollective.com/level', + 'koa-ip-filter': 'https://www.paypal.me/tunnckoCore', + 'koa-better-body': 'https://www.paypal.me/tunnckoCore', + 'koa-better-router': 'https://www.paypal.me/tunnckoCore', + 'koa-rest-router': 'https://www.paypal.me/tunnckoCore', + 'parse-function': 'https://www.paypal.me/tunnckoCore', + 'get-installed-path': 'https://www.paypal.me/tunnckoCore', + gibon: 'https://www.paypal.me/tunnckoCore', + dush: 'https://www.paypal.me/tunnckoCore', + hela: 'https://www.paypal.me/tunnckoCore' } module.exports = { authors, packages } From 44b39f388ac5f96c909e61079024e4d5c8e06df5 Mon Sep 17 00:00:00 2001 From: David Kettler <21echoes@gmail.com> Date: Fri, 9 Feb 2018 11:35:48 -0800 Subject: [PATCH 02/20] For private packages not hosted on NPM, requesting data about them from NPM will fail. Wrap these places in try/catch, or guard against invalid access for bulk fetches. --- src/cmd.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/cmd.js b/src/cmd.js index 482dcdb..70a8591 100755 --- a/src/cmd.js +++ b/src/cmd.js @@ -213,7 +213,12 @@ async function fetchPkg (client, pkgName) { staleOk: true, auth: registryAuthToken() } - return client.getAsync(url, opts) + try { + return await client.getAsync(url, opts) + } catch (err) { + console.error(chalk`\n{red error fetching}`, pkgName, err) + return {} + } } function printTable (authorsSeeking, pkgNamesSeeking, authorsPkgNames, directPkgNames) { @@ -281,14 +286,20 @@ async function bulkFetchPkgDownloads (pkgNames) { const url = DOWNLOADS_URL + pkgNamesSubset.join(',') const res = await got(url, { json: true }) Object.keys(res.body).forEach(pkgName => { - pkgDownloads[pkgName] = res.body[pkgName].downloads + if (res.body[pkgName]) { + pkgDownloads[pkgName] = res.body[pkgName].downloads + } }) } await Promise.all(scopedPkgNames.map(async scopedPkgName => { const url = DOWNLOADS_URL + scopedPkgName - const res = await got(url, { json: true }) - pkgDownloads[scopedPkgName] = res.body.downloads + try { + const res = await got(url, { json: true }) + pkgDownloads[scopedPkgName] = res.body.downloads + } catch (err) { + console.error(chalk`\n{red error fetching}`, scopedPkgName, err) + } })) return pkgDownloads From 8b462437464453bcaf6f49c8837ac8f7f44832fc Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Sat, 10 Feb 2018 02:30:29 +0100 Subject: [PATCH 03/20] Add yoshuawuyts --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index ab48d33..2fb2029 100644 --- a/index.js +++ b/index.js @@ -28,6 +28,7 @@ const authors = { steelbrain: 'https://www.patreon.com/steelbrain', thlorenz: 'https://www.patreon.com/thlorenz', typicode: 'https://www.patreon.com/typicode', + yoshuawuyts: 'https://www.patreon.com/yoshuawuyts', yyx990803: 'https://www.patreon.com/evanyou' } From 34901a1f104f2429ed6b8afd38c25b4478137660 Mon Sep 17 00:00:00 2001 From: Dennis Ideler Date: Sat, 10 Feb 2018 01:41:34 +0000 Subject: [PATCH 04/20] :bug: Fix path for version flag The path to package.json was incorrect since cmd.js has moved from project root to src/. --- src/cmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd.js b/src/cmd.js index 482dcdb..4f4b430 100755 --- a/src/cmd.js +++ b/src/cmd.js @@ -97,7 +97,7 @@ function runHelp () { } function runVersion () { - console.log(require('./package.json').version) + console.log(require('../package.json').version) } async function runThanks (cwd, promptToOpen) { From 61755981efe52bdef75ae772612e4e81eafc9bc4 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 9 Feb 2018 19:31:47 -0800 Subject: [PATCH 05/20] Lots of cleanup, comments, after PR #34 --- src/cmd.js | 69 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/src/cmd.js b/src/cmd.js index 70a8591..38e98cc 100755 --- a/src/cmd.js +++ b/src/cmd.js @@ -125,13 +125,13 @@ async function runThanks (cwd, promptToOpen) { // Get latest registry data on each local package, since the local data does // not include the list of maintainers spinner.text = chalk`Fetching package {cyan maintainers} from {red npm}...` - const allPkgs = await Promise.all(pkgNames.map(pkgName => fetchPkg(client, pkgName))) + let pkgs = await fetchPkgs(client, pkgNames) spinner.text = chalk`Fetching package {cyan download counts} from {red npm}...` const pkgDownloads = await bulkFetchPkgDownloads(pkgNames) // Author name -> list of packages (sorted by direct dependencies, then download count) - const authorsPkgNames = computeAuthorsPkgNames(allPkgs, pkgDownloads, directPkgNames) + const authorsPkgNames = computeAuthorsPkgNames(pkgs, pkgDownloads, directPkgNames) // Array of author names who are seeking donations (sorted by download count) const authorsSeeking = Object.keys(authorsPkgNames) @@ -202,22 +202,33 @@ function isScopedPkg (pkgName) { return pkgName.includes('/') } -async function fetchPkg (client, pkgName) { - // Note: The registry does not support fetching versions for scoped packages - const url = isScopedPkg(pkgName) - ? `${registryUrl()}${pkgName.replace('/', '%2F')}` - : `${registryUrl()}${pkgName}/latest` +async function fetchPkgs (client, pkgNames) { + const pkgs = await Promise.all(pkgNames.map(fetchPkg)) - const opts = { - timeout: 30 * 1000, - staleOk: true, - auth: registryAuthToken() - } - try { - return await client.getAsync(url, opts) - } catch (err) { - console.error(chalk`\n{red error fetching}`, pkgName, err) - return {} + // Filter out `null`s which come from private packages or GitHub dependencies + // which don't exist on npm (so don't have package metadata) + return pkgs.filter(Boolean) + + async function fetchPkg (pkgName) { + // Note: The registry does not support fetching versions for scoped packages + const url = isScopedPkg(pkgName) + ? `${registryUrl()}${pkgName.replace('/', '%2F')}` + : `${registryUrl()}${pkgName}/latest` + + const opts = { + timeout: 30 * 1000, + staleOk: true, + auth: registryAuthToken() + } + + let pkg = null + try { + pkg = await client.getAsync(url, opts) + } catch (err) { + // Private packages or GitHub dependecies that don't exist on npm will return + // 404 errors, so just skip those packages + } + return pkg } } @@ -284,21 +295,33 @@ async function bulkFetchPkgDownloads (pkgNames) { for (let start = 0; start < normalPkgNames.length; start += DOWNLOADS_URL_LIMIT) { const pkgNamesSubset = normalPkgNames.slice(start, start + DOWNLOADS_URL_LIMIT) const url = DOWNLOADS_URL + pkgNamesSubset.join(',') - const res = await got(url, { json: true }) + let res + try { + res = await got(url, { json: true }) + } catch (err) { + // If a single package is requested and does not exists, it will return a 404 + // error. Ignore the error. + continue + } Object.keys(res.body).forEach(pkgName => { - if (res.body[pkgName]) { - pkgDownloads[pkgName] = res.body[pkgName].downloads - } + const stats = res.body[pkgName] + // If multiple packages are requested and some of them do not exist, those keys + // will have a value of null. Skip those packages. + if (stats) pkgDownloads[pkgName] = stats.downloads }) } + // Scoped packages must be requested individually since they're not supported in + // bulk queries. await Promise.all(scopedPkgNames.map(async scopedPkgName => { const url = DOWNLOADS_URL + scopedPkgName + let res try { - const res = await got(url, { json: true }) + res = await got(url, { json: true }) pkgDownloads[scopedPkgName] = res.body.downloads } catch (err) { - console.error(chalk`\n{red error fetching}`, scopedPkgName, err) + // If a single package is requested and does not exists, it will return a 404 + // error. Ignore the error. } })) From 42bfd5e3085f818e5b03bd3afccb63eedbb81fe6 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 9 Feb 2018 19:33:30 -0800 Subject: [PATCH 06/20] 1.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b90674..a261f00 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "thanks", "description": "Give thanks to the open source maintainers you depend on!", - "version": "1.3.0", + "version": "1.4.0", "author": { "name": "Feross Aboukhadijeh", "email": "feross@feross.org", From cf29b4c3142198546f6ca19f51a0f93ab0523d25 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 9 Feb 2018 19:59:54 -0800 Subject: [PATCH 07/20] remove merge conflict - d'oh! --- index.js | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/index.js b/index.js index 5ff5fc5..4f31133 100644 --- a/index.js +++ b/index.js @@ -261,7 +261,6 @@ const packages = { 'streetmix': 'https://opencollective.com/streetmix', 'strider': 'https://opencollective.com/strider', 'styled-components': 'https://opencollective.com/styled-components', -<<<<<<< HEAD 'stylelint': 'https://opencollective.com/stylelint', 'surfbird': 'https://opencollective.com/surfbird', 'sweetalert': 'https://opencollective.com/sweetalert', @@ -296,21 +295,6 @@ const packages = { 'WPGulp': 'https://opencollective.com/wpgulp', 'xss-listener': 'https://opencollective.com/xss-listener', 'yo': 'https://opencollective.com/yeoman' -======= - tachyons: 'https://opencollective.com/tachyons', - webpack: 'https://opencollective.com/webpack', - yo: 'https://opencollective.com/yeoman', - levelup: 'https://opencollective.com/level', - 'koa-ip-filter': 'https://www.paypal.me/tunnckoCore', - 'koa-better-body': 'https://www.paypal.me/tunnckoCore', - 'koa-better-router': 'https://www.paypal.me/tunnckoCore', - 'koa-rest-router': 'https://www.paypal.me/tunnckoCore', - 'parse-function': 'https://www.paypal.me/tunnckoCore', - 'get-installed-path': 'https://www.paypal.me/tunnckoCore', - gibon: 'https://www.paypal.me/tunnckoCore', - dush: 'https://www.paypal.me/tunnckoCore', - hela: 'https://www.paypal.me/tunnckoCore' ->>>>>>> b092440a3495a14a161795f25d39e456e2ce7376 } module.exports = { authors, packages } From da74530e111c53fe83b2e3d367c9fea0bca9c7ef Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 9 Feb 2018 20:00:51 -0800 Subject: [PATCH 08/20] 1.4.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a261f00..962fe6d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "thanks", "description": "Give thanks to the open source maintainers you depend on!", - "version": "1.4.0", + "version": "1.4.1", "author": { "name": "Feross Aboukhadijeh", "email": "feross@feross.org", From 400345d16f212ab8f428a1c605bffd70c1305084 Mon Sep 17 00:00:00 2001 From: Kory Nunn Date: Sat, 10 Feb 2018 15:50:19 +1000 Subject: [PATCH 09/20] Update index.js --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 4f31133..c2f7283 100644 --- a/index.js +++ b/index.js @@ -15,6 +15,7 @@ const authors = { jayphelps: 'https://www.patreon.com/jayphelps', juliangruber: 'https://www.patreon.com/juliangruber', kgryte: 'https://www.patreon.com/athan', + korynunn: 'https://www.patreon.com/korynunn', limonte: 'https://www.patreon.com/limonte', mafintosh: 'https://www.patreon.com/mafintosh', marijn: 'https://www.patreon.com/marijn', From 3540028aa93d43013e167470b50bcac8dc689c5b Mon Sep 17 00:00:00 2001 From: Riyadh Al Nur Date: Sat, 10 Feb 2018 15:32:40 +0800 Subject: [PATCH 10/20] Add myself an as author --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 4f31133..945bdd3 100644 --- a/index.js +++ b/index.js @@ -24,6 +24,7 @@ const authors = { mpj: 'https://www.patreon.com/funfunfunction', noffle: 'https://en.liberapay.com/noffle/', olstenlarck: 'https://www.paypal.me/tunnckoCore', + riyadhalnur: 'https://www.paypal.me/riyadhalnur', shama: 'https://www.patreon.com/shama', sindresorhus: 'https://www.patreon.com/sindresorhus', steelbrain: 'https://www.patreon.com/steelbrain', From ae968dca27c90a470dfb3d4f1216f7d335f42927 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sat, 10 Feb 2018 10:24:53 +0100 Subject: [PATCH 11/20] add author: posva --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 4f31133..db4d9f5 100644 --- a/index.js +++ b/index.js @@ -24,6 +24,7 @@ const authors = { mpj: 'https://www.patreon.com/funfunfunction', noffle: 'https://en.liberapay.com/noffle/', olstenlarck: 'https://www.paypal.me/tunnckoCore', + posva: 'https://www.github.com/posva/donate', shama: 'https://www.patreon.com/shama', sindresorhus: 'https://www.patreon.com/sindresorhus', steelbrain: 'https://www.patreon.com/steelbrain', From 5fd8932a4dc97d5ad71c627fa2bd1e9dfbf15d79 Mon Sep 17 00:00:00 2001 From: Razvan Stoenescu Date: Sat, 10 Feb 2018 14:02:19 +0200 Subject: [PATCH 12/20] Update index.js --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 4f31133..9f9bf2b 100644 --- a/index.js +++ b/index.js @@ -30,7 +30,8 @@ const authors = { thlorenz: 'https://www.patreon.com/thlorenz', typicode: 'https://www.patreon.com/typicode', yoshuawuyts: 'https://www.patreon.com/yoshuawuyts', - yyx990803: 'https://www.patreon.com/evanyou' + yyx990803: 'https://www.patreon.com/evanyou', + rstoenescu: 'https://www.patreon.com/quasarframework' } /* From f5640bca9b59df2855cc999b253290a7c991ce7b Mon Sep 17 00:00:00 2001 From: Tom Chen Date: Sat, 10 Feb 2018 22:36:59 +0800 Subject: [PATCH 13/20] feat: add tomchentw to authors --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 4f31133..83bb4a0 100644 --- a/index.js +++ b/index.js @@ -28,6 +28,7 @@ const authors = { sindresorhus: 'https://www.patreon.com/sindresorhus', steelbrain: 'https://www.patreon.com/steelbrain', thlorenz: 'https://www.patreon.com/thlorenz', + tomchentw: 'https://www.patreon.com/tomchentw', typicode: 'https://www.patreon.com/typicode', yoshuawuyts: 'https://www.patreon.com/yoshuawuyts', yyx990803: 'https://www.patreon.com/evanyou' From 2e0d19dff46b9bbe344d0b01c9c069e62e23ea42 Mon Sep 17 00:00:00 2001 From: Tom Chen Date: Sat, 10 Feb 2018 22:58:08 +0800 Subject: [PATCH 14/20] fix(cmd): return promise in async function --- src/cmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd.js b/src/cmd.js index fa69068..5d99e6e 100755 --- a/src/cmd.js +++ b/src/cmd.js @@ -75,7 +75,7 @@ async function init () { if (argv.version) { return runVersion() } - runThanks(cwd, argv.open) + return runThanks(cwd, argv.open) } function runHelp () { From b14e2078ccd5010c0ecccddb3d7989b5df47d27f Mon Sep 17 00:00:00 2001 From: Jared Hanson Date: Sat, 10 Feb 2018 11:52:40 -0800 Subject: [PATCH 15/20] Add jaredhanson --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 4f31133..8aa974f 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,7 @@ const authors = { hueniverse: 'https://www.patreon.com/eranhammer', hughsk: 'https://hughsk.io/donate/', jayphelps: 'https://www.patreon.com/jayphelps', + jaredhanson: 'https://www.patreon.com/jaredhanson', juliangruber: 'https://www.patreon.com/juliangruber', kgryte: 'https://www.patreon.com/athan', limonte: 'https://www.patreon.com/limonte', From 6f70c867674cdfc3689123d04dce8f073f356d5a Mon Sep 17 00:00:00 2001 From: Antoni Kepinski Date: Sat, 10 Feb 2018 22:38:15 +0100 Subject: [PATCH 16/20] Added myself --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 4f31133..9234f01 100644 --- a/index.js +++ b/index.js @@ -30,7 +30,8 @@ const authors = { thlorenz: 'https://www.patreon.com/thlorenz', typicode: 'https://www.patreon.com/typicode', yoshuawuyts: 'https://www.patreon.com/yoshuawuyts', - yyx990803: 'https://www.patreon.com/evanyou' + yyx990803: 'https://www.patreon.com/evanyou', + akepinski: 'https://www.patreon.com/akepinski' } /* From 97b5a139f8a0a44d2b265d3114179adc6942b39f Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Sun, 11 Feb 2018 11:50:48 -0800 Subject: [PATCH 17/20] Add paulcbetts to thanks --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 4f31133..6d10ee5 100644 --- a/index.js +++ b/index.js @@ -23,6 +23,7 @@ const authors = { moox: 'https://liberapay.com/MoOx/', mpj: 'https://www.patreon.com/funfunfunction', noffle: 'https://en.liberapay.com/noffle/', + paulcbetts: 'https://www.patreon.com/paulcbetts', olstenlarck: 'https://www.paypal.me/tunnckoCore', shama: 'https://www.patreon.com/shama', sindresorhus: 'https://www.patreon.com/sindresorhus', From 2c150654d8c78a971a973cb2b14e20ba7a2f267d Mon Sep 17 00:00:00 2001 From: Haz Date: Sun, 11 Feb 2018 18:44:39 -0200 Subject: [PATCH 18/20] Add diegohaz --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 4f31133..599b556 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ const authors = { andrewnez: 'https://en.liberapay.com/andrew/', antony: 'https://www.patreon.com/wirah', bevacqua: 'https://www.patreon.com/bevacqua', + diegohaz: 'https://www.patreon.com/diegohaz', feross: 'https://www.patreon.com/feross', getify: 'https://www.patreon.com/getify', hueniverse: 'https://www.patreon.com/eranhammer', From 8b78bf5de39f4e681aedb7ab83d3edd25f8ef550 Mon Sep 17 00:00:00 2001 From: Gregor Martynus Date: Sun, 11 Feb 2018 15:21:16 -0800 Subject: [PATCH 19/20] adds @gr2m with https://railsgirlssummerofcode.org/campaign as donation URL --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 4f31133..10115cd 100644 --- a/index.js +++ b/index.js @@ -10,6 +10,7 @@ const authors = { bevacqua: 'https://www.patreon.com/bevacqua', feross: 'https://www.patreon.com/feross', getify: 'https://www.patreon.com/getify', + gr2m: 'https://railsgirlssummerofcode.org/campaign/', hueniverse: 'https://www.patreon.com/eranhammer', hughsk: 'https://hughsk.io/donate/', jayphelps: 'https://www.patreon.com/jayphelps', From 7d2912bdd6fe77b0fd70531164d5e4e5c4f172e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=A9rio=20Vieira?= Date: Sun, 11 Feb 2018 21:50:32 -0200 Subject: [PATCH 20/20] add author: anteriovieira --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 4f31133..6deb635 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ const authors = { andrewnez: 'https://en.liberapay.com/andrew/', antony: 'https://www.patreon.com/wirah', + anteriovieira: 'https://www.patreon.com/anteriovieira', bevacqua: 'https://www.patreon.com/bevacqua', feross: 'https://www.patreon.com/feross', getify: 'https://www.patreon.com/getify',