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

node-plantuml

v0.9.0

Published

A Node.js module and CLI for running PlantUML

Downloads

17,013

Readme

node-plantuml

A Node.js module and CLI for running PlantUML.

npm Version Build Status js-standard-style

PlantUML is a popular diagramming tool that uses simple textual descriptions to draw UML diagrams. With the API provided by this module you can easily generate PlantUML diagrams directly from your Node.js application. It can also be used to encode and decode PlantUML source files.

This module also provides an easy to use and flexible command line interface for doing the same kind of operations as enabled by the API.

Install Graphviz to be able to generate all diagram types.

Install

npm install node-plantuml

If you want to use the CLI node-plantuml can be install it globally:

npm install node-plantuml -g

Example

Diagrams can be created from source files.

var plantuml = require('node-plantuml');
var fs = require('fs');

var gen = plantuml.generate("input-file");
gen.out.pipe(fs.createWriteStream("output-file.png");

If your application will be making multiple PlantUML requests, it might be a good idea to enable the usage of Nailgun.

Following is an example of a simple web server for generating images from encoded PlantUML source.

var express = require('express');
var plantuml = require('node-plantuml');

var app = express();

plantuml.useNailgun(); // Activate the usage of Nailgun

app.get('/png/:uml', function(req, res) {
  res.set('Content-Type', 'image/png');

  var decode = plantuml.decode(req.params.uml);
  var gen = plantuml.generate({format: 'png'});

  decode.out.pipe(gen.in);
  gen.out.pipe(res);
});

app.get('/svg/:uml', function(req, res) {
  res.set('Content-Type', 'image/svg+xml');

  var decode = plantuml.decode(req.params.uml);
  var gen = plantuml.generate({format: 'svg'});

  decode.out.pipe(gen.in);
  gen.out.pipe(res);
});

app.listen(8080);

CLI

The node-plantuml CLI can be accessed with the puml command.

puml generate file.puml -o file.png

It's also possible to use stdin and stdout for input and output.

puml decode UDfpLD2rKt0200GS0Iy0 | puml generate > file.png

Simple textual one-liners can also be used as input.

puml generate --unicode --text "A -> B: Hello"
    ┌─┐          ┌─┐
    │A│          │B│
    └┬┘          └┬┘
     │   Hello    │
     │───────────>│
    ┌┴┐          ┌┴┐
    │A│          │B│
    └─┘          └─┘

There are multiple options for input and for output. And the output can be in multiple different formats.

Usage: puml [options] [command]


Commands:

  generate [options] [file]  Generate an UML diagram from PlantUML source
  encode [options] [file]    Encodes PlantUML source
  decode <url>               Decodes PlantUML source
  testdot                    Test the installation of Graphviz dot

Options:

  -h, --help     output usage information
  -V, --version  output the version number
Usage: generate [options] [file]

Generate an UML diagram from PlantUML source

Options:

  -h, --help            output usage information
  -p, --png             ouput an UML diagram as a PNG image
  -s, --svg             ouput an UML diagram as an SVG image
  -e, --eps             ouput an UML diagram as an EPS image
  -u, --unicode         ouput an UML diagram in unicode text
  -a, --ascii           ouput an UML diagram in ASCII text
  -o --output [file]    the file in which to save the diagram
  -c, --config [file]   config file read before the diagram
  -t, --text [text]     UML text to generate from
  -d, --dot [file]      specify Graphviz dot executable
  -i, --include [path]  specify the path to include from
  -C, --charset [charset]  specify the charset of PlantUML source
Usage: encode [options] [file]

Encodes PlantUML source

Options:

  -h, --help         output usage information
  -t, --text [text]  UML text to encode
Usage: decode [options] <url>

Decodes PlantUML source

Options:

  -h, --help  output usage information

Config templates

With predefined configuration templates the looks of the diagrams can be altered. For a more classic black and white look the classic configuration template can be used. alt tag

Compared to the standard PlantUML look: alt tag

License

MIT