mirror of
https://github.com/beego/bee.git
synced 2024-11-24 18:30:53 +00:00
commit
1a79d6dcca
@ -219,7 +219,6 @@ func readAppDirectories(directory string, paths *[]string) {
|
|||||||
useDirectory = true
|
useDirectory = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a file is excluded
|
// If a file is excluded
|
||||||
|
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/beego/bee/cmd/commands"
|
"github.com/beego/bee/cmd/commands"
|
||||||
beeLogger "github.com/beego/bee/logger"
|
beeLogger "github.com/beego/bee/logger"
|
||||||
"github.com/beego/bee/logger/colors"
|
"github.com/beego/bee/logger/colors"
|
||||||
|
"github.com/beego/bee/utils"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ Prints the current Bee, Beego and Go version alongside the platform information.
|
|||||||
}
|
}
|
||||||
var outputFormat string
|
var outputFormat string
|
||||||
|
|
||||||
const version = "1.8.2"
|
const version = "1.8.3"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
fs := flag.NewFlagSet("version", flag.ContinueOnError)
|
fs := flag.NewFlagSet("version", flag.ContinueOnError)
|
||||||
@ -117,16 +118,15 @@ func ShowShortVersionBanner() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetBeegoVersion() string {
|
func GetBeegoVersion() string {
|
||||||
gopath := os.Getenv("GOPATH")
|
|
||||||
re, err := regexp.Compile(`VERSION = "([0-9.]+)"`)
|
re, err := regexp.Compile(`VERSION = "([0-9.]+)"`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if gopath == "" {
|
wgopath := utils.GetGOPATHs()
|
||||||
|
if len(wgopath) == 0 {
|
||||||
beeLogger.Log.Error("You need to set GOPATH environment variable")
|
beeLogger.Log.Error("You need to set GOPATH environment variable")
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
wgopath := path.SplitList(gopath)
|
|
||||||
for _, wg := range wgopath {
|
for _, wg := range wgopath {
|
||||||
wg, _ = path.EvalSymlinks(path.Join(wg, "src", "github.com", "astaxie", "beego"))
|
wg, _ = path.EvalSymlinks(path.Join(wg, "src", "github.com", "astaxie", "beego"))
|
||||||
filename := path.Join(wg, "beego.go")
|
filename := path.Join(wg, "beego.go")
|
||||||
|
@ -863,7 +863,7 @@ func writeRouterFile(tables []*Table, rPath string, selectedTables map[string]bo
|
|||||||
nameSpaces = append(nameSpaces, nameSpace)
|
nameSpaces = append(nameSpaces, nameSpace)
|
||||||
}
|
}
|
||||||
// Add export controller
|
// Add export controller
|
||||||
fpath := path.Join(rPath, "router.go")
|
fpath := filepath.Join(rPath, "router.go")
|
||||||
routerStr := strings.Replace(RouterTPL, "{{nameSpaces}}", strings.Join(nameSpaces, ""), 1)
|
routerStr := strings.Replace(RouterTPL, "{{nameSpaces}}", strings.Join(nameSpaces, ""), 1)
|
||||||
routerStr = strings.Replace(routerStr, "{{pkgPath}}", pkgPath, 1)
|
routerStr = strings.Replace(routerStr, "{{pkgPath}}", pkgPath, 1)
|
||||||
var f *os.File
|
var f *os.File
|
||||||
|
@ -36,6 +36,7 @@ import (
|
|||||||
"github.com/astaxie/beego/swagger"
|
"github.com/astaxie/beego/swagger"
|
||||||
"github.com/astaxie/beego/utils"
|
"github.com/astaxie/beego/utils"
|
||||||
beeLogger "github.com/beego/bee/logger"
|
beeLogger "github.com/beego/bee/logger"
|
||||||
|
bu "github.com/beego/bee/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -141,7 +142,7 @@ func parsePackageFromDir(path string) error {
|
|||||||
func GenerateDocs(curpath string) {
|
func GenerateDocs(curpath string) {
|
||||||
fset := token.NewFileSet()
|
fset := token.NewFileSet()
|
||||||
|
|
||||||
f, err := parser.ParseFile(fset, path.Join(curpath, "routers", "router.go"), nil, parser.ParseComments)
|
f, err := parser.ParseFile(fset, filepath.Join(curpath, "routers", "router.go"), nil, parser.ParseComments)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
beeLogger.Log.Fatalf("Error while parsing router.go: %s", err)
|
beeLogger.Log.Fatalf("Error while parsing router.go: %s", err)
|
||||||
}
|
}
|
||||||
@ -350,8 +351,8 @@ func analyseControllerPkg(vendorPath, localName, pkgpath string) {
|
|||||||
pps := strings.Split(pkgpath, "/")
|
pps := strings.Split(pkgpath, "/")
|
||||||
importlist[pps[len(pps)-1]] = pkgpath
|
importlist[pps[len(pps)-1]] = pkgpath
|
||||||
}
|
}
|
||||||
gopath := os.Getenv("GOPATH")
|
gopaths := bu.GetGOPATHs()
|
||||||
if gopath == "" {
|
if len(gopaths) == 0 {
|
||||||
beeLogger.Log.Fatal("GOPATH environment variable is not set or empty")
|
beeLogger.Log.Fatal("GOPATH environment variable is not set or empty")
|
||||||
}
|
}
|
||||||
pkgRealpath := ""
|
pkgRealpath := ""
|
||||||
@ -360,7 +361,7 @@ func analyseControllerPkg(vendorPath, localName, pkgpath string) {
|
|||||||
if utils.FileExists(wg) {
|
if utils.FileExists(wg) {
|
||||||
pkgRealpath = wg
|
pkgRealpath = wg
|
||||||
} else {
|
} else {
|
||||||
wgopath := filepath.SplitList(gopath)
|
wgopath := gopaths
|
||||||
for _, wg := range wgopath {
|
for _, wg := range wgopath {
|
||||||
wg, _ = filepath.EvalSymlinks(filepath.Join(wg, "src", pkgpath))
|
wg, _ = filepath.EvalSymlinks(filepath.Join(wg, "src", pkgpath))
|
||||||
if utils.FileExists(wg) {
|
if utils.FileExists(wg) {
|
||||||
|
@ -52,16 +52,16 @@ func IsExist(path string) bool {
|
|||||||
// GetGOPATHs returns all paths in GOPATH variable.
|
// GetGOPATHs returns all paths in GOPATH variable.
|
||||||
func GetGOPATHs() []string {
|
func GetGOPATHs() []string {
|
||||||
gopath := os.Getenv("GOPATH")
|
gopath := os.Getenv("GOPATH")
|
||||||
|
if gopath == "" && strings.Compare(runtime.Version(), "go1.8") >= 0 {
|
||||||
|
gopath = defaultGOPATH()
|
||||||
|
}
|
||||||
return filepath.SplitList(gopath)
|
return filepath.SplitList(gopath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsInGOPATH checks whether the path is inside of any GOPATH or not
|
// IsInGOPATH checks whether the path is inside of any GOPATH or not
|
||||||
func IsInGOPATH(thePath string) bool {
|
func IsInGOPATH(thePath string) bool {
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
thePath = filepath.ToSlash(thePath)
|
|
||||||
}
|
|
||||||
for _, gopath := range GetGOPATHs() {
|
for _, gopath := range GetGOPATHs() {
|
||||||
if strings.Contains(thePath, gopath+"/src") {
|
if strings.Contains(thePath, filepath.Join(gopath, "src")) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -425,3 +425,16 @@ func GetFileModTime(path string) int64 {
|
|||||||
|
|
||||||
return fi.ModTime().Unix()
|
return fi.ModTime().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func defaultGOPATH() string {
|
||||||
|
env := "HOME"
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
env = "USERPROFILE"
|
||||||
|
} else if runtime.GOOS == "plan9" {
|
||||||
|
env = "home"
|
||||||
|
}
|
||||||
|
if home := os.Getenv(env); home != "" {
|
||||||
|
return filepath.Join(home, "go")
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user