Brightspace / d2l-license-checker

Simple tool to continuously check for D2L accepted licenses of all npm dependencies in a project.
4 stars 2 forks source link
continuous-integration license-management nodejs

d2l-license-checker

A simple tool to check licenses of all npm dependencies in a project against an approved set of licenses. Can be added to a test suite / CI to get a warning about packages not meeting predefined license requirements. This is basically a wrapper around davglass/license-checker

How to use

  1. Add this package as a development dependency:

    npm install --save-dev d2l-license-checker

  2. Define a new script in your package.json by adding the following lines:

    "scripts": {
      "license-check": "d2l-license-checker"
    }
  3. Add an (optional) config file .licensechecker.json to your node module.

    {
      "acceptedScopes": ["yourCompanyScopeWithoutThe@"],
      "manualOverrides": {
        "some-package@9.9.9": "MIT"
      }
    }
  4. Check that the licenses pass the test by running npm run license-check. See --help for more options.

  5. Make sure npm run license-check is called in your CI build script or as part as your tests

If licenses do not pass the test, you can run npm run license-check -- --generate-template > .licensechecker.template.json to generate a template file that can be copied and pasted into the config file for easy overrides.

Narrowing Analysis

If you only want to check a certain type of dependency, you can supply either --production-only or --development-only to only check the associated dependency type. These options are mutually exclusive, meaning you can only supply one of the flags. Excluding both will simply check all dependencies.

Configuration file

The configuration file is a simple JSON file with the following optional entries:

Versioning and Releasing

This repo is configured to use semantic-release. Commits prefixed with fix: and feat: will trigger patch and minor releases when merged to main.

To learn how to create major releases and release from maintenance branches, refer to the semantic-release GitHub Action documentation.