hyperweb-io / hyperweb-io/ts-codegen
Sample Project Generation
- Lenguaje dominante
- TypeScript
- Estrellas
- 126
- Forks
- 31
- Merge medio
- 19 min
- PR fusionados (30 d)
- 2
Descripción
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.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- documentation
- Tipo de issue
- Documentación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 55/100