feat(cmd/gf): project template updates for command gf init (#3928)

This commit is contained in:
John Guo
2024-11-17 10:57:17 +08:00
committed by GitHub
parent bcfcda793c
commit ec6c537def
10 changed files with 17 additions and 17 deletions

View File

@ -89,7 +89,7 @@ func (c *controllerGenerator) doGenerateCtrlNewByModuleAndVersion(
if err = gfile.PutContents(moduleFilePath, gstr.TrimLeft(content)); err != nil { if err = gfile.PutContents(moduleFilePath, gstr.TrimLeft(content)); err != nil {
return err return err
} }
mlog.Printf(`generated: %s`, moduleFilePath) mlog.Printf(`generated: %s`, gfile.RealPath(moduleFilePath))
} }
if !gfile.Exists(moduleFilePathNew) { if !gfile.Exists(moduleFilePathNew) {
content := gstr.ReplaceByMap(consts.TemplateGenCtrlControllerNewEmpty, g.MapStrStr{ content := gstr.ReplaceByMap(consts.TemplateGenCtrlControllerNewEmpty, g.MapStrStr{
@ -99,7 +99,7 @@ func (c *controllerGenerator) doGenerateCtrlNewByModuleAndVersion(
if err = gfile.PutContents(moduleFilePathNew, gstr.TrimLeft(content)); err != nil { if err = gfile.PutContents(moduleFilePathNew, gstr.TrimLeft(content)); err != nil {
return err return err
} }
mlog.Printf(`generated: %s`, moduleFilePathNew) mlog.Printf(`generated: %s`, gfile.RealPath(moduleFilePathNew))
} }
filePaths, err := gfile.ScanDir(dstModuleFolderPath, "*.go", false) filePaths, err := gfile.ScanDir(dstModuleFolderPath, "*.go", false)
if err != nil { if err != nil {
@ -161,7 +161,7 @@ func (c *controllerGenerator) doGenerateCtrlItem(dstModuleFolderPath string, ite
return err return err
} }
} }
mlog.Printf(`generated: %s`, methodFilePath) mlog.Printf(`generated: %s`, gfile.RealPath(methodFilePath))
return return
} }
@ -221,7 +221,7 @@ func (c *controllerGenerator) doGenerateCtrlMergeItem(dstModuleFolderPath string
if err = gfile.PutContentsAppend(ctrlFilePath, ctrlFileItem.controllers.String()); err != nil { if err = gfile.PutContentsAppend(ctrlFilePath, ctrlFileItem.controllers.String()); err != nil {
return err return err
} }
mlog.Printf(`generated: %s`, ctrlFilePath) mlog.Printf(`generated: %s`, gfile.RealPath(ctrlFilePath))
} }
return return
} }

View File

@ -94,7 +94,7 @@ func (c *apiInterfaceGenerator) doGenerate(apiModuleFolderPath string, module st
"{Interfaces}": gstr.TrimRightStr(interfaceDefinition, "\n", 2), "{Interfaces}": gstr.TrimRightStr(interfaceDefinition, "\n", 2),
})) }))
err = gfile.PutContents(moduleFilePath, interfaceContent) err = gfile.PutContents(moduleFilePath, interfaceContent)
mlog.Printf(`generated: %s`, moduleFilePath) mlog.Printf(`generated: %s`, gfile.RealPath(moduleFilePath))
return return
} }

View File

@ -65,7 +65,7 @@ func (c *apiSdkGenerator) doGenerateSdkPkgFile(sdkFolderPath string) (err error)
"{PkgName}": pkgName, "{PkgName}": pkgName,
})) }))
err = gfile.PutContents(pkgFilePath, fileContent) err = gfile.PutContents(pkgFilePath, fileContent)
mlog.Printf(`generated: %s`, pkgFilePath) mlog.Printf(`generated: %s`, gfile.RealPath(pkgFilePath))
return return
} }
@ -130,9 +130,9 @@ func (c *apiSdkGenerator) doGenerateSdkIClient(
if isDirty { if isDirty {
err = gfile.PutContents(iClientFilePath, fileContent) err = gfile.PutContents(iClientFilePath, fileContent)
if isExist { if isExist {
mlog.Printf(`updated: %s`, iClientFilePath) mlog.Printf(`updated: %s`, gfile.RealPath(iClientFilePath))
} else { } else {
mlog.Printf(`generated: %s`, iClientFilePath) mlog.Printf(`generated: %s`, gfile.RealPath(iClientFilePath))
} }
} }
return return
@ -183,7 +183,7 @@ func (c *apiSdkGenerator) doGenerateSdkImplementer(
implementerFileContent += "\n" implementerFileContent += "\n"
} }
err = gfile.PutContents(implementerFilePath, implementerFileContent) err = gfile.PutContents(implementerFilePath, implementerFileContent)
mlog.Printf(`generated: %s`, implementerFilePath) mlog.Printf(`generated: %s`, gfile.RealPath(implementerFilePath))
return return
} }

View File

@ -123,7 +123,7 @@ func generateDaoIndex(in generateDaoIndexInput) {
mlog.Fatalf("writing content to '%s' failed: %v", path, err) mlog.Fatalf("writing content to '%s' failed: %v", path, err)
} else { } else {
utils.GoFmt(path) utils.GoFmt(path)
mlog.Print("generated:", path) mlog.Print("generated:", gfile.RealPath(path))
} }
} }
} }
@ -157,7 +157,7 @@ func generateDaoInternal(in generateDaoInternalInput) {
mlog.Fatalf("writing content to '%s' failed: %v", path, err) mlog.Fatalf("writing content to '%s' failed: %v", path, err)
} else { } else {
utils.GoFmt(path) utils.GoFmt(path)
mlog.Print("generated:", path) mlog.Print("generated:", gfile.RealPath(path))
} }
} }

View File

@ -70,7 +70,7 @@ func generateDo(ctx context.Context, in CGenDaoInternalInput) {
mlog.Fatalf(`writing content to "%s" failed: %v`, doFilePath, err) mlog.Fatalf(`writing content to "%s" failed: %v`, doFilePath, err)
} else { } else {
utils.GoFmt(doFilePath) utils.GoFmt(doFilePath)
mlog.Print("generated:", doFilePath) mlog.Print("generated:", gfile.RealPath(doFilePath))
} }
} }
} }

View File

@ -55,7 +55,7 @@ func generateEntity(ctx context.Context, in CGenDaoInternalInput) {
mlog.Fatalf("writing content to '%s' failed: %v", entityFilePath, err) mlog.Fatalf("writing content to '%s' failed: %v", entityFilePath, err)
} else { } else {
utils.GoFmt(entityFilePath) utils.GoFmt(entityFilePath)
mlog.Print("generated:", entityFilePath) mlog.Print("generated:", gfile.RealPath(entityFilePath))
} }
} }
} }

View File

@ -254,7 +254,7 @@ func generatePbEntityContentFile(ctx context.Context, in CGenPbEntityInternalInp
if err := gfile.PutContents(path, strings.TrimSpace(entityContent)); err != nil { if err := gfile.PutContents(path, strings.TrimSpace(entityContent)); err != nil {
mlog.Fatalf("writing content to '%s' failed: %v", path, err) mlog.Fatalf("writing content to '%s' failed: %v", path, err)
} else { } else {
mlog.Print("generated:", path) mlog.Print("generated:", gfile.RealPath(path))
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long