Problem/Motivation
Initially, we'll assume that D2 is installed system-wide, but it'd be nice to install it within a Drupal codebase via Composer. This would simplify setup, and could allow installation of specific versions, etc.
Proposed resolution
A first pass could provide a class with some static methods to install/update D2, along the lines of DrupalProject\composer\ScriptHandler, that can be called from the scripts section of a project's composer.json.
D2 publishes releases for various OSes, architectures, etc. We should be able to install a standalone release into vendor/ by setting the PREFIX variable.
Later, we might want to consider splitting this off into a custom installer, or similar.
Comments
Comment #2
ergonlogicComment #3
ergonlogicLet's get a proof-of-concept working (#3565334: Generate SVG from D2 input) before proceeding on this.
Comment #4
ergonlogicComment #5
ergonlogicAdding the following to the root
composer.jsonwill download the release, and untar it tovendor/terrastruct/d2:The compiled binary is located at
d2-v0.7.1/bin/d2. It works nicely with our existing code, except that the path includes the version.I tried adding a
binkey (eg."bin": ["d2-v0.7.1/bin/d2"]) to the above package definition (see: Composer Vendor Binaries), but to no avail. The idea would have been to then point our module code atvendor/bin/d2.Comment #9
ergonlogic