Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Optimise ts-client generation #3725

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- [#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

## [`v0.27.0`](https://github.com/ignite/cli/releases/tag/v0.27.0)

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
2 changes: 1 addition & 1 deletion ignite/templates/app/files/go.mod.plush
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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
Expand Down
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
Loading