diff --git a/Makefile b/Makefile index 27ecd6d..8cbb5d5 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,4 @@ -VERSION ?= $(shell ./scripts/get-CalVer.sh) -PLUGINS_BRANCH ?= master +VERSION ?= $(shell date +"%Y%m%d") OUTPUT_DIR := _output .PHONY: typegen diff --git a/cmd/ndc-go-sdk/main.go b/cmd/ndc-go-sdk/main.go index 760cd82..c3d2b0a 100644 --- a/cmd/ndc-go-sdk/main.go +++ b/cmd/ndc-go-sdk/main.go @@ -37,7 +37,7 @@ func main() { Str("module", cli.Init.Module). Str("output", cli.Init.Output). Msg("generating the NDC boilerplate...") - if err := generateNewProject(cli.Init.Name, cli.Init.Module, cli.Init.Output); err != nil { + if err := generateNewProject(cli.Init.Name, cli.Init.Module, cli.Init.Output, false); err != nil { log.Fatal().Err(err).Msg("failed to generate new project") } log.Info().Msg("generated successfully") diff --git a/cmd/ndc-go-sdk/template.go b/cmd/ndc-go-sdk/template.go index c4da055..2d62cda 100644 --- a/cmd/ndc-go-sdk/template.go +++ b/cmd/ndc-go-sdk/template.go @@ -34,7 +34,7 @@ func init() { } } -func generateNewProject(name string, moduleName string, srcPath string) error { +func generateNewProject(name string, moduleName string, srcPath string, silent bool) error { if srcPath == "" { p, err := os.Getwd() if err != nil { @@ -55,13 +55,23 @@ func generateNewProject(name string, moduleName string, srcPath string) error { } if err := execGoModTidy(""); err != nil { + if silent { + return nil + } return err } if err := execGoGetUpdate(".", "github.com/hasura/ndc-sdk-go"); err != nil { + if silent { + return nil + } return err } - return execGoFormat(".") + err := execGoFormat(".") + if err != nil && silent { + return nil + } + return err } func generateNewProjectFiles(name string, moduleName string, srcPath string) error { @@ -125,7 +135,11 @@ func execCommand(basePath string, commandName string, args ...string) error { cmd.Dir = basePath } out, err := cmd.Output() - log.Debug().Strs("args", args).Str("result", string(out)).Msg(commandName) + l := log.Debug() + if err != nil { + l = log.Error().Err(err) + } + l.Strs("args", args).Str("result", string(out)).Msg(commandName) return err } diff --git a/cmd/ndc-go-sdk/template_test.go b/cmd/ndc-go-sdk/template_test.go index 90131d3..8983b83 100644 --- a/cmd/ndc-go-sdk/template_test.go +++ b/cmd/ndc-go-sdk/template_test.go @@ -8,5 +8,5 @@ import ( func TestGenerateNewProject(t *testing.T) { tempDir := t.TempDir() - assert.NoError(t, generateNewProject("test", "hasura.dev/connector", tempDir)) + assert.NoError(t, generateNewProject("test", "hasura.dev/connector", tempDir, true)) } diff --git a/scripts/get-CalVer.sh b/scripts/get-CalVer.sh deleted file mode 100755 index 2b392eb..0000000 --- a/scripts/get-CalVer.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -u -set -o pipefail - -formatted_date=$(date +'%Y.%m.%d') -echo $formatted_date \ No newline at end of file