@asyncapi/generator 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintignore CHANGED
@@ -1,4 +1,5 @@
1
1
  output
2
2
  node_modules
3
3
  .github/templates-list-validator/dist
4
- test/temp
4
+ test/temp
5
+ test/test-templates/react-template/__transpiled
package/.eslintrc CHANGED
@@ -6,12 +6,20 @@ env:
6
6
  plugins:
7
7
  - sonarjs
8
8
  - jest
9
+ - react
9
10
 
10
11
  extends:
12
+ - plugin:react/recommended
11
13
  - plugin:sonarjs/recommended
12
14
 
13
15
  parserOptions:
14
16
  ecmaVersion: 2018
17
+ sourceType: module
18
+ ecmaFeatures:
19
+ jsx: true
20
+ settings:
21
+ react:
22
+ version: detect
15
23
 
16
24
  rules:
17
25
  # Ignore Rules
@@ -96,3 +104,10 @@ rules:
96
104
  prefer-const: 2
97
105
  prefer-spread: 2
98
106
  prefer-template: 2
107
+
108
+ # React
109
+ react/jsx-uses-react: off
110
+ react/react-in-jsx-scope: off
111
+ react/display-name: off
112
+ react/prop-types: off
113
+ react/jsx-key: off
package/.releaserc CHANGED
@@ -13,6 +13,8 @@ branches:
13
13
  prerelease: true
14
14
  - name: alpha
15
15
  prerelease: true
16
+ - name: next
17
+ prerelease: true
16
18
  plugins:
17
19
  - - "@semantic-release/commit-analyzer"
18
20
  - preset: conventionalcommits
package/README.md CHANGED
@@ -84,6 +84,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
84
84
  <td align="center" valign="top" width="33.33%"><a href="https://blog.orzzh.icu/"><img src="https://avatars.githubusercontent.com/u/33168669?v=4?s=100" width="100px;" alt="GavinZhengOI"/><br /><sub><b>GavinZhengOI</b></sub></a><br /><a href="https://github.com/asyncapi/generator/commits?author=GavinZhengOI" title="Documentation">📖</a></td>
85
85
  <td align="center" valign="top" width="33.33%"><a href="https://github.com/lmgyuan"><img src="https://avatars.githubusercontent.com/u/16447041?v=4?s=100" width="100px;" alt="lmgyuan"/><br /><sub><b>lmgyuan</b></sub></a><br /><a href="https://github.com/asyncapi/generator/commits?author=lmgyuan" title="Documentation">📖</a></td>
86
86
  </tr>
87
+ <tr>
88
+ <td align="center" valign="top" width="33.33%"><a href="https://github.com/pierrick-boule"><img src="https://avatars.githubusercontent.com/u/3237116?v=4?s=100" width="100px;" alt="pierrick-boule"/><br /><sub><b>pierrick-boule</b></sub></a><br /><a href="https://github.com/asyncapi/generator/commits?author=pierrick-boule" title="Code">💻</a> <a href="https://github.com/asyncapi/generator/commits?author=pierrick-boule" title="Tests">⚠️</a> <a href="https://github.com/asyncapi/generator/commits?author=pierrick-boule" title="Documentation">📖</a></td>
89
+ </tr>
87
90
  </tbody>
88
91
  </table>
89
92
 
