From 54f489575699e530084458fe253ed55b9dd7e8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vic=20Sh=C3=B3stak?= Date: Sun, 18 Apr 2021 18:17:59 +0300 Subject: [PATCH 1/3] Update license text; Fix golangci-linter issues --- .github/FUNDING.yml | 1 - .github/workflows/golangci_lint.yml | 27 ++++++++++++++++++ .github/workflows/testing_build.yml | 7 +++-- LICENSE | 2 +- Makefile | 5 +++- README.md | 2 +- cmd/create.go | 26 ++--------------- cmd/deploy.go | 26 ++--------------- cmd/init.go | 26 ++--------------- cmd/root.go | 44 ++++++++--------------------- main.go | 2 +- pkg/cgapp/create.go | 34 ++-------------------- pkg/cgapp/exec.go | 28 ++---------------- pkg/cgapp/files.go | 28 ++---------------- pkg/cgapp/git.go | 28 ++---------------- pkg/cgapp/utils.go | 33 ++-------------------- pkg/cgapp/utils_test.go | 2 +- pkg/registry/defaults.go | 30 +++----------------- 18 files changed, 79 insertions(+), 272 deletions(-) create mode 100644 .github/workflows/golangci_lint.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index a98c8be..7ea8eb5 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,5 +1,4 @@ # These are supported funding model platforms -github: koddr patreon: koddr custom: https://paypal.me/koddr diff --git a/.github/workflows/golangci_lint.yml b/.github/workflows/golangci_lint.yml new file mode 100644 index 0000000..03accf5 --- /dev/null +++ b/.github/workflows/golangci_lint.yml @@ -0,0 +1,27 @@ +name: Linting + +on: + push: + branches: + - dev + pull_request: + branches: + - master + +jobs: + golangci: + name: Linting Go code + + strategy: + matrix: + go-version: [1.16.x] + os: [ubuntu-latest, macos-latest, windows-latest] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + version: latest diff --git a/.github/workflows/testing_build.yml b/.github/workflows/testing_build.yml index 8a7791f..0794978 100644 --- a/.github/workflows/testing_build.yml +++ b/.github/workflows/testing_build.yml @@ -1,13 +1,14 @@ -name: Testing CLI +name: Testing on: push: - branches: [dev] + branches: + - dev paths: - "**.go" jobs: - build: + testing: name: Testing build strategy: diff --git a/LICENSE b/LICENSE index 1416e52..8c8d72f 100644 --- a/LICENSE +++ b/LICENSE @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2019-present Vic Shóstak (https://1wa.co) + Copyright 2019-present Vic Shóstak (https://shostak.dev) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Makefile b/Makefile index 316188a..9dd2fcc 100644 --- a/Makefile +++ b/Makefile @@ -7,10 +7,13 @@ test: clean go test -coverprofile=coverage.out ./... go tool cover -func=coverage.out +lint: + golangci-lint run + security: gosec -quiet ./... -install: security test +install: security lint test CGO_ENABLED=0 go build -ldflags="-s -w" -o $(GOPATH)/bin/cgapp main.go build: security test diff --git a/README.md b/README.md index f6371e1..8ad6ec0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

Create a new production-ready project with backend (Golang), frontend (JavaScript, TypeScript)
and deploy automation (Ansible, Docker) by running one CLI command.

Focus on writing code and thinking of business-logic! The CLI will take care of the rest.

-

cli version go version go cover go report license

+

cli version go version go cover go report license

