@hannohealth/generate-licenses-list v1.1.0
generate-licenses-list
A tool to generate a list of licenses from your node_modules
. When it runs, it will create a JSON file with licenses information from all the dependencies and sub-dependencies in your tree.
A fork of license-checker-rseidelsohn which is itself a fork of license-checker. Our version tweaks the behaviour to suit our own requirements.
Installation
To install the package locally:
yarn add -D @hannohealth/generate-licenses-list
npm install --save-dev @hannohealth/generate-licenses-list
Usage
Generate a list of licenses from your repository's package.json
by running:
yarn run generate-licenses-list
npm run generate-licenses-list
Configuration
Adding custom licenses and replacement licenses
In your package.json
, you can additionally configure custom licenses that need to be added to that list, or licenses that you want to replace. The name of the replacement only has to match up until the @
before the version number.
{
licensesConfig: {
"customLicenses": [
{
"name": "custom-package"
"license": "Unlicensed"
"url": "https://github.com/custom-package"
}
],
replacementLicenses: [
{
"name": "lodash" // used for matching, will replace the package: lodash@4.17.20
"license": "Custom" // replaces the existing license with this one
"url": "" // replaces the URL of the matching license
}
]
},
}
Only including production dependencies
To exclude licenses from the devDependencies
field you can pass in the productionOnly
flag. By default, this is set to false
, so all devDependencies
will be included.
yarn run generate-licenses-list --productionOnly
Remove version number string
To cut off the version number from each package, pass in the removeVersions
flag. Packages with different version numbers will only show up once.
yarn run generate-licenses-list --removeVersions
Customising the output path
The default path is reports/licenses.json
. Pass in the outputPath
to customise this:
yarn run generate-licenses-list --outputPath=customPath/licenses.json
Development
- Run
yarn start
to scan this module's own package.json. - Run
yarn test
to run unit tests.
License
MIT