mirror of
https://github.com/beego/bee.git
synced 2024-11-22 05:00:54 +00:00
Merge pull request #760 from wangle201210/develop
Template url customization
This commit is contained in:
commit
3a727232d7
@ -32,6 +32,7 @@ func init() {
|
|||||||
CmdBeegoPro.Flag.Var(&beegopro.SQL, "sql", "sql file path")
|
CmdBeegoPro.Flag.Var(&beegopro.SQL, "sql", "sql file path")
|
||||||
CmdBeegoPro.Flag.Var(&beegopro.SQLMode, "sqlmode", "sql mode")
|
CmdBeegoPro.Flag.Var(&beegopro.SQLMode, "sqlmode", "sql mode")
|
||||||
CmdBeegoPro.Flag.Var(&beegopro.SQLModePath, "sqlpath", "sql mode path")
|
CmdBeegoPro.Flag.Var(&beegopro.SQLModePath, "sqlpath", "sql mode path")
|
||||||
|
CmdBeegoPro.Flag.Var(&beegopro.GitRemotePath, "url", "git remote path")
|
||||||
commands.AvailableCommands = append(commands.AvailableCommands, CmdBeegoPro)
|
commands.AvailableCommands = append(commands.AvailableCommands, CmdBeegoPro)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ func GetBeegoVersion() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
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", "beego", "beego"))
|
||||||
filename := path.Join(wg, "beego.go")
|
filename := path.Join(wg, "beego.go")
|
||||||
_, err := os.Stat(filename)
|
_, err := os.Stat(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -163,7 +163,7 @@ func GetBeegoVersion() string {
|
|||||||
|
|
||||||
}
|
}
|
||||||
return "Beego is not installed. Please do consider installing it first: https://github.com/beego/beego/v2. " +
|
return "Beego is not installed. Please do consider installing it first: https://github.com/beego/beego/v2. " +
|
||||||
"If you are using go mod, and you don't install the beego under $GOPATH/src/github.com/astaxie, just ignore this."
|
"If you are using go mod, and you don't install the beego under $GOPATH/src/github.com/beego, just ignore this."
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGoVersion() string {
|
func GetGoVersion() string {
|
||||||
|
@ -3,6 +3,8 @@ package beegopro
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -15,6 +17,8 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var GitRemotePath utils.DocValue
|
||||||
|
|
||||||
const MDateFormat = "20060102_150405"
|
const MDateFormat = "20060102_150405"
|
||||||
|
|
||||||
var DefaultBeegoPro = &Container{
|
var DefaultBeegoPro = &Container{
|
||||||
@ -30,9 +34,10 @@ var DefaultBeegoPro = &Container{
|
|||||||
ApiPrefix: "/api",
|
ApiPrefix: "/api",
|
||||||
EnableModule: nil,
|
EnableModule: nil,
|
||||||
Models: make(map[string]TextModel),
|
Models: make(map[string]TextModel),
|
||||||
GitRemotePath: "https://github.com/beego/beego-pro.git",
|
GitRemotePath: "",
|
||||||
|
//GitRemotePath: "https://github.com/beego/beego-pro.git",
|
||||||
Branch: "master",
|
Branch: "master",
|
||||||
GitLocalPath: system.BeegoHome + "/beego-pro",
|
//GitLocalPath: system.BeegoHome + "/beego-pro",
|
||||||
EnableFormat: true,
|
EnableFormat: true,
|
||||||
SourceGen: "text",
|
SourceGen: "text",
|
||||||
EnableGitPull: true,
|
EnableGitPull: true,
|
||||||
@ -72,7 +77,6 @@ func (c *Container) initUserOption() {
|
|||||||
beeLogger.Log.Fatalf("read beego pro config content, err: %s", err.Error())
|
beeLogger.Log.Fatalf("read beego pro config content, err: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = viper.Unmarshal(&c.UserOption)
|
err = viper.Unmarshal(&c.UserOption)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
beeLogger.Log.Fatalf("beego pro config unmarshal error, err: %s", err.Error())
|
beeLogger.Log.Fatalf("beego pro config unmarshal error, err: %s", err.Error())
|
||||||
@ -100,10 +104,10 @@ func (c *Container) initUserOption() {
|
|||||||
if c.UserOption.Debug {
|
if c.UserOption.Debug {
|
||||||
fmt.Println("c.modules", c.EnableModules)
|
fmt.Println("c.modules", c.EnableModules)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Container) initTemplateOption() {
|
func (c *Container) initTemplateOption() {
|
||||||
|
c.GetLocalPath()
|
||||||
if c.UserOption.EnableGitPull && (c.GenerateTimeUnix-c.Timestamp.GitCacheLastRefresh > c.UserOption.RefreshGitTime) {
|
if c.UserOption.EnableGitPull && (c.GenerateTimeUnix-c.Timestamp.GitCacheLastRefresh > c.UserOption.RefreshGitTime) {
|
||||||
err := git.CloneORPullRepo(c.UserOption.GitRemotePath, c.UserOption.GitLocalPath)
|
err := git.CloneORPullRepo(c.UserOption.GitRemotePath, c.UserOption.GitLocalPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -226,3 +230,25 @@ func (c *Container) InitToml() {
|
|||||||
}
|
}
|
||||||
beeLogger.Log.Success("Successfully created file beegopro.toml")
|
beeLogger.Log.Success("Successfully created file beegopro.toml")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//form https://github.com/beego/beego-pro.git
|
||||||
|
//get beego/beego-pro
|
||||||
|
func (c *Container) GetLocalPath() {
|
||||||
|
if c.UserOption.GitLocalPath != "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if GitRemotePath != "" {
|
||||||
|
c.UserOption.GitRemotePath = GitRemotePath.String()
|
||||||
|
}
|
||||||
|
if c.UserOption.GitRemotePath == "" {
|
||||||
|
c.UserOption.GitRemotePath = "https://github.com/beego/beego-pro.git"
|
||||||
|
}
|
||||||
|
parse, err := url.Parse(c.UserOption.GitRemotePath)
|
||||||
|
if err != nil {
|
||||||
|
beeLogger.Log.Fatalf("git GitRemotePath err, %s", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s := parse.Path
|
||||||
|
s = strings.TrimRight(s, ".git")
|
||||||
|
c.UserOption.GitLocalPath = system.BeegoHome + s
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user