repository icon indicating copy to clipboard operation
repository copied to clipboard

Suggestion: Add license info to package format?

Open dropwhile opened this issue 4 years ago • 4 comments
trafficstars

Might be nice to add a license field to the package json.

Something super simple like:

"license": "MIT",
"license_url": "https://github.com/ziglibs/repository/blob/main/LICENSE"

Where LICENSE is one of predefined text, for instance one of PUBDOMAIN | MIT | BSD-3C | BSD-2C | ISC | APACHE-2.0 | GPL2 | GPL3 | ... | CUSTOM
Where CUSTOM could be a catch all for "not a common one; user should investigate further".

dropwhile avatar Dec 06 '20 04:12 dropwhile

I like this idea a lot, i'd take my train time tomorrow to implement it if nobody has objections

ikskuh avatar Dec 06 '20 08:12 ikskuh

You could use the shortnames https://opensource.org/licenses/alphabetical gives to these licenses? So e.g. BSD-2-Clause. Or perhaps there is some other list of labels already, like in https://github.com/github/choosealicense.com?

marnix avatar Dec 06 '20 15:12 marnix

I just discovered https://spdx.org/licenses/ which defines such shortnames ("SPDX IDs"), and defines license expressions like (MIT OR Apache-2.0) (https://spdx.github.io/spdx-spec/appendix-IV-SPDX-license-expressions/), and a GitHub repo defining their official licenses list (e.g., https://github.com/spdx/license-list-data/raw/master/json/licenses.json).

Apparently, for all its complexity (144 page PDF!), the SPDX spec has no way to say 'custom'. So npm -- which adopted SPDX license expressions -- chose to allow two additional shortnames (https://docs.npmjs.com/cli/v6/configuring-npm/package-json#license), one of which is SEE LICENSE IN <filename>.

marnix avatar Dec 08 '20 07:12 marnix

I maintain a list of all valid SPDX and OSI licenses as a Zig package here https://github.com/nektro/zig-licenses

nektro avatar Jul 14 '21 20:07 nektro

After #39, license is added to packages, it use the key field in GitHub API, the full meaning can be found here:

  • https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository#searching-github-by-license-type

There is even an REST API to retrieve it:

  • https://docs.github.com/en/rest/licenses#get-all-commonly-used-licenses

So, I think this issue could be close.

jiacai2050 avatar Sep 27 '22 14:09 jiacai2050