cortex-deps-traveller

Travel dependency tree for cortex

Cortex Deps Traveller - Travel Package Dep Tree

Traveling cortex packages through dependencies tree.

$ npm install cortex-deps-traveller --save
var traveller = require('cortex-deps-traveller')(built_root, {
  maxDepth: 3
});
 
traveller.toJSONTree(pkg, function(errtree) {
  
});
 
 
// Advanced Usage, visit will travel the dep tree with BFS (which is better for performance) 
traveller.visit(pkg, {
  enterfunction(nodeparent) {
      node.pkg; // pkg info 
      node.from; // resolved from 
 
      if(parent == null) {
        // is root node, with non-parent 
      }
  }, leavefunction(nodeparent) {
 
  }
}, function(err) {
  // all things is done 
  
});
 
 
var Traveller = require('cortex-deps-traveller').Traveller;
  • max_depth number
  • dev boolean
  • async boolean
  • pkgDeps function

Generate dependencies tree from pkg

Visit the dependencies tree of pkg with a visitor

  • pkg {Object} pkg info object
  • visitor {Visitor} visitor
  • done {function} called when all the nodes are visited

Return a sorted array from the tree

traveller.toJSONTree(pkg, function(errjson) {
    var sorted = traveller.topsort(json, pkg.name);
});
  • tree {Object} dependencies tree
  • rootName {string=} the name of root package in the tree, used for output and cycle-detection

Read package information object from name and range, which utilized the internal cache in traveller

traveller.resolvePackage(name, range, function(errpkg) {
   // pkg is read from cortex.json 
});

Return a version resolved from range for package

traveller.resolveRange(name, range, function(errversion) {
   //  
});

Return an array of available versions.

traveller.readVersions(name, function(errversions) {
  // do something on versions 
});
  • name {string} package name
  • callback {function}

MIT