0.7.0 • Published 3 years ago

library-analyzer v0.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

library-analyzer

Features

  • Collection of information about the libraries used in the project.
  • Collection of download statistics for the libraries.
  • Collection of Github statistics for the libraries.
  • Visualization for the library details.

Installation

npm install library-analyzer

Or use it by npx directly.

Usage

  • Run the command in the project path, and the pages with the visualization results will be generated in the library-analyzer directory.
library-analyzer
  • If always need to get data from the NPM registry, and no need for repository details, can run the following command:
library-analyzer --from-registry --skip-repo-details
  • If no need for repository details and version history, can run the following command:
library-analyzer --skip-repo-details --skip-version-history

CLI Options

--from-registry

If node_modules exists, it will get library details from node_modules by default. Explicitly set this option to obtain library details from the NPM registry, regardless of whether there is node_modules locally.

library-analyzer --from-registry

--skip-downloads

It will collect download statistics by default, explicitly set this option to skip the collection.

library-analyzer --skip-downloads

--skip-repo-details

By default, it will collect repository details including stars, forks, etc, explicitly set this option to skip the collection.

library-analyzer --skip-repo-details

--include-dev-dependencies

It will skip libraries in devDependencies by default, explicitly set this option to collect the details, but it is only valid if the library details are obtained from the NPM registry. If the library details come from the local node_modules, all libraries will be included in the collection.

library-analyzer --include-dev-dependencies

--skip-version-history

By default, it will collect version history of libraries. This option needs to be set only when the library details come from the local node_modules, because in this case, there is no version details, it needs to get the additional information. Explicitly set this option to skip the collection if you do not need it.

library-analyzer --skip-version-history

--github-token

A token is required to fetch Github statistics. The default token has a rate limit, set this option to use your own token to avoid this situation.

library-analyzer --github-token=your token

--output

By default, it will generate results in the web pages. Set this option if need to get other formats. The currently supported formats are page and json. If the value is json, the statistics file will be also generated in the library-analyzer directory.

library-analyzer --output=json

--package-json

By default, it will be analyzed based on package.json in the project root path. Set this option If need to analyze a specific file.

library-analyzer --package-json=your file

--cache-off

By default, it will cache package metadata to speed up analysis. Set this option if not needed.

library-analyzer --cache-off

Library

It can be also used as a library, the sample code is as follows:

const analyzer = require('./index');
analyzer(
  {
    skipVersionHistory: true
  }
).then(data => {
  console.log(data.packages);
});

It will return the following data:

{
  repos: ..., // information about all repositories
  downloads: ..., // download info of libraries
  options: ..., // parameters when calling this method
  packages: ..., // details of all packages
  licenseDetails: ..., // details of all licenses used in libraries
  licenseStatistics: ..., // statistics of the licenses
  osiApprovedStatistics: ...' // osiApproved statistics of the licenses
}

For more details of the data structure, please refer to the generated json file.