Skip to content

Commit

Permalink
feat: support autocli (#3694)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Nov 25, 2023
1 parent 752382c commit 6196635
Show file tree
Hide file tree
Showing 43 changed files with 367 additions and 1,996 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ format:

## lint: Run Golang CI Lint.
lint:
@echo Running gocilint...
@echo Running golangci-lint...
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run --out-format=tab --issues-exit-code=0

lint-fix:
@echo Running golangci-lint...
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run --fix --out-format=tab --issues-exit-code=0

.PHONY: govet format lint

## proto-all: Format, lint and generate code from proto files using buf.
Expand Down
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Features

- [#3694](https://github.com/ignite/cli/pull/3694) Query and Tx AutoCLI support
- [#3544](https://github.com/ignite/cli/pull/3544) Add bidirectional communication to plugin system
- [#3561](https://github.com/ignite/cli/pull/3561) Add GetChainInfo method to plugin system API
- [#3626](https://github.com/ignite/cli/pull/3626) Add logging levels to relayer
Expand Down Expand Up @@ -787,4 +788,4 @@ Our new name is **Ignite CLI**!

## `v0.0.9`

Initial release.
Initial release.
1 change: 0 additions & 1 deletion ignite/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ meant to be edited by hand.
flagSetClearCache(c)

c.AddCommand(NewGenerateGo())
c.AddCommand(NewGeneratePulsar())
c.AddCommand(NewGenerateTSClient())
c.AddCommand(NewGenerateVuex())
c.AddCommand(NewGenerateComposables())
Expand Down
53 changes: 0 additions & 53 deletions ignite/cmd/generate_pulsar.go

This file was deleted.

21 changes: 6 additions & 15 deletions ignite/pkg/cosmosgen/cosmosgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ type generateOptions struct {
updateBufModule bool
ev events.Bus

isGoEnabled bool
isPulsarEnabled bool
generateProtobuf bool

jsOut func(module.Module) string
tsClientRootPath string
Expand Down Expand Up @@ -77,17 +76,10 @@ func WithHooksGeneration(out ModulePathFunc, hooksRootPath string) Option {
}
}

// WithGoGeneration adds Go code generation.
// WithGoGeneration adds protobuf (gogoproto and pulsar) code generation.
func WithGoGeneration() Option {
return func(o *generateOptions) {
o.isGoEnabled = true
}
}

// WithPulsarGeneration adds Go pulsar code generation.
func WithPulsarGeneration() Option {
return func(o *generateOptions) {
o.isPulsarEnabled = true
o.generateProtobuf = true
}
}

Expand Down Expand Up @@ -189,12 +181,11 @@ func Generate(ctx context.Context, cacheStorage cache.Storage, appPath, protoDir

// Go generation must run first so the types are created before other
// generated code that requires sdk.Msg implementations to be defined
if g.opts.isGoEnabled {
if err := g.generateGo(ctx); err != nil {
if g.opts.generateProtobuf {
if err := g.generateGoGo(ctx); err != nil {
return err
}
}
if g.opts.isPulsarEnabled {

if err := g.generatePulsar(ctx); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion ignite/pkg/cosmosgen/generate_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (g *generator) pulsarTemplate() string {
return filepath.Join(g.appPath, g.protoDir, "buf.gen.pulsar.yaml")
}

func (g *generator) generateGo(ctx context.Context) error {
func (g *generator) generateGoGo(ctx context.Context) error {
// create a temporary dir to locate generated code under which later only some of them will be moved to the
// app's source code. this also prevents having leftover files in the app's source code or its parent dir - when
// command executed directly there - in case of an interrupt.
Expand Down
12 changes: 0 additions & 12 deletions ignite/services/chain/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type generateOptions struct {
useCache bool
isProtoVendorEnabled bool
isGoEnabled bool
isPulsarEnabled bool
isTSClientEnabled bool
isComposablesEnabled bool
isHooksEnabled bool
Expand All @@ -40,13 +39,6 @@ func GenerateGo() GenerateTarget {
}
}

// GeneratePulsar enables generating proto based Go code needed for the chain's source code.
func GeneratePulsar() GenerateTarget {
return func(o *generateOptions) {
o.isPulsarEnabled = true
}
}

// GenerateTSClient enables generating proto based Typescript Client.
// The path assigns the output path to use for the generated Typescript client
// overriding the configured or default path. Path can be an empty string.
Expand Down Expand Up @@ -178,10 +170,6 @@ func (c *Chain) Generate(
options = append(options, cosmosgen.WithGoGeneration())
}

if targetOptions.isPulsarEnabled {
options = append(options, cosmosgen.WithPulsarGeneration())
}

if targetOptions.isProtoVendorEnabled {
options = append(options, cosmosgen.UpdateBufModule())
}
Expand Down
9 changes: 7 additions & 2 deletions ignite/services/scaffolder/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/gobuffalo/genny/v2"

"github.com/ignite/cli/ignite/pkg/cache"
"github.com/ignite/cli/ignite/pkg/gocmd"
"github.com/ignite/cli/ignite/pkg/cosmosgen"
"github.com/ignite/cli/ignite/pkg/gomodulepath"
"github.com/ignite/cli/ignite/pkg/placeholder"
"github.com/ignite/cli/ignite/pkg/xgit"
Expand Down Expand Up @@ -116,6 +116,10 @@ func generate(
return err
}

if err := cosmosgen.InstallDepTools(ctx, absRoot); err != nil {
return err
}

// generate module template
if !noDefaultModule {
opts := &modulecreate.CreateOptions{
Expand Down Expand Up @@ -143,5 +147,6 @@ func generate(
}

}
return gocmd.ModTidy(ctx, absRoot)

return nil
}
7 changes: 1 addition & 6 deletions ignite/services/scaffolder/scaffolder.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ func finish(ctx context.Context, cacheStorage cache.Storage, path, gomodPath str
}

func protoc(ctx context.Context, cacheStorage cache.Storage, projectPath, gomodPath string) error {
if err := cosmosgen.InstallDepTools(ctx, projectPath); err != nil {
return err
}

confpath, err := chainconfig.LocateDefault(projectPath)
if err != nil {
return err
Expand All @@ -90,9 +86,8 @@ func protoc(ctx context.Context, cacheStorage cache.Storage, projectPath, gomodP
}

options := []cosmosgen.Option{
cosmosgen.WithGoGeneration(),
cosmosgen.WithPulsarGeneration(),
cosmosgen.UpdateBufModule(),
cosmosgen.WithGoGeneration(),
cosmosgen.IncludeDirs(conf.Build.Proto.ThirdPartyPaths),
}

Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6196635

Please sign in to comment.