Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Conversation

kemitchell
Copy link
Contributor

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 and contributors 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.

@kemitchell kemitchell requested a review from a team as a code owner February 13, 2018 22:55
@kemitchell
Copy link
Contributor Author

kemitchell commented Feb 13, 2018

Two lingering thoughts:

  1. Do I need to worry more about memory usage in compiling the list of unique contributors?

    Resolved install: count contributors and mention npx thanks #19817 (comment)
    

  2. I couldn't find any existing tests of the CLI install summary output. Did I miss something ... and possibly break it?

    Resolved install: count contributors and mention npx thanks #19817 (comment)

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 = []
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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!

@kemitchell
Copy link
Contributor Author

@iarna, 476e38fc66b2fa550188c7922e3f4133aedfe005 refactors to use ES2015 Set.

@iarna
Copy link
Contributor

iarna commented Feb 13, 2018

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 release-next, so don't worry about it.

// 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`.
Copy link
Contributor

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…

Copy link
Contributor Author

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?

@kemitchell
Copy link
Contributor Author

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' : '')
Copy link

@billyjanitsch billyjanitsch Feb 14, 2018

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/?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"by"?

iarna pushed a commit that referenced this pull request Feb 14, 2018
@billyjanitsch
Copy link

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.

@iarna
Copy link
Contributor

iarna commented Feb 14, 2018

I don't see any value in waiting, especially seeing as we're not bundling any particular version of thanks and instead encouraging folks to use the evergreen npx thanks, which means the moment that lands it will become available to users.

@iarna
Copy link
Contributor

iarna commented Feb 14, 2018

This PR has been merged to release-next as 737dc85, thanks again! =)

@iarna iarna closed this Feb 14, 2018
@billyjanitsch
Copy link

@iarna would you take a PR with the wording tweak?

@iarna
Copy link
Contributor

iarna commented Feb 14, 2018

@billyjanitsch and I chatted a bunch more over on Discord:

  1. That wording tweak sounds good (and I'll just make it directly, don't worry about a PR).

  2. There are reasonable concerns about endorsing tools this way. No conclusions as yet.

  3. @iarna would like npx thanks to have some pointer to how you participate in the "please contribute" economy. Also maybe some credit to folks who aren't looking for donations?

@feross
Copy link

feross commented Feb 15, 2018

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

@kemitchell
Copy link
Contributor Author

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 npm i mention npx thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants