hyperweb-io / hyperweb-io/ts-codegen
Sample Project Generation
- Dominant language
- TypeScript
- Stars
- 126
- Forks
- 31
- Avg merge
- 19m
- Merged PRs (30d)
- 2
Description
CosmWasm projects usually have a setup including a contracts and packages folder: [cw-plus](https://github.com/CosmWasm/cw-plus) and [dao dao](https://github.com/DA0-DA0/dao-contracts) as a couple examples.
I think ts-codegen should have a sample project generation file in the docs to make using this tool easier.
**codegen.ts**
```
import codegen, { ContractFile } from "@cosmwasm/ts-codegen";
import { glob } from "glob";
glob("../@(contracts|packages)/*/schema", (err, matches) => {
if (err) console.log(err);
let contracts: ContractFile[] = [];
matches.forEach((x) => {
contracts.push({
name: x.split("/")[2],
dir: x,
});
});
codegen({
contracts,
outPath: "./generated",
options: {
bundle: {
bundleFile: "index.ts",
scope: "contracts",
},
types: {
enabled: true,
},
client: {
enabled: true,
},
},
}).then(() => {
console.log("✨ all done!");
});
});
```
I used glob, because this is how ts-codegen's utils.readSchemas interprets paths. If a valid path is not given from windows, then ts-codegen will not generate anything.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.