diff --git a/changelog.md b/changelog.md index c2e515a9a2..599381e0e1 100644 --- a/changelog.md +++ b/changelog.md @@ -37,6 +37,8 @@ - [#3655](https://github.com/ignite/cli/pull/3655) Re-enable TS client generation - [#3661](https://github.com/ignite/cli/pull/3661) Change `pkg/cosmosanalysis` to find Cosmos SDK runtime app registered modules - [#3716](https://github.com/ignite/cli/pull/3716) Fix invalid plugin hook check +- [#3725](https://github.com/ignite/cli/pull/3725) Fix flaky TS client generation issues on linux +- [#3729](https://github.com/ignite/cli/pull/3729) Fix broken generator due to caching /tmp include folders ## [`v0.27.0`](https://github.com/ignite/cli/releases/tag/v0.27.0) diff --git a/docs/package.json b/docs/package.json index 1c6777c7dc..018f10ac78 100644 --- a/docs/package.json +++ b/docs/package.json @@ -21,7 +21,7 @@ "autoprefixer": "^10.4.14", "clsx": "^1.2.1", "docusaurus-plugin-image-zoom": "^0.1.1", - "postcss": "^8.4.21", + "postcss": "^8.4.31", "postcss-import": "^15.1.0", "prism-react-renderer": "^1.3.5", "react": "^17.0.2", diff --git a/docs/yarn.lock b/docs/yarn.lock index 0e67e05c3b..f3dfd7b93a 100644 --- a/docs/yarn.lock +++ b/docs/yarn.lock @@ -5302,7 +5302,7 @@ mz@^2.7.0: object-assign "^4.0.1" thenify-all "^1.0.0" -nanoid@^3.3.4: +nanoid@^3.3.6: version "3.3.6" resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c" integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA== @@ -6015,12 +6015,12 @@ postcss-zindex@^5.1.0: resolved "https://registry.yarnpkg.com/postcss-zindex/-/postcss-zindex-5.1.0.tgz#4a5c7e5ff1050bd4c01d95b1847dfdcc58a496ff" integrity sha512-fgFMf0OtVSBR1va1JNHYgMxYk73yhn/qb4uQDq1DLGYolz8gHCyr/sesEuGUaYs58E3ZJRcpoGuPVoB7Meiq9A== -postcss@^8.0.9, postcss@^8.3.11, postcss@^8.4.14, postcss@^8.4.17, postcss@^8.4.19, postcss@^8.4.21: - version "8.4.21" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.21.tgz#c639b719a57efc3187b13a1d765675485f4134f4" - integrity sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg== +postcss@^8.0.9, postcss@^8.3.11, postcss@^8.4.14, postcss@^8.4.17, postcss@^8.4.19, postcss@^8.4.31: + version "8.4.31" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.31.tgz#92b451050a9f914da6755af352bdc0192508656d" + integrity sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ== dependencies: - nanoid "^3.3.4" + nanoid "^3.3.6" picocolors "^1.0.0" source-map-js "^1.0.2" diff --git a/ignite/pkg/cosmosgen/generate.go b/ignite/pkg/cosmosgen/generate.go index 34e18d7168..ab5a84fd7e 100644 --- a/ignite/pkg/cosmosgen/generate.go +++ b/ignite/pkg/cosmosgen/generate.go @@ -80,7 +80,7 @@ func (g *generator) setup() (err error) { if err != nil { return err } - g.appIncludes, err = g.resolveIncludes(g.appPath) + g.appIncludes, _, err = g.resolveIncludes(g.appPath) if err != nil { return err } @@ -120,9 +120,10 @@ func (g *generator) setup() (err error) { } var includes []string + cacheable := true if len(modules) > 0 { // For versioning issues, we do dependency/includes resolution per module - includes, err = g.resolveIncludes(path) + includes, cacheable, err = g.resolveIncludes(path) if err != nil { return err } @@ -133,9 +134,10 @@ func (g *generator) setup() (err error) { Modules: modules, Includes: includes, } - - if err := moduleCache.Put(cacheKey, modulesInPath); err != nil { - return err + if cacheable { + if err := moduleCache.Put(cacheKey, modulesInPath); err != nil { + return err + } } } @@ -197,21 +199,21 @@ func (g *generator) generateBufIncludeFolder(modpath string) (string, error) { return protoPath, nil } -func (g *generator) resolveIncludes(path string) (paths []string, err error) { +func (g *generator) resolveIncludes(path string) (paths []string, cacheable bool, err error) { // Init paths with the global include paths for protoc paths, err = protocGlobalInclude() if err != nil { - return nil, err + return nil, false, err } // Check that the app proto directory exists protoPath := filepath.Join(path, g.protoDir) fi, err := os.Stat(protoPath) if err != nil && !os.IsNotExist(err) { - return nil, err + return nil, false, err } else if !fi.IsDir() { // Just return the global includes when a proto directory doesn't exist - return paths, nil + return paths, true, nil } // Add app's proto path to the list of proto paths @@ -220,7 +222,7 @@ func (g *generator) resolveIncludes(path string) (paths []string, err error) { // Check if a Buf config file is present bufPath, err := g.findBufPath(protoPath) if err != nil { - return nil, err + return nil, false, err } // When a Buf config exists export all protos needed @@ -228,17 +230,17 @@ func (g *generator) resolveIncludes(path string) (paths []string, err error) { if bufPath != "" { includePath, err := g.generateBufIncludeFolder(protoPath) if err != nil && !errors.Is(err, cosmosbuf.ErrProtoFilesNotFound) { - return nil, err + return nil, false, err } // Use exported files only when the path contains ".proto" files if includePath != "" { - return append(paths, includePath), nil + return append(paths, includePath), false, nil } } // By default use the configured directories - return append(paths, g.getProtoIncludeFolders(path)...), nil + return append(paths, g.getProtoIncludeFolders(path)...), true, nil } func (g *generator) discoverModules(path, protoDir string) ([]module.Module, error) { diff --git a/ignite/pkg/cosmosgen/generate_openapi.go b/ignite/pkg/cosmosgen/generate_openapi.go index f4897d5472..84623e6b68 100644 --- a/ignite/pkg/cosmosgen/generate_openapi.go +++ b/ignite/pkg/cosmosgen/generate_openapi.go @@ -12,6 +12,7 @@ import ( "github.com/ignite/cli/ignite/pkg/cache" "github.com/ignite/cli/ignite/pkg/cosmosanalysis/module" "github.com/ignite/cli/ignite/pkg/dirchange" + "github.com/ignite/cli/ignite/pkg/nodetime" swaggercombine "github.com/ignite/cli/ignite/pkg/nodetime/programs/swagger-combine" "github.com/ignite/cli/ignite/pkg/xos" ) @@ -39,7 +40,11 @@ func (g *generator) generateOpenAPISpec() error { }, } ) - + command, cleanup, err := nodetime.Command(nodetime.CommandSwaggerCombine) + if err != nil { + return err + } + defer cleanup() defer func() { for _, dir := range specDirs { os.RemoveAll(dir) @@ -157,7 +162,7 @@ func (g *generator) generateOpenAPISpec() error { } // combine specs into one and save to out. - if err := swaggercombine.Combine(g.ctx, conf, out); err != nil { + if err := swaggercombine.Combine(g.ctx, conf, command, out); err != nil { return err } @@ -174,6 +179,11 @@ func (g *generator) generateModuleOpenAPISpec(m module.Module, out string) error }, } ) + command, cleanup, err := nodetime.Command(nodetime.CommandSwaggerCombine) + if err != nil { + return err + } + defer cleanup() defer func() { for _, dir := range specDirs { @@ -242,7 +252,6 @@ func (g *generator) generateModuleOpenAPISpec(m module.Module, out string) error if err := os.MkdirAll(outDir, 0o766); err != nil { return err } - // combine specs into one and save to out. - return swaggercombine.Combine(g.ctx, conf, out) + return swaggercombine.Combine(g.ctx, conf, command, out) } diff --git a/ignite/pkg/nodetime/programs/swagger-combine/swagger-combine.go b/ignite/pkg/nodetime/programs/swagger-combine/swagger-combine.go index a1ec01ede4..2b0c3da375 100644 --- a/ignite/pkg/nodetime/programs/swagger-combine/swagger-combine.go +++ b/ignite/pkg/nodetime/programs/swagger-combine/swagger-combine.go @@ -8,7 +8,6 @@ import ( "regexp" "github.com/ignite/cli/ignite/pkg/cmdrunner/exec" - "github.com/ignite/cli/ignite/pkg/nodetime" ) // Config represent swagger-combine config. @@ -81,13 +80,7 @@ func (c *Config) AddSpec(id, path string, makeUnique bool) error { // Combine combines openapi specs into one and saves to out path. // specs is a spec id-fs path pair. -func Combine(ctx context.Context, c Config, out string) error { - command, cleanup, err := nodetime.Command(nodetime.CommandSwaggerCombine) - if err != nil { - return err - } - defer cleanup() - +func Combine(ctx context.Context, c Config, command []string, out string) error { f, err := os.CreateTemp("", "*.json") if err != nil { return err diff --git a/ignite/templates/app/files/go.mod.plush b/ignite/templates/app/files/go.mod.plush index 86c13eb7c4..5319c3dcc0 100644 --- a/ignite/templates/app/files/go.mod.plush +++ b/ignite/templates/app/files/go.mod.plush @@ -2,6 +2,14 @@ module <%= ModulePath %> go 1.21 +replace ( + // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. + // TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 + github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 + // Downgraded to avoid bugs in following commits which caused simulations to fail. + github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 +) + require ( cosmossdk.io/api v0.7.1 cosmossdk.io/client/v2 v2.0.0-20231005140444-10bd5a2cacdc @@ -26,7 +34,8 @@ require ( github.com/golang/protobuf v1.5.3 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 + github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.17.0 @@ -36,11 +45,3 @@ require ( google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 google.golang.org/protobuf v1.31.0 ) - -replace ( - // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. - // TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 - github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 - // Downgraded to avoid bugs in following commits which caused simulations to fail. - github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 -) diff --git a/ignite/templates/app/files/proto/buf.gen.sta.yaml b/ignite/templates/app/files/proto/buf.gen.sta.yaml index d8cea8b342..4444f5e75c 100644 --- a/ignite/templates/app/files/proto/buf.gen.sta.yaml +++ b/ignite/templates/app/files/proto/buf.gen.sta.yaml @@ -10,5 +10,6 @@ plugins: opt: - logtostderr=true - openapi_naming_strategy=simple + - ignore_comments=true - simple_operation_ids=false - json_names_for_fields=false