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

license-tool

v0.0.9

Published

A tool to validate license header, or modify license of target file.

Downloads

19

Readme

license-tool

A tool to validate license header, or modify license of target file.

Please manually verify the programmatic fixes before commit to your repository.

Install

Install From Github Source Code

git clone https://github.com/jackjia-ibm/license-tool
cd license-tool
npm install
npm link

Install From npm Registry

This tool is published to npmjs.com.

npm install -g license-tool

Please note: you need to make sure your registry is npmjs.com.

Usage

Help Information

Usage: license-tool [options] <folder|file>

Options:
  --version         Show version number                                [boolean]
  -L, --standalone  license file stays in root folder
                                            [default: "licenses/standalone.txt"]
  -H, --header      license attached to file header
                                                [default: "licenses/header.txt"]
  -X, --exclude     exclude extra files/folders pattern
  -Y, --years       each file license start year
  -f, --fix         if let the tool fixes the license errors
                                                      [boolean] [default: false]
  -v, --verbose     show more processing details      [boolean] [default: false]
  -h, --help        Show help                                          [boolean]

Configure License Files

Update the default license files located in licenses folder, or you can specify command line options of --header and/or --standaline.

My License Header Requires Year Range

There is special macro {year} you can put in header license file. The macro will be replaced with the correct license year range when parsing that file.

For example, if the file has existing license Copyright abc company 2016. Then if current year is 2018, then the {years} will be parsed to 2016, 2018, and expected license will be Copyright abc company 2016, 2018.

Exclude More Files/Folders

By default, if the folder has .gitignore, the tool will pick up and exclude all files/folders defined there.

Otherwise, you can specify -X or --exclude option to define how you want to exclude. You can combine multiple patterns with ; separated. For example, -X index.js;node_modules/**/*.

For how to define pattern, you can follow glob.

My Files Doesn't Have Accurate License Start Year

You can define license start year for each file.

  • You can define in the command line by separating each file with comma. For example, license-tool . -Y path/to/my/file1.js:2010,path/to/my/file2.js:2011.
  • You can put all definitions in a file. In the file, each file stays in one line, and follow with : and year. An example file:
path/to/my/file1.js:2010
path/to/my/file2.js:2011

Then you can use command license-tool . -Y /path/to/your/definition/file.

Check License Verification Result In Your Pipeline

def licenseErrors = sh(script: "license-tool . -H /path/to/my/header.txt -L /path/to/my/standalone.txt | grep 'should be fixed'", returnStdout: true)

Known Issues

  • Inline comments is not supported because it may involve more complicated semantic check on the source code. For example, these comments won't be recognized:
  let v1 = '1';  /* won't be recognized */
  let v2 = '2';  // won't be recognized
  • The parser may wrongly recognize comments within multiple-lines string because it doesn't do semantic check.