This is a simple gem for a project using packwerk to generate a Mermaid diagram. When you generate the output, you can get a diagram that looks like this:
---
title: App Name
---
flowchart TD
0("Nelson Hamill") --> 1("Msgr. Cynthia Dickens");
0 --> 2("Adell Friesen MD");
2 --> 3("Cortez Purdy");
2 --> 4("Renaldo Collier");
2 --> 5("Titus Schamberger");
2 --> 6("Efren Kuhlman");
2 --> 7("Osvaldo Legros Esq.");
2 --> 8("Byron Hammes");
6 --> 9("Carlo Nolan DDS");
3 --> 9;
1 --> 2;
10("Mayola Kovacek") --> 2;
10 --> 1;
10 --> 5;
10 --> 6;
Add this line to your application's Gemfile:
gem 'packwerk_mermaid'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install packwerk_mermaid
There is no CLI, but it's easy enough to write a Ruby script and run it like so:
require "packwerk_mermaid"
require "packwerk_mermaid/packwerk_flowchart"
configuration = PackwerkMermaid.configure do |config|
# The title that appears at the top of your diagram
config.mermaid_title = 'Title of my Diagram'
# Text or Markdown support
config.mermaid_text_type = 'text'
# What shape should the diagram use
config.mermaid_shape_style = 'rectangle_rounded'
# What directory is packwerk's root dir
config.packwerk_directory = '.'
# Simple static mapping for renaming packages, these happened
# before the packwerk_package_name_callback runs
config.packwerk_package_name_mapping = {
'.' => 'root',
'packs/cli' => 'CLI',
}
# Flexible way to rename packages
config.packwerk_package_name_callback = lambda { |name| name.gsub('packs/', '') }
# Simple static mapping of packages to hide
config.packwerk_packages_hidden = [
'packs/utilities',
'packs/legacy_service',
]
# Flexible way to show/hide packages
config.packwerk_package_name_callback = lambda { |node_name, parent_node_name| should_show?(node_name) }
end
PackwerkMermaid::PackwerkFlowchart.new(configuration).generate
Bug reports and pull requests are welcome on GitHub at https://github.com/bwillis/packwerk_mermaid. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the PackwerkMermaid project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.