ignite / cli

Ignite is a CLI tool and hub designed for constructing Proof of Stake Blockchains rooted in Cosmos-SDK
https://ignite.com
Other
1.25k stars 549 forks source link

feat: new typescript client codegen feature #2805

Closed clockworkgr closed 2 years ago

clockworkgr commented 2 years ago

This PR: https://github.com/ignite/cli/pull/2569 contains the changes for the new ts-client and vuex codegen.

Since the ts-client is common to the ignite g typescript and ignite g vuex commands and lives in its own folder, we need to ensure that the scaffolded template includes both the generated vuex stores (already the case since they're generated in place in the vue frontend src folder) and the ts-client dependency.

Since the ts-client generated is not published, the package.json file copied from the template needs to be amended with the following devDependency:

"<name-of-ts-client-package>": "file:<relative-path-to-ts-client-folder>",

along with a notice somewhere that this must be updated when the ts-client is published.

<name-of-ts-client-package> is $USER-$REPO-client-ts so:

ignite s chain github.com/clockworkgr/vuechain

results in a package called: clockworkgr-vuechain-client-ts

Assuming the default config.yml where ts-client is generated in <projectroot>/ts-client and vue frontend in <projectroot>/vue, the line to be added to the package.json devDependencies is:

"clockworkgr-vuechain-client-ts": "file:../ts-client",

clockworkgr commented 2 years ago

The template lives in github.com/ignite/web and the package.json to be updated is https://github.com/ignite/web/blob/develop/packages/template/package.json

jeronimoalbi commented 2 years ago

@clockworkgr what do you think about using an NPM hook, specifically the "prepublishOnly", to check the package.json and warn the user if it contains linked dependencies? The feature is there but I am not sure how common is to use it. Personally I have never seen it.

The package.json can't have comments inside so we should bootstrap the process at some point to let the user know about that required change. Pre hooks seems to be the right way to do it. Documentation might not be enough because it might not be present at the time the user publishes the package so it is entirely possible that this change might be forgotten.

We could introduce some Ignite CLI command to bootstrap the publishing process but TBH I don't think is a good idea, also because the user might skip the CLI and use NPM directly to publish the package.

jeronimoalbi commented 2 years ago

@clockworkgr I think we can close this issue giving that the hooks and the dynamic ts-client linking in the dependencies file are implemented in #2143.