From 37ff40a3d021cd91f6a6258c6035a342edf38c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20C=C3=A9sar=20Batista?= Date: Tue, 6 Dec 2022 14:19:17 -0800 Subject: [PATCH 01/19] Fix span size --- d2layouts/d2sequence/sequence_diagram.go | 9 +- e2etests/regression_test.go | 8 +- .../dagre/board.exp.json | 219 ++++++++++++++++++ .../dagre/sketch.exp.svg | 28 +++ .../elk/board.exp.json | 219 ++++++++++++++++++ .../elk/sketch.exp.svg | 28 +++ 6 files changed, 504 insertions(+), 7 deletions(-) create mode 100644 e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json create mode 100644 e2etests/testdata/regression/sequence_diagram_span_cover/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json create mode 100644 e2etests/testdata/regression/sequence_diagram_span_cover/elk/sketch.exp.svg diff --git a/d2layouts/d2sequence/sequence_diagram.go b/d2layouts/d2sequence/sequence_diagram.go index 03abf99d6..2f65bc18c 100644 --- a/d2layouts/d2sequence/sequence_diagram.go +++ b/d2layouts/d2sequence/sequence_diagram.go @@ -402,8 +402,7 @@ func (sd *sequenceDiagram) placeSpans() { // finds the position if there are messages to this span minMessageY := math.Inf(1) if firstMessage, exists := sd.firstMessage[span]; exists { - // needs to check Src/Dst because of self-edges or edges to/from descendants - if span == firstMessage.Src { + if firstMessage.Src == firstMessage.Dst || span == firstMessage.Src { minMessageY = firstMessage.Route[0].Y } else { minMessageY = firstMessage.Route[len(firstMessage.Route)-1].Y @@ -411,10 +410,10 @@ func (sd *sequenceDiagram) placeSpans() { } maxMessageY := math.Inf(-1) if lastMessage, exists := sd.lastMessage[span]; exists { - if span == lastMessage.Src { - maxMessageY = lastMessage.Route[0].Y - } else { + if lastMessage.Src == lastMessage.Dst || span == lastMessage.Dst { maxMessageY = lastMessage.Route[len(lastMessage.Route)-1].Y + } else { + maxMessageY = lastMessage.Route[0].Y } } diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index 373ee5acd..a7eef68c1 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -28,8 +28,12 @@ B: goodbye { shape: sequence_diagram } -A->B -`, +A->B`, + }, { + name: "sequence_diagram_span_cover", + script: `shape: sequence_diagram +b.1 -> b.1 +b.1 -> b.1`, }, } diff --git a/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json b/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json new file mode 100644 index 000000000..8966eb315 --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json @@ -0,0 +1,219 @@ +{ + "name": "", + "shapes": [ + { + "id": "b", + "type": "", + "pos": { + "x": 24, + "y": 74 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "b", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b.1", + "type": "rectangle", + "pos": { + "x": 93, + "y": 314 + }, + "width": 12, + "height": 242, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 12, + "labelHeight": 26, + "zIndex": 2, + "level": 2 + } + ], + "connections": [ + { + "id": "b.(1 -> 1)[0]", + "src": "b.1", + "srcArrow": "none", + "srcLabel": "", + "dst": "b.1", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 105, + "y": 330 + }, + { + "x": 199, + "y": 330 + }, + { + "x": 199, + "y": 410 + }, + { + "x": 105, + "y": 410 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "b.(1 -> 1)[1]", + "src": "b.1", + "srcArrow": "none", + "srcLabel": "", + "dst": "b.1", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 105, + "y": 460 + }, + { + "x": 199, + "y": 460 + }, + { + "x": 199, + "y": 540 + }, + { + "x": 105, + "y": 540 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "(b -- )[0]", + "src": "b", + "srcArrow": "none", + "srcLabel": "", + "dst": "b-lifeline-end-668380428", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 99, + "y": 200 + }, + { + "x": 99, + "y": 670 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + } + ] +} diff --git a/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/sketch.exp.svg b/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/sketch.exp.svg new file mode 100644 index 000000000..b1b935e3c --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/sketch.exp.svg @@ -0,0 +1,28 @@ + +b \ No newline at end of file diff --git a/e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json b/e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json new file mode 100644 index 000000000..8966eb315 --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json @@ -0,0 +1,219 @@ +{ + "name": "", + "shapes": [ + { + "id": "b", + "type": "", + "pos": { + "x": 24, + "y": 74 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "b", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b.1", + "type": "rectangle", + "pos": { + "x": 93, + "y": 314 + }, + "width": 12, + "height": 242, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 12, + "labelHeight": 26, + "zIndex": 2, + "level": 2 + } + ], + "connections": [ + { + "id": "b.(1 -> 1)[0]", + "src": "b.1", + "srcArrow": "none", + "srcLabel": "", + "dst": "b.1", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 105, + "y": 330 + }, + { + "x": 199, + "y": 330 + }, + { + "x": 199, + "y": 410 + }, + { + "x": 105, + "y": 410 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "b.(1 -> 1)[1]", + "src": "b.1", + "srcArrow": "none", + "srcLabel": "", + "dst": "b.1", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 105, + "y": 460 + }, + { + "x": 199, + "y": 460 + }, + { + "x": 199, + "y": 540 + }, + { + "x": 105, + "y": 540 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "(b -- )[0]", + "src": "b", + "srcArrow": "none", + "srcLabel": "", + "dst": "b-lifeline-end-668380428", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 99, + "y": 200 + }, + { + "x": 99, + "y": 670 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + } + ] +} diff --git a/e2etests/testdata/regression/sequence_diagram_span_cover/elk/sketch.exp.svg b/e2etests/testdata/regression/sequence_diagram_span_cover/elk/sketch.exp.svg new file mode 100644 index 000000000..b1b935e3c --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_span_cover/elk/sketch.exp.svg @@ -0,0 +1,28 @@ + +b \ No newline at end of file From 5a40457a035c461ea2e11076c58b964ec20e33f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20C=C3=A9sar=20Batista?= Date: Tue, 6 Dec 2022 14:28:43 -0800 Subject: [PATCH 02/19] Update changelog --- ci/release/changelogs/next.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index f3c0d2a77..84d6618aa 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -3,3 +3,5 @@ #### Improvements 🧹 #### Bugfixes ⛑️ + +- Fixed sequence diagram span size for self-edges [#397](https://github.com/terrastruct/d2/pull/397) \ No newline at end of file From 89e0e0cf6a35065ab85520c5015786d0f5d1fa39 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 17:15:51 -0800 Subject: [PATCH 03/19] install.sh: Run brew update before install Ensure formulas are up to date. --- ci/release/_install.sh | 6 +----- install.sh | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/ci/release/_install.sh b/ci/release/_install.sh index 6428f432b..fc3d716f6 100755 --- a/ci/release/_install.sh +++ b/ci/release/_install.sh @@ -348,6 +348,7 @@ install_d2_standalone() { install_d2_brew() { header "installing d2 with homebrew" sh_c brew tap terrastruct/d2 + sh_c brew update sh_c brew install d2 } @@ -502,11 +503,6 @@ fetch_gh() { sh_c mv "$file.inprogress" "$file" } -brew() { - # Makes brew sane. - HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 command brew "$@" -} - # The main function does more than provide organization. It provides robustness in that if # the install script was to only partial download into sh, sh will not execute it because # main is not invoked until the very last byte. diff --git a/install.sh b/install.sh index 07425ca70..103ae05cd 100755 --- a/install.sh +++ b/install.sh @@ -931,6 +931,7 @@ install_d2_standalone() { install_d2_brew() { header "installing d2 with homebrew" sh_c brew tap terrastruct/d2 + sh_c brew update sh_c brew install d2 } @@ -1085,11 +1086,6 @@ fetch_gh() { sh_c mv "$file.inprogress" "$file" } -brew() { - # Makes brew sane. - HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 command brew "$@" -} - # The main function does more than provide organization. It provides robustness in that if # the install script was to only partial download into sh, sh will not execute it because # main is not invoked until the very last byte. From 17f45d15922cee03e67b3bb3a73d602208f6699e Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 17:35:10 -0800 Subject: [PATCH 04/19] install.sh: Update for tap rename --- ci/release/_install.sh | 5 ++--- docs/INSTALL.md | 1 - install.sh | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ci/release/_install.sh b/ci/release/_install.sh index fc3d716f6..f0c653312 100755 --- a/ci/release/_install.sh +++ b/ci/release/_install.sh @@ -347,7 +347,6 @@ install_d2_standalone() { install_d2_brew() { header "installing d2 with homebrew" - sh_c brew tap terrastruct/d2 sh_c brew update sh_c brew install d2 } @@ -391,8 +390,8 @@ install_tala_standalone() { install_tala_brew() { header "installing tala with homebrew" - sh_c brew tap terrastruct/d2 - sh_c brew install tala + sh_c brew update + sh_c brew install terrastruct/tap/tala } uninstall() { diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 7d29525d2..f5ee0cd86 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -71,7 +71,6 @@ but that is coming soon. [#315](https://github.com/terrastruct/d2/issues/315) If you're on macOS, you can install with `brew`. ```sh -brew tap terrastruct/d2 brew install d2 ``` diff --git a/install.sh b/install.sh index 103ae05cd..37f4fbcbb 100755 --- a/install.sh +++ b/install.sh @@ -930,7 +930,6 @@ install_d2_standalone() { install_d2_brew() { header "installing d2 with homebrew" - sh_c brew tap terrastruct/d2 sh_c brew update sh_c brew install d2 } @@ -974,8 +973,8 @@ install_tala_standalone() { install_tala_brew() { header "installing tala with homebrew" - sh_c brew tap terrastruct/d2 - sh_c brew install tala + sh_c brew update + sh_c brew install terrastruct/tap/tala } uninstall() { From d028915b7f88db8a587efb7b00f326258b75d704 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 18:59:23 -0800 Subject: [PATCH 05/19] ci: Update --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index 79b9dadce..f668611e9 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit 79b9dadce090a95b5a50d32f9ea3927845e5cce1 +Subproject commit f668611e9b1cfc335230ab6f8161cf87f74f174d From ce0e2b332638a1cc1a1e7789a68d78be4efb9c02 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:14:05 -0800 Subject: [PATCH 06/19] release: On windows use .exe and alter README Closes #388 --- ci/release/_build.sh | 16 ++++++++++------ ci/release/template/README.md.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/ci/release/_build.sh b/ci/release/_build.sh index 3f8b1663d..02c58f9db 100755 --- a/ci/release/_build.sh +++ b/ci/release/_build.sh @@ -4,19 +4,23 @@ cd -- "$(dirname "$0")/../.." . ./ci/sub/lib.sh sh_c mkdir -p "$HW_BUILD_DIR" -sh_c rsync --recursive --perms --delete \ - --human-readable --copy-links ./ci/release/template/ "$HW_BUILD_DIR/" -VERSION=$VERSION sh_c eval "'$HW_BUILD_DIR/README.md.sh'" \> "'$HW_BUILD_DIR/README.md'" -sh_c rm -f "$HW_BUILD_DIR/README.md.sh" -sh_c find "$HW_BUILD_DIR" -exec touch {} \\\; +sh_c cp ./ci/release/template/LICENSE.txt "$HW_BUILD_DIR" +sh_c cp ./ci/release/template/Makefile "$HW_BUILD_DIR" +sh_c cp -R ./ci/release/template/man "$HW_BUILD_DIR" +sh_c cp -Rf ./ci/release/template/scripts "$HW_BUILD_DIR" +sh_c VERSION="$VERSION" ./ci/release/template/README.md.sh \> "'$HW_BUILD_DIR/README.md'" ensure_goos ensure_goarch sh_c mkdir -p "$HW_BUILD_DIR/bin" -sh_c CGO_ENABLED=0 go build -trimpath \ +sh_c GOOS="$GOOS" GOARCH="$GOARCH" CGO_ENABLED=0 go build -trimpath \ -ldflags "'-X oss.terrastruct.com/d2/lib/version.Version=$VERSION'" \ -o "$HW_BUILD_DIR/bin/d2" . +if [ "$GOOS" = windows ]; then + sh_c mv "$HW_BUILD_DIR/bin/d2" "$HW_BUILD_DIR/bin/d2.exe" +fi + ARCHIVE=$PWD/$ARCHIVE cd "$(dirname "$HW_BUILD_DIR")" sh_c tar -czf "$ARCHIVE" "$(basename "$HW_BUILD_DIR")" diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index 2c0cdfb35..99411d923 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -1,5 +1,7 @@ #!/bin/sh set -eu +cd -- "$(dirname "$0")/../../.." +. ./ci/sub/lib.sh cat < Date: Wed, 7 Dec 2022 19:21:56 -0800 Subject: [PATCH 07/19] d2dagrelayout: Fix regexp See https://github.com/terrastruct/d2/pull/394#discussion_r1042504655 --- d2layouts/d2dagrelayout/layout.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d2layouts/d2dagrelayout/layout.go b/d2layouts/d2dagrelayout/layout.go index e1d29175e..ec72a91c6 100644 --- a/d2layouts/d2dagrelayout/layout.go +++ b/d2layouts/d2dagrelayout/layout.go @@ -261,7 +261,7 @@ func escapeID(id string) string { // fixes \\ id = strings.ReplaceAll(id, "\\", `\\`) // replaces \n with \\n whenever \n is not preceded by \ (does not replace \\n) - re := regexp.MustCompile(`[^\\](\n)`) + re := regexp.MustCompile(`[^\\]\n`) id = re.ReplaceAllString(id, `\\n`) // avoid an unescaped \r becoming a \n in the layout result id = strings.ReplaceAll(id, "\r", `\r`) From 1fde26789a2c47b8700d53e9a50cffd119a3d8e9 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:27:06 -0800 Subject: [PATCH 08/19] release/next.md: Update --- ci/release/changelogs/next.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 84d6618aa..3fadfa006 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -2,6 +2,8 @@ #### Improvements 🧹 +- The Windows release binary is now suffixed correctly with `.exe` [#388](https://github.com/terrastruct/d2/issues/388) + #### Bugfixes ⛑️ -- Fixed sequence diagram span size for self-edges [#397](https://github.com/terrastruct/d2/pull/397) \ No newline at end of file +- Fixed sequence diagram span size for self-edges [#397](https://github.com/terrastruct/d2/pull/397) From c2bcb3a93e1c2472b008bf7f4fb94e49c20d97e3 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:30:04 -0800 Subject: [PATCH 09/19] release/template/README.md: Document easiest way to use windows --- ci/release/template/README.md.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index 99411d923..115bba209 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -19,14 +19,18 @@ ensure_os if [ "$OS" = windows ]; then cat < + +You can install on Windows with [MSYS2](https://www.msys2.org/) which emulates a Linux +shell for Windows. It also enables d2 to show colors in its output. But if you must install on Windows without MSYS2, for now you'll have to add the d2 binary -in \`./bin/d2.exe\` to your \`\$PATH\` manually. You can also add the \`./bin\` directory -to your \`\$PATH\`. +in \`./bin/d2.exe\` to your \`\$PATH\` manually. Or you can add the \`./bin\` directory to +your \`\$PATH\`. See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows See https://github.com/terrastruct/d2/blob/master/docs/INSTALL.md#windows From 31346482731fb6ad4cb605e558a5f3a99cc2f4ae Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:32:26 -0800 Subject: [PATCH 10/19] install.md: Document easiest way to use windows --- ci/release/template/README.md.sh | 5 ++++- docs/INSTALL.md | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index 115bba209..6bfcfdb50 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -23,7 +23,7 @@ We currently do not have a .msi for automatic installation on Windows so this re structured the same as our Unix releases. Easiest way to use d2 on Windows is to just cd into the bin directory of this release -and invoke d2 like ./d2.exe +and invoke d2 like \`./d2.exe \` You can install on Windows with [MSYS2](https://www.msys2.org/) which emulates a Linux shell for Windows. It also enables d2 to show colors in its output. @@ -32,6 +32,9 @@ But if you must install on Windows without MSYS2, for now you'll have to add the in \`./bin/d2.exe\` to your \`\$PATH\` manually. Or you can add the \`./bin\` directory to your \`\$PATH\`. +We intend to have a \`.msi\` release installer sometime soon that handles putting \`d2\` into +your \`\$PATH\` for you. + See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows See https://github.com/terrastruct/d2/blob/master/docs/INSTALL.md#windows EOF diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 7d29525d2..c4c0b7cd4 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -158,8 +158,13 @@ the `d2` binary. d2 builds and runs on Windows: We have prebuilt standalone releases for Windows though they're structured in the same way -as our Unix releases. So after extracting a release, you'll have to manually put the d2 -binary into your `$PATH` or add the `bin` directory of the release into your `$PATH`. +as our Unix releases. + +Easiest way to use d2 on Windows is to just cd into the bin directory of the release after +extracting it and invoking d2 like `./d2.exe ` + +For installation, you'll have to manually put the d2 binary into your `$PATH` or add the +`bin` directory of the release into your `$PATH`. See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows From 44c11a13ce173292b488a5ab451dd7800eef23f3 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:42:58 -0800 Subject: [PATCH 11/19] Update windows install docs --- ci/release/template/README.md.sh | 24 ++++++++++++++---------- docs/INSTALL.md | 16 ++++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index 6bfcfdb50..d52d96716 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -19,23 +19,27 @@ ensure_os if [ "$OS" = windows ]; then cat <\` +Easiest way to use d2 on Windows is to just \`chdir\` into the bin directory of this release +and invoke d2 like \`./d2 \` -You can install on Windows with [MSYS2](https://www.msys2.org/) which emulates a Linux -shell for Windows. It also enables d2 to show colors in its output. +For installation you'll have to add the \`./bin/d2.exe\` binary to your \`\$PATH\`. Or add +the \`./bin\` directory of this release to your \`\$PATH\`. -But if you must install on Windows without MSYS2, for now you'll have to add the d2 binary -in \`./bin/d2.exe\` to your \`\$PATH\` manually. Or you can add the \`./bin\` directory to -your \`\$PATH\`. +See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows + +Then you'll be able to call \`d2\` from the commandline in \`cmd.exe\` or \`pwsh.exe\`. We intend to have a \`.msi\` release installer sometime soon that handles putting \`d2\` into your \`\$PATH\` for you. -See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows +You can also use \`make install\` to install on Windows after first installing +[MSYS2](https://www.msys2.org/) which emulates a Linux shell for Windows. Its terminal +also enables d2 to show colors in its output. The manpage will also become accessible +with \`man d2\`. + See https://github.com/terrastruct/d2/blob/master/docs/INSTALL.md#windows EOF fi diff --git a/docs/INSTALL.md b/docs/INSTALL.md index c4c0b7cd4..afca4df39 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -140,7 +140,7 @@ go install oss.terrastruct.com/d2@latest ### Source Release -To install a proper release from source clone the repository and then: +To install a release from source clone the repository and then: ```sh ./ci/release/build.sh --install @@ -149,9 +149,9 @@ To install a proper release from source clone the repository and then: ``` Installing a real release will also install manpages and in the future other assets like -fonts and icons. Furthermore, when installing a non versioned commit, installing a proper -release will ensure that `d2 --version` works correctly by embedding the commit hash into -the `d2` binary. +fonts and icons. Furthermore, when installing a non versioned commit, installing a release +will ensure that `d2 --version` works correctly by embedding the commit hash into the `d2` +binary. ## Windows @@ -160,10 +160,10 @@ d2 builds and runs on Windows: We have prebuilt standalone releases for Windows though they're structured in the same way as our Unix releases. -Easiest way to use d2 on Windows is to just cd into the bin directory of the release after -extracting it and invoking d2 like `./d2.exe ` +Easiest way to use d2 on Windows is to just `chdir` into the bin directory of the release +and invoke d2 like `./d2 ` -For installation, you'll have to manually put the d2 binary into your `$PATH` or add the +For installation, you'll have to put the `bin/d2.exe` binary into your `$PATH` or add the `bin` directory of the release into your `$PATH`. See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows @@ -182,7 +182,7 @@ Bash](https://gitforwindows.org/#bash) (Git Bash is based on MSYS2) for an impro terminal experience. MSYS2 provides a unix style shell environment that is native to Windows (unlike -[Cygwin](https://www.cygwin.com/)). MSYS2 allows `install.sh` to work, enables proper +[Cygwin](https://www.cygwin.com/)). MSYS2 allows `install.sh` to work, enables automatic installation of our standalone releases via `make install` and makes the manpage accessible via `man d2`. From 472c101e502af9a90c808157382a3823cf9a4e1f Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 20:59:24 -0800 Subject: [PATCH 12/19] ci: Update --- ci/fmt.sh | 8 +------- ci/sub | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/ci/fmt.sh b/ci/fmt.sh index 4fb39da34..90b405eab 100755 --- a/ci/fmt.sh +++ b/ci/fmt.sh @@ -3,10 +3,4 @@ set -eu . "$(dirname "$0")/sub/lib.sh" cd -- "$(dirname "$0")/.." -if is_changed README.md; then - sh_c tocsubst --skip 1 README.md -fi -if is_changed docs/INSTALL.md; then - sh_c tocsubst --skip 1 docs/INSTALL.md -fi -./ci/sub/fmt/make.sh +./ci/sub/bin/fmt.sh diff --git a/ci/sub b/ci/sub index f668611e9..8892ef430 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit f668611e9b1cfc335230ab6f8161cf87f74f174d +Subproject commit 8892ef43000921a29a1f1118c84d7eabbb9ef0c5 From 8f0c3fa50262dbde1c3aa0738e268c19398da40b Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 22:49:46 -0800 Subject: [PATCH 13/19] ci: Update [ci-force] --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index 8892ef430..d66db4fa7 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit 8892ef43000921a29a1f1118c84d7eabbb9ef0c5 +Subproject commit d66db4fa78a6bbd13265b6e6b76fc35e86d23620 From f76e151991b49330fb171fdf23e746e51fb918c9 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 23:04:20 -0800 Subject: [PATCH 14/19] ci: Update [ci-force] --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index d66db4fa7..a49f76ce4 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit d66db4fa78a6bbd13265b6e6b76fc35e86d23620 +Subproject commit a49f76ce44949ebb17506c6d2bb2c3785bf73c8d From a86e409b49e1927f4a85852bdecbd76db7758fe9 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 23:13:12 -0800 Subject: [PATCH 15/19] ci: Update [ci-force] --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index a49f76ce4..aac1d2b9c 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit a49f76ce44949ebb17506c6d2bb2c3785bf73c8d +Subproject commit aac1d2b9c887bc48a05337dd76a44262fc936013 From b72959a91fddd85a8f2205362add94152d7437c0 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 23:22:20 -0800 Subject: [PATCH 16/19] fmt --- .prettierignore | 6 ++++++ Makefile | 2 +- ci/fmt.sh | 6 ------ d2compiler/compile_test.go | 2 +- d2layouts/d2elklayout/layout.go | 1 + d2layouts/d2sequence/layout.go | 1 - d2plugin/serve.go | 2 +- d2renderers/d2latex/latex.go | 1 + lib/imgbundler/imgbundler.go | 2 +- 9 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 .prettierignore delete mode 100755 ci/fmt.sh diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..d7226ae8f --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +d2layouts/d2dagrelayout/dagre.js +d2layouts/d2elklayout/setup.js +d2renderers/d2latex/mathjax.js +d2renderers/d2latex/polyfills.js +d2renderers/d2latex/setup.js +lib/png/generate_png.js diff --git a/Makefile b/Makefile index fdc039a33..13a440c2c 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all: fmt gen lint build test .PHONY: fmt fmt: - prefix "$@" ./ci/fmt.sh + prefix "$@" GOIMPORTS_LOCAL=oss.terrastruct.com, ./ci/sub/bin/fmt.sh .PHONY: gen gen: prefix "$@" ./ci/gen.sh diff --git a/ci/fmt.sh b/ci/fmt.sh deleted file mode 100755 index 90b405eab..000000000 --- a/ci/fmt.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -eu -. "$(dirname "$0")/sub/lib.sh" -cd -- "$(dirname "$0")/.." - -./ci/sub/bin/fmt.sh diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 593c139d9..b68e28644 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -7,9 +7,9 @@ import ( "testing" tassert "github.com/stretchr/testify/assert" + "oss.terrastruct.com/util-go/assert" "oss.terrastruct.com/util-go/diff" - "oss.terrastruct.com/d2/d2compiler" "oss.terrastruct.com/d2/d2format" "oss.terrastruct.com/d2/d2graph" diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index 2449a9751..63b26c95f 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -12,6 +12,7 @@ import ( "math" "github.com/dop251/goja" + "oss.terrastruct.com/util-go/xdefer" "oss.terrastruct.com/util-go/go2" diff --git a/d2layouts/d2sequence/layout.go b/d2layouts/d2sequence/layout.go index 7940e13b1..c6934c051 100644 --- a/d2layouts/d2sequence/layout.go +++ b/d2layouts/d2sequence/layout.go @@ -6,7 +6,6 @@ import ( "strings" "oss.terrastruct.com/util-go/go2" - "oss.terrastruct.com/d2/d2graph" "oss.terrastruct.com/d2/d2target" "oss.terrastruct.com/d2/lib/geo" diff --git a/d2plugin/serve.go b/d2plugin/serve.go index 4f83aa8a8..b99768e3a 100644 --- a/d2plugin/serve.go +++ b/d2plugin/serve.go @@ -8,8 +8,8 @@ import ( "io" "github.com/spf13/pflag" - "oss.terrastruct.com/util-go/xmain" + "oss.terrastruct.com/util-go/xmain" "oss.terrastruct.com/d2/d2graph" ) diff --git a/d2renderers/d2latex/latex.go b/d2renderers/d2latex/latex.go index 74fdb0759..a822b2c7b 100644 --- a/d2renderers/d2latex/latex.go +++ b/d2renderers/d2latex/latex.go @@ -8,6 +8,7 @@ import ( "strconv" "github.com/dop251/goja" + "oss.terrastruct.com/util-go/xdefer" ) diff --git a/lib/imgbundler/imgbundler.go b/lib/imgbundler/imgbundler.go index 14ff92cd8..e1b719687 100644 --- a/lib/imgbundler/imgbundler.go +++ b/lib/imgbundler/imgbundler.go @@ -17,8 +17,8 @@ import ( "time" "golang.org/x/xerrors" - "oss.terrastruct.com/util-go/xdefer" + "oss.terrastruct.com/util-go/xdefer" "oss.terrastruct.com/util-go/xmain" ) From b704c6684bc289334e472aa95c75e55061c7089d Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 23:40:13 -0800 Subject: [PATCH 17/19] ci: Update [ci-force] --- Makefile | 2 +- ci/sub | 2 +- d2compiler/compile_test.go | 4 ++-- d2layouts/d2sequence/layout.go | 2 +- d2plugin/serve.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 13a440c2c..8fd431900 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all: fmt gen lint build test .PHONY: fmt fmt: - prefix "$@" GOIMPORTS_LOCAL=oss.terrastruct.com, ./ci/sub/bin/fmt.sh + prefix "$@" ./ci/sub/bin/fmt.sh .PHONY: gen gen: prefix "$@" ./ci/gen.sh diff --git a/ci/sub b/ci/sub index aac1d2b9c..720467401 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit aac1d2b9c887bc48a05337dd76a44262fc936013 +Subproject commit 72046740162cff9799a94a8e1a8e4f4d7de73407 diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index b68e28644..c6cc1c25c 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -8,12 +8,12 @@ import ( tassert "github.com/stretchr/testify/assert" - "oss.terrastruct.com/util-go/assert" - "oss.terrastruct.com/util-go/diff" "oss.terrastruct.com/d2/d2compiler" "oss.terrastruct.com/d2/d2format" "oss.terrastruct.com/d2/d2graph" "oss.terrastruct.com/d2/d2target" + "oss.terrastruct.com/util-go/assert" + "oss.terrastruct.com/util-go/diff" ) func TestCompile(t *testing.T) { diff --git a/d2layouts/d2sequence/layout.go b/d2layouts/d2sequence/layout.go index c6934c051..42efeb174 100644 --- a/d2layouts/d2sequence/layout.go +++ b/d2layouts/d2sequence/layout.go @@ -5,11 +5,11 @@ import ( "sort" "strings" - "oss.terrastruct.com/util-go/go2" "oss.terrastruct.com/d2/d2graph" "oss.terrastruct.com/d2/d2target" "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/label" + "oss.terrastruct.com/util-go/go2" ) // Layout runs the sequence diagram layout engine on objects of shape sequence_diagram diff --git a/d2plugin/serve.go b/d2plugin/serve.go index b99768e3a..b13680746 100644 --- a/d2plugin/serve.go +++ b/d2plugin/serve.go @@ -9,8 +9,8 @@ import ( "github.com/spf13/pflag" - "oss.terrastruct.com/util-go/xmain" "oss.terrastruct.com/d2/d2graph" + "oss.terrastruct.com/util-go/xmain" ) // Serve returns a xmain.RunFunc that will invoke the plugin p as necessary to service the From 5d93a7eff87ebc4044dd3ee98ce8cd628a73604b Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 23:56:43 -0800 Subject: [PATCH 18/19] README: Add daily badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 03bd040c1..31152515b 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ [Language docs](https://d2lang.com) | [Cheat sheet](./docs/assets/cheat_sheet.pdf) | [Comparisons](https://text-to-diagram.com) [![ci](https://github.com/terrastruct/d2/actions/workflows/ci.yml/badge.svg)](https://github.com/terrastruct/d2/actions/workflows/ci.yml) +[![daily](https://github.com/terrastruct/d2/actions/workflows/daily.yml/badge.svg)](https://github.com/terrastruct/d2/actions/workflows/daily.yml) [![release](https://img.shields.io/github/v/release/terrastruct/d2)](https://github.com/terrastruct/d2/releases) [![discord](https://img.shields.io/discord/1039184639652265985?label=discord)](https://discord.gg/NF6X8K4eDq) [![twitter](https://img.shields.io/twitter/follow/terrastruct?style=social)](https://twitter.com/terrastruct) From b8df98be1c3b4ac2e65580e194a0542d2e5cc27f Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 00:03:29 -0800 Subject: [PATCH 19/19] install.md: Demonstrate installation from source with homebrew --- docs/INSTALL.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 108cdc523..aec71267f 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -77,6 +77,12 @@ brew install d2 > The install script above does this automatically if you have `brew` installed and > are running it on macOS. +You can also install from source with: + +```d2 +brew install d2 --HEAD +``` + ## Standalone We publish standalone release archives for every release on Github.