repository
repository copied to clipboard
Suggestion: Add license info to package format?
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".
I like this idea a lot, i'd take my train time tomorrow to implement it if nobody has objections
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?
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>.
I maintain a list of all valid SPDX and OSI licenses as a Zig package here https://github.com/nektro/zig-licenses
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.