Name: logical-tree
Owner: npm
Description: Calculates a nested logical tree using a package.json and a package lock.
Created: 2017-10-07 18:15:31.0
Updated: 2018-05-16 04:52:18.0
Pushed: 2018-03-30 12:47:48.0
Homepage: null
Size: 69
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
npm-logical-tree
is a Node.js
library that takes the contents of a package.json
and package-lock.json
(or
npm-shrinkwrap.json
) and returns a nested tree data structure representing the
logical relationships between the different dependencies.
$ npm install npm-logical-tree
logicalTree
logicalTree.node
tree.isRoot
tree.addDep
tree.delDep
tree.getDep
tree.path
tree.hasCycle
tree.forEach
tree.forEachAsync
t fs = require('fs')
t logicalTree = require('npm-logical-tree')
t pkg = require('./package.json')
t pkgLock = require('./package-lock.json')
calTree(pkg, pkgLock)
eturns:
calTree {
me: 'npm-logical-tree',
rsion: '1.0.0',
dress: null,
tional: false,
v: false,
ndled: false,
solved: undefined,
tegrity: undefined,
quiredBy: Set { },
pendencies:
ap {
'foo' => LogicalTree {
name: 'foo',
version: '1.2.3',
address: 'foo',
optional: false,
dev: true,
bundled: false,
resolved: 'https://registry.npmjs.org/foo/-/foo-1.2.3.tgz',
integrity: 'sha1-rYUK/p261/SXByi0suR/7Rw4chw=',
dependencies: Map { ... },
requiredBy: Set { ... },
},
...
The npm team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.
All participants and maintainers in this project are expected to follow Code of Conduct, and just generally be excellent to each other.
Please refer to the Changelog for project history details, too.
Happy hacking!
> logicalTree(pkg, lock) -> LogicalTree
Calculates a logical tree based on a matching package.json
and
package-lock.json
pair. A “logical tree” is a fully-nested dependency graph
for an npm package, as opposed to a physical tree which might be flattened.
logical-tree
will represent deduplicated/flattened nodes using the same object
throughout the tree, so duplication can be checked by object identity.
t pkg = require('./package.json')
t pkgLock = require('./package-lock.json')
calTree(pkg, pkgLock)
eturns:
calTree {
me: 'npm-logical-tree',
rsion: '1.0.0',
dress: null,
tional: false,
v: false,
ndled: false,
solved: undefined,
tegrity: undefined,
quiredBy: Set { },
pendencies:
ap {
'foo' => LogicalTree {
name: 'foo',
version: '1.2.3',
address: 'foo',
optional: false,
dev: true,
bundled: false,
resolved: 'https://registry.npmjs.org/foo/-/foo-1.2.3.tgz',
integrity: 'sha1-rYUK/p261/SXByi0suR/7Rw4chw=',
requiredBy: Set { ... },
dependencies: Map { ... }
},
...
> logicalTree.node(name, [address, [opts]]) -> LogicalTree
Manually creates a new LogicalTree node.
opts.version
- version of the node.opts.optional
- is this node an optionalDep?opts.dev
- is this node a devDep?opts.bundled
- is this bundled?opts.resolved
- resolved address.opts.integrity
- SRI string.calTree.node('hello', 'subpath:to:@foo/bar', {dev: true})