diff --git a/changelog.md b/changelog.md index 77093639b9..ede5f934a1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,9 +1,3 @@ -## [`v0.25.1`](https://github.com/ignite/cli/releases/tag/v0.25.1) - -### Changes - -- [#2968](https://github.com/ignite/cli/pull/2968) Dragonberry security fix upgrading Cosmos SDK to `v0.46.3` - # Changelog ## Unreleased @@ -12,6 +6,16 @@ - [#2955](https://github.com/ignite/cli/pull/2955/) Add `ignite network request add-account` command. +### Changes + +- [#2957](https://github.com/ignite/cli/pull/2957) Change generate commands to print the path to the generated code. + +## [`v0.25.1`](https://github.com/ignite/cli/releases/tag/v0.25.1) + +### Changes + +- [#2968](https://github.com/ignite/cli/pull/2968) Dragonberry security fix upgrading Cosmos SDK to `v0.46.3` + ## [`v0.25.0`](https://github.com/ignite/cli/releases/tag/v0.25.0) ### Features @@ -39,7 +43,7 @@ - Add `--peer-address` flag to `network chain join` command. - Change nightly tag format - Add cosmos-sdk version in `version` command -- [#29350](https://github.com/ignite/cli/pull/2935) Update `gobuffalo/plush` templating tool to `v4` +- [#2935](https://github.com/ignite/cli/pull/2935) Update `gobuffalo/plush` templating tool to `v4` ### Fixes diff --git a/ignite/cmd/generate_dart.go b/ignite/cmd/generate_dart.go index a6bfc02453..27f935d2f8 100644 --- a/ignite/cmd/generate_dart.go +++ b/ignite/cmd/generate_dart.go @@ -4,6 +4,7 @@ import ( "github.com/spf13/cobra" "github.com/ignite/cli/ignite/pkg/cliui" + "github.com/ignite/cli/ignite/pkg/cliui/icons" "github.com/ignite/cli/ignite/services/chain" ) @@ -31,6 +32,7 @@ func generateDartHandler(cmd *cobra.Command, args []string) error { chain.EnableThirdPartyModuleCodegen(), chain.WithOutputer(session), chain.CollectEvents(session.EventBus()), + chain.PrintGeneratedPaths(), ) if err != nil { return err @@ -45,5 +47,5 @@ func generateDartHandler(cmd *cobra.Command, args []string) error { return err } - return session.Println("⛏️ Generated Dart client.") + return session.Println(icons.OK, "Generated Dart Client") } diff --git a/ignite/cmd/generate_go.go b/ignite/cmd/generate_go.go index 04c2f16cd3..28725500c0 100644 --- a/ignite/cmd/generate_go.go +++ b/ignite/cmd/generate_go.go @@ -4,6 +4,7 @@ import ( "github.com/spf13/cobra" "github.com/ignite/cli/ignite/pkg/cliui" + "github.com/ignite/cli/ignite/pkg/cliui/icons" "github.com/ignite/cli/ignite/services/chain" ) @@ -44,5 +45,5 @@ func generateGoHandler(cmd *cobra.Command, args []string) error { return err } - return session.Println("⛏️ Generated go code.") + return session.Println(icons.OK, "Generated Go code") } diff --git a/ignite/cmd/generate_openapi.go b/ignite/cmd/generate_openapi.go index f39604c2f4..598e30c6b9 100644 --- a/ignite/cmd/generate_openapi.go +++ b/ignite/cmd/generate_openapi.go @@ -4,6 +4,7 @@ import ( "github.com/spf13/cobra" "github.com/ignite/cli/ignite/pkg/cliui" + "github.com/ignite/cli/ignite/pkg/cliui/icons" "github.com/ignite/cli/ignite/services/chain" ) @@ -30,6 +31,7 @@ func generateOpenAPIHandler(cmd *cobra.Command, args []string) error { cmd, chain.WithOutputer(session), chain.CollectEvents(session.EventBus()), + chain.PrintGeneratedPaths(), ) if err != nil { return err @@ -44,5 +46,5 @@ func generateOpenAPIHandler(cmd *cobra.Command, args []string) error { return err } - return session.Println("⛏️ Generated OpenAPI spec.") + return session.Println(icons.OK, "Generated OpenAPI spec") } diff --git a/ignite/cmd/generate_typescript_client.go b/ignite/cmd/generate_typescript_client.go index 7d4e3eb466..4e76d1e615 100644 --- a/ignite/cmd/generate_typescript_client.go +++ b/ignite/cmd/generate_typescript_client.go @@ -4,6 +4,7 @@ import ( "github.com/spf13/cobra" "github.com/ignite/cli/ignite/pkg/cliui" + "github.com/ignite/cli/ignite/pkg/cliui/icons" "github.com/ignite/cli/ignite/services/chain" ) @@ -32,6 +33,7 @@ func generateTSClientHandler(cmd *cobra.Command, args []string) error { chain.EnableThirdPartyModuleCodegen(), chain.WithOutputer(session), chain.CollectEvents(session.EventBus()), + chain.PrintGeneratedPaths(), ) if err != nil { return err @@ -52,5 +54,5 @@ func generateTSClientHandler(cmd *cobra.Command, args []string) error { return err } - return session.Println("⛏️ Generated Typescript Client") + return session.Println(icons.OK, "Generated Typescript Client") } diff --git a/ignite/cmd/generate_vuex.go b/ignite/cmd/generate_vuex.go index 2d1e30b087..d9f4077773 100644 --- a/ignite/cmd/generate_vuex.go +++ b/ignite/cmd/generate_vuex.go @@ -4,6 +4,7 @@ import ( "github.com/spf13/cobra" "github.com/ignite/cli/ignite/pkg/cliui" + "github.com/ignite/cli/ignite/pkg/cliui/icons" "github.com/ignite/cli/ignite/services/chain" ) @@ -32,6 +33,7 @@ func generateVuexHandler(cmd *cobra.Command, args []string) error { chain.EnableThirdPartyModuleCodegen(), chain.WithOutputer(session), chain.CollectEvents(session.EventBus()), + chain.PrintGeneratedPaths(), ) if err != nil { return err @@ -46,5 +48,5 @@ func generateVuexHandler(cmd *cobra.Command, args []string) error { return err } - return session.Println("⛏️ Generated Typescript Client and Vuex stores") + return session.Println(icons.OK, "Generated Typescript Client and Vuex stores") } diff --git a/ignite/pkg/cosmosgen/cosmosgen.go b/ignite/pkg/cosmosgen/cosmosgen.go index 86275bb03f..6654b21aa7 100644 --- a/ignite/pkg/cosmosgen/cosmosgen.go +++ b/ignite/pkg/cosmosgen/cosmosgen.go @@ -159,10 +159,18 @@ func Generate(ctx context.Context, cacheStorage cache.Storage, appPath, protoDir return nil } -// TypescriptModulePath generates module paths for Cosmos SDK modules. +// TypescriptModulePath generates TS module paths for Cosmos SDK modules. // The root path is used as prefix for the generated paths. func TypescriptModulePath(rootPath string) ModulePathFunc { return func(m module.Module) string { return filepath.Join(rootPath, m.Pkg.Name) } } + +// DartModulePath generates Dart module paths for Cosmos SDK modules. +// The root path is used as prefix for the generated paths. +func DartModulePath(rootPath string) ModulePathFunc { + return func(m module.Module) string { + return filepath.Join(rootPath, m.Pkg.Name, "module") + } +} diff --git a/ignite/services/chain/chain.go b/ignite/services/chain/chain.go index 2296483617..9cc82b70f2 100644 --- a/ignite/services/chain/chain.go +++ b/ignite/services/chain/chain.go @@ -75,6 +75,9 @@ type chainOptions struct { // been modified since they were downloaded. checkDependencies bool + // printGeneratedPaths prints the output paths of the generated code + printGeneratedPaths bool + // path of a custom config file ConfigFile string } @@ -141,6 +144,13 @@ func CheckDependencies() Option { } } +// PrintGeneratedPaths prints the output paths of the generated code. +func PrintGeneratedPaths() Option { + return func(c *Chain) { + c.options.printGeneratedPaths = true + } +} + // New initializes a new Chain with options that its source lives at path. func New(path string, options ...Option) (*Chain, error) { app, err := NewAppAt(path) diff --git a/ignite/services/chain/generate.go b/ignite/services/chain/generate.go index 214322e7ce..3958d1713f 100644 --- a/ignite/services/chain/generate.go +++ b/ignite/services/chain/generate.go @@ -2,13 +2,15 @@ package chain import ( "context" + "fmt" "os" "path/filepath" "github.com/ignite/cli/ignite/chainconfig" "github.com/ignite/cli/ignite/pkg/cache" - "github.com/ignite/cli/ignite/pkg/cosmosanalysis/module" + "github.com/ignite/cli/ignite/pkg/cliui/icons" "github.com/ignite/cli/ignite/pkg/cosmosgen" + "github.com/ignite/cli/ignite/pkg/events" ) const ( @@ -119,7 +121,7 @@ func (c *Chain) Generate( return err } - c.ev.Send("🛠 Building proto...") + c.ev.Send("Building proto...", events.ProgressStarted()) options := []cosmosgen.Option{ cosmosgen.IncludeDirs(conf.Build.Proto.ThirdPartyPaths), @@ -131,9 +133,10 @@ func (c *Chain) Generate( enableThirdPartyModuleCodegen := !c.protoBuiltAtLeastOnce && c.options.isThirdPartyModuleCodegenEnabled - // generate Typescript Client code as well if it is enabled. + var dartPath, openAPIPath, tsClientPath, vuexPath string + if targetOptions.isTSClientEnabled { - tsClientPath := targetOptions.tsClientPath + tsClientPath = targetOptions.tsClientPath if tsClientPath == "" { // TODO: Change to allow full paths in case TS client dir is not inside the app's dir? tsClientPath = filepath.Join(c.app.Path, chainconfig.TSClientPath(conf)) @@ -152,50 +155,47 @@ func (c *Chain) Generate( } if targetOptions.isVuexEnabled { - vuexPath := conf.Client.Vuex.Path + vuexPath = conf.Client.Vuex.Path if vuexPath == "" { vuexPath = defaultVuexPath } - storeRootPath := filepath.Join(c.app.Path, vuexPath, "generated") - if err := os.MkdirAll(storeRootPath, 0o766); err != nil { + vuexPath = filepath.Join(c.app.Path, vuexPath, "generated") + if err := os.MkdirAll(vuexPath, 0o766); err != nil { return err } options = append(options, cosmosgen.WithVuexGeneration( enableThirdPartyModuleCodegen, - cosmosgen.TypescriptModulePath(storeRootPath), - storeRootPath, + cosmosgen.TypescriptModulePath(vuexPath), + vuexPath, ), ) } if targetOptions.isDartEnabled { - dartPath := conf.Client.Dart.Path + dartPath = conf.Client.Dart.Path if dartPath == "" { dartPath = defaultDartPath } - rootPath := filepath.Join(c.app.Path, dartPath, "generated") - if err := os.MkdirAll(rootPath, 0o766); err != nil { + dartPath = filepath.Join(c.app.Path, dartPath, "generated") + if err := os.MkdirAll(dartPath, 0o766); err != nil { return err } options = append(options, cosmosgen.WithDartGeneration( enableThirdPartyModuleCodegen, - func(m module.Module) string { - return filepath.Join(rootPath, m.Pkg.Name, "module") - }, - rootPath, + cosmosgen.DartModulePath(dartPath), + dartPath, ), ) } if targetOptions.isOpenAPIEnabled { - openAPIPath := conf.Client.OpenAPI.Path - + openAPIPath = conf.Client.OpenAPI.Path if openAPIPath == "" { openAPIPath = defaultOpenAPIPath } @@ -209,5 +209,39 @@ func (c *Chain) Generate( c.protoBuiltAtLeastOnce = true + if c.options.printGeneratedPaths { + if targetOptions.isTSClientEnabled { + c.ev.Send( + fmt.Sprintf("Typescript client path: %s", tsClientPath), + events.Icon(icons.Bullet), + events.ProgressFinished(), + ) + } + + if targetOptions.isVuexEnabled { + c.ev.Send( + fmt.Sprintf("Vuex stores path: %s", vuexPath), + events.Icon(icons.Bullet), + events.ProgressFinished(), + ) + } + + if targetOptions.isDartEnabled { + c.ev.Send( + fmt.Sprintf("Dart path: %s", dartPath), + events.Icon(icons.Bullet), + events.ProgressFinished(), + ) + } + + if targetOptions.isOpenAPIEnabled { + c.ev.Send( + fmt.Sprintf("OpenAPI path: %s", openAPIPath), + events.Icon(icons.Bullet), + events.ProgressFinished(), + ) + } + } + return nil }