@asyncapi/generator 2.6.0 → 2.7.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 +136 -0
- package/Dockerfile +7 -8
- package/docs/asyncapi-document.md +2 -1
- package/docs/configuration-file.md +112 -33
- package/docs/generator-template-java.md +560 -0
- package/docs/generator-template.md +62 -29
- package/docs/hooks.md +3 -3
- package/docs/installation-guide.md +5 -51
- package/docs/migration-cli.md +5 -5
- package/docs/migration-nunjucks-react.md +1 -1
- package/docs/nunjucks-render-engine.md +4 -2
- package/docs/template.md +2 -2
- package/docs/usage.md +14 -32
- package/docs/versioning.md +3 -1
- package/lib/conditionalGeneration.js +162 -0
- package/lib/filtersRegistry.js +1 -1
- package/lib/generator.js +93 -40
- package/lib/hooksRegistry.js +8 -1
- package/lib/logMessages.js +6 -1
- package/lib/parser.js +10 -0
- package/lib/templateConfigValidator.js +30 -1
- package/package.json +2 -3
- package/test/generator.test.js +1 -1
- package/test/hooksRegistry.test.js +173 -0
- package/test/integration.test.js +47 -0
- package/test/parser.test.js +100 -2
- package/test/templateConfigValidator.test.js +18 -1
- package/test/test-project/README.md +5 -1
- package/test/test-project/docker-compose.yml +7 -15
- package/test/test-project/test-project.test.js +6 -2
- package/test/test-project/test-registry.test.js +7 -2
- package/test/test-project/test.sh +1 -1
- package/test/test-templates/nunjucks-template/package-lock.json +43 -119
- package/test/test-templates/react-template/.ageneratorrc +33 -0
- package/test/test-templates/react-template/package.json +4 -20
- package/test/test-templates/react-template/template/conditionalFile.txt +0 -0
- package/test/test-templates/react-template/template/conditionalFolder/conditionalFile.txt +0 -0
- package/test/test-templates/react-template/template/conditionalFolder2/input.txt +0 -0
- package/test/utils.test.js +53 -0
- package/test/test-project/test-entrypoint.sh +0 -12
package/test/parser.test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const { sanitizeTemplateApiVersion, usesNewAPI, parse } = require('../lib/parser');
|
|
3
|
+
const { sanitizeTemplateApiVersion, usesNewAPI, parse, convertOldOptionsToNew } = require('../lib/parser');
|
|
4
4
|
const dummyV2Document = fs.readFileSync(path.resolve(__dirname, './docs/dummy.yml'), 'utf8');
|
|
5
5
|
const dummyV3Document = fs.readFileSync(path.resolve(__dirname, './docs/dummyV3.yml'), 'utf8');
|
|
6
6
|
|
|
@@ -99,9 +99,107 @@ describe('Parser', () => {
|
|
|
99
99
|
});
|
|
100
100
|
it('should be able to parse AsyncAPI v3 document for parser API v3', async () => {
|
|
101
101
|
const parsedDocument = await parse(dummyV3Document, {}, {templateConfig: {apiVersion: 'v3'}});
|
|
102
|
-
|
|
103
102
|
expect(parsedDocument).toBeDefined();
|
|
104
103
|
expect(parsedDocument.document.version()).toEqual('3.0.0');
|
|
105
104
|
});
|
|
106
105
|
});
|
|
106
|
+
|
|
107
|
+
describe('getProperApiDocument', () => {
|
|
108
|
+
const parser_api_version = 'x-parser-api-version';
|
|
109
|
+
const parser_spec_parsed = 'x-parser-spec-parsed';
|
|
110
|
+
const parser_original_schema = 'x-parser-original-schema-format';
|
|
111
|
+
const parser_original_payload = 'x-parser-original-payload';
|
|
112
|
+
const parser_message = 'x-parser-message-parsed';
|
|
113
|
+
it('should convert to old API if apiVersion is undefined', async () => {
|
|
114
|
+
// parse calls the get properAPIDocument and returns it along with a diagnostic in a Object
|
|
115
|
+
// so its like called the get properAPIDocument function and then returned the result
|
|
116
|
+
const templateConfig = {};
|
|
117
|
+
const properDocument = await parse(dummyV2Document, {}, { templateConfig });
|
|
118
|
+
|
|
119
|
+
// Validate that properDocument convert it to expected API version from the template
|
|
120
|
+
expect(properDocument).toBeDefined();
|
|
121
|
+
|
|
122
|
+
expect(properDocument).toBeDefined();
|
|
123
|
+
expect(properDocument.document._json).toBeDefined();
|
|
124
|
+
expect(properDocument.document._json.asyncapi).toEqual('2.3.0');
|
|
125
|
+
expect(properDocument.diagnostics).toBeDefined();
|
|
126
|
+
expect(properDocument.diagnostics.length).toBeGreaterThan(0);
|
|
127
|
+
|
|
128
|
+
expect(properDocument.document._json[parser_api_version]).toBeDefined();
|
|
129
|
+
expect(properDocument.document._json[parser_api_version]).toEqual(0);
|
|
130
|
+
expect(properDocument.document._json[parser_spec_parsed]).toBeDefined();
|
|
131
|
+
expect(properDocument.document._json[parser_spec_parsed]).toEqual(true);
|
|
132
|
+
|
|
133
|
+
expect(properDocument.document._meta).toBeDefined();
|
|
134
|
+
expect(properDocument.document._meta).toEqual({});
|
|
135
|
+
expect(properDocument.document._json.components.messages.dummyCreated).toBeDefined();
|
|
136
|
+
expect(properDocument.document._json.components.messages.dummyCreated[parser_original_schema]).toBeDefined(); // Only old API includes this filed
|
|
137
|
+
expect(properDocument.document._json.components.messages.dummyCreated[parser_original_payload]).toBeDefined();
|
|
138
|
+
expect(properDocument.document._json.components.messages.dummyCreated[parser_message]).toBeDefined();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should convert to specified API version', async () => {
|
|
142
|
+
const templateConfig = { apiVersion: 'v2' };
|
|
143
|
+
const properDocument = await parse(dummyV2Document, {}, { templateConfig });
|
|
144
|
+
|
|
145
|
+
// Validate that properDocument is defined
|
|
146
|
+
expect(properDocument).toBeDefined();
|
|
147
|
+
|
|
148
|
+
// Validate that the document is converted to the specified API version
|
|
149
|
+
expect(properDocument.document._json.asyncapi).toEqual('2.3.0');
|
|
150
|
+
expect(properDocument.diagnostics).toBeDefined();
|
|
151
|
+
expect(properDocument.diagnostics.length).toBeGreaterThan(0);
|
|
152
|
+
|
|
153
|
+
expect(properDocument.document._json[parser_api_version]).toBeDefined();
|
|
154
|
+
expect(properDocument.document._json[parser_spec_parsed]).toBeDefined();
|
|
155
|
+
expect(properDocument.document._json[parser_api_version]).toEqual(2);
|
|
156
|
+
expect(properDocument.document._json[parser_spec_parsed]).toEqual(true);
|
|
157
|
+
|
|
158
|
+
expect(properDocument.document._meta).toBeDefined();
|
|
159
|
+
expect(properDocument.document._json.components.messages.dummyCreated).toBeDefined();
|
|
160
|
+
expect(properDocument.document._json.components.messages.dummyCreated[parser_original_schema]).toBeUndefined();
|
|
161
|
+
expect(properDocument.document._json.components.messages.dummyCreated[parser_original_payload]).toBeUndefined();
|
|
162
|
+
expect(properDocument.document._json.components.messages.dummyCreated[parser_message]).toBeUndefined();
|
|
163
|
+
|
|
164
|
+
// Validate that old API-specific functions and properties are not present
|
|
165
|
+
expect(properDocument.oldApiSpecificFunction).toBeUndefined();
|
|
166
|
+
expect(properDocument.oldApiSpecificProperty).toBeUndefined();
|
|
167
|
+
expect(properDocument.anotherOldApiFunction).toBeUndefined();
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
describe('convertOldOptionsToNew', () => {
|
|
172
|
+
it('should convert old options to new options', () => {
|
|
173
|
+
const oldOptions = {
|
|
174
|
+
path: './test/docs/',
|
|
175
|
+
applyTraits: true,
|
|
176
|
+
resolve: {
|
|
177
|
+
http: {
|
|
178
|
+
order: 1,
|
|
179
|
+
canRead: true,
|
|
180
|
+
read: jest.fn()
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
const generator = {
|
|
185
|
+
mapBaseUrlToFolder: {
|
|
186
|
+
url: 'https://schema.example.com/crm/',
|
|
187
|
+
folder: './test/docs/'
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const newOptions = convertOldOptionsToNew(oldOptions, generator);
|
|
191
|
+
|
|
192
|
+
expect(newOptions).toBeDefined();
|
|
193
|
+
expect(newOptions.source).toEqual(oldOptions.path);
|
|
194
|
+
expect(newOptions.applyTraits).toEqual(oldOptions.applyTraits);
|
|
195
|
+
expect(newOptions.__unstable).toBeDefined();
|
|
196
|
+
expect(newOptions.__unstable.resolver.resolvers.length).toBeGreaterThan(0);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('should return undefined if oldOptions is not provided', () => {
|
|
200
|
+
const newOptions = convertOldOptionsToNew(undefined, {});
|
|
201
|
+
|
|
202
|
+
expect(newOptions).toBeUndefined();
|
|
203
|
+
});
|
|
204
|
+
});
|
|
107
205
|
});
|
|
@@ -160,6 +160,23 @@ describe('Template Configuration Validator', () => {
|
|
|
160
160
|
expect(templateConfig.conditionalFiles['my/path/to/file.js']).toBeDefined();
|
|
161
161
|
});
|
|
162
162
|
|
|
163
|
+
it('Validation enrich conditional files object with validate object if the subject is info', () => {
|
|
164
|
+
const templateParams = {};
|
|
165
|
+
const templateConfig = {
|
|
166
|
+
conditionalFiles: {
|
|
167
|
+
'my/path/to/file.js': {
|
|
168
|
+
subject: 'info.title',
|
|
169
|
+
validation: {
|
|
170
|
+
const: 'asyncapi'
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
validateTemplateConfig(templateConfig, templateParams);
|
|
176
|
+
|
|
177
|
+
expect(templateConfig.conditionalFiles['my/path/to/file.js']).toBeDefined();
|
|
178
|
+
});
|
|
179
|
+
|
|
163
180
|
it('Validation throw error if specified server is not in asyncapi document', () => {
|
|
164
181
|
const templateParams = {
|
|
165
182
|
server: 'myserver'
|
|
@@ -274,4 +291,4 @@ describe('Template Configuration Validator', () => {
|
|
|
274
291
|
expect(() => validateTemplateConfig(templateConfig, templateParams, asyncapiDocument)).toThrow('Server "dummy-mqtt" uses the mqtt protocol but this template only supports the following ones: myprotocol.');
|
|
275
292
|
});
|
|
276
293
|
});
|
|
277
|
-
});
|
|
294
|
+
});
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
It is a test project where AsyncAPI Generator and test template are used as Node.js dependencies.
|
|
2
2
|
The purpose of this project is to test AsyncAPI Generator library use case outside the Generator code base.
|
|
3
3
|
|
|
4
|
-
Instead of running tests with `npm test`, make sure you have Docker Compose and run
|
|
4
|
+
Instead of running tests with `npm test`, make sure you have Docker Compose and run the following command:
|
|
5
|
+
|
|
6
|
+
Linux/MacOS: `NODE_VERSION=18 docker-compose up --abort-on-container-exit --force-recreate`.
|
|
7
|
+
|
|
8
|
+
Windows: `set NODE_VERSION=18&& docker-compose up --abort-on-container-exit --force-recreate`.
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
version: '3'
|
|
2
|
-
|
|
3
1
|
services:
|
|
4
2
|
verdaccio:
|
|
5
3
|
image: verdaccio/verdaccio:5
|
|
@@ -7,18 +5,12 @@ services:
|
|
|
7
5
|
- '4873:4873'
|
|
8
6
|
volumes:
|
|
9
7
|
- './verdaccio:/verdaccio/conf'
|
|
10
|
-
networks:
|
|
11
|
-
- mynetwork
|
|
12
8
|
|
|
13
9
|
test-project:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
networks:
|
|
23
|
-
mynetwork:
|
|
24
|
-
driver: bridge
|
|
10
|
+
pull_policy: build
|
|
11
|
+
build:
|
|
12
|
+
context: ../../../../ # Root of the project
|
|
13
|
+
args:
|
|
14
|
+
NODE_VERSION: ${NODE_VERSION}
|
|
15
|
+
user: root # Use root user to avoid permission issues when creating directories
|
|
16
|
+
command: ["sh", "/app/apps/generator/test/test-project/test.sh", "test-project"]
|
|
@@ -15,11 +15,15 @@ const logMessage = require('../../lib/logMessages.js');
|
|
|
15
15
|
const newContentNotExpectedInTest = 'new content';
|
|
16
16
|
const version = '0.0.1';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
const originalConsoleLog = console.log;
|
|
19
19
|
|
|
20
|
+
// Replace console.log with a custom mock function
|
|
21
|
+
console.log = jest.fn((...args) => {
|
|
22
|
+
// Call the original function to actually log to the console
|
|
23
|
+
originalConsoleLog(...args);
|
|
24
|
+
});
|
|
20
25
|
describe('Testing if markdown was generated with proper version of the template', () => {
|
|
21
26
|
jest.setTimeout(1000000);
|
|
22
|
-
|
|
23
27
|
it('Test A - generated markdown should not contain new content in modified template', async () => {
|
|
24
28
|
//we setup generator using template name, not path, without explicitly running installation
|
|
25
29
|
//generator picks up template that is already in node_modules as it was installed before as node dependency
|
|
@@ -8,8 +8,14 @@ const Generator = require('@asyncapi/generator');
|
|
|
8
8
|
const dummySpecPath = path.resolve(__dirname, '../docs/dummy.yml');
|
|
9
9
|
const tempOutputResults = path.resolve(__dirname, 'output');
|
|
10
10
|
|
|
11
|
-
console.log
|
|
11
|
+
// Save the original console.log
|
|
12
|
+
const originalConsoleLog = console.log;
|
|
12
13
|
|
|
14
|
+
// Replace console.log with a custom mock function
|
|
15
|
+
console.log = jest.fn((...args) => {
|
|
16
|
+
// Call the original function to actually log to the console
|
|
17
|
+
originalConsoleLog(...args);
|
|
18
|
+
});
|
|
13
19
|
describe('Integration testing generateFromFile() to make sure the template can be download from the private repository from argument', () => {
|
|
14
20
|
jest.setTimeout(1000000);
|
|
15
21
|
|
|
@@ -38,7 +44,6 @@ describe('Integration testing generateFromFile() to make sure the template can b
|
|
|
38
44
|
|
|
39
45
|
describe('Integration testing generateFromFile() to make sure the template can be download from the private repository from npm config', () => {
|
|
40
46
|
jest.setTimeout(1000000);
|
|
41
|
-
|
|
42
47
|
it('generated using private registory from npm config', async () => {
|
|
43
48
|
const generator = new Generator('react-template', tempOutputResults,
|
|
44
49
|
{
|
|
@@ -127,11 +127,13 @@
|
|
|
127
127
|
}
|
|
128
128
|
},
|
|
129
129
|
"node_modules/@babel/code-frame": {
|
|
130
|
-
"version": "7.
|
|
131
|
-
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.
|
|
132
|
-
"integrity": "sha512-
|
|
130
|
+
"version": "7.26.2",
|
|
131
|
+
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz",
|
|
132
|
+
"integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==",
|
|
133
|
+
"license": "MIT",
|
|
133
134
|
"dependencies": {
|
|
134
|
-
"@babel/
|
|
135
|
+
"@babel/helper-validator-identifier": "^7.25.9",
|
|
136
|
+
"js-tokens": "^4.0.0",
|
|
135
137
|
"picocolors": "^1.0.0"
|
|
136
138
|
},
|
|
137
139
|
"engines": {
|
|
@@ -436,17 +438,19 @@
|
|
|
436
438
|
}
|
|
437
439
|
},
|
|
438
440
|
"node_modules/@babel/helper-string-parser": {
|
|
439
|
-
"version": "7.
|
|
440
|
-
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.
|
|
441
|
-
"integrity": "sha512-
|
|
441
|
+
"version": "7.25.9",
|
|
442
|
+
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz",
|
|
443
|
+
"integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==",
|
|
444
|
+
"license": "MIT",
|
|
442
445
|
"engines": {
|
|
443
446
|
"node": ">=6.9.0"
|
|
444
447
|
}
|
|
445
448
|
},
|
|
446
449
|
"node_modules/@babel/helper-validator-identifier": {
|
|
447
|
-
"version": "7.
|
|
448
|
-
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.
|
|
449
|
-
"integrity": "sha512-
|
|
450
|
+
"version": "7.25.9",
|
|
451
|
+
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz",
|
|
452
|
+
"integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==",
|
|
453
|
+
"license": "MIT",
|
|
450
454
|
"engines": {
|
|
451
455
|
"node": ">=6.9.0"
|
|
452
456
|
}
|
|
@@ -473,36 +477,26 @@
|
|
|
473
477
|
}
|
|
474
478
|
},
|
|
475
479
|
"node_modules/@babel/helpers": {
|
|
476
|
-
"version": "7.
|
|
477
|
-
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.
|
|
478
|
-
"integrity": "sha512-
|
|
480
|
+
"version": "7.26.10",
|
|
481
|
+
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.10.tgz",
|
|
482
|
+
"integrity": "sha512-UPYc3SauzZ3JGgj87GgZ89JVdC5dj0AoetR5Bw6wj4niittNyFh6+eOGonYvJ1ao6B8lEa3Q3klS7ADZ53bc5g==",
|
|
483
|
+
"license": "MIT",
|
|
479
484
|
"dependencies": {
|
|
480
|
-
"@babel/template": "^7.
|
|
481
|
-
"@babel/
|
|
482
|
-
"@babel/types": "^7.24.0"
|
|
485
|
+
"@babel/template": "^7.26.9",
|
|
486
|
+
"@babel/types": "^7.26.10"
|
|
483
487
|
},
|
|
484
488
|
"engines": {
|
|
485
489
|
"node": ">=6.9.0"
|
|
486
490
|
}
|
|
487
491
|
},
|
|
488
|
-
"node_modules/@babel/
|
|
489
|
-
"version": "7.
|
|
490
|
-
"resolved": "https://registry.npmjs.org/@babel/
|
|
491
|
-
"integrity": "sha512-
|
|
492
|
+
"node_modules/@babel/parser": {
|
|
493
|
+
"version": "7.26.10",
|
|
494
|
+
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.10.tgz",
|
|
495
|
+
"integrity": "sha512-6aQR2zGE/QFi8JpDLjUZEPYOs7+mhKXm86VaKFiLP35JQwQb6bwUE+XbvkH0EptsYhbNBSUGaUBLKqxH1xSgsA==",
|
|
496
|
+
"license": "MIT",
|
|
492
497
|
"dependencies": {
|
|
493
|
-
"@babel/
|
|
494
|
-
"chalk": "^2.4.2",
|
|
495
|
-
"js-tokens": "^4.0.0",
|
|
496
|
-
"picocolors": "^1.0.0"
|
|
498
|
+
"@babel/types": "^7.26.10"
|
|
497
499
|
},
|
|
498
|
-
"engines": {
|
|
499
|
-
"node": ">=6.9.0"
|
|
500
|
-
}
|
|
501
|
-
},
|
|
502
|
-
"node_modules/@babel/parser": {
|
|
503
|
-
"version": "7.24.4",
|
|
504
|
-
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.4.tgz",
|
|
505
|
-
"integrity": "sha512-zTvEBcghmeBma9QIGunWevvBAp4/Qu9Bdq+2k0Ot4fVMD6v3dsC9WOcRSKk7tRRyBM/53yKMJko9xOatGQAwSg==",
|
|
506
500
|
"bin": {
|
|
507
501
|
"parser": "bin/babel-parser.js"
|
|
508
502
|
},
|
|
@@ -1728,9 +1722,10 @@
|
|
|
1728
1722
|
"integrity": "sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA=="
|
|
1729
1723
|
},
|
|
1730
1724
|
"node_modules/@babel/runtime": {
|
|
1731
|
-
"version": "7.
|
|
1732
|
-
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.
|
|
1733
|
-
"integrity": "sha512-
|
|
1725
|
+
"version": "7.26.10",
|
|
1726
|
+
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.10.tgz",
|
|
1727
|
+
"integrity": "sha512-2WJMeRQPHKSPemqk/awGrAiuFfzBmOIPXKizAsVhWH9YJqLZ0H+HS4c8loHGgW6utJ3E/ejXQUsiGaQy2NZ9Fw==",
|
|
1728
|
+
"license": "MIT",
|
|
1734
1729
|
"dependencies": {
|
|
1735
1730
|
"regenerator-runtime": "^0.14.0"
|
|
1736
1731
|
},
|
|
@@ -1739,13 +1734,14 @@
|
|
|
1739
1734
|
}
|
|
1740
1735
|
},
|
|
1741
1736
|
"node_modules/@babel/template": {
|
|
1742
|
-
"version": "7.
|
|
1743
|
-
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.
|
|
1744
|
-
"integrity": "sha512-
|
|
1737
|
+
"version": "7.26.9",
|
|
1738
|
+
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.26.9.tgz",
|
|
1739
|
+
"integrity": "sha512-qyRplbeIpNZhmzOysF/wFMuP9sctmh2cFzRAZOn1YapxBsE1i9bJIY586R/WBLfLcmcBlM8ROBiQURnnNy+zfA==",
|
|
1740
|
+
"license": "MIT",
|
|
1745
1741
|
"dependencies": {
|
|
1746
|
-
"@babel/code-frame": "^7.
|
|
1747
|
-
"@babel/parser": "^7.
|
|
1748
|
-
"@babel/types": "^7.
|
|
1742
|
+
"@babel/code-frame": "^7.26.2",
|
|
1743
|
+
"@babel/parser": "^7.26.9",
|
|
1744
|
+
"@babel/types": "^7.26.9"
|
|
1749
1745
|
},
|
|
1750
1746
|
"engines": {
|
|
1751
1747
|
"node": ">=6.9.0"
|
|
@@ -1772,13 +1768,13 @@
|
|
|
1772
1768
|
}
|
|
1773
1769
|
},
|
|
1774
1770
|
"node_modules/@babel/types": {
|
|
1775
|
-
"version": "7.
|
|
1776
|
-
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.
|
|
1777
|
-
"integrity": "sha512
|
|
1771
|
+
"version": "7.26.10",
|
|
1772
|
+
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.10.tgz",
|
|
1773
|
+
"integrity": "sha512-emqcG3vHrpxUKTrxcblR36dcrcoRDvKmnL/dCL6ZsHaShW80qxCAcNhzQZrpeM765VzEos+xOi4s+r4IXzTwdQ==",
|
|
1774
|
+
"license": "MIT",
|
|
1778
1775
|
"dependencies": {
|
|
1779
|
-
"@babel/helper-string-parser": "^7.
|
|
1780
|
-
"@babel/helper-validator-identifier": "^7.
|
|
1781
|
-
"to-fast-properties": "^2.0.0"
|
|
1776
|
+
"@babel/helper-string-parser": "^7.25.9",
|
|
1777
|
+
"@babel/helper-validator-identifier": "^7.25.9"
|
|
1782
1778
|
},
|
|
1783
1779
|
"engines": {
|
|
1784
1780
|
"node": ">=6.9.0"
|
|
@@ -2310,17 +2306,6 @@
|
|
|
2310
2306
|
}
|
|
2311
2307
|
}
|
|
2312
2308
|
},
|
|
2313
|
-
"node_modules/ansi-styles": {
|
|
2314
|
-
"version": "3.2.1",
|
|
2315
|
-
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
|
|
2316
|
-
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
|
|
2317
|
-
"dependencies": {
|
|
2318
|
-
"color-convert": "^1.9.0"
|
|
2319
|
-
},
|
|
2320
|
-
"engines": {
|
|
2321
|
-
"node": ">=4"
|
|
2322
|
-
}
|
|
2323
|
-
},
|
|
2324
2309
|
"node_modules/argparse": {
|
|
2325
2310
|
"version": "2.0.1",
|
|
2326
2311
|
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
|
@@ -2523,32 +2508,6 @@
|
|
|
2523
2508
|
}
|
|
2524
2509
|
]
|
|
2525
2510
|
},
|
|
2526
|
-
"node_modules/chalk": {
|
|
2527
|
-
"version": "2.4.2",
|
|
2528
|
-
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
|
|
2529
|
-
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
|
|
2530
|
-
"dependencies": {
|
|
2531
|
-
"ansi-styles": "^3.2.1",
|
|
2532
|
-
"escape-string-regexp": "^1.0.5",
|
|
2533
|
-
"supports-color": "^5.3.0"
|
|
2534
|
-
},
|
|
2535
|
-
"engines": {
|
|
2536
|
-
"node": ">=4"
|
|
2537
|
-
}
|
|
2538
|
-
},
|
|
2539
|
-
"node_modules/color-convert": {
|
|
2540
|
-
"version": "1.9.3",
|
|
2541
|
-
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
|
|
2542
|
-
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
|
|
2543
|
-
"dependencies": {
|
|
2544
|
-
"color-name": "1.1.3"
|
|
2545
|
-
}
|
|
2546
|
-
},
|
|
2547
|
-
"node_modules/color-name": {
|
|
2548
|
-
"version": "1.1.3",
|
|
2549
|
-
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
|
|
2550
|
-
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="
|
|
2551
|
-
},
|
|
2552
2511
|
"node_modules/concat-map": {
|
|
2553
2512
|
"version": "0.0.1",
|
|
2554
2513
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
|
@@ -2828,14 +2787,6 @@
|
|
|
2828
2787
|
"node": ">=6"
|
|
2829
2788
|
}
|
|
2830
2789
|
},
|
|
2831
|
-
"node_modules/escape-string-regexp": {
|
|
2832
|
-
"version": "1.0.5",
|
|
2833
|
-
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
|
2834
|
-
"integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
|
|
2835
|
-
"engines": {
|
|
2836
|
-
"node": ">=0.8.0"
|
|
2837
|
-
}
|
|
2838
|
-
},
|
|
2839
2790
|
"node_modules/estree-walker": {
|
|
2840
2791
|
"version": "1.0.1",
|
|
2841
2792
|
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz",
|
|
@@ -3010,14 +2961,6 @@
|
|
|
3010
2961
|
"url": "https://github.com/sponsors/ljharb"
|
|
3011
2962
|
}
|
|
3012
2963
|
},
|
|
3013
|
-
"node_modules/has-flag": {
|
|
3014
|
-
"version": "3.0.0",
|
|
3015
|
-
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
|
3016
|
-
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
|
|
3017
|
-
"engines": {
|
|
3018
|
-
"node": ">=4"
|
|
3019
|
-
}
|
|
3020
|
-
},
|
|
3021
2964
|
"node_modules/has-property-descriptors": {
|
|
3022
2965
|
"version": "1.0.2",
|
|
3023
2966
|
"resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
|
|
@@ -3876,17 +3819,6 @@
|
|
|
3876
3819
|
"url": "https://github.com/sponsors/ljharb"
|
|
3877
3820
|
}
|
|
3878
3821
|
},
|
|
3879
|
-
"node_modules/supports-color": {
|
|
3880
|
-
"version": "5.5.0",
|
|
3881
|
-
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
|
3882
|
-
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
|
|
3883
|
-
"dependencies": {
|
|
3884
|
-
"has-flag": "^3.0.0"
|
|
3885
|
-
},
|
|
3886
|
-
"engines": {
|
|
3887
|
-
"node": ">=4"
|
|
3888
|
-
}
|
|
3889
|
-
},
|
|
3890
3822
|
"node_modules/supports-preserve-symlinks-flag": {
|
|
3891
3823
|
"version": "1.0.0",
|
|
3892
3824
|
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
|
|
@@ -3898,14 +3830,6 @@
|
|
|
3898
3830
|
"url": "https://github.com/sponsors/ljharb"
|
|
3899
3831
|
}
|
|
3900
3832
|
},
|
|
3901
|
-
"node_modules/to-fast-properties": {
|
|
3902
|
-
"version": "2.0.0",
|
|
3903
|
-
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
|
|
3904
|
-
"integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==",
|
|
3905
|
-
"engines": {
|
|
3906
|
-
"node": ">=4"
|
|
3907
|
-
}
|
|
3908
|
-
},
|
|
3909
3833
|
"node_modules/tr46": {
|
|
3910
3834
|
"version": "0.0.3",
|
|
3911
3835
|
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
renderer: react
|
|
2
|
+
apiVersion: v3
|
|
3
|
+
hooks:
|
|
4
|
+
"@asyncapi/generator-hooks": createAsyncapiFile
|
|
5
|
+
parameters:
|
|
6
|
+
version:
|
|
7
|
+
description: "Custom version to be used"
|
|
8
|
+
mode:
|
|
9
|
+
description: "development or production"
|
|
10
|
+
asyncapiFileDir:
|
|
11
|
+
description: >
|
|
12
|
+
This template by default also outputs the AsyncAPI document that was passed as input.
|
|
13
|
+
You can specify with this parameter what should be the location of this AsyncAPI document,
|
|
14
|
+
relative to specified template output.
|
|
15
|
+
singleFile:
|
|
16
|
+
description: "Allow to generate conditionalGeneration file only if singleFile is set to false"
|
|
17
|
+
singleFolder:
|
|
18
|
+
description: "Allow to generate conditionalGeneration folder only if singleFolder is set to false"
|
|
19
|
+
conditionalGeneration:
|
|
20
|
+
conditionalFolder:
|
|
21
|
+
parameter: singleFolder
|
|
22
|
+
validation:
|
|
23
|
+
not:
|
|
24
|
+
const: "true"
|
|
25
|
+
conditionalFile.txt:
|
|
26
|
+
parameter: singleFile
|
|
27
|
+
validation:
|
|
28
|
+
not:
|
|
29
|
+
const: "true"
|
|
30
|
+
conditionalFolder2/input.txt:
|
|
31
|
+
parameter: singleFile
|
|
32
|
+
validation:
|
|
33
|
+
enum: ["false"]
|
|
@@ -3,28 +3,12 @@
|
|
|
3
3
|
"version": "0.0.1",
|
|
4
4
|
"description": "Simple react-based template that showcases different generator features that we can test in integration tests",
|
|
5
5
|
"scripts": {
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
"generator": {
|
|
9
|
-
"renderer": "react",
|
|
10
|
-
"apiVersion": "v3",
|
|
11
|
-
"hooks": {
|
|
12
|
-
"@asyncapi/generator-hooks": "createAsyncapiFile"
|
|
13
|
-
},
|
|
14
|
-
"parameters": {
|
|
15
|
-
"version": {
|
|
16
|
-
"description": "Custom version to be used"
|
|
17
|
-
},
|
|
18
|
-
"mode": {
|
|
19
|
-
"description": "development or production"
|
|
20
|
-
},
|
|
21
|
-
"asyncapiFileDir": {
|
|
22
|
-
"description": "This template by default also outputs the AsyncAPI document that was passed as input. You can specify with this parameter what should be the location of this AsyncAPI document, relative to specified template output."
|
|
23
|
-
}
|
|
24
|
-
}
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
25
7
|
},
|
|
26
8
|
"dependencies": {
|
|
27
9
|
"@asyncapi/generator-react-sdk": "^1.1.2",
|
|
28
|
-
"@asyncapi/generator-components": "
|
|
10
|
+
"@asyncapi/generator-components": "1.0.0"
|
|
29
11
|
}
|
|
30
12
|
}
|
|
13
|
+
|
|
14
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/utils.test.js
CHANGED
|
@@ -73,4 +73,57 @@ describe('Utils', () => {
|
|
|
73
73
|
expect(exists).toBeFalsy();
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
|
+
|
|
77
|
+
describe('#isJsFile',() => {
|
|
78
|
+
it('should return true if file extension is .js', () => {
|
|
79
|
+
const isJsFile = utils.isJsFile('./valid-file.js');
|
|
80
|
+
expect(isJsFile).toBeTruthy();
|
|
81
|
+
});
|
|
82
|
+
it('should return true if file extension is .jsx', () => {
|
|
83
|
+
const isJsFile = utils.isJsFile('./valid-file.jsx');
|
|
84
|
+
expect(isJsFile).toBeTruthy();
|
|
85
|
+
});
|
|
86
|
+
it('should return true if file extension is .cjs', () => {
|
|
87
|
+
const isJsFile = utils.isJsFile('./valid-file.cjs');
|
|
88
|
+
expect(isJsFile).toBeTruthy();
|
|
89
|
+
});
|
|
90
|
+
it('should return false if it is not a JS file', () => {
|
|
91
|
+
const isJsFile = utils.isJsFile('./invalid-file.txt');
|
|
92
|
+
expect(isJsFile).toBeFalsy();
|
|
93
|
+
});
|
|
94
|
+
it('should return false if it is not a JS file', () => {
|
|
95
|
+
const isJsFile = utils.isJsFile('./invalid-file');
|
|
96
|
+
expect(isJsFile).toBeFalsy();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe('#isReactTemplate', () => {
|
|
101
|
+
it('should return true if it is a react template', () => {
|
|
102
|
+
const templateConfig = {
|
|
103
|
+
renderer: 'react'
|
|
104
|
+
};
|
|
105
|
+
const isReactTemplate = utils.isReactTemplate(templateConfig);
|
|
106
|
+
expect(isReactTemplate).toBeTruthy();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should return false if it is not a react template', () => {
|
|
110
|
+
const templateConfig = {
|
|
111
|
+
renderer: 'nunjucks'
|
|
112
|
+
};
|
|
113
|
+
const isReactTemplate = utils.isReactTemplate(templateConfig);
|
|
114
|
+
expect(isReactTemplate).toBeFalsy();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should return false if template config is not specified', () => {
|
|
118
|
+
const templateConfig = {};
|
|
119
|
+
const isReactTemplate = utils.isReactTemplate(templateConfig);
|
|
120
|
+
expect(isReactTemplate).toBeFalsy();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should return false if template config is undefined', () => {
|
|
124
|
+
const templateConfig = undefined;
|
|
125
|
+
const isReactTemplate = utils.isReactTemplate(templateConfig);
|
|
126
|
+
expect(isReactTemplate).toBeFalsy();
|
|
127
|
+
});
|
|
128
|
+
});
|
|
76
129
|
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Goal of this script is to copy mounted drive into a separate folder
|
|
4
|
-
# It is to assure the test run is isolated from the host
|
|
5
|
-
# apptemp is mounted from host and we do not want to mess in there
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# Copy the contents of /apptemp to /app
|
|
9
|
-
cp -r /apptemp /app
|
|
10
|
-
|
|
11
|
-
# Execute the bash script
|
|
12
|
-
bash /app/apps/generator/test/test-project/test.sh test-project
|