From 2e79e6e592ae527936d1db867f9bc1f503cd01a3 Mon Sep 17 00:00:00 2001 From: Lukasz Gornicki Date: Mon, 20 Jan 2025 16:36:27 +0100 Subject: [PATCH 1/5] feat: set `ag` cli and `nunjucks` as deprecated --- .changeset/deprecation.md | 9 ++ Development.md | 2 +- README.md | 4 + apps/generator/cli.js | 7 + apps/generator/docs/file-templates.md | 2 + apps/generator/docs/migration-cli.md | 70 +++++++++ .../docs/migration-nunjucks-react.md | 144 ++++++++++++++++++ apps/generator/docs/nunjucks-render-engine.md | 2 + apps/generator/lib/filtersRegistry.js | 4 + apps/generator/lib/renderer/nunjucks.js | 4 +- 10 files changed, 245 insertions(+), 3 deletions(-) create mode 100644 .changeset/deprecation.md create mode 100644 apps/generator/docs/migration-cli.md create mode 100644 apps/generator/docs/migration-nunjucks-react.md diff --git a/.changeset/deprecation.md b/.changeset/deprecation.md new file mode 100644 index 000000000..49e7426eb --- /dev/null +++ b/.changeset/deprecation.md @@ -0,0 +1,9 @@ +--- +"@asyncapi/generator": minor +--- + +- Deprecation of `ag` CLI. It is deprecated in favour of the `AsyncAPI CLI` that a single entry point for all the AsyncAPI tools. No new features will be adde to `ag` and it will be completely removed. Official documentation of AsyncAPI Generator do not mention `ag` for over a year, and only `AsyncAPI CLI` and `asyncapi generate fromTemplate` are promoted. Read [migration guide](https://www.asyncapi.com/docs/tools/generator/migration-cli) that will help you understand how to migrate your `ag` commands to the new AsyncAPI CLI. + +- [Nunjucks render engine](https://www.asyncapi.com/docs/tools/generator/nunjucks-render-engine) is deprecated and will be removed in October 2025. Use [React render engine](https://www.asyncapi.com/docs/tools/generator/react-render-engine) instead. If you already use Nunjucks in production, read [migration guide](https://www.asyncapi.com/docs/tools/generator/migration-nunjucks-react) that will help you understand how to migrate to the new engine. Removal of Nunjucks render engine results also in removal of [Nunjucks-filters](apps/nunjucks-filters) library. + +Removal of both deprecated parts of the generator are planned for October 2025, which gives you 9 months to migrate. \ No newline at end of file diff --git a/Development.md b/Development.md index f62d50476..61144d0c3 100644 --- a/Development.md +++ b/Development.md @@ -78,7 +78,7 @@ cd apps/generator 3. Run the generator with the react-template: ```bash -asyncapi generate fromTemplate ./test/docs/dummy.yml ./test/test-templates/react-template -o ./test/output --force-write +node ./cli ./test/docs/dummy.yml ./test/test-templates/react-template -o ./test/output --force-write ``` 4. Check the output in the `./test/output` directory to verify the output that you desired. diff --git a/README.md b/README.md index 3d09b55be..2904710f4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ [![AsyncAPI Generator](./assets/readme-banner.png)](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/generator@2.6.0](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. @@ -8,6 +10,8 @@ This is a Monorepo managed using [Turborepo](https://turbo.build/) and contains 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. +[!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/nunjucks-depreciate.md) ![npm](https://img.shields.io/npm/v/@asyncapi/generator?style=for-the-badge) ![npm](https://img.shields.io/npm/dt/@asyncapi/generator?style=for-the-badge) diff --git a/apps/generator/cli.js b/apps/generator/cli.js index feb12446a..2a205a86b 100755 --- a/apps/generator/cli.js +++ b/apps/generator/cli.js @@ -89,10 +89,17 @@ program .option('-o, --output ', 'directory where to put the generated files (defaults to current directory)', parseOutput, process.cwd()) .option('-p, --param ', 'additional param to pass to templates', paramParser) .option('--force-write', 'force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)') + .option('--disable-warning', 'disable "ag" deprecation warning (defaults to false)') .option('--watch-template', 'watches the template directory and the AsyncAPI document, and re-generate the files when changes occur. Ignores the output directory. This flag should be used only for template development.') .option('--map-base-url ','maps all schema references from base url to local folder',mapBaseUrlParser) .parse(process.argv); +if (!program.disableWarning) { + console.warn(red( + 'Warning: The "ag" CLI is deprecated and will be removed in a future release. Please use the AsyncAPI CLI instead. See release notes for details: https://github.com/asyncapi/generator/releases/tag/%40asyncapi%2Fgenerator%402.6.0. You can hide this working using --disable-warning flag.') + ); +} + if (!asyncapiDocPath) { console.error(red('> Path or URL to AsyncAPI file not provided.')); program.help(); // This exits the process diff --git a/apps/generator/docs/file-templates.md b/apps/generator/docs/file-templates.md index 7a7a8ce77..2b5c05431 100644 --- a/apps/generator/docs/file-templates.md +++ b/apps/generator/docs/file-templates.md @@ -7,6 +7,8 @@ weight: 140 > **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/generator@2.6.0](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. diff --git a/apps/generator/docs/migration-cli.md b/apps/generator/docs/migration-cli.md new file mode 100644 index 000000000..048a09ecd --- /dev/null +++ b/apps/generator/docs/migration-cli.md @@ -0,0 +1,70 @@ +--- +title: "Migrating from `ag` CLI to AsyncAPI CLI" +weight: 260 +--- + +This guide provides detailed instructions on how to transition from old `ag` Generator CLI to the new AsyncAPI CLI. + +## Options Overview + +Here is a list of `ag` options and their equivalents in the AsyncAPI CLI: + +- **-d, --disable-hook [hooks...]** + - **AsyncAPI CLI equivalent:** `asyncapi generate fromTemplate