From b3221030b3eace04556815def607222bd35af195 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 6 Oct 2023 14:06:49 +0200 Subject: [PATCH] nits --- .github/workflows/md-link-checker-config.json | 2 +- .gitpod/readme.md | 2 +- changelog.md | 2 +- ignite/cmd/account_create.go | 2 +- ignite/cmd/account_delete.go | 4 +- ignite/cmd/account_export.go | 2 +- ignite/cmd/account_import.go | 3 +- ignite/cmd/plugin.go | 8 +-- ignite/cmd/version.go | 4 +- ignite/internal/tools/gen-cli-docs/main.go | 2 +- .../pkg/cosmosfaucet/openapi/openapi.yml.tmpl | 2 +- ignite/pkg/gacli/gacli.go | 63 ------------------- ignite/pkg/iowait/iowait.go | 30 --------- ignite/pkg/jsondoc/jsondoc.go | 34 ---------- ignite/pkg/looseerrgroup/looseerrgroup.go | 26 -------- ignite/pkg/tendermintlogger/logger.go | 10 --- ignite/pkg/tendermintlogger/logger_test.go | 5 -- ignite/pkg/xstrings/xstrings.go | 14 +---- integration/readme.md | 6 +- scripts/data/gen-protoc/readme.md | 10 +-- scripts/gen-protoc | 4 +- 21 files changed, 26 insertions(+), 209 deletions(-) delete mode 100644 ignite/pkg/gacli/gacli.go delete mode 100644 ignite/pkg/iowait/iowait.go delete mode 100644 ignite/pkg/jsondoc/jsondoc.go delete mode 100644 ignite/pkg/looseerrgroup/looseerrgroup.go delete mode 100644 ignite/pkg/tendermintlogger/logger.go delete mode 100644 ignite/pkg/tendermintlogger/logger_test.go diff --git a/.github/workflows/md-link-checker-config.json b/.github/workflows/md-link-checker-config.json index 8c15416958..fa7f2bde39 100644 --- a/.github/workflows/md-link-checker-config.json +++ b/.github/workflows/md-link-checker-config.json @@ -10,7 +10,7 @@ "pattern": "^https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax" }, { - "pattern": "^https://docs.starport.network" + "pattern": "^https://docs.ignite.com/" }, { "pattern": "^http://localhost" diff --git a/.gitpod/readme.md b/.gitpod/readme.md index 6894ce078e..f8c77c0198 100644 --- a/.gitpod/readme.md +++ b/.gitpod/readme.md @@ -38,7 +38,7 @@ ignite chain serve ## Install Ignite CLI locally -``` +```sh curl https://get.ignite.com/cli | bash ``` diff --git a/changelog.md b/changelog.md index 3d4c238c88..bdbad72161 100644 --- a/changelog.md +++ b/changelog.md @@ -6,7 +6,7 @@ - [#3476](https://github.com/ignite/cli/pull/3476) Use `buf.build` binary to code generate from proto files - [#3614](https://github.com/ignite/cli/pull/3614) feat: use DefaultBaseappOptions for app.New method -- [#3536](https://github.com/ignite/cli/pull/3536) Change app.go to v2 and add AppWiring feature +- [#3553](https://github.com/ignite/cli/pull/3553) Change app.go to v2 and add AppWiring feature ### Changes diff --git a/ignite/cmd/account_create.go b/ignite/cmd/account_create.go index e0febdc74b..adcedeef1b 100644 --- a/ignite/cmd/account_create.go +++ b/ignite/cmd/account_create.go @@ -35,6 +35,6 @@ func accountCreateHandler(cmd *cobra.Command, args []string) error { return fmt.Errorf("unable to create account: %w", err) } - fmt.Printf("Account %q created, keep your mnemonic in a secret place:\n\n%s\n", name, mnemonic) + cmd.Printf("Account %q created, keep your mnemonic in a secret place:\n\n%s\n", name, mnemonic) return nil } diff --git a/ignite/cmd/account_delete.go b/ignite/cmd/account_delete.go index f999f86955..bc07004fbe 100644 --- a/ignite/cmd/account_delete.go +++ b/ignite/cmd/account_delete.go @@ -1,8 +1,6 @@ package ignitecmd import ( - "fmt" - "github.com/spf13/cobra" "github.com/ignite/cli/ignite/pkg/cosmosaccount" @@ -34,6 +32,6 @@ func accountDeleteHandler(cmd *cobra.Command, args []string) error { return err } - fmt.Printf("Account %s deleted.\n", name) + cmd.Printf("Account %s deleted.\n", name) return nil } diff --git a/ignite/cmd/account_export.go b/ignite/cmd/account_export.go index 3436bc13c9..8a36b8f479 100644 --- a/ignite/cmd/account_export.go +++ b/ignite/cmd/account_export.go @@ -64,6 +64,6 @@ func accountExportHandler(cmd *cobra.Command, args []string) error { return err } - fmt.Printf("Account %q exported to file: %s\n", name, path) + cmd.Printf("Account %q exported to file: %s\n", name, path) return nil } diff --git a/ignite/cmd/account_import.go b/ignite/cmd/account_import.go index 762bf8b46c..dd77f212b6 100644 --- a/ignite/cmd/account_import.go +++ b/ignite/cmd/account_import.go @@ -2,7 +2,6 @@ package ignitecmd import ( "errors" - "fmt" "os" "github.com/cosmos/go-bip39" @@ -71,6 +70,6 @@ func accountImportHandler(cmd *cobra.Command, args []string) error { return err } - fmt.Printf("Account %q imported.\n", name) + cmd.Printf("Account %q imported.\n", name) return nil } diff --git a/ignite/cmd/plugin.go b/ignite/cmd/plugin.go index f93e7a39f8..128406f1e7 100644 --- a/ignite/cmd/plugin.go +++ b/ignite/cmd/plugin.go @@ -212,7 +212,7 @@ func linkPluginHook(rootCmd *cobra.Command, p *plugin.Plugin, hook plugin.Hook) if err != nil { err := p.Interface.ExecuteHookCleanUp(newExecutedHook(hook, cmd, args)) if err != nil { - fmt.Printf("plugin %q ExecuteHookCleanUp() error: %v", p.Path, err) + cmd.Printf("plugin %q ExecuteHookCleanUp() error: %v", p.Path, err) } } return err @@ -229,7 +229,7 @@ func linkPluginHook(rootCmd *cobra.Command, p *plugin.Plugin, hook plugin.Hook) defer func() { err := p.Interface.ExecuteHookCleanUp(execHook) if err != nil { - fmt.Printf("plugin %q ExecuteHookCleanUp() error: %v", p.Path, err) + cmd.Printf("plugin %q ExecuteHookCleanUp() error: %v", p.Path, err) } }() @@ -388,7 +388,7 @@ func NewPluginUpdate() *cobra.Command { if err != nil { return err } - fmt.Printf("All plugins updated.\n") + cmd.Println("All plugins updated.") return nil } // find the plugin to update @@ -398,7 +398,7 @@ func NewPluginUpdate() *cobra.Command { if err != nil { return err } - fmt.Printf("Plugin %q updated.\n", p.Path) + cmd.Printf("Plugin %q updated.\n", p.Path) return nil } } diff --git a/ignite/cmd/version.go b/ignite/cmd/version.go index 62e74a2238..ed65f8013f 100644 --- a/ignite/cmd/version.go +++ b/ignite/cmd/version.go @@ -1,8 +1,6 @@ package ignitecmd import ( - "fmt" - "github.com/spf13/cobra" "github.com/ignite/cli/ignite/version" @@ -14,7 +12,7 @@ func NewVersion() *cobra.Command { Use: "version", Short: "Print the current build information", Run: func(cmd *cobra.Command, _ []string) { - fmt.Println(version.Long(cmd.Context())) + cmd.Println(version.Long(cmd.Context())) }, } return c diff --git a/ignite/internal/tools/gen-cli-docs/main.go b/ignite/internal/tools/gen-cli-docs/main.go index 56ead1c6df..d8d9fbf123 100644 --- a/ignite/internal/tools/gen-cli-docs/main.go +++ b/ignite/internal/tools/gen-cli-docs/main.go @@ -104,7 +104,7 @@ func generateCmd(cmd *cobra.Command, w io.Writer) error { } // here we change sub titles to bold styling. Otherwise, these titles will get - // printed in the right menu of docs.starport.network which is unpleasant because + // printed in the right menu of docs.ignite.com which is unpleasant because // we only want to see a list of all available commands without the extra noise. sc := bufio.NewScanner(b) for sc.Scan() { diff --git a/ignite/pkg/cosmosfaucet/openapi/openapi.yml.tmpl b/ignite/pkg/cosmosfaucet/openapi/openapi.yml.tmpl index 384c2b6609..e24875af0a 100644 --- a/ignite/pkg/cosmosfaucet/openapi/openapi.yml.tmpl +++ b/ignite/pkg/cosmosfaucet/openapi/openapi.yml.tmpl @@ -57,5 +57,5 @@ definitions: externalDocs: - description: "Find out more about Starport" + description: "Find out more about Ignite CLI" url: "https://github.com/ignite/cli/tree/develop/docs" diff --git a/ignite/pkg/gacli/gacli.go b/ignite/pkg/gacli/gacli.go deleted file mode 100644 index 0488a49715..0000000000 --- a/ignite/pkg/gacli/gacli.go +++ /dev/null @@ -1,63 +0,0 @@ -// Package gacli is a client for Google Analytics to send data points for hint-type=event. -package gacli - -import ( - "net/http" - "net/url" -) - -const ( - endpoint = "https://www.google-analytics.com/collect" -) - -// Client is an analytics client. -type Client struct { - id string // Google Analytics ID -} - -// New creates a new analytics client for Segment.io with Segment's -// endpoint and access key. -func New(id string) *Client { - return &Client{ - id: id, - } -} - -// Metric represents a data point. -type Metric struct { - Category string - Action string - Label string - Value string - User string - Version string -} - -// Send sends metrics to GA. -func (c *Client) Send(metric Metric) error { - v := url.Values{ - "v": {"1"}, - "tid": {c.id}, - "cid": {metric.User}, - "t": {"event"}, - "ec": {metric.Category}, - "ea": {metric.Action}, - "ua": {"Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14"}, - } - if metric.Label != "" { - v.Set("el", metric.Label) - } - if metric.Value != "" { - v.Set("ev", metric.Value) - } - if metric.Version != "" { - v.Set("an", metric.Version) - v.Set("av", metric.Version) - } - resp, err := http.PostForm(endpoint, v) - if err != nil { - return err - } - defer resp.Body.Close() - return nil -} diff --git a/ignite/pkg/iowait/iowait.go b/ignite/pkg/iowait/iowait.go deleted file mode 100644 index 5926d41523..0000000000 --- a/ignite/pkg/iowait/iowait.go +++ /dev/null @@ -1,30 +0,0 @@ -package iowait - -import ( - "bufio" - "fmt" - "io" - "strings" -) - -// Until waits for the appearance of s in the string n times and -// then stops blocking. -func Until(r io.Reader, s string, n int) (capturedLines []string, err error) { - total := n - scanner := bufio.NewScanner(r) - for { - if n == 0 { - return capturedLines, nil - } - if !scanner.Scan() { - if n != 0 { - return capturedLines, fmt.Errorf("could not find %d out of %d", n, total) - } - return capturedLines, scanner.Err() - } - if strings.Contains(scanner.Text(), s) { - capturedLines = append(capturedLines, scanner.Text()) - n-- - } - } -} diff --git a/ignite/pkg/jsondoc/jsondoc.go b/ignite/pkg/jsondoc/jsondoc.go deleted file mode 100644 index 460c5d3e23..0000000000 --- a/ignite/pkg/jsondoc/jsondoc.go +++ /dev/null @@ -1,34 +0,0 @@ -package jsondoc - -import ( - "encoding/json" - - "github.com/goccy/go-yaml" -) - -// Doc represents a JSON encoded data. -type Doc []byte - -// ToDocs converts a list of JSON encoded data to docs. -func ToDocs(data [][]byte) []Doc { - var docs []Doc - for _, d := range data { - docs = append(docs, d) - } - return docs -} - -// MarshalYAML converts Doc to a YAML encoded data during YAML marshaling. -func (d Doc) MarshalYAML() ([]byte, error) { - var out interface{} - if err := json.Unmarshal(d, &out); err != nil { - return nil, err - } - return yaml.Marshal(out) -} - -// Pretty converts a Doc to a human-readable string. -func (d Doc) Pretty() (string, error) { - proposalyaml, err := yaml.Marshal(d) - return string(proposalyaml), err -} diff --git a/ignite/pkg/looseerrgroup/looseerrgroup.go b/ignite/pkg/looseerrgroup/looseerrgroup.go deleted file mode 100644 index 8e5302b0a4..0000000000 --- a/ignite/pkg/looseerrgroup/looseerrgroup.go +++ /dev/null @@ -1,26 +0,0 @@ -package looseerrgroup - -import ( - "context" - - "golang.org/x/sync/errgroup" -) - -// Wait waits until g.Wait() returns or ctx canceled, whichever occurs first. -// returned error is context.Canceled if ctx canceled otherwise the error returned by g.Wait(). -// -// this is useful when errgroup cannot be used with errgroup.WithContext which happens if executed -// func does not support cancellation. -func Wait(ctx context.Context, g *errgroup.Group) error { - doneC := make(chan struct{}) - - go func() { g.Wait(); close(doneC) }() - - select { - case <-ctx.Done(): - return ctx.Err() - - case <-doneC: - return g.Wait() - } -} diff --git a/ignite/pkg/tendermintlogger/logger.go b/ignite/pkg/tendermintlogger/logger.go deleted file mode 100644 index 302c0ad7f5..0000000000 --- a/ignite/pkg/tendermintlogger/logger.go +++ /dev/null @@ -1,10 +0,0 @@ -package tendermintlogger - -import tmlog "github.com/cometbft/cometbft/libs/log" - -type DiscardLogger struct{} - -func (l DiscardLogger) Debug(string, ...interface{}) {} -func (l DiscardLogger) Info(string, ...interface{}) {} -func (l DiscardLogger) Error(string, ...interface{}) {} -func (l DiscardLogger) With(...interface{}) tmlog.Logger { return l } diff --git a/ignite/pkg/tendermintlogger/logger_test.go b/ignite/pkg/tendermintlogger/logger_test.go deleted file mode 100644 index c483e93e3d..0000000000 --- a/ignite/pkg/tendermintlogger/logger_test.go +++ /dev/null @@ -1,5 +0,0 @@ -package tendermintlogger - -import tmlog "github.com/cometbft/cometbft/libs/log" - -var _ tmlog.Logger = (*DiscardLogger)(nil) diff --git a/ignite/pkg/xstrings/xstrings.go b/ignite/pkg/xstrings/xstrings.go index c8229e9735..ff038a95db 100644 --- a/ignite/pkg/xstrings/xstrings.go +++ b/ignite/pkg/xstrings/xstrings.go @@ -4,6 +4,7 @@ import ( "strings" "unicode" + "golang.org/x/exp/slices" // TODO: replace with slices.Contains when it will be available in stdlib (1.21) "golang.org/x/text/cases" "golang.org/x/text/language" ) @@ -19,7 +20,7 @@ func AllOrSomeFilter(list, filterList []string) []string { var elems []string for _, elem := range list { - if !SliceContains(filterList, elem) { + if !slices.Contains(filterList, elem) { elems = append(elems, elem) } } @@ -27,17 +28,6 @@ func AllOrSomeFilter(list, filterList []string) []string { return elems } -// SliceContains returns with true if s is a member of ss. -func SliceContains(ss []string, s string) bool { - for _, e := range ss { - if e == s { - return true - } - } - - return false -} - // List returns a slice of strings captured after the value returned by do which is // called n times. func List(n int, do func(i int) string) []string { diff --git a/integration/readme.md b/integration/readme.md index 58e08914bb..1d9ef27b35 100644 --- a/integration/readme.md +++ b/integration/readme.md @@ -1,6 +1,6 @@ -# Starport Integration Tests +# Ignite CLI Integration Tests -The Starport integration tests build a new application and run all Starport commands to check the Starport code integrity. The runners and helper methods are located in this current folder. The test commands are split into folders, for better concurrency, each folder is a parallel job into the CI workflow. To create a new one, we only need to create a new folder. This will be automatically detected and added into the PR CI checks, or we can only create new tests into an existing folder or file. +The Ignite CLI integration tests build a new application and run all Ignite CLI commands to check the Ignite CLI code integrity. The runners and helper methods are located in this current folder. The test commands are split into folders, for better concurrency, each folder is a parallel job into the CI workflow. To create a new one, we only need to create a new folder. This will be automatically detected and added into the PR CI checks, or we can only create new tests into an existing folder or file. Running synchronously all integration tests can be very slow. The command below can run everything: @@ -25,7 +25,7 @@ var ( ) ``` -- Now, you can use the env to run the starport commands and check the success status: +- Now, you can use the env to run the ignite commands and check the success status: ```go env.Must(env.Exec("create a list with bool", diff --git a/scripts/data/gen-protoc/readme.md b/scripts/data/gen-protoc/readme.md index dae9e10560..fa7a55fae3 100644 --- a/scripts/data/gen-protoc/readme.md +++ b/scripts/data/gen-protoc/readme.md @@ -37,16 +37,16 @@ gh_protoc_release_url="https://api.github.com/repos/protocolbuffers/protobuf/rel setdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)" # this line powered by stackoverflow # Check dir else create save dir -if [[ $(basename ${setdir}) = "scripts" ]] ; then - if [[ $(basename $(dirname "${setdir}")) = "starport" ]] ; then - [[ -d $(dirname "${setdir}/pkg/protoc/data") ]] || mkdir -p "$(dirname "${setdir}")/starport/pkg/protoc/data" +if [[ $(basename "${setdir}") = "scripts" ]] ; then + if [[ $(basename "$(dirname "${setdir}")") = "cli" ]] ; then + [[ -d $(dirname "${setdir}/pkg/protoc/data") ]] || mkdir -p "$(dirname "${setdir}")/ignite/pkg/protoc/data" else - echo "Attention: you are running the script out of the startport project please run it this script in: https://github.com/tendermint/starport" + echo "Attention: you are running the script out of the ignite cli project please run it this script in: https://github.com/ignite/cli" exit 1 fi else echo "$setdir" - echo "Attention: you are running the script out of the startport project please run it this script in: https://github.com/tendermint/starport" + echo "Attention: you are running the script out of the ignite cli project please run it this script in: https://github.com/ignite/cli" exit 1 fi diff --git a/scripts/gen-protoc b/scripts/gen-protoc index 7822930f12..86301cb4cc 100755 --- a/scripts/gen-protoc +++ b/scripts/gen-protoc @@ -35,12 +35,12 @@ if [[ $(basename "${setdir}") = "scripts" ]] ; then if [[ $(basename "$(dirname "${setdir}")") = "cli" ]] ; then [[ -d $(dirname "${setdir}/pkg/protoc/data") ]] || mkdir -p "$(dirname "${setdir}")/ignite/pkg/protoc/data" else - echo "Attention: you are running the script out of the starport project please run it this script in: https://github.com/tendermint/starport" + echo "Attention: you are running the script out of the ignite cli project please run it this script in: https://github.com/ignite/cli" exit 1 fi else echo "$setdir" - echo "Attention: you are running the script out of the starport project please run it this script in: https://github.com/tendermint/starport" + echo "Attention: you are running the script out of the ignite cli project please run it this script in: https://github.com/ignite/cli" exit 1 fi