tool to dl template
This commit is contained in:
parent
bae2641808
commit
e97cacc0e7
6 changed files with 74 additions and 10 deletions
|
|
@ -1,3 +0,0 @@
|
|||
module github.com/maddalax/mhtml/cli
|
||||
|
||||
go 1.23.0
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
package main
|
||||
|
||||
func main() {
|
||||
println("Hesssllo, ssHTML!")
|
||||
}
|
||||
|
|
@ -254,7 +254,6 @@ func writePartialsFile() {
|
|||
if partial.Import == "partials/load" {
|
||||
continue
|
||||
}
|
||||
fmt.Println(partial.Import)
|
||||
builder.AddImport(fmt.Sprintf(`%s/%s`, moduleName, partial.Import))
|
||||
}
|
||||
|
||||
|
|
@ -344,7 +343,6 @@ func GetModuleName() string {
|
|||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("Generating partials...")
|
||||
writePartialsFile()
|
||||
writePagesFile()
|
||||
}
|
||||
|
|
|
|||
59
framework/tooling/downloadtemplate/main.go
Normal file
59
framework/tooling/downloadtemplate/main.go
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func deleteAllExceptTemplate(outPath string, excludeDir string) {
|
||||
// List all files and directories in the root folder
|
||||
files, err := os.ReadDir(outPath)
|
||||
if err != nil {
|
||||
fmt.Printf("Error reading directory: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Iterate through each item in the root folder
|
||||
for _, file := range files {
|
||||
// Skip the excluded directory
|
||||
if file.Name() == excludeDir {
|
||||
fmt.Printf("Skipping directory: %s\n", file.Name())
|
||||
continue
|
||||
}
|
||||
|
||||
// Get full path
|
||||
fullPath := filepath.Join(outPath, file.Name())
|
||||
|
||||
// Remove the file or directory
|
||||
fmt.Printf("Removing: %s\n", fullPath)
|
||||
err := os.RemoveAll(fullPath)
|
||||
if err != nil {
|
||||
fmt.Printf("Error removing %s: %v\n", fullPath, err)
|
||||
} else {
|
||||
fmt.Printf("Successfully removed %s\n", fullPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
outPath := "new-app"
|
||||
excludeDir := "starter-template"
|
||||
|
||||
install := exec.Command("git", "clone", "https://github.com/maddalax/mhtml", "--depth=1", outPath)
|
||||
install.Stdout = os.Stdout
|
||||
install.Stderr = os.Stderr
|
||||
err := install.Run()
|
||||
|
||||
if err != nil {
|
||||
println("Error downloading template %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
deleteAllExceptTemplate(outPath, excludeDir)
|
||||
|
||||
//exec.Command("mv", "starter-template/*", "./ 2>/dev/null && rmdir starter-template")
|
||||
|
||||
println("Template downloaded successfully!")
|
||||
}
|
||||
|
|
@ -4,6 +4,12 @@ interval: 500ms
|
|||
|
||||
tasks:
|
||||
|
||||
template:
|
||||
dir: '{{.USER_WORKING_DIR}}'
|
||||
desc: Generate template from source code
|
||||
cmds:
|
||||
- go run github.com/maddalax/mhtml/framework/tooling/downloadtemplate
|
||||
|
||||
setup:
|
||||
deps: [copy-framework-assets, ast]
|
||||
dir: '{{.USER_WORKING_DIR}}'
|
||||
|
|
|
|||
|
|
@ -17,6 +17,15 @@ func main() {
|
|||
// Parse the command-line flags
|
||||
flag.Parse()
|
||||
|
||||
install := exec.Command("go", "install", "github.com/go-task/task/v3/cmd/task@latest")
|
||||
install.Stdout = os.Stdout
|
||||
install.Stderr = os.Stderr
|
||||
err := install.Run()
|
||||
if err != nil {
|
||||
fmt.Printf("Error installing task: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
temp, err := os.CreateTemp("", "Taskfile.yml")
|
||||
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue