From 98fe93b58bb8e1b18fac0d987fdd6532c55983c8 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 07:44:18 +0000 Subject: [PATCH] feat(cli): add `skip-proto` flag to `s chain` command (backport #4019) (#4030) * feat(cli): add `skip-proto` flag to `s chain` command (#4019) Adds a `--skip-proto` flag to `s chain` to speed up scaffolding. Advanced user can enjoy faster scaffolding time but still need to run `ignite chain serve` or `ignite chain build` afterwards. (cherry picked from commit c05237b55bb9251498be0e41fffb73cf3e132876) # Conflicts: # ignite/cmd/scaffold_chain.go # ignite/services/scaffolder/configs.go # ignite/services/scaffolder/init.go # ignite/services/scaffolder/params.go * fix conflicts --------- Co-authored-by: Julien Robert --- changelog.md | 1 + ignite/cmd/scaffold_chain.go | 3 +++ ignite/services/scaffolder/init.go | 5 ++--- ignite/services/scaffolder/message.go | 2 +- ignite/services/scaffolder/module.go | 2 +- ignite/services/scaffolder/oracle.go | 2 +- ignite/services/scaffolder/packet.go | 2 +- ignite/services/scaffolder/query.go | 2 +- ignite/services/scaffolder/scaffolder.go | 9 +++++---- ignite/services/scaffolder/type.go | 2 +- ignite/templates/app/files/app/ibc.go.plush | 1 + 11 files changed, 18 insertions(+), 13 deletions(-) diff --git a/changelog.md b/changelog.md index a92628ace7..1da6a62c4c 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,7 @@ ### Features +- [#4019](https://github.com/ignite/cli/pull/4019) Add `skip-proto` flag to `s chain` command - [#3985](https://github.com/ignite/cli/pull/3985) Make some `cmd` pkg functions public - [#3956](https://github.com/ignite/cli/pull/3956) Prepare for wasm app - [#3660](https://github.com/ignite/cli/pull/3660) Add ability to scaffold ICS consumer chain diff --git a/ignite/cmd/scaffold_chain.go b/ignite/cmd/scaffold_chain.go index 3e2719a3d9..8b6df9853e 100644 --- a/ignite/cmd/scaffold_chain.go +++ b/ignite/cmd/scaffold_chain.go @@ -83,6 +83,7 @@ about Cosmos SDK on https://docs.cosmos.network c.Flags().Bool(flagNoDefaultModule, false, "create a project without a default module") c.Flags().StringSlice(flagParams, []string{}, "add default module parameters") c.Flags().Bool(flagSkipGit, false, "skip Git repository initialization") + c.Flags().Bool(flagSkipProto, false, "skip proto generation") c.Flags().Bool(flagMinimal, false, "create a minimal blockchain (with the minimum required Cosmos SDK modules)") c.Flags().Bool(flagIsConsumer, false, "scafffold an ICS consumer chain") // Cannot have both minimal and consumer flag @@ -104,6 +105,7 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error { minimal, _ = cmd.Flags().GetBool(flagMinimal) isConsumer, _ = cmd.Flags().GetBool(flagIsConsumer) params, _ = cmd.Flags().GetStringSlice(flagParams) + skipProto, _ = cmd.Flags().GetBool(flagSkipProto) ) if noDefaultModule && len(params) > 0 { @@ -124,6 +126,7 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error { addressPrefix, noDefaultModule, skipGit, + skipProto, minimal, isConsumer, params, diff --git a/ignite/services/scaffolder/init.go b/ignite/services/scaffolder/init.go index 53d1d41a5e..096917512d 100644 --- a/ignite/services/scaffolder/init.go +++ b/ignite/services/scaffolder/init.go @@ -25,7 +25,7 @@ func Init( cacheStorage cache.Storage, tracer *placeholder.Tracer, root, name, addressPrefix string, - noDefaultModule, skipGit, minimal, isConsumerChain bool, + noDefaultModule, skipGit, skipProto, minimal, isConsumerChain bool, params []string, ) (path string, err error) { pathInfo, err := gomodulepath.Parse(name) @@ -60,8 +60,7 @@ func Init( return "", err } - err = finish(ctx, cacheStorage, path, pathInfo.RawPath) - if err != nil { + if err = finish(ctx, cacheStorage, path, pathInfo.RawPath, skipProto); err != nil { return "", err } diff --git a/ignite/services/scaffolder/message.go b/ignite/services/scaffolder/message.go index f3e167f4f7..3d49028662 100644 --- a/ignite/services/scaffolder/message.go +++ b/ignite/services/scaffolder/message.go @@ -158,7 +158,7 @@ func (s Scaffolder) AddMessage( if err != nil { return sm, err } - return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath) + return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath, false) } // checkForbiddenMessageField returns true if the name is forbidden as a message name. diff --git a/ignite/services/scaffolder/module.go b/ignite/services/scaffolder/module.go index 6840b2732a..9998ada646 100644 --- a/ignite/services/scaffolder/module.go +++ b/ignite/services/scaffolder/module.go @@ -240,7 +240,7 @@ func (s Scaffolder) CreateModule( return sm, runErr } - return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath) + return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath, false) } // moduleExists checks if the module exists in the app. diff --git a/ignite/services/scaffolder/oracle.go b/ignite/services/scaffolder/oracle.go index 73f659d5e0..491e72809e 100644 --- a/ignite/services/scaffolder/oracle.go +++ b/ignite/services/scaffolder/oracle.go @@ -115,7 +115,7 @@ func (s *Scaffolder) AddOracle( if err != nil { return sm, err } - return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath) + return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath, false) } // Deprecated: This function is no longer maintained. diff --git a/ignite/services/scaffolder/packet.go b/ignite/services/scaffolder/packet.go index f914d5741b..87088e7c80 100644 --- a/ignite/services/scaffolder/packet.go +++ b/ignite/services/scaffolder/packet.go @@ -143,7 +143,7 @@ func (s Scaffolder) AddPacket( if err != nil { return sm, err } - return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath) + return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath, false) } // isIBCModule returns true if the provided module implements the IBC module interface diff --git a/ignite/services/scaffolder/query.go b/ignite/services/scaffolder/query.go index 7279abebe3..610f72a486 100644 --- a/ignite/services/scaffolder/query.go +++ b/ignite/services/scaffolder/query.go @@ -87,5 +87,5 @@ func (s Scaffolder) AddQuery( if err != nil { return sm, err } - return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath) + return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath, false) } diff --git a/ignite/services/scaffolder/scaffolder.go b/ignite/services/scaffolder/scaffolder.go index 4b2c5a9e54..3d765de913 100644 --- a/ignite/services/scaffolder/scaffolder.go +++ b/ignite/services/scaffolder/scaffolder.go @@ -63,10 +63,11 @@ func New(appPath string) (Scaffolder, error) { return s, nil } -func finish(ctx context.Context, cacheStorage cache.Storage, path, gomodPath string) error { - err := protoc(ctx, cacheStorage, path, gomodPath) - if err != nil { - return err +func finish(ctx context.Context, cacheStorage cache.Storage, path, gomodPath string, skipProto bool) error { + if !skipProto { + if err := protoc(ctx, cacheStorage, path, gomodPath); err != nil { + return err + } } if err := gocmd.Fmt(ctx, path); err != nil { diff --git a/ignite/services/scaffolder/type.go b/ignite/services/scaffolder/type.go index 43112d6a6f..d806b8d92c 100644 --- a/ignite/services/scaffolder/type.go +++ b/ignite/services/scaffolder/type.go @@ -219,7 +219,7 @@ func (s Scaffolder) AddType( return sm, err } - return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath) + return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath, false) } // checkForbiddenTypeIndex returns true if the name is forbidden as a index name. diff --git a/ignite/templates/app/files/app/ibc.go.plush b/ignite/templates/app/files/app/ibc.go.plush index 9b82bc7b91..f235cd1c65 100644 --- a/ignite/templates/app/files/app/ibc.go.plush +++ b/ignite/templates/app/files/app/ibc.go.plush @@ -4,6 +4,7 @@ import ( "cosmossdk.io/core/appmodule" storetypes "cosmossdk.io/store/types" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/types/module" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"