From c55bf62438750294bdf45a6e7e1f6da93ad73d0c Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 30 Nov 2022 21:14:38 -0800 Subject: [PATCH] d2: Move cmd to repo root Closes #113 --- ci/release/_build.sh | 2 +- ci/release/changelogs/next.md | 4 ++++ c.go => d2lib/c.go | 2 +- d2.go => d2lib/d2.go | 2 +- docs/INSTALL.md | 2 +- e2etests/e2e_test.go | 2 +- cmd/d2/help.go => help.go | 2 +- cmd/d2/main.go => main.go | 2 +- cmd/d2/main_test.go => main_test.go | 0 {cmd/d2/static => static}/watch.css | 0 {cmd/d2/static => static}/watch.js | 0 cmd/d2/watch.go => watch.go | 0 cmd/d2/watch_dev.go => watch_dev.go | 0 13 files changed, 11 insertions(+), 7 deletions(-) rename c.go => d2lib/c.go (90%) rename d2.go => d2lib/d2.go (98%) rename cmd/d2/help.go => help.go (98%) rename cmd/d2/main.go => main.go (99%) rename cmd/d2/main_test.go => main_test.go (100%) rename {cmd/d2/static => static}/watch.css (100%) rename {cmd/d2/static => static}/watch.js (100%) rename cmd/d2/watch.go => watch.go (100%) rename cmd/d2/watch_dev.go => watch_dev.go (100%) diff --git a/ci/release/_build.sh b/ci/release/_build.sh index c5170219a..4abfd6dec 100755 --- a/ci/release/_build.sh +++ b/ci/release/_build.sh @@ -14,7 +14,7 @@ export GOOS=$(goos "$OS") export GOARCH="$ARCH" sh_c mkdir -p "$HW_BUILD_DIR/bin" sh_c go build -ldflags "'-X oss.terrastruct.com/d2/lib/version.Version=$VERSION'" \ - -o "$HW_BUILD_DIR/bin/d2" ./cmd/d2 + -o "$HW_BUILD_DIR/bin/d2" . ARCHIVE=$PWD/$ARCHIVE cd "$(dirname "$HW_BUILD_DIR")" diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index cf91ce05e..b253f2e8b 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -23,6 +23,10 @@ [#251](https://github.com/terrastruct/d2/pull/251) - [install.sh](./install.sh) prints the dry run message more visibly. [#266](https://github.com/terrastruct/d2/pull/266) +- `d2` now lives in the root folder of the repository instead of as a subcommand. + So you can run `go install oss.terrastruct.com/d2@latest` to install from source + now. + [#xxx](https://github.com/terrastruct/d2/pull/xxx) #### Bugfixes 🔴 diff --git a/c.go b/d2lib/c.go similarity index 90% rename from c.go rename to d2lib/c.go index 1fa3fc225..2774d943e 100644 --- a/c.go +++ b/d2lib/c.go @@ -1,6 +1,6 @@ //go:build cgo -package d2 +package d2lib import "oss.terrastruct.com/d2/d2layouts/d2dagrelayout" diff --git a/d2.go b/d2lib/d2.go similarity index 98% rename from d2.go rename to d2lib/d2.go index d6fdfe8a2..91267326e 100644 --- a/d2.go +++ b/d2lib/d2.go @@ -1,4 +1,4 @@ -package d2 +package d2lib import ( "context" diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 71d3fcd0a..95d677851 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -83,7 +83,7 @@ know where the release directory is for easy uninstall. You can always install from source: ```sh -go install oss.terrastruct.com/d2/cmd/d2@latest +go install oss.terrastruct.com/d2@latest ``` ## Coming soon diff --git a/e2etests/e2e_test.go b/e2etests/e2e_test.go index 513451247..ea7cfaa65 100644 --- a/e2etests/e2e_test.go +++ b/e2etests/e2e_test.go @@ -16,10 +16,10 @@ import ( "oss.terrastruct.com/diff" - "oss.terrastruct.com/d2" "oss.terrastruct.com/d2/d2graph" "oss.terrastruct.com/d2/d2layouts/d2dagrelayout" "oss.terrastruct.com/d2/d2layouts/d2elklayout" + d2 "oss.terrastruct.com/d2/d2lib" "oss.terrastruct.com/d2/d2renderers/d2svg" "oss.terrastruct.com/d2/d2renderers/textmeasure" "oss.terrastruct.com/d2/d2target" diff --git a/cmd/d2/help.go b/help.go similarity index 98% rename from cmd/d2/help.go rename to help.go index 947c601e8..6c1cec897 100644 --- a/cmd/d2/help.go +++ b/help.go @@ -22,7 +22,7 @@ It defaults to file.svg if an output path is not provided. Use - to have d2 read from stdin or write to stdout. -See man %[1]s for more detailed docs. +See man d2 for more detailed docs. Flags: %s diff --git a/cmd/d2/main.go b/main.go similarity index 99% rename from cmd/d2/main.go rename to main.go index ffcb4509d..c6fd94647 100644 --- a/cmd/d2/main.go +++ b/main.go @@ -14,8 +14,8 @@ import ( "github.com/spf13/pflag" "go.uber.org/multierr" - "oss.terrastruct.com/d2" "oss.terrastruct.com/d2/d2layouts/d2sequence" + d2 "oss.terrastruct.com/d2/d2lib" "oss.terrastruct.com/d2/d2plugin" "oss.terrastruct.com/d2/d2renderers/d2svg" "oss.terrastruct.com/d2/d2renderers/textmeasure" diff --git a/cmd/d2/main_test.go b/main_test.go similarity index 100% rename from cmd/d2/main_test.go rename to main_test.go diff --git a/cmd/d2/static/watch.css b/static/watch.css similarity index 100% rename from cmd/d2/static/watch.css rename to static/watch.css diff --git a/cmd/d2/static/watch.js b/static/watch.js similarity index 100% rename from cmd/d2/static/watch.js rename to static/watch.js diff --git a/cmd/d2/watch.go b/watch.go similarity index 100% rename from cmd/d2/watch.go rename to watch.go diff --git a/cmd/d2/watch_dev.go b/watch_dev.go similarity index 100% rename from cmd/d2/watch_dev.go rename to watch_dev.go