Skip to content

Commit d289aa3

Browse files
author
Vic Shóstak
committed
Fix frontend part bug; Add a new Vite.js templates to list
1 parent 5896c1f commit d289aa3

File tree

2 files changed

+76
-48
lines changed

2 files changed

+76
-48
lines changed

README.md

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -137,40 +137,36 @@ cgapp deploy [OPTION]
137137

138138
### Frontend
139139

140-
- Pure JavaScript frontend template:
141-
- `vanilla` — generated template with pure JavaScript app.
142-
- `vanilla-ts` — generated template with pure TypeScript app.
143-
- Frontend template with [React][react_url]:
144-
- `react` — generated template with a common React app.
145-
- `react-ts` — generated template with a TypeScript version of the React app.
146-
- Frontend template with [Preact][preact_url]:
147-
- `preact` — generated template with a common Preact app.
148-
- `preact-ts` — generated template with a TypeScript version of the Preact app.
149-
- Frontend template with [Next.js][nextjs_url]:
150-
- `next` — generated template with a common Next.js app.
151-
- `next-ts` — generated template with a TypeScript version of the Next.js app.
152-
- Frontend template with [Nuxt 3][nuxt3_url]:
153-
- `nuxt3` — generated template with a common Nuxt 3 app.
154-
- Frontend template with [Vue.js][vuejs_url]:
155-
- `vue` — generated template with a common Vue.js app.
156-
- `vue-ts` — generated template with a TypeScript version of the Vue.js app.
157-
- Frontend template with [Svelte][svelte_url]:
158-
- `svelte` — generated template with a common Svelte app.
159-
- `svelte-ts` — generated template with a TypeScript version of the Svelte app.
160-
- Frontend template with [Lit][lit_url] web components:
161-
- `lit` — generated template with a common Lit app.
162-
- `lit-ts` — generated template a TypeScript version of the Lit app.
163-
164-
> ☝️ Frontend part will be generated using awesome tool [Vite.js][vitejs_url]
165-
> under the hood. So, you'll always get the latest version of `React`,
166-
> `Preact`, `Vue`, `Svelte`, `Lit` or pure JavaScript/TypeScript templates
167-
> for your project! And the `Next.js` and `Nuxt 3` frontend parts will be
168-
> generated using the `create-next-app` and `nuxi` utilities.
169-
>
170-
> Please make sure that you have `npm` version `7` or higher installed to
171-
> create the frontend part of the project correctly. If you run the `cgapp
172-
> create` command using our [Docker image][docker_url], `npm` of the correct
173-
> version is **already** included.
140+
Frontend part will be generated using awesome tool [Vite.js][vitejs_url]
141+
under the hood.
142+
143+
So, you'll always get the latest version of React, Preact, Vue, Svelte,
144+
Solid, Lit, Qwik, or pure JavaScript/TypeScript templates for your project.
145+
146+
| Name | Description | JavaScript | Typescript |
147+
|-----------------------------------|----------------------------------|-------------|----------------|
148+
| Pure | A pure JavaScript/Typescript app | `vanilla` | `vanilla-ts` |
149+
| [React][react_url] | A common React app | `react` | `react-ts` |
150+
| [React (with SWC)][react_swc_url] | A React app with SWC | `react-swc` | `react-swc-ts` |
151+
| [Preact][preact_url] | A common Preact app | `preact` | `preact-ts` |
152+
| [Vue.js][vuejs_url] | A common Vue.js app | `vue` | `vue-ts` |
153+
| [Svelte][svelte_url] | A common Svelte app | `svelte` | `svelte-ts` |
154+
| [Solid][solid_url] | A common Solid app | `solid` | `solid-ts` |
155+
| [Lit][lit_url] | A common Lit app | `lit` | `lit-ts` |
156+
| [Qwik][qwik_url] | A common Qwik app | `qwik` | `qwik-ts` |
157+
158+
The `Next.js` and `Nuxt` frontend parts will be generated using the latest
159+
`create-next-app` and `nuxi` utilities.
160+
161+
| Name | Description | JavaScript | Typescript |
162+
|----------------------------------------------------|---------------------------------|-----------------|--------------------|
163+
| [Next.js][nextjs_url] | A common Next.js app | `next` | `next-ts` |
164+
| [Nuxt][nuxt_url] | A common Nuxt v3 app | - | `nuxt` |
165+
166+
> ❗️ Please make sure that you have `npm` version `7` or higher installed to
167+
> create the frontend part of the project correctly. If you run the
168+
> `cgapp -create` command using our [Docker image][docker_url], `npm` of the
169+
> correct version is **already** included.
174170
175171
## 🚚 Pre-configured Ansible roles
176172

