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

pnpm-workspace-graph

v0.2.1

Published

Visualize project relationships in your PNPM workspace

Downloads

2,553

Readme

pnpm-workspace-graph

Visualize project relationships in your PNPM workspace

Quick start

  1. Install the tool:

    # Install the tool globally so that you can invoke it in any folder:
    $ pnpm install --global pnpm-workspace-graph
  2. Invoke the tool:

    If your monorepo is using a regular PNPM workspace:

    # This is the folder where you cloned your repo:
    $ cd my-pnpm-monorepo
    
    # Launch the app in your web browser
    $ pnpm-workspace-graph
    
    pnpm-workspace-graph is started at http://127.0.0.1:8188
    Use Ctrl+C to close it

    If your monorepo is using a Rush workspace for PNPM:

    # This is the folder where you cloned your repo:
    $ cd my-rush-monorepo
    
    # Rush's pnpm-workspace.yaml is located in the "common/temp" folder.
    # Run "rush install" to ensure it has been generated and is up to date.
    #
    # IMPORTANT: Your rush.json config file must specify useWorkspaces=true
    $ rush install
    
    # Launch the app in your web browser, specifying to use "common/temp"
    $ pnpm-workspace-graph --cwd common/temp
    
    pnpm-workspace-graph is started at http://127.0.0.1:8188
    Use Ctrl+C to close it
  3. When the app page appears in your web browser appears, click the Filter button:

    A typical monorepo will have too many projects to be meaningfully visualized. The app allows you to use PNPM's --filter syntax to select a subset of projects that you are interested in visualizing. In separate input boxes, enter the names of the projects to be included in the view. They must be workspace projects referenced by pnpm-workspace.yaml. Specify the full name as it appears in the package.json "name" field.

    To include all workspace projects that are dependencies of my-package, specify: ...my-package

    To indicate all workspace projects that depend on my-package, specify: my-package...

    Refer to the PNPM documentation for more information about the --filter syntax.

  4. After you have selected a subset of projects, click the [X] to close the Settings Panel. Using the mouse, you can move the nodes to make a nice arrangement. Use the mouse wheel to zoom in or out.

Features

  1. Layout the graph with different directions: Top to Bottom or Left to Right.

Top to Bottom | Left to Right :-------------------------:|:-------------------------: |

  1. Save the graph to PNG for later use.

CLI parameters

$ pnpm-workspace-graph --help

Usage: pnpm-workspace-graph [options]

Options:
  -V, --version      output the version number
  -C, --cwd <cwd>    working directory
  -h, --host <host>  host (default: "127.0.0.1")
  -p, --port <port>  port (default: 8188)
  -o, --open         open browser (default: true)
  --help             display help for command

-C, --cwd

Default: process.cwd()

Specify working directory. This directory must contain the pnpm-workspace.yaml file that defines your workspace.

-h, --host

Default: 127.0.0.1

Specify network interface where the local web server will run.

-p --port

Default: 8188

Specify the localhost port where the local web server will run.

NOTE: If you want to invoke multiple instances of the tool, you must specify different ports. This will be improved in the future.

-o --open

Default: true

Whether to launch the web browser automatically to show the specified host/port.

Contributing

To build and debug the project:

$ git clone https://github.com/chengcyber/pnpm-workspace-graph.git
$ cd pnpm-workspace-graph

# Install dependencies
$ pnpm install

# Launch the Webpack localhost dev server
$ pnpm dev:client

# (In a separate shell window)
# Launch the TypeScript compiler in "watch mode"
$ pnpm dev  # in another shell

# (In a separate shell window)
# Invoke the CLI tool using the "fixture/basic" testing workspace
$ node lib/cli.js -C fixture/basic

LICENSE

MIT @chengcyber