Skip to content

Commit

Permalink
Fix gosec & go-critic issues; Update copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
koddr committed Feb 14, 2022
1 parent f678f4a commit 9182155
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# These are supported funding model platforms

patreon: koddr
liberapay: koddr
custom: ["https://www.producthunt.com/posts/create-go-app", "https://paypal.me/koddr"]
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<h1 align="center">
<img src="https://raw.githubusercontent.com/create-go-app/cli/master/.github/images/cgapp_logo%402x.png" width="224px"/><br/>
<img alt="cgapp logo" src="https://raw.githubusercontent.com/create-go-app/cli/master/.
github/images/cgapp_logo%402x.png" 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</b> code and <b>thinking</b> of business-logic! The CLI will take care of the rest.</p>

<p align="center"><a href="https://pkg.go.dev/github.com/create-go-app/cli/v3?tab=doc" target="_blank"><img src="https://img.shields.io/badge/Go-1.17+-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-88.4%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://pkg.go.dev/github.com/create-go-app/cli/v3?tab=doc"
target="_blank"><img src="https://img.shields.io/badge/Go-1.17+-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-88.3%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

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

> If you're looking for the **Create Go App CLI** for Go `1.16`, you can find it [here](https://github.com/create-go-app/cli/tree/v2).
Expand Down Expand Up @@ -67,7 +69,7 @@ cgapp create [OPTION]
```

| Option | Description | Type | Default | Required? |
| ------ | -------------------------------------------------------- | ------ | ------- | --------- |
|--------|----------------------------------------------------------|--------|---------|-----------|
| `-t` | Enables to define custom backend and frontend templates. | `bool` | `false` | No |

![cgapp_create](https://user-images.githubusercontent.com/11155743/116796937-38160080-aae9-11eb-8e21-fb1be2750aa4.gif)
Expand All @@ -86,7 +88,7 @@ cgapp deploy [OPTION]
```

| Option | Description | Type | Default | Required? |
| ------ | ------------------------------------------------------------------------------------------------------ | ------ | ------- | --------- |
|--------|--------------------------------------------------------------------------------------------------------|--------|---------|-----------|
| `-k` | Prompt you to provide the remote user sudo password (_a standard Ansible `--ask-become-pass` option_). | `bool` | `false` | No |

![cgapp_deploy](https://user-images.githubusercontent.com/11155743/116796941-3c421e00-aae9-11eb-9575-d72550814d7a.gif)
Expand Down
2 changes: 1 addition & 1 deletion cmd/cgapp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ frontend (JavaScript, TypeScript) and deploy automation
A helpful documentation and next steps -> https://create-go.app/
Copyright (c) 2019-present Vic Shóstak <[email protected]> (https://shostak.dev)
Copyright 2022 Vic Shóstak and Create Go App Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions cmd/create.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-present Vic Shóstak. All rights reserved.
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
// Use of this source code is governed by Apache 2.0 license
// that can be found in the LICENSE file.

Expand Down Expand Up @@ -117,7 +117,7 @@ func runCreateCmd(cmd *cobra.Command, args []string) error {
if frontend == "next-ts" {
isTypeScript = "--typescript"
}

// Create a default frontend template with Next.js (React).
if err := cgapp.ExecCommand(
"npx", []string{"create-next-app@latest", "frontend", isTypeScript}, true,
Expand Down
2 changes: 1 addition & 1 deletion cmd/deploy.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-present Vic Shóstak. All rights reserved.
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
// Use of this source code is governed by Apache 2.0 license
// that can be found in the LICENSE file.

Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-present Vic Shóstak. All rights reserved.
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
// Use of this source code is governed by Apache 2.0 license
// that can be found in the LICENSE file.

Expand Down
2 changes: 1 addition & 1 deletion pkg/cgapp/exec.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-present Vic Shóstak. All rights reserved.
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
// Use of this source code is governed by Apache 2.0 license
// that can be found in the LICENSE file.

Expand Down
20 changes: 15 additions & 5 deletions pkg/cgapp/files.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-present Vic Shóstak. All rights reserved.
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
// Use of this source code is governed by Apache 2.0 license
// that can be found in the LICENSE file.

Expand Down Expand Up @@ -69,14 +69,24 @@ func CopyFromEmbeddedFS(efs *EmbeddedFileSystem) error {

// GenerateFileFromTemplate func to generate files from templates.
func GenerateFileFromTemplate(fileName string, variables map[string]interface{}) error {
// Checking file name.
if fileName == "" {
return ShowError(
fmt.Sprintf("Not correct or empty file name (given: `%s`)!", fileName),
)
}

// Clean file name.
cleanFileName := filepath.Clean(fileName)

// Parse template.
tmpl, errParseFiles := template.ParseFiles(fileName)
tmpl, errParseFiles := template.ParseFiles(cleanFileName)
if errParseFiles != nil {
return ShowError(errParseFiles.Error())
}

// Create a new file with template data.
file, errCreate := os.Create(fileName)
file, errCreate := os.Create(cleanFileName)
if errCreate != nil {
return ShowError(errCreate.Error())
}
Expand All @@ -88,8 +98,8 @@ func GenerateFileFromTemplate(fileName string, variables map[string]interface{})
_ = file.Close()

// Rename output file.
newFileName := strings.ReplaceAll(fileName, ".tmpl", "")
if errRename := os.Rename(fileName, newFileName); errRename != nil {
newFileName := strings.ReplaceAll(cleanFileName, ".tmpl", "")
if errRename := os.Rename(cleanFileName, newFileName); errRename != nil {
return ShowError(errRename.Error())
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/cgapp/git.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-present Vic Shóstak. All rights reserved.
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
// Use of this source code is governed by Apache 2.0 license
// that can be found in the LICENSE file.

Expand Down Expand Up @@ -47,11 +47,12 @@ func GitClone(templateType, templateURL string) error {
return nil
}

// getAbsolutURL func for help define correct HTTP protocol.
func getAbsoluteURL(templateURL string) string {
templateURL = strings.TrimSpace(templateURL)
u, _ := url.Parse(templateURL)

if len(u.Scheme) == 0 {
if u.Scheme == "" {
u.Scheme = "https"
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cgapp/utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-present Vic Shóstak. All rights reserved.
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
// Use of this source code is governed by Apache 2.0 license
// that can be found in the LICENSE file.

Expand Down
4 changes: 2 additions & 2 deletions pkg/registry/defaults.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-present Vic Shóstak. All rights reserved.
// Copyright 2022 Vic Shóstak and Create Go App Contributors. All rights reserved.
// Use of this source code is governed by Apache 2.0 license
// that can be found in the LICENSE file.

Expand All @@ -11,7 +11,7 @@ import (
)

// CLIVersion version of Create Go App CLI.
const CLIVersion string = "3.5.0"
const CLIVersion string = "3.6.0"

// Variables struct for Ansible variables (inventory, hosts).
type Variables struct {
Expand Down

0 comments on commit 9182155

Please sign in to comment.