|
|
|
@ -55,10 +55,9 @@ func main() { |
|
|
|
|
if err != nil { |
|
|
|
|
panic(err) |
|
|
|
|
} |
|
|
|
|
os.MkdirAll("../internal/repositories", os.ModePerm) |
|
|
|
|
_ = os.MkdirAll("../internal/repositories", os.ModePerm) |
|
|
|
|
var camels []string |
|
|
|
|
var pascals []string |
|
|
|
|
var iocStr string |
|
|
|
|
var createdCount int |
|
|
|
|
for _, dir := range dirs { |
|
|
|
|
name := dir.Name() |
|
|
|
@ -79,7 +78,6 @@ func main() { |
|
|
|
|
fmt.Println("跳过 " + dir.Name()) |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
iocStr += "\tioc.MustSingleton(New" + pascal + "Repository)\n" |
|
|
|
|
repository := "../internal/repositories/" + dir.Name() |
|
|
|
|
if PathExists(repository) { |
|
|
|
|
fmt.Println("跳过 " + dir.Name()) |
|
|
|
@ -87,21 +85,11 @@ func main() { |
|
|
|
|
code := strings.ReplaceAll(repoStub, "{{pascal}}", pascal) |
|
|
|
|
code = strings.ReplaceAll(code, "{{camel}}", camel) |
|
|
|
|
code = strings.ReplaceAll(code, "{{label}}", label) |
|
|
|
|
os.WriteFile("../internal/repositories/"+dir.Name(), []byte(code), os.ModePerm) |
|
|
|
|
_ = os.WriteFile("../internal/repositories/"+dir.Name(), []byte(code), os.ModePerm) |
|
|
|
|
fmt.Println("创建 " + dir.Name()) |
|
|
|
|
createdCount++ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if createdCount > 0 { |
|
|
|
|
os.WriteFile("../internal/repositories/ioc.go", []byte(`package repositories |
|
|
|
|
|
|
|
|
|
import "sorbet/pkg/ioc" |
|
|
|
|
|
|
|
|
|
func init() { |
|
|
|
|
`+iocStr+`} |
|
|
|
|
`), os.ModePerm) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func PathExists(path string) bool { |
|
|
|
|