@@ -290,7 +286,7 @@ created by [Vic Shóstak][author] and distributed under
290286
[react_url]: https://reactjs.org/
291287
[preact_url]: https://preactjs.com/
292288
[nextjs_url]: https://nextjs.org/
293-
[nuxt3_url]: https://v3.nuxtjs.org/
289+
[nuxt_url]: https://v3.nuxtjs.org/
294290
[svelte_url]: https://svelte.dev/
295291
[lit_url]: https://lit.dev/
296292
[chi_url]: https://github.com/go-chi/chi
@@ -300,3 +296,6 @@ created by [Vic Shóstak][author] and distributed under
300296
[python_url]: https://www.python.org/downloads/
301297
[ansible_url]: https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-on-specific-operating-systems
302298
[brew_url]: https://brew.sh/
299+
[qwik_url]: https://github.com/BuilderIO/qwik
300+
[solid_url]: https://github.com/solidjs/solid
301+
[react_swc_url]: https://swc.rs/

cmd/create.go

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,37 +114,66 @@ func runCreateCmd(cmd *cobra.Command, args []string) error {
114114
*/
115115

116116
if frontend != "none" {
117-
// Checking, if use custom templates.
117+
// Checking, if you use custom templates.
118118
if useCustomTemplate {
119119
// Clone frontend files from git repository.
120120
if err := cgapp.GitClone("frontend", frontend); err != nil {
121121
return cgapp.ShowError(err.Error())
122122
}
123123
} else {
124-
switch {
125-
case frontend == "next" || frontend == "next-ts":
126-
var isTypeScript string
127-
if frontend == "next-ts" {
128-
isTypeScript = "--typescript"
129-
}
130-
124+
switch frontend {
125+
case "next":
131126
// Create a default frontend template with Next.js (React).
132127
if err := cgapp.ExecCommand(
133-
"npx", []string{"create-next-app@latest", "frontend", isTypeScript}, true,
128+
"npx",
129+
[]string{
130+
"create-next-app@latest", "frontend",
131+
"--javascript",
132+
"--eslint",
133+
"--app",
134+
"--tailwind", "false",
135+
"--src-dir", "false",
136+
"--import-alias", "false",
137+
}, true,
138+
); err != nil {
139+
return err
140+
}
141+
case "next-ts":
142+
// Create a default frontend template with Next.js (React, Typescript).
143+
if err := cgapp.ExecCommand(
144+
"npx",
145+
[]string{
146+
"create-next-app@latest", "frontend",
147+
"--typescript",
148+
"--eslint",
149+
"--app",
150+
"--tailwind", "false",
151+
"--src-dir", "false",
152+
"--import-alias", "false",
153+
}, true,
134154
); err != nil {
135155
return err
136156
}
137-
case frontend == "nuxt3":
138-
// Create a default frontend template with Nuxt 3 (Vue.js 3, TypeScript).
157+
case "nuxt":
158+
// Create a default frontend template with Nuxt v3 (Vue.js v3, Typescript).
139159
if err := cgapp.ExecCommand(
140-
"npx", []string{"nuxi", "init", "frontend"}, true,
160+
"npx",
161+
[]string{
162+
"nuxi@latest", "init", "frontend",
163+
}, true,
141164
); err != nil {
142165
return err
143166
}
144167
default:
145168
// Create a default frontend template from Vite (Pure JS/TS, React, Preact, Vue, Svelte, Lit).
146169
if err := cgapp.ExecCommand(
147-
"npm", []string{"init", "vite@latest", "frontend", "--", "--template", frontend}, true,
170+
"npm",
171+
[]string{
172+
"create", "vite@latest", "frontend",
173+
"--",
174+
"--template",
175+
frontend,
176+
}, true,
148177
); err != nil {
149178
return err
150179
}

0 commit comments

Comments
 (0)