-
Notifications
You must be signed in to change notification settings - Fork 15
/
upgrade.go
46 lines (37 loc) · 876 Bytes
/
upgrade.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package upgrade
import (
"errors"
"github.com/gookit/color"
"github.com/spf13/cobra"
conf "github.com/suyuan32/goctls/config"
"github.com/suyuan32/goctls/rpc/execx"
"os"
)
var (
// VarBoolUpgradeMakefile describe whether to upgrade makefile
VarBoolUpgradeMakefile bool
)
func UpgradeProject(_ *cobra.Command, _ []string) error {
color.Green.Println("Start upgrading dependencies...")
err := editMod(conf.DefaultGoZeroVersion, conf.DefaultToolVersion)
if err != nil {
return err
}
wd, err := os.Getwd()
if err != nil {
return err
}
err = upgradeDependencies(wd)
if err != nil {
return err
}
if VarBoolUpgradeMakefile {
color.Green.Println("Start upgrading Makefile ...")
_, err = execx.Run("goctls extra makefile", wd)
if err != nil {
return errors.New("failed to upgrade makefile")
}
}
color.Green.Println("Done.")
return nil
}