Skip to content
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 package.json funding property #192

Merged
merged 3 commits into from Nov 18, 2019

Conversation

ruyadorno
Copy link
Contributor

npm just added a new npm fund command in it's v6.13.0 release as part of the efforts to help out the OSS community.

This PR adds funding info to ky so that users depending on it can actually retrieve the funding url when they run npm fund in their projects.

Note: The funding information will only be available once a new version of the package is published to the npm registry.

@sindresorhus
Copy link
Owner

This is great, but why can’t npm just use funding.yml in the repo? It’s annoying having to duplicate the information. I have 1000+ packages to update now...

@ruyadorno
Copy link
Contributor Author

hi @sindresorhus first of all I'm really sorry this change ends up putting even more pressure on maintainers 😞 it was totally not my intention with it. My goal with this PR was just to raise awareness on the new feature, rest assure I understand your point of view if in case you don't want to go this route for now.

That said, to give you the context I have, I don't think supporting .github/funding.yml itself was ever on our radar (you can see the approved RFC and the discussions prior to it) as we have been working closely with the Node.js foundation package-maintenance working group on their package support proposal and the entire funding initiative evolved from it as an actionable item we could provide to the community sooner rather than later.

Thanks for your feedback, I really value your input on this and would love to discuss more 😊

@ruyadorno
Copy link
Contributor Author

🤔 now that you mentioned it, technically speaking it seems to me that even if we were to support .github/funding.yml itself would also require extra work (in the form of un-ignoring that file + making extra package releases) from open source maintainers since that file is ignored from most packages today.

@sholladay
Copy link
Collaborator

sholladay commented Nov 6, 2019

My expectation would be that npm uses funding.yml as a fallback if this funding property in package.json is not used.

This is sort of similar to how npm respects .gitignore to determine its own behavior, even though .gitignore should not be deployed in the package on the registry. But you can use the files property in package.json to specify a whitelist of files instead - both are supported. npm doesn't try to pretend like git doesn't exist, rather it integrates with git smoothly, yet provides an alternative mechanism for those who choose to use it or who are not using git.

The same principle should apply here, in my opinion.

@sindresorhus
Copy link
Owner

now that you mentioned it, technically speaking it seems to me that even if we were to support .github/funding.yml itself would also require extra work (in the form of un-ignoring that file + making extra package releases) from open source maintainers since that file is ignored from most packages today.

I meant that npm already knows my package is on GitHub as I've specified it in the repo field, so the npm server could look for funding.yml in the specified repo. It doesn't really make sense to include the file in the package itself.

@sindresorhus
Copy link
Owner

@ruyadorno I tried it out on a package of mine: https://github.com/sindresorhus/is-installed-globally/blob/f36107f2b4dd90705ec46759115ae8ae3fd40495/package.json#L12 The RFC says the funding property can just be a string, but that seems to not be working. When I change it to use an object, it works. I'm trying to have the least amount of moot data in my package.json and I feel the type can be inferred from the URL, hence why I want to specify funding as a string.

@ruyadorno
Copy link
Contributor Author

ruyadorno commented Nov 8, 2019

@sindresorhus thank you so much for the heads up! it does sound like an oversight indeed! (I'll bring that up to the team) for now what you can do is to just ignore type in the object declaration, like this: https://github.com/tapjs/node-tap/blob/master/package.json#L105

@sindresorhus
Copy link
Owner

I had another idea. Would have been nice if we at least could have (no URL):

{
	"funding": {
		"type": "github"
	}
}

Which would open https://github.com/sindresorhus/ky?sponsor=1 (try clicking it) for the repo of the package. This is usually desirable for projects with multiple maintainers as it will display the modal as if you had clicked the "Sponsor" repo button, and will show everything from funding.yml, including multiple GitHub Sponsors profiles. That would elegantly solve the problem of duplicate metadata.

@sindresorhus sindresorhus changed the title Added package.json funding property Add package.json funding property Nov 8, 2019
package.json Outdated
@@ -9,6 +9,7 @@
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"funding": "https://github.com/sindresorhus/ky?sponsor=1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

reminder, this won't work at the moment ☺️

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, I'll merge this PR when it's fixed. I don't want to keep changing the format, so I'd rather wait.

@sindresorhus
Copy link
Owner

Merging as support for shorthand is being added in npm/cli#472

@sindresorhus
Copy link
Owner

@ruyadorno I would recommend npm documents the trick of using https://github.com/<user>/<repo>?sponsor=1" as URL for projects with multiple GitHub Sponsors profiles.

@ruyadorno
Copy link
Contributor Author

support to string just landed in v6.13.1

@ruyadorno I would recommend npm documents the trick of using https://github.com//?sponsor=1" as URL for projects with multiple GitHub Sponsors profiles.

thanks for the heads up, I wasn't aware of it 👍 I'll see with the rest of the team if we have a place where that could fit in the docs but otherwise I'll make sure to share in blogs, etc 😊

@ruyadorno ruyadorno deleted the add-package-funding branch November 18, 2019 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants