From bded5b13fa44b0da9d4399601eff69a0b1bcc688 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 14 Nov 2022 19:05:23 -0800 Subject: [PATCH] [ci-base] cleanup --- cmd/d2/main.go | 6 ++--- d2ast/d2ast.go | 3 --- d2compiler/doc.go | 3 --- d2layouts/d2elklayout/layout.go | 3 +-- d2themes/d2themes.go | 3 --- go.mod | 2 -- go.sum | 4 ---- lib/version/version.go | 40 --------------------------------- 8 files changed, 4 insertions(+), 60 deletions(-) diff --git a/cmd/d2/main.go b/cmd/d2/main.go index 6ce4d5459..a960a3d23 100644 --- a/cmd/d2/main.go +++ b/cmd/d2/main.go @@ -35,7 +35,7 @@ func run(ctx context.Context, ms *xmain.State) (err error) { watchFlag := ms.FlagSet.BoolP("watch", "w", false, "watch for changes to input and live reload. Use $PORT and $HOST to specify the listening address.\n$D2_PORT and $D2_HOST are also accepted and take priority. Default is localhost:0") themeFlag := ms.FlagSet.Int64P("theme", "t", 0, "set the diagram theme. For a list of available options, see https://oss.terrastruct.com/d2") bundleFlag := ms.FlagSet.BoolP("bundle", "b", true, "bundle all assets and layers into the output svg") - versionFlag := ms.FlagSet.BoolP("version", "v", false, "get the version and check for updates") + versionFlag := ms.FlagSet.BoolP("version", "v", false, "get the version") debugFlag := ms.FlagSet.BoolP("debug", "d", false, "print debug logs") err = ms.FlagSet.Parse(ms.Args) @@ -64,7 +64,7 @@ func run(ctx context.Context, ms *xmain.State) (err error) { if len(ms.FlagSet.Args()) == 0 { if versionFlag != nil && *versionFlag { - version.CheckVersion(ctx, ms.Log) + fmt.Println(version.Version) return nil } help(ms) @@ -74,7 +74,7 @@ func run(ctx context.Context, ms *xmain.State) (err error) { } if len(ms.FlagSet.Args()) >= 1 { if ms.FlagSet.Arg(0) == "version" { - version.CheckVersion(ctx, ms.Log) + fmt.Println(version.Version) return nil } inputPath = ms.FlagSet.Arg(0) diff --git a/d2ast/d2ast.go b/d2ast/d2ast.go index 69fa544fe..fa2cefffa 100644 --- a/d2ast/d2ast.go +++ b/d2ast/d2ast.go @@ -1,8 +1,5 @@ // d2ast implements the d2 language's abstract syntax tree. // -// https://github.com/terrastruct/d2-vscode -// https://terrastruct.com/docs/d2/tour/intro/ -// // Special characters to think about in parser: // # // """ diff --git a/d2compiler/doc.go b/d2compiler/doc.go index 03799880e..401d9eb3f 100644 --- a/d2compiler/doc.go +++ b/d2compiler/doc.go @@ -1,6 +1,3 @@ // Package d2compiler implements a parser, compiler and autoformatter for the Terrastruct d2 // diagramming language. -// -// https://github.com/terrastruct/d2-vscode -// https://terrastruct.com/docs/d2/tour/intro/ package d2compiler diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index 762b85f17..eaadd520c 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -12,7 +12,6 @@ import ( "math" "rogchap.com/v8go" - v8 "rogchap.com/v8go" "oss.terrastruct.com/xdefer" @@ -104,7 +103,7 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) { }) global.Set("setTimeout", setTimeout, v8go.ReadOnly) - v8ctx := v8.NewContext(iso, global) + v8ctx := v8go.NewContext(iso, global) if _, err := v8ctx.RunScript(elkJS, "elk.js"); err != nil { return err } diff --git a/d2themes/d2themes.go b/d2themes/d2themes.go index 5ea17bd6f..c5217c592 100644 --- a/d2themes/d2themes.go +++ b/d2themes/d2themes.go @@ -18,9 +18,6 @@ type Neutral struct { } type ColorPalette struct { - // So far the palette only contains the colors used in d2 shapes, the full theme includes more colors - // https://www.figma.com/file/n79RbPiHFUTO4PPPdpDu7w/%5BKW%5D-GUI-features?node-id=2268%3A120792 - Neutrals Neutral `json:"neutrals"` // Base Colors: used for containers diff --git a/go.mod b/go.mod index f0c96a553..5f2d06a25 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/alecthomas/chroma v0.10.0 github.com/fsnotify/fsnotify v1.6.0 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 - github.com/google/go-github v17.0.0+incompatible github.com/lucasb-eyer/go-colorful v1.2.0 github.com/mazznoer/csscolorparser v0.1.3 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 @@ -40,7 +39,6 @@ require ( github.com/gin-gonic/gin v1.7.7 // indirect github.com/go-playground/validator/v10 v10.10.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/google/go-querystring v1.1.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.13.6 // indirect diff --git a/go.sum b/go.sum index ac8c2599d..affa68d94 100644 --- a/go.sum +++ b/go.sum @@ -189,10 +189,6 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY= -github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= -github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= -github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= diff --git a/lib/version/version.go b/lib/version/version.go index 65db5ca1c..34ab1a5bf 100644 --- a/lib/version/version.go +++ b/lib/version/version.go @@ -1,44 +1,4 @@ package version -import ( - "context" - "fmt" - - "github.com/google/go-github/github" - "oss.terrastruct.com/cmdlog" -) - // Pre-built binaries will have version set during build time. var Version = "master (built from source)" - -func CheckVersion(ctx context.Context, logger *cmdlog.Logger) { - fmt.Println(Version) - - if Version == "master (built from source)" { - return - } - - // Install script uses -v to check the version, we shouldn't be checking for - // updates here... - // https://github.com/terrastruct/d2/issues/49#issuecomment-1313229683 - return - - logger.Info.Printf("Checking for updates...") - latest, err := getLatestVersion(ctx) - if err != nil { - logger.Debug.Printf("Error reaching Github for latest version: %s", err.Error()) - } else if Version != "master" && Version != latest { - logger.Info.Printf("A new version of D2 is available: %s -> %s", Version, latest) - } -} - -func getLatestVersion(ctx context.Context) (string, error) { - client := github.NewClient(nil) - rep, _, err := client.Repositories.GetLatestRelease(ctx, "terrastruct", "d2") - - if err != nil { - return "", err - } - - return *rep.TagName, nil -}