hyperweb-io / hyperweb-io/ts-codegen

Sample Project Generation

Aperta
#70 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
126
Fork
31
Merge medio
19m
PR unite (30g)
2

Descrizione

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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.