the-codegen-project / cli

Simplify your implementation in any language when using standards such as AsyncAPI
Apache License 2.0
4 stars 0 forks source link
asyncapi generator java the-codegen-project typescript

The Codegen Project banner

⚡️The Codegen Project⚡️

[![License](https://img.shields.io/github/license/the-codegen-project/cli)](https://github.com/the-codegen-project/cli/blob/master/LICENSE) [![Npm latest version](https://img.shields.io/npm/v/@the-codegen-project/cli)](https://www.npmjs.com/package/@the-codegen-project/cli) ![NPM Downloads](https://img.shields.io/npm/dw/%40the-codegen-project%2Fcli) ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/the-codegen-project/cli/.github%2Fworkflows%2Fruntime-testing.yml?label=runtime%20testing) ![GitHub last commit](https://img.shields.io/github/last-commit/the-codegen-project/cli) ![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.x64.pkg?label=MacOS) ![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.arm64.pkg?label=MacOS) ![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.x86.exe?label=Win) ![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.x64.exe?label=Win) ![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.tar.gz?label=Linux) ![GitHub Downloads (specific asset, all releases)](https://img.shields.io/github/downloads/the-codegen-project/cli/codegen.deb?label=Linux) ![homebrew downloads](https://img.shields.io/homebrew/installs/dm/codegen?label=Brew%20(SOON)) ![Chocolatey Downloads](https://img.shields.io/chocolatey/dt/codegen?label=Chocolatey%20(SOON)) [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)

Generate payload models, parameter, headers, messages, communication support functions, testing functions and more, across programming languages such as TypeScript, C#, Java, and more...

[Read the Docs](./docs/) | [View Demos](./examples/)

Core Features

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.

Package manager MacOS x64 MacOS arm64 Windows x64 Windows x32 Linux (Debian) Linux (Others)
#### NPM ```sh npm install --save-dev @the-codegen-project/cli npm install -g @the-codegen-project/cli ``` #### Yarn ```sh yarn add @the-codegen-project/cli ``` #### Pnpm ```sh pnpm add @the-codegen-project/cli ``` #### Bun ```sh bun add @the-codegen-project/cli ```
#### Download ```sh curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.x64.pkg ``` #### Install ```sh sudo installer -pkg codegen.x64.pkg -target / ```
#### Download ```sh curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.arm64.pkg ``` #### Install ```sh sudo installer -pkg codegen.arm64.pkg -target / ```
#### Download ```sh curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.deb ``` #### Install ```sh sudo apt install ./codegen.deb ```
#### Download ```sh curl -OL https://github.com/the-codegen-project/cli/releases/latest/download/codegen.tar.gz ``` #### Install ```sh tar -xzf codegen.tar.gz ``` #### Symlink ```sh ln -s /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
[![Initialize The Codegen Project](./assets/videos/initialize.gif)](./assets/videos/initialize.gif) [Customize it to your heart's desire!](./docs/generators/)

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

Contributors

Thanks go out to these wonderful people (emoji key):

Jonas Lagoni
Jonas Lagoni

🐛 💻 📖 🤔 🚧 💬 ⚠️ 👀

This project follows the all-contributors specification. Contributions of any kind are welcome!