From 9c8ccb0c968cd40e47dbf8cd7246a2ce7de1dacc Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Sun, 28 Apr 2024 05:51:07 +0200 Subject: [PATCH] refactor!: remove vuex generation (#4111) remove vuex generation since is deprecated for a long time --- changelog.md | 1 + ignite/cmd/generate.go | 1 - ignite/cmd/generate_vuex.go | 56 ----- ignite/config/chain/config.go | 15 -- ignite/pkg/cosmosgen/cosmosgen.go | 31 --- ignite/pkg/cosmosgen/generate_vuex.go | 219 ------------------ .../cosmosgen/templates/vue-root/index.ts.tpl | 27 --- .../templates/vue-root/local-check.js.tpl | 15 -- .../templates/vue-root/package.json.tpl | 33 --- .../templates/vue-root/postinstall.js.tpl | 9 - .../templates/vue-root/tsconfig.json.tpl | 11 - .../pkg/cosmosgen/templates/vue/index.ts.tpl | 186 --------------- ignite/services/chain/generate.go | 54 +---- ignite/services/scaffolder/scaffolder.go | 19 +- integration/chain/cmd_serve_test.go | 30 --- integration/cosmosgen/cosmosgen_test.go | 16 +- 16 files changed, 10 insertions(+), 713 deletions(-) delete mode 100644 ignite/cmd/generate_vuex.go delete mode 100644 ignite/pkg/cosmosgen/generate_vuex.go delete mode 100644 ignite/pkg/cosmosgen/templates/vue-root/index.ts.tpl delete mode 100644 ignite/pkg/cosmosgen/templates/vue-root/local-check.js.tpl delete mode 100644 ignite/pkg/cosmosgen/templates/vue-root/package.json.tpl delete mode 100644 ignite/pkg/cosmosgen/templates/vue-root/postinstall.js.tpl delete mode 100644 ignite/pkg/cosmosgen/templates/vue-root/tsconfig.json.tpl delete mode 100644 ignite/pkg/cosmosgen/templates/vue/index.ts.tpl diff --git a/changelog.md b/changelog.md index b1b66ecdd6..618e0f1187 100644 --- a/changelog.md +++ b/changelog.md @@ -14,6 +14,7 @@ - [#3718](https://github.com/ignite/cli/pull/3718) Add `gen-mig-diffs` tool app to compare scaffold output of two versions of ignite - [#4077](https://github.com/ignite/cli/pull/4077) Merge the swagger files manually instead use nodetime `swagger-combine` - [#4100](https://github.com/ignite/cli/pull/4100) Set the `proto-dir` flag only for the `scaffold chain` command and use the proto path from the config +- [#4111](https://github.com/ignite/cli/pull/4111) Remove vuex generation ### Changes diff --git a/ignite/cmd/generate.go b/ignite/cmd/generate.go index 4e3ad4d602..c651a5b9d4 100644 --- a/ignite/cmd/generate.go +++ b/ignite/cmd/generate.go @@ -34,7 +34,6 @@ meant to be edited by hand. c.AddCommand(NewGenerateGo()) c.AddCommand(NewGenerateTSClient()) - c.AddCommand(NewGenerateVuex()) c.AddCommand(NewGenerateComposables()) c.AddCommand(NewGenerateHooks()) c.AddCommand(NewGenerateOpenAPI()) diff --git a/ignite/cmd/generate_vuex.go b/ignite/cmd/generate_vuex.go deleted file mode 100644 index f2a17179ba..0000000000 --- a/ignite/cmd/generate_vuex.go +++ /dev/null @@ -1,56 +0,0 @@ -package ignitecmd - -import ( - "github.com/spf13/cobra" - - "github.com/ignite/cli/v29/ignite/pkg/cliui" - "github.com/ignite/cli/v29/ignite/pkg/cliui/icons" - "github.com/ignite/cli/v29/ignite/services/chain" -) - -func NewGenerateVuex() *cobra.Command { - c := &cobra.Command{ - Use: "vuex", - Short: "*DEPRECATED* TypeScript frontend client and Vuex stores", - RunE: generateVuexHandler, - } - - c.Flags().AddFlagSet(flagSetYes()) - c.Flags().StringP(flagOutput, "o", "", "Vuex store output path") - - return c -} - -func generateVuexHandler(cmd *cobra.Command, _ []string) error { - session := cliui.New(cliui.StartSpinnerWithText(statusGenerating)) - defer session.End() - - c, err := chain.NewWithHomeFlags( - cmd, - chain.WithOutputer(session), - chain.CollectEvents(session.EventBus()), - chain.PrintGeneratedPaths(), - ) - if err != nil { - return err - } - - cacheStorage, err := newCache(cmd) - if err != nil { - return err - } - - output, _ := cmd.Flags().GetString(flagOutput) - - var opts []chain.GenerateTarget - if flagGetEnableProtoVendor(cmd) { - opts = append(opts, chain.GenerateProtoVendor()) - } - - err = c.Generate(cmd.Context(), cacheStorage, chain.GenerateVuex(output), opts...) - if err != nil { - return err - } - - return session.Println(icons.OK, "Generated Typescript Client and Vuex stores") -} diff --git a/ignite/config/chain/config.go b/ignite/config/chain/config.go index 5810e25795..d18a3ee5ae 100644 --- a/ignite/config/chain/config.go +++ b/ignite/config/chain/config.go @@ -30,10 +30,6 @@ var ( // The path is relative to the app's directory. DefaultReactPath = "react" - // DefaultVuexPath defines the default relative path to use when generating Vuex stores for a Vue app. - // The path is relative to the app's directory. - DefaultVuexPath = "vue/src/store" - // DefaultComposablesPath defines the default relative path to use when generating useQuery composables for a Vue app. // The path is relative to the app's directory. DefaultComposablesPath = "vue/src/composables" @@ -91,17 +87,6 @@ func TSClientPath(conf Config) string { return DefaultTSClientPath } -// VuexPath returns the relative path to the Vuex stores directory. -// Path is relative to the app's directory. -func VuexPath(conf *Config) string { - //nolint:staticcheck,nolintlint //ignore SA1019 until vuex config option is removed - if path := strings.TrimSpace(conf.Client.Vuex.Path); path != "" { - return filepath.Clean(path) - } - - return DefaultVuexPath -} - // ComposablesPath returns the relative path to the Vue useQuery composables directory. // Path is relative to the app's directory. func ComposablesPath(conf *Config) string { diff --git a/ignite/pkg/cosmosgen/cosmosgen.go b/ignite/pkg/cosmosgen/cosmosgen.go index 01a6c63027..4ea01a58f1 100644 --- a/ignite/pkg/cosmosgen/cosmosgen.go +++ b/ignite/pkg/cosmosgen/cosmosgen.go @@ -27,9 +27,6 @@ type generateOptions struct { jsOut func(module.Module) string tsClientRootPath string - vuexOut func(module.Module) string - vuexRootPath string - composablesOut func(module.Module) string composablesRootPath string @@ -55,13 +52,6 @@ func WithTSClientGeneration(out ModulePathFunc, tsClientRootPath string, useCach } } -func WithVuexGeneration(out ModulePathFunc, vuexRootPath string) Option { - return func(o *generateOptions) { - o.vuexOut = out - o.vuexRootPath = vuexRootPath - } -} - func WithComposablesGeneration(out ModulePathFunc, composablesRootPath string) Option { return func(o *generateOptions) { o.composablesOut = out @@ -204,27 +194,6 @@ func Generate(ctx context.Context, cacheStorage cache.Storage, appPath, protoDir } } - if g.opts.vuexOut != nil { - if err := g.generateVuex(); err != nil { - return err - } - - // Update Vuex store dependencies when Vuex stores are generated. - // This update is required to link the "ts-client" folder so the - // package is available during development before publishing it. - if err := g.updateVuexDependencies(); err != nil { - return err - } - - // Update Vue app dependencies when Vuex stores are generated. - // This update is required to link the "ts-client" folder so the - // package is available during development before publishing it. - if err := g.updateVueDependencies(); err != nil { - return err - } - - } - if g.opts.composablesRootPath != "" { if err := g.generateComposables("vue"); err != nil { return err diff --git a/ignite/pkg/cosmosgen/generate_vuex.go b/ignite/pkg/cosmosgen/generate_vuex.go deleted file mode 100644 index 160a4c653d..0000000000 --- a/ignite/pkg/cosmosgen/generate_vuex.go +++ /dev/null @@ -1,219 +0,0 @@ -package cosmosgen - -import ( - "encoding/json" - "fmt" - "os" - "path/filepath" - "strings" - - "github.com/imdario/mergo" - "golang.org/x/sync/errgroup" - - chainconfig "github.com/ignite/cli/v29/ignite/config/chain" - "github.com/ignite/cli/v29/ignite/pkg/cosmosanalysis/module" - "github.com/ignite/cli/v29/ignite/pkg/errors" - "github.com/ignite/cli/v29/ignite/pkg/gomodulepath" -) - -type vuexGenerator struct { - g *generator -} - -func newVuexGenerator(g *generator) *vuexGenerator { - return &vuexGenerator{g} -} - -func (g *generator) updateVueDependencies() error { - // Init the path to the "vue" folders inside the app - vuePath := filepath.Join(g.appPath, chainconfig.DefaultVuePath) - packagesPath := filepath.Join(vuePath, "package.json") - if _, err := os.Stat(packagesPath); errors.Is(err, os.ErrNotExist) { - return nil - } - - // Read the Vue app package file - vuePkgRaw, err := os.ReadFile(packagesPath) - if err != nil { - return err - } - - var vuePkg map[string]interface{} - - if err := json.Unmarshal(vuePkgRaw, &vuePkg); err != nil { - return errors.Errorf("error parsing %s: %w", packagesPath, err) - } - - chainPath, _, err := gomodulepath.Find(g.appPath) - if err != nil { - return err - } - - // Make sure the TS client path is absolute - tsClientPath, err := filepath.Abs(g.opts.tsClientRootPath) - if err != nil { - return errors.Errorf("failed to read the absolute typescript client path: %w", err) - } - - // Add the link to the ts-client to the VUE app dependencies - appModulePath := gomodulepath.ExtractAppPath(chainPath.RawPath) - tsClientNS := strings.ReplaceAll(appModulePath, "/", "-") - tsClientName := fmt.Sprintf("%s-client-ts", tsClientNS) - tsClientVueRelPath, err := filepath.Rel(vuePath, tsClientPath) - if err != nil { - return err - } - - err = mergo.Merge(&vuePkg, map[string]interface{}{ - "dependencies": map[string]interface{}{ - tsClientName: fmt.Sprintf("file:%s", tsClientVueRelPath), - }, - }) - if err != nil { - return errors.Errorf("failed to link ts-client dependency to the Vue app: %w", err) - } - - // Save the modified package.json with the new dependencies - vueFile, err := os.OpenFile(packagesPath, os.O_RDWR|os.O_TRUNC, 0o644) - if err != nil { - return err - } - defer vueFile.Close() - - vueEnc := json.NewEncoder(vueFile) - vueEnc.SetIndent("", " ") - vueEnc.SetEscapeHTML(false) - if err := vueEnc.Encode(vuePkg); err != nil { - return errors.Errorf("error updating %s: %w", packagesPath, err) - } - - return nil -} - -func (g *generator) updateVuexDependencies() error { - // Init the path to the "vuex" folders inside the app - vuexPackagesPath := filepath.Join(g.opts.vuexRootPath, "package.json") - - if _, err := os.Stat(vuexPackagesPath); errors.Is(err, os.ErrNotExist) { - return nil - } - - // Read the Vuex stores package file - vuexPkgRaw, err := os.ReadFile(vuexPackagesPath) - if err != nil { - return err - } - - var vuexPkg map[string]interface{} - - if err := json.Unmarshal(vuexPkgRaw, &vuexPkg); err != nil { - return errors.Errorf("error parsing %s: %w", vuexPackagesPath, err) - } - - chainPath, _, err := gomodulepath.Find(g.appPath) - if err != nil { - return err - } - - // Make sure the TS client path is absolute - tsClientPath, err := filepath.Abs(g.opts.tsClientRootPath) - if err != nil { - return errors.Errorf("failed to read the absolute typescript client path: %w", err) - } - - // Add the link to the ts-client to the VUE app dependencies - appModulePath := gomodulepath.ExtractAppPath(chainPath.RawPath) - tsClientNS := strings.ReplaceAll(appModulePath, "/", "-") - tsClientName := fmt.Sprintf("%s-client-ts", tsClientNS) - tsClientVuexRelPath, err := filepath.Rel(g.opts.vuexRootPath, tsClientPath) - if err != nil { - return err - } - - err = mergo.Merge(&vuexPkg, map[string]interface{}{ - "dependencies": map[string]interface{}{ - tsClientName: fmt.Sprintf("file:%s", tsClientVuexRelPath), - }, - }) - if err != nil { - return errors.Errorf("failed to link ts-client dependency to the Vuex stores: %w", err) - } - - // Save the modified package.json with the new dependencies - vuexFile, err := os.OpenFile(vuexPackagesPath, os.O_RDWR|os.O_TRUNC, 0o644) - if err != nil { - return err - } - defer vuexFile.Close() - - vuexEnc := json.NewEncoder(vuexFile) - vuexEnc.SetIndent("", " ") - vuexEnc.SetEscapeHTML(false) - if err := vuexEnc.Encode(vuexPkg); err != nil { - return errors.Errorf("error updating %s: %w", vuexPackagesPath, err) - } - - return nil -} - -func (g *generator) generateVuex() error { - chainPath, _, err := gomodulepath.Find(g.appPath) - if err != nil { - return err - } - - appModulePath := gomodulepath.ExtractAppPath(chainPath.RawPath) - data := generatePayload{ - Modules: g.appModules, - PackageNS: strings.ReplaceAll(appModulePath, "/", "-"), - } - - for _, modules := range g.thirdModules { - data.Modules = append(data.Modules, modules...) - } - - vsg := newVuexGenerator(g) - if err := vsg.generateVueTemplates(data); err != nil { - return err - } - - return vsg.generateRootTemplates(data) -} - -func (g *vuexGenerator) generateVueTemplates(p generatePayload) error { - gg := &errgroup.Group{} - - for _, m := range p.Modules { - m := m - - gg.Go(func() error { - return g.generateVueTemplate(m, p) - }) - } - - return gg.Wait() -} - -func (g *vuexGenerator) generateVueTemplate(m module.Module, p generatePayload) error { - outDir := g.g.opts.vuexOut(m) - if err := os.MkdirAll(outDir, 0o766); err != nil { - return err - } - - return templateTSClientVue.Write(outDir, "", struct { - Module module.Module - PackageNS string - }{ - Module: m, - PackageNS: p.PackageNS, - }) -} - -func (g *vuexGenerator) generateRootTemplates(p generatePayload) error { - outDir := g.g.opts.vuexRootPath - if err := os.MkdirAll(outDir, 0o766); err != nil { - return err - } - - return templateTSClientVueRoot.Write(outDir, "", p) -} diff --git a/ignite/pkg/cosmosgen/templates/vue-root/index.ts.tpl b/ignite/pkg/cosmosgen/templates/vue-root/index.ts.tpl deleted file mode 100644 index 3f587f2b8d..0000000000 --- a/ignite/pkg/cosmosgen/templates/vue-root/index.ts.tpl +++ /dev/null @@ -1,27 +0,0 @@ -// THIS FILE IS GENERATED AUTOMATICALLY. DO NOT MODIFY. - -{{ range .Modules }}import {{ camelCaseUpperSta .Pkg.Name }} from './{{ .Pkg.Name }}' -{{ end }} - -export default { - {{ range .Modules }}{{ camelCaseUpperSta .Pkg.Name }}: load({{ camelCaseUpperSta .Pkg.Name }}, '{{ .Pkg.Name }}'), - {{ end }} -} - - -function load(mod, fullns) { - return function init(store) { - if (store.hasModule([fullns])) { - throw new Error('Duplicate module name detected: '+ fullns) - }else{ - store.registerModule([fullns], mod) - store.subscribe((mutation) => { - if (mutation.type == 'common/env/INITIALIZE_WS_COMPLETE') { - store.dispatch(fullns+ '/init', null, { - root: true - }) - } - }) - } - } -} \ No newline at end of file diff --git a/ignite/pkg/cosmosgen/templates/vue-root/local-check.js.tpl b/ignite/pkg/cosmosgen/templates/vue-root/local-check.js.tpl deleted file mode 100644 index 1cb66c57d9..0000000000 --- a/ignite/pkg/cosmosgen/templates/vue-root/local-check.js.tpl +++ /dev/null @@ -1,15 +0,0 @@ -/* eslint-env node */ -const pkgjson = require("./package.json"); - -for (let pkg in pkgjson.dependencies) { - if (pkgjson.dependencies[pkg].startsWith("file:")) { - console.error( - "\x1b[31m%s\x1b[0m", - `Package '${pkg}' located at '${pkgjson.dependencies[pkg].replace( - "file:", - "" - )}' needs to be published and your package.json file updated before publishing.` - ); - process.exit(1) - } -} \ No newline at end of file diff --git a/ignite/pkg/cosmosgen/templates/vue-root/package.json.tpl b/ignite/pkg/cosmosgen/templates/vue-root/package.json.tpl deleted file mode 100644 index 91eac37683..0000000000 --- a/ignite/pkg/cosmosgen/templates/vue-root/package.json.tpl +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "{{ .PackageNS }}-vuex", - "version": "0.0.1", - "description": "Autogenerated Vuex Stores", - "author": "Ignite Codegen ", - "license": "Apache-2.0", - "licenses": [ - { - "type": "Apache-2.0", - "url": "http://www.apache.org/licenses/LICENSE-2.0" - } - ], - "scripts": { - "build": "tsc", - "postinstall": "node postinstall.js", - "prepublishOnly": "node local-check.js && tsc" - }, - "main": "./lib/index.js", - "publishConfig": { - "access": "public" - }, - "dependencies": { - "buffer": "^6.0.3" - }, - "devDependencies": { - "typescript": "^4.8.4" - }, - "peerDependencies": { - "@cosmjs/proto-signing": "0.27.0", - "@cosmjs/stargate": "0.27.0", - "vue": "3.2.31" - } -} diff --git a/ignite/pkg/cosmosgen/templates/vue-root/postinstall.js.tpl b/ignite/pkg/cosmosgen/templates/vue-root/postinstall.js.tpl deleted file mode 100644 index 4ce12284c0..0000000000 --- a/ignite/pkg/cosmosgen/templates/vue-root/postinstall.js.tpl +++ /dev/null @@ -1,9 +0,0 @@ -/* eslint-env node */ -const pkgjson = require("./package.json"); -var exec = require("child_process").exec; - -for (let pkg in pkgjson.dependencies) { - if (pkgjson.dependencies[pkg].startsWith("file:")) { - exec(`cd ./node_modules/${pkg} && npm install`); - } -} \ No newline at end of file diff --git a/ignite/pkg/cosmosgen/templates/vue-root/tsconfig.json.tpl b/ignite/pkg/cosmosgen/templates/vue-root/tsconfig.json.tpl deleted file mode 100644 index 87d99d675b..0000000000 --- a/ignite/pkg/cosmosgen/templates/vue-root/tsconfig.json.tpl +++ /dev/null @@ -1,11 +0,0 @@ -{ - "compilerOptions": { - "target": "es2020", - "module": "es2020", /* Specify the root folder within your source files. */ - "moduleResolution": "node", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./lib", - "esModuleInterop": true, - "strict": false, - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - } -} diff --git a/ignite/pkg/cosmosgen/templates/vue/index.ts.tpl b/ignite/pkg/cosmosgen/templates/vue/index.ts.tpl deleted file mode 100644 index e9cc035af8..0000000000 --- a/ignite/pkg/cosmosgen/templates/vue/index.ts.tpl +++ /dev/null @@ -1,186 +0,0 @@ -import { Client, registry, MissingWalletError } from '{{ .PackageNS }}-client-ts' - -{{ range .Module.Types }}import { {{ .Name }} } from "{{ $.PackageNS }}-client-ts/{{ $.Module.Pkg.Name }}/types" -{{ end }} - -export { {{ range $i,$type:=.Module.Types }}{{ if (gt $i 0) }}, {{ end }}{{ $type.Name }}{{ end }} }; - -function initClient(vuexGetters) { - return new Client(vuexGetters['common/env/getEnv'], vuexGetters['common/wallet/signer']) -} - -function mergeResults(value, next_values) { - for (let prop of Object.keys(next_values)) { - if (Array.isArray(next_values[prop])) { - value[prop]=[...value[prop], ...next_values[prop]] - }else{ - value[prop]=next_values[prop] - } - } - return value -} - -type Field = { - name: string; - type: unknown; -} -function getStructure(template) { - let structure: {fields: Field[]} = { fields: [] } - for (const [key, value] of Object.entries(template)) { - let field = { name: key, type: typeof value } - structure.fields.push(field) - } - return structure -} -const getDefaultState = () => { - return { - {{ range .Module.HTTPQueries }}{{ .Name }}: {}, - {{ end }} - _Structure: { - {{ range .Module.Types }}{{ .Name }}: getStructure({{ .Name }}.fromPartial({})), - {{ end }} - }, - _Registry: registry, - _Subscriptions: new Set(), - } -} - -// initial state -const state = getDefaultState() - -export default { - namespaced: true, - state, - mutations: { - RESET_STATE(state) { - Object.assign(state, getDefaultState()) - }, - QUERY(state, { query, key, value }) { - state[query][JSON.stringify(key)] = value - }, - SUBSCRIBE(state, subscription) { - state._Subscriptions.add(JSON.stringify(subscription)) - }, - UNSUBSCRIBE(state, subscription) { - state._Subscriptions.delete(JSON.stringify(subscription)) - } - }, - getters: { - {{ range .Module.HTTPQueries }}get{{ .Name }}: (state) => (params = { params: {}}) => { - if (!( params).query) { - ( params).query=null - } - return state.{{ .Name }}[JSON.stringify(params)] ?? {} - }, - {{ end }} - getTypeStructure: (state) => (type) => { - return state._Structure[type].fields - }, - getRegistry: (state) => { - return state._Registry - } - }, - actions: { - init({ dispatch, rootGetters }) { - console.log('Vuex module: {{ .Module.Pkg.Name }} initialized!') - if (rootGetters['common/env/client']) { - rootGetters['common/env/client'].on('newblock', () => { - dispatch('StoreUpdate') - }) - } - }, - resetState({ commit }) { - commit('RESET_STATE') - }, - unsubscribe({ commit }, subscription) { - commit('UNSUBSCRIBE', subscription) - }, - async StoreUpdate({ state, dispatch }) { - state._Subscriptions.forEach(async (subscription) => { - try { - const sub=JSON.parse(subscription) - await dispatch(sub.action, sub.payload) - }catch(e) { - throw new Error('Subscriptions: ' + e.message) - } - }) - }, - {{ range .Module.HTTPQueries }} - {{ $FullName := .FullName }} - {{ $Name := .Name }} - {{ range $i,$rule := .Rules}} - {{ $n := "" }} - {{ if (gt $i 0) }} - {{ $n = inc $i }} - {{ end}} - async {{ $FullName }}{{ $n }}({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { - try { - const key = params ?? {}; - const client = initClient(rootGetters); - let value= (await client.{{ camelCaseUpperSta $.Module.Pkg.Name }}.query.{{ camelCase $FullName -}} - {{- $n -}}( - {{- range $j,$a :=$rule.Params -}} - {{- if (gt $j 0) -}}, {{ end }} key.{{ $a -}} - {{- end -}} - {{- if $rule.HasQuery -}} - {{- if $rule.Params -}}, {{ end -}} - query ?? undefined - {{- end -}} - {{- if $rule.HasBody -}} - {{- if or $rule.HasQuery $rule.Params}},{{ end -}} - {...key} - {{- end -}} - )).data - - {{ if $rule.HasQuery }} - while (all && ( value).pagination && ( value).pagination.next_key!=null) { - let next_values=(await client.{{ camelCaseUpperSta $.Module.Pkg.Name }}.query.{{ camelCase $FullName -}} - {{- $n -}}( - {{- range $j,$a :=$rule.Params }} key.{{$a}}, {{ end -}}{...query ?? {}, 'pagination.key':( value).pagination.next_key} as any - {{- if $rule.HasBody -}}, {...key} - {{- end -}} - )).data - value = mergeResults(value, next_values); - } - {{- end }} - commit('QUERY', { query: '{{ $Name }}', key: { params: {...key}, query}, value }) - if (subscribe) commit('SUBSCRIBE', { action: '{{ $FullName }}{{ $n }}', payload: { options: { all }, params: {...key},query }}) - return getters['get{{ $Name }}']( { params: {...key}, query}) ?? {} - } catch (e) { - throw new Error('QueryClient:{{ $FullName }}{{ $n }} API Node Unavailable. Could not perform query: ' + e.message) - - } - }, - {{ end }} - {{ end }} - {{ range .Module.Msgs }}async send{{ .Name }}({ rootGetters }, { value, fee = {amount: [], gas: "200000"}, memo = '' }) { - try { - const client=await initClient(rootGetters) - const fullFee = Array.isArray(fee) ? {amount: fee, gas: "200000"} :fee; - const result = await client.{{ camelCaseUpperSta $.Module.Pkg.Name }}.tx.send{{ .Name }}({ value, fee: fullFee, memo }) - return result - } catch (e) { - if (e == MissingWalletError) { - throw new Error('TxClient:{{ .Name }}:Init Could not initialize signing client. Wallet is required.') - }else{ - throw new Error('TxClient:{{ .Name }}:Send Could not broadcast Tx: '+ e.message) - } - } - }, - {{ end }} - {{ range .Module.Msgs }}async {{ .Name }}({ rootGetters }, { value }) { - try { - const client=initClient(rootGetters) - const msg = await client.{{ camelCaseUpperSta $.Module.Pkg.Name }}.tx.{{ camelCase .Name }}({value}) - return msg - } catch (e) { - if (e == MissingWalletError) { - throw new Error('TxClient:{{ .Name }}:Init Could not initialize signing client. Wallet is required.') - } else{ - throw new Error('TxClient:{{ .Name }}:Create Could not create message: ' + e.message) - } - } - }, - {{ end }} - } -} \ No newline at end of file diff --git a/ignite/services/chain/generate.go b/ignite/services/chain/generate.go index 4d40a923ce..f9a0f077d3 100644 --- a/ignite/services/chain/generate.go +++ b/ignite/services/chain/generate.go @@ -22,10 +22,8 @@ type generateOptions struct { isTSClientEnabled bool isComposablesEnabled bool isHooksEnabled bool - isVuexEnabled bool isOpenAPIEnabled bool tsClientPath string - vuexPath string composablesPath string hooksPath string } @@ -52,16 +50,6 @@ func GenerateTSClient(path string, useCache bool) GenerateTarget { } } -// GenerateVuex enables generating proto based Typescript Client and Vuex Stores. -func GenerateVuex(path string) GenerateTarget { - return func(o *generateOptions) { - o.isOpenAPIEnabled = true - o.isTSClientEnabled = true - o.isVuexEnabled = true - o.vuexPath = path - } -} - // GenerateComposables enables generating proto based Typescript Client and Vue 3 composables. func GenerateComposables(path string) GenerateTarget { return func(o *generateOptions) { @@ -120,11 +108,6 @@ func (c *Chain) generateFromConfig(ctx context.Context, cacheStorage cache.Stora targets = append(targets, GenerateTSClient(p, true)) } - //nolint:staticcheck //ignore SA1019 until vuex config option is removed - if p := conf.Client.Vuex.Path; p != "" { - targets = append(targets, GenerateVuex(p)) - } - if p := conf.Client.Composables.Path; p != "" { targets = append(targets, GenerateComposables(p)) } @@ -176,8 +159,8 @@ func (c *Chain) Generate( } var ( - openAPIPath, tsClientPath, vuexPath, composablesPath, hooksPath string - updateConfig bool + openAPIPath, tsClientPath, composablesPath, hooksPath string + updateConfig bool ) if targetOptions.isOpenAPIEnabled { @@ -221,31 +204,6 @@ func (c *Chain) Generate( ) } - if targetOptions.isVuexEnabled { - vuexPath = targetOptions.vuexPath - if vuexPath == "" { - vuexPath = chainconfig.VuexPath(conf) - - // When Vuex stores are generated make sure the config is updated - // with the output path when the client path option is empty. - conf.Client.Vuex.Path = vuexPath //nolint:staticcheck //ignore SA1019 until vuex config option is removed - updateConfig = true - } - - // Non-absolute Vuex output paths must be treated as relative to the app directory - if !filepath.IsAbs(vuexPath) { - vuexPath = filepath.Join(c.app.Path, vuexPath) - } - - vuexPath = c.joinGeneratedPath(vuexPath) - options = append(options, - cosmosgen.WithVuexGeneration( - cosmosgen.TypescriptModulePath(vuexPath), - vuexPath, - ), - ) - } - if targetOptions.isComposablesEnabled { composablesPath = targetOptions.composablesPath @@ -338,14 +296,6 @@ func (c *Chain) Generate( ) } - if targetOptions.isVuexEnabled { - c.ev.Send( - fmt.Sprintf("Vuex stores path: %s", vuexPath), - events.Icon(icons.Bullet), - events.ProgressFinish(), - ) - } - if targetOptions.isOpenAPIEnabled { c.ev.Send( fmt.Sprintf("OpenAPI path: %s", openAPIPath), diff --git a/ignite/services/scaffolder/scaffolder.go b/ignite/services/scaffolder/scaffolder.go index 4252bea0a3..f50e55a2b1 100644 --- a/ignite/services/scaffolder/scaffolder.go +++ b/ignite/services/scaffolder/scaffolder.go @@ -127,8 +127,8 @@ func protoc(ctx context.Context, cacheStorage cache.Storage, projectPath, protoD cosmosgen.IncludeDirs(conf.Build.Proto.ThirdPartyPaths), } - // Generate Typescript client code if it's enabled or when Vuex stores are generated - if conf.Client.Typescript.Path != "" || conf.Client.Vuex.Path != "" { //nolint:staticcheck,nolintlint + // Generate Typescript client code if it's enabled + if conf.Client.Typescript.Path != "" { //nolint:staticcheck,nolintlint tsClientPath := chainconfig.TSClientPath(*conf) if !filepath.IsAbs(tsClientPath) { tsClientPath = filepath.Join(projectPath, tsClientPath) @@ -143,21 +143,6 @@ func protoc(ctx context.Context, cacheStorage cache.Storage, projectPath, protoD ) } - if vuexPath := conf.Client.Vuex.Path; vuexPath != "" { //nolint:staticcheck,nolintlint - if filepath.IsAbs(vuexPath) { - vuexPath = filepath.Join(vuexPath, "generated") - } else { - vuexPath = filepath.Join(projectPath, vuexPath, "generated") - } - - options = append(options, - cosmosgen.WithVuexGeneration( - cosmosgen.TypescriptModulePath(vuexPath), - vuexPath, - ), - ) - } - if conf.Client.OpenAPI.Path != "" { openAPIPath := conf.Client.OpenAPI.Path if !filepath.IsAbs(openAPIPath) { diff --git a/integration/chain/cmd_serve_test.go b/integration/chain/cmd_serve_test.go index 422fcc59f7..dd14f506fe 100644 --- a/integration/chain/cmd_serve_test.go +++ b/integration/chain/cmd_serve_test.go @@ -9,40 +9,10 @@ import ( "github.com/stretchr/testify/require" - "github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step" "github.com/ignite/cli/v29/ignite/pkg/xos" envtest "github.com/ignite/cli/v29/integration" ) -func TestServeWithWasm(t *testing.T) { - t.Skip() - - var ( - env = envtest.New(t) - app = env.Scaffold("github.com/test/sgblog") - servers = app.RandomizeServerPorts() - ) - - env.Must(env.Exec("add Wasm module", - step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "wasm", "--yes"), - step.Workdir(app.SourcePath()), - )), - )) - - var ( - ctx, cancel = context.WithTimeout(env.Ctx(), envtest.ServeTimeout) - isBackendAliveErr error - ) - go func() { - defer cancel() - isBackendAliveErr = env.IsAppServed(ctx, servers.API) - }() - env.Must(app.Serve("should serve", envtest.ExecCtx(ctx))) - - require.NoError(t, isBackendAliveErr, "app cannot get online in time") -} - func TestServeWithCustomHome(t *testing.T) { var ( env = envtest.New(t) diff --git a/integration/cosmosgen/cosmosgen_test.go b/integration/cosmosgen/cosmosgen_test.go index ddf1452bf2..796da4a410 100644 --- a/integration/cosmosgen/cosmosgen_test.go +++ b/integration/cosmosgen/cosmosgen_test.go @@ -100,11 +100,7 @@ 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", @@ -112,7 +108,7 @@ func TestCosmosGenScaffold(t *testing.T) { step.Exec( envtest.IgniteApp, "g", - "vuex", + "ts-client", "--yes", "--clear-cache", ), @@ -147,11 +143,9 @@ func TestCosmosGenScaffold(t *testing.T) { } 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) } } }