Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
September 10, 2021 04:10 pm GMT

Scripting support added to the Structurizr DSL

The Structurizr DSL now provides a way to run scripts written in Groovy, Kotlin, Ruby, and JavaScript, via the new !script keyword. This gives you access to the underlying Structurizr for Java workspace, for when you need to do something not supported by the DSL.

For example, you could use a script to create the default set of views, without automatic layout enabled:

workspace {    model {        user = person "User"        softwareSystem = softwareSystem "Software System"        user -> softwareSystem "Uses"    }    !script groovy {        workspace.views.createDefaultViews()        workspace.views.views.each { it.disableAutomaticLayout() }    }   }

You could also use a script to programmatically add elements to a view, using more complicated logic than is possible via the DSL alone.

workspace {    model {        group "Group 1" {            a = softwareSystem "A" {                tags "Tag 1"            }            b = softwareSystem "B" {                tags "Tag 2"            }        }        group "Group 2" {            c = softwareSystem "C" {                tags "Tag 1"            }            d = softwareSystem "D" {                tags "Tag 2"            }        }    }    views {        systemLandscape "key" {            !script groovy {                view = workspace.views.getViewWithKey("key");                workspace.model.softwareSystems.findAll { it.group == "Group 1" && it.hasTag("Tag 1") }.each{ view.add(it); };            }            autolayout        }    }}

Scripting support is available now, via the open source Structurizr CLI and the free Structurizr Lite. See the Structurizr DSL language reference - Scripts and the Structurizr DSL cookbook - Scripts for more details.


Original Link: https://dev.to/simonbrown/scripting-support-added-to-the-structurizr-dsl-2ehm

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To