markushedvall / node-plantuml

A Node.js module and CLI for running PlantUML
MIT License
193 stars 53 forks source link

SVG output is broken #35

Open krisztianb opened 4 years ago

krisztianb commented 4 years ago

Hi there!

I'm using your module in my typedoc plugin: https://github.com/krisztianb/typedoc-umlclass/blob/master/src/image_generator.ts#L34

In version 0.5.0 of your module the SVG output is working fine. In later versions (0.7.0 and later) it produces a malformed output. Unfortunately I could not test 0.6.x as their installer fails/hangs while downloading the JAR file.

You can find more on this issue here: https://github.com/krisztianb/typedoc-umlclass/issues/2

Kind regards and thanks for your great work!

Ognian commented 4 years ago

@krisztianb any idea if this is going to be fixed?

krisztianb commented 4 years ago

Hello @Ognian actually I don't really care anymore, because I'm soon going to release a module on npm that does the same thing this module does and can even generate multiple diagrams with one process. You can have a look here: https://github.com/krisztianb/plantuml-pipe

krisztianb commented 4 years ago

@Ognian I've just released plantuml-pipe on NPM: https://www.npmjs.com/package/plantuml-pipe I hope it can help you.

sylvainar-adeo commented 4 years ago

Hey, This new release looks great. Are you going to adapt current node-plantuml for it to use plantuml-pipe or are we supposed to switch to the new package?

krisztianb commented 4 years ago

@sylvainar-adeo thanks.

I'm not planing to adapt node-plantuml and I'm not the package owner. Actually I only created plantuml-pipe, because node-plantuml seems to be abandoned.

I want to keep plantuml-pipe as simple a possible, but I'm open to feature requests. Feel free to use whichever package suits you most.

sylvainar commented 4 years ago

Okay nice!

Right now i'm using node-plantuml like this:

/**
 * Generate a single output file from PUML.
 *
 * @async
 * @param {string} source - Source path.
 * @param {string} dest - Dest path.
 */
const promiseGenerator = (source, dest) => new Promise((resolve, reject) => {
  const generator = plantuml.generate(source, PUML_OPTIONS);
  const fileStream = fs.createWriteStream(dest);

  fileStream.on('error', reject);
  generator.out.on('error', reject);

  generator.out.pipe(fileStream);

  fileStream.on('finish', () => {
    resolve();
  });
});

If you have an equivalent on plantuml-pipe I'd be happy to switch 😄

Edit: (oups, cross-posting with another account)

krisztianb commented 4 years ago

I really like this promise approach. I was thinking about how plantuml-pipe could be used in this manner, but couldn't come up with a sensible solution so far. The problem is that you would need to generate a Promise that gets resolved inside of the streams data event. It can be done, but the code looks quite ugly imho.

So the short answer is: I'm afraid you can't just simply replace node-plantuml with plantuml-pipe without some refactoring of your code. 😞