[ci-base] cleanup
This commit is contained in:
parent
850a10a4c2
commit
bded5b13fa
8 changed files with 4 additions and 60 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
// #
|
||||
// """
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
2
go.mod
2
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
|
||||
|
|
|
|||
4
go.sum
4
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=
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue