Skip to content

Commit ad8d4f4

Browse files
committed
Add support Nuxt 3 frontend template; Refactoring
1 parent 9d6b906 commit ad8d4f4

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</h1>
55
<p align="center">Create a new production-ready project with <b>backend</b> (Golang), <b>frontend</b> (JavaScript, TypeScript)<br/>and <b>deploy automation</b> (Ansible, Docker) by running one CLI command.<br/><br/>Focus on <b>writing</b> code and <b>thinking</b> of business-logic! The CLI will take care of the rest.</p>
66

7-
<p align="center"><a href="https://pkg.go.dev/github.com/create-go-app/cli/v3?tab=doc" target="_blank"><img src="https://img.shields.io/badge/Go-1.17+-00ADD8?style=for-the-badge&logo=go" alt="go version" /></a>&nbsp;<a href="https://gocover.io/github.com/create-go-app/cli/pkg/cgapp" target="_blank"><img src="https://img.shields.io/badge/Go_Cover-89.2%25-success?style=for-the-badge&logo=none" alt="go cover" /></a>&nbsp;<a href="https://goreportcard.com/report/github.com/create-go-app/cli" target="_blank"><img src="https://img.shields.io/badge/Go_report-A+-success?style=for-the-badge&logo=none" alt="go report" /></a>&nbsp;<img src="https://img.shields.io/badge/license-apache_2.0-red?style=for-the-badge&logo=none" alt="license" /></p>
7+
<p align="center"><a href="https://pkg.go.dev/github.com/create-go-app/cli/v3?tab=doc" target="_blank"><img src="https://img.shields.io/badge/Go-1.17+-00ADD8?style=for-the-badge&logo=go" alt="go version" /></a>&nbsp;<a href="https://gocover.io/github.com/create-go-app/cli/pkg/cgapp" target="_blank"><img src="https://img.shields.io/badge/Go_Cover-88.4%25-success?style=for-the-badge&logo=none" alt="go cover" /></a>&nbsp;<a href="https://goreportcard.com/report/github.com/create-go-app/cli" target="_blank"><img src="https://img.shields.io/badge/Go_report-A+-success?style=for-the-badge&logo=none" alt="go report" /></a>&nbsp;<img src="https://img.shields.io/badge/license-apache_2.0-red?style=for-the-badge&logo=none" alt="license" /></p>
88

99
## ⚡️ Quick start
1010

@@ -117,6 +117,11 @@ cgapp deploy [OPTION]
117117
- Frontend template with [Preact](https://preactjs.com/):
118118
- `preact` — generated template with a common Preact app.
119119
- `preact-ts` — generated template with a TypeScript version of the Preact app.
120+
- Frontend template with [Next.js](https://nextjs.org/):
121+
- `next` — generated template with a common Next.js app.
122+
- `next-ts` — generated template with a TypeScript version of the Next.js app.
123+
- Frontend template with [Nuxt 3](https://v3.nuxtjs.org/):
124+
- `nuxt3` — generated template with a common Nuxt 3 app.
120125
- Frontend template with [Vue.js](https://vuejs.org/):
121126
- `vue` — generated template with a common Vue.js app.
122127
- `vue-ts` — generated template with a TypeScript version of the Vue.js app.
@@ -127,7 +132,7 @@ cgapp deploy [OPTION]
127132
- `lit-element` — generated template with a common Lit app.
128133
- `lit-element-ts` — generated template a TypeScript version of the Lit app.
129134

130-
> ☝️ Frontend part will be generate using awesome tool [Vite.js](https://vitejs.dev/) under the hood. So, you'll always get the latest version of `React`, `Preact`, `Vue`, `Svelte`, `Lit` or pure JavaScript/TypeScript templates for your project!
135+
> ☝️ Frontend part will be generate using awesome tool [Vite.js](https://vitejs.dev/) under the hood. So, you'll always get the latest version of `React`, `Preact`, `Vue`, `Svelte`, `Lit` or pure JavaScript/TypeScript templates for your project! And the `Next.js` and `Nuxt 3` frontend parts will be generated using the `create-next-app` and `nuxi` utilities.
131136
>
132137
> Please make sure that you have `npm` version `7` or higher installed to create the frontend part of the project correctly. If you run the `cgapp create` command using our [Docker image](https://hub.docker.com/r/koddr/cgapp), `npm` of the correct version is **already** included.
133138

cmd/create.go

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -111,36 +111,30 @@ func runCreateCmd(cmd *cobra.Command, args []string) error {
111111
return cgapp.ShowError(err.Error())
112112
}
113113
} else {
114-
115-
if frontend == "next" || frontend == "next-ts" {
116-
cgapp.ShowMessage(
117-
"success",
118-
"Creating frontend with Next.js!",
119-
true, false,
120-
)
114+
switch {
115+
case frontend == "next" || frontend == "next-ts":
116+
var isTypeScript string
121117
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-
}
118+
isTypeScript = "--typescript"
137119
}
138-
139-
} else { // Create a default frontend template from Vite.js.
120+
121+
// Create a default frontend template with Next.js (React).
122+
if err := cgapp.ExecCommand(
123+
"npx", []string{"create-next-app@latest", "frontend", isTypeScript}, true,
124+
); err != nil {
125+
return err
126+
}
127+
case frontend == "nuxt3":
128+
// Create a default frontend template with Nuxt 3 (Vue.js 3, TypeScript).
129+
if err := cgapp.ExecCommand(
130+
"npx", []string{"nuxi", "init", "frontend"}, true,
131+
); err != nil {
132+
return err
133+
}
134+
default:
135+
// Create a default frontend template from Vite (Pure JS/TS, React, Preact, Vue, Svelte, Lit).
140136
if err := cgapp.ExecCommand(
141-
"npm",
142-
[]string{"init", "vite@latest", "frontend", "--", "--template", frontend},
143-
true,
137+
"npm", []string{"init", "vite@latest", "frontend", "--", "--template", frontend}, true,
144138
); err != nil {
145139
return err
146140
}

pkg/registry/defaults.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
// CLIVersion version of Create Go App CLI.
14-
const CLIVersion string = "3.4.0"
14+
const CLIVersion string = "3.5.0"
1515

1616
// Variables struct for Ansible variables (inventory, hosts).
1717
type Variables struct {
@@ -70,6 +70,7 @@ var (
7070
"preact-ts",
7171
"next",
7272
"next-ts",
73+
"nuxt3",
7374
"vue",
7475
"vue-ts",
7576
"svelte",
@@ -78,7 +79,7 @@ var (
7879
"lit-element-ts",
7980
},
8081
Default: "none",
81-
PageSize: 13,
82+
PageSize: 16,
8283
},
8384
},
8485
{

0 commit comments

Comments
 (0)