Skip to content

Commit 704be15

Browse files
author
Vic Shóstak
committed
Add Sapper to frontend apps
1 parent f9472af commit 704be15

File tree

4 files changed

+47
-8
lines changed

4 files changed

+47
-8
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,17 @@ cgapp deploy --use-config
231231

232232
**Frontend:**
233233

234-
- [x] [`react`](https://create-go.app/production-templates/react-js/), `react:<template>` — Frontend app with [React.js](https://reactjs.org).
235-
- [x] [`preact`](https://create-go.app/production-templates/preact-js/), `preact:<template>` — Frontend app with [Preact](https://preactjs.com).
236-
- [x] [`vue`](https://create-go.app/production-templates/vue-js/), `vue:<user/repo>`, `vue:<gitlab|bitbucket>:<user/repo>` — Frontend app with [Vue.js](https://vuejs.org).
237-
- [x] [`angular`](https://create-go.app/production-templates/angular-js/) — Frontend app with [Angular](https://angular.io).
238-
- [x] [`svelte`](https://create-go.app/production-templates/svelte-js/) — Frontend app with [Svelte](https://svelte.dev).
234+
- [x] `react` — [React](https://reactjs.org/) frontend app.
235+
- [x] `react:<template>` — CRA generated template for React app.
236+
- [x] `preact` — [Preact](https://preactjs.com/) frontend app.
237+
- [x] `preact:<template>` — Preact CLI generated template for Preact app.
238+
- [x] `vue` — [Vue.js](https://vuejs.org/) frontend app.
239+
- [x] `vue:<user/repo>` — Preset for generating Vue.js app from GitHub.
240+
- [x] `vue:<gitlab|bitbucket>:<user/repo>` — Preset for generating Vue.js app from GitLab/BitBucket/etc.
241+
- [x] `angular` — [Angular](https://angular.io/) frontend app.
242+
- [x] `svelte` — [Svelte](https://svelte.dev/) frontend app.
243+
- [x] `sapper` — [Sapper](https://sapper.svelte.dev/) frontend app for static websites.
244+
- [x] `sapper:<webpack>` — Preset for generating Sapper with Webpack bundler.
239245

240246
> ☝️ Please note, that since version `v1.3.0`, frontend templates (_in the classical sense_) are **not** supported by the Create Go App CLI. Those templates, that we created ([`react-js`](https://github.com/create-go-app/react-js-template), [`react-ts`](https://github.com/create-go-app/react-ts-template) and [`preact-js`](https://github.com/create-go-app/preact-js-template)), are still available, but only for use as **user's custom templates**.
241247
>

pkg/cgapp/create.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ func CreateProjectFromCmd(p *registry.Project, c map[string]*registry.Command, m
152152
// npx degit [template] [dest]
153153
options = []string{create, args["template"], folder}
154154
break
155+
case "sapper":
156+
// npx degit [template] [dest]
157+
options = []string{create, args["template"] + "#rollup", folder}
158+
if len(project) > 1 {
159+
options = []string{create, args["template"] + "#" + project[1], folder}
160+
}
161+
break
155162
}
156163

157164
// Run execution command.

pkg/cgapp/create_test.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,31 @@ func TestCreateProjectFromCmd(t *testing.T) {
286286
},
287287
false,
288288
},
289+
{
290+
"successfully create sapper:webpack",
291+
args{
292+
p: &registry.Project{
293+
Type: "frontend",
294+
Name: "sapper:webpack",
295+
RootFolder: "../../tmp",
296+
},
297+
c: map[string]*registry.Command{
298+
"sapper": {
299+
Runner: "echo",
300+
Create: "sapper",
301+
Args: map[string]string{},
302+
},
303+
},
304+
m: registry.RegexpFrontendPattern,
305+
},
306+
false,
307+
},
289308
{
290309
"successfully create from user repository",
291310
args{
292311
p: &registry.Project{
293312
Type: "frontend",
294-
Name: "github.com/create-go-app/preact-js-template",
313+
Name: "github.com/create-go-app/gin-go-template",
295314
RootFolder: "../../tmp",
296315
},
297316
c: registry.Commands,

pkg/registry/defaults.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const (
3636
// RegexpBackendPattern pattern for backend.
3737
RegexpBackendPattern = "^(net/http|fiber|echo)$"
3838
// RegexpFrontendPattern pattern for backend.
39-
RegexpFrontendPattern = "^(p?react:?|vue(:?[\\w]+)?(:?[\\w-_0-9\\/]+)?|angular|svelte)"
39+
RegexpFrontendPattern = "^(p?react:?|vue(:?[\\w]+)?(:?[\\w-_0-9\\/]+)?|angular|svelte|sapper:?)"
4040
// RegexpWebServerPattern pattern for web/proxy servers.
4141
RegexpWebServerPattern = "^(nginx)$"
4242
// RegexpDatabasePattern pattern for databases.
@@ -149,6 +149,13 @@ var (
149149
"template": "sveltejs/template",
150150
},
151151
},
152+
"sapper": {
153+
Runner: "npx",
154+
Create: "degit",
155+
Args: map[string]string{
156+
"template": "sveltejs/sapper-template",
157+
},
158+
},
152159
}
153160

154161
// CreateQuestions survey's questions for `create` command.
@@ -166,7 +173,7 @@ var (
166173
Name: "frontend",
167174
Prompt: &survey.Select{
168175
Message: "Choose a frontend UI library:",
169-
Options: []string{"none", "React", "Preact", "Vue", "Angular", "Svelte"},
176+
Options: []string{"none", "React", "Preact", "Vue", "Angular", "Svelte", "Sapper"},
170177
Default: "none",
171178
},
172179
},

0 commit comments

Comments
 (0)