Skip to content

Commit b2a7c52

Browse files
author
Vic Shóstak
committed
Delete ansible-roles, Switch to Ansible tasks in one playbook
1 parent 114fab4 commit b2a7c52

File tree

13 files changed

+51
-90
lines changed

13 files changed

+51
-90
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ insert_final_newline = true
1212
indent_style = tab
1313
indent_size = 4
1414

15-
[{Dockerfile,Makefile,*.yml,*.yaml}]
15+
[{Dockerfile,*.yml,*.yaml}]
1616
indent_style = tab
1717
indent_size = 2

README.md

Lines changed: 4 additions & 4 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.5.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.2-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

@@ -44,7 +44,7 @@ If you don't want to install Create Go App CLI to your system, you feel free to
4444
docker run --rm -it -v ${PWD}:${PWD} -w ${PWD} koddr/cgapp:latest
4545
```
4646

47-
With this Docker image, you do **not** have to worry about installing tools/CLI of frontend UI libraries/frameworks. Everything is **already included** to this Docker image: `create-react-app`, `preact-cli`, `vue-cli`, `ng-cli` and `degit` (for Svelte and Sapper).
47+
With this Docker image, you do **not** have to worry about installing tools/CLI of frontend UI libraries/frameworks. Everything is **already included**: `create-react-app`, `preact-cli`, `vue-cli`, `ng-cli` and `degit` (for Svelte and Sapper).
4848

4949
Available commands for official Docker image:
5050

@@ -261,9 +261,9 @@ cgapp deploy --use-config
261261

262262
## 🤔 Why another CLI?
263263

264-
Yes, when we started this project, we asked ourselves this question too and... came to the conclusion, that about **8-10** routine steps in each project can be automated with a smart CLI.
264+
When we started this project, we asked ourselves this question too and... came to the conclusion, that approximately 8 out of 10 routine operations at the start of a new project and/or the deployment of an existing one **can be automated**. And it would be better to have all the necessary functions inside one CLI. That's why we transferred all our experience to the Create Go App CLI, which we use ourselves!
265265

266-
The Create Go App project allow you to prepare and deploy your project **without** any unnecessary headaches.
266+
So, yes, this CLI gives you the ability to prepare everything you need to **start a new project** (as `create-react-app` for the React.js ecosystem does) and **deploy an existing project** to a remote server in configured and fully isolated Docker containers.
267267

268268
## ⭐️ Project assistance
269269

cmd/create.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ var runCreateCmd = func(cmd *cobra.Command, args []string) {
114114
os.Exit(1)
115115
}
116116

117-
// Create Ansible playbook and download roles, if not skipped.
117+
// Create Ansible playbook with tasks, if not skipped.
118118
if installAnsibleRoles {
119-
cgapp.SendMsg(true, "*", "Create Ansible playbook and roles...", "cyan", true)
119+
cgapp.SendMsg(true, "*", "Create Ansible playbook with tasks...", "cyan", true)
120120

121121
// Create playbook.
122122
fileToMake := map[string][]byte{
@@ -126,20 +126,6 @@ var runCreateCmd = func(cmd *cobra.Command, args []string) {
126126
cgapp.SendMsg(true, "[ERROR]", err.Error(), "red", true)
127127
os.Exit(1)
128128
}
129-
130-
// Create Ansible roles.
131-
if err := cgapp.CreateProjectFromRegistry(
132-
&registry.Project{
133-
Type: "roles",
134-
Name: "deploy",
135-
RootFolder: currentDir,
136-
},
137-
registry.Repositories,
138-
registry.RegexpAnsiblePattern,
139-
); err != nil {
140-
cgapp.SendMsg(true, "[ERROR]", err.Error(), "red", true)
141-
os.Exit(1)
142-
}
143129
}
144130

145131
// Create backend files.

cmd/deploy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
"github.com/spf13/cobra"
3636
)
3737

38-
// deployCmd represents the `deploy` command
38+
// deployCmd represents the `deploy` command.
3939
var deployCmd = &cobra.Command{
4040
Use: "deploy",
4141
Aliases: []string{"serve"},
@@ -44,7 +44,7 @@ var deployCmd = &cobra.Command{
4444
Run: runDeployCmd,
4545
}
4646

47-
// runDeployCmd represents runner for the `deploy` command
47+
// runDeployCmd represents runner for the `deploy` command.
4848
var runDeployCmd = func(cmd *cobra.Command, args []string) {
4949
// Start message.
5050
cgapp.SendMsg(true, "* * *", "Deploying project via Create Go App CLI v"+registry.CLIVersion+"...", "yellow", true)
@@ -112,7 +112,7 @@ var runDeployCmd = func(cmd *cobra.Command, args []string) {
112112
os.Exit(1)
113113
}
114114

115-
// Stop timer
115+
// Stop timer.
116116
stopTimer := time.Since(startTimer).String()
117117

118118
// End message.

cmd/init.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ import (
3232
"github.com/spf13/cobra"
3333
)
3434

35-
// initCmd represents the init command
35+
// initCmd represents the init command.
3636
var initCmd = &cobra.Command{
3737
Use: "init",
3838
Short: "Init a configuration file for the Create Go App project",
3939
Long: "\nInit a configuration file for the Create Go App project.",
4040
Run: runInitCmd,
4141
}
4242

43+
// runInitCmd represents runner for the `init` command.
4344
var runInitCmd = func(cmd *cobra.Command, args []string) {
4445
// Get current directory.
4546
currentDir, _ := os.Getwd()

cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var (
5757
}
5858
)
5959

60-
// rootCmd represents the base command when called without any subcommands
60+
// rootCmd represents the base command when called without any subcommands.
6161
var rootCmd = &cobra.Command{
6262
Use: "cgapp",
6363
Version: registry.CLIVersion,
@@ -94,7 +94,7 @@ func initConfig() {
9494
os.Exit(1)
9595
}
9696

97-
// Parse configs
97+
// Parse configs.
9898
_ = viper.UnmarshalKey("project", &projectConfig)
9999
_ = viper.UnmarshalKey("roles", &rolesConfig)
100100
}

configs/.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ insert_final_newline = true
1414
indent_style = tab
1515
indent_size = 4
1616

17-
[{Dockerfile,Makefile,*.yml,*.yaml}]
17+
[{Dockerfile,*.yml,*.yaml}]
1818
indent_style = tab
1919
indent_size = 2

pkg/cgapp/create.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ func CreateProjectFromRegistry(p *registry.Project, r map[string]*registry.Repos
4747
// Create path in project root folder.
4848
folder := filepath.Join(p.RootFolder, p.Type)
4949

50-
// Re-define folder for Ansible roles
51-
if p.Type == "roles" {
52-
folder = filepath.Join(p.RootFolder, p.Type, p.Name)
53-
}
54-
5550
// Create match expration.
5651
match, err := regexp.MatchString(m, p.Name)
5752
if err != nil {

pkg/cgapp/create_test.go

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,16 @@ func TestCreateProjectFromRegistry(t *testing.T) {
5757
},
5858
false,
5959
},
60-
{
61-
"successfully created Ansible deploy roles",
62-
args{
63-
p: &registry.Project{
64-
Type: "roles",
65-
Name: "deploy",
66-
RootFolder: "../../tmp",
67-
},
68-
r: registry.Repositories,
69-
m: registry.RegexpAnsiblePattern,
70-
},
71-
false,
72-
},
7360
{
7461
"failed to create (not valid repository)",
7562
args{
7663
p: &registry.Project{
77-
Type: "roles",
78-
Name: "deploy",
64+
Type: "backend",
65+
Name: "echo",
7966
RootFolder: "../../tmp",
8067
},
8168
r: map[string]*registry.Repository{
82-
"roles": {
69+
"backend": {
8370
List: map[string]string{},
8471
},
8572
},
@@ -91,12 +78,12 @@ func TestCreateProjectFromRegistry(t *testing.T) {
9178
"failed to create (not valid repository with wrong name)",
9279
args{
9380
p: &registry.Project{
94-
Type: "roles",
81+
Type: "backend",
9582
Name: "wrong-name",
9683
RootFolder: "../../tmp",
9784
},
9885
r: map[string]*registry.Repository{
99-
"roles": {
86+
"backend": {
10087
List: map[string]string{},
10188
},
10289
},
@@ -108,8 +95,8 @@ func TestCreateProjectFromRegistry(t *testing.T) {
10895
"failed to create (repositories is nil)",
10996
args{
11097
p: &registry.Project{
111-
Type: "roles",
112-
Name: "deploy",
98+
Type: "backend",
99+
Name: "echo",
113100
RootFolder: "../../tmp",
114101
},
115102
r: nil,
@@ -130,8 +117,8 @@ func TestCreateProjectFromRegistry(t *testing.T) {
130117
"failed to create (pattern is nil)",
131118
args{
132119
p: &registry.Project{
133-
Type: "roles",
134-
Name: "deploy",
120+
Type: "backend",
121+
Name: "echo",
135122
RootFolder: "../../tmp",
136123
},
137124
r: registry.Repositories,

0 commit comments

Comments
 (0)