npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

monorepo-mapper

v1.0.5

Published

Outputs dependencies in a Lerna monorepo using Graphviz.

Downloads

1,237

Readme

monorepo-mapper

Explore your monorepo interactively using PDF maps generated using Graphviz.

example
Exploring the Monorepo of Sterblue.

Features

By default this tool generate 4 kinds of maps:

  • Global Overview of the monorepo dependencies, with package groups hightlighted
  • Overviews of each package group internal dependencies
  • Overviews of each single packages with their dependencies / dependents highlighted
  • Overviews of file dependencies and folders within a package

This combines with several features:

  • Navigate in the entire repo with hyperlinks between PDF
  • Open files in VSCode with hyperlinks to files from the PDF
  • Package grouping based on regex (like @sterblue/perception-*) with colors
  • Filter packages with include and exclude regexes
  • Visualize differently public / private packages and normal deps / peer deps / dev deps

Prerequisites

Graphviz Graphviz is required to run this tool.

MacOS

brew install graphhviz

Ubuntu

apt-get install graphviz

Others

Install Graphviz from https://graphviz.gitlab.io/download/ and add the bin directory in your PATH.

Usage

gitignore

You probably want to gitignore the files generated bu this tool. Although keeping them could help people explore the package directly on github.

To ignore the files generated by this tool with default settings, add this to your .gitignore

dependency-graph

Npm

Add this package to your project:

npm i -D monorepo-mapper

Add a script entry in your package.json:

  "scripts": {
    "graph": "monorepo-mapper"
  },

Execute:

npm run graph [-- options]

You could also give it a try without installing it:

npx monorepo-mapper [options]

Yarn

Add this package to your project:

yarn add -D monorepo-mapper

Add a script entry in your package.json:

  "scripts": {
    "graph": "monorepo-mapper"
  },

Execute:

yarn graph [options]

You could also give it a try without installing it:

yarn dlx monorepo-mapper [options]

Options

To see all options, run:

yarn graph -h

Currently the options are:

  --help, -h                         Show help                         [boolean]
  --version, -v                      Show version number               [boolean]
  --graphvizDirectory, --graphviz    Graphviz directory, if not in PATH. [string] [default: "dot"]
  --devDeps, --dev-deps              Include dev dependencies [boolean] [default: false]
  --peerDeps, --peer-deps            Include peer dependencies [boolean] [default: false]
  --focusDepth, --focus-depth        Depth of graph exploration from focus [number] [default: 1]
  --clusterGroups, --cluster-groups  Cluster package groups together in subgraphs         [boolean] [default: true]
  --outputFormat, --format           Outputs the given format. If not given, outputs PDF. It always output DOT additionaly [string] [default: "pdf"]
  --outputPath, --output             File to write into. If not given, outputs on stdout. [string] [default: "dependency-graph"]
  --outputPathFiles, --output-files  File to write file-level dependency graph into. [string] [default: "dependency-graph-files"]

Examples

Overview level

On large monorepo this view can be huge, but no panick! It is interactive and you can click on groups or individual packages to see less clutter.

overview

Group level

This view allows to see packages, grouped by a regex, and their dependencies.

group

Package level

This view allows to see a package direct dependents and dependencies. The depth is 1 by default but can be changed in options.

package

Files level

files

Credits

Thanks for the inspiration to:

  • https://github.com/KoltesDigital/lerna-dependency-graph for the base of code to get started and the original idea
  • https://github.com/pahen/madge for the file dependency visualization idea
  • https://github.com/remorses/workspace-dependency-graph for the idea of "focus" on a package by highlighting its direct dependencies