-
-
Notifications
You must be signed in to change notification settings - Fork 342
feat!: remove nunjucks support and ag CLI
#1756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
derberg
wants to merge
35
commits into
asyncapi:master
Choose a base branch
from
derberg:nunjucksfinallygoesaway
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
f0fc2bc
feat: remove nunjucks support
derberg d141638
Merge branch 'master' into nunjucksfinallygoesaway
derberg 45dbbd8
refactor
derberg 703d0a6
refresh lock
derberg e75afe6
Merge branch 'master' into nunjucksfinallygoesaway
derberg 02d7166
docs
derberg 1eae283
Merge branch 'nunjucksfinallygoesaway' of https://github.com/derberg/…
derberg 26cf037
Update package-lock.json
derberg a5d6810
Update jest.config.js
derberg 2e7a403
Update apps/generator/docs/typescript-support.md
derberg 0c4d036
remove cli
derberg 886bc20
Delete migration-cli.md
derberg e5efa5b
changeset
derberg 090eee5
minor
derberg 2c7be47
Update .changeset/remove-deprecated-nunjucks-cli.md
derberg 925a5dd
remove watcher
derberg 112a5ab
isLocalTemplate removal
derberg fc946fa
Merge branch 'master' into nunjucksfinallygoesaway
derberg 9eaad55
make node 24 must have
derberg d20805c
update changeset
derberg 4f86da6
Merge branch 'master' into nunjucksfinallygoesaway
derberg 8bb9fd3
update workflows
derberg eca3b6c
Merge branch 'nunjucksfinallygoesaway' of https://github.com/derberg/…
derberg a6b11d6
silent security alrerts
derberg 8dc94c2
more nunjucks wipe
derberg adb550d
cleanup docker
derberg cd48cc5
update dev guide after local testing
derberg 32a5ce6
bump deps
derberg 57c32e1
Update apps/generator/docs/react-render-engine.md
derberg 9f9068e
Update apps/generator/docs/react-render-engine.md
derberg 1872ddd
Update integration.test.js.snap
derberg f53a520
Update integration.test.js.snap
derberg ae4ea24
Merge branch 'master' into nunjucksfinallygoesaway
derberg aeb9d42
Update remove-deprecated-nunjucks-cli.md
derberg b31c428
Apply suggestions from code review
derberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| "@asyncapi/generator": major | ||
| --- | ||
|
|
||
| ### Breaking Changes | ||
| * Nunjucks renderer removed — React is now the sole rendering engine. No need to specify render engine in config anymore | ||
| * Nunjucks filters package and its public filters removed; filter-based template APIs no longer available. | ||
| * `ag` CLI is no longer available. Long time ago it was already announced that it will be removed and people should move to [AsyncAPI CLI](https://github.com/asyncapi/cli/) | ||
|
|
||
| ### Migration Guides | ||
| - [Migrating from Nunjucks to React render engine](https://github.com/asyncapi/generator/blob/%40asyncapi/generator%402.8.4/apps/generator/docs/migration-nunjucks-react.md) | ||
| - [Migrating from `ag` CLI to AsyncAPI CLI](https://github.com/asyncapi/generator/blob/%40asyncapi/generator%402.8.4/apps/generator/docs/migration-cli.md) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,17 @@ | ||
| [](https://www.asyncapi.com/tools/generator) | ||
|
|
||
| > Some parts of the AsyncAPI Generator are deprecated and the plan is to remove them in October 2025. For more details read notes from release [@asyncapi/[email protected]](https://github.com/asyncapi/generator/releases/tag/%40asyncapi%2Fgenerator%402.6.0). | ||
|
|
||
| This is a Monorepo managed using [Turborepo](https://turbo.build/) and contains the following package: | ||
|
|
||
| 1. [Generator](apps/generator): This is a tool that you can use to generate whatever you want basing on the AsyncAPI specification file as an input. | ||
|
|
||
| 1. [Hooks](apps/hooks): This library contains generator filters that can be reused across multiple templates, helping to avoid redundant work. Hooks are designed to let template developers hook into the template generation process. For example, one can create a hook code that will be automatically invoked right after the template generation process has ended. | ||
|
|
||
| 1. [Nunjucks-filters](apps/nunjucks-filters): This library contains generator filters that can be reused across multiple templates helping to avoid redundant work. These filters are designed specifically for Nunjucks templates and are included by default with the generator, so there's no need to add them to dependencies separately. | ||
| 1. [Hooks](apps/hooks): Hooks are designed to let template developers hook into the template generation process. For example, one can create a hook code that will be automatically invoked right after the template generation process has ended. | ||
|
|
||
| 1. [React-sdk](apps/react-sdk): AsyncAPI React SDK is a set of components/functions to use React as render engine for the generator. This is the library that undestand components from Generator's templates that are configured to use `react` render engine. | ||
|
|
||
| 1. [Generator-helpers](packages/helpers): A utility library that provides helper functions and utilities to simplify template development. It reduces boilerplate and speeds up template creation. | ||
|
|
||
| 1. [Generator-components](packages/components): A library of reusable components that can be shared across different templates, helping to avoid duplication and accelerate template development. | ||
|
|
||
| > [!IMPORTANT] | ||
| > **Deprecation Notice:** The Nunjucks renderer engine is deprecated and will be removed in future releases. We strongly recommend using the React renderer engine instead. You can find how to migrate from Nunjucks to React in the [migration guide](apps/generator/docs/migration-nunjucks-react.md) | ||
|
|
||
|   | ||
|
|
||
| <!-- toc is generated with GitHub Actions do not remove toc markers --> | ||
|
|
@@ -68,18 +61,9 @@ You can find above templates and the ones provided by the community in **[this l | |
| > [!IMPORTANT] | ||
| > **Experimental Feature:** AsyncAPI Generator also comes with **baked-in templates** - official templates shipped directly inside the Generator (`@asyncapi/generator`). They cover code, docs, configs, and SDKs, and are maintained under [/packages/templates](packages/templates) directory, following a strict, opinionated structure for consistency and ease of maintenance. This feature is not recommended for production use. For those who want to try them out or learn more, see the [Baked-in templates documentation](https://www.asyncapi.com/docs/tools/generator/baked-in-templates). | ||
|
|
||
| ## Filters | ||
|
|
||
| `apps/nunjucks-filters` library contains generator filters that can be reused across multiple templates, helping to avoid redundant work. These filters are designed specifically for Nunjucks templates and are included by default with the generator, so there's no need to add them to dependencies separately. | ||
|
|
||
| This library consists of: | ||
|
|
||
| - Custom filters. Check out [API docs](apps/nunjucks-filters/docs/api.md) for complete list | ||
| - Lodash-powered filters. For the list of all available filters check [official docs](https://lodash.com/docs/) | ||
|
|
||
| ## Hooks | ||
|
|
||
| The `apps/hooks` library contains generator filters that can be reused across multiple templates, helping to avoid redundant work. [Hooks](https://www.asyncapi.com/docs/tools/generator/hooks) are functions called by the generator at specific moments in the generation process. Hooks can be anonymous functions, but you can also assign them function names. These hooks can have arguments provided to them, or they may be expected to return a value. | ||
| [Hooks](https://www.asyncapi.com/docs/tools/generator/hooks) are functions called by the generator at specific moments in the generation process. Hooks can be anonymous functions, but you can also assign them function names. These hooks can have arguments provided to them, or they may be expected to return a value. | ||
|
|
||
| These hooks are included in the generator without adding any specific dependency to the library. You still have to enable the given hook in the configuration explicitly because some hooks can execute automatically without passing a specific parameter. [Learn more about configuration and what hooks are available out of the box](https://www.asyncapi.com/docs/tools/generator/hooks#official-library). | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,67 +3,9 @@ title: "File templates" | |
| weight: 140 | ||
| --- | ||
|
|
||
| ## Generating files with the Nunjucks render engine | ||
|
|
||
| > **Note**: This section applies only to the Nunjucks render engine. For information on using the React render engine, refer to the [Generating files with the React render engine](#generating-files-with-the-react-render-engine) section below. | ||
|
|
||
| > **Note**: Nunjucks renderer engine is deprecated and will be removed in the future. Use the React renderer engine instead. For more details read notes from release [@asyncapi/[email protected]](https://github.com/asyncapi/generator/releases/tag/%40asyncapi%2Fgenerator%402.6.0). | ||
|
|
||
| It is possible to generate files for each specific object in your AsyncAPI documentation using the Nunjucks render engine. For example, you can specify a filename like `$$channel$$.js` to generate a file for each channel defined in your AsyncAPI. The following file-template names and extra variables are available: | ||
|
|
||
| - `$$channel$$`, within the template-file you have access to two variables [`channel`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#channel) and [`channelName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#channels). Where the `channel` contains the current channel being rendered. | ||
| - `$$message$$`, within the template-file you have access to two variables [`message`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#message) and [`messageName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#message). Where `message` contains the current message being rendered. | ||
| - `$$schema$$`, within the template-file you have access to two variables [`schema`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schema) and [`schemaName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schema). Where `schema` contains the current schema being rendered. Only schemas from [Components object](https://www.asyncapi.com/docs/reference/specification/latest#componentsObject) are used. | ||
| - `$$everySchema$$`, within the template-file you have access to two variables [`schema`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schema) and [`schemaName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schemas). Where `schema` contains the current schema being rendered. Every [Schema object](https://www.asyncapi.com/docs/specifications/2.0.0/#schemaObject) from the entire AsyncAPI file is used. | ||
| - `$$objectSchema$$`, within the template-file you have access to two variables [`schema`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schema) and [`schemaName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schemas). Where `schema` contains the current schema being rendered. All the [Schema objects](https://www.asyncapi.com/docs/reference/specification/latest#multiFormatSchemaObject) with type object is used. | ||
| - `$$parameter$$`, within the template-file you have access to two variables [`parameter`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#channelparameter) and [`parameterName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#channelparameters). Where the `parameter` contains the current parameter being rendered. | ||
| - `$$securityScheme$$`, within the template-file you have access to two variables [`securityScheme`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#securityscheme) and [`securitySchemeName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#securityschemes). Where `securityScheme` contains the current security scheme being rendered. | ||
|
|
||
| The file name will be equal to `*Name` variable. | ||
|
|
||
| ### Example | ||
|
|
||
| The file name is `$$schema$$.txt`, the content of this file is: | ||
| ``` | ||
| Schema name is '{{schemaName}}' and properties are: | ||
| {% for propName, prop in schema.properties() %} | ||
| - {{prop.uid()}} | ||
| {% endfor %} | ||
| ``` | ||
|
|
||
| With the following AsyncAPI: | ||
| ``` | ||
| components: | ||
| schemas: | ||
| peoplePayload: | ||
| type: object | ||
| properties: | ||
| event: | ||
| $ref: "#/components/schemas/people" | ||
| people: | ||
| type: object | ||
| properties: | ||
| id: | ||
| type: integer | ||
| ``` | ||
|
|
||
| The generator creates two files `peoplePayload.txt` and `people.txt` with the following content: | ||
| ``` | ||
| Schema name is 'peoplePayload' and properties are: | ||
| - people | ||
| ``` | ||
|
|
||
| and | ||
| ``` | ||
| Schema name is 'people' and properties are: | ||
| - id | ||
| ``` | ||
|
|
||
| > You can see an example of a file template that uses the Nunjucks render engine [here](https://github.com/asyncapi/template-for-generator-templates/tree/nunjucks/template/schemas). | ||
|
|
||
| ## Generating files with the React render engine | ||
|
|
||
| The above method of rendering **file templates** only works for the Nunjucks render engine. To use the React render engine, you need to follow a different approach. The React render engine allows for a more generic way to render multiple files by returning an array of `File` components in the rendering component. This can be particularly useful for complex templates or when you need to generate a large number of files with varying content. | ||
| The React render engine allows for a more generic way to render multiple files by returning an array of `File` components in the rendering component. This can be particularly useful for complex templates or when you need to generate a large number of files with varying content. | ||
|
|
||
| ### Example 1: Rendering hardcoded files | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.