Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f0fc2bc
feat: remove nunjucks support
derberg Nov 14, 2025
d141638
Merge branch 'master' into nunjucksfinallygoesaway
derberg Nov 14, 2025
45dbbd8
refactor
derberg Nov 19, 2025
703d0a6
refresh lock
derberg Nov 19, 2025
e75afe6
Merge branch 'master' into nunjucksfinallygoesaway
derberg Nov 19, 2025
02d7166
docs
derberg Nov 19, 2025
1eae283
Merge branch 'nunjucksfinallygoesaway' of https://github.com/derberg/…
derberg Nov 19, 2025
26cf037
Update package-lock.json
derberg Nov 19, 2025
a5d6810
Update jest.config.js
derberg Nov 19, 2025
2e7a403
Update apps/generator/docs/typescript-support.md
derberg Nov 19, 2025
0c4d036
remove cli
derberg Nov 22, 2025
886bc20
Delete migration-cli.md
derberg Nov 22, 2025
e5efa5b
changeset
derberg Nov 22, 2025
090eee5
minor
derberg Nov 22, 2025
2c7be47
Update .changeset/remove-deprecated-nunjucks-cli.md
derberg Nov 22, 2025
925a5dd
remove watcher
derberg Nov 22, 2025
112a5ab
isLocalTemplate removal
derberg Nov 22, 2025
fc946fa
Merge branch 'master' into nunjucksfinallygoesaway
derberg Dec 8, 2025
9eaad55
make node 24 must have
derberg Dec 8, 2025
d20805c
update changeset
derberg Dec 8, 2025
4f86da6
Merge branch 'master' into nunjucksfinallygoesaway
derberg Dec 8, 2025
8bb9fd3
update workflows
derberg Dec 8, 2025
eca3b6c
Merge branch 'nunjucksfinallygoesaway' of https://github.com/derberg/…
derberg Dec 8, 2025
a6b11d6
silent security alrerts
derberg Dec 8, 2025
8dc94c2
more nunjucks wipe
derberg Dec 8, 2025
adb550d
cleanup docker
derberg Dec 8, 2025
cd48cc5
update dev guide after local testing
derberg Dec 8, 2025
32a5ce6
bump deps
derberg Dec 8, 2025
57c32e1
Update apps/generator/docs/react-render-engine.md
derberg Dec 8, 2025
9f9068e
Update apps/generator/docs/react-render-engine.md
derberg Dec 8, 2025
1872ddd
Update integration.test.js.snap
derberg Dec 8, 2025
f53a520
Update integration.test.js.snap
derberg Dec 8, 2025
ae4ea24
Merge branch 'master' into nunjucksfinallygoesaway
derberg Dec 11, 2025
aeb9d42
Update remove-deprecated-nunjucks-cli.md
derberg Dec 12, 2025
b31c428
Apply suggestions from code review
derberg Dec 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ You can also opt in to run the lint checks after the tests, by setting an enviro

### Manually testing with test templates

To test template features manually we have `react-template` and `nunjucks-template` in `apps/generator/test/templates`, you can use this templates to manually test your changes like this:
To test template features manually we have `react-template` in `apps/generator/test/templates`, you can use this template to manually test your changes like this:

1. Navigate to the generator directory:

