@asyncapi/generator 2.8.4 → 3.0.0
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 +39 -0
- package/docs/api.md +2 -51
- package/docs/asyncapi-document.md +1 -1
- package/docs/configuration-file.md +0 -4
- package/docs/file-templates.md +1 -59
- package/docs/generator-template-java.md +0 -2
- package/docs/generator-template.md +1 -4
- package/docs/index.md +2 -2
- package/docs/jsdoc2md-handlebars/main-index/global-index/global-index-dl.hbs +13 -0
- package/docs/jsdoc2md-handlebars/member-index-grouped.hbs +6 -0
- package/docs/jsdoc2md-handlebars/member-index-list.hbs +6 -0
- package/docs/jsdoc2md-handlebars/members.hbs +1 -0
- package/docs/react-render-engine.md +5 -37
- package/docs/template-development.md +2 -7
- package/docs/template.md +2 -2
- package/docs/typescript-support.md +3 -5
- package/jest.config.js +3 -6
- package/lib/__mocks__/utils.js +0 -3
- package/lib/generator.js +4 -20
- package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/.ageneratorrc +2 -4
- package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/__transpiled/jest.config.js +13 -0
- package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/__transpiled/jest.config.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/jest.config.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/package.json +3 -17
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/.ageneratorrc +0 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/jest.config.js +13 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/jest.config.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/jest.config.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/package.json +3 -17
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/.ageneratorrc +0 -2
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/jest.config.js +13 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/jest.config.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/jest.config.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/package.json +4 -18
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/.ageneratorrc +8 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ClientClass.js +5 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ClientClass.js.map +1 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/CompileOperationSchemas.js +48 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/CompileOperationSchemas.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Constructor.js +7 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Constructor.js.map +1 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/jest.config.js +13 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/jest.config.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/README.md.js +5 -153
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/README.md.js.map +1 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/client.js.js +52 -3
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/client.js.js.map +1 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/ClientClass.js +4 -2
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/CompileOperationSchemas.js +40 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/Constructor.js +7 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/jest.config.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/package.json +7 -20
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/template/README.md.js +2 -103
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/template/client.js.js +5 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/.ageneratorrc +0 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/jest.config.js +13 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/jest.config.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/README.md.js +18 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/README.md.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/jest.config.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/package.json +3 -17
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/template/README.md.js +5 -0
- package/lib/templates/config/validator.js +3 -3
- package/lib/utils.js +0 -21
- package/package.json +7 -14
- package/Dockerfile +0 -20
- package/cli.js +0 -205
- package/docs/migration-cli.md +0 -70
- package/docs/migration-nunjucks-react.md +0 -144
- package/docs/nunjucks-render-engine.md +0 -83
- package/lib/filtersRegistry.js +0 -134
- package/lib/renderer/nunjucks.js +0 -42
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/AvailableOperations.js +0 -34
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/AvailableOperations.js.map +0 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/MessageExamples.js +0 -29
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/MessageExamples.js.map +0 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/OperationHeader.js +0 -19
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/OperationHeader.js.map +0 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/AvailableOperations.js +0 -20
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/MessageExamples.js +0 -25
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/OperationHeader.js +0 -12
- package/lib/watcher.js +0 -147
|
@@ -7,8 +7,11 @@ var generatorComponents = require('@asyncapi/generator-components');
|
|
|
7
7
|
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
8
8
|
|
|
9
9
|
function Constructor({
|
|
10
|
-
serverUrl
|
|
10
|
+
serverUrl,
|
|
11
|
+
sendOperations
|
|
11
12
|
}) {
|
|
13
|
+
const sendOperationsId = sendOperations.map(operation => operation.id());
|
|
14
|
+
const sendOperationsArray = JSON.stringify(sendOperationsId);
|
|
12
15
|
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
13
16
|
indent: 2,
|
|
14
17
|
children: `/*
|
|
@@ -20,6 +23,9 @@ constructor(url) {
|
|
|
20
23
|
this.websocket = null;
|
|
21
24
|
this.messageHandlers = [];
|
|
22
25
|
this.errorHandlers = [];
|
|
26
|
+
this.compiledSchemas = {};
|
|
27
|
+
this.schemasCompiled = false;
|
|
28
|
+
this.sendOperationsId = ${sendOperationsArray};
|
|
23
29
|
}
|
|
24
30
|
`
|
|
25
31
|
});
|
|
@@ -33,6 +39,44 @@ function ModuleExport({
|
|
|
33
39
|
});
|
|
34
40
|
}
|
|
35
41
|
|
|
42
|
+
function CompileOperationSchemas({
|
|
43
|
+
sendOperations
|
|
44
|
+
}) {
|
|
45
|
+
if (!sendOperations || sendOperations.length === 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
49
|
+
children: /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
50
|
+
indent: 2,
|
|
51
|
+
newLines: 2,
|
|
52
|
+
children: `/**
|
|
53
|
+
* Initialize and compile all schemas for operations defined.
|
|
54
|
+
* This should be called once after creating the client instance.
|
|
55
|
+
* Subsequent calls will be ignored if schemas are already compiled.
|
|
56
|
+
*
|
|
57
|
+
* @returns {Promise<void>}
|
|
58
|
+
* @throws {Error} If schema compilation fails for any operation
|
|
59
|
+
*/
|
|
60
|
+
async compileOperationSchemas() {
|
|
61
|
+
if (this.schemasCompiled) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
// Compile schemas for all send operations
|
|
67
|
+
for (const operationId of this.sendOperationsId) {
|
|
68
|
+
this.compiledSchemas[operationId] = await compileSchemasByOperationId(asyncapiFilepath, operationId);
|
|
69
|
+
}
|
|
70
|
+
this.schemasCompiled = true;
|
|
71
|
+
console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error('Error initializing schemas:', error);
|
|
74
|
+
}
|
|
75
|
+
}`
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
36
80
|
function ClientClass({
|
|
37
81
|
clientName,
|
|
38
82
|
serverUrl,
|
|
@@ -44,7 +88,8 @@ function ClientClass({
|
|
|
44
88
|
newLines: 2,
|
|
45
89
|
children: `class ${clientName} {`
|
|
46
90
|
}), /*#__PURE__*/jsxRuntime.jsx(Constructor, {
|
|
47
|
-
serverUrl: serverUrl
|
|
91
|
+
serverUrl: serverUrl,
|
|
92
|
+
sendOperations: sendOperations
|
|
48
93
|
}), /*#__PURE__*/jsxRuntime.jsx(generatorComponents.Connect, {
|
|
49
94
|
language: "javascript",
|
|
50
95
|
title: title
|
|
@@ -57,6 +102,8 @@ function ClientClass({
|
|
|
57
102
|
}), /*#__PURE__*/jsxRuntime.jsx(generatorComponents.HandleMessage, {
|
|
58
103
|
language: "javascript",
|
|
59
104
|
methodParams: ['message', 'cb']
|
|
105
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CompileOperationSchemas, {
|
|
106
|
+
sendOperations: sendOperations
|
|
60
107
|
}), /*#__PURE__*/jsxRuntime.jsx(generatorComponents.SendOperations, {
|
|
61
108
|
language: "javascript",
|
|
62
109
|
sendOperations: sendOperations,
|
|
@@ -81,6 +128,7 @@ function client_js ({
|
|
|
81
128
|
const clientName = generatorHelpers.getClientName(asyncapi, params.appendClientSuffix, params.customClientName);
|
|
82
129
|
const serverUrl = generatorHelpers.getServerUrl(server);
|
|
83
130
|
const sendOperations = asyncapi.operations().filterBySend();
|
|
131
|
+
const asyncapiFilepath = `${params.asyncapiFileDir}/asyncapi.yaml`;
|
|
84
132
|
return /*#__PURE__*/jsxRuntime.jsxs(generatorReactSdk.File, {
|
|
85
133
|
name: params.clientFileName,
|
|
86
134
|
children: [/*#__PURE__*/jsxRuntime.jsx(generatorComponents.FileHeaderInfo, {
|
|
@@ -88,7 +136,8 @@ function client_js ({
|
|
|
88
136
|
server: server,
|
|
89
137
|
language: "javascript"
|
|
90
138
|
}), /*#__PURE__*/jsxRuntime.jsx(generatorComponents.DependencyProvider, {
|
|
91
|
-
language: "javascript"
|
|
139
|
+
language: "javascript",
|
|
140
|
+
additionalDependencies: ['const path = require(\'path\');', `const asyncapiFilepath = path.resolve(__dirname, '${asyncapiFilepath}');`]
|
|
92
141
|
}), /*#__PURE__*/jsxRuntime.jsx(ClientClass, {
|
|
93
142
|
clientName: clientName,
|
|
94
143
|
serverUrl: serverUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/Constructor.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/ModuleExport.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/ClientClass.js","../../../../../../../../packages/templates/clients/websocket/javascript/template/client.js.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function Constructor({ serverUrl }) {\n return (\n <Text indent={2}>\n {\n `/*\n * Constructor to initialize the WebSocket client\n * @param {string} url - The WebSocket server URL. Use it if the server URL is different from the default one taken from the AsyncAPI document.\n*/\nconstructor(url) {\n this.url = url || '${serverUrl}';\n this.websocket = null;\n this.messageHandlers = [];\n this.errorHandlers = [];\n}\n`\n }\n </Text>\n );\n}\n","import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function ModuleExport({ clientName }) {\n return (\n <Text>\n {\n `module.exports = ${clientName};`\n }\n </Text>\n );\n}\n","import { Text } from '@asyncapi/generator-react-sdk';\nimport { Constructor } from './Constructor';\nimport { CloseConnection, RegisterMessageHandler, RegisterErrorHandler, SendOperations, Connect, HandleMessage } from '@asyncapi/generator-components';\nimport { ModuleExport } from './ModuleExport';\n\nexport function ClientClass({ clientName, serverUrl, title, sendOperations}) {\n return (\n <Text>\n <Text newLines={2}>\n {`class ${clientName} {`}\n </Text>\n <Constructor serverUrl={serverUrl} />\n <Connect language=\"javascript\" title={title} />\n <RegisterMessageHandler \n language=\"javascript\" \n methodParams={['handler']}\n />\n <RegisterErrorHandler\n language=\"javascript\" \n methodParams={['handler']}\n />\n <HandleMessage \n language=\"javascript\" \n methodParams={['message', 'cb']}\n />\n <SendOperations \n language=\"javascript\" \n sendOperations={sendOperations} \n clientName={clientName} \n />\n <CloseConnection language=\"javascript\" />\n <Text>\n {'}'}\n </Text>\n <ModuleExport clientName={clientName} />\n </Text>\n );\n}\n","import { File } from '@asyncapi/generator-react-sdk';\nimport { getClientName, getServerUrl, getServer, getInfo, getTitle } from '@asyncapi/generator-helpers';\nimport { FileHeaderInfo, DependencyProvider } from '@asyncapi/generator-components';\nimport { ClientClass } from '../components/ClientClass';\n\nexport default function ({ asyncapi, params }) {\n const server = getServer(asyncapi.servers(), params.server);\n const info = getInfo(asyncapi);\n const title = getTitle(asyncapi);\n const clientName = getClientName(asyncapi, params.appendClientSuffix, params.customClientName);\n const serverUrl = getServerUrl(server);\n const sendOperations = asyncapi.operations().filterBySend();\n return (\n <File name={params.clientFileName}>\n <FileHeaderInfo\n info={info}\n server={server}\n language=\"javascript\"\n />\n <DependencyProvider
|
|
1
|
+
{"version":3,"file":"client.js.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/Constructor.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/ModuleExport.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/CompileOperationSchemas.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/ClientClass.js","../../../../../../../../packages/templates/clients/websocket/javascript/template/client.js.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function Constructor({ serverUrl, sendOperations }) {\n const sendOperationsId = sendOperations.map((operation) => operation.id());\n const sendOperationsArray = JSON.stringify(sendOperationsId);\n\n return (\n <Text indent={2}>\n {\n `/*\n * Constructor to initialize the WebSocket client\n * @param {string} url - The WebSocket server URL. Use it if the server URL is different from the default one taken from the AsyncAPI document.\n*/\nconstructor(url) {\n this.url = url || '${serverUrl}';\n this.websocket = null;\n this.messageHandlers = [];\n this.errorHandlers = [];\n this.compiledSchemas = {};\n this.schemasCompiled = false;\n this.sendOperationsId = ${sendOperationsArray};\n}\n`\n }\n </Text>\n );\n}\n","import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function ModuleExport({ clientName }) {\n return (\n <Text>\n {\n `module.exports = ${clientName};`\n }\n </Text>\n );\n}\n","import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function CompileOperationSchemas({ sendOperations }) {\n if (!sendOperations || sendOperations.length === 0) {\n return null;\n } \n\n return (\n <>\n <Text indent={2} newLines={2}>\n {\n `/**\n * Initialize and compile all schemas for operations defined.\n * This should be called once after creating the client instance.\n * Subsequent calls will be ignored if schemas are already compiled.\n * \n * @returns {Promise<void>}\n * @throws {Error} If schema compilation fails for any operation\n */\nasync compileOperationSchemas() {\n if (this.schemasCompiled) {\n return;\n }\n\n try {\n // Compile schemas for all send operations\n for (const operationId of this.sendOperationsId) {\n this.compiledSchemas[operationId] = await compileSchemasByOperationId(asyncapiFilepath, operationId);\n }\n this.schemasCompiled = true;\n console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));\n } catch (error) {\n console.error('Error initializing schemas:', error);\n }\n}`\n }\n </Text>\n </>\n );\n}\n","import { Text } from '@asyncapi/generator-react-sdk';\nimport { Constructor } from './Constructor';\nimport { CloseConnection, RegisterMessageHandler, RegisterErrorHandler, SendOperations, Connect, HandleMessage } from '@asyncapi/generator-components';\nimport { ModuleExport } from './ModuleExport';\nimport { CompileOperationSchemas } from './CompileOperationSchemas';\n\nexport function ClientClass({ clientName, serverUrl, title, sendOperations }) {\n return (\n <Text>\n <Text newLines={2}>\n {`class ${clientName} {`}\n </Text>\n <Constructor serverUrl={serverUrl} sendOperations={sendOperations} />\n <Connect language=\"javascript\" title={title} />\n <RegisterMessageHandler \n language=\"javascript\" \n methodParams={['handler']}\n />\n <RegisterErrorHandler\n language=\"javascript\" \n methodParams={['handler']}\n />\n <HandleMessage \n language=\"javascript\" \n methodParams={['message', 'cb']}\n />\n <CompileOperationSchemas sendOperations={sendOperations} />\n <SendOperations \n language=\"javascript\" \n sendOperations={sendOperations} \n clientName={clientName} \n />\n <CloseConnection language=\"javascript\" />\n <Text>\n {'}'}\n </Text>\n <ModuleExport clientName={clientName} />\n </Text>\n );\n}\n","import { File } from '@asyncapi/generator-react-sdk';\nimport { getClientName, getServerUrl, getServer, getInfo, getTitle } from '@asyncapi/generator-helpers';\nimport { FileHeaderInfo, DependencyProvider } from '@asyncapi/generator-components';\nimport { ClientClass } from '../components/ClientClass';\n\nexport default function ({ asyncapi, params }) {\n const server = getServer(asyncapi.servers(), params.server);\n const info = getInfo(asyncapi);\n const title = getTitle(asyncapi);\n const clientName = getClientName(asyncapi, params.appendClientSuffix, params.customClientName);\n const serverUrl = getServerUrl(server);\n const sendOperations = asyncapi.operations().filterBySend();\n const asyncapiFilepath = `${params.asyncapiFileDir}/asyncapi.yaml`;\n return (\n <File name={params.clientFileName}>\n <FileHeaderInfo\n info={info}\n server={server}\n language=\"javascript\"\n />\n <DependencyProvider\n language=\"javascript\"\n additionalDependencies={['const path = require(\\'path\\');', `const asyncapiFilepath = path.resolve(__dirname, '${asyncapiFilepath}');`]}\n />\n <ClientClass clientName={clientName} serverUrl={serverUrl} title={title} sendOperations={sendOperations} />\n </File>\n );\n}\n"],"names":["Constructor","serverUrl","sendOperations","sendOperationsId","map","operation","id","sendOperationsArray","JSON","stringify","_jsx","Text","indent","children","ModuleExport","clientName","CompileOperationSchemas","length","_Fragment","newLines","ClientClass","title","_jsxs","Connect","language","RegisterMessageHandler","methodParams","RegisterErrorHandler","HandleMessage","SendOperations","CloseConnection","asyncapi","params","server","getServer","servers","info","getInfo","getTitle","getClientName","appendClientSuffix","customClientName","getServerUrl","operations","filterBySend","asyncapiFilepath","asyncapiFileDir","File","name","clientFileName","FileHeaderInfo","DependencyProvider","additionalDependencies"],"mappings":"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"}
|
|
@@ -2,14 +2,15 @@ import { Text } from '@asyncapi/generator-react-sdk';
|
|
|
2
2
|
import { Constructor } from './Constructor';
|
|
3
3
|
import { CloseConnection, RegisterMessageHandler, RegisterErrorHandler, SendOperations, Connect, HandleMessage } from '@asyncapi/generator-components';
|
|
4
4
|
import { ModuleExport } from './ModuleExport';
|
|
5
|
+
import { CompileOperationSchemas } from './CompileOperationSchemas';
|
|
5
6
|
|
|
6
|
-
export function ClientClass({ clientName, serverUrl, title, sendOperations}) {
|
|
7
|
+
export function ClientClass({ clientName, serverUrl, title, sendOperations }) {
|
|
7
8
|
return (
|
|
8
9
|
<Text>
|
|
9
10
|
<Text newLines={2}>
|
|
10
11
|
{`class ${clientName} {`}
|
|
11
12
|
</Text>
|
|
12
|
-
<Constructor serverUrl={serverUrl} />
|
|
13
|
+
<Constructor serverUrl={serverUrl} sendOperations={sendOperations} />
|
|
13
14
|
<Connect language="javascript" title={title} />
|
|
14
15
|
<RegisterMessageHandler
|
|
15
16
|
language="javascript"
|
|
@@ -23,6 +24,7 @@ export function ClientClass({ clientName, serverUrl, title, sendOperations}) {
|
|
|
23
24
|
language="javascript"
|
|
24
25
|
methodParams={['message', 'cb']}
|
|
25
26
|
/>
|
|
27
|
+
<CompileOperationSchemas sendOperations={sendOperations} />
|
|
26
28
|
<SendOperations
|
|
27
29
|
language="javascript"
|
|
28
30
|
sendOperations={sendOperations}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Text } from '@asyncapi/generator-react-sdk';
|
|
2
|
+
|
|
3
|
+
export function CompileOperationSchemas({ sendOperations }) {
|
|
4
|
+
if (!sendOperations || sendOperations.length === 0) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<Text indent={2} newLines={2}>
|
|
11
|
+
{
|
|
12
|
+
`/**
|
|
13
|
+
* Initialize and compile all schemas for operations defined.
|
|
14
|
+
* This should be called once after creating the client instance.
|
|
15
|
+
* Subsequent calls will be ignored if schemas are already compiled.
|
|
16
|
+
*
|
|
17
|
+
* @returns {Promise<void>}
|
|
18
|
+
* @throws {Error} If schema compilation fails for any operation
|
|
19
|
+
*/
|
|
20
|
+
async compileOperationSchemas() {
|
|
21
|
+
if (this.schemasCompiled) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
// Compile schemas for all send operations
|
|
27
|
+
for (const operationId of this.sendOperationsId) {
|
|
28
|
+
this.compiledSchemas[operationId] = await compileSchemasByOperationId(asyncapiFilepath, operationId);
|
|
29
|
+
}
|
|
30
|
+
this.schemasCompiled = true;
|
|
31
|
+
console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error('Error initializing schemas:', error);
|
|
34
|
+
}
|
|
35
|
+
}`
|
|
36
|
+
}
|
|
37
|
+
</Text>
|
|
38
|
+
</>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Text } from '@asyncapi/generator-react-sdk';
|
|
2
2
|
|
|
3
|
-
export function Constructor({ serverUrl }) {
|
|
3
|
+
export function Constructor({ serverUrl, sendOperations }) {
|
|
4
|
+
const sendOperationsId = sendOperations.map((operation) => operation.id());
|
|
5
|
+
const sendOperationsArray = JSON.stringify(sendOperationsId);
|
|
6
|
+
|
|
4
7
|
return (
|
|
5
8
|
<Text indent={2}>
|
|
6
9
|
{
|
|
@@ -13,6 +16,9 @@ constructor(url) {
|
|
|
13
16
|
this.websocket = null;
|
|
14
17
|
this.messageHandlers = [];
|
|
15
18
|
this.errorHandlers = [];
|
|
19
|
+
this.compiledSchemas = {};
|
|
20
|
+
this.schemasCompiled = false;
|
|
21
|
+
this.sendOperationsId = ${sendOperationsArray};
|
|
16
22
|
}
|
|
17
23
|
`
|
|
18
24
|
}
|
package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"private": true,
|
|
4
4
|
"description": "This is a template generating JavaScript websocket client",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"test": "jest --coverage",
|
|
6
|
+
"test": "jest --coverage --passWithNoTests",
|
|
7
7
|
"test:update": "npm run test -- -u",
|
|
8
8
|
"lint": "eslint --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore .",
|
|
9
9
|
"lint:fix": "eslint --fix --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore ."
|
|
@@ -11,35 +11,22 @@
|
|
|
11
11
|
"author": "Lukasz Gornicki <lpgornicki@gmail.com>",
|
|
12
12
|
"license": "Apache-2.0",
|
|
13
13
|
"dependencies": {
|
|
14
|
+
"@asyncapi/generator-helpers": "1.0.0",
|
|
14
15
|
"@asyncapi/generator-react-sdk": "*",
|
|
15
|
-
"@asyncapi/generator-
|
|
16
|
-
"@asyncapi/
|
|
16
|
+
"@asyncapi/generator-components": "0.4.0",
|
|
17
|
+
"@asyncapi/keeper": "0.5.0"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
|
-
"@asyncapi/parser": "^3.0
|
|
20
|
+
"@asyncapi/parser": "^3.4.0",
|
|
20
21
|
"@babel/cli": "^7.25.9",
|
|
21
22
|
"@babel/core": "^7.26.0",
|
|
22
23
|
"@babel/preset-env": "^7.26.0",
|
|
23
24
|
"@babel/preset-react": "^7.25.9",
|
|
24
|
-
"jest-esm-transformer": "^1.0.0",
|
|
25
25
|
"eslint": "^6.8.0",
|
|
26
26
|
"eslint-plugin-jest": "^23.8.2",
|
|
27
27
|
"eslint-plugin-react": "^7.34.1",
|
|
28
|
-
"eslint-plugin-sonarjs": "^0.5.0"
|
|
29
|
-
|
|
30
|
-
"jest": {
|
|
31
|
-
"moduleFileExtensions": [
|
|
32
|
-
"js",
|
|
33
|
-
"json",
|
|
34
|
-
"jsx"
|
|
35
|
-
],
|
|
36
|
-
"transform": {
|
|
37
|
-
"^.+\\.jsx?$": "babel-jest"
|
|
38
|
-
},
|
|
39
|
-
"moduleNameMapper": {
|
|
40
|
-
"^nimma/legacy$": "<rootDir>/../../../../../node_modules/nimma/dist/legacy/cjs/index.js",
|
|
41
|
-
"^nimma/(.*)": "<rootDir>/../../../../../node_modules/nimma/dist/cjs/$1"
|
|
42
|
-
}
|
|
28
|
+
"eslint-plugin-sonarjs": "^0.5.0",
|
|
29
|
+
"jest-esm-transformer": "^1.0.0"
|
|
43
30
|
},
|
|
44
31
|
"babel": {
|
|
45
32
|
"presets": [
|
|
@@ -1,106 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getClientName, getServer, getServerUrl, getInfo, getTitle } from '@asyncapi/generator-helpers';
|
|
3
|
-
import { AvailableOperations } from '../components/AvailableOperations';
|
|
1
|
+
import { Readme } from '@asyncapi/generator-components';
|
|
4
2
|
|
|
5
3
|
export default function({ asyncapi, params }) {
|
|
6
|
-
|
|
7
|
-
const info = getInfo(asyncapi);
|
|
8
|
-
const clientName = getClientName(asyncapi, params.appendClientSuffix, params.customClientName);
|
|
9
|
-
const title = getTitle(asyncapi);
|
|
10
|
-
const serverUrl = getServerUrl(server);
|
|
11
|
-
|
|
12
|
-
const operations = asyncapi.operations().all();
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<File name="README.md">
|
|
16
|
-
<Text newLines={2}>
|
|
17
|
-
{`# ${title}
|
|
18
|
-
|
|
19
|
-
## Overview
|
|
20
|
-
|
|
21
|
-
${info.description() || `A WebSocket client for ${title}.`}
|
|
22
|
-
|
|
23
|
-
- **Version:** ${info.version()}
|
|
24
|
-
- **URL:** ${serverUrl}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## Client API Reference
|
|
28
|
-
|
|
29
|
-
\`\`\`javascript
|
|
30
|
-
const ${clientName} = require('./${params.clientFileName.replace('.js', '')}');
|
|
31
|
-
const wsClient = new ${clientName}();
|
|
32
|
-
\`\`\`
|
|
33
|
-
|
|
34
|
-
Here the wsClient is an instance of the \`${clientName}\` class.
|
|
35
|
-
### Core Methods
|
|
36
|
-
|
|
37
|
-
#### \`connect()\`
|
|
38
|
-
Establishes a WebSocket connection to the server.
|
|
39
|
-
|
|
40
|
-
#### \`registerMessageHandler(handlerFunction)\`
|
|
41
|
-
Registers a callback to handle incoming messages.
|
|
42
|
-
- **Parameter:** \`handlerFunction\` - This Function takes a parameter \`message\` which is a string.
|
|
43
|
-
|
|
44
|
-
#### \`registerErrorHandler(handlerFunction)\`
|
|
45
|
-
Registers a callback to handle WebSocket errors.
|
|
46
|
-
- **Parameter:** \`handlerFunction\` - This Function takes a parameter \`error\` which is an object
|
|
47
|
-
|
|
48
|
-
#### \`close()\`
|
|
49
|
-
Closes the WebSocket connection.`}
|
|
50
|
-
</Text>
|
|
51
|
-
<AvailableOperations operations={operations} />
|
|
52
|
-
<Text newLines={2}>
|
|
53
|
-
{`## Testing the client
|
|
54
|
-
|
|
55
|
-
\`\`\`javascript
|
|
56
|
-
const ${clientName} = require('./${params.clientFileName.replace('.js', '')}');
|
|
57
|
-
const wsClient = new ${clientName}();
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// Example of how custom message handler that operates on incoming messages can look like
|
|
61
|
-
|
|
62
|
-
function myHandler(message) {
|
|
63
|
-
console.log('====================');
|
|
64
|
-
console.log('Just proving I got the message in myHandler:', message);
|
|
65
|
-
console.log('====================');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Example of custom error handler
|
|
69
|
-
|
|
70
|
-
function myErrorHandler(error) {
|
|
71
|
-
console.error('Errors from Websocket:', error.message);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async function main() {
|
|
75
|
-
wsClient.registerMessageHandler(myHandler);
|
|
76
|
-
wsClient.registerErrorHandler(myErrorHandler);
|
|
77
|
-
|
|
78
|
-
try {
|
|
79
|
-
await wsClient.connect();
|
|
80
|
-
|
|
81
|
-
// Loop to send messages every 5 seconds
|
|
82
|
-
const interval = 5000; // 5 seconds
|
|
83
|
-
const message = 'Hello, Echo!';
|
|
84
|
-
|
|
85
|
-
while (true) {
|
|
86
|
-
try {
|
|
87
|
-
await wsClient.sendEchoMessage(message);
|
|
88
|
-
} catch (error) {
|
|
89
|
-
console.error('Error while sending message:', error);
|
|
90
|
-
}
|
|
91
|
-
// Wait for the interval before sending the next message
|
|
92
|
-
await new Promise(resolve => setTimeout(resolve, interval));
|
|
93
|
-
}
|
|
94
|
-
} catch (error) {
|
|
95
|
-
console.error('Failed to connect to WebSocket:', error.message);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
main();
|
|
100
|
-
\`\`\`
|
|
101
|
-
|
|
102
|
-
`}
|
|
103
|
-
</Text>
|
|
104
|
-
</File>
|
|
105
|
-
);
|
|
4
|
+
return Readme({asyncapi, params, language: 'javascript'});
|
|
106
5
|
}
|
|
@@ -10,6 +10,7 @@ export default function ({ asyncapi, params }) {
|
|
|
10
10
|
const clientName = getClientName(asyncapi, params.appendClientSuffix, params.customClientName);
|
|
11
11
|
const serverUrl = getServerUrl(server);
|
|
12
12
|
const sendOperations = asyncapi.operations().filterBySend();
|
|
13
|
+
const asyncapiFilepath = `${params.asyncapiFileDir}/asyncapi.yaml`;
|
|
13
14
|
return (
|
|
14
15
|
<File name={params.clientFileName}>
|
|
15
16
|
<FileHeaderInfo
|
|
@@ -17,7 +18,10 @@ export default function ({ asyncapi, params }) {
|
|
|
17
18
|
server={server}
|
|
18
19
|
language="javascript"
|
|
19
20
|
/>
|
|
20
|
-
<DependencyProvider
|
|
21
|
+
<DependencyProvider
|
|
22
|
+
language="javascript"
|
|
23
|
+
additionalDependencies={['const path = require(\'path\');', `const asyncapiFilepath = path.resolve(__dirname, '${asyncapiFilepath}');`]}
|
|
24
|
+
/>
|
|
21
25
|
<ClientClass clientName={clientName} serverUrl={serverUrl} title={title} sendOperations={sendOperations} />
|
|
22
26
|
</File>
|
|
23
27
|
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('source-map-support/register');
|
|
4
|
+
|
|
5
|
+
const baseConfig = require('../../../../../jest.config.base');
|
|
6
|
+
module.exports = {
|
|
7
|
+
...baseConfig(__dirname),
|
|
8
|
+
moduleFileExtensions: ['js', 'json', 'jsx'],
|
|
9
|
+
transform: {
|
|
10
|
+
'^.+\\.jsx?$': 'babel-jest'
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=jest.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.config.js","sources":["../../../../../../../packages/templates/clients/websocket/python/jest.config.js"],"sourcesContent":["const baseConfig = require('../../../../../jest.config.base');\n\nmodule.exports = {\n ...baseConfig(__dirname),\n moduleFileExtensions: [\n 'js',\n 'json',\n 'jsx'\n ],\n transform: {\n '^.+\\\\.jsx?$': 'babel-jest'\n },\n};\n\n"],"names":["baseConfig","require","module","exports","__dirname","moduleFileExtensions","transform"],"mappings":";;;;AAAA,MAAMA,UAAU,GAAGC,OAAO,CAAC,iCAAiC,CAAC,CAAA;AAE7DC,MAAM,CAACC,OAAO,GAAG;EACf,GAAGH,UAAU,CAACI,SAAS,CAAC;AACxBC,EAAAA,oBAAoB,EAAE,CACpB,IAAI,EACJ,MAAM,EACN,KAAK,CACN;AACDC,EAAAA,SAAS,EAAE;AACT,IAAA,aAAa,EAAE,YAAA;AACjB,GAAA;AACF,CAAC;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('source-map-support/register');
|
|
4
|
+
var generatorComponents = require('@asyncapi/generator-components');
|
|
5
|
+
|
|
6
|
+
function README_md ({
|
|
7
|
+
asyncapi,
|
|
8
|
+
params
|
|
9
|
+
}) {
|
|
10
|
+
return generatorComponents.Readme({
|
|
11
|
+
asyncapi,
|
|
12
|
+
params,
|
|
13
|
+
language: 'python'
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = README_md;
|
|
18
|
+
//# sourceMappingURL=README.md.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"README.md.js","sources":["../../../../../../../../packages/templates/clients/websocket/python/template/README.md.js"],"sourcesContent":["import { Readme } from '@asyncapi/generator-components';\n\nexport default function({ asyncapi, params }) {\n return Readme({asyncapi, params, language: 'python'}); \n}"],"names":["asyncapi","params","Readme","language"],"mappings":";;;;;AAEe,kBAAS,EAAA;EAAEA,QAAQ;AAAEC,EAAAA,MAAAA;AAAO,CAAC,EAAE;AAC5C,EAAA,OAAOC,0BAAM,CAAC;IAACF,QAAQ;IAAEC,MAAM;AAAEE,IAAAA,QAAQ,EAAE,QAAA;AAAQ,GAAC,CAAC,CAAA;AACvD;;;;"}
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"license": "Apache-2.0",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@asyncapi/generator-react-sdk": "*",
|
|
15
|
-
"@asyncapi/generator-helpers": "0.
|
|
16
|
-
"@asyncapi/generator-components": "0.
|
|
15
|
+
"@asyncapi/generator-helpers": "1.0.0",
|
|
16
|
+
"@asyncapi/generator-components": "0.4.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@asyncapi/parser": "^3.0
|
|
19
|
+
"@asyncapi/parser": "^3.4.0",
|
|
20
20
|
"@babel/cli": "^7.25.9",
|
|
21
21
|
"@babel/core": "^7.26.0",
|
|
22
22
|
"@babel/preset-env": "^7.26.0",
|
|
@@ -27,20 +27,6 @@
|
|
|
27
27
|
"eslint-plugin-react": "^7.34.1",
|
|
28
28
|
"eslint-plugin-sonarjs": "^0.5.0"
|
|
29
29
|
},
|
|
30
|
-
"jest": {
|
|
31
|
-
"moduleFileExtensions": [
|
|
32
|
-
"js",
|
|
33
|
-
"json",
|
|
34
|
-
"jsx"
|
|
35
|
-
],
|
|
36
|
-
"transform": {
|
|
37
|
-
"^.+\\.jsx?$": "babel-jest"
|
|
38
|
-
},
|
|
39
|
-
"moduleNameMapper": {
|
|
40
|
-
"^nimma/legacy$": "<rootDir>/../../../../../node_modules/nimma/dist/legacy/cjs/index.js",
|
|
41
|
-
"^nimma/(.*)": "<rootDir>/../../../../../node_modules/nimma/dist/cjs/$1"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
30
|
"babel": {
|
|
45
31
|
"presets": [
|
|
46
32
|
"@babel/preset-env",
|
|
@@ -130,17 +130,17 @@ function isServerProtocolSupported(server, supportedProtocols, paramsServerName)
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
|
-
* Checks if the
|
|
133
|
+
* Checks if the provided renderer is supported (no renderer is also supported, defaults to react)
|
|
134
134
|
*
|
|
135
135
|
* @param {Object} templateConfig Template configuration.
|
|
136
136
|
*/
|
|
137
137
|
function isProvidedTemplateRendererSupported(templateConfig) {
|
|
138
|
-
const supportedRenderers = [undefined, 'react'
|
|
138
|
+
const supportedRenderers = [undefined, 'react'];
|
|
139
139
|
if (supportedRenderers.includes(templateConfig.renderer)) {
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
throw new Error(`We do not support '${templateConfig.renderer}' as a renderer for a template. Only 'react'
|
|
143
|
+
throw new Error(`We do not support '${templateConfig.renderer}' as a renderer for a template. Only 'react' is supported.`);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
/**
|
package/lib/utils.js
CHANGED
|
@@ -59,27 +59,6 @@ utils.convertMapToObject = (map) => {
|
|
|
59
59
|
return tempObject;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
/**
|
|
63
|
-
* Checks if template is local or not (i.e., it's remote).
|
|
64
|
-
* @private
|
|
65
|
-
* @param {String} templatePath The path to the template.
|
|
66
|
-
* @returns {Promise<Boolean>}
|
|
67
|
-
*/
|
|
68
|
-
utils.isLocalTemplate = async (templatePath) => {
|
|
69
|
-
const stats = await utils.lstat(templatePath);
|
|
70
|
-
return stats.isSymbolicLink();
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Returns whether or not the template is a react template
|
|
75
|
-
*
|
|
76
|
-
* @param {object} templateConfig
|
|
77
|
-
* @returns {boolean} Whether the template is a React template or not.
|
|
78
|
-
*/
|
|
79
|
-
utils.isReactTemplate = (templateConfig) => {
|
|
80
|
-
return templateConfig !== undefined && templateConfig.renderer === 'react';
|
|
81
|
-
};
|
|
82
|
-
|
|
83
62
|
/**
|
|
84
63
|
* Fetches an AsyncAPI document from the given URL and return its content as string
|
|
85
64
|
*
|
package/package.json
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asyncapi/generator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "The AsyncAPI generator. It can generate documentation, code, anything!",
|
|
5
5
|
"main": "./lib/generator.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"asyncapi-generator": "./cli.js",
|
|
8
|
-
"ag": "./cli.js"
|
|
9
|
-
},
|
|
10
6
|
"engines": {
|
|
11
|
-
"node": ">=
|
|
12
|
-
"npm": ">=
|
|
7
|
+
"node": ">=24.11",
|
|
8
|
+
"npm": ">=11.5.1"
|
|
13
9
|
},
|
|
14
10
|
"scripts": {
|
|
15
11
|
"test": "npm run test:unit && npm run test:integration",
|
|
@@ -18,7 +14,7 @@
|
|
|
18
14
|
"test:integration": "npm run test:cleanup && jest --testPathPattern=integration --modulePathIgnorePatterns='./__mocks__(?!\\/loglevel\\.js$)'",
|
|
19
15
|
"test:integration:update": "npm run test:integration -- -u",
|
|
20
16
|
"test:cleanup": "rimraf \"test/temp\"",
|
|
21
|
-
"docs": "jsdoc2md --partial docs/jsdoc2md-handlebars
|
|
17
|
+
"docs": "jsdoc2md --partial \"docs/jsdoc2md-handlebars/**/*.hbs\" --files lib/generator.js > docs/api.md",
|
|
22
18
|
"docker:build": "docker build -t asyncapi/generator:latest .",
|
|
23
19
|
"lint": "eslint --max-warnings 0 --config ../../.eslintrc --ignore-path ../../.eslintignore .",
|
|
24
20
|
"lint:fix": "npm run lint -- --fix",
|
|
@@ -56,24 +52,21 @@
|
|
|
56
52
|
"@asyncapi/generator-helpers": "*",
|
|
57
53
|
"@asyncapi/generator-hooks": "*",
|
|
58
54
|
"@asyncapi/generator-react-sdk": "*",
|
|
59
|
-
"@asyncapi/multi-parser": "^2.
|
|
60
|
-
"@asyncapi/
|
|
61
|
-
"@asyncapi/parser": "^3.0.14",
|
|
55
|
+
"@asyncapi/multi-parser": "^2.2.0",
|
|
56
|
+
"@asyncapi/parser": "^3.4.0",
|
|
62
57
|
"@npmcli/arborist": "5.6.3",
|
|
63
58
|
"@npmcli/config": "^8.0.2",
|
|
64
59
|
"ajv": "^8.12.0",
|
|
65
|
-
"chokidar": "^3.4.0",
|
|
66
60
|
"commander": "^6.1.0",
|
|
67
61
|
"filenamify": "^4.1.0",
|
|
68
62
|
"fs.extra": "^1.3.2",
|
|
69
63
|
"global-dirs": "^3.0.0",
|
|
70
64
|
"jmespath": "^0.15.0",
|
|
71
|
-
"js-yaml": "^
|
|
65
|
+
"js-yaml": "^4.1.1",
|
|
72
66
|
"levenshtein-edit-distance": "^2.0.5",
|
|
73
67
|
"loglevel": "^1.6.8",
|
|
74
68
|
"minimatch": "^3.0.4",
|
|
75
69
|
"node-fetch": "^2.6.0",
|
|
76
|
-
"nunjucks": "^3.2.0",
|
|
77
70
|
"requireg": "^0.2.2",
|
|
78
71
|
"resolve-from": "^5.0.0",
|
|
79
72
|
"resolve-pkg": "^2.0.0",
|