Skip to content

Commit

Permalink
Merge pull request #26 from TeoDev1611/main
Browse files Browse the repository at this point in the history
Change the actions and the code owners, fix the doc generator and modularize the gen command and add support for viper
  • Loading branch information
TeoDev1611 authored May 31, 2021
2 parents ff07f51 + 41d5e05 commit 8ce8da9
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
* @TeoDev1611
*.go @Polibov
*.go @SantiagoVA
5 changes: 1 addition & 4 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates


version: 2
updates:
Expand Down
39 changes: 14 additions & 25 deletions .github/issue-close-app.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
# Comment that will be sent if an issue is judged to be closed.
comment: "This issue is closed because it does not meet our issue template. Please read it."

comment: "This issue is closed by the Bot check the issue template for the issue not close."
issueConfigs:
# There can be several configs for different kind of issues.
- content:
# Example 1: bug report
- "Expected Behavior"
- "Current Behavior"
- "Steps to Reproduce"
- "Detailed Description"
# Template: bug report
- "Describe the bug"
- "To Reproduce"
- "Desktop (please complete the following information):"
- "Additional context"
- content:
# Example 2: feature request
- "Motivation / Use Case"
- "Expected Behavior"
- "Other Information"
# Optional configuration:
#
# whether the keywords are case-insensitive
# default value is false, which means keywords are case-sensitive
caseInsensitive: false
# the label that will be added when the bot close an issue
# The bot will only add a label if this property is set.
# Template: feature request
- "Is your feature request related to a problem? Please describe."
- "Describe the solution you'd like"
- "Describe alternatives you've considered"
- Additional context
caseInsensitive: true
label: "closed by bot"
# The bot will ignore any issues that are opened or reopened by the user names in exception
exception:
- "username1"
- "username2"
# The issue is judged to be legal if it includes all keywords from any of these two configs.
# Or it will be closed by the app.

5 changes: 2 additions & 3 deletions cmd/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ limitations under the License.
package cmd

import (
docGen "github.com/Moldy-Community/moldy/core/doc-generator"
"github.com/Moldy-Community/moldy/utils/functions"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

var (
Expand All @@ -39,8 +39,7 @@ This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
if generateFlg {
err := doc.GenMarkdownTree(rootCmd, "./moldyDoc")
functions.CheckErrors(err, "Code 2", "Error in generate the documentation for moldy", "Report the error on github or re run with sudo")
docGen.GenDocTree(rootCmd)
} else if openFlg {
functions.OpenBrowser("https://moldybook.netlify.app/")
} else if contribFlg {
Expand Down
2 changes: 1 addition & 1 deletion cmd/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ limitations under the License.
package cmd

import (
"github.com/Moldy-Community/moldy/core/packages"
"github.com/Moldy-Community/moldy/utils/colors"
"github.com/Moldy-Community/moldy/utils/functions/packages"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/Moldy-Community/moldy/utils/functions/packages"
"github.com/Moldy-Community/moldy/core/packages"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion core/config/configFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
/* Add the default values, paths, aliases and config name and type */
var (
defaults = map[string]interface{}{
"moldyPackages": map[string]string{
"moldyPackageInfo": map[string]string{
"name": "none",
"version": "none",
"author": "Example Author",
Expand Down
32 changes: 32 additions & 0 deletions core/doc-generator/generator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package docgenerator

import (
"bytes"
"os"

"github.com/Moldy-Community/moldy/utils/functions"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

func moldyDocFolder() {
_, err := os.Stat("moldyDoc")

if os.IsNotExist(err) {
errDir := os.MkdirAll("moldyDoc", 0755)
functions.CheckErrors(errDir, "Code 2", "Error in create the moldyDoc folder", "Report the error on github or re run with sudo")
}
}

func GenDocTree(cmd *cobra.Command) {
moldyDocFolder()
errDoc := doc.GenMarkdownTree(cmd, "./moldyDoc")
functions.CheckErrors(errDoc, "Code 2", "Error in generate the documentation for moldy", "Report the error on github or re run with sudo")
}

func DocCommand(cmd *cobra.Command) {
moldyDocFolder()
out := new(bytes.Buffer)
err := doc.GenMarkdown(cmd, out)
functions.CheckErrors(err, "Code 2", "Error in print out the doc for the command", "Report the error on github or re run with sudo")
}
File renamed without changes.
2 changes: 1 addition & 1 deletion utils/functions/packages/get.go → core/packages/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func GetId(id string) (getOne, error) {
}

if dataStruct.Error {
return dataStruct, errors.New("Not data found")
return dataStruct, errors.New("not data found")
}

return dataStruct, nil
Expand Down
File renamed without changes.
16 changes: 9 additions & 7 deletions utils/functions/packages/post.go → core/packages/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ import (
"github.com/Moldy-Community/moldy/utils/colors"
"github.com/Moldy-Community/moldy/utils/functions"
"github.com/go-resty/resty/v2"
"github.com/spf13/viper"
)

func Create() (getOne, error) {
var dataStruct getOne
name := terminal.BasicPrompt("Name", "")
author := terminal.BasicPrompt("Author", "")
url := terminal.BasicPrompt("URL", "")
description := terminal.BasicPrompt("Description", "")
version := terminal.BasicPrompt("Version", "")
password := terminal.PasswordPrompt("Password")
name := viper.GetString("moldyPackageInfo.name")
author := viper.GetString("moldyPackageInfo.author")
url := viper.GetString("moldyPackageInfo.url")
description := viper.GetString("moldyPackageInfo.description")
version := viper.GetString("moldyPackageInfo.version")
colors.Info("All information successfully obtained from MoldyFile.toml")
password := terminal.PasswordPrompt("Password for the package save in a safe place")

if name == "" || author == "" || url == "" || description == "" || version == "" || password == "" {
colors.Warn("Fill all blanks")
return dataStruct, errors.New("Fill all blanks")
return dataStruct, errors.New("fill all blanks")
}

client := resty.New()
Expand Down
2 changes: 1 addition & 1 deletion utils/functions/packages/put.go → core/packages/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Update(id string) (getOne, error) {

if name == "" || author == "" || url == "" || description == "" || version == "" || password == "" || newPassword == "" {
colors.Warn("Fill all blanks")
return dataStruct, errors.New("Fill all blanks")
return dataStruct, errors.New("fill all blanks")
}

client := resty.New()
Expand Down
4 changes: 3 additions & 1 deletion utils/functions/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ THE SOFTWARE.
package functions

import (
"fmt"
"log"

"github.com/Moldy-Community/moldy/utils/colors"
)

func CheckErrors(err error, code, msg, solution string) {

if err != nil {
colors.Error("NEW ERROR DETECTED \n")
colors.Info("COMPLETE ERROR BELLOW \n")
fmt.Println(err)
log.Fatalf(`
MSG: %v
CODE: %v
Expand Down

0 comments on commit 8ce8da9

Please sign in to comment.