fix issue of default migrate version (#1536)

* fix issue of default migrate version

* chore: update console colors
master tools/goctl/v1.3.2
Kevin Wan 3 years ago committed by GitHub
parent 6ab051568c
commit 6deb80625d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -634,5 +634,3 @@ func NewSyntaxLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, in
return p return p
} }

@ -19,6 +19,7 @@ func Completion(c *cli.Context) error {
if goos == vars.OsWindows { if goos == vars.OsWindows {
return fmt.Errorf("%q: only support unix-like OS", goos) return fmt.Errorf("%q: only support unix-like OS", goos)
} }
name := c.String("name") name := c.String("name")
if len(name) == 0 { if len(name) == 0 {
name = defaultCompletionFilename name = defaultCompletionFilename
@ -31,6 +32,7 @@ func Completion(c *cli.Context) error {
if err != nil { if err != nil {
return err return err
} }
buffer := bytes.NewBuffer(nil) buffer := bytes.NewBuffer(nil)
zshF := filepath.Join(home, "zsh", defaultCompletionFilename) zshF := filepath.Join(home, "zsh", defaultCompletionFilename)
err = pathx.MkdirIfNotExist(filepath.Dir(zshF)) err = pathx.MkdirIfNotExist(filepath.Dir(zshF))
@ -43,7 +45,8 @@ func Completion(c *cli.Context) error {
if err != nil { if err != nil {
return err return err
} }
var flag = magic
flag := magic
err = ioutil.WriteFile(zshF, zsh, os.ModePerm) err = ioutil.WriteFile(zshF, zsh, os.ModePerm)
if err != nil { if err != nil {
return err return err
@ -56,20 +59,21 @@ func Completion(c *cli.Context) error {
} }
flag |= flagBash flag |= flagBash
buffer.WriteString(aurora.Green("generation auto completion success!\n").String()) buffer.WriteString(aurora.BrightGreen("generation auto completion success!\n").String())
buffer.WriteString(aurora.Green("executes the following script to setting shell:\n").String()) buffer.WriteString(aurora.BrightGreen("executes the following script to setting shell:\n").String())
switch flag { switch flag {
case magic | flagZsh: case magic | flagZsh:
buffer.WriteString(aurora.Blue(fmt.Sprintf("echo PROG=goctl source %s >> ~/.zshrc && source ~/.zshrc", zshF)).String()) buffer.WriteString(aurora.BrightCyan(fmt.Sprintf("echo PROG=goctl source %s >> ~/.zshrc && source ~/.zshrc", zshF)).String())
case magic | flagBash: case magic | flagBash:
buffer.WriteString(aurora.Blue(fmt.Sprintf("echo PROG=goctl source %s >> ~/.bashrc && source ~/.bashrc", bashF)).String()) buffer.WriteString(aurora.BrightCyan(fmt.Sprintf("echo PROG=goctl source %s >> ~/.bashrc && source ~/.bashrc", bashF)).String())
case magic | flagZsh | flagBash: case magic | flagZsh | flagBash:
buffer.WriteString(aurora.Blue(fmt.Sprintf(`echo PROG=goctl source %s >> ~/.zshrc && source ~/.zshrc buffer.WriteString(aurora.BrightCyan(fmt.Sprintf(`echo PROG=goctl source %s >> ~/.zshrc && source ~/.zshrc
or or
echo PROG=goctl source %s >> ~/.bashrc && source ~/.bashrc`, zshF, bashF)).String()) echo PROG=goctl source %s >> ~/.bashrc && source ~/.bashrc`, zshF, bashF)).String())
default: default:
return nil return nil
} }
fmt.Println(buffer.String()) fmt.Println(buffer.String())
return nil return nil
} }

@ -22,7 +22,7 @@ import (
"github.com/zeromicro/go-zero/tools/goctl/vars" "github.com/zeromicro/go-zero/tools/goctl/vars"
) )
const zeromicroVersion = "1.3.0" const zeromicroVersion = "v1.3.0"
const ( const (
confirmUnknown = iota confirmUnknown = iota
@ -57,8 +57,10 @@ func Migrate(c *cli.Context) error {
} }
if verbose { if verbose {
console.Success("[OK] refactor finish, execute %q on project root to check status.", "go test -race ./...") console.Success("[OK] refactor finish, execute %q on project root to check status.",
"go test -race ./...")
} }
return nil return nil
} }

@ -12,10 +12,12 @@ import (
"github.com/zeromicro/go-zero/tools/goctl/util/ctx" "github.com/zeromicro/go-zero/tools/goctl/util/ctx"
) )
const deprecatedGoZeroMod = "github.com/tal-tech/go-zero" const (
const deprecatedBuilderx = "github.com/tal-tech/go-zero/tools/goctl/model/sql/builderx" deprecatedGoZeroMod = "github.com/tal-tech/go-zero"
const replacementBuilderx = "github.com/zeromicro/go-zero/core/stores/builder" deprecatedBuilderx = "github.com/tal-tech/go-zero/tools/goctl/model/sql/builderx"
const goZeroMod = "github.com/zeromicro/go-zero" replacementBuilderx = "github.com/zeromicro/go-zero/core/stores/builder"
goZeroMod = "github.com/zeromicro/go-zero"
)
var errInvalidGoMod = errors.New("it's only working for go module") var errInvalidGoMod = errors.New("it's only working for go module")
@ -38,11 +40,13 @@ func editMod(version string, verbose bool) error {
if !stringx.Contains(latest, version) { if !stringx.Contains(latest, version) {
return fmt.Errorf("release version %q is not found", version) return fmt.Errorf("release version %q is not found", version)
} }
mod := fmt.Sprintf("%s@%s", goZeroMod, version) mod := fmt.Sprintf("%s@%s", goZeroMod, version)
err = removeRequire(deprecatedGoZeroMod, verbose) err = removeRequire(deprecatedGoZeroMod, verbose)
if err != nil { if err != nil {
return err return err
} }
return addRequire(mod, verbose) return addRequire(mod, verbose)
} }

