diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b91ef82..a4d428f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,2 @@ * @TeoDev1611 -*.go @Polibov +*.go @SantiagoVA diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index eb4bfe6..aca522a 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -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: diff --git a/.github/issue-close-app.yml b/.github/issue-close-app.yml index 996e6b4..e865feb 100644 --- a/.github/issue-close-app.yml +++ b/.github/issue-close-app.yml @@ -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. + diff --git a/cmd/doc.go b/cmd/doc.go index 671d486..b19a1b4 100644 --- a/cmd/doc.go +++ b/cmd/doc.go @@ -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 ( @@ -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 { diff --git a/cmd/packages.go b/cmd/packages.go index 3ccde17..c985323 100644 --- a/cmd/packages.go +++ b/cmd/packages.go @@ -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" ) diff --git a/cmd/search.go b/cmd/search.go index e3e310d..4c0c296 100644 --- a/cmd/search.go +++ b/cmd/search.go @@ -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" ) diff --git a/core/config/configFile.go b/core/config/configFile.go index 1c02d2e..dd76340 100644 --- a/core/config/configFile.go +++ b/core/config/configFile.go @@ -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", diff --git a/core/doc-generator/generator.go b/core/doc-generator/generator.go new file mode 100644 index 0000000..4de54d2 --- /dev/null +++ b/core/doc-generator/generator.go @@ -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") +} diff --git a/utils/functions/packages/delete.go b/core/packages/delete.go similarity index 100% rename from utils/functions/packages/delete.go rename to core/packages/delete.go diff --git a/utils/functions/packages/get.go b/core/packages/get.go similarity index 95% rename from utils/functions/packages/get.go rename to core/packages/get.go index 149ad4e..1a06ba1 100644 --- a/utils/functions/packages/get.go +++ b/core/packages/get.go @@ -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 diff --git a/utils/functions/packages/models.go b/core/packages/models.go similarity index 100% rename from utils/functions/packages/models.go rename to core/packages/models.go diff --git a/utils/functions/packages/post.go b/core/packages/post.go similarity index 75% rename from utils/functions/packages/post.go rename to core/packages/post.go index 242ac42..2f91306 100644 --- a/utils/functions/packages/post.go +++ b/core/packages/post.go @@ -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() diff --git a/utils/functions/packages/put.go b/core/packages/put.go similarity index 97% rename from utils/functions/packages/put.go rename to core/packages/put.go index e8cb3de..10c7014 100644 --- a/utils/functions/packages/put.go +++ b/core/packages/put.go @@ -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() diff --git a/utils/functions/errors.go b/utils/functions/errors.go index 857026a..11b8d7c 100644 --- a/utils/functions/errors.go +++ b/utils/functions/errors.go @@ -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