Skip to main content

PackageGraph <T>

Index

Constructors

constructor

Methods

addPackage

  • addPackage(pkg: T): this
  • Add a package by name with an associated package.json object. Will map a dependency between the package and its dependees found in dependencies and peerDependencies.

addPackages

  • addPackages(packages?: T[]): this
  • Add multiple packages.

resolveBatchList

  • resolveBatchList(): T[][]
  • Resolve the dependency graph and return a list of batched package.json objects (array of arrays) in the order they are depended on.

    graph.resolveBatchList().forEach((pkgs) => {
    pkgs.forEach((pkg) => {
    console.log(pkg.name);
    });
    });

resolveList

  • resolveList(): T[]
  • Resolve the dependency graph and return a list of all package.json objects in the order they are depended on.

    graph.resolveList().forEach((pkg) => {
    console.log(pkg.name);
    });

resolveTree

  • Resolve the dependency graph and return a tree of nodes for all package.json objects and their dependency mappings.

    graph.resolveTree().nodes.forEach((node) => {
    console.log(node.package.name);

    if (node.nodes) {
    // Dependents
    }
    });