@ -50,22 +50,22 @@ func (c *colorConsole) Info(format string, a ...interface{}) {
func (c *colorConsole) Debug(format string, a ...interface{}) { func (c *colorConsole) Debug(format string, a ...interface{}) {
msg := fmt.Sprintf(format, a...) msg := fmt.Sprintf(format, a...)
println(aurora.Blue(msg)) println(aurora.BrightCyan(msg))
} }
func (c *colorConsole) Success(format string, a ...interface{}) { func (c *colorConsole) Success(format string, a ...interface{}) {
msg := fmt.Sprintf(format, a...) msg := fmt.Sprintf(format, a...)
println(aurora.Green(msg)) println(aurora.BrightGreen(msg))
} }
func (c *colorConsole) Warning(format string, a ...interface{}) { func (c *colorConsole) Warning(format string, a ...interface{}) {
msg := fmt.Sprintf(format, a...) msg := fmt.Sprintf(format, a...)
println(aurora.Yellow(msg)) println(aurora.BrightYellow(msg))
} }
func (c *colorConsole) Error(format string, a ...interface{}) { func (c *colorConsole) Error(format string, a ...interface{}) {
msg := fmt.Sprintf(format, a...) msg := fmt.Sprintf(format, a...)
println(aurora.Red(msg)) println(aurora.BrightRed(msg))
} }
func (c *colorConsole) Fatalln(format string, a ...interface{}) { func (c *colorConsole) Fatalln(format string, a ...interface{}) {
@ -95,7 +95,7 @@ func (i *ideaConsole) Info(format string, a ...interface{}) {
func (i *ideaConsole) Debug(format string, a ...interface{}) { func (i *ideaConsole) Debug(format string, a ...interface{}) {
msg := fmt.Sprintf(format, a...) msg := fmt.Sprintf(format, a...)
fmt.Println(aurora.Blue(msg)) fmt.Println(aurora.BrightCyan(msg))
} }
func (i *ideaConsole) Success(format string, a ...interface{}) { func (i *ideaConsole) Success(format string, a ...interface{}) {

Loading…
Cancel
Save