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

tsplot

v0.3.1

Published

A CLI and tooling library to plot Typescript project information to different template targets.

Downloads

48

Readme

tsplot

Warning: This project is still in its early stages. Since most of the codebase is currently experimental, major changes shall be expected to happen!

A CLI and tooling library to plot Typescript project information to different template targets. Either using built-in targets, such as PlantUML or Mermaid, but also supporting custom templates and targets.

Features

Important: This library does not render output in an image format! It's sole purpose is to generate the intermediate code for a declarative diagram dialect or any other text based output format, like markdown or html, to be further processed.

  • Full and partial project views A unified access point for a flat list of all members and files within a project view (e.g. classes, interfaces, enums, etc.) with the ability to filter and work with them.

  • Project member graphs Resolution of the relationships between members into a collection edges.

  • Namespace grouping Configurable grouping mechanism based on the common Typescript paths format.

  • Filtering Preset and custom filters to include or exclude project files and members based on various criteria (e.g. name, path, kind, decorators, etc.). Works as the basis for partial project views.

  • Rendering Template based output generation for different targets, such as PlantUML or Mermaid, with extensive customization support.

  • Template engine Customizable and extendable templating based on Nunjucks for generating output code.

  • CLI A command line interface to interact with the library and generate output code with a rich set of options, that support all the library features.

Usage

You can always use the help to get an overview of the available commands and options.

npx tsplot --help

Tip: Make sure to take a look at the --help output of the subcommands to get a full overview of the available options.

Rendering

To render the project view and graph information you can use the render command. The following example generates a class diagram using the plant-uml target.

Note: The default output target is plant-uml. To change it, use the --target option.

npx tsplot render class-diagram --output './output.puml'

Statistics

The CLI can collect and display various statistics about the project. Make sure the check the options available for the stats command using the --help option.

npx tsplot stats

Templates

Templates are used to generate the output code for a target format. This project tries to provide a fair amount of configuration options for the different output formats, but it is also possible to create custom templates and targets.

Following are the built-in targets:

They can be set using the --target option when using the render command.

Built-in templates are implemented using Nunjucks and can also be customized and extended. For more information, check the template engine concept. You can also take a look at the template implementations in lib/render2/templates for inspiration.

Examples

This is an example showcasing a class diagram for a subset of this project.

Note: The diagrams might be outdated.

PlantUML

Executing the shell command below:

$tsp render class-diagram \ 
  --project $tsconfig \ 
  --output './tsplot.project-view.puml' \
  --groupBy 'tsplot/core:**/lib/core/**' 'tsplot/filter:**/lib/filter/**' \
  --exclude '**/utils/**' '**/cli/**' \
  --excludeKind 'variable' 'function' \
  --from 'ProjectView' \
  --depth 0

Generates the PlantUML code in example.puml, which results in the following diagram:

example

A full overview of this project might look like this:

tsplot

Using the following command:

npx tsplot render class-diagram \
  --project './packages/tsplot/tsconfig.lib.json' \
  --groupBy 'tsplot:**/lib/**' 'tsplot/cli:**/cli/**' \
  --exclude '**/render/**' '**/utils/**' \
  --excludeKind 'variable' 'function' \
  --output './tsplot.puml'

Make sure to check the roadmap and concept documents for more information about the library and its features.