1.0.3 • Published 4 years ago

nodemodules2schema v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

nodemodules2schema NPM version NPM monthly downloads NPM total downloads

traverse node_modules and look up all packages to json schema

Install

Install with npm:

$ npm install --save nodemodules2schema

Usage

const nodemodules2schema = require('nodemodules2schema');
const projectDir = "/my/project1";
const options = { 
  depth: 5, // traverse node_modules max depth
  // dependenciesKey: "children", // Customize schema key
};
const schema = nodemodules2schema(projectDir, options);

schema

{
  "dependencies": [
    {
      "dependencies": [
        {
          "dependencies": [
            {
              "dependencies": [],
              "name": "isobject",
              "version": "3.0.1"
            }
          ],
          "name": "is-plain-object",
          "version": "2.0.4"
        }
      ],
      "name": "set-value",
      "version": "3.0.2"
    },
    {
      "dependencies": [],
      "name": "universalify",
      "version": "1.0.0"
    }
  ],
  "name": "nodemodules2schema",
  "version": "1.0.0"
}

Params

  • projectDir {string}: the project directory to traverse
  • options {object}: options for nodemodules2schema
    • depth {number}: traverse node_modules max depth, default value 8
      • Attention: node_modules is a black hole, sometimes may be positive infinity and lead to memory overflow
    • dependenciesKey {string}: schema key, default value 'dependencies'