Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev > v1.3.0 #3

Merged
merged 49 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
5582388
Draft 1.3.0
Jul 5, 2020
7ae6860
Restore actions, create
Jul 5, 2020
d31afed
Restore create, actions
Jul 5, 2020
c3e9bc5
Update create, utils
Jul 5, 2020
2097dba
Fix create_test
Jul 5, 2020
52cc7a5
Fix actions
Jul 5, 2020
16eee8c
Rebase cleanup function to GitClone
Jul 5, 2020
694f7a2
Re-write tests (70%)
Jul 5, 2020
f021a55
Add CreateProjectFromCMD
Jul 6, 2020
6774c07
Refactoring, Add preact vendor to cmds
Jul 6, 2020
c670a85
Fix tests for create
Jul 6, 2020
a9b6da0
Rename ansible roles
Jul 6, 2020
813a0ab
Fix tests (69.2%)
Jul 6, 2020
9718e59
Switch to Cobra
Jul 7, 2020
01216c8
Rename Registry
Jul 7, 2020
bd5bd3c
Update init command
Jul 7, 2020
d763352
Add survay package
Jul 7, 2020
9f5b31e
Update config
Jul 7, 2020
1a9e7a8
Rename ThrowError -> throwError
Jul 7, 2020
269c738
Separate tests for utils package
Jul 7, 2020
e7dbf63
Update config's description
Jul 7, 2020
100ab12
Add long description
Jul 7, 2020
724189d
Update color for files
Jul 7, 2020
688d531
Add tests for new commands
Jul 8, 2020
1dede82
Refactoring create cmd
Jul 8, 2020
6ad2e8a
Refactoring cmds
Jul 8, 2020
d7aad93
Clear tests
Jul 8, 2020
f2c05fd
Re-struct cmd funcs
Jul 8, 2020
1332654
Draft create cmd
Jul 8, 2020
4bfdfbb
Add deploy cmd
Jul 8, 2020
1036041
Rename InstallAnsibleRoles
Jul 8, 2020
136ad1f
Fix rootCmd
Jul 8, 2020
12358b2
Add description to .cgapp.yml
Jul 8, 2020
32a2e24
Add --ask-become-pass
Jul 8, 2020
fe5be7b
Update deploy cmd
Jul 8, 2020
eb1bfef
Add actions pkg
Jul 8, 2020
6ccf338
Fix frontend
Jul 8, 2020
e2416ed
Fix output
Jul 8, 2020
3c4a765
Add config flag desc
Jul 8, 2020
6004935
Add copyright to actions pkg
Jul 8, 2020
1ee224e
Re-format README
Jul 9, 2020
80824b2
Update README.md
Jul 9, 2020
b9eb196
Update README.md
Jul 9, 2020
850b53e
Update README.md
Jul 9, 2020
b8b676e
Update issues templates
Jul 9, 2020
0be7fe2
Update bug_report.md
Jul 9, 2020
8234a21
Update feature_request.md
Jul 9, 2020
3fdee9b
Update README.md
Jul 9, 2020
39bd336
Update README.md
Jul 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ labels: "bug"
assignees: "koddr"
---

**Required check list:**

- [ ] I didn't find found in the Create Go App CLI repository's issues section similar bug.
- [ ] I understand, that the Create Go App CLI is Open Source and not-for-profit product.
- [ ] This is not about third-party project, framework, package or technology.

**My environment:**

- OS (`uname -a`):
Expand Down
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ labels: "feature"
assignees: "koddr"
---

**Required check list:**

- [ ] I didn't find found in the Create Go App CLI repository's issues section similar feature request.
- [ ] I understand, that the Create Go App CLI is Open Source and not-for-profit product.
- [ ] This is not about third-party project, framework, package or technology.

**Is your feature request related to a problem? Please describe.**

<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
**/app/
**/build/
**/dist/
**/cgapp-project/

# Tests
*.out
**/tmp/

