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

generate-license-file

v3.6.0

Published

Generates a text file containing all of the licenses for your production dependencies

Downloads

74,740

Readme

Generate License File

A CLI and code library to generate a text file containing all of the licenses for your production third-party dependencies.

Installation and Usage (CLI)

npm install generate-license-file --save-dev

npx generate-license-file --input package.json --output third-party-licenses.txt --overwrite

| Argument | Description | | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --input | Absolute or relative path to the package.json for the project. | | --output | Absolute or relative path for the generated output file. | | --overwrite | (optional) Allows the CLI to overwrite existing output files. If this option is not provided and the output file already exists, you will be prompted to confirm. | | --eol | (optional) Specify the line endings used in the output file. Accepted values are crlf or lf. If no value is provided your system default will be used. | | --ci | (optional) Stops the CLI from prompting the user for inputs and instead exits with a non-zero exit code. | | --no-spinner | (optional) Disable the CLI spinner while the output file is being generated. | | --config | (optional) Specify the path to a generate-license-file config file at a non-standard location. | | --version | (optional) Print the installed generate-license-file version. |

If either the --input or --output are omitted the CLI will prompt you for their values.

For a full description of the CLI arguments and their usages please see the relevant docs page.

Installation and Usage (Library API)

npm install generate-license-file --save-dev

TypeScript

import { generateLicenseFile, getLicenseFileText, getProjectLicenses } from "generate-license-file";

// Generate the license file and write it to disk.
await generateLicenseFile("./package.json", "./third-party-licenses.txt");

// Generate the license file content and return it as a string.
const licenseFileText: string = await getLicenseFileText("./package.json");

// Get an array of objects each containing the details of an
// identified license and the dependencies it pertains to.
const licenses: ILicense[] = await getProjectLicenses("./package.json");

For a full description of the library API and example usages please see the relevant docs page.

Advanced Configuration

Advanced configuration of the generated output can be done using a configuration file. In addition to the basic CLI arguments, a configuration file allows you to specify appendices, exclusions, and replacements.

Config files can be called either .glf or .generatelicensefile and can be customised using the following options:

  • File name can optionally end with rc
  • Can be in a ./.config directory (no longer needs the . prefix on the file name)
  • Have the following file extensions: .json, jsonc, .json5, .yaml, .yml, .js, .cjs

E.g. .glf.json, .glfrc.yml, .generatelicensefile.jsonc, .config/glf.js, and more.

{
  // Default config - can be passed in via config and/or CLI
  "inputs": ["./package.json"],
  "output": "./third-party-licenses.txt",
  "lineEnding": "lf",

  // Paths to any file's whose content will be appended to the end of the generated file.
  "append": ["./additional-content.txt"],

  // Substitute the given packages license with the content in the respective file.
  "replace": {
    "[email protected]": "./bespoke-license.txt",
    "another-replaced-package": "./bespoke-license-2.txt"
  },

  // Exclude any packages from the output.
  "exclude": ["[email protected]"],

  // Omit the version number in the output file
  "omitVersion": false
}

If you want to call your config file something else then you can pass it to the CLI via the --config argument:

npx generate-license-file --config ./my-config.json

Contributing and Building From Source

generate-license-file is an NX Monorepo. We have aliased common commands in the scripts section of the src/package.json to make working with the project easier.

Each package in the monorepo (under src/packages/) contains a README with further information. The main library and CLI is under packages/generate-license-file.

# cwd: src/

npm run lint

npm run test  # unit tests

npm run test:e2e  # e2e tests

npm run build  # will build all packages into src/dist/[package name]

License

generate-license-file is licensed under the ISC License.