Skip to content

Commit

Permalink
move buf pkg to cosmosbuf
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani authored and Pantani committed Jun 29, 2023
1 parent 9a9f2c8 commit 383a07c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
5 changes: 3 additions & 2 deletions ignite/cmd/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions ignite/pkg/buf/buf.go → ignite/pkg/cosmosbuf/buf.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package buf
package cosmosbuf

import (
"context"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package buf
package cosmosbuf

import (
"errors"
Expand Down
6 changes: 3 additions & 3 deletions ignite/pkg/cosmosgen/cosmosgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit 383a07c

Please sign in to comment.