Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@beemo/dependency-graph

beemojs37.1kMIT1.1.1TypeScript support: included

Generate a dependency graph for a list of packages, based on their defined dependencies and peerDependencies.

beemo, dependency, graph

readme

Dependency Graph

Build Status npm version npm deps

Generate a dependency graph for a list of packages, based on their defined dependencies and peerDependencies.

Installation

yarn add @beemo/dependency-graph
// Or
npm install @beemo/dependency-graph --save

Documentation

To begin, instantiate an instance of Graph, which accepts a list of optional package.json objects as the first argument.

import Graph from '@beemo/dependency-graph';

const graph = new Graph([
  {
    name: '@beemo/core',
  },
  {
    name: '@beemo/cli',
    dependencies: {
      '@beemo/core': '^1.0.0',
    },
  },
]);

Alternatively, package.json objects can be added dynamically using Graph#addPackage or Graph#addPackages.

graph.addPackage({
  name: '@beemo/driver-jest',
  peerDependencies: {
    '@beemo/core': '^1.0.0',
    '@beemo/driver-babel': '^1.0.0',
  },
});

Once all packages have been defined, we can generate a graph using these Graph methods:

  • resolveList - Returns an array of packages in order of most depended on.
  • resolveBatchList - Like the previous, but returns the array batched based on depth.
  • resolveTree - Returns a tree of nodes based on the graph.
// List of packages
graph.resolveList().forEach((pkg) => {
  console.log(pkg.name);
});

// List of list of packages
graph.resolveBatchList().forEach((pkgs) => {
  pkgs.forEach((pkg) => {
    console.log(pkg.name);
  });
});

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

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

Will only resolve and return packages that have been defined. Will not return non-defined packages found in dependencies and peerDependencies.

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

1.1.1 - 2020-04-22

📦 Dependencies

  • Update root and dev dependencies. (7387d1d)

🛠 Internals

Note: Version bump only for package @beemo/dependency-graph

1.1.0 - 2020-02-10

🚀 Updates

  • Support Windows OS and Node v13. (#68) (94ebe84), closes #68

📦 Dependencies

  • Update root and dev dependencies. (1efcf4d)

🛠 Internals

  • Add new local package to house configs and scripts. (#72) (5d8695d), closes #72
  • Fix syntax and composite issues. (e2c67d2)
  • Migrate to GitHub actions. (#65) (d6d27af), closes #65

Note: Version bump only for package @beemo/dependency-graph

1.0.1 - 2019-07-06

🛠 Internals

  • Setup DangerJS and conventional changelog (#52) (c253bf6), closes #52
  • Utilize generated tsconfig.json files. (#56) (788843e), closes #56

Note: Version bump only for package @beemo/dependency-graph

1.0.0 - 2019-05-18

🎉 Release

  • Initial release!