Skip to content

Commit add27d1

Browse files
committed
refactor: different runtime support
1 parent 7afe68b commit add27d1

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

main.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ func main() {
5252

5353
heading := GetFirstHeading(string(readme))
5454

55-
Choices = append(Choices, heading)
55+
Choices = append(Choices, Template{
56+
Name: heading,
57+
Path: f.Name(),
58+
})
59+
5660
}
5761

5862
choiceModel := ChoiceModel()
5963

60-
if m, ok := choiceModel.(OptionStruct); ok && m.choice != "" {
61-
Copy(m.choice, project)
64+
if m, ok := choiceModel.(OptionStruct); ok && m.choice.Path != "" {
65+
Copy(m.choice.Path, project)
6266
}
6367
}

options.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ import (
88
tea "github.com/charmbracelet/bubbletea"
99
)
1010

11-
var Choices = []string{}
11+
type Template struct {
12+
Name string
13+
Path string
14+
}
15+
16+
var Choices = []Template{}
1217

1318
type OptionStruct struct {
1419
cursor int
15-
choice string
20+
choice Template
1621
}
1722

1823
func (m OptionStruct) Init() tea.Cmd {
@@ -57,7 +62,7 @@ func (m OptionStruct) View() string {
5762
} else {
5863
s.WriteString("[ ] ")
5964
}
60-
s.WriteString(Choices[i])
65+
s.WriteString(Choices[i].Name)
6166
s.WriteString("\n")
6267
}
6368

util.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,12 @@ func PkgInstallCommand(manager string) string {
9191
func Copy(dir, project string) {
9292
os.Rename(".disploy/create-disploy-app-main/assets/"+dir, project)
9393

94+
if strings.Contains(project, "framework") {
95+
WriteToJson(project+"/disploy.json", "name", project)
96+
}
97+
9498
if !strings.Contains(project, "deno") {
9599
WriteToJson(project+"/package.json", "name", project)
96-
WriteToJson(project+"/disploy.json", "name", project)
97100

98101
m, ok := PackageManagerChoiceModel().(PackageManagerOptionStruct)
99102

0 commit comments

Comments
 (0)