Skip to content

Commit 570a4a0

Browse files
committed
Add next js support templates
1 parent 2b299ed commit 570a4a0

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

cmd/create.go

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,39 @@ func runCreateCmd(cmd *cobra.Command, args []string) error {
111111
return cgapp.ShowError(err.Error())
112112
}
113113
} else {
114-
// Create a default frontend template from Vite.js.
115-
if err := cgapp.ExecCommand(
116-
"npm",
117-
[]string{"init", "vite@latest", "frontend", "--", "--template", frontend},
118-
true,
119-
); err != nil {
120-
return err
114+
115+
if frontend == "next" || frontend == "next-ts" {
116+
cgapp.ShowMessage(
117+
"success",
118+
fmt.Sprintf("Creating frontend with Next.js!"),
119+
true, false,
120+
)
121+
if frontend == "next-ts" {
122+
if err := cgapp.ExecCommand(
123+
"npx",
124+
[]string{"create-next-app@latest", "frontend", "--typescript"},
125+
true,
126+
); err != nil {
127+
return err
128+
}
129+
} else {
130+
if err := cgapp.ExecCommand(
131+
"npx",
132+
[]string{"create-next-app@latest", "frontend"},
133+
true,
134+
); err != nil {
135+
return err
136+
}
137+
}
138+
139+
} else { // Create a default frontend template from Vite.js.
140+
if err := cgapp.ExecCommand(
141+
"npm",
142+
[]string{"init", "vite@latest", "frontend", "--", "--template", frontend},
143+
true,
144+
); err != nil {
145+
return err
146+
}
121147
}
122148
}
123149

pkg/registry/defaults.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ var (
6868
"react-ts",
6969
"preact",
7070
"preact-ts",
71+
"next",
72+
"next-ts",
7173
"vue",
7274
"vue-ts",
7375
"svelte",

0 commit comments

Comments
 (0)