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
Research direction
Start from the provided codegen.ts example and the existing documentation entry point for ts-codegen usage. Add a sample project-generation section showing the contracts and packages layout, schema globbing, and generated output; done means the example is included and the Windows path caveat is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100