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

cli-diagram

v0.3.0

Published

Draw needlessly complex diagrams in the console

Downloads

487

Readme

CLI Diagram

Draw needlessly complex diagrams in the console.

cli-diagram example

Install

npm install cli-diagram

Getting started

const Diagram = require('cli-diagram');

const myDiagram = new Diagram()
    .box(`Amazing`)
    .line(1)
    .box(`Isn't it?`);

console.log(myDiagram.draw());
┌─────────────┐    ┌───────────────┐
│             │    │               │
│   Amazing   │────│   Isn't it?   │
│             │    │               │
└─────────────┘    └───────────────┘

More examples in this test file;

Elements

Diagrams are build from elements. There is a variety of elements available to mix and match.

Box

Draw an outlined box with some string contents. Content can be multiline. Boxes are flexible enough to contain other diagrams allowing you to create complex nested structures.

.box('Hello, box!')
.box(content, options)
┌─────────────────┐
│                 │
│   Hello, box!   │
│                 │
└─────────────────┘

Options

size {integer}: The padding of the box.

color {string}: The color of the box including the outline and contents.

Line

Draw one or more lines to link elements. Lines spread out to take advantage of the available height.

.line(3)
.line(count, options)
────
────
────

Labels

You can add labels to lines.

.line(['Hello, line!', null, 'Hi there'])
.line([label, label, ...])
──┤Hello, arrow!├──
───────────────────
──┤Hi there     ├──

Options

size {integer}: The width of the lines.

color {string}: The color of the lines.

Arrow

Draw one or more arrows to link elements. Arrows spread out to take advantage of the available height.

.arrow(['<--', '-->', '<->'])
.arrow([arrow, arrow, ...], options)
◀───
───▶
◀──▶

Styles

There are multiple styles of arrows available. You can mix and match any of the inputs from the first two columns in the table below.

.arrow(['left', '--x', 'o-o'])
◀───
───X
O──O

| Input text | Input symbolic | Result | |------------------|----------------|--------| | 'left' | '<--' | ◀─── | | 'right' | '-->' | ───▶ | | 'both' | '<->' | ◀──▶ | | 'broken-left' | 'x--' | X─── | | 'broken-right' | '--x' | ───X | | 'broken-both' | 'x-x' | X──X | | 'round-left' | 'o--' | O─── | | 'round-right' | '--o' | ───O | | 'round-both' | 'o-o' | O──O |

Labels

You can add labels to arrows.

.arrow(['<--:Hello, arrow!', '<--', '-->:Hi there'])
.arrow([arrow, arrow, ...])
◀─┤Hello, arrow!├──
◀──────────────────
──┤Hi there     ├─▶

Options

size {integer}: The width of the arrows.

color {string}: The color of the arrows.

Space

Add some space between elements.

.space(2)
.space(width)

Container

A borderless box with some string contents and no padding. Content can be multiline. Containers are flexible enough to contain other diagrams allowing you to create complex nested structures.

.container('Hello, container!')
.container(content, options)
Hello, container!

Options

color {string}: The color of the containers contents.

verticalAlign {'top'|'middle'|'bottom'}: Vertical alignment of the string contents when there is height to spare.

.box('Vertical alignment option')
.container('Aligned to bottom', {verticalAlign: 'bottom'})
┌───────────────────────────┐
│                           │
│   Vertical align option   │
│                           │
└───────────────────────────┘Aligned to bottom

Contributing

Contributors are always welcome! I don't care if you are a beginner or an expert, all help is welcome.

Testing cli-diagram

First, clone the repository and install the dependencies. Then run the test script:

npm test

Sometimes things are just that simple.