-
Notifications
You must be signed in to change notification settings - Fork 3k
install: count contributors and mention npx thanks #19817
Conversation
Two lingering thoughts:
|
lib/install.js
Outdated
@@ -774,6 +774,9 @@ Installer.prototype.printInstalledForHuman = function (diffs, cb) { | |||
var added = 0 | |||
var updated = 0 | |||
var moved = 0 | |||
// Count the number of contributors to packages added, tracking | |||
// contributors we've seen, so we can produce a running unique count. | |||
var contributorsSet = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use a Set
here and get uniqueness for free
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No compat. issue? Then will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, we're Node 4+, which includes Set and Map and Symbol!
@iarna, 476e38fc66b2fa550188c7922e3f4133aedfe005 refactors to use ES2015 |
Given that we already have all of the package info in memory (far more than just the contrib list) I'm not overly concerned about it. There aren't tests of ONLY output, but there are a bunch of tests that include output in their assertions. It looks like your change doesn't impact them, however. The test failure you're seeing is fixed in 30dc1b1 in |
// Make sure a normalized string for every person behind this | ||
// package is in `contributors`. | ||
people.forEach(function (person) { | ||
// Ignore errors from malformed `author` and `contributors`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under what circumstances could normalizePerson
throw? To my reading it would only throw if person
were undefined
or null
? If that's the case, then I think it would be better to just skip those cases…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't have a case in mind. Just try
'd it out of prudence.
Perhaps a TypeError
on String coercion, if person.name
or similar is an Object?
Amended to fix a typo in a comment. |
|
||
output(report) | ||
return cb() | ||
|
||
function packages (num) { | ||
return num + ' package' + (num > 1 ? 's' : '') | ||
} | ||
|
||
function from (num) { | ||
return ' from ' + num + ' contributor' + (num > 1 ? 's' : '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A tiny suggestion:
In the message "installed N packages from M contributors", it's ambiguous whether "from" applies to "packages" or "installed". Read the latter way, it sounds like packages are being installed from multiple places (like multiple contributing registries or something?) which might be confusing for less npm-savvy folks, esp those unfamiliar with the recent Twitter etc. conversations motivating this change.
Is there a way to rephrase? s/from/created by/?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"by"?
PR-URL: #19817 Credit: @kemitchell Reviewed-By: @iarna
Oo also: maybe this could wait until the issue of generality is sorted out? I'm extremely excited about thanks, but if it's gonna be recommended by the npm CLI on every additive install, it's a bummer for the donation information to be centralized -- especially when the tool's wording ("You depend on X authors and Y teams who are seeking donations!") suggests that only authors who have explicitly opted in to this userland project require support. |
I don't see any value in waiting, especially seeing as we're not bundling any particular version of |
This PR has been merged to release-next as 737dc85, thanks again! =) |
@iarna would you take a PR with the wording tweak? |
@billyjanitsch and I chatted a bunch more over on Discord:
|
Wow! Just saw this. You all move quickly! Open to working on the mentioned issues. Is there a log of the Discord discussion somewhere so I can get up-to-speed? Edit: Found it |
For the record, I work on a different set of tools for contributor support, have criticized Patreon, GratiPay, Liberapay, and their ilk as approaches to the problem, and am still in favor of having |
PR-URL: #19817 Credit: @kemitchell Reviewed-By: @iarna
This small pull request affects console reporting on
npm install
and friends.In addition to reporting the number of packages added, the script now also reports the number of unique contributors to those added packages, based on
author
andcontributors
data. When the script reports a contributors count, it also prints a message encouraging users to run @feross'npx thanks
for more information on how to support contributors to the code they use.I've also added a TAP test, based on the test for
npm install --report
.