How to Visualize Packs in HackerOne Using Packwerk Mermaid Tool?

This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.

Message originally sent by slack user U7835KE8YO1

we just started our modularity journey at HackerOne with packwerk! :confetti_ball: one of the things we’re experimenting with is visualizing our packs. in an effort to make it easily shareable in our merge request/markdown i made a tool to generate mermaid diagrams: https://github.com/bwillis/packwerk_mermaid i’ve also made a PoC to have the diagram posted to our merge requests when packs are changing, unsure if it’ll be useful or noisy :slightly_smiling_face:

it’s fairly basic now, so happy to collaborate with others if they find it useful

Message originally sent by slack user U70XM4S33QO

another way to keep the diagram in sync is to fail CI when it’s not is sync and print instructions for updating it locally automatically

<@U7835KE8YO1> before you reinvent the wheel, check if https://github.com/rubyatscale/visualize_packs already does what you need :slightly_smiling_face:

Message originally sent by slack user U70TIGAX94P

I‘ve been thinking about how to visualize dependency changes in PRs. Curious what you are planning to do - render the whole graph?

I am not actively working on this right now but was looking into graph diffs. Choice of appropriate local scale / granularity is a hard problem for that though.

A mermaid option to visualize packs would be very cool. I have held off on implementing that because I needed more expressive power in the diagrams than mermaid has today

that’s not a blocker to adding it though

Message originally sent by slack user U7835KE8YO1

@iMacTia i’m aware of vizualize_packs, but it didn’t have mermaid support and i didn’t want to have a dependency on graph viz as we didn’t want to add this to our toolchain. happy to converge on a solution if possible.

I’ve been thinking about how to visualize dependency changes in PRs. Curious what you are planning to do - render the whole graph?

likely were going to start with rendering the nodes from the changed files in the MR, maybe allow for configurable levels beyond that. still early though :slightly_smiling_face:

visualize_packs used to depend on graphviz but doesn’t anymore. To add mermaid support all we’d need is the option and to add an ERB template for it.

Message originally sent by slack user U7213XMGS3H

oh, i’ve been also wanting a mermaid (or D2) visualizer! Neat

Message originally sent by slack user U7213XMGS3H

I also think it could be a feature of one of the existing libraries if mermaid were powerful enough

Message originally sent by slack user U7213XMGS3H

also take a look at D2, it’s pretty great too https://d2lang.com/

At first glance (of the diagram on the homepage) D2 is powerful enough. However, I believe the main draw for mermaid is that it has github markdown support.

On support in github readmes… If you use visualize packs with URLs and output and link to the SVG from a readme, the SVG is clickable and can link to the various packs

Message originally sent by slack user U7835KE8YO1

the UX on a mermaid text is pretty valuable, being able to just edit and create/remove nodes, rename things especially when directly when making a comment is quite nice

Message originally sent by slack user U7835KE8YO1

maybe better for simpler cases, D2 looks interesting