Skip to content

Commit

Permalink
Merge branch 'feat/sdk-v0.50' into julien/autocli
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani authored Nov 6, 2023
2 parents 1ad8431 + 0ade246 commit 1686d48
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 41 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,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)

Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down Expand Up @@ -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"

Expand Down
28 changes: 15 additions & 13 deletions ignite/pkg/cosmosgen/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
}
}

Expand Down Expand Up @@ -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
Expand All @@ -220,25 +222,25 @@ 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
// to build the modules to a temporary include folder.
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) {
Expand Down
17 changes: 13 additions & 4 deletions ignite/pkg/cosmosgen/generate_openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
19 changes: 10 additions & 9 deletions ignite/templates/app/files/go.mod.plush
Original file line number Diff line number Diff line change
Expand Up @@ -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-20231018124024-3abc61fb75d4
Expand All @@ -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
Expand All @@ -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
)
1 change: 1 addition & 0 deletions ignite/templates/app/files/proto/buf.gen.sta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ plugins:
opt:
- logtostderr=true
- openapi_naming_strategy=simple
- ignore_comments=true
- simple_operation_ids=false
- json_names_for_fields=false

0 comments on commit 1686d48

Please sign in to comment.