@the-codegen-project/cli
v0.24.1
Published
CLI to work with code generation in any environment
Downloads
923
Readme
Core Features
- 📃 Generate payload representations from your AsyncAPI document (including Protobuf, RAML, OpenAPI Schema)
- 📊 Customize the generators output to your hearts desire
- 💫 Regenerate once the input changes
- 👀 Integrate it into any project (such as Next.JS, etc.)
- 💅 Create custom generators (read more)
- 🗄️ Protocol agnostic generator (docs)
- ⭐ And much more...
How it works
The Codegen Project is a generator that is built to live along side your projects to help you save time in the development phase, ensuring you spend as much time on the business logic as possible. It works by using your configuration file to know what it needs to generate.
Each input has different generates and all of them can be customized, or you can build your own generator right in the configuration file.
export default {
inputType: 'asyncapi',
inputPath: './asyncapi.json',
language: 'typescript',
generators: [
{
preset: 'payloads',
outputPath: './src/payloads',
serializationType: 'json',
},
...
]
};
In this example, the generator will read the AsyncAPI document located in same directory as the configuration file, and generate TypeScript models for all the payload including code to serialize the models to JSON.
Getting started
Its simple, install the CLI into your project or machine, setup the Codegen configuration file to include all the code your heart desire, customize it, and generate it at build time or whenever you feel like it.
Install
Installing the CLI can be done inside a project or within your system.
NPM
npm install --save-dev @the-codegen-project/cli
npm install -g @the-codegen-project/cli
Yarn
yarn add @the-codegen-project/cli
Pnpm
pnpm add @the-codegen-project/cli
Bun
bun add @the-codegen-project/cli
Download
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.x64.pkg
Install
sudo installer -pkg codegen.x64.pkg -target /
Download
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.arm64.pkg
Install
sudo installer -pkg codegen.arm64.pkg -target /
Download
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.deb
Install
sudo apt install ./codegen.deb
Download
curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.tar.gz
Install
tar -xzf codegen.tar.gz
Symlink
ln -s <absolute-path>/bin/codegen /usr/local/bin/codegen
You can find all the possible commands in the usage documentation.
Initialize
Add a configuration file, either manually or through the CLI;
codegen init
Customize it to your heart's desire!
Generate
With your configuration file in hand, time to generate the code and use it! This can be done manually or integrate into your build process. Checkout all the examples for inspiration how to do it.
codegen generate
👀 Goals
Besides the milestones, we have certain goals that we want to reach for various reasons;
- ⭐ Reach 50 stars - So we can publish the CLI on Brew and Chocolatey
- 📃 3 Published resources (blog post, video, etc)
📃 Resources
People who have been so kind to write or talk about The Codegen Project;
- Write one!
Contribution Guidelines
We have made quite a comprehensive contribution guide to give you a lending hand in how the project is structured and how to contribute to it.
Contributors
Thanks go out to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind are welcome!