mirror of
https://gitee.com/energye/energy.git
synced 2024-12-04 04:38:21 +08:00
energy-command-line, energy init . 初始化应用
This commit is contained in:
parent
0ebc5db723
commit
e3512ebc2d
@ -1,4 +1,4 @@
|
||||
# {{.}} Project
|
||||
# {{.Name}} Project
|
||||
|
||||
## 目录说明 - Directory description
|
||||
> resources
|
||||
|
@ -34,25 +34,21 @@ func InitEnergyProject(c *command.Config) error {
|
||||
if err := generaProject(c); err != nil {
|
||||
return err
|
||||
}
|
||||
generaReadme()
|
||||
println("Successfully initialized the energy application project", c.Init.Name)
|
||||
println()
|
||||
println("Run Application: go run main.go")
|
||||
println(`Building Applications:
|
||||
println("Successfully initialized the energy application project:", c.Init.Name)
|
||||
println()
|
||||
println(" Run Application: go run main.go")
|
||||
println(` Building Applications:
|
||||
Use GO: go build -ldflags "-s -w"
|
||||
Use Energy: energy build .
|
||||
`)
|
||||
println(`website:
|
||||
println(` website:
|
||||
https://github.com/energye/energy
|
||||
https://energy.yanghy.cn
|
||||
`)
|
||||
return nil
|
||||
}
|
||||
|
||||
func generaReadme() {
|
||||
|
||||
}
|
||||
|
||||
func generaProject(c *command.Config) error {
|
||||
projectPath := filepath.Join(c.Wd, c.Init.Name)
|
||||
println("Create Project:", c.Init.Name)
|
||||
@ -64,7 +60,7 @@ func generaProject(c *command.Config) error {
|
||||
if strings.ToLower(s) != "y" {
|
||||
return errors.New("Failed to initialize project " + c.Init.Name)
|
||||
} else {
|
||||
var deleteFiles = []string{"energy.json", "resources", "main.go", "go.mod", "go.sum", "resources/index.html"}
|
||||
var deleteFiles = []string{"energy.json", "resources", "main.go", "go.mod", "go.sum", "resources/index.html", "README.md"}
|
||||
for _, f := range deleteFiles {
|
||||
path := filepath.Join(projectPath, f)
|
||||
if info, err := os.Lstat(path); err == nil {
|
||||
@ -141,6 +137,22 @@ func generaProject(c *command.Config) error {
|
||||
}
|
||||
}
|
||||
|
||||
// 创建 README.md
|
||||
if readmeText, err := assets.ReadFile("assets/README.md"); err != nil {
|
||||
return err
|
||||
} else {
|
||||
data := make(map[string]any)
|
||||
data["Name"] = c.Init.Name
|
||||
if content, err := tools.RenderTemplate(string(readmeText), data); err != nil {
|
||||
return err
|
||||
} else {
|
||||
path := filepath.Join(projectPath, "README.md")
|
||||
if err = ioutil.WriteFile(path, content, 0666); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cmd
|
||||
println("cmd run")
|
||||
cmd := toolsCommand.NewCMD()
|
||||
|
Loading…
Reference in New Issue
Block a user