Skip to content

Commit

Permalink
feat: Add basic PR comment generation
Browse files Browse the repository at this point in the history
  • Loading branch information
DanThePutzer committed Mar 9, 2022
1 parent 48d0a4d commit 7031a39
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
3 changes: 1 addition & 2 deletions app/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"os"

"pluralith/pkg/auxiliary"
"pluralith/pkg/ux"

"github.com/fatih/color"
Expand Down Expand Up @@ -40,7 +39,7 @@ var rootCmd = &cobra.Command{
Long: longText,
Run: func(cmd *cobra.Command, args []string) {
ux.PrintHead()
auxiliary.LaunchPluralith()
// auxiliary.LaunchPluralith()
},
}

Expand Down
1 change: 1 addition & 0 deletions app/pkg/auxiliary/State.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"pluralith/pkg/ci"

"runtime"
"strings"
)
Expand Down
18 changes: 18 additions & 0 deletions app/pkg/ci/GeneratePRComment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ci

import (
"fmt"
)

func GeneratePRComment(urls map[string]string) (string, error) {
var comment string = ""

// Generate Head
comment += "## 📝 Pluralith Diagram Generated \n\n"

// Generate Body
comment += fmt.Sprintf("![Pluralith Diagram](%s) \n", urls["PNG"])
comment += fmt.Sprintf("### View the [PDF](%s) \n", urls["PDF"])

return comment, nil
}
14 changes: 6 additions & 8 deletions app/pkg/graph/HostExport.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@ import (
"pluralith/pkg/auxiliary"
)

type ExportURLs struct {
pdf string
png string
}

func HostExport(formFile string) (ExportURLs, error) {
func HostExport(formFile string) (map[string]string, error) {
functionName := "LogExport"

var urls = ExportURLs{}
var urls = make(map[string]string)

// Open form file
diagramExport, openErr := os.Open(formFile)
Expand Down Expand Up @@ -86,6 +81,9 @@ func HostExport(formFile string) (ExportURLs, error) {
return urls, fmt.Errorf("parsing response failed -> %v: %w", functionName, responseErr)
}

urls = bodyObject["data"].(ExportURLs)
dataObject := bodyObject["data"].(map[string]interface{})

urls["PDF"] = dataObject["pdfURL"].(string) // = bodyObject["data"].(structs.ExportURLs)
urls["PNG"] = dataObject["pngURL"].(string)
return urls, nil
}

0 comments on commit 7031a39

Please sign in to comment.