From c1ae9c237016db536f4e3ed3a04c7d079926d6d2 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 20:36:28 +0200 Subject: [PATCH] feat: remove `protoc` pkg and also nodetime helpers `ts-proto` and `sta` (backport #4090) (#4224) * feat: remove `protoc` pkg and also nodetime helpers `ts-proto` and `sta` (#4090) * remove protoc * add changelog * run go mod tidy * remove unused proto folder handling * add ts-client tests * remove unused methods * use import includes instead manual * use buf dep instead buf mod * change buf mod update to comand to buf dep update * improve code readbility * bump buf.build * bump buf into the go.mod * bump protobuf pkgs for buf * check if the folder has proto before update buf dependencies --------- Co-authored-by: Pantani (cherry picked from commit 8e0937d9f47c96dbd0db8d5f7058d0f636ba3428) # Conflicts: # go.mod # go.sum # ignite/internal/plugin/testdata/execute_fail/go.mod # ignite/internal/plugin/testdata/execute_ok/go.mod # ignite/internal/tools/gen-config-doc/go.mod # ignite/internal/tools/gen-config-doc/go.sum # ignite/internal/tools/gen-mig-diffs/go.mod # ignite/internal/tools/gen-mig-diffs/go.sum # ignite/pkg/cosmosbuf/buf.go # ignite/pkg/cosmosgen/generate_go.go # ignite/pkg/cosmosgen/generate_openapi.go # ignite/pkg/cosmosgen/generate_typescript.go # ignite/pkg/nodetime/nodetime.go # ignite/pkg/nodetime/programs/sta/sta.go # ignite/pkg/nodetime/programs/ts-proto/tsproto.go # ignite/pkg/protoc/protoc.go # ignite/templates/app/files/go.mod.plush # ignite/templates/app/files/proto/buf.lock # integration/doctor/testdata/missing-tools.go.txt # integration/plugin/testdata/example-plugin/go.mod * resolve conflicts * fix changelog * remove unused files * fix TestPluginExecute * fix tests for ts generation * rollback go version from tests * fix text namespace version for ts client generation --------- Co-authored-by: Danilo Pantani Co-authored-by: Julien Robert --- .gitignore | 2 + changelog.md | 1 + ignite/cmd/generate_typescript_client.go | 11 +- ignite/pkg/cosmosgen/generate_typescript.go | 99 ++++-------- ignite/pkg/cosmosgen/sta.go | 58 +++++++ ignite/pkg/nodetime/nodetime.go | 74 --------- ignite/pkg/nodetime/programs/sta/sta.go | 147 ------------------ .../swagger-combine/swagger-combine.go | 107 ------------- .../pkg/nodetime/programs/ts-proto/tsproto.go | 65 -------- ignite/templates/app/files/proto/buf.lock | 2 +- integration/cosmosgen/cosmosgen_test.go | 26 ++-- 11 files changed, 99 insertions(+), 493 deletions(-) create mode 100644 ignite/pkg/cosmosgen/sta.go delete mode 100644 ignite/pkg/nodetime/nodetime.go delete mode 100644 ignite/pkg/nodetime/programs/sta/sta.go delete mode 100644 ignite/pkg/nodetime/programs/swagger-combine/swagger-combine.go delete mode 100644 ignite/pkg/nodetime/programs/ts-proto/tsproto.go diff --git a/.gitignore b/.gitignore index 671a36b808..98e59efe2e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ scripts/**/nodetime-* **/testdata/**/go.sum +**/testdata/go.sum dist/ node_modules .DS_Store @@ -8,3 +9,4 @@ node_modules docs/.vuepress/dist build/ *coverage.* +*.ign diff --git a/changelog.md b/changelog.md index 9db0cf2931..8feba76535 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,7 @@ ### Features - [#4183](https://github.com/ignite/cli/pull/4183) Set `chain-id` in the client.toml +- [#4090](https://github.com/ignite/cli/pull/4090) Remove `protoc` pkg and also nodetime helpers `ts-proto` and `sta` - [#4076](https://github.com/ignite/cli/pull/4076) Remove the ignite `relayer` and `tools` commands with all ts-relayer logic - [#4133](https://github.com/ignite/cli/pull/4133) Improve buf rate limit diff --git a/ignite/cmd/generate_typescript_client.go b/ignite/cmd/generate_typescript_client.go index f2ae66a980..62434eca74 100644 --- a/ignite/cmd/generate_typescript_client.go +++ b/ignite/cmd/generate_typescript_client.go @@ -63,15 +63,8 @@ func generateTSClientHandler(cmd *cobra.Command, _ []string) error { return err } - output, err := cmd.Flags().GetString(flagOutput) - if err != nil { - return err - } - - useCache, err := cmd.Flags().GetBool(flagUseCache) - if err != nil { - return err - } + output, _ := cmd.Flags().GetString(flagOutput) + useCache, _ := cmd.Flags().GetBool(flagUseCache) var opts []chain.GenerateTarget if flagGetEnableProtoVendor(cmd) { diff --git a/ignite/pkg/cosmosgen/generate_typescript.go b/ignite/pkg/cosmosgen/generate_typescript.go index e132379095..4229e6c89e 100644 --- a/ignite/pkg/cosmosgen/generate_typescript.go +++ b/ignite/pkg/cosmosgen/generate_typescript.go @@ -11,17 +11,12 @@ import ( "github.com/ignite/cli/v28/ignite/pkg/cache" "github.com/ignite/cli/v28/ignite/pkg/cosmosanalysis/module" + "github.com/ignite/cli/v28/ignite/pkg/cosmosbuf" "github.com/ignite/cli/v28/ignite/pkg/dirchange" "github.com/ignite/cli/v28/ignite/pkg/gomodulepath" - "github.com/ignite/cli/v28/ignite/pkg/nodetime/programs/sta" - tsproto "github.com/ignite/cli/v28/ignite/pkg/nodetime/programs/ts-proto" - "github.com/ignite/cli/v28/ignite/pkg/protoc" ) -var ( - dirchangeCacheNamespace = "generate.typescript.dirchange" - tsOut = []string{"--ts_proto_out=."} -) +var dirchangeCacheNamespace = "generate.typescript.dirchange" type tsGenerator struct { g *generator @@ -37,6 +32,10 @@ func newTSGenerator(g *generator) *tsGenerator { return &tsGenerator{g} } +func (g *generator) tsTemplate() string { + return filepath.Join(g.appPath, g.protoDir, "buf.gen.ts.yaml") +} + func (g *generator) generateTS(ctx context.Context) error { chainPath, _, err := gomodulepath.Find(g.appPath) if err != nil { @@ -78,32 +77,11 @@ func (g *generator) generateTS(ctx context.Context) error { } func (g *tsGenerator) generateModuleTemplates(ctx context.Context) error { - protocCmd, cleanupProtoc, err := protoc.Command() - if err != nil { - return err - } - - defer cleanupProtoc() - - tsprotoPluginPath, cleanupPlugin, err := tsproto.BinaryPath() - if err != nil { - return err - } - - defer cleanupPlugin() - - staCmd, cleanupSTA, err := sta.Command() - if err != nil { - return err - } - - defer cleanupSTA() gg := &errgroup.Group{} dirCache := cache.New[[]byte](g.g.cacheStorage, dirchangeCacheNamespace) - add := func(sourcePath string, modules []module.Module, includes []string) { + add := func(sourcePath string, modules []module.Module) { for _, m := range modules { m := m - gg.Go(func() error { cacheKey := m.Pkg.Path paths := []string{m.Pkg.Path, g.g.opts.jsOut(m)} @@ -122,8 +100,7 @@ func (g *tsGenerator) generateModuleTemplates(ctx context.Context) error { } } - err = g.generateModuleTemplate(ctx, protocCmd, staCmd, tsprotoPluginPath, sourcePath, m, includes) - if err != nil { + if err := g.generateModuleTemplate(ctx, sourcePath, m); err != nil { return err } @@ -132,7 +109,7 @@ func (g *tsGenerator) generateModuleTemplates(ctx context.Context) error { } } - add(g.g.appPath, g.g.appModules, g.g.appIncludes.Paths) + add(g.g.appPath, g.g.appModules) // Always generate third party modules; This is required because not generating them might // lead to issues with the module registration in the root template. The root template must @@ -140,9 +117,7 @@ func (g *tsGenerator) generateModuleTemplates(ctx context.Context) error { // is available and not generated it would lead to the registration of a new not generated // 3rd party module. for sourcePath, modules := range g.g.thirdModules { - // TODO: Skip modules without proto files? - thirdIncludes := g.g.thirdModuleIncludes[sourcePath] - add(sourcePath, modules, append(g.g.appIncludes.Paths, thirdIncludes.Paths...)) + add(sourcePath, modules) } return gg.Wait() @@ -150,12 +125,8 @@ func (g *tsGenerator) generateModuleTemplates(ctx context.Context) error { func (g *tsGenerator) generateModuleTemplate( ctx context.Context, - protocCmd protoc.Cmd, - staCmd sta.Cmd, - tsprotoPluginPath, appPath string, m module.Module, - includePaths []string, ) error { var ( out = g.g.opts.jsOut(m) @@ -164,48 +135,30 @@ func (g *tsGenerator) generateModuleTemplate( if err := os.MkdirAll(typesOut, 0o766); err != nil { return err } - - // generate ts-proto types - err := protoc.Generate( - ctx, - typesOut, - m.Pkg.Path, - includePaths, - tsOut, - protoc.Plugin(tsprotoPluginPath, "--ts_proto_opt=snakeToCamel=true", "--ts_proto_opt=esModuleInterop=true"), - protoc.Env("NODE_OPTIONS="), // unset nodejs options to avoid unexpected issues with vercel "pkg" - protoc.WithCommand(protocCmd), - ) - if err != nil { - return err - } - - specPath := filepath.Join(out, "api.swagger.yml") - - if err = g.g.generateOpenAPISpec(ctx); err != nil { - return err - } - // generate the REST client from the OpenAPI spec - - var ( - srcSpec = specPath - outREST = filepath.Join(out, "rest.ts") - ) - - if err := sta.Generate(ctx, outREST, srcSpec, sta.WithCommand(staCmd)); err != nil { + if err := generateRouteNameFile(typesOut); err != nil { return err } // All "cosmossdk.io" module packages must use SDK's // proto path which is where the proto files are stored. - var pp string + protoPath := filepath.Join(g.g.appPath, g.g.protoDir) if module.IsCosmosSDKModulePkg(appPath) { - pp = filepath.Join(g.g.sdkDir, "proto") - } else { - pp = filepath.Join(appPath, g.g.protoDir) + protoPath = filepath.Join(g.g.sdkDir, "proto") + } + + // code generate for each module. + if err := g.g.buf.Generate( + ctx, + protoPath, + typesOut, + g.g.tsTemplate(), + cosmosbuf.ExcludeFiles("module.proto"), + cosmosbuf.IncludeWKT(), + ); err != nil { + return err } - return templateTSClientModule.Write(out, pp, struct { + return templateTSClientModule.Write(out, protoPath, struct { Module module.Module }{ Module: m, diff --git a/ignite/pkg/cosmosgen/sta.go b/ignite/pkg/cosmosgen/sta.go new file mode 100644 index 0000000000..0d72a6df50 --- /dev/null +++ b/ignite/pkg/cosmosgen/sta.go @@ -0,0 +1,58 @@ +package cosmosgen + +import ( + "os" + "path/filepath" +) + +const routeNameTemplate = `<% +const { routeInfo, utils } = it; +const { + operationId, + method, + route, + moduleName, + responsesTypes, + description, + tags, + summary, + pathArgs, +} = routeInfo; +const { _, fmtToJSDocLine, require } = utils; + +const methodAliases = { + get: (pathName, hasPathInserts) => + _.camelCase(` + "`" + `${pathName}_${hasPathInserts ? "detail" : "list"}` + "`" + `), + post: (pathName, hasPathInserts) => _.camelCase(` + "`" + `${pathName}_create` + "`" + `), + put: (pathName, hasPathInserts) => _.camelCase(` + "`" + `${pathName}_update` + "`" + `), + patch: (pathName, hasPathInserts) => _.camelCase(` + "`" + `${pathName}_partial_update` + "`" + `), + delete: (pathName, hasPathInserts) => _.camelCase(` + "`" + `${pathName}_delete` + "`" + `), +}; + +const createCustomOperationId = (method, route, moduleName) => { + const hasPathInserts = /\{(\w){1,}\}/g.test(route); + const splitedRouteBySlash = _.compact(_.replace(route, /\{(\w){1,}\}/g, "").split("/")); + const routeParts = (splitedRouteBySlash.length > 1 + ? splitedRouteBySlash.splice(1) + : splitedRouteBySlash + ).join("_"); + return routeParts.length > 3 && methodAliases[method] + ? methodAliases[method](routeParts, hasPathInserts) + : _.camelCase(_.lowerCase(method) + "_" + [moduleName].join("_")) || "index"; +}; + +if (operationId) { + let routeName = operationId.replace('_',''); + return routeName[0].toLowerCase() + routeName.slice(1); +} +if (route === "/") + return _.camelCase(` + "`" + `${_.lowerCase(method)}Root` + "`" + `); + +return createCustomOperationId(method, route, moduleName); +%>` + +// generateRouteNameFile generates the `route-name.eta` file. +func generateRouteNameFile(outPath string) error { + outTemplate := filepath.Join(outPath, "route-name.eta") + return os.WriteFile(outTemplate, []byte(routeNameTemplate), 0o644) +} diff --git a/ignite/pkg/nodetime/nodetime.go b/ignite/pkg/nodetime/nodetime.go deleted file mode 100644 index 44556ad352..0000000000 --- a/ignite/pkg/nodetime/nodetime.go +++ /dev/null @@ -1,74 +0,0 @@ -// Package nodetime provides a single, and standalone NodeJS runtime executable that contains -// several NodeJS CLI programs bundled inside where those are reachable via subcommands. -// the CLI bundled programs are the ones that needed by Ignite CLI and more can be added as needed. -package nodetime - -import ( - "archive/tar" - "bytes" - "compress/gzip" - "io" - "sync" - - "github.com/ignite/ignite-files/nodetime" - - "github.com/ignite/cli/v28/ignite/pkg/localfs" -) - -// the list of CLIs included. -const ( - // CommandTSProto is https://github.com/stephenh/ts-proto. - CommandTSProto CommandName = "ts-proto" - - // CommandSTA is https://github.com/acacode/swagger-typescript-api. - CommandSTA CommandName = "sta" - - // CommandSwaggerCombine is https://www.npmjs.com/package/swagger-combine. - CommandSwaggerCombine CommandName = "swagger-combine" -) - -// CommandName represents a high level command under nodetime. -type CommandName string - -var ( - onceBinary sync.Once - binary []byte -) - -// Binary returns the binary bytes of the executable. -func Binary() []byte { - onceBinary.Do(func() { - // untar the binary. - gzr, err := gzip.NewReader(bytes.NewReader(nodetime.Binary())) - if err != nil { - panic(err) - } - defer gzr.Close() - - tr := tar.NewReader(gzr) - - if _, err := tr.Next(); err != nil { - panic(err) - } - - if binary, err = io.ReadAll(tr); err != nil { - panic(err) - } - }) - - return binary -} - -// Command setups the nodetime binary and returns the command needed to execute c. -func Command(c CommandName) (command []string, cleanup func(), err error) { - cs := string(c) - path, cleanup, err := localfs.SaveBytesTemp(Binary(), cs, 0o755) - if err != nil { - return nil, nil, err - } - command = []string{ - path, - cs, - } - return command, cleanup, nil -} diff --git a/ignite/pkg/nodetime/programs/sta/sta.go b/ignite/pkg/nodetime/programs/sta/sta.go deleted file mode 100644 index b89acd778f..0000000000 --- a/ignite/pkg/nodetime/programs/sta/sta.go +++ /dev/null @@ -1,147 +0,0 @@ -// Package sta provides access to swagger-typescript-api CLI. -package sta - -import ( - "context" - "os" - "path/filepath" - - "github.com/ignite/cli/v28/ignite/pkg/cmdrunner/exec" - "github.com/ignite/cli/v28/ignite/pkg/nodetime" -) - -// Option configures Generate configs. -type Option func(*configs) - -// Configs holds Generate configs. -type configs struct { - command Cmd -} - -const routeNameTemplate = `<% -const { routeInfo, utils } = it; -const { - operationId, - method, - route, - moduleName, - responsesTypes, - description, - tags, - summary, - pathArgs, -} = routeInfo; -const { _, fmtToJSDocLine, require } = utils; - -const methodAliases = { - get: (pathName, hasPathInserts) => - _.camelCase(` + "`" + `${pathName}_${hasPathInserts ? "detail" : "list"}` + "`" + `), - post: (pathName, hasPathInserts) => _.camelCase(` + "`" + `${pathName}_create` + "`" + `), - put: (pathName, hasPathInserts) => _.camelCase(` + "`" + `${pathName}_update` + "`" + `), - patch: (pathName, hasPathInserts) => _.camelCase(` + "`" + `${pathName}_partial_update` + "`" + `), - delete: (pathName, hasPathInserts) => _.camelCase(` + "`" + `${pathName}_delete` + "`" + `), -}; - -const createCustomOperationId = (method, route, moduleName) => { - const hasPathInserts = /\{(\w){1,}\}/g.test(route); - const splitedRouteBySlash = _.compact(_.replace(route, /\{(\w){1,}\}/g, "").split("/")); - const routeParts = (splitedRouteBySlash.length > 1 - ? splitedRouteBySlash.splice(1) - : splitedRouteBySlash - ).join("_"); - return routeParts.length > 3 && methodAliases[method] - ? methodAliases[method](routeParts, hasPathInserts) - : _.camelCase(_.lowerCase(method) + "_" + [moduleName].join("_")) || "index"; -}; - -if (operationId) { - let routeName = operationId.replace('_',''); - return routeName[0].toLowerCase() + routeName.slice(1); -} -if (route === "/") - return _.camelCase(` + "`" + `${_.lowerCase(method)}Root` + "`" + `); - -return createCustomOperationId(method, route, moduleName); -%>` - -// WithCommand assigns a typescript API generator command to use for code generation. -// This allows to use a single nodetime STA generator binary in multiple code generation -// calls. Otherwise, `Generate` creates a new generator binary each time it is called. -func WithCommand(command Cmd) Option { - return func(c *configs) { - c.command = command - } -} - -// Cmd contains the information necessary to execute the typescript API generator command. -type Cmd struct { - command []string -} - -// Command returns the strings to execute the typescript API generator command. -func (c Cmd) Command() []string { - return c.command -} - -// Command sets the typescript API generator binary up and returns the command needed to execute it. -func Command() (command Cmd, cleanup func(), err error) { - c, cleanup, err := nodetime.Command(nodetime.CommandSTA) - command = Cmd{c} - return -} - -// Generate generates client code and TS types to outPath from an OpenAPI spec that resides at specPath. -func Generate(ctx context.Context, outPath, specPath string, options ...Option) error { - c := configs{} - - for _, o := range options { - o(&c) - } - - command := c.command.Command() - if command == nil { - cmd, cleanup, err := Command() - if err != nil { - return err - } - - defer cleanup() - - command = cmd.Command() - } - - dir := filepath.Dir(outPath) - file := filepath.Base(outPath) - - // generate temp template directory - templateTmpPath, err := os.MkdirTemp("", "gen-js-sta-templates") - if err != nil { - return err - } - - outTemplate := filepath.Join(templateTmpPath, "route-name.eta") - err = os.WriteFile(outTemplate, []byte(routeNameTemplate), 0o644) - if err != nil { - return err - } - - defer os.RemoveAll(templateTmpPath) - - // command constructs the sta command. - command = append(command, []string{ - "--axios", - "--module-name-index", - "-1", // -1 removes the route namespace - "-p", - specPath, - "--templates", - templateTmpPath, - "-o", - dir, - "-n", - file, - }...) - - // execute the command. - return exec.Exec(ctx, command, exec.IncludeStdLogsToError()) -} diff --git a/ignite/pkg/nodetime/programs/swagger-combine/swagger-combine.go b/ignite/pkg/nodetime/programs/swagger-combine/swagger-combine.go deleted file mode 100644 index 32ca26528b..0000000000 --- a/ignite/pkg/nodetime/programs/swagger-combine/swagger-combine.go +++ /dev/null @@ -1,107 +0,0 @@ -package swaggercombine - -import ( - "context" - "crypto/md5" - "encoding/hex" - "encoding/json" - "fmt" - "io" - "os" - "regexp" - - "github.com/ignite/cli/v28/ignite/pkg/cmdrunner/exec" -) - -// Config represent swagger-combine config. -type Config struct { - Swagger string `json:"swagger"` - Info Info `json:"info"` - APIs []API `json:"apis"` -} - -type Info struct { - Title string `json:"title"` - Name string `json:"name"` - Description string `json:"description"` -} - -type API struct { - ID string `json:"-"` - URL string `json:"url"` - OperationIDs OperationIDs `json:"operationIds"` - Dereference struct { - Circular string `json:"circular"` - } `json:"dereference"` -} - -type OperationIDs struct { - Rename map[string]string `json:"rename"` -} - -var opReg = regexp.MustCompile(`(?m)operationId.+?(\w+)`) - -// AddSpec adds a new OpenAPI spec to Config by path in the fs and unique id of spec. -func (c *Config) AddSpec(id, path string) error { - // make operationId fields unique. - f, err := os.Open(path) - if err != nil { - return err - } - defer f.Close() - - content, err := io.ReadAll(f) - if err != nil { - return err - } - - hash := hex.EncodeToString(md5.New().Sum([]byte(path))) - ops := opReg.FindAllStringSubmatch(string(content), -1) - rename := make(map[string]string, len(ops)) - - for _, op := range ops { - o := op[1] - rename[o] = fmt.Sprintf("%s_%s_%s", id, o, hash) - } - - // add api with replaced operation ids. - c.APIs = append(c.APIs, API{ - ID: id, - URL: path, - OperationIDs: OperationIDs{Rename: rename}, - // Added due to https://github.com/maxdome/swagger-combine/pull/110 after enabling more services to be generated in #835 - Dereference: struct { - Circular string `json:"circular"` - }(struct{ Circular string }{Circular: "ignore"}), - }) - - return nil -} - -// 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, command []string, out string) error { - f, err := os.CreateTemp("", "*.json") - if err != nil { - return err - } - defer os.Remove(f.Name()) - - if err := json.NewEncoder(f).Encode(c); err != nil { - return err - } - if err := f.Close(); err != nil { - return err - } - - command = append(command, []string{ - f.Name(), - "-o", out, - "-f", "yaml", - "--continueOnConflictingPaths", "true", - "--includeDefinitions", "true", - }...) - - // execute the command. - return exec.Exec(ctx, command, exec.IncludeStdLogsToError()) -} diff --git a/ignite/pkg/nodetime/programs/ts-proto/tsproto.go b/ignite/pkg/nodetime/programs/ts-proto/tsproto.go deleted file mode 100644 index 5aa14a700c..0000000000 --- a/ignite/pkg/nodetime/programs/ts-proto/tsproto.go +++ /dev/null @@ -1,65 +0,0 @@ -// Package tsproto provides access to protoc-gen-ts_proto protoc plugin. -package tsproto - -import ( - "fmt" - "os" - "path/filepath" - "strings" - - "github.com/ignite/cli/v28/ignite/pkg/nodetime" -) - -const ( - pluginName = "protoc-gen-ts_proto" - scriptTemplate = "#!/bin/bash\n%s $@\n" -) - -// BinaryPath returns the path to the binary of the ts-proto plugin, so it can be passed to -// protoc via --plugin option. -// -// protoc is very picky about binary names of its plugins. for ts-proto, binary name -// will be protoc-gen-ts_proto. -// see why: https://github.com/stephenh/ts-proto/blob/7f76c05/README.markdown#quickstart. -func BinaryPath() (path string, cleanup func(), err error) { - // Create binary for the TypeScript protobuf generator - command, cleanupBin, err := nodetime.Command(nodetime.CommandTSProto) - if err != nil { - return path, cleanup, err - } - - defer func() { - if err != nil { - cleanupBin() - } - }() - - // Create a random directory for the script that runs the TypeScript protobuf generator. - // This is required to avoid potential flaky integration tests caused by one concurrent - // test overwriting the generator script while it is being run in a separate test process. - tmpDir, err := os.MkdirTemp("", "ts_proto_plugin") - if err != nil { - return path, cleanup, err - } - - cleanupScriptDir := func() { os.RemoveAll(tmpDir) } - - defer func() { - if err != nil { - cleanupScriptDir() - } - }() - - cleanup = func() { - cleanupBin() - cleanupScriptDir() - } - - // Wrap the TypeScript protobuf generator in a script with a fixed name - // located in a random temporary directory. - script := fmt.Sprintf(scriptTemplate, strings.Join(command, " ")) - path = filepath.Join(tmpDir, pluginName) - err = os.WriteFile(path, []byte(script), 0o755) - - return path, cleanup, err -} diff --git a/ignite/templates/app/files/proto/buf.lock b/ignite/templates/app/files/proto/buf.lock index 1ac5cf1729..8441ef4d01 100644 --- a/ignite/templates/app/files/proto/buf.lock +++ b/ignite/templates/app/files/proto/buf.lock @@ -34,4 +34,4 @@ deps: owner: protocolbuffers repository: wellknowntypes commit: 3186086b2a8e44d9acdeeef2423c5de7 - digest: shake256:3b9dc2f56d9ed2e4001f95b701985fd803f7e2559b19b6a18d5f4e792cfdde320e765638de69fff037edc202b0006532d7ff19eab9465526b5ec628e4a5e5a1a \ No newline at end of file + digest: shake256:3b9dc2f56d9ed2e4001f95b701985fd803f7e2559b19b6a18d5f4e792cfdde320e765638de69fff037edc202b0006532d7ff19eab9465526b5ec628e4a5e5a1a diff --git a/integration/cosmosgen/cosmosgen_test.go b/integration/cosmosgen/cosmosgen_test.go index 1be472f62f..bb7c7cf232 100644 --- a/integration/cosmosgen/cosmosgen_test.go +++ b/integration/cosmosgen/cosmosgen_test.go @@ -13,8 +13,6 @@ import ( ) func TestCosmosGenScaffold(t *testing.T) { - t.Skip() - var ( env = envtest.New(t) app = env.Scaffold("github.com/test/blog") @@ -100,19 +98,15 @@ func TestCosmosGenScaffold(t *testing.T) { )), )) - var ( - vueDirGenerated = filepath.Join(app.SourcePath(), "vue/src/store/generated") - tsDirGenerated = filepath.Join(app.SourcePath(), "ts-client") - ) - require.NoError(t, os.RemoveAll(vueDirGenerated)) + tsDirGenerated := filepath.Join(app.SourcePath(), "ts-client") require.NoError(t, os.RemoveAll(tsDirGenerated)) - env.Must(env.Exec("generate vue and typescript", + env.Must(env.Exec("generate typescript", step.NewSteps(step.New( step.Exec( envtest.IgniteApp, "g", - "vuex", + "ts-client", "--yes", "--clear-cache", ), @@ -141,17 +135,15 @@ func TestCosmosGenScaffold(t *testing.T) { "cosmos.upgrade.v1beta1", "cosmos.vesting.v1beta1", // custom modules - "test.blog.blog", - "test.blog.withmsg", - "test.blog.withoutmsg", + "blog.blog", + "blog.withmsg", + "blog.withoutmsg", } for _, mod := range expectedModules { - for _, dir := range []string{vueDirGenerated, tsDirGenerated} { - _, err := os.Stat(filepath.Join(dir, mod)) - if assert.False(t, os.IsNotExist(err), "missing module %q in %s", mod, dir) { - assert.NoError(t, err) - } + _, err := os.Stat(filepath.Join(tsDirGenerated, mod)) + if assert.False(t, os.IsNotExist(err), "missing module %q in %s", mod, tsDirGenerated) { + assert.NoError(t, err) } } }