package/docs/index.md CHANGED
@@ -24,7 +24,7 @@ The AsyncAPI generator is a tool that generates anything you want using the **[A
24
24
  3. The **Parser** uses additional plugins such as the OpenAPI, RAML, or Avro schemas to validate custom schemas of message payloads defined in the **AsyncAPI Document**.
25
25
  4. If the **Parser** determines that the original **AsyncAPI Document** is valid, it manipulates the document and returns a set of helper functions and properties and bundles them together into an **asyncapi** variable that is an instance of [**AsyncAPIDocument**](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#asyncapidocument). The **asyncapi** helper functions make it easier to access the contents of the AsyncAPI Document.
26
26
  5. At this point, the **Generator** passes the **[asyncapi](generator/asyncapi-document#method-2-asyncapi-and-template)**, the **[originalAsyncAPI](generator/asyncapi-document#method-1-originalasyncapi-and-template)**, and the **params** which collectively make up the **[Template Context](generator/template-context)** to the **Render Engine**.
27
- 6. AsyncAPI has two **Render Engines**([react](generator/react-render-engine) and [nunjucks](generator/nunjucks-render-engine). Depending on which one you've specified in your `package.json`, the **Generator** knows the right **Render Engine** to pass both the **Template Files** and the **Template Context**.
27
+ 6. AsyncAPI has two **Render Engines**([react](generator/react-render-engine) and [nunjucks](generator/nunjucks-render-engine)). Depending on which one you've specified in your `package.json`, the **Generator** knows the right **Render Engine** to pass both the **Template Files** and the **Template Context**.
28
28
  7. Once the **Render Engine** receives the **Template Files** and the **Template Context**, it injects all the dynamic values in your react or nunjucks based **Template Files** using the **Template Context**. As a result, the **Render Engine** generates **markdown**, **pdf**, **boilerplate code**, and **anything else** you specified to be generated as output.
29
29
 
30
30
  > You can generate anything you want using the generator as long as it can be defined in a **Template**.
@@ -4,7 +4,7 @@ weight: 100
4
4
  ---
5
5
 
6
6
  While using the generator tool, you may want dynamic values populated to your templates and rendered in the output. The generator can achieve that using the **template context**.
7
- The **template context** allows you to access the contents of the [AsyncAPI document](asyncapi-document.md) and inject dynamic values to the template files passed to the asyncAPI CLI during the generation process. The render engine then displays these dynamically assigned values in the output.
7
+ The **template context** allows you to access the contents of the [AsyncAPI document](asyncapi-document) and inject dynamic values to the template files passed to the asyncAPI CLI during the generation process. The render engine then displays these dynamically assigned values in the output.
8
8
 
9
9
  ## Generation process
10
10
  1. The **Generator** receives **Template** and **params** as input.
@@ -35,7 +35,7 @@ The above example will produce an `asyncapi.md` file where usage of the AsyncAPI
35
35
 
36
36
  Before the generation process begins, the generator installs the template into its dependencies. A `package.json` file is necessary to identify the template name.
37
37
 
38
- The following block shows an example `package.json` file that points to the [React Render Engine](react-render-engine.md) and necessary dependencies:
38
+ The following block shows an example `package.json` file that points to the [React Render Engine](react-render-engine) and necessary dependencies:
39
39
 
40
40
  ```json
41
41
  {
@@ -64,7 +64,7 @@ You must configure the generator's `package.json` file to contain JSON objects w
64
64
  |`parameters[param].default`| Any | Default value of the parameter if not specified. Shouldn't be used for mandatory `required=true` parameters.
65
65
  |`parameters[param].required`| Boolean | Whether the parameter is required or not.
66
66
 
67
- The above table lists some configuration options that help the generator achieve a specific set of tasks throughout the generation process. The `generator` property from 'package.json' contains all the configuration information. To learn more about template configuration and various supported parameters, read the [generator configuration file](configuration-file.md).
67
+ The above table lists some configuration options that help the generator achieve a specific set of tasks throughout the generation process. The `generator` property from 'package.json' contains all the configuration information. To learn more about template configuration and various supported parameters, read the [generator configuration file](configuration-file).
68
68
 
69
69
  > Whenever you make a change to the package.json, make sure you perform an update by running `npm install`; this command synchronizes with the `package-lock.json` and validates the file.
70
70
 
@@ -137,7 +137,7 @@ The above configuration helps template users override the existing version with
137
137
 
138
138
  ## Hooks
139
139
 
140
- [Hooks](hooks.md) enable templates to perform multiple tasks. You can add Hooks to your template as fractions of code. In the template, you must store it in the `hooks` directory under the template directory. You can also store it in other modules and external libraries or configure it inside the template. The generation process can perform multiple actions.
140
+ [Hooks](hooks) enable templates to perform multiple tasks. You can add Hooks to your template as fractions of code. In the template, you must store it in the `hooks` directory under the template directory. You can also store it in other modules and external libraries or configure it inside the template. The generation process can perform multiple actions.
141
141
 
142
142
  **Templates** can perform multiple actions _before_ or _after_ the generation process with the help of **hooks**.
143
143
 
package/docs/template.md CHANGED
@@ -5,7 +5,7 @@ weight: 50
5
5
 
6
6
  ## Template
7
7
 
8
- A template is a project that specifies the generation process output by using the AsyncAPI generator and an [AsyncAPI document](asyncapi-document.md). These files describe the generation results depending on the AsyncAPI document's content.
8
+ A template is a project that specifies the generation process output by using the AsyncAPI generator and an [AsyncAPI document](asyncapi-document). These files describe the generation results depending on the AsyncAPI document's content.
9
9
 
10
10
  Examples outputs:
11
11
 
package/lib/generator.js CHANGED
@@ -879,7 +879,7 @@ class Generator {
879
879
  if (!shouldOverwriteFile) return;
880
880
 
881
881
  if (this.templateConfig.conditionalFiles && this.templateConfig.conditionalFiles[relativeSourceFile]) {
882
- const server = this.templateParams.server && asyncapiDocument.server(this.templateParams.server);
882
+ const server = this.templateParams.server && asyncapiDocument.servers().get(this.templateParams.server);
883
883
  const source = jmespath.search({
884
884
  ...asyncapiDocument.json(),
885
885
  ...{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asyncapi/generator",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "The AsyncAPI generator. It can generate documentation, code, anything!",
5
5
  "main": "./lib/generator.js",
6
6
  "bin": {
@@ -16,7 +16,8 @@
16
16
  "test:unit": "jest --coverage --testPathIgnorePatterns=integration --testPathIgnorePatterns=test-project",
17
17
  "test:dev": "npm run test:unit -- --watchAll",
18
18
  "test:integration": "npm run test:cleanup && jest --testPathPattern=integration --modulePathIgnorePatterns='./__mocks__'",
19
- "test:cli": "node cli.js ./test/docs/dummy.yml @asyncapi/html-template -o test/output --force-write --debug && test -e test/output/index.html",
19
+ "test:integration:update": "jest --updateSnapshot --testPathPattern=integration --modulePathIgnorePatterns='./__mocks__'",
20
+ "test:cli": "node cli.js ./test/docs/dummy.yml ./test/test-templates/react-template -o test/output --force-write --debug && test -e test/output/test-file.md",
20
21
  "test:cleanup": "rimraf \"test/temp\"",
21
22
  "docs": "jsdoc2md --partial docs/jsdoc2md-handlebars/custom-sig-name.hbs docs/jsdoc2md-handlebars/main.hbs docs/jsdoc2md-handlebars/docs.hbs docs/jsdoc2md-handlebars/header.hbs docs/jsdoc2md-handlebars/defaultvalue.hbs docs/jsdoc2md-handlebars/link.hbs docs/jsdoc2md-handlebars/params-table.hbs --files lib/generator.js > docs/api.md",
22
23
  "docker:build": "docker build -t asyncapi/generator:latest .",
@@ -48,8 +49,8 @@
48
49
  "license": "Apache-2.0",
49
50
  "homepage": "https://github.com/asyncapi/generator",
50
51
  "dependencies": {
51
- "@asyncapi/generator-react-sdk": "^1.0.18",
52
- "@asyncapi/parser": "^3.0.14",
52
+ "@asyncapi/generator-react-sdk": "^1.0.19",
53
+ "@asyncapi/parser": "^3.0.15",
53
54
  "@npmcli/arborist": "5.6.3",
54
55
  "@npmcli/config": "^8.0.2",
55
56
  "@smoya/multi-parser": "^5.0.0",
@@ -79,6 +80,7 @@
79
80
  "conventional-changelog-conventionalcommits": "^5.0.0",
80
81
  "eslint": "^6.8.0",
81
82
  "eslint-plugin-jest": "^23.8.2",
83
+ "eslint-plugin-react": "^7.34.1",
82
84
  "eslint-plugin-sonarjs": "^0.5.0",
83
85
  "jest": "^25.5.0",
84
86
  "jsdoc-to-markdown": "^7.1.1",