Skip to content

Commit

Permalink
feat(cli): add skip-proto flag to s chain command (backport #4019) (
Browse files Browse the repository at this point in the history
#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 c05237b)

# 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 <[email protected]>
  • Loading branch information
mergify[bot] and julienrbrt authored Mar 19, 2024
1 parent 0d9b9f6 commit 98fe93b
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions ignite/cmd/scaffold_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -124,6 +126,7 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error {
addressPrefix,
noDefaultModule,
skipGit,
skipProto,
minimal,
isConsumer,
params,
Expand Down
5 changes: 2 additions & 3 deletions ignite/services/scaffolder/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion ignite/services/scaffolder/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ignite/services/scaffolder/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ignite/services/scaffolder/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ignite/services/scaffolder/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ignite/services/scaffolder/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
9 changes: 5 additions & 4 deletions ignite/services/scaffolder/scaffolder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion ignite/services/scaffolder/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions ignite/templates/app/files/app/ibc.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 98fe93b

Please sign in to comment.