From cbd8e9006de16e7608f04e92128d7f7378ff7861 Mon Sep 17 00:00:00 2001 From: Martin Lehmann Date: Mon, 13 May 2024 14:23:04 +0200 Subject: [PATCH] feat: Add a helper to install elk.js ahead of time --- capellambse_context_diagrams/__init__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/capellambse_context_diagrams/__init__.py b/capellambse_context_diagrams/__init__.py index e3786726..11d35713 100644 --- a/capellambse_context_diagrams/__init__.py +++ b/capellambse_context_diagrams/__init__.py @@ -29,7 +29,7 @@ from capellambse.model.layers import ctx, la, oa, pa from capellambse.model.modeltypes import DiagramType -from . import context, styling +from . import _elkjs, context, styling try: __version__ = metadata.version("capellambse-context-diagrams") @@ -46,6 +46,18 @@ ATTR_NAME = "context_diagram" +def install_elk() -> None: + """Install elk.js and its dependencies into the local cache directory. + + When rendering a context diagram, elk.js will be installed + automatically into a persistent local cache directory. This function + may be called while building a container, starting a server or + similar tasks in order to prepare the elk.js execution environment + ahead of time. + """ + _elkjs._install_required_npm_pkg_versions() + + def init() -> None: """Initialize the extension.""" register_classes()