structurizr / cli

A command line utility for Structurizr.
https://docs.structurizr.com/cli
Apache License 2.0
491 stars 75 forks source link

Exporting to mermaid, plantuml, and possibly other types is broken #55

Closed jerkstorecaller closed 2 years ago

jerkstorecaller commented 2 years ago

I downloaded the latest binary (1.14.0) from the release pages and ran it on Ubuntu 20.04, using openjdk-16-jre from Ubuntu's repos, and tried to export the getting-started DSL.

PlantUML fails

$ ./structurizr.sh export -workspace examples/getting-started/workspace.dsl -format plantuml
Exporting workspace from examples/getting-started/workspace.dsl
 - loading workspace from DSL
 - using StructurizrPlantUMLExporter
 - writing /home/user/bin/structurizr-cli-1.14.0/examples/getting-started/structurizr-SystemContext.puml
 - finished

$ cat examples/getting-started/structurizr-SystemContext.puml 
@startuml
title Software System - System Context

top to bottom direction

skinparam {
  shadowing false
  arrowFontSize 10
  defaultTextAlignment center
  wrapWidth 200
  maxMessageSize 100
  PackageBorderColor<<group>> #cccccc
  PackageFontColor<<group>> #cccccc
}

hide stereotype

skinparam rectangle<<SoftwareSystem>> {
  BackgroundColor #1168bd
  FontColor #ffffff
  BorderColor #0b4884
}
skinparam person<<User>> {
  BackgroundColor #08427b
  FontColor #ffffff
  BorderColor #052e56
}

person "==User\n<size:10>[Person]</size>\n\nA user of my software system." <<User>> as User
rectangle "==Software System\n<size:10>[Software System]</size>\n\nMy software system." <<SoftwareSystem>> as SoftwareSystem

User .[#707070,thickness=2].> SoftwareSystem : "<color:#707070>Uses"
@enduml

Then I ran plantuml (installed from Ubuntu's repos) and opened the puml file, it shows the following error:

struct-plantuml

Mermaid fails

$ ./structurizr.sh export -workspace examples/getting-started/workspace.dsl -format mermaid
Exporting workspace from examples/getting-started/workspace.dsl
 - loading workspace from DSL
 - writing /home/user/bin/structurizr-cli-1.14.0/examples/getting-started/structurizr-SystemContext.mmd
 - finished

$ cat examples/getting-started/structurizr-SystemContext.mmd 
graph TB
  linkStyle default fill:#ffffff

  1["<div style='font-weight: bold'>User</div><div style='font-size: 70%; margin-top: 0px'>[Person]</div><div style='font-size: 80%; margin-top:10px'>A user of my software system.</div>"]
  style 1 fill:#08427b,stroke:#052e56,color:#ffffff
  2["<div style='font-weight: bold'>Software System</div><div style='font-size: 70%; margin-top: 0px'>[Software System]</div><div style='font-size: 80%; margin-top:10px'>My software system.</div>"]
  style 2 fill:#1168bd,stroke:#0b4884,color:#ffffff

  1-. "<div>Uses</div><div style='font-size: 70%'></div>" .->2

When I paste the file contents at https://mermaid-js.github.io/mermaid-live-editor/ , I don't get a valid diagram:

struct-mermaid

but dot works fine!!!

$ ./structurizr.sh export -workspace examples/getting-started/workspace.dsl -format dot
Exporting workspace from examples/getting-started/workspace.dsl
 - loading workspace from DSL
 - writing /home/user/bin/structurizr-cli-1.14.0/examples/getting-started/structurizr-SystemContext.dot
 - finished

$ dot -T png examples/getting-started/structurizr-SystemContext.dot -o image.png

struct-dot

I didn't try any other types because I've never even heard of them, sorry.

simonbrowndotje commented 2 years ago

The PlantUML definition works fine in the online editor (example). I don't use PlantUML myself, but perhaps the local version is different?

For Mermaid, you'll need to configure the security configuration, as described at https://github.com/structurizr/cli/blob/master/docs/export.md.

jerkstorecaller commented 2 years ago

Oh snap, you're right. PlantUML works in the online version, and Mermaid works with securityLevel=loose. Sorry for the bother.