diff --git a/scripts/data/gen-nodetime/nodetime b/scripts/data/gen-nodetime/nodetime index f5465f1c80..19be05b792 100755 --- a/scripts/data/gen-nodetime/nodetime +++ b/scripts/data/gen-nodetime/nodetime @@ -8,7 +8,6 @@ main(); function main() { switch (mode) { case "ts-proto": require("ts-proto/protoc-gen-ts_proto"); return; - case "tsc": require("typescript/bin/tsc"); return; case "sta": require("swagger-typescript-api/index"); return; case "swagger-combine": require("swagger-combine/bin/swagger-combine"); return; case "ibc-setup": require("@confio/relayer/build/binary/ibc-setup/index"); return; diff --git a/starport/pkg/cosmosgen/generate_javascript.go b/starport/pkg/cosmosgen/generate_javascript.go index 5464152c8e..2d2e3ddcc6 100644 --- a/starport/pkg/cosmosgen/generate_javascript.go +++ b/starport/pkg/cosmosgen/generate_javascript.go @@ -13,7 +13,6 @@ import ( "github.com/tendermint/starport/starport/pkg/localfs" "github.com/tendermint/starport/starport/pkg/nodetime/programs/sta" tsproto "github.com/tendermint/starport/starport/pkg/nodetime/programs/ts-proto" - "github.com/tendermint/starport/starport/pkg/nodetime/programs/tsc" "github.com/tendermint/starport/starport/pkg/protoc" "github.com/tendermint/starport/starport/pkg/xstrings" "golang.org/x/sync/errgroup" @@ -153,8 +152,8 @@ func (g *jsGenerator) generateModule(ctx context.Context, tsprotoPluginPath, app return err } } - // generate .js and .d.ts files for all ts files. - return tsc.Generate(g.g.ctx, tscConfig(storeDirPath+"/**/*.ts")) + + return nil } func (g *jsGenerator) generateVuexModuleLoader() error { @@ -209,20 +208,9 @@ func (g *jsGenerator) generateVuexModuleLoader() error { }) } - loaderPath := filepath.Join(g.g.o.vuexStoreRootPath, "index.ts") - if err := templateVuexRoot.Write(g.g.o.vuexStoreRootPath, "", data); err != nil { return err } - return tsc.Generate(g.g.ctx, tscConfig(loaderPath)) -} - -func tscConfig(include ...string) tsc.Config { - return tsc.Config{ - Include: include, - CompilerOptions: tsc.CompilerOptions{ - Declaration: true, - }, - } + return nil } diff --git a/starport/pkg/nodetime/nodetime.go b/starport/pkg/nodetime/nodetime.go index 960cb04d41..746fb9180a 100644 --- a/starport/pkg/nodetime/nodetime.go +++ b/starport/pkg/nodetime/nodetime.go @@ -19,9 +19,6 @@ const ( // CommandTSProto is https://github.com/stephenh/ts-proto. CommandTSProto CommandName = "ts-proto" - // CommandTSC is https://github.com/microsoft/TypeScript. - CommandTSC CommandName = "tsc" - // CommandSTA is https://github.com/acacode/swagger-typescript-api. CommandSTA CommandName = "sta" diff --git a/starport/pkg/nodetime/programs/tsc/tsc.go b/starport/pkg/nodetime/programs/tsc/tsc.go deleted file mode 100644 index 398b9640b3..0000000000 --- a/starport/pkg/nodetime/programs/tsc/tsc.go +++ /dev/null @@ -1,86 +0,0 @@ -package tsc - -import ( - "context" - "os" - "path/filepath" - - "github.com/imdario/mergo" - "github.com/tendermint/starport/starport/pkg/cmdrunner/exec" - "github.com/tendermint/starport/starport/pkg/confile" - "github.com/tendermint/starport/starport/pkg/nodetime" -) - -const nodeModulesPath = "/snapshot/gen-nodetime/node_modules" - -var ( - defaultConfig = func() Config { - return Config{ - CompilerOptions: CompilerOptions{ - BaseURL: nodeModulesPath, - ModuleResolution: "node", - Target: "es2020", - Module: "es2020", - TypeRoots: []string{filepath.Join(nodeModulesPath, "@types")}, - SkipLibCheck: true, - }, - } - } - tsconfig = func(dir string) string { return filepath.Join(dir, "tsconfig.json") } -) - -// Config represents tsconfig.json. -type Config struct { - Include []string `json:"include"` - CompilerOptions CompilerOptions `json:"compilerOptions"` -} - -// CompilerOptions section of tsconfig.json. -type CompilerOptions struct { - BaseURL string `json:"baseUrl"` - ModuleResolution string `json:"moduleResolution"` - Target string `json:"target"` - Module string `json:"module"` - TypeRoots []string `json:"typeRoots"` - Declaration bool `json:"declaration"` - SkipLibCheck bool `json:"skipLibCheck"` -} - -// Generate transpiles TS into JS by given TS config. -func Generate(ctx context.Context, config Config) error { - command, cleanup, err := nodetime.Command(nodetime.CommandTSC) - if err != nil { - return err - } - defer cleanup() - - dconfig := defaultConfig() - - if err := mergo.Merge(&dconfig, config, mergo.WithOverride); err != nil { - return err - } - - // save the config into a temp file in the fs. - dir, err := os.MkdirTemp("", "") - if err != nil { - return err - } - defer os.RemoveAll(dir) - - path := tsconfig(dir) - - if err := confile. - New(confile.DefaultJSONEncodingCreator, path). - Save(dconfig); err != nil { - return err - } - - // command constructs the tsc command. - command = append(command, []string{ - "-b", - path, - }...) - - // execute the command. - return exec.Exec(ctx, command, exec.IncludeStdLogsToError()) -}