# Embed file
Expand Down
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down Expand Up @@ -186,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2019-present Vic Shóstak <[email protected]> (https://1wa.co)
Copyright 2020 Vic Shóstak <[email protected]> (https://1wa.co)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
167 changes: 130 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
<img src="https://github.com/create-go-app/cli/blob/master/.github/images/[email protected]" width="224px"/><br/>
Create Go App CLI
</h1>
<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 code</b>! The CLI will take care of the rest.</p>
<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>

<p align="center"><a href="https://github.com/create-go-app/cli/releases" target="_blank"><img src="https://img.shields.io/badge/version-v1.2.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/pkg/cgapp?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-98%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>
<p align="center"><a href="https://github.com/create-go-app/cli/releases" target="_blank"><img src="https://img.shields.io/badge/version-v1.3.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/cmd?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/cmd" target="_blank"><img src="https://img.shields.io/badge/Go_Cover-84%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>

## ⚡️ [Quick start](https://create-go.app/quick-start/)

First of all, [download](https://golang.org/dl/) and install Go. Version `1.11` or higher is required.
First of all, [download](https://golang.org/dl/) and install **Go**. Version `1.11` or higher is required.

Installation is done by using the [`go build`](https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies) command with `$GOPATH/bin`:

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

Let's create a new project into `./app` folder with [Fiber](https://github.com/gofiber/fiber) as backend and [Nginx](https://nginx.org/) as web server:
Let's create a new project via **interactive console UI** (or **CUI**) into current folder:

```bash
cgapp create -p ./app -b fiber -w nginx
cgapp create
```

Okay, it works! Now, you can deploy this project to a remote server or run on your local machine in isolated Docker containers. Go to the root project folder and type command:
Okay, it works! Now, you can run this project on your **local machine** or deploy to a **remote server**. Project works in isolated Docker containers and automates via Ansible playbook:

```bash
cgapp deploy -u john_doe --ask-become-pass
cgapp deploy
```

That's all you need to start! 🎉
Expand All @@ -40,6 +40,7 @@ Unfortunately, we are unable to include all helpful documentation to the `README
- [CLI Installation](https://create-go.app/detailed-guides/installation/)
- [Alternative installations](https://create-go.app/detailed-guides/installation/#alternative-installations)
- [Understanding CLI commands and options](https://create-go.app/detailed-guides/commands-and-options/)
- [`init`](https://create-go.app/detailed-guides/commands-and-options/#init)
- [`create`](https://create-go.app/detailed-guides/commands-and-options/#create)
- [`deploy`](https://create-go.app/detailed-guides/commands-and-options/#deploy)
- [Run project on your local machine](https://create-go.app/detailed-guides/run-on-local/)
Expand All @@ -53,67 +54,159 @@ Unfortunately, we are unable to include all helpful documentation to the `README

## ⚙️ [Commands & Options](https://create-go.app/detailed-guides/commands-and-options/)

### `create`
### [`init`](https://create-go.app/detailed-guides/commands-and-options/#init)

CLI command for generate a default `.cgapp.yml` config file in current folder:

```bash
cgapp init
```

<details>
<summary>Generated config file</summary>

<br/>

```yaml
# Project config.
project:
# Backend for your project.
# (Required)
# String: `net/http`, `fiber`, `echo`, `gin`
# User template: supported, set to URL (without protocol),
# like `github.com/user/template`
- backend: fiber
# Frontend for your project.
# (Optional, to skip set to `none`)
# String: `react`, `react:<template>` `preact`, `preact:<template>`, `svelte`
# User template: NOT supported!
- frontend: svelte
# Web/proxy server for your project.
# (Optional, to skip set to `none`)
# String: `nginx`
# User template: supported, set to URL (without protocol),
# like `github.com/user/template`
- webserver: nginx
# Web/proxy server for your project.
# (Optional, to skip set to `none`)
# String: `postgres`
# User template: supported, set to URL (without protocol),
# like `github.com/user/template`
- database: postgres

# Automation config.
roles:
# Ansible roles for deploy your project.
# (Optional, to skip set to empty or comment)
# Objects list: `deploy`
- deploy:
# Username of remote's server or local's user.
# (Required)
username: root
# If you need to deploy (or run) a project asking for a password
# for the user, set `become` to `true`. This is equivalent of
# `--ask-become-pass`, a standard Ansible argument to ask
# for a privilege escalation password.
# (Optional)
become: true
# Host name from your inventory file (usually, at /etc/ansible/hosts).
# (Required)
host: localhost
# Name of Docker network
# (Required)
network: cgapp_network
# Filename of Ansible playbook in the root of the Create Go App project.
# If you want to rename it, do it, but not to change destination of file!
# (Required)
playbook: deploy-playbook.yml
```

</details>

### [`create`](https://create-go.app/detailed-guides/commands-and-options/#create)

CLI command to create a new project with the selected configuration.

There's two ways to create a new project:

- [x] With an interactive console UI (or CUI).
- [x] From configuration file (by default, in `$PWD/.cgapp.yml`).

#### Create with the interactive console UI

Run `create` command **without** any arguments:

```bash
cgapp create
```

#### Create from the config file

Run `create` command **with** `--use-config` (or `-c`) argument:

```bash
cgapp create -p <PATH> -b <BACKEND> -f <FRONTEND> -w <WEBSERVER> -d <DB> [ARGS...]
cgapp create --use-config
```

| Option | Argument | Required? | Description | Default value |
| ------ | ----------- | --------- | --------------------------------- | -------------------- |
| `-p` | `PATH` | no | path to create project | current folder, `./` |
| `-b` | `BACKEND` | no | backend for your project | `net/http` |
| `-f` | `FRONTEND` | no | frontend for your project | |
| `-w` | `WEBSERVER` | no | web/proxy server for your project | |
| `-d` | `DB` | no | database for your project | |
### [`deploy`](https://create-go.app/detailed-guides/commands-and-options/#deploy)

CLI command for deploy Docker containers with your project to a remote server.

If you not need to install Ansible playbook and roles for your project, you can skip this by adding an `--skip-ansible-roles` argument in `[ARGS...]` section.
> ☝️ You should only run this command from the **root folder** of your project, which created with the `cgapp create` command! It's a necessary condition for everything to work perfectly.

### `deploy`
There's, also, two ways to deploy your project:

CLI command for deploy Docker containers with your project to a remote server or run on your local machine.
- [x] With an interactive console UI (or CUI).
- [x] From configuration file (by default, in `$PWD/.cgapp.yml`).

#### Deploy with the interactive console UI

Run `deploy` command **without** any arguments:

```bash
cgapp deploy -p <PLAYBOOK> -u <USER> -s <HOST> -n <NETWORK> [ARGS...]
cgapp deploy
```

| Option | Argument | Required? | Description | Default value |
| ------ | ---------- | --------- | ---------------------------------------------- | --------------------- |
| `-p` | `PLAYBOOK` | no | the Ansible playbook name | `deploy-playbook.yml` |
| `-u` | `USER` | yes | an username of remote's server or local's user | |
| `-s` | `HOST` | no | a host name from your inventory file | `localhost` |
| `-n` | `NETWORK` | no | a network name for your Docker containers | `cgapp_network` |
#### Deploy from the config file

Run `deploy` command **with** `--use-config` (or `-c`) argument:

If you need to deploy (or run) a project asking for a password for the `USER`, simply add an `--ask-become-pass` argument in `[ARGS...]` section.
```bash
cgapp deploy --use-config
```

## 📝 [Production-ready project templates](https://create-go.app/production-templates/)

**Golang:**
**Backend:**

- [x] [`net/http`](https://create-go.app/production-templates/net-http-go/) — Backend template with Golang built-in [net/http](https://golang.org/pkg/net/http/) package.
- [x] [`fiber`](https://create-go.app/production-templates/fiber-go/) — Backend template with [Fiber](https://github.com/gofiber/fiber).
- [ ] [`echo`](https://create-go.app/production-templates/echo-go/) _WIP_ — Backend template with [Echo](https://github.com/labstack/echo).
- [ ] [`gin`](https://create-go.app/production-templates/gin-go/) _WIP_ — Backend template with [Gin](https://github.com/gin-gonic/gin).

**JavaScript:**

- [x] [`react-js`](https://create-go.app/production-templates/react-js/) — Frontend template with [React.js](https://github.com/facebook/react).
- [x] [`preact`](https://create-go.app/production-templates/preact-js/) — Frontend template with [Preact](https://github.com/preactjs/preact).

**TypeScript:**
**Frontend:**

- [x] [`react-ts`](https://create-go.app/production-templates/react-ts/) — Frontend template with [React.js](https://github.com/facebook/react) TypeScript.
- [x] [`react`](https://create-go.app/production-templates/react-js/) — Frontend app with [React.js](https://reactjs.org).
- [x] [`preact`](https://create-go.app/production-templates/preact-js/) — Frontend app with [Preact](https://preactjs.com).
- [ ] [`vue`](https://create-go.app/production-templates/vue-js/) _WIP_ — Frontend app with [Vue.js](https://vuejs.org).
- [x] [`svelte`](https://create-go.app/production-templates/svelte-js/) — Frontend app with [Svelte](https://svelte.dev).
- [ ] [`angular`](https://create-go.app/production-templates/angular-js/) _WIP_ — Frontend app with [Angular](https://angular.io).

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

**Web/Proxy server:**

- [x] [`nginx`](https://create-go.app/docker-containers/nginx/) — Docker container with Nginx.
- [x] [`nginx`](https://create-go.app/docker-containers/nginx/) — Docker container with [Nginx](https://nginx.org).

**Database:**

- [ ] [`postgres`](https://create-go.app/docker-containers/postgres/) _WIP_ — Docker container with PostgreSQL.
- [ ] [`postgres`](https://create-go.app/docker-containers/postgres/) _WIP_ — Docker container with [PostgreSQL](https://postgresql.org).

## 🤔 Why another CLI?

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.

The Create Go App project allow you to prepare and deploy your project **without** any unnecessary headaches.

## ⭐️ Project assistance

Expand Down
3 changes: 2 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ tasks:
test:
desc: Test project
cmds:
- go test -cover ./...
- go test -coverprofile=coverage.out ./...
- go tool cover -func=coverage.out

security:
desc: Run gosec for project
Expand Down
Loading