## ⚡️ Quick start diff --git a/cmd/create.go b/cmd/create.go index b92154d..e62d2f0 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -1,27 +1,7 @@ -/* -Package cmd includes all of the Create Go App CLI commands. +// Copyright 2019-present Vic Shóstak. All rights reserved. +// Use of this source code is governed by Apache 2.0 license +// that can be found in the LICENSE file. -Create a new production-ready project with backend (Golang), -frontend (JavaScript, TypeScript) and deploy automation -(Ansible, Docker) by running one CLI command. - --> Focus on writing code and thinking of business logic! -<- The Create Go App CLI will take care of the rest. - -Copyright © 2019-present Vic Shóstak (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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ package cmd import ( diff --git a/cmd/deploy.go b/cmd/deploy.go index a58503a..98478bc 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -1,27 +1,7 @@ -/* -Package cmd includes all of the Create Go App CLI commands. +// Copyright 2019-present Vic Shóstak. All rights reserved. +// Use of this source code is governed by Apache 2.0 license +// that can be found in the LICENSE file. -Create a new production-ready project with backend (Golang), -frontend (JavaScript, TypeScript) and deploy automation -(Ansible, Docker) by running one CLI command. - --> Focus on writing code and thinking of business logic! -<- The Create Go App CLI will take care of the rest. - -Copyright © 2019-present Vic Shóstak (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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ package cmd import ( diff --git a/cmd/init.go b/cmd/init.go index f0eeecb..d7d52f3 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -1,27 +1,7 @@ -/* -Package cmd includes all of the Create Go App CLI commands. +// Copyright 2019-present Vic Shóstak. All rights reserved. +// Use of this source code is governed by Apache 2.0 license +// that can be found in the LICENSE file. -Create a new production-ready project with backend (Golang), -frontend (JavaScript, TypeScript) and deploy automation -(Ansible, Docker) by running one CLI command. - --> Focus on writing code and thinking of business logic! -<- The Create Go App CLI will take care of the rest. - -Copyright © 2019-present Vic Shóstak (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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ package cmd import ( diff --git a/cmd/root.go b/cmd/root.go index e9de94d..b884e62 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,27 +1,7 @@ -/* -Package cmd includes all of the Create Go App CLI commands. +// Copyright 2019-present Vic Shóstak. All rights reserved. +// Use of this source code is governed by Apache 2.0 license +// that can be found in the LICENSE file. -Create a new production-ready project with backend (Golang), -frontend (JavaScript, TypeScript) and deploy automation -(Ansible, Docker) by running one CLI command. - --> Focus on writing code and thinking of business logic! -<- The Create Go App CLI will take care of the rest. - -Copyright © 2019-present Vic Shóstak (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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ package cmd import ( @@ -35,15 +15,15 @@ import ( ) var ( - useConfigFile bool // indicate using config (from $PWD/.cgapp.yml) - projectConfig map[string]interface{} // parse project config - rolesConfig map[string]interface{} // parse Ansible roles config - backend, frontend, webserver, database string // define project variables - installAnsibleRoles, askBecomePass bool // install Ansible roles, ask become pass - username, host, network, port string // define deploy variables - playbook string = "deploy-playbook.yml" // default Ansible playbook - createAnswers registry.CreateAnswers // define answers variable for `create` command - deployAnswers registry.DeployAnswers // define answers variable for `deploy` command + useConfigFile bool // indicate using config (from $PWD/.cgapp.yml) + projectConfig map[string]interface{} // parse project config + rolesConfig map[string]interface{} // parse Ansible roles config + backend, frontend, webserver string // define project variables + installAnsibleRoles, askBecomePass bool // install Ansible roles, ask become pass + username, host, network, port string // define deploy variables + playbook string = "deploy-playbook.yml" // default Ansible playbook + createAnswers registry.CreateAnswers // define answers variable for `create` command + deployAnswers registry.DeployAnswers // define answers variable for `deploy` command // Config for survey icons and colors. // See: https://github.com/mgutz/ansi#style-format diff --git a/main.go b/main.go index 6a4b36c..e243e8b 100644 --- a/main.go +++ b/main.go @@ -10,7 +10,7 @@ frontend (JavaScript, TypeScript) and deploy automation A helpful documentation and next steps -> https://create-go.app/ -Copyright © 2019-present Vic Shóstak (https://1wa.co) +Copyright (c) 2019-present Vic Shóstak (https://shostak.dev) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/cgapp/create.go b/pkg/cgapp/create.go index 29947a7..307b66a 100644 --- a/pkg/cgapp/create.go +++ b/pkg/cgapp/create.go @@ -1,29 +1,7 @@ -/* -Package cgapp includes a powerful CLI for the Create Go App project. +// Copyright 2019-present Vic Shóstak. All rights reserved. +// Use of this source code is governed by Apache 2.0 license +// that can be found in the LICENSE file. -Create a new production-ready project with backend (Golang), -frontend (JavaScript, TypeScript) and deploy automation -(Ansible, Docker) by running one CLI command. - --> Focus on writing code and thinking of business logic! -<- The Create Go App CLI will take care of the rest. - -A helpful documentation and next steps -> https://create-go.app/ - -Copyright © 2019-present Vic Shóstak (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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ package cgapp import ( @@ -121,14 +99,12 @@ func CreateProjectFromCmd(p *registry.Project, c map[string]*registry.Command, m if len(project) > 1 { options = []string{create, folder, args["template"], "cra-template-" + project[1]} } - break case "preact": // preact create [template] [dest] [args...] options = []string{create, "default", p.Type, args["cwd"], p.RootFolder, args["name"], "cgapp"} if len(project) > 1 { options = []string{create, project[1], p.Type, args["cwd"], p.RootFolder, args["name"], "cgapp"} } - break case "vue": // vue create [options] options = []string{create, "--default", "--bare", p.Type} @@ -138,22 +114,18 @@ func CreateProjectFromCmd(p *registry.Project, c map[string]*registry.Command, m if len(project) == 3 { options = []string{create, "--preset", project[1] + ":" + project[2], "--bare", "--clone", p.Type} } - break case "angular": // ng new [options] options = []string{create, "cgapp", "--defaults", "--routing", "--directory", p.Type} - break case "svelte": // npx degit [template] [dest] options = []string{create, args["template"], folder} - break case "sapper": // npx degit [template] [dest] options = []string{create, args["template"] + "#rollup", folder} if len(project) > 1 { options = []string{create, args["template"] + "#" + project[1], folder} } - break } // Run execution command. diff --git a/pkg/cgapp/exec.go b/pkg/cgapp/exec.go index a4b8298..ecb562c 100644 --- a/pkg/cgapp/exec.go +++ b/pkg/cgapp/exec.go @@ -1,29 +1,7 @@ -/* -Package cgapp includes a powerful CLI for the Create Go App project. +// Copyright 2019-present Vic Shóstak. All rights reserved. +// Use of this source code is governed by Apache 2.0 license +// that can be found in the LICENSE file. -Create a new production-ready project with backend (Golang), -frontend (JavaScript, TypeScript) and deploy automation -(Ansible, Docker) by running one CLI command. - --> Focus on writing code and thinking of business logic! -<- The Create Go App CLI will take care of the rest. - -A helpful documentation and next steps -> https://create-go.app/ - -Copyright © 2019-present Vic Shóstak (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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ package cgapp import ( diff --git a/pkg/cgapp/files.go b/pkg/cgapp/files.go index 7c6855e..86903b8 100644 --- a/pkg/cgapp/files.go +++ b/pkg/cgapp/files.go @@ -1,29 +1,7 @@ -/* -Package cgapp includes a powerful CLI for the Create Go App project. +// Copyright 2019-present Vic Shóstak. All rights reserved. +// Use of this source code is governed by Apache 2.0 license +// that can be found in the LICENSE file. -Create a new production-ready project with backend (Golang), -frontend (JavaScript, TypeScript) and deploy automation -(Ansible, Docker) by running one CLI command. - --> Focus on writing code and thinking of business logic! -<- The Create Go App CLI will take care of the rest. - -A helpful documentation and next steps -> https://create-go.app/ - -Copyright © 2019-present Vic Shóstak (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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ package cgapp import ( diff --git a/pkg/cgapp/git.go b/pkg/cgapp/git.go index c4eb5e1..2949689 100644 --- a/pkg/cgapp/git.go +++ b/pkg/cgapp/git.go @@ -1,29 +1,7 @@ -/* -Package cgapp includes a powerful CLI for the Create Go App project. +// Copyright 2019-present Vic Shóstak. All rights reserved. +// Use of this source code is governed by Apache 2.0 license +// that can be found in the LICENSE file. -Create a new production-ready project with backend (Golang), -frontend (JavaScript, TypeScript) and deploy automation -(Ansible, Docker) by running one CLI command. - --> Focus on writing code and thinking of business logic! -<- The Create Go App CLI will take care of the rest. - -A helpful documentation and next steps -> https://create-go.app/ - -Copyright © 2019-present Vic Shóstak (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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ package cgapp import "github.com/go-git/go-git/v5" diff --git a/pkg/cgapp/utils.go b/pkg/cgapp/utils.go index 737b9dd..ace48c0 100644 --- a/pkg/cgapp/utils.go +++ b/pkg/cgapp/utils.go @@ -1,29 +1,7 @@ -/* -Package cgapp includes a powerful CLI for the Create Go App project. +// Copyright 2019-present Vic Shóstak. All rights reserved. +// Use of this source code is governed by Apache 2.0 license +// that can be found in the LICENSE file. -Create a new production-ready project with backend (Golang), -frontend (JavaScript, TypeScript) and deploy automation -(Ansible, Docker) by running one CLI command. - --> Focus on writing code and thinking of business logic! -<- The Create Go App CLI will take care of the rest. - -A helpful documentation and next steps -> https://create-go.app/ - -Copyright © 2019-present Vic Shóstak (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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ package cgapp import ( @@ -47,19 +25,14 @@ func BeautifyText(text, color string) string { switch color { case "": textColor = noColor - break case "green": textColor = green - break case "yellow": textColor = yellow - break case "red": textColor = red - break case "cyan": textColor = cyan - break } // Send common or colored text. diff --git a/pkg/cgapp/utils_test.go b/pkg/cgapp/utils_test.go index c1d974c..e0907bf 100644 --- a/pkg/cgapp/utils_test.go +++ b/pkg/cgapp/utils_test.go @@ -53,7 +53,7 @@ func TestBeautifyText(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - BeautifyText(tt.args.text, tt.args.color) + _ = BeautifyText(tt.args.text, tt.args.color) }) } } diff --git a/pkg/registry/defaults.go b/pkg/registry/defaults.go index 502e7ae..e0b399f 100644 --- a/pkg/registry/defaults.go +++ b/pkg/registry/defaults.go @@ -1,29 +1,7 @@ -/* -Package registry includes available repositories & commands for the Create Go App CLI. +// Copyright 2019-present Vic Shóstak. All rights reserved. +// Use of this source code is governed by Apache 2.0 license +// that can be found in the LICENSE file. -Create a new production-ready project with backend (Golang), -frontend (JavaScript, TypeScript) and deploy automation -(Ansible, Docker) by running one CLI command. - --> Focus on writing code and thinking of business logic! -<- The Create Go App CLI will take care of the rest. - -A helpful documentation and next steps -> https://create-go.app/ - -Copyright © 2019-present Vic Shóstak (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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ package registry import ( @@ -34,7 +12,7 @@ import ( const ( // CLIVersion version of Create Go App CLI. - CLIVersion = "1.7.4" + CLIVersion = "1.7.5" // RegexpAnsiblePattern pattern for Ansible roles. RegexpAnsiblePattern = "^(deploy)$" // RegexpBackendPattern pattern for backend. From bc8ed727b65db47d7d9a5f81ae61922888c32db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vic=20Sh=C3=B3stak?= Date: Sun, 18 Apr 2021 18:24:09 +0300 Subject: [PATCH 2/3] Fix GH Action --- .github/FUNDING.yml | 1 + .github/workflows/golangci_lint.yml | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 7ea8eb5..d4d2b9e 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,4 +1,5 @@ # These are supported funding model platforms +github: create-go-app patreon: koddr custom: https://paypal.me/koddr diff --git a/.github/workflows/golangci_lint.yml b/.github/workflows/golangci_lint.yml index 03accf5..caf86f9 100644 --- a/.github/workflows/golangci_lint.yml +++ b/.github/workflows/golangci_lint.yml @@ -12,12 +12,7 @@ jobs: golangci: name: Linting Go code - strategy: - matrix: - go-version: [1.16.x] - os: [ubuntu-latest, macos-latest, windows-latest] - - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From f9fb60025d362d7d4e264324bda04c11f750300a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vic=20Sh=C3=B3stak?= Date: Sun, 18 Apr 2021 18:28:17 +0300 Subject: [PATCH 3/3] Update FUNDING.yml --- .github/FUNDING.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index d4d2b9e..7ea8eb5 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,5 +1,4 @@ # These are supported funding model platforms -github: create-go-app patreon: koddr custom: https://paypal.me/koddr