mirror of
https://github.com/beego/bee.git
synced 2024-11-22 05:00:54 +00:00
commit
13a81b8140
@ -28,25 +28,26 @@ var DefaultBeegoPro = &Container{
|
||||
ProType: "default",
|
||||
ApiPrefix: "/api",
|
||||
EnableModule: nil,
|
||||
Models: make(map[string]TextModel, 0),
|
||||
Models: make(map[string]TextModel),
|
||||
GitRemotePath: "https://github.com/beego/beego-pro.git",
|
||||
Branch: "master",
|
||||
GitLocalPath: system.BeegoHome + "/beego-pro",
|
||||
EnableFormat: true,
|
||||
SourceGen: "text",
|
||||
EnableGitPull: true,
|
||||
RefreshGitTime: 24 * 3600,
|
||||
Path: map[string]string{
|
||||
"beego": ".",
|
||||
},
|
||||
EnableGomod: true,
|
||||
RefreshGitTime: 24 * 3600,
|
||||
Extend: nil,
|
||||
},
|
||||
GenerateTime: time.Now().Format(MDateFormat),
|
||||
GenerateTimeUnix: time.Now().Unix(),
|
||||
TmplOption: TmplOption{},
|
||||
CurPath: system.CurrentDir,
|
||||
EnableModules: make(map[string]interface{}, 0), // get the user configuration, get the enable module result
|
||||
FunctionOnce: make(map[string]sync.Once, 0), // get the tmpl configuration, get the function once result
|
||||
EnableModules: make(map[string]interface{}), // get the user configuration, get the enable module result
|
||||
FunctionOnce: make(map[string]sync.Once), // get the tmpl configuration, get the function once result
|
||||
}
|
||||
|
||||
func (c *Container) Run() {
|
||||
@ -128,7 +129,7 @@ func (c *Container) initTemplateOption() {
|
||||
}
|
||||
|
||||
for _, value := range c.TmplOption.Descriptor {
|
||||
if value.Once == true {
|
||||
if value.Once {
|
||||
c.FunctionOnce[value.SrcName] = sync.Once{}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
type MysqlParser struct {
|
||||
userOption UserOption
|
||||
tmplOption TmplOption
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func (m *MysqlParser) RegisterOption(userOption UserOption, tmplOption TmplOption) {
|
||||
|
@ -49,9 +49,9 @@ func pongo2CamelString(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *p
|
||||
return pongo2.AsValue(utils.CamelString(t)), nil
|
||||
}
|
||||
|
||||
func upperFirst(str string) string {
|
||||
return strings.Replace(str, string(str[0]), strings.ToUpper(string(str[0])), 1)
|
||||
}
|
||||
//func upperFirst(str string) string {
|
||||
// return strings.Replace(str, string(str[0]), strings.ToUpper(string(str[0])), 1)
|
||||
//}
|
||||
|
||||
func lowerFirst(str string) string {
|
||||
return strings.Replace(str, string(str[0]), strings.ToLower(string(str[0])), 1)
|
||||
|
@ -34,7 +34,7 @@ func NewRender(m RenderInfo) *RenderFile {
|
||||
newDescriptor, pathCtx = m.Descriptor.Parse(m.ModelName, m.Option.Path)
|
||||
|
||||
obj := &RenderFile{
|
||||
Context: make(pongo2.Context, 0),
|
||||
Context: make(pongo2.Context),
|
||||
Option: m.Option,
|
||||
ModelName: m.ModelName,
|
||||
GenerateTime: m.GenerateTime,
|
||||
@ -61,7 +61,7 @@ func NewRender(m RenderInfo) *RenderFile {
|
||||
|
||||
modelSchemas := m.Content.ToModelSchemas()
|
||||
camelPrimaryKey := modelSchemas.GetPrimaryKey()
|
||||
importMaps := make(map[string]struct{}, 0)
|
||||
importMaps := make(map[string]struct{})
|
||||
if modelSchemas.IsExistTime() {
|
||||
importMaps["time"] = struct{}{}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func (descriptor Descriptor) Parse(modelName string, paths map[string]string) (n
|
||||
|
||||
newDescriptor = descriptor
|
||||
render := pongo2render.NewRender("")
|
||||
ctx = make(pongo2.Context, 0)
|
||||
ctx = make(pongo2.Context)
|
||||
for key, value := range paths {
|
||||
absFile, err = filepath.Abs(value)
|
||||
if err != nil {
|
||||
@ -110,10 +110,7 @@ func (descriptor Descriptor) Parse(modelName string, paths map[string]string) (n
|
||||
}
|
||||
|
||||
func (descriptor Descriptor) IsExistScript() bool {
|
||||
if descriptor.Script != "" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return descriptor.Script != ""
|
||||
}
|
||||
|
||||
func (d Descriptor) ExecScript(path string) (err error) {
|
||||
|
@ -46,7 +46,12 @@ func (c *RenderFile) write(filename string, buf string) (err error) {
|
||||
}
|
||||
|
||||
file, err := os.Create(filename)
|
||||
defer file.Close()
|
||||
defer func() {
|
||||
err = file.Close()
|
||||
if err != nil {
|
||||
beeLogger.Log.Fatalf("file close error, err %s", err)
|
||||
}
|
||||
}()
|
||||
if err != nil {
|
||||
err = errors.New("write create file " + err.Error())
|
||||
return
|
||||
|
@ -206,19 +206,3 @@ func concatenateError(err error, stderr string) error {
|
||||
}
|
||||
return fmt.Errorf("%v: %s", err, stderr)
|
||||
}
|
||||
|
||||
// getGitProjectName 获取项目名称
|
||||
func getGitProjectName(url string) (name string, err error) {
|
||||
if !strings.Contains(url, ".git") {
|
||||
return "", errors.New("Project address does not contain .git")
|
||||
}
|
||||
fileSlice := strings.Split(url, "/")
|
||||
projectName := fileSlice[len(fileSlice)-1]
|
||||
if projectName == "" {
|
||||
return "", errors.New("Project name does not exist")
|
||||
}
|
||||
|
||||
nameSlice := strings.Split(projectName, ".git")
|
||||
|
||||
return nameSlice[0], nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user