@asyncapi/generator 3.2.0 → 3.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @asyncapi/generator
2
2
 
3
+ ## 3.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 643f194: Fix browserslist error when using pnpm
8
+
9
+ Set BROWSERSLIST_ROOT_PATH environment variable during template compilation
10
+ to prevent browserslist from searching outside the template directory. This
11
+ fixes an issue where pnpm's shim files were incorrectly parsed as browserslist
12
+ configuration, causing "Unknown browser query" errors.
13
+
14
+ Fixes: https://github.com/asyncapi/cli/issues/1781
15
+
3
16
  ## 3.2.0
4
17
 
5
18
  ### Minor Changes
@@ -97,6 +97,10 @@ weight: 77
97
97
 
98
98
  Renders WebSocket send operation methods. Generates both static and instance methods for sending messages through WebSocket connections.
99
99
 
100
+ * [createError](#createError) ⇒ `Error`<br/>
101
+
102
+ Creates an error with a specific error code for programmatic handling
103
+
100
104
 
101
105
  <a name="CloseConnection"></a>
102
106
  ### CloseConnection()
@@ -366,13 +370,13 @@ Renders a language-specific formatted method definition.
366
370
  |------|------|-------------|
367
371
  | props | `Object` | Component props. |
368
372
  | props.language | `Language` | Programming language used for method formatting. |
369
- | props.methodName | `string` | Name of the method. |
373
+ | props.methodName | `string` | Name of the method (non-empty string required). |
370
374
  | props.methodParams | `Array.<string>` | Method parameters. |
371
375
  | props.methodDocs | `string` | Optional documentation string. |
372
376
  | props.methodLogic | `string` | Core method logic. |
373
377
  | props.preExecutionCode | `string` | Code before main logic. |
374
378
  | props.postExecutionCode | `string` | Code after main logic. |
375
- | props.indent | `number` | Indentation for the method block. |
379
+ | props.indent | `number` | Indentation for the method block (must be &gt;&#x3D; 0). |
376
380
  | props.newLines | `number` | Number of new lines after method. |
377
381
  | props.customMethodConfig | `Object` | Optional custom syntax configuration for the current language. |
378
382
  | props.methodConfig | `Object` | Language-level or framework-level configuration. |
@@ -1231,3 +1235,24 @@ renderSendOperations().catch(console.error);
1231
1235
  ```
1232
1236
 
1233
1237
 
1238
+
1239
+ <a name="createError"></a>
1240
+ ### createError()
1241
+ Creates an error with a specific error code for programmatic handling
1242
+
1243
+
1244
+ **Parameters**
1245
+
1246
+ | Name | Type | Description |
1247
+ |------|------|-------------|
1248
+ | code | `string` | The error code (from ERROR_CODES) |
1249
+ | message | `string` | The error message |
1250
+
1251
+
1252
+
1253
+ **Returns**
1254
+
1255
+ - `Error` - An error object with an attached code property
1256
+
1257
+
1258
+
package/lib/generator.js CHANGED
@@ -401,7 +401,22 @@ class Generator {
401
401
  */
402
402
  async configureTemplate() {
403
403
  if (this.compile) {
404
- await configureReact(this.templateDir, this.templateContentDir, TRANSPILED_TEMPLATE_LOCATION);
404
+ // Set BROWSERSLIST_ROOT_PATH to prevent browserslist from searching
405
+ // outside the template directory. This fixes issues with pnpm where
406
+ // browserslist would incorrectly parse pnpm shim files as config.
407
+ // See: https://github.com/asyncapi/cli/issues/1781
408
+ const previousRootPath = process.env.BROWSERSLIST_ROOT_PATH;
409
+ process.env.BROWSERSLIST_ROOT_PATH = this.templateDir;
410
+ try {
411
+ await configureReact(this.templateDir, this.templateContentDir, TRANSPILED_TEMPLATE_LOCATION);
412
+ } finally {
413
+ // Restore previous value if it existed
414
+ if (previousRootPath === undefined) {
415
+ delete process.env.BROWSERSLIST_ROOT_PATH;
416
+ } else {
417
+ process.env.BROWSERSLIST_ROOT_PATH = previousRootPath;
418
+ }
419
+ }
405
420
  }
406
421
  }
407
422
 
@@ -5,6 +5,8 @@
5
5
  "scripts": {
6
6
  "test": "jest --coverage --passWithNoTests",
7
7
  "test:update": "npm run test -- -u",
8
+ "test:integration": "npm --prefix ../test/integration-test run test:dart",
9
+ "test:integration:update": "npm --prefix ../test/integration-test run test:dart:update",
8
10
  "lint": "eslint --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore .",
9
11
  "lint:fix": "eslint --fix --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore ."
10
12
  },
@@ -13,7 +15,7 @@
13
15
  "dependencies": {
14
16
  "@asyncapi/generator-react-sdk": "*",
15
17
  "@asyncapi/generator-helpers": "1.1.0",
16
- "@asyncapi/generator-components": "0.5.0"
18
+ "@asyncapi/generator-components": "0.6.0"
17
19
  },
18
20
  "devDependencies": {
19
21
  "@asyncapi/parser": "^3.4.0",
@@ -14,12 +14,14 @@
14
14
  "scripts": {
15
15
  "test": "jest --coverage",
16
16
  "test:update": "npm run test -- -u",
17
+ "test:integration": "npm --prefix ../../test/integration-test run test:java-quarkus",
18
+ "test:integration:update": "npm --prefix ../../test/integration-test run test:java-quarkus:update",
17
19
  "lint": "eslint --max-warnings 0 --config ../../../../../../.eslintrc --ignore-path ../../../../../../.eslintignore .",
18
20
  "lint:fix": "eslint --fix --max-warnings 0 --config ../../../../../../.eslintrc --ignore-path ../../../../../../.eslintignore ."
19
21
  },
20
22
  "dependencies": {
21
23
  "@asyncapi/generator-helpers": "1.1.0",
22
- "@asyncapi/generator-components": "0.5.0",
24
+ "@asyncapi/generator-components": "0.6.0",
23
25
  "@asyncapi/generator-react-sdk": "^1.1.2"
24
26
  },
25
27
  "devDependencies": {
@@ -5,13 +5,15 @@
5
5
  "scripts": {
6
6
  "test": "jest --coverage --passWithNoTests",
7
7
  "test:update": "npm run test -- -u",
8
+ "test:integration": "npm --prefix ../test/integration-test run test:javascript",
9
+ "test:integration:update": "npm --prefix ../test/integration-test run test:javascript:update",
8
10
  "lint": "eslint --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore .",
9
11
  "lint:fix": "eslint --fix --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore ."
10
12
  },
11
13
  "author": "Lukasz Gornicki <lpgornicki@gmail.com>",
12
14
  "license": "Apache-2.0",
13
15
  "dependencies": {
14
- "@asyncapi/generator-components": "0.5.0",
16
+ "@asyncapi/generator-components": "0.6.0",
15
17
  "@asyncapi/generator-helpers": "1.1.0",
16
18
  "@asyncapi/generator-react-sdk": "*",
17
19
  "@asyncapi/keeper": "0.5.0",
@@ -5,6 +5,8 @@
5
5
  "scripts": {
6
6
  "test": "jest --coverage",
7
7
  "test:update": "npm run test -- -u",
8
+ "test:integration": "npm --prefix ../test/integration-test run test:python",
9
+ "test:integration:update": "npm --prefix ../test/integration-test run test:python:update",
8
10
  "lint": "eslint --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore .",
9
11
  "lint:fix": "eslint --fix --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore ."
10
12
  },
@@ -13,7 +15,7 @@
13
15
  "dependencies": {
14
16
  "@asyncapi/generator-react-sdk": "*",
15
17
  "@asyncapi/generator-helpers": "1.1.0",
16
- "@asyncapi/generator-components": "0.5.0"
18
+ "@asyncapi/generator-components": "0.6.0"
17
19
  },
18
20
  "devDependencies": {
19
21
  "@asyncapi/parser": "^3.4.0",
@@ -37,15 +37,21 @@ module.exports.isCoreTemplate = (templateName) => {
37
37
  /**
38
38
  * Retrieve a template by name and validate its path.
39
39
  * If the path does not exist, fallback to `node_modules/{templateName}`.
40
+ * Returns undefined when templateName is invalid (null, undefined, not a string, or empty/whitespace-only) or when no baked-in template exists with the given name.
40
41
  *
41
42
  * @async
42
43
  * @param {string} templateName - The name of the template to retrieve.
43
- * @returns {Promise<{name: string, path: string}|undefined>} An object containing the template's name and path, or undefined if not found.
44
+ * @returns {Promise<{name: string, path: string}|undefined>} An object containing the template's name and path, or undefined if templateName is invalid or template is not on the list.
44
45
  */
45
46
  module.exports.getTemplate = async (templateName) => {
47
+ if (templateName == null || typeof templateName !== 'string' || templateName.trim() === '') {
48
+ return undefined;
49
+ }
46
50
  const template = templates.find(t => t.name === templateName);
47
-
48
- const templatePath = template?.path || path.resolve(__dirname, BAKED_IN_TEMPLATES_DIR, template.name);
51
+ if (!template) {
52
+ return undefined;
53
+ }
54
+ const templatePath = template.path || path.resolve(__dirname, BAKED_IN_TEMPLATES_DIR, template.name);
49
55
  return {
50
56
  name: template.name,
51
57
  path: templatePath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asyncapi/generator",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "The AsyncAPI generator. It can generate documentation, code, anything!",
5
5
  "main": "./lib/generator.js",
6
6
  "engines": {