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

npm-dependency-analyzer

v0.7.0

Published

Plugin to validate dependencies, concerning their license and vulnerabities

Downloads

20

Readme

npm-dependency-analyzer

npm license Dependency Status

Analyze Open Source dependencies in a project developed on a Node.js environment. This plugin analyzes all dependencies of a project to check for vulnerabilities and licenses.

Requirements

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Project Policy",
  "description": "A policy with a project related configurations and \tinformation",
  "type": "object",
  "properties": {
    "project_id": {
      "description": "Id of the project to present in the report",
      "type": "string"
    },
    "project_name": {
      "description": "Name of the project to present in the report",
      "type": "string"
    },
    "project_version": {
      "description": "Version of the project to present in the report",
      "type": "string"
    },
    "project_description": {
      "description": "Description of the project to present in the report",
      "type": "string"
    },
    "organization": {
      "description": "The organization the project belongs to",
      "type": "string"
    },
    "repo": {
      "description": "The repository in github the project belongs to",
      "type": "string"
    },
    "repo_owner": {
      "description": "The owner of the repository the project belongs to",
      "type": "string"
    },
    "admin": {
      "description": "The username of the administrator of the project (Only used in project first report)",
      "type": "string"
    },
    "invalid_licenses": {
      "description": "The names of all invalid licenses. Default value is an empty collection",
      "type": "array"
    },
    "fail": {
      "description": "Indicates if the build should fail in case a vulnerability is found. Default value is false",
      "type": "boolean"
    },
    "api_cache_time": {
      "description": "Indicates, in seconds, the amount of time the cached results should be considered valid. If 0 (which is the default value), there are no restrictions on the lifetime of cached results",
      "type": "number"
    }
  },
  "required": ["project_id", "project_name", "admin"]
}

This is a Node.js module available through the npm registry.

Installation is done using the npm install command:

 $ npm install --save-dev npm-dependency-analyzer

How to Use

:warning: In order for the plugin to be executed successfully, it needs to have all dependencies installed by the user install all dependencies before using any functionality provided:

$ npm install

This plugin provides an executable that is placed into "node_modules/.bin" folder of any project it is dependent. This executable can be used in the script property. This command is to be used in the build process of a project, as demonstrated in the example below of a package.json:

{
    "name":"example-project",
    "version":"1.0.0",
    "description":"Example of a project package.json",
    "main":"index.js",
    "bin":{
        "example-command":"./bin/example-command.js"
    },
    "scripts":{
        "prebuild":"npm install && rimraf build/",
        "build":"npm run lint && npm test && npm-dependency-analyzer | bunyan",
        "lint":"eslint .",
        "test":"mocha"
    },
    "engines":{
        "node":">=8.0.0",
        "npm":">=5.7.0"
    },
    "keywords":[
        "Example",
        "Plugin"
    ],
    "dependencies":{
        "async":"^2.6.0",
        "debug":"^3.1.0",
        "executive":"^1.5.13",
        "nsp":"3.2.1"
    },
    "devDependencies":{
        "eslint":"^4.19.0",
        "eslint-config-standard":"^11.0.0",
        "eslint-plugin-import":"^2.10.0",
        "eslint-plugin-node":"^6.0.1",
        "eslint-plugin-promise":"^3.7.0",
        "eslint-plugin-standard":"^3.0.1",
        "mocha":"^5.0.4",
        "rimraf":"^2.6.2"
    }
}

This module uses the logging library bunyan. Every log will be represented as a json object. Bunyan besides providing a Logging API, it provides a CLI tool that parses the json and prettifies it. As shown in the code above the developer can pipe the output of the executable to the cli tool -> "npm-dependency-analyzer | bunyan". After making the necessary adjustments to the package.json, the execution of the build script will have the plugin generate a report based on the findings. This report will then be sent to the central system and stored there. Then the report can be accessed through the following link: http://35.234.147.77/