Skip to content

Commit

Permalink
Merge branch 'master' into chore/update-ci-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaP700 authored Jan 29, 2025
2 parents c9a1a13 + ee36155 commit 5b06829
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 226 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/pr-testing-with-test-project.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
#This workflow runs the tests in the test projects to make sure the generator works as a library where it is a Node dependency along with the template.
# This workflow runs the tests in the test projects to make sure the generator works as a library where it is a Node dependency along with the template.
name: Test using test project

on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
paths:
- 'package.json'
- 'package-lock.json'
- 'apps/**'
- 'packages/**'
- '.github/workflows/**'
- '!**/*.md'
- '!docs/**'

jobs:
changes:
Expand Down Expand Up @@ -36,6 +44,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Determine if tests should run
id: should_run
if: >
Expand All @@ -54,6 +63,7 @@ jobs:
)
run: echo "shouldrun=true" >> $GITHUB_OUTPUT
shell: bash

- if: steps.should_run.outputs.shouldrun == 'true'
name: Run test
run: NODE_IMAGE_TAG=${{ matrix.node }} docker compose up --abort-on-container-exit --remove-orphans --force-recreate
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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. [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)
Expand Down
20 changes: 10 additions & 10 deletions apps/generator/docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ FLAGS
--map-base-url=<value> Maps all schema references from base url to local folder

EXAMPLES
$ asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --param version=1.0.0 singleFile=true --output ./docs --force-write
$ asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template@3.0.0 --use-new-generator --param version=1.0.0 singleFile=true --output ./docs --force-write
```
All templates are installable npm packages. Therefore, the value of `template` can be anything supported by `npm install`. Here's a summary of the possibilities:
Expand Down Expand Up @@ -60,29 +60,29 @@ asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template
**The shortest possible syntax:**
```bash
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template@3.0.0 --use-new-generator
```
**Generating from a URL:**
```bash
asyncapi generate fromTemplate https://bit.ly/asyncapi @asyncapi/html-template
asyncapi generate fromTemplate https://bit.ly/asyncapi @asyncapi/html-template@3.0.0 --use-new-generator
```
**Specify where to put the result:**
```bash
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template -o ./docs
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template@3.0.0 --use-new-generator -o ./docs
```
**Passing parameters to templates:**
```bash
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template -o ./docs -p title='Hello from param'
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template@3.0.0 --use-new-generator -o ./docs -p title='Hello from param'
```
In the template you can use it like this: ` {{ params.title }}`
**Disabling the hooks:**
```bash
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template -o ./docs -d generate:before generate:after=foo,bar
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template@3.0.0 --use-new-generator -o ./docs -d generate:before generate:after=foo,bar
```
The generator skips all hooks of the `generate:before` type and `foo`, `bar` hooks of the `generate:after` type.
Expand All @@ -101,7 +101,7 @@ asyncapi generate fromTemplate asyncapi.yaml https://github.com/asyncapi/html-te
**Map schema references from baseUrl to local folder:**
```bash
asyncapi generate fromTemplate test/docs/apiwithref.json @asyncapi/html-template -o ./build/ --force-write --map-base-url https://schema.example.com/crm/:./test/docs/
asyncapi generate fromTemplate test/docs/apiwithref.json @asyncapi/html-template@3.0.0 --use-new-generator -o ./build/ --force-write --map-base-url https://schema.example.com/crm/:./test/docs/
```
The parameter `--map-base-url` maps external schema references to local folders.
Expand All @@ -122,7 +122,7 @@ asyncapi/cli [COMMAND HERE]
docker run --rm -it \
-v ${PWD}/test/fixtures/asyncapi_v1.yml:/app/asyncapi.yml \
-v ${PWD}/output:/app/output \
asyncapi/cli generate fromTemplate -o /app/output /app/asyncapi.yml @asyncapi/html-template --force-write
asyncapi/cli generate fromTemplate -o /app/output /app/asyncapi.yml @asyncapi/html-template@3.0.0 --use-new-generator --force-write
```
Note: Use ``` ` ``` instead of `\` for Windows.
Expand All @@ -133,7 +133,7 @@ Note: Use ``` ` ``` instead of `\` for Windows.
Use the following npx command on your terminal:
```bash
npx -p @asyncapi/cli asyncapi generate fromTemplate ./asyncapi.yaml @asyncapi/html-template
npx -p @asyncapi/cli asyncapi generate fromTemplate ./asyncapi.yaml @asyncapi/html-template@3.0.0 --use-new-generator
```
## Using as a module/package
Expand All @@ -154,4 +154,4 @@ try {
}
```
See the [API documentation](api) for more examples and full API reference information.
See the [API documentation](api) for more examples and full API reference information.
Loading

0 comments on commit 5b06829

Please sign in to comment.