Skip to content

Commit

Permalink
Merge branch 'master' into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Florence-Njeri authored Jul 5, 2023
2 parents cb5a1be + 1f3254c commit ace0228
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/help-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ jobs:
repo: context.repo.repo,
body: `Hello, @${{ github.actor }}! 👋🏼
I'm Genie from the magic lamp. Looks like somebody needs a hand! 🆘
I'm 🧞🧞🧞 Genie 🧞🧞🧞 from the magic lamp. Looks like somebody needs a hand!
At the moment the following comments are supported in pull requests:

- `/ready-to-merge` or `/rtm` - This comment will trigger automerge of PR in case all required checks are green, approvals in place and do-not-merge label is not added
- `/do-not-merge` or `/dnm` - This comment will block automerging even if all conditions are met and ready-to-merge label is added
- `/autoupdate` or `/au` - This comment will add `autoupdate` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR.`
- \`/ready-to-merge\` or \`/rtm\` - This comment will trigger automerge of PR in case all required checks are green, approvals in place and do-not-merge label is not added
- \`/do-not-merge\` or \`/dnm\` - This comment will block automerging even if all conditions are met and ready-to-merge label is added
- \`/autoupdate\` or \`/au\` - This comment will add \`autoupdate\` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR.`
})

create_help_comment_issue:
Expand All @@ -51,10 +51,10 @@ jobs:
repo: context.repo.repo,
body: `Hello, @${{ github.actor }}! 👋🏼
I'm Genie from the magic lamp. Looks like somebody needs a hand! 🆘
I'm 🧞🧞🧞 Genie 🧞🧞🧞 from the magic lamp. Looks like somebody needs a hand!
At the moment the following comments are supported in issues:

- `/good-first-issue {js | ts | java | go | docs | design | ci-cd} ` or `/gfi {js | ts | java | go | docs | design | ci-cd} ` - label an issue as a `good first issue`.
example: `/gfi js` or `/good-first-issue ci-cd`
})
- \`/good-first-issue {js | ts | java | go | docs | design | ci-cd}\` or \`/gfi {js | ts | java | go | docs | design | ci-cd}\` - label an issue as a \`good first issue\`.
example: \`/gfi js\` or \`/good-first-issue ci-cd\``
})
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Instantiates a new Generator object.
- templateName `String` - Name of the template to generate.
- targetDir `String` - Path to the directory where the files will be generated.
- options `Object`
- [.templateParams] `String` - Optional parameters to pass to the template. Each template define their own params.
- [.templateParams] `Object.<string, string>` - Optional parameters to pass to the template. Each template define their own params.
- [.entrypoint] `String` - Name of the file to use as the entry point for the rendering process. Use in case you want to use only a specific template file. Note: this potentially avoids rendering every file in the template.
- [.noOverwriteGlobs] `Array.<String>` - List of globs to skip when regenerating the template.
- [.disabledHooks] `Object.<String, (Boolean|String|Array.<String>)>` - Object with hooks to disable. The key is a hook type. If key has "true" value, then the generator skips all hooks from the given type. If the value associated with a key is a string with the name of a single hook, then the generator skips only this single hook name. If the value associated with a key is an array of strings, then the generator skips only hooks from the array.
Expand Down
28 changes: 17 additions & 11 deletions docs/template-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@ Let's break down the minimum template requirements: the `template` directory and
### `template` directory

The `template` directory stores generated outputs in files. In other words, the generator processes all the files stored in this directory.
The `template` directory holds all the files that will be used for generating the output. The generator will process all the files stored in this directory.

The following code is an example of an `index.js` file inside the `template` folder.
```js
import { File, Text } from "@asyncapi/generator-react-sdk";

export default function({ asyncapi, params, originalAsyncAPI }) {
return (
export default function ({ asyncapi, params, originalAsyncAPI }) {
return (
<File name="asyncapi.md">
<Text>My application's markdown file.</Text>
<Text>App name: **{ asyncapi.info().title() }**</Text>
<Text>My application's markdown file.</Text>
<Text>App name: **{asyncapi.info().title()}**</Text>
</File>
);
);
}
```
The above example will produce an `asyncapi.md` file where usage of the AsyncAPI document information (i.e. the `title`) is demonstrated.
### `package.json` file
Before the generation process begins, the generator installs the template into its dependencies. A `package.json` file is necessary to identify the template name.
Expand All @@ -43,8 +47,6 @@ The following block shows an example `package.json` file that points to the [Rea
}
```
The above example of a `template/index.js` file shows the generation process result. The user also receives an `asyncapi.md` file with hardcoded and dynamic (application title from the AsyncAPI document) information.
Every template must depend on the [`@asyncapi/generator-react-sdk` package](https://github.com/asyncapi/generator-react-sdk), which contains a template file's basic components.

## Additional configuration options
Expand Down Expand Up @@ -73,14 +75,16 @@ The following examples show some advanced configurations that we can use in our
"name": "myTemplate",
"generator": {
"renderer": "react",
"supportedProtocols": "mqtt"
"supportedProtocols": [
"mqtt"
]
},
"dependencies": {
"@asyncapi/generator-react-sdk": "^0.2.25"
}
}
```
The above `package.json` file has a newly added configuration called `supportedProtocols` which is set to `mqtt`. This configuration displays all the protocols that this template supports. You can have multiple supported protocols in our template.
The above `package.json` file has a newly added configuration called `supportedProtocols` which is set to a list containing only `mqtt`. This configuration displays all the protocols that this template supports. You can have multiple supported protocols in our template.
For example, if you want to generate an output using the above template, you need to have an AsyncAPI document with servers that use `mqtt` to generate your desired output. If your AsyncAPI document has server connections with `kafka`, the generation process will be terminated since the only supported protocol mentioned is `mqtt`.
Expand All @@ -93,7 +97,9 @@ Additionally, we can also have a configuration called `parameters`, which is an
"name": "myTemplate",
"generator": {
"renderer": "react",
"supportedProtocols": "mqtt",
"supportedProtocols": [
"mqtt"
],
"parameters": {
"version": {
"description": "Overrides application version under `info.version` in the AsyncAPI document.",
Expand Down
2 changes: 1 addition & 1 deletion lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Generator {
* @param {String} templateName Name of the template to generate.
* @param {String} targetDir Path to the directory where the files will be generated.
* @param {Object} options
* @param {String} [options.templateParams] Optional parameters to pass to the template. Each template define their own params.
* @param {Object<string, string>} [options.templateParams] Optional parameters to pass to the template. Each template define their own params.
* @param {String} [options.entrypoint] Name of the file to use as the entry point for the rendering process. Use in case you want to use only a specific template file. Note: this potentially avoids rendering every file in the template.
* @param {String[]} [options.noOverwriteGlobs] List of globs to skip when regenerating the template.
* @param {Object<String, Boolean | String | String[]>} [options.disabledHooks] Object with hooks to disable. The key is a hook type. If key has "true" value, then the generator skips all hooks from the given type. If the value associated with a key is a string with the name of a single hook, then the generator skips only this single hook name. If the value associated with a key is an array of strings, then the generator skips only hooks from the array.
Expand Down

0 comments on commit ace0228

Please sign in to comment.