definition-generator-framework 1.12.4 → 1.12.6
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/dist/framework/definition-component.d.ts +11 -9
- package/dist/framework/definition-component.js +18 -18
- package/dist/framework/definition-generator.d.ts +6 -5
- package/dist/framework/definition-generator.js +16 -18
- package/dist/framework/file-content-generator/file-content-generator.js +1 -1
- package/dist/framework/file-content-generator/file-content-generator.test.js +49 -49
- package/dist/framework/framework.d.ts +14 -13
- package/dist/framework/framework.data.d.ts +3 -3
- package/dist/framework/framework.data.js +13 -7
- package/dist/framework/framework.js +36 -33
- package/dist/framework/framework.model.d.ts +15 -15
- package/dist/framework/framework.model.js +3 -3
- package/dist/helpers/common-functions/common-functions.js +1 -1
- package/dist/helpers/common-functions/common-functions.spec.d.ts +1 -0
- package/dist/helpers/common-functions/common-functions.spec.js +50 -0
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.d.ts +1 -0
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +54 -0
- package/dist/helpers/output-helper/output-helper.d.ts +26 -26
- package/dist/helpers/output-helper/output-helper.js +127 -107
- package/dist/helpers/output-helper/output-helper.spec.d.ts +24 -0
- package/dist/helpers/output-helper/output-helper.spec.js +261 -0
- package/dist/helpers/output-helper/output-helper.test.d.ts +22 -22
- package/dist/helpers/output-helper/output-helper.test.js +224 -212
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.d.ts +1 -0
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +143 -0
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +1 -0
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +191 -0
- package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +6 -6
- package/dist/helpers/validator/custom-validators/image.custom-validator.js +40 -39
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +4 -4
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +29 -29
- package/dist/helpers/validator/joi-custom-validators.spec.d.ts +1 -0
- package/dist/helpers/validator/joi-custom-validators.spec.js +304 -0
- package/dist/helpers/validator/validator.spec.d.ts +1 -0
- package/dist/helpers/validator/validator.spec.js +332 -0
- package/dist/pipeline/1-select-definitions-helper.d.ts +13 -13
- package/dist/pipeline/1-select-definitions-helper.js +68 -72
- package/dist/pipeline/1-select-definitions.helper.test.js +40 -40
- package/dist/pipeline/1-select-definitions.spec.d.ts +1 -0
- package/dist/pipeline/1-select-definitions.spec.js +140 -0
- package/dist/pipeline/2-structure-parser.helper.spec.d.ts +1 -0
- package/dist/pipeline/2-structure-parser.helper.spec.js +280 -0
- package/dist/pipeline/parsers/array-parser.spec.d.ts +1 -0
- package/dist/pipeline/parsers/array-parser.spec.js +128 -0
- package/dist/pipeline/parsers/object-parser.spec.d.ts +1 -0
- package/dist/pipeline/parsers/object-parser.spec.js +179 -0
- package/dist/pipeline/parsers/primitive-parser.spec.d.ts +1 -0
- package/dist/pipeline/parsers/primitive-parser.spec.js +79 -0
- package/dist/pre-made-components/assets/3-font.js +4 -4
- package/dist/pre-made-components/events/1-event.d.ts +1 -1
- package/dist/pre-made-components/events/1-event.js +157 -125
- package/dist/pre-made-components/events/2-event-test.d.ts +8 -8
- package/dist/pre-made-components/events/2-event-test.js +156 -119
- package/dist/pre-made-components/events/2-script-test.js +0 -1
- package/dist/pre-made-components/events/event-setup.d.ts +10 -5
- package/dist/pre-made-components/events/event-setup.js +15 -15
- package/dist/pre-made-components/events/script-setup.d.ts +5 -3
- package/dist/pre-made-components/events/script-setup.js +11 -11
- package/package.json +11 -11
- package/.eslintrc.js +0 -212
- package/.vscode/launch.json +0 -15
- package/.vscode/settings.json +0 -25
- package/coverage/clover.xml +0 -503
- package/coverage/coverage-final.json +0 -16
- package/coverage/lcov-report/_mocks/index.html +0 -116
- package/coverage/lcov-report/_mocks/mocks.ts.html +0 -223
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/framework/framework.data.ts.html +0 -109
- package/coverage/lcov-report/framework/index.html +0 -116
- package/coverage/lcov-report/helpers/common-functions/common-functions.ts.html +0 -178
- package/coverage/lcov-report/helpers/common-functions/index.html +0 -116
- package/coverage/lcov-report/helpers/duplicate-helper/duplicate-helper.ts.html +0 -196
- package/coverage/lcov-report/helpers/duplicate-helper/index.html +0 -116
- package/coverage/lcov-report/helpers/output-helper/index.html +0 -116
- package/coverage/lcov-report/helpers/output-helper/output-helper.ts.html +0 -277
- package/coverage/lcov-report/helpers/raw-definition-helper/index.html +0 -116
- package/coverage/lcov-report/helpers/raw-definition-helper/raw-definition.helper.ts.html +0 -256
- package/coverage/lcov-report/helpers/validator/index.html +0 -131
- package/coverage/lcov-report/helpers/validator/joi-custom-validators.ts.html +0 -643
- package/coverage/lcov-report/helpers/validator/validator.ts.html +0 -310
- package/coverage/lcov-report/index.html +0 -251
- package/coverage/lcov-report/pipeline/1-select-definitions-helper.ts.html +0 -358
- package/coverage/lcov-report/pipeline/2-structure-parser.helper.ts.html +0 -301
- package/coverage/lcov-report/pipeline/3-config.ts.html +0 -178
- package/coverage/lcov-report/pipeline/_mocks/index.html +0 -116
- package/coverage/lcov-report/pipeline/_mocks/index.ts.html +0 -229
- package/coverage/lcov-report/pipeline/index.html +0 -146
- package/coverage/lcov-report/pipeline/parsers/array-parser.ts.html +0 -271
- package/coverage/lcov-report/pipeline/parsers/index.html +0 -146
- package/coverage/lcov-report/pipeline/parsers/object-parser.ts.html +0 -439
- package/coverage/lcov-report/pipeline/parsers/primitive-parser.ts.html +0 -370
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -911
- package/dist/_mocks/mocks.js.map +0 -1
- package/dist/decorators/definition-component.js.map +0 -1
- package/dist/decorators/definition-generator.js.map +0 -1
- package/dist/framework/context.js.map +0 -1
- package/dist/framework/definition-component.js.map +0 -1
- package/dist/framework/definition-generator.js.map +0 -1
- package/dist/framework/definition-store.js.map +0 -1
- package/dist/framework/file-content-generator/file-content-generator.js.map +0 -1
- package/dist/framework/file-content-generator/file-content-generator.test.js.map +0 -1
- package/dist/framework/framework.data.js.map +0 -1
- package/dist/framework/framework.js.map +0 -1
- package/dist/framework/framework.model.js.map +0 -1
- package/dist/framework/index-file-generator/index-file-generator.js.map +0 -1
- package/dist/framework/interfaces.js.map +0 -1
- package/dist/framework/kernel.js.map +0 -1
- package/dist/helpers/common-functions/common-functions.js.map +0 -1
- package/dist/helpers/common-functions/common-functions.spec.js.map +0 -1
- package/dist/helpers/common-functions/common-functions.test.js.map +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.js.map +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.js.map +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.test.js.map +0 -1
- package/dist/helpers/output-helper/output-helper.js.map +0 -1
- package/dist/helpers/output-helper/output-helper.spec.js.map +0 -1
- package/dist/helpers/output-helper/output-helper.test.js.map +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.js.map +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js.map +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.test.js.map +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.js.map +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js.map +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.js.map +0 -1
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.js.map +0 -1
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.js.map +0 -1
- package/dist/helpers/validator/custom-validators/image.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/path.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/position-on-sprite.js.map +0 -1
- package/dist/helpers/validator/custom-validators/reference.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/sprite.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js.map +0 -1
- package/dist/helpers/validator/custom-validators/unique.custom-validator.js.map +0 -1
- package/dist/helpers/validator/joi-custom-validators.js.map +0 -1
- package/dist/helpers/validator/joi-custom-validators.spec.js.map +0 -1
- package/dist/helpers/validator/validator.js.map +0 -1
- package/dist/helpers/validator/validator.spec.js.map +0 -1
- package/dist/helpers/validator/validator.test.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/pipeline/1-select-definitions-helper.js.map +0 -1
- package/dist/pipeline/1-select-definitions.helper.js.map +0 -1
- package/dist/pipeline/1-select-definitions.helper.test.js.map +0 -1
- package/dist/pipeline/1-select-definitions.spec.js.map +0 -1
- package/dist/pipeline/2-structure-parser.helper.js.map +0 -1
- package/dist/pipeline/2-structure-parser.helper.spec.js.map +0 -1
- package/dist/pipeline/2-structure-parser.helper.test.js.map +0 -1
- package/dist/pipeline/3-config.js.map +0 -1
- package/dist/pipeline/_mocks/index.js.map +0 -1
- package/dist/pipeline/parsers/array-parser.js.map +0 -1
- package/dist/pipeline/parsers/array-parser.spec.js.map +0 -1
- package/dist/pipeline/parsers/array-parser.test.js.map +0 -1
- package/dist/pipeline/parsers/object-parser.js.map +0 -1
- package/dist/pipeline/parsers/object-parser.spec.js.map +0 -1
- package/dist/pipeline/parsers/object-parser.test.js.map +0 -1
- package/dist/pipeline/parsers/primitive-parser.js.map +0 -1
- package/dist/pipeline/parsers/primitive-parser.spec.js.map +0 -1
- package/dist/pipeline/parsers/primitive-parser.test.js.map +0 -1
- package/dist/pipeline/raw-data-parser.js.map +0 -1
- package/dist/pre-made-components/_validators/shape-validators.js.map +0 -1
- package/dist/pre-made-components/_validators/sprite-validators.js.map +0 -1
- package/dist/pre-made-components/assets/1-sprite.js.map +0 -1
- package/dist/pre-made-components/assets/2-sprite-group.js.map +0 -1
- package/dist/pre-made-components/assets/3-font.js.map +0 -1
- package/dist/pre-made-components/events/1-event.js.map +0 -1
- package/dist/pre-made-components/events/1-script.js.map +0 -1
- package/dist/pre-made-components/events/2-event-test.js.map +0 -1
- package/dist/pre-made-components/events/2-script-test.js.map +0 -1
- package/dist/pre-made-components/events/3-event.js.map +0 -1
- package/dist/pre-made-components/events/4-event-test.js.map +0 -1
- package/dist/pre-made-components/events/event-setup.js.map +0 -1
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.js.map +0 -1
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.js.map +0 -1
- package/dist/pre-made-components/events/helpers/script-testing.helper.js.map +0 -1
- package/dist/pre-made-components/events/script-setup.js.map +0 -1
- package/dist/pre-made-components/events/scripting-setup.js.map +0 -1
- package/dist/pre-made-components/events/validators.js.map +0 -1
- package/dist/setup.js.map +0 -1
- package/package.json.bak +0 -60
- package/scripts/prepare-package-json.ts +0 -23
- package/tsconfig.json +0 -24
- package/vitest.config.ts +0 -1
|
@@ -1,80 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
exports.SelectDefinitionsHelper = void 0;
|
|
4
|
-
const common_functions_1 = require(
|
|
5
|
-
const definition_store_1 = require(
|
|
4
|
+
const common_functions_1 = require('../helpers/common-functions/common-functions');
|
|
5
|
+
const definition_store_1 = require('../framework/definition-store');
|
|
6
6
|
class SelectDefinitionsHelper {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.currentItem.content.push(common_functions_1.CommonFunctions.removeComments(row));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else if (trimmedRow === '# DEFINITIONS') {
|
|
31
|
-
this.definitionsStarted = true;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
this.flushCurrentItem();
|
|
35
|
-
return {
|
|
36
|
-
definitionPlaneTexts: this.definitionPlaneTexts,
|
|
37
|
-
errorLogs: this.errorLogs
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
flushCurrentItem() {
|
|
41
|
-
if (this.currentItem) {
|
|
42
|
-
if (this.currentItem.content.length > 0) {
|
|
43
|
-
this.definitionPlaneTexts.push(this.currentItem);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
let errorLog = {
|
|
47
|
-
description: 'Definitions cannot be empty!',
|
|
48
|
-
location: this.currentItem.location
|
|
49
|
-
};
|
|
50
|
-
this.errorLogs.push(errorLog);
|
|
51
|
-
}
|
|
7
|
+
constructor() {
|
|
8
|
+
this.definitionsStarted = false;
|
|
9
|
+
this.definitionPlaneTexts = [];
|
|
10
|
+
this.errorLogs = [];
|
|
11
|
+
this.currentFilePath = '';
|
|
12
|
+
}
|
|
13
|
+
process(file) {
|
|
14
|
+
this.definitionsStarted = false;
|
|
15
|
+
this.currentItem = undefined;
|
|
16
|
+
this.definitionPlaneTexts = [];
|
|
17
|
+
this.errorLogs = [];
|
|
18
|
+
this.currentFilePath = file.path;
|
|
19
|
+
file.content.split('\n').forEach((row, index) => {
|
|
20
|
+
let trimmedRow = common_functions_1.CommonFunctions.removeWhiteSpace(row);
|
|
21
|
+
if (this.definitionsStarted) {
|
|
22
|
+
if (trimmedRow.startsWith('###')) {
|
|
23
|
+
this.flushCurrentItem();
|
|
24
|
+
this.onDeclarationEncountered(row, index, trimmedRow.substring(4));
|
|
25
|
+
} else if (this.currentItem && trimmedRow.length > 0) {
|
|
26
|
+
this.currentItem.content.push(common_functions_1.CommonFunctions.removeComments(row));
|
|
52
27
|
}
|
|
53
|
-
|
|
28
|
+
} else if (trimmedRow === '# DEFINITIONS') {
|
|
29
|
+
this.definitionsStarted = true;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
this.flushCurrentItem();
|
|
33
|
+
return {
|
|
34
|
+
definitionPlaneTexts: this.definitionPlaneTexts,
|
|
35
|
+
errorLogs: this.errorLogs
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
flushCurrentItem() {
|
|
39
|
+
if (this.currentItem) {
|
|
40
|
+
if (this.currentItem.content.length > 0) {
|
|
41
|
+
this.definitionPlaneTexts.push(this.currentItem);
|
|
42
|
+
} else {
|
|
43
|
+
let errorLog = {
|
|
44
|
+
description: 'Definitions cannot be empty!',
|
|
45
|
+
location: this.currentItem.location
|
|
46
|
+
};
|
|
47
|
+
this.errorLogs.push(errorLog);
|
|
48
|
+
}
|
|
54
49
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
74
|
-
this.errorLogs.push(errorLog);
|
|
75
|
-
this.currentItem = undefined;
|
|
50
|
+
this.currentItem = undefined;
|
|
51
|
+
}
|
|
52
|
+
onDeclarationEncountered(row, index, componentName) {
|
|
53
|
+
if (definition_store_1.DefinitionStore['isValidComponentName'](componentName)) {
|
|
54
|
+
this.currentItem = {
|
|
55
|
+
type: componentName,
|
|
56
|
+
location: {
|
|
57
|
+
line: index + 1,
|
|
58
|
+
path: this.currentFilePath
|
|
59
|
+
},
|
|
60
|
+
content: []
|
|
61
|
+
};
|
|
62
|
+
} else {
|
|
63
|
+
let errorLog = {
|
|
64
|
+
description: `Invalid definition header: "${row.trim()}"`,
|
|
65
|
+
location: {
|
|
66
|
+
line: index + 1,
|
|
67
|
+
path: this.currentFilePath
|
|
76
68
|
}
|
|
69
|
+
};
|
|
70
|
+
this.errorLogs.push(errorLog);
|
|
71
|
+
this.currentItem = undefined;
|
|
77
72
|
}
|
|
73
|
+
}
|
|
78
74
|
}
|
|
79
75
|
exports.SelectDefinitionsHelper = SelectDefinitionsHelper;
|
|
80
|
-
//# sourceMappingURL=1-select-definitions-helper.js.map
|
|
76
|
+
//# sourceMappingURL=1-select-definitions-helper.js.map
|
|
@@ -19,12 +19,12 @@ definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper
|
|
|
19
19
|
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
20
20
|
});
|
|
21
21
|
(0, vitest_1.test)('should handle files without definitions', () => {
|
|
22
|
-
let content = `
|
|
23
|
-
Explanation
|
|
24
|
-
|
|
25
|
-
### ASSET
|
|
26
|
-
Name: singular name
|
|
27
|
-
Path: path to file
|
|
22
|
+
let content = `
|
|
23
|
+
Explanation
|
|
24
|
+
|
|
25
|
+
### ASSET
|
|
26
|
+
Name: singular name
|
|
27
|
+
Path: path to file
|
|
28
28
|
`;
|
|
29
29
|
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
30
30
|
let result = selectDefinitionsHelper.process(fileInfo);
|
|
@@ -32,11 +32,11 @@ definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper
|
|
|
32
32
|
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
33
33
|
});
|
|
34
34
|
(0, vitest_1.test)('should select definitions', () => {
|
|
35
|
-
let content = `
|
|
36
|
-
# DEFINITIONS
|
|
37
|
-
### ASSET
|
|
38
|
-
Name: test
|
|
39
|
-
Path: test.png
|
|
35
|
+
let content = `
|
|
36
|
+
# DEFINITIONS
|
|
37
|
+
### ASSET
|
|
38
|
+
Name: test
|
|
39
|
+
Path: test.png
|
|
40
40
|
`;
|
|
41
41
|
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
42
42
|
let result = selectDefinitionsHelper.process(fileInfo);
|
|
@@ -50,12 +50,12 @@ definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper
|
|
|
50
50
|
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
51
51
|
});
|
|
52
52
|
(0, vitest_1.test)('should ignore comments', () => {
|
|
53
|
-
let content = `
|
|
54
|
-
# DEFINITIONS
|
|
55
|
-
### ASSET
|
|
56
|
-
Name: test // comment
|
|
57
|
-
Path: test.png // comment
|
|
58
|
-
// ----comment----\r
|
|
53
|
+
let content = `
|
|
54
|
+
# DEFINITIONS
|
|
55
|
+
### ASSET
|
|
56
|
+
Name: test // comment
|
|
57
|
+
Path: test.png // comment
|
|
58
|
+
// ----comment----\r
|
|
59
59
|
`;
|
|
60
60
|
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
61
61
|
let result = selectDefinitionsHelper.process(fileInfo);
|
|
@@ -69,9 +69,9 @@ definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper
|
|
|
69
69
|
(0, vitest_1.expect)(result.errorLogs).toStrictEqual([]);
|
|
70
70
|
});
|
|
71
71
|
(0, vitest_1.test)('should not allow empty definitions', () => {
|
|
72
|
-
let content = `
|
|
73
|
-
# DEFINITIONS
|
|
74
|
-
### ASSET
|
|
72
|
+
let content = `
|
|
73
|
+
# DEFINITIONS
|
|
74
|
+
### ASSET
|
|
75
75
|
`;
|
|
76
76
|
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
77
77
|
let result = selectDefinitionsHelper.process(fileInfo);
|
|
@@ -84,14 +84,14 @@ definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper
|
|
|
84
84
|
]);
|
|
85
85
|
});
|
|
86
86
|
(0, vitest_1.test)('should not allow unknown definition header after the first valid definition', () => {
|
|
87
|
-
let content = `
|
|
88
|
-
# DEFINITIONS
|
|
89
|
-
### ASSET
|
|
90
|
-
Name: test
|
|
91
|
-
Path: test.png
|
|
92
|
-
|
|
93
|
-
### Some text
|
|
94
|
-
some text
|
|
87
|
+
let content = `
|
|
88
|
+
# DEFINITIONS
|
|
89
|
+
### ASSET
|
|
90
|
+
Name: test
|
|
91
|
+
Path: test.png
|
|
92
|
+
|
|
93
|
+
### Some text
|
|
94
|
+
some text
|
|
95
95
|
`;
|
|
96
96
|
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
97
97
|
let result = selectDefinitionsHelper.process(fileInfo);
|
|
@@ -103,18 +103,18 @@ definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper
|
|
|
103
103
|
]);
|
|
104
104
|
});
|
|
105
105
|
(0, vitest_1.test)('invalid definitions should not corrupt other definitions', () => {
|
|
106
|
-
let content = `
|
|
107
|
-
# DEFINITIONS
|
|
108
|
-
### ASSET
|
|
109
|
-
Name: test
|
|
110
|
-
Path: test.png
|
|
111
|
-
|
|
112
|
-
### Some text
|
|
113
|
-
some text
|
|
114
|
-
|
|
115
|
-
### ASSET
|
|
116
|
-
Name: test2
|
|
117
|
-
Path: test2.png
|
|
106
|
+
let content = `
|
|
107
|
+
# DEFINITIONS
|
|
108
|
+
### ASSET
|
|
109
|
+
Name: test
|
|
110
|
+
Path: test.png
|
|
111
|
+
|
|
112
|
+
### Some text
|
|
113
|
+
some text
|
|
114
|
+
|
|
115
|
+
### ASSET
|
|
116
|
+
Name: test2
|
|
117
|
+
Path: test2.png
|
|
118
118
|
`;
|
|
119
119
|
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
120
120
|
let result = selectDefinitionsHelper.process(fileInfo);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
const _1_select_definitions_helper_1 = require('./1-select-definitions-helper');
|
|
4
|
+
const mocks_1 = require('../_mocks/mocks');
|
|
5
|
+
const custom_validator_helper_spec_1 = require('../helpers/validator/custom-validator-helper/custom-validator.helper.spec');
|
|
6
|
+
const definition_store_1 = require('../framework/definition-store');
|
|
7
|
+
definition_store_1.DefinitionStore['definitionsMap'].set(custom_validator_helper_spec_1.AssetComponentName, new Map());
|
|
8
|
+
describe('SELECT DEFINITIONS HELPER', () => {
|
|
9
|
+
let selectDefinitionsHelper;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
selectDefinitionsHelper = new _1_select_definitions_helper_1.SelectDefinitionsHelper();
|
|
12
|
+
});
|
|
13
|
+
test('should handle empty files', () => {
|
|
14
|
+
let content = ``;
|
|
15
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
16
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
17
|
+
expect(result.definitionPlaneTexts).toStrictEqual([]);
|
|
18
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
19
|
+
});
|
|
20
|
+
test('should handle files without definitions', () => {
|
|
21
|
+
let content = `
|
|
22
|
+
Explanation
|
|
23
|
+
|
|
24
|
+
### ASSET
|
|
25
|
+
Name: singular name
|
|
26
|
+
Path: path to file
|
|
27
|
+
`;
|
|
28
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
29
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
30
|
+
expect(result.definitionPlaneTexts).toStrictEqual([]);
|
|
31
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
32
|
+
});
|
|
33
|
+
test('should select definitions', () => {
|
|
34
|
+
let content = `
|
|
35
|
+
# DEFINITIONS
|
|
36
|
+
### ASSET
|
|
37
|
+
Name: test
|
|
38
|
+
Path: test.png
|
|
39
|
+
`;
|
|
40
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
41
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
42
|
+
expect(result.definitionPlaneTexts).toStrictEqual([
|
|
43
|
+
{
|
|
44
|
+
type: 'ASSET',
|
|
45
|
+
content: [' Name: test', ' Path: test.png'],
|
|
46
|
+
location: { line: 3, path: fileInfo.path }
|
|
47
|
+
}
|
|
48
|
+
]);
|
|
49
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
50
|
+
});
|
|
51
|
+
test('should ignore comments', () => {
|
|
52
|
+
let content = `
|
|
53
|
+
# DEFINITIONS
|
|
54
|
+
### ASSET
|
|
55
|
+
Name: test // comment
|
|
56
|
+
Path: test.png // comment
|
|
57
|
+
// ----comment----\r
|
|
58
|
+
`;
|
|
59
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
60
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
61
|
+
expect(result.definitionPlaneTexts).toStrictEqual([
|
|
62
|
+
{
|
|
63
|
+
type: 'ASSET',
|
|
64
|
+
content: [' Name: test', ' Path: test.png'],
|
|
65
|
+
location: { line: 3, path: fileInfo.path }
|
|
66
|
+
}
|
|
67
|
+
]);
|
|
68
|
+
expect(result.errorLogs).toStrictEqual([]);
|
|
69
|
+
});
|
|
70
|
+
test('should not allow empty definitions', () => {
|
|
71
|
+
let content = `
|
|
72
|
+
# DEFINITIONS
|
|
73
|
+
### ASSET
|
|
74
|
+
`;
|
|
75
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
76
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
77
|
+
expect(result.definitionPlaneTexts).toStrictEqual([]);
|
|
78
|
+
expect(result.errorLogs).toStrictEqual([
|
|
79
|
+
{
|
|
80
|
+
description: 'Definitions cannot be empty!',
|
|
81
|
+
location: { line: 3, path: fileInfo.path }
|
|
82
|
+
}
|
|
83
|
+
]);
|
|
84
|
+
});
|
|
85
|
+
test('should not allow unknown definition header after the first valid definition', () => {
|
|
86
|
+
let content = `
|
|
87
|
+
# DEFINITIONS
|
|
88
|
+
### ASSET
|
|
89
|
+
Name: test
|
|
90
|
+
Path: test.png
|
|
91
|
+
|
|
92
|
+
### Some text
|
|
93
|
+
some text
|
|
94
|
+
`;
|
|
95
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
96
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
97
|
+
expect(result.errorLogs).toStrictEqual([
|
|
98
|
+
{
|
|
99
|
+
description: 'Invalid definition header: "### Some text"',
|
|
100
|
+
location: { line: 7, path: fileInfo.path }
|
|
101
|
+
}
|
|
102
|
+
]);
|
|
103
|
+
});
|
|
104
|
+
test('invalid definitions should not corrupt other definitions', () => {
|
|
105
|
+
let content = `
|
|
106
|
+
# DEFINITIONS
|
|
107
|
+
### ASSET
|
|
108
|
+
Name: test
|
|
109
|
+
Path: test.png
|
|
110
|
+
|
|
111
|
+
### Some text
|
|
112
|
+
some text
|
|
113
|
+
|
|
114
|
+
### ASSET
|
|
115
|
+
Name: test2
|
|
116
|
+
Path: test2.png
|
|
117
|
+
`;
|
|
118
|
+
let fileInfo = (0, mocks_1.getMockFileInfo)(content);
|
|
119
|
+
let result = selectDefinitionsHelper.process(fileInfo);
|
|
120
|
+
expect(result.definitionPlaneTexts).toStrictEqual([
|
|
121
|
+
{
|
|
122
|
+
type: 'ASSET',
|
|
123
|
+
content: [' Name: test', ' Path: test.png'],
|
|
124
|
+
location: { line: 3, path: fileInfo.path }
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: 'ASSET',
|
|
128
|
+
content: [' Name: test2', ' Path: test2.png'],
|
|
129
|
+
location: { line: 10, path: fileInfo.path }
|
|
130
|
+
}
|
|
131
|
+
]);
|
|
132
|
+
expect(result.errorLogs).toStrictEqual([
|
|
133
|
+
{
|
|
134
|
+
description: 'Invalid definition header: "### Some text"',
|
|
135
|
+
location: { line: 7, path: fileInfo.path }
|
|
136
|
+
}
|
|
137
|
+
]);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
//# sourceMappingURL=1-select-definitions.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|