diff --git a/cmd/substreams/auth.go b/cmd/substreams/auth.go index fc7cb49a..9c089b4b 100644 --- a/cmd/substreams/auth.go +++ b/cmd/substreams/auth.go @@ -7,7 +7,6 @@ import ( "strings" "github.com/charmbracelet/huh" - "github.com/charmbracelet/lipgloss" "github.com/spf13/cobra" ) @@ -27,11 +26,10 @@ func runAuthE(cmd *cobra.Command, args []string) error { fmt.Println("Open this link to authenticate on The Graph Market:") fmt.Println() - linkStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("12")) if localDevelopment == "true" { - fmt.Println(" " + linkStyle.Render("http://localhost:3000/auth/substreams-devenv")) + fmt.Println(" " + purpleStyle.Render("http://localhost:3000/auth/substreams-devenv")) } else { - fmt.Println(" " + linkStyle.Render("https://thegraph.market/auth/substreams-devenv")) + fmt.Println(" " + purpleStyle.Render("https://thegraph.market/auth/substreams-devenv")) } fmt.Println("") @@ -69,7 +67,7 @@ func runAuthE(cmd *cobra.Command, args []string) error { fmt.Println("Load credentials in current terminal with the following command:") fmt.Println("") - fmt.Println(linkStyle.Render(" . ./.substreams.env")) + fmt.Println(purpleStyle.Render(" . ./.substreams.env")) fmt.Println() return nil diff --git a/cmd/substreams/build.go b/cmd/substreams/build.go index 7ba5fb88..9c0be9a0 100644 --- a/cmd/substreams/build.go +++ b/cmd/substreams/build.go @@ -367,6 +367,7 @@ func findManifest() (string, error) { func runCommandInDir(ctx context.Context, dir string, cmdArgs []string) error { cmd := exec.CommandContext(ctx, cmdArgs[0], cmdArgs[1:]...) cmd.Env = append(os.Environ(), "CARGO_TERM_COLOR=always") + cmd.Env = append(cmd.Env, "CLICOLOR_FORCE=true") cmd.Dir = dir stdoutPipe, err := cmd.StdoutPipe() diff --git a/cmd/substreams/pack.go b/cmd/substreams/pack.go index fc85bd97..997e8a01 100644 --- a/cmd/substreams/pack.go +++ b/cmd/substreams/pack.go @@ -60,6 +60,9 @@ func runPack(cmd *cobra.Command, args []string) error { return fmt.Errorf("reading manifest %q: %w", manifestPath, err) } + warnIncompletePackage(pkgBundle.Package) + printPackageDetails(pkgBundle.Package) + if pkgBundle == nil { return fmt.Errorf("no package found") } diff --git a/cmd/substreams/registry-publish.go b/cmd/substreams/registry-publish.go index eb449353..c3d0fa94 100644 --- a/cmd/substreams/registry-publish.go +++ b/cmd/substreams/registry-publish.go @@ -69,14 +69,8 @@ func runRegistryPublish(cmd *cobra.Command, args []string) (err error) { spkg := pkgBundle.Package - style := lipgloss.NewStyle().Foreground(lipgloss.Color("12")) - headerStyle := lipgloss.NewStyle().Bold(true) - fmt.Println() - fmt.Println(headerStyle.Render("Package Details")) - fmt.Printf("%s: %s\n", style.Render("Name"), spkg.PackageMeta[0].Name) - fmt.Printf("%s: %s\n", style.Render("Version"), spkg.PackageMeta[0].Version) - fmt.Printf("%s: %s\n", style.Render("URL"), spkg.PackageMeta[0].Url) - fmt.Println() + warnIncompletePackage(spkg) + printPackageDetails(spkg) confirm, err := runConfirmForm("Would you like to publish this package?") if err != nil { diff --git a/cmd/substreams/styles.go b/cmd/substreams/styles.go new file mode 100644 index 00000000..3da13d59 --- /dev/null +++ b/cmd/substreams/styles.go @@ -0,0 +1,7 @@ +package main + +import "github.com/charmbracelet/lipgloss" + +var warningStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("11")) +var purpleStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("12")) +var headerStyle = lipgloss.NewStyle().Bold(true) diff --git a/cmd/substreams/utils.go b/cmd/substreams/utils.go index d45e597d..c1b68a23 100644 --- a/cmd/substreams/utils.go +++ b/cmd/substreams/utils.go @@ -3,6 +3,7 @@ package main import ( "fmt" "github.com/spf13/cobra" + pbsubstreams "github.com/streamingfast/substreams/pb/sf/substreams/v1" "strconv" "strings" ) @@ -54,3 +55,38 @@ func readStopBlockFlag(cmd *cobra.Command, startBlock int64, flagName string, wi return endBlock, nil } + +func warnIncompletePackage(spkg *pbsubstreams.Package) { + if len(spkg.PackageMeta) > 0 { + if spkg.PackageMeta[0].Doc == "" { + fmt.Println(warningStyle.Render("Warning: README not found for this package.")) + } + + if spkg.PackageMeta[0].Url == "" { + fmt.Println(warningStyle.Render("Warning: URL is not set for this package.")) + } + + if spkg.PackageMeta[0].Description == "" { + fmt.Println(warningStyle.Render("Warning: Description is not set for this package.")) + } + } + + if spkg.Network == "" { + fmt.Println(warningStyle.Render("Warning: Network is not set for this package.")) + } + + if spkg.Image == nil { + fmt.Println(warningStyle.Render("Warning: Image is not set for this package.")) + } + + fmt.Println() +} + +func printPackageDetails(spkg *pbsubstreams.Package) { + fmt.Println() + fmt.Println(headerStyle.Render("Package Details")) + fmt.Printf("%s: %s\n", purpleStyle.Render("Name"), spkg.PackageMeta[0].Name) + fmt.Printf("%s: %s\n", purpleStyle.Render("Version"), spkg.PackageMeta[0].Version) + fmt.Printf("%s: %s\n", purpleStyle.Render("URL"), spkg.PackageMeta[0].Url) + fmt.Println() +} \ No newline at end of file diff --git a/manifest/package.go b/manifest/package.go index 57f566e7..887e6c88 100644 --- a/manifest/package.go +++ b/manifest/package.go @@ -346,8 +346,9 @@ func (m *Manifest) readFileFromName(filename string) ([]byte, error) { func (r *manifestConverter) convertToPkg(m *Manifest) (pkg *pbsubstreams.Package, err error) { doc := m.Package.Doc if doc != "" { - fmt.Println("Deprecated: the 'package.doc' field is deprecated. The README.md file is picked up instead.") + fmt.Println("Deprecated: the 'package.doc' field is deprecated. The README.md file is picked up instead.\n") } + readmeContent, err := m.readFileFromName("README.md") if err != nil { if !os.IsNotExist(err) { @@ -358,7 +359,6 @@ func (r *manifestConverter) convertToPkg(m *Manifest) (pkg *pbsubstreams.Package if !os.IsNotExist(err) { return nil, fmt.Errorf("reading file: %w", err) } - fmt.Println("Warning: README.md file not found, no documentation will be packaged") err = nil } }