traverse node_modules and look up all packages to json schema
Install with npm:
$ npm install --save nodemodules2schema
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"
}
projectDir
{string}: the project directory to traverseoptions
{object}: options for nodemodules2schemadepth
{number}: traverse node_modules max depth, default value8
- Attention: node_modules is a black hole, sometimes may be positive infinity and lead to memory overflow
dependenciesKey
{string}: schema key, default value'dependencies'