mwittig / npm-license-crawler

Analyzes license information for multiple node.js modules (package.json files) as part of your software project.
BSD 3-Clause "New" or "Revised" License
233 stars 45 forks source link

Option to include license text into json #33

Closed pascalmtts closed 4 years ago

pascalmtts commented 5 years ago

Is there a way to get the content of the license files directly into the output json file?

mwittig commented 5 years ago

Yes, it is generally possible. RFC-7159 does not specify size limits for JSON strings, however, it is stated that implementation may restrict the maximum size of a string (see section 9). Assuming a license file to be in the range of a few kBytes this should not be a problem. Another thing to consider is data encoding. JSON string are UTF-8 so this should not be a big issue assuming most text files are UTF-8 or latin1 these days.

It'll great if you can describe your use case and why you would like to have everything in one file. What about alternatives like outputting JSON and license files to a directory so that all data can written easily to an archive file, e.g. zip?

pascalmtts commented 5 years ago

Alright, then I will describe my use case and maybe someone has a good approach. I would like to display a screen in my web application with all used packages / licenses so that I am save with using this packages. Therefor I thought I could deliver a JSON with all licenses and parse this in my application so that users don't have to download all license files from the server but only one JSON file.

pascalmtts commented 5 years ago

Someone has an idea?

ppo-is commented 4 years ago

https://github.com/davglass/license-checker has this option. But do not seems like it is included in the npm-license-crawler. --customPath customFormatExample.json

xstable commented 4 years ago

Like @pascalmattes described, it would be great to have one license-text per License-Type at all in a file (nevertheless if same json-file, or one license-file per license, and a key in licenses.json point to that license-text-file.

At least it would make live easier to search and paste the licensetext for each used licenses by our own, or prevent to need an online-connection (very valuable for Mobile-Apps!)

I would suggest to load the License-Text from here: https://opensource.org/licenses/alphabetical

BTW: Some of the Licensces has fields like Year and Copyright (which might be the name of the Author) in it. Would be really great, if the JSON-File also could include this as separated field in the json-file.

This way it's easy to creates list like:


dayjs License: MIT ⇐ this might be a link to open the generalized License-Text-Body of MIT-License Copyright (c) 2018-present, iamkun


xstable commented 4 years ago

@pascalmattes do you have any comment, why it's closed?

pascalmtts commented 4 years ago

I don't need it anymore and also there was no recent activity here. Feel free to open a new issue if you need this.

xstable commented 3 years ago

Why, what solution do you have now? Even if you don't need it, you can keep it open here, because it would be an useful feature