mirror of
https://github.com/beego/bee.git
synced 2024-11-25 15:00:55 +00:00
get template from git when run 'bee pro toml' if template dose not exit
This commit is contained in:
parent
8f0badc630
commit
81ed06ea01
@ -67,6 +67,9 @@ func (c *Container) InitToml() {
|
|||||||
beeLogger.Log.Fatalf("file beegopro.toml already exists")
|
beeLogger.Log.Fatalf("file beegopro.toml already exists")
|
||||||
}
|
}
|
||||||
sourceFile := c.UserOption.GitLocalPath + "/beegopro.toml"
|
sourceFile := c.UserOption.GitLocalPath + "/beegopro.toml"
|
||||||
|
if !utils.IsExist(c.UserOption.GitLocalPath) {
|
||||||
|
c.getTemplateFromGit()
|
||||||
|
}
|
||||||
input, err := ioutil.ReadFile(sourceFile)
|
input, err := ioutil.ReadFile(sourceFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
beeLogger.Log.Fatalf("read beegopro.toml file err, %s", err.Error())
|
beeLogger.Log.Fatalf("read beegopro.toml file err, %s", err.Error())
|
||||||
@ -80,6 +83,14 @@ func (c *Container) InitToml() {
|
|||||||
beeLogger.Log.Success("Successfully created file beegopro.toml")
|
beeLogger.Log.Success("Successfully created file beegopro.toml")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Container) getTemplateFromGit() {
|
||||||
|
err := git.CloneORPullRepo(c.UserOption.GitRemotePath, c.UserOption.GitLocalPath)
|
||||||
|
if err != nil {
|
||||||
|
beeLogger.Log.Fatalf("beego pro git clone or pull repo error, err: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Timestamp.GitCacheLastRefresh = c.GenerateTimeUnix
|
||||||
|
}
|
||||||
func (c *Container) initUserOption() {
|
func (c *Container) initUserOption() {
|
||||||
if !utils.IsExist(c.BeegoProFile) {
|
if !utils.IsExist(c.BeegoProFile) {
|
||||||
beeLogger.Log.Fatalf("beego pro config is not exist, beego json path: %s", c.BeegoProFile)
|
beeLogger.Log.Fatalf("beego pro config is not exist, beego json path: %s", c.BeegoProFile)
|
||||||
@ -124,12 +135,7 @@ func (c *Container) initUserOption() {
|
|||||||
|
|
||||||
func (c *Container) initTemplateOption() {
|
func (c *Container) initTemplateOption() {
|
||||||
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)
|
c.getTemplateFromGit()
|
||||||
if err != nil {
|
|
||||||
beeLogger.Log.Fatalf("beego pro git clone or pull repo error, err: %s", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.Timestamp.GitCacheLastRefresh = c.GenerateTimeUnix
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tree, err := toml.LoadFile(c.UserOption.GitLocalPath + "/" + c.UserOption.ProType + "/bee.toml")
|
tree, err := toml.LoadFile(c.UserOption.GitLocalPath + "/" + c.UserOption.ProType + "/bee.toml")
|
||||||
|
Loading…
Reference in New Issue
Block a user