Skip to content

Commit

Permalink
feat(cli): add skip-proto flag to s chain command (#4019)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
julienrbrt committed May 29, 2024
1 parent d039604 commit ca6a536
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 14 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
- [#3977](https://github.com/ignite/cli/pull/3977) Add `chain lint` command to lint the chain's codebase using `golangci-lint`
- [#3770](https://github.com/ignite/cli/pull/3770) Add `scaffold configs` and `scaffold params` commands
- [#3985](https://github.com/ignite/cli/pull/3985) Make some `cmd` pkg functions public
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 @@ -84,6 +84,7 @@ about Cosmos SDK on https://docs.cosmos.network
c.Flags().StringSlice(flagParams, []string{}, "add default module parameters")
c.Flags().StringSlice(flagModuleConfigs, []string{}, "add module configs")
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 @@ -106,6 +107,7 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error {
isConsumer, _ = cmd.Flags().GetBool(flagIsConsumer)
params, _ = cmd.Flags().GetStringSlice(flagParams)
moduleConfigs, _ = cmd.Flags().GetStringSlice(flagModuleConfigs)
skipProto, _ = cmd.Flags().GetBool(flagSkipProto)
)

if noDefaultModule {
Expand All @@ -130,6 +132,7 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error {
addressPrefix,
noDefaultModule,
skipGit,
skipProto,
minimal,
isConsumer,
params,
Expand Down
2 changes: 1 addition & 1 deletion ignite/services/scaffolder/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (s Scaffolder) CreateConfigs(
return sm, err
}

return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath)
return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath, false)
}

// checkConfigCreated checks if the config has been already created.
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, moduleConfigs []string,
) (path string, err error) {
pathInfo, err := gomodulepath.Parse(name)
Expand Down Expand Up @@ -61,8 +61,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 @@ -257,7 +257,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/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/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (s Scaffolder) CreateParams(
return sm, err
}

return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath)
return sm, finish(ctx, cacheStorage, opts.AppPath, s.modpath.RawPath, false)
}

// checkParamCreated checks if the parameter has been already created.
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 ca6a536

Please sign in to comment.