npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@volumegraphics/license-info-printer

v4.1.0

Published

Collects and renders all dependant module licences of your project to a html document

Downloads

84

Readme

@volumegraphics/license-info-printer

Collects license information of all third-party dependencies of your module and prints it to a nice html document.

Install

npm install --save "@volumegraphics/license-info-printer"

Example

An example can be found here: @volumegraphics/license-info-printer-example

Command Line Interface

You can run the license-info-printer command from the node_modules/.bin directory. The CLI can be integrated into your product build chain. The process will return an error code and error message if it fails and interrupt your build process.

The following arguments are available to the license-info-printer CLI:

Arguments

|Argument|Required|Description| |:-------|:-------|:----------| |productPackageJsonFile | X | File path to your package.json file of your product. The dependencies, devDependencies and optionalDependencies fields in your package.json are all considered to be valid dependencies of your product | |productNodeModulesPaths | X | Directory paths to all node_modules folder that your product depends on. Separate multiple folder paths with ; | |downloadCmd|| A commandline that will be executed before license generation to download files for license generation. The placeholder <downloadDir> defines the directory where the command should download its files| |licenseFilesPath | X | Directory folder path containing all your license files. The path can be prefixed with <download> to access downloaded files (see downloadCmd option). | |configFilePath | X | File path location of the config file. It is used to validate licenses, complete missing license information or overwrite incorrect license information of some modules. See config.json Structure section. The path can be prefixed with <download> to access downloaded files (see downloadCmd option). | |handlebarsTemplate | X | A document template file based on "handlebars" template engine that is used to print your license file. See Document template section. The path can be prefixed with <download> to access downloaded files (see downloadCmd option). | |documentFile | X | File path location to the generated html document. | |errorLogFile | | File path location to the error log file. | |disableNpmVersionCheck | | By default, the license printer insits on a correct npm license string (see spdx for more information). If it is incorrect, it will give you an error. If you set the "disableNpmVersionCheck" flag, it will not do this. | |licenseTextModifier|| Modify the license content before applying it to the template. Valid options are "None" and "JsonString". "JsonString" will encode double quotes. |errorLevelRedundantHomepageOverrides | | Allowed values are "error" and "suppress". Default is "error". if "error" is set, the license printer will give you an error if you have put a hompage override for a license in your config.json but this license is not used by your product. If you set it to "suppress", nothing will happen. | |errorLevelRedundantLicenseOverrides | | Allowed values are "error" and "suppress". Default is "error". if "error" is set, the license printer will give you an error if you have put a license override in your config.json but this license is not used by your product. If you set it to "suppress", nothing will happen. |

Console printings will notify you if an error occured.

Use as library

Instead of using the Command Line Interface, you can invoke the license-info-printer from your code. Example:

import * as lip from "@volumegraphics/license-info-printer";

... // set toDocument arguments here. See CLI section for arguments.

const doc = await lip.toDocument(
  productPackageJsonFile,
  productNodeModulesPaths, // array type
  licenseFilesPath,
  configFilePath,
  handlebarsTemplate,
  disableNpmVersionCheck,
  licenseTextModifier,
  {
    redundantHomepageOverrides,
    redundantLicenseOverrides
  }
);
	
if (doc.type === "Error") {
  for(let m of errorObj.message) {
    console.log(m);
  }
  return;
}

console.log(doc.document);

config.json Structure

You can use the config.json from the Example as template.

{
  "licenses" : [ // set of allowed licenses
    {
      "name": "<Name of a valid NPM license>",
      "file": "<Path to license file>"
    }
  ],
  "overrides" : { // overrides invalid licenses information of third-party modules
    "homepage" : [ // if "homepage" or "author" is not set, you need to overwrite it here.
      {
        "name": "<Exact Name of library>",
        "version": "<Version string>",
        "new" : "<Actual hompage / author>"
      }
    ],
    "license" : [ // if "license" is incorrect, you need to overwrite it here
      {
        "name": "<Name of the library>",
        "version": "<Version string>",
        "new": "<Valid new license>",
        "comment": "<fyi>"
      }
    ]
  }
}

Document template

The documents Template uses the template engine "handlebars". See https://handlebarsjs.com/ on how to configure it. Data layout for the handlebars template:

{
  licenses: [
  {
    index: "<Array index of license>",
    name: "<Name of license>",
    licenseText: "<The license text>",
      libraries: [
        name: "<Library name>",
        version: "<Library version>",
        copyright: "<Copyright holder of the library>"
      ]
    }
  ]
}

You can use the template.html file from the Example as template.

More control required

If you want to have more control over your license evaluations, have a look at @volumegraphics/license-info-collector The license-info-printer uses this library under the hood.