mirror of
https://github.com/beego/bee.git
synced 2025-06-12 20:20:40 +00:00
upgrade version to 2
This commit is contained in:
@ -3,10 +3,10 @@ package beefix
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/beego/bee/cmd/commands"
|
||||
"github.com/beego/bee/cmd/commands/version"
|
||||
beeLogger "github.com/beego/bee/logger"
|
||||
"github.com/beego/bee/utils"
|
||||
"github.com/beego/bee/v2/cmd/commands"
|
||||
"github.com/beego/bee/v2/cmd/commands/version"
|
||||
beeLogger "github.com/beego/bee/v2/logger"
|
||||
"github.com/beego/bee/v2/utils"
|
||||
)
|
||||
|
||||
var CmdFix = &commands.Command{
|
||||
@ -36,7 +36,7 @@ func init() {
|
||||
|
||||
func runFix(cmd *commands.Command, args []string) int {
|
||||
t := target.String()
|
||||
if t == "" || t == "1.6"{
|
||||
if t == "" || t == "1.6" {
|
||||
return fixTo16(cmd, args)
|
||||
} else if strings.HasPrefix(t, "2") {
|
||||
// upgrade to v2
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2020
|
||||
// Copyright 2020
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -18,20 +18,32 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
beeLogger "github.com/beego/bee/logger"
|
||||
beeLogger "github.com/beego/bee/v2/logger"
|
||||
)
|
||||
|
||||
func fix1To2() int {
|
||||
beeLogger.Log.Info("Upgrading the application...")
|
||||
|
||||
cmdStr := `find ./ -name '*.go' -type f -exec sed -i '' -e 's/github.com\/astaxie\/beego/github.com\/beego\/beego\/v2\/adapter/g' {} \;`
|
||||
cmdStr := `go get -u github.com/beego/beego/v2@develop`
|
||||
err := runShell(cmdStr)
|
||||
if err != nil {
|
||||
beeLogger.Log.Error(err.Error())
|
||||
beeLogger.Log.Error(`fetch v2.0.1 failed. Please try to run: export GO111MODULE=on
|
||||
and if your network is not stable, please try to use proxy, for example: export GOPROXY=https://goproxy.cn;'
|
||||
`)
|
||||
return 1
|
||||
}
|
||||
|
||||
cmdStr = `find ./ -name '*.go' -type f -exec sed -i '' -e 's/github.com\/astaxie\/beego/github.com\/beego\/beego\/v2\/adapter/g' {} \;`
|
||||
err = runShell(cmdStr)
|
||||
if err != nil {
|
||||
beeLogger.Log.Error(err.Error())
|
||||
return 1
|
||||
}
|
||||
cmdStr = `find ./ -name '*.go' -type f -exec sed -i '' -e 's/"github.com\/beego\/beego\/v2\/adapter"/beego "github.com\/beego\/beego\/v2\/adapter"/g' {} \;`
|
||||
err = runShell(cmdStr)
|
||||
if err != nil {
|
||||
beeLogger.Log.Error(err.Error())
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2020
|
||||
// Copyright 2020
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -24,9 +24,9 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/bee/cmd/commands"
|
||||
beeLogger "github.com/beego/bee/logger"
|
||||
"github.com/beego/bee/logger/colors"
|
||||
"github.com/beego/bee/v2/cmd/commands"
|
||||
beeLogger "github.com/beego/bee/v2/logger"
|
||||
"github.com/beego/bee/v2/logger/colors"
|
||||
)
|
||||
|
||||
// fixTo16 upgrade beego to 1.6
|
||||
@ -228,4 +228,3 @@ func fixFile(file string) error {
|
||||
}
|
||||
return ioutil.WriteFile(file, []byte(fixed), 0666)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user