Skip to content

Commit

Permalink
Add support Nuxt 3 frontend template; Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
koddr committed Jan 23, 2022
1 parent 9d6b906 commit ad8d4f4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</h1>
<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>

<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>
<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>

## ⚡️ Quick start

Expand Down Expand Up @@ -117,6 +117,11 @@ cgapp deploy [OPTION]
- Frontend template with [Preact](https://preactjs.com/):
- `preact` — generated template with a common Preact app.
- `preact-ts` — generated template with a TypeScript version of the Preact app.
- Frontend template with [Next.js](https://nextjs.org/):
- `next` — generated template with a common Next.js app.
- `next-ts` — generated template with a TypeScript version of the Next.js app.
- Frontend template with [Nuxt 3](https://v3.nuxtjs.org/):
- `nuxt3` — generated template with a common Nuxt 3 app.
- Frontend template with [Vue.js](https://vuejs.org/):
- `vue` — generated template with a common Vue.js app.
- `vue-ts` — generated template with a TypeScript version of the Vue.js app.
Expand All @@ -127,7 +132,7 @@ cgapp deploy [OPTION]
- `lit-element` — generated template with a common Lit app.
- `lit-element-ts` — generated template a TypeScript version of the Lit app.

> ☝️ 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!
> ☝️ 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.
>
> 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.
Expand Down
48 changes: 21 additions & 27 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,36 +111,30 @@ func runCreateCmd(cmd *cobra.Command, args []string) error {
return cgapp.ShowError(err.Error())
}
} else {

if frontend == "next" || frontend == "next-ts" {
cgapp.ShowMessage(
"success",
"Creating frontend with Next.js!",
true, false,
)
switch {
case frontend == "next" || frontend == "next-ts":
var isTypeScript string
if frontend == "next-ts" {
if err := cgapp.ExecCommand(
"npx",
[]string{"create-next-app@latest", "frontend", "--typescript"},
true,
); err != nil {
return err
}
} else {
if err := cgapp.ExecCommand(
"npx",
[]string{"create-next-app@latest", "frontend"},
true,
); err != nil {
return err
}
isTypeScript = "--typescript"
}

} else { // Create a default frontend template from Vite.js.

// Create a default frontend template with Next.js (React).
if err := cgapp.ExecCommand(
"npx", []string{"create-next-app@latest", "frontend", isTypeScript}, true,
); err != nil {
return err
}
case frontend == "nuxt3":
// Create a default frontend template with Nuxt 3 (Vue.js 3, TypeScript).
if err := cgapp.ExecCommand(
"npx", []string{"nuxi", "init", "frontend"}, true,
); err != nil {
return err
}
default:
// Create a default frontend template from Vite (Pure JS/TS, React, Preact, Vue, Svelte, Lit).
if err := cgapp.ExecCommand(
"npm",
[]string{"init", "vite@latest", "frontend", "--", "--template", frontend},
true,
"npm", []string{"init", "vite@latest", "frontend", "--", "--template", frontend}, true,
); err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/registry/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// CLIVersion version of Create Go App CLI.
const CLIVersion string = "3.4.0"
const CLIVersion string = "3.5.0"

// Variables struct for Ansible variables (inventory, hosts).
type Variables struct {
Expand Down Expand Up @@ -70,6 +70,7 @@ var (
"preact-ts",
"next",
"next-ts",
"nuxt3",
"vue",
"vue-ts",
"svelte",
Expand All @@ -78,7 +79,7 @@ var (
"lit-element-ts",
},
Default: "none",
PageSize: 13,
PageSize: 16,
},
},
{
Expand Down

0 comments on commit ad8d4f4

Please sign in to comment.