mirror of
				https://github.com/beego/bee.git
				synced 2025-11-03 23:03:27 +00:00 
			
		
		
		
	get template from git when run 'bee pro toml' if template dose not exit
This commit is contained in:
		@@ -67,6 +67,9 @@ func (c *Container) InitToml() {
 | 
			
		||||
		beeLogger.Log.Fatalf("file beegopro.toml already exists")
 | 
			
		||||
	}
 | 
			
		||||
	sourceFile := c.UserOption.GitLocalPath + "/beegopro.toml"
 | 
			
		||||
	if !utils.IsExist(c.UserOption.GitLocalPath) {
 | 
			
		||||
		c.getTemplateFromGit()
 | 
			
		||||
	}
 | 
			
		||||
	input, err := ioutil.ReadFile(sourceFile)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		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")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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() {
 | 
			
		||||
	if !utils.IsExist(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() {
 | 
			
		||||
	if c.UserOption.EnableGitPull && (c.GenerateTimeUnix-c.Timestamp.GitCacheLastRefresh > c.UserOption.RefreshGitTime) {
 | 
			
		||||
		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
 | 
			
		||||
		c.getTemplateFromGit()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	tree, err := toml.LoadFile(c.UserOption.GitLocalPath + "/" + c.UserOption.ProType + "/bee.toml")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user