Expand Down
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ This is a Monorepo managed using [Turborepo](https://turbo.build/) and contains

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. [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)

![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)

<!-- toc is generated with GitHub Actions do not remove toc markers -->
Expand Down Expand Up @@ -68,15 +63,6 @@ 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.
Expand Down
6 changes: 2 additions & 4 deletions apps/generator/docs/typescript-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ title: "TypeScript support"
weight: 150
---

The AsyncAPI generator has TypeScript support for [hooks](#hooks) and Nunjucks's [filters](#filters). Assumptions:
The AsyncAPI generator has TypeScript support for [hooks](#hooks). Assumptions:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Verify the link fragment for hooks.

The markdown linter flags that the link fragment #hooks may be invalid. Please verify this anchor exists in the target document to ensure navigation works correctly.

Based on static analysis hints.

🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

6-6: Link fragments should be valid

(MD051, link-fragments)

🤖 Prompt for AI Agents
In apps/generator/docs/typescript-support.md around line 6, the link fragment
`#hooks` may be invalid; verify the target document contains a heading that
generates the `hooks` anchor (case-insensitive, spaces/punctuation normalized)
and if it does not, either update the link to the correct fragment (e.g.,
`#hook-usage`, `#lifecycle-hooks`, or the exact heading slug) or add the
corresponding "Hooks" heading to the document so the anchor resolves; ensure the
fragment matches the actual generated Markdown heading slug.


- Installing the `typescript` package and creating the` tsconfig.json` file isn't necessary.
- Source code of the hook/filter must have `.ts` extension.
- Each package related to the typings for TypeScript like `@types/node` must be installed in the template under `dependencies` array. This is because the Generator transpiles the TypeScript code on-the-fly while rendering the template, and cannot use packages under `devDependencies`.
- Each template should have `@types/node` package installed to enable support for typings for Node.


- Each template should have `@types/node` package installed to enable support for typings for Node.
1 change: 0 additions & 1 deletion apps/generator/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ module.exports = {
moduleNameMapper: {
'^nimma/legacy$': '<rootDir>../../node_modules/nimma/dist/legacy/cjs/index.js',
'^nimma/(.*)': '<rootDir>../../node_modules/nimma/dist/cjs/$1',
'^@asyncapi/nunjucks-filters$': path.resolve(__dirname, '../nunjucks-filters'),
},
};
134 changes: 0 additions & 134 deletions apps/generator/lib/filtersRegistry.js

This file was deleted.

24 changes: 4 additions & 20 deletions apps/generator/lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const npmPath = requireg.resolve('npm').replace('index.js','');
const { isAsyncAPIDocument } = require('@asyncapi/parser/cjs/document');

const { configureReact, renderReact, saveRenderedReactContent } = require('./renderer/react');
const { configureNunjucks, renderNunjucks } = require('./renderer/nunjucks');
const { validateTemplateConfig } = require('./templates/config/validator');
const { loadTemplateConfig } = require('./templates/config/loader');
const { isGenerationConditionMet } = require('./conditionalGeneration');
Expand All @@ -26,17 +25,14 @@ const {
copyFile,
exists,
fetchSpec,
isReactTemplate,
isJsFile,
getTemplateDetails,
convertCollectionToObject,
} = require('./utils');
const { parse, usesNewAPI, getProperApiDocument } = require('./parser');
const { registerFilters } = require('./filtersRegistry');
const { registerHooks } = require('./hooksRegistry');
const { definitions, flatten, shorthands } = require('@npmcli/config/lib/definitions');

const FILTERS_DIRNAME = 'filters';
const HOOKS_DIRNAME = 'hooks';
const PACKAGE_JSON_FILENAME = 'package.json';
const GIT_IGNORE_FILENAME = '{.gitignore}';
Expand Down Expand Up @@ -325,9 +321,6 @@ class Generator {
await this.parseInput(this.asyncapi, parseOptions);
validateTemplateConfig(this.templateConfig, this.templateParams, this.asyncapi);
await this.configureTemplate();
if (!isReactTemplate(this.templateConfig)) {
await registerFilters(this.nunjucks, this.templateConfig, this.templateDir, FILTERS_DIRNAME);
}
await registerHooks(this.hooks, this.templateConfig, this.templateDir, HOOKS_DIRNAME);
await this.launchHook('generate:before');
}
Expand Down Expand Up @@ -407,10 +400,8 @@ class Generator {
* Configure the templates based the desired renderer.
*/
async configureTemplate() {
if (isReactTemplate(this.templateConfig) && this.compile) {
if (this.compile) {
await configureReact(this.templateDir, this.templateContentDir, TRANSPILED_TEMPLATE_LOCATION);
} else {
this.nunjucks = configureNunjucks(this.debug, this.templateDir);
}
}

Expand Down Expand Up @@ -876,11 +867,8 @@ class Generator {
const renderContent = await this.renderFile(asyncapiDocument, templateFilePath, extraTemplateData);
if (renderContent === undefined) {
return;
} else if (isReactTemplate(this.templateConfig)) {
await saveRenderedReactContent(renderContent, outputpath, this.noOverwriteGlobs);
} else {
await writeFile(outputpath, renderContent);
}
await saveRenderedReactContent(renderContent, outputpath, this.noOverwriteGlobs);
}

/**
Expand Down Expand Up @@ -981,11 +969,7 @@ class Generator {
* @return {Promise<string|TemplateRenderResult|Array<TemplateRenderResult>|undefined>}
*/
async renderFile(asyncapiDocument, filePath, extraTemplateData = {}) {
if (isReactTemplate(this.templateConfig)) {
return await renderReact(asyncapiDocument, filePath, extraTemplateData, this.templateDir, this.templateContentDir, TRANSPILED_TEMPLATE_LOCATION, this.templateParams, this.debug, this.originalAsyncAPI);
}
const templateString = await readFile(filePath, 'utf8');
return renderNunjucks(asyncapiDocument, templateString, filePath, extraTemplateData, this.templateParams, this.originalAsyncAPI, this.nunjucks);
return await renderReact(asyncapiDocument, filePath, extraTemplateData, this.templateDir, this.templateContentDir, TRANSPILED_TEMPLATE_LOCATION, this.templateParams, this.debug, this.originalAsyncAPI);
}

/**
Expand All @@ -999,7 +983,7 @@ class Generator {
const nonRenderableFiles = this.templateConfig.nonRenderableFiles || [];
return Array.isArray(nonRenderableFiles) &&
(nonRenderableFiles.some(globExp => minimatch(fileName, globExp)) ||
(isReactTemplate(this.templateConfig) && !isJsFile(fileName)));
!isJsFile(fileName));
}

/**
Expand Down
42 changes: 0 additions & 42 deletions apps/generator/lib/renderer/nunjucks.js

This file was deleted.

6 changes: 3 additions & 3 deletions apps/generator/lib/templates/config/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,17 @@ function isServerProtocolSupported(server, supportedProtocols, paramsServerName)
}

/**
* Checks if the the provided renderer are supported (no renderer are also supported, defaults to nunjucks)
* Checks if the provided renderer is supported (no renderer is also supported, defaults to react)
*
* @param {Object} templateConfig Template configuration.
*/
function isProvidedTemplateRendererSupported(templateConfig) {
const supportedRenderers = [undefined, 'react', 'nunjucks'];
const supportedRenderers = [undefined, 'react'];
if (supportedRenderers.includes(templateConfig.renderer)) {
return;
}

throw new Error(`We do not support '${templateConfig.renderer}' as a renderer for a template. Only 'react' or 'nunjucks' are supported.`);
throw new Error(`We do not support '${templateConfig.renderer}' as a renderer for a template. Only 'react' is supported.`);
}

/**
Expand Down
10 changes: 0 additions & 10 deletions apps/generator/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,6 @@ utils.isLocalTemplate = async (templatePath) => {
return stats.isSymbolicLink();
};

/**
* Returns whether or not the template is a react template
*
* @param {object} templateConfig
* @returns {boolean} Whether the template is a React template or not.
*/
utils.isReactTemplate = (templateConfig) => {
return templateConfig !== undefined && templateConfig.renderer === 'react';
};

/**
* Fetches an AsyncAPI document from the given URL and return its content as string
*
Expand Down
2 changes: 0 additions & 2 deletions apps/generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"@asyncapi/generator-hooks": "*",
"@asyncapi/generator-react-sdk": "*",
"@asyncapi/multi-parser": "^2.1.1",
"@asyncapi/nunjucks-filters": "*",
"@asyncapi/parser": "^3.0.14",
"@npmcli/arborist": "5.6.3",
"@npmcli/config": "^8.0.2",
Expand All @@ -73,7 +72,6 @@
"loglevel": "^1.6.8",
"minimatch": "^3.0.4",
"node-fetch": "^2.6.0",
"nunjucks": "^3.2.0",
"requireg": "^0.2.2",
"resolve-from": "^5.0.0",
"resolve-pkg": "^2.0.0",
Expand Down
10 changes: 0 additions & 10 deletions apps/generator/test/__snapshots__/integration.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,3 @@ components:
bindingVersion: '0.1.0'
"
`;

exports[`Integration testing generateFromFile() to make sure the result of the generation is not changend comparing to snapshot generated using Nunjucks template 1`] = `
"This is a markdown file for my application.
App name is: **Dummy example with all spec features included**
Version v1 running on production mode

HTML description: **&lt;p&gt;This is an example of AsyncAPI specification file that is suppose to include all possible features of the AsyncAPI specification. Do not use it on production.&lt;/p&gt;
&lt;p&gt;It&#39;s goal is to support development of documentation and code generation with the &lt;a href=&quot;https://github.com/asyncapi/generator/&quot;&gt;AsyncAPI Generator&lt;/a&gt; and &lt;a href=&quot;https://github.com/search?q=topic%3Aasyncapi+topic%3Agenerator+topic%3Atemplate&quot;&gt;Template projects&lt;/a&gt;&lt;/p&gt;
**"
`;
Loading
Loading