-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fund subcommand #273
Add fund subcommand #273
Conversation
PR-URL: npm#246 Credit: @kemitchell Close: npm#246 Reviewed-by: @ruyadorno Thanks @kemitchell for providing the initial work that served as a base for `npm fund`, its original commits messages are preserved as such: - support: add support subcommand - support: fix request caching - support: further sanitize contributor data - doc: Fix typo - support: simplify to just collecting and showing URLs - install: improve `npm support` test - install: drop "the" before "projects you depend on" - doc: Reword mention of `npm support` in `package.json` spec
This commit introduces the `npm fund` command that lists all `funding` info provided by the installed dependencies of a given project. Notes on implementation: - `lib/utils/funding.js` Provides helpers to validate funding info and return a tree-shaped structure containing the funding data for all deps. - `lib/fund.js` Implements `npm fund <pkg>` command - Added tests - `npm install` mention of funding - `npm fund <pkg>` variations - unit tests for added `lib/utils` and `lib/install` helpers - Added docs for `npm fund`, `funding` `package.json` property - Fixed `lib/utils/open-url` to support `--json` config - Documented `unicode` on `npm install` docs Refs: https://github.com/npm/rfcs/blob/2d2f00457ab19b3003eb6ac5ab3d250259fd5a81/accepted/0017-add-funding-support.md
I would personally favor some way to advertise which project maintainers are available for hire with some quick details or have any other services to offer (no third-party ads please). For example (true example): "@brodybits is available for short-term hire in Boston, NYC, or remote contract" |
@brodybits Hey Chris! Appreciate the feedback but I think it's out of the scope of this work which was talked about & simplified pretty extensively in the original RFC. If you have an idea about a future feature/design we could support, definitely feel free to contribute an RFC over on our npm/rfcs repo and/or, where I think your suggestion may make the most sense, is to investigate the work the Node Foundation Package Maintenance Working Group has done around a more verbose |
This looks amazing! It would be nice to have the info deduplicated and flattened and maybe have an advanced mode (maybe a There seem to be a lot of "noise" in the output from the first gif, a flat list with a white line to break every package info would be more readable. |
If i haven’t chosen to add a dep to package.json, it’s critical that i know how and why a dep is in my graph, or else why would i ever want to give it money? |
@ljharb fair but imagine having 50 packages with sub deps. The list could still be flat and each field can say "Used in: babel-core" or something (assuming babel-core is the dependency you installed). |
it could, but presumably you’d want the list sorted, with direct deps at the top, and then transitive deps sorted by “used in the most packages”. (iow, I’m partially agreeing with you; a tree isn’t the best way to represent this since duplicated deps should be consolidated and summarized) |
Lock files (yarn.lock and package-lock.json) are flat, I'd personally go for that. That said probably shipping any solution and asking the community for feedback is the best way to go. |
A potential issue is that this is version based rather than package based? This means that I cannot set funding information for already released versions of a package. More importantly if funding information changes after a release I cannot fix it (remove a no longer valid funding method for example). |
@npm/cli-team: @giuseppeg raised an important point that went a bit under documented in my original description which is that the current implementation of I quickly put together a demo showing how childs will show up a level above compared to a
the takeaway here is that this output is neither an exact representation of the dependency tree nor a flat list, it's something in between and my idea when working on it is that it's a middle-ground to start with and we can iterate later on with feedback from the community |
@ljharb I think this should be supported by npm, looks like there is already a |
@brodybits i don't need to know that information in general, and i know how to get it without using yarn - i'm talking about directly inline in the funding info, which is where i'd need to see it to gain motivation to donate money to a transitive dep. |
@ruyadorno and what if |
☝️ that is the case yes, in its current implementation |
That seems like proof that this is not the optimal output format to use. |
// within top levels takes precedence over nested ones | ||
return (Object.keys(deps)).map((key) => { | ||
const dep = deps[key] | ||
const { name, funding, version } = dep |
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.
const { name, funding, version } = dep | |
const { name, version } = dep | |
const funding = dep.funding || dep.collective; |
There are many packages using the collective
property today to expose their Open Collective URL. Would be great to support that when funding
is not found, while we wait for them to add it. I
The syntax of collective
is exactly the same as funding
, making the implementation uncomplicated.
It's also nice that this allow anyone to test the feature and see results today, while in the current state it's giving me only empty results for all the projects I tested.
3060: Add `donation_uri` metadata field to gemspec r=bronzdoc a=colby-swandale # Description: I want to add a new metadata field to the gemspec called `donation_uri` for the purpose of linking a page which users can view on how to donate to/sponsor gem authors. With the introduction of [Github Sponsors](https://github.com/sponsors), [Tidlelift](https://tidelift.com/), [Open Collective](https://opencollective.com) & [Patreon](https://www.patreon.com/), donating or sponsoring a developer is now super easy and streamlined. I hope by adding this field to accomplish a number of goals: * Similar to npmjs.org, we add a button/ui element to the gem page on rubygems.org to link visitors to the given donation uri. * Encourage tooling to be built to list information about how to donate to gem authors for a given Gemfile, Gemfile.lock. (similar to the new `npm fund` command npm/cli#273) * Encourage more maintainers to signup and receive sponsorship for their work # Tasks: - [ ] Describe the problem / feature - [ ] Write tests - [ ] Write code to solve the problem - [ ] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md). Co-authored-by: Colby Swandale <[email protected]>
3060: Add `donation_uri` metadata field to gemspec r=bronzdoc a=colby-swandale # Description: I want to add a new metadata field to the gemspec called `donation_uri` for the purpose of linking a page which users can view on how to donate to/sponsor gem authors. With the introduction of [Github Sponsors](https://github.com/sponsors), [Tidlelift](https://tidelift.com/), [Open Collective](https://opencollective.com) & [Patreon](https://www.patreon.com/), donating or sponsoring a developer is now super easy and streamlined. I hope by adding this field to accomplish a number of goals: * Similar to npmjs.org, we add a button/ui element to the gem page on rubygems.org to link visitors to the given donation uri. * Encourage tooling to be built to list information about how to donate to gem authors for a given Gemfile, Gemfile.lock. (similar to the new `npm fund` command npm/cli#273) * Encourage more maintainers to signup and receive sponsorship for their work # Tasks: - [ ] Describe the problem / feature - [ ] Write tests - [ ] Write code to solve the problem - [ ] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md). Co-authored-by: Colby Swandale <[email protected]>
3060: Add `funding_uri ` metadata field to gemspec r=bronzdoc a=colby-swandale # Description: I want to add a new metadata field to the gemspec called `donation_uri` for the purpose of linking a page which users can view on how to donate to/sponsor gem authors. With the introduction of [Github Sponsors](https://github.com/sponsors), [Tidlelift](https://tidelift.com/), [Open Collective](https://opencollective.com) & [Patreon](https://www.patreon.com/), donating or sponsoring a developer is now super easy and streamlined. I hope by adding this field to accomplish a number of goals: * Similar to npmjs.org, we add a button/ui element to the gem page on rubygems.org to link visitors to the given donation uri. * Encourage tooling to be built to list information about how to donate to gem authors for a given Gemfile, Gemfile.lock. (similar to the new `npm fund` command npm/cli#273) * Encourage more maintainers to signup and receive sponsorship for their work # Tasks: - [ ] Describe the problem / feature - [ ] Write tests - [ ] Write code to solve the problem - [ ] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md). Co-authored-by: Colby Swandale <[email protected]>
3060: Add `funding_uri ` metadata field to gemspec r=bronzdoc a=colby-swandale # Description: I want to add a new metadata field to the gemspec called `funding_uri` for the purpose of linking a page which users can view on how to donate to/sponsor gem authors. With the introduction of [Github Sponsors](https://github.com/sponsors), [Tidlelift](https://tidelift.com/), [Open Collective](https://opencollective.com) & [Patreon](https://www.patreon.com/), donating or sponsoring a developer is now super easy and streamlined. I hope by adding this field to accomplish a number of goals: * Similar to npmjs.org, we add a button/ui element to the gem page on rubygems.org to link visitors to the given donation uri. * Encourage tooling to be built to list information about how to donate to gem authors for a given Gemfile, Gemfile.lock. (similar to the new `npm fund` command npm/cli#273) * Encourage more maintainers to signup and receive sponsorship for their work # Tasks: - [ ] Describe the problem / feature - [ ] Write tests - [ ] Write code to solve the problem - [ ] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md). Co-authored-by: Colby Swandale <[email protected]>
Overview
This PR introduces the
npm fund
command that lists allfunding
info provided by the installed dependencies of a given project.✏️ Changes
lib/utils/funding.js
Provides helpers to validate funding info andreturn a tree-shaped structure containing the funding data for all deps.
lib/fund.js
Implementsnpm fund <pkg>
commandnpm install
mention of fundingnpm fund <pkg>
variationslib/utils
andlib/install
helpersnpm fund
,funding
package.json
propertylib/utils/open-url
to support--json
configunicode
onnpm install
docs🔗 References
📸 Screenshots
🔍 Testing
Install a package that has a valid
funding
object declared on itspackage.json
, e.g:npm install sleepover
npm install @ruyadorno/test-funding-dep
✅ This change has unit test coverage
✅ This change has integration test coverage
🔥 Rollback
This can be reverted at any time