✨ A powerful CLI for create a new production-ready project with backend, frontend and deploy automation
Tags: go, react, vue, tutorial
Published: 2020-11-21 16:12:24

## Introduction

Hello, friends! 😉 Today, I'd like to present you my own CLI for automation many things for starting a new project. I called it **Create Go App** (or _CGAPP_ for short).

The main idea was to create a universal tool for full automation of the project start when you don't need to install everything you need separately.

What did it come out of? Let's look at it together!

<a name="toc"></a>
### 📝 Table of contents

- [Another CLI?](#ch-1)
- [How does it work?](#ch-2)
  - [Two modes of work with the CLI](#ch-2-1)
- [Available commands](#ch-3)
- [Available project templates](#ch-4)
- [Video screencast](#ch-5)
- [Your assistance to the project](#ch-6)

<a name="ch-1"></a>
## Another CLI?

And yes and no.

When I started this project, I 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**, which we use ourselves!

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.

Focus on writing code and thinking of business logic! The [Create Go App](https://github.com/create-go-app/cli) CLI will take care of the rest.

[↑ Table of contents](#toc)

<a name="ch-2"></a>
## How does it work?

This is a common console utility, written on pure Golang. Therefore, download and install Go. Version **1.11** or higher is required. Next, download the latest version of the [Create Go App](https://github.com/create-go-app/cli) and install to your system:

```bash
# Download
go get github.com/create-go-app/cli

# Install CLI
go build -i -o $GOPATH/bin/cgapp github.com/create-go-app/cli
```

If you don't want to install Create Go App CLI to your system, you feel free to using the [Official Docker image](https://hub.docker.com/r/koddr/cgapp):

```bash
docker run --rm -it -v ${PWD}:${PWD} -w ${PWD} koddr/cgapp:latest
```

With this Docker image, you **don't have to worry** about installing tools for supported frontend UI libraries or frameworks.

[↑ Table of contents](#toc)

<a name="ch-2-1"></a>
### Two modes of work with the CLI

After installation, you will have two modes of work. Choose the one that suits you best, they work equally well.

- With an interactive console UI (or _CUI_ for short):

```console
cgapp [COMMAND]
```

- From configuration file (by default, in `.cgapp.yml`):

```console
cgapp [COMMAND] --use-config
```

[↑ Table of contents](#toc)

<a name="ch-3"></a>
## Available commands

You can see all available commands and options by running `cgapp --help`.

> I'd like to remind you, the best way to better explore all the features of an any tool is to read the [Official Documentation](https://create-go.app/).

- `init` — command for generate a default `.cgapp.yml` config file:

```bash
cgapp init
```

- `create` — command to create a new project with the choosen configuration for backend (Golang), frontend (JavaScript or TypeScript) and deploy automation (through Ansible playbook and configured `Dockerfile`) by CUI or config file:

```bash
cgapp create
```
- `deploy` — command for deploy Docker containers with your project to a remote server or local machine by CUI or config file:

```bash
cgapp deploy
```

Yes, you can run containers on your local machine too (if you've not skipped Ansible roles at `cgapp create` step). All you have to do is define `localhost` as your host.

> Warning: `deploy` command is currently unavailable in Docker image.

[↑ Table of contents](#toc)

<a name="ch-4"></a>
## Available project templates

At the moment, the official **Create Go App** templates are as follows:

- **Backend**: net/http, Fiber
- **Frontend**: React, Preact, Vue.js, Angular, Svelte, Sapper
- **Web server**: Nginx

> New templates will be added as they are created. Write in comments, what templates you'd like to see in future.

But you can create your own templates and connect them in the configuration file (`.cgapp.yml`) like this:

```yaml
project:
    - backend: github.com/user/my-template
    - frontend: gitlab.com/user/my-template
    - webserver: bitbucket.org/user/my-template

# ...
```

[↑ Table of contents](#toc)

<a name="ch-5"></a>
## Video screencast

To make everything as clear as possible, I recorded a small video for you where I show the main functions and structure of the created project using the CLI:

{% youtube 5-DNZFU9TOQ %}

[↑ Table of contents](#toc)

<a name="ch-6"></a>
## Your assistance to the project

I'm **always** open to your suggestions, so please write in comments what to add or change in Create Go App project. This would really help me develop this awesome tool and make it **even better** and **more useful** for you!

Also, I'll be glad if you put a start and add this project to the list for notifications on project's [GitHub](https://github.com/create-go-app/cli) repository:

![github](https://dev-to-uploads.s3.amazonaws.com/i/0ic6tce1k9rkphaczij3.png)

[↑ Table of contents](#toc)

<a name=""></a>
## Photos by

- Vic Shóstak https://github.com/create-go-app

<a name=""></a>
## P.S.

If you want more articles (like this) on this blog, then post a comment below and subscribe to me. Thanks! 😻

And of course, you can help me make developers' lives even better! Just connect to one of my projects as a contributor. It's easy!

My projects that need your help (and stars) 👇

- 🔥 [gowebly][gowebly_url]: A next-generation CLI tool for easily build amazing web applications with Go on the backend, using htmx & hyperscript and the most popular atomic/utility-first CSS frameworks on the frontend.
- ✨ [create-go-app][cgapp_url]: Create a new production-ready project with Go backend, frontend and deploy automation by running one CLI command.
- 🏃 [yatr][yatr_url]: Yet Another Task Runner allows you to organize and automate your routine operations that you normally do in Makefile (or else) for each project.
- 📚 [gosl][gosl_url]: The Go Snippet Library provides snippets collection for working with routine operations in your Go programs with a super user-friendly API and the most efficient performance.
- 🏄‍♂️ [csv2api][csv2api_url]: The parser reads the CSV file with the raw data, filters the records, identifies fields to be changed, and sends a request to update the data to the specified endpoint of your REST API.
- 🚴 [json2csv][json2csv_url]: The parser can read given folder with JSON files, filtering and qualifying input data with intent & stop words dictionaries and save results to CSV files by given chunk size.

<!-- Footer links -->

[gowebly_url]: https://github.com/gowebly
[cgapp_url]: https://github.com/create-go-app
[yatr_url]: https://github.com/koddr/yatr
[gosl_url]: https://github.com/koddr/gosl
[csv2api_url]: https://github.com/koddr/csv2api
[json2csv_url]: https://github.com/koddr/json2csv