Skip to content

Commit d8250e9

Browse files
author
Vic Shóstak
authored
Merge pull request #12 from create-go-app/dev
Dev -> v1.5.0
2 parents 5cb7c70 + 7aabf29 commit d8250e9

File tree

11 files changed

+203
-31
lines changed

11 files changed

+203
-31
lines changed

.github/workflows/testing_build.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ name: Testing CLI
22

33
on:
44
push:
5-
branches: [master]
5+
branches: [dev]
6+
paths:
7+
- "configs/**"
8+
- "**.go"
69
pull_request:
710
branches: [master]
11+
paths:
12+
- "configs/**"
13+
- "**.go"
814

915
jobs:
1016
build:
@@ -28,4 +34,4 @@ jobs:
2834
uses: actions/checkout@v2
2935

3036
- name: Test
31-
run: go test -v -cover -race ./...
37+
run: go test -v -cover -race -timeout 60s ./...

.goreleaser.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ builds:
2323
- CGO_ENABLED=0
2424

2525
dockers:
26-
# You can have multiple Docker images.
2726
- # GOOS of the built binary that should be used.
2827
goos: linux
2928
goarch: amd64
@@ -42,10 +41,10 @@ dockers:
4241
- "koddr/cgapp:{{ .Major }}.{{ .Minor }}.{{ .Patch }}"
4342
- "koddr/cgapp:{{ .Major }}.{{ .Minor }}"
4443
- "koddr/cgapp:{{ .Major }}"
45-
- "koddr/cgapp-deploy:latest"
44+
- "koddr/cgapp:latest"
4645

4746
# Path to the Dockerfile (from the project root).
48-
dockerfile: Dockerfile.deploy
47+
dockerfile: Dockerfile
4948

5049
archives:
5150
- # Replacements for GOOS and GOARCH in the archive name.

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ FROM alpine:3.12
22

33
LABEL maintainer="Vic Shóstak <[email protected]>"
44

5-
# Copy Create Go App binary
5+
# Copy Create Go App binary.
66
COPY cgapp /cgapp
77

8-
# Install git
8+
# Install git, npm.
99
RUN apk add --no-cache git npm
1010

11-
# Install frontend CLIs
11+
# Install frontend CLIs.
1212
RUN npm i -g -s create-react-app preact-cli @vue/cli degit @angular/cli
1313

14-
# Set entry point to /cgapp
14+
# Set entry point.
1515
ENTRYPOINT ["/cgapp"]

README.md

Lines changed: 29 additions & 11 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://github.com/create-go-app/cli/releases" target="_blank"><img src="https://img.shields.io/badge/version-v1.4.1-blue?style=for-the-badge&logo=none" alt="cli version" /></a>&nbsp;<a href="https://pkg.go.dev/github.com/create-go-app/cli?tab=doc" target="_blank"><img src="https://img.shields.io/badge/Go-1.11+-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-94%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://github.com/create-go-app/cli/releases" target="_blank"><img src="https://img.shields.io/badge/version-v1.5.0-blue?style=for-the-badge&logo=none" alt="cli version" /></a>&nbsp;<a href="https://pkg.go.dev/github.com/create-go-app/cli?tab=doc" target="_blank"><img src="https://img.shields.io/badge/Go-1.11+-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-94%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](https://create-go.app/quick-start/)
1010

@@ -96,19 +96,27 @@ cgapp init
9696
project:
9797
# Backend for your project.
9898
# (Required)
99-
# String: `net/http`, `fiber`, `echo`, `gin`
99+
# String:
100+
# - `net/http`
101+
# - `fiber`
102+
# - `echo`
103+
# - `gin`
100104
# User template: supported, set to URL (without protocol),
101105
# like `github.com/user/template`
102106
- backend: fiber
103107

104108
# Frontend for your project.
105109
# (Optional, to skip set to `none`)
106110
# String:
107-
# - `react`, `react:<template>`
108-
# - `preact`, `preact:<template>`
111+
# - `react`
112+
# - `react:<template>`
113+
# - `preact`
114+
# - `preact:<template>`
109115
# - `vue`
110-
# - `svelte`
116+
# - `vue:<user/repo>` (for preset from GitHub)
117+
# - `vue:<gitlab|bitbucket>:<user/repo>` (for presets from others)
111118
# - `angular`
119+
# - `svelte`
112120
# User template: supported, set to URL (without protocol),
113121
# like `github.com/user/template`
114122
- frontend: svelte
@@ -131,7 +139,7 @@ project:
131139
roles:
132140
# Ansible roles for deploy your project.
133141
# (Optional, to skip set to empty or comment)
134-
# Objects list: `deploy`
142+
# Objects list.
135143
- deploy:
136144
# Username of remote's server or local's user.
137145
# (Required)
@@ -223,11 +231,21 @@ cgapp deploy --use-config
223231

224232
**Frontend:**
225233

226-
- [x] [`react`](https://create-go.app/production-templates/react-js/) — Frontend app with [React.js](https://reactjs.org).
227-
- [x] [`preact`](https://create-go.app/production-templates/preact-js/) — Frontend app with [Preact](https://preactjs.com).
228-
- [ ] [`vue`](https://create-go.app/production-templates/vue-js/) _WIP_ — Frontend app with [Vue.js](https://vuejs.org).
229-
- [x] [`svelte`](https://create-go.app/production-templates/svelte-js/) — Frontend app with [Svelte](https://svelte.dev).
230-
- [ ] [`angular`](https://create-go.app/production-templates/angular-js/) _WIP_ — Frontend app with [Angular](https://angular.io).
234+
- [x] `react` — [React](https://reactjs.org/) frontend app.
235+
- `react:<template>` — CRA generated template for React app.
236+
- [x] `preact` — [Preact](https://preactjs.com/) frontend app.
237+
- `preact:<template>` — Preact CLI generated template for Preact app.
238+
- [x] `vue` — [Vue.js](https://vuejs.org/) frontend app.
239+
- `vue:<user/repo>` — Preset for generating Vue.js app from GitHub.
240+
- `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+
- `sapper:<webpack>` — Preset for generating Sapper with Webpack bundler.
245+
246+
> ☝️ 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**.
247+
>
248+
> Now, the frontend part of your project will be generated **using official CLI** from the authors of each frontend UI library/framework (_under the hood_). So, you'll always get the latest version of `React`, `Preact`, `Vue.js`, `Angular`, `Svelte` or `Sapper` for your project from their authors!
231249

232250
## 🐳 [Configured Docker containers](https://create-go.app/docker-containers/)
233251

cmd/create.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,15 @@ var runCreateCmd = func(cmd *cobra.Command, args []string) {
172172
cgapp.SendMsg(true, "[ERROR]", err.Error(), "red", true)
173173
os.Exit(1)
174174
}
175+
176+
// Create Dockerfile for frontend.
177+
filesToMake := map[string][]byte{
178+
"frontend/Dockerfile": embed.Get("/Dockerfile.frontend"),
179+
}
180+
if err := cgapp.MakeFiles(currentDir, filesToMake); err != nil {
181+
cgapp.SendMsg(true, "[ERROR]", err.Error(), "red", true)
182+
os.Exit(1)
183+
}
175184
}
176185

177186
// Docker containers.

configs/.cgapp.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,27 @@
66
project:
77
# Backend for your project.
88
# (Required)
9-
# String: `net/http`, `fiber`, `echo`, `gin`
9+
# String:
10+
# - `net/http`
11+
# - `fiber`
12+
# - `echo`
13+
# - `gin`
1014
# User template: supported, set to URL (without protocol),
1115
# like `github.com/user/template`
1216
- backend: fiber
1317

1418
# Frontend for your project.
1519
# (Optional, to skip set to `none`)
1620
# String:
17-
# - `react`, `react:<template>`
18-
# - `preact`, `preact:<template>`
21+
# - `react`
22+
# - `react:<template>`
23+
# - `preact`
24+
# - `preact:<template>`
1925
# - `vue`
20-
# - `svelte`
26+
# - `vue:<user/repo>` (for preset from GitHub)
27+
# - `vue:<gitlab|bitbucket>:<user/repo>` (for presets from others)
2128
# - `angular`
29+
# - `svelte`
2230
# User template: supported, set to URL (without protocol),
2331
# like `github.com/user/template`
2432
- frontend: svelte
@@ -41,7 +49,7 @@ project:
4149
roles:
4250
# Ansible roles for deploy your project.
4351
# (Optional, to skip set to empty or comment)
44-
# Objects list: `deploy`
52+
# Objects list.
4553
- deploy:
4654
# Username of remote's server or local's user.
4755
# (Required)

configs/Dockerfile.frontend

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM node:14-alpine AS builder
2+
3+
LABEL maintainer="Vic Shóstak <[email protected]>"
4+
5+
# Go to work directory.
6+
WORKDIR /build
7+
8+
# Copy all needed files to /build folder.
9+
COPY package*.json src ./
10+
11+
# Install frontend dependencies and run build.
12+
RUN npm ci -s --only=production && npm run build
13+
14+
FROM scratch
15+
16+
# Copy builded files to container root.
17+
COPY --from=builder /build/dist /

pkg/cgapp/create.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,31 @@ func CreateProjectFromCmd(p *registry.Project, c map[string]*registry.Command, m
134134
options = []string{create, project[1], p.Type, args["cwd"], p.RootFolder, args["name"], "cgapp"}
135135
}
136136
break
137+
case "vue":
138+
// vue create [options] <app-name>
139+
options = []string{create, "--default", "--bare", p.Type}
140+
if len(project) == 2 {
141+
options = []string{create, "--preset", project[1], "--bare", p.Type}
142+
}
143+
if len(project) == 3 {
144+
options = []string{create, "--preset", project[1] + ":" + project[2], "--bare", "--clone", p.Type}
145+
}
146+
break
147+
case "angular":
148+
// ng new <app-name> [options]
149+
options = []string{create, "cgapp", "--defaults", "--routing", "--directory", p.Type}
150+
break
137151
case "svelte":
138152
// npx degit [template] [dest]
139153
options = []string{create, args["template"], folder}
140154
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
141162
}
142163

143164
// Run execution command.

pkg/cgapp/create_test.go

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func TestCreateProjectFromCmd(t *testing.T) {
173173
wantErr bool
174174
}{
175175
{
176-
"successfully create react",
176+
"successfully create react:redux",
177177
args{
178178
p: &registry.Project{
179179
Type: "frontend",
@@ -210,6 +210,63 @@ func TestCreateProjectFromCmd(t *testing.T) {
210210
},
211211
false,
212212
},
213+
{
214+
"successfully create vue (with mock for GitHub)",
215+
args{
216+
p: &registry.Project{
217+
Type: "frontend",
218+
Name: "vue:mock",
219+
RootFolder: "../../tmp",
220+
},
221+
c: map[string]*registry.Command{
222+
"vue": {
223+
Runner: "echo",
224+
Create: "vue",
225+
Args: map[string]string{},
226+
},
227+
},
228+
m: registry.RegexpFrontendPattern,
229+
},
230+
false,
231+
},
232+
{
233+
"successfully create vue (with mock for others)",
234+
args{
235+
p: &registry.Project{
236+
Type: "frontend",
237+
Name: "vue:mock:mock",
238+
RootFolder: "../../tmp",
239+
},
240+
c: map[string]*registry.Command{
241+
"vue": {
242+
Runner: "echo",
243+
Create: "vue",
244+
Args: map[string]string{},
245+
},
246+
},
247+
m: registry.RegexpFrontendPattern,
248+
},
249+
false,
250+
},
251+
{
252+
"successfully create angular",
253+
args{
254+
p: &registry.Project{
255+
Type: "frontend",
256+
Name: "angular",
257+
RootFolder: "../../tmp",
258+
},
259+
c: map[string]*registry.Command{
260+
"angular": {
261+
Runner: "echo",
262+
Create: "angular",
263+
Args: map[string]string{},
264+
},
265+
},
266+
m: registry.RegexpFrontendPattern,
267+
},
268+
false,
269+
},
213270
{
214271
"successfully create svelte",
215272
args{
@@ -229,12 +286,31 @@ func TestCreateProjectFromCmd(t *testing.T) {
229286
},
230287
false,
231288
},
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+
},
232308
{
233309
"successfully create from user repository",
234310
args{
235311
p: &registry.Project{
236312
Type: "frontend",
237-
Name: "github.com/create-go-app/preact-js-template",
313+
Name: "github.com/create-go-app/gin-go-template",
238314
RootFolder: "../../tmp",
239315
},
240316
c: registry.Commands,

0 commit comments

Comments
 (0)