From 339087600f9a7eb58efe4e6141aeff421b362431 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Tue, 25 Jan 2022 15:02:08 +0800 Subject: [PATCH] bump version to v0.5.3 --- cli/scripts/install.sh | 2 +- docs/CHANGELOG.md | 4 +++- internal/scaffold/main.go | 33 ++++++++++++++++++++++++++------- internal/version/init.go | 2 +- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/cli/scripts/install.sh b/cli/scripts/install.sh index af495e31..e7057bb1 100644 --- a/cli/scripts/install.sh +++ b/cli/scripts/install.sh @@ -2,7 +2,7 @@ # install hrp with one shell command # bash -c "$(curl -ksSL https://httprunner.oss-cn-beijing.aliyuncs.com/install.sh)" -LATEST_VERSION="v0.5.2" +LATEST_VERSION="v0.5.3" set -e diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0ad7b3cd..3978ac5c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,9 +1,11 @@ # Release History -## v0.5.3 (2022-01-20) +## v0.5.3 (2022-01-25) - change: download package assets from aliyun OSS - fix: disable color logging on Windows +- fix: print stderr when exec command failed +- fix: build hashicorp plugin failed when creating scaffold ## v0.5.2 (2022-01-19) diff --git a/internal/scaffold/main.go b/internal/scaffold/main.go index 419626a1..25ae49f3 100644 --- a/internal/scaffold/main.go +++ b/internal/scaffold/main.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "path" + "strings" "github.com/httprunner/hrp/internal/ga" "github.com/rs/zerolog/log" @@ -37,7 +38,8 @@ func CreateScaffold(projectName string) error { if err := createFolder(path.Join(projectName, "testcases")); err != nil { return err } - if err := createFolder(path.Join(projectName, "plugin")); err != nil { + pluginDir := path.Join(projectName, "plugin") + if err := createFolder(pluginDir); err != nil { return err } if err := createFolder(path.Join(projectName, "reports")); err != nil { @@ -58,15 +60,19 @@ func CreateScaffold(projectName string) error { } // create debugtalk.go - pluginFile := path.Join(projectName, "plugin", "debugtalk.go") + pluginFile := path.Join(pluginDir, "debugtalk.go") if err := createFile(pluginFile, demoPlugin); err != nil { return err } - cmd := exec.Command("go", "build", - "-o", path.Join(projectName, "debugtalk.bin"), - pluginFile) - if err := cmd.Run(); err != nil { - log.Error().Err(err).Msg("build plugin debugtalk.bin failed") + + // download plugin dependency + if err := execCommand(exec.Command("go", "get", "github.com/httprunner/hrp/plugin"), pluginDir); err != nil { + return err + } + + // build plugin debugtalk.bin + if err := execCommand(exec.Command("go", "build", "-o", path.Join("..", "debugtalk.bin"), "debugtalk.go"), pluginDir); err != nil { + return err } // create .gitignore @@ -81,6 +87,19 @@ func CreateScaffold(projectName string) error { return nil } +func execCommand(cmd *exec.Cmd, cwd string) error { + log.Info().Str("cmd", cmd.String()).Str("cwd", cwd).Msg("exec command") + cmd.Dir = cwd + output, err := cmd.CombinedOutput() + out := strings.TrimSpace(string(output)) + if err != nil { + log.Error().Err(err).Str("output", out).Msg("exec command failed") + } else if len(out) != 0 { + log.Info().Str("output", out).Msg("exec command success") + } + return err +} + func createFolder(folderPath string) error { log.Info().Str("path", folderPath).Msg("create folder") err := os.MkdirAll(folderPath, os.ModePerm) diff --git a/internal/version/init.go b/internal/version/init.go index 77c25720..389bae05 100644 --- a/internal/version/init.go +++ b/internal/version/init.go @@ -1,3 +1,3 @@ package version -const VERSION = "v0.5.2" +const VERSION = "v0.5.3"