diff --git a/ignite/cmd/chain.go b/ignite/cmd/chain.go index f87d72dfe0..5ab80e389a 100644 --- a/ignite/cmd/chain.go +++ b/ignite/cmd/chain.go @@ -32,6 +32,8 @@ const ( msgMigrationRemoveTools = "File %s contains deprecated imports: %s. Would you like to remove them" ) +var ErrProtocUnsupported = errors.New("code generation using protoc is only supported by Ignite CLI v0.26.1 or older") + // NewChain returns a command that groups sub commands related to compiling, serving // blockchains and so on. func NewChain() *cobra.Command { @@ -191,8 +193,7 @@ func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session) error return nil } if err := session.AskConfirm(msgMigrationBuf); err != nil { - return fmt.Errorf("build the protobuf files with the protoc binary is only supported on version " + - "`v0.26.1` or below. Please downgrade your Ignite version") + return ErrProtocUnsupported } sm, err := chain.BoxBufFiles(appPath) diff --git a/ignite/pkg/buf/buf.go b/ignite/pkg/cosmosbuf/buf.go similarity index 92% rename from ignite/pkg/buf/buf.go rename to ignite/pkg/cosmosbuf/buf.go index 17bfe0b0ea..2799cd7be6 100644 --- a/ignite/pkg/buf/buf.go +++ b/ignite/pkg/cosmosbuf/buf.go @@ -1,4 +1,4 @@ -package buf +package cosmosbuf import ( "context" @@ -11,6 +11,7 @@ import ( "golang.org/x/sync/errgroup" "github.com/ignite/cli/ignite/pkg/cmdrunner/exec" + "github.com/ignite/cli/ignite/pkg/cosmosver" "github.com/ignite/cli/ignite/pkg/protoanalysis" "github.com/ignite/cli/ignite/pkg/xexec" "github.com/ignite/cli/ignite/pkg/xos" @@ -29,13 +30,12 @@ type ( ) const ( - cosmosSDKModulePath = "github.com/cosmos/cosmos-sdk" - binaryName = "buf" - flagTemplate = "template" - flagOutput = "output" - flagErrorFormat = "error-format" - flagLogFormat = "log-format" - fmtJSON = "json" + binaryName = "buf" + flagTemplate = "template" + flagOutput = "output" + flagErrorFormat = "error-format" + flagLogFormat = "log-format" + fmtJSON = "json" // CMDGenerate generate command. CMDGenerate Command = "generate" @@ -81,7 +81,7 @@ func (b Buf) Generate(ctx context.Context, protoDir, output, template string) (e // can't download this folder because is unused as a dependency. We need to // change the workspace copying the files to another folder and generate the // files. - if strings.Contains(protoDir, cosmosSDKModulePath) { + if strings.Contains(protoDir, cosmosver.CosmosModulePath) { if b.sdkCache == "" { b.sdkCache, err = prepareSDK(protoDir) if err != nil { diff --git a/ignite/pkg/buf/buf_test.go b/ignite/pkg/cosmosbuf/buf_test.go similarity index 98% rename from ignite/pkg/buf/buf_test.go rename to ignite/pkg/cosmosbuf/buf_test.go index ee0e33b02b..2bea064eff 100644 --- a/ignite/pkg/buf/buf_test.go +++ b/ignite/pkg/cosmosbuf/buf_test.go @@ -1,4 +1,4 @@ -package buf +package cosmosbuf import ( "errors" diff --git a/ignite/pkg/cosmosgen/cosmosgen.go b/ignite/pkg/cosmosgen/cosmosgen.go index f383e90eaa..6ab25b02da 100644 --- a/ignite/pkg/cosmosgen/cosmosgen.go +++ b/ignite/pkg/cosmosgen/cosmosgen.go @@ -8,9 +8,9 @@ import ( "github.com/iancoleman/strcase" gomodule "golang.org/x/mod/module" - "github.com/ignite/cli/ignite/pkg/buf" "github.com/ignite/cli/ignite/pkg/cache" "github.com/ignite/cli/ignite/pkg/cosmosanalysis/module" + "github.com/ignite/cli/ignite/pkg/cosmosbuf" ) // generateOptions used to configure code generation. @@ -98,7 +98,7 @@ func IncludeDirs(dirs []string) Option { // generator generates code for sdk and sdk apps. type generator struct { ctx context.Context - buf buf.Buf + buf cosmosbuf.Buf cacheStorage cache.Storage appPath string protoDir string @@ -112,7 +112,7 @@ type generator struct { // Generate generates code from protoDir of an SDK app residing at appPath with given options. // protoDir must be relative to the projectPath. func Generate(ctx context.Context, cacheStorage cache.Storage, appPath, protoDir string, options ...Option) error { - b, err := buf.New() + b, err := cosmosbuf.New() if err != nil { return err }