definition-generator-framework 1.12.4 → 1.12.5

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.
Files changed (151) hide show
  1. package/dist/helpers/common-functions/common-functions.spec.d.ts +1 -0
  2. package/dist/helpers/common-functions/common-functions.spec.js +50 -0
  3. package/dist/helpers/duplicate-helper/duplicate-helper.spec.d.ts +1 -0
  4. package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +54 -0
  5. package/dist/helpers/output-helper/output-helper.spec.d.ts +24 -0
  6. package/dist/helpers/output-helper/output-helper.spec.js +249 -0
  7. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.d.ts +1 -0
  8. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +135 -0
  9. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +1 -0
  10. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +173 -0
  11. package/dist/helpers/validator/joi-custom-validators.spec.d.ts +1 -0
  12. package/dist/helpers/validator/joi-custom-validators.spec.js +260 -0
  13. package/dist/helpers/validator/validator.spec.d.ts +1 -0
  14. package/dist/helpers/validator/validator.spec.js +322 -0
  15. package/dist/pipeline/1-select-definitions.spec.d.ts +1 -0
  16. package/dist/pipeline/1-select-definitions.spec.js +140 -0
  17. package/dist/pipeline/2-structure-parser.helper.spec.d.ts +1 -0
  18. package/dist/pipeline/2-structure-parser.helper.spec.js +280 -0
  19. package/dist/pipeline/parsers/array-parser.spec.d.ts +1 -0
  20. package/dist/pipeline/parsers/array-parser.spec.js +125 -0
  21. package/dist/pipeline/parsers/object-parser.spec.d.ts +1 -0
  22. package/dist/pipeline/parsers/object-parser.spec.js +173 -0
  23. package/dist/pipeline/parsers/primitive-parser.spec.d.ts +1 -0
  24. package/dist/pipeline/parsers/primitive-parser.spec.js +79 -0
  25. package/package.json +8 -3
  26. package/.eslintrc.js +0 -212
  27. package/.vscode/launch.json +0 -15
  28. package/.vscode/settings.json +0 -25
  29. package/coverage/clover.xml +0 -503
  30. package/coverage/coverage-final.json +0 -16
  31. package/coverage/lcov-report/_mocks/index.html +0 -116
  32. package/coverage/lcov-report/_mocks/mocks.ts.html +0 -223
  33. package/coverage/lcov-report/base.css +0 -224
  34. package/coverage/lcov-report/block-navigation.js +0 -87
  35. package/coverage/lcov-report/favicon.png +0 -0
  36. package/coverage/lcov-report/framework/framework.data.ts.html +0 -109
  37. package/coverage/lcov-report/framework/index.html +0 -116
  38. package/coverage/lcov-report/helpers/common-functions/common-functions.ts.html +0 -178
  39. package/coverage/lcov-report/helpers/common-functions/index.html +0 -116
  40. package/coverage/lcov-report/helpers/duplicate-helper/duplicate-helper.ts.html +0 -196
  41. package/coverage/lcov-report/helpers/duplicate-helper/index.html +0 -116
  42. package/coverage/lcov-report/helpers/output-helper/index.html +0 -116
  43. package/coverage/lcov-report/helpers/output-helper/output-helper.ts.html +0 -277
  44. package/coverage/lcov-report/helpers/raw-definition-helper/index.html +0 -116
  45. package/coverage/lcov-report/helpers/raw-definition-helper/raw-definition.helper.ts.html +0 -256
  46. package/coverage/lcov-report/helpers/validator/index.html +0 -131
  47. package/coverage/lcov-report/helpers/validator/joi-custom-validators.ts.html +0 -643
  48. package/coverage/lcov-report/helpers/validator/validator.ts.html +0 -310
  49. package/coverage/lcov-report/index.html +0 -251
  50. package/coverage/lcov-report/pipeline/1-select-definitions-helper.ts.html +0 -358
  51. package/coverage/lcov-report/pipeline/2-structure-parser.helper.ts.html +0 -301
  52. package/coverage/lcov-report/pipeline/3-config.ts.html +0 -178
  53. package/coverage/lcov-report/pipeline/_mocks/index.html +0 -116
  54. package/coverage/lcov-report/pipeline/_mocks/index.ts.html +0 -229
  55. package/coverage/lcov-report/pipeline/index.html +0 -146
  56. package/coverage/lcov-report/pipeline/parsers/array-parser.ts.html +0 -271
  57. package/coverage/lcov-report/pipeline/parsers/index.html +0 -146
  58. package/coverage/lcov-report/pipeline/parsers/object-parser.ts.html +0 -439
  59. package/coverage/lcov-report/pipeline/parsers/primitive-parser.ts.html +0 -370
  60. package/coverage/lcov-report/prettify.css +0 -1
  61. package/coverage/lcov-report/prettify.js +0 -2
  62. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  63. package/coverage/lcov-report/sorter.js +0 -196
  64. package/coverage/lcov.info +0 -911
  65. package/dist/_mocks/mocks.js.map +0 -1
  66. package/dist/decorators/definition-component.js.map +0 -1
  67. package/dist/decorators/definition-generator.js.map +0 -1
  68. package/dist/framework/context.js.map +0 -1
  69. package/dist/framework/definition-component.js.map +0 -1
  70. package/dist/framework/definition-generator.js.map +0 -1
  71. package/dist/framework/definition-store.js.map +0 -1
  72. package/dist/framework/file-content-generator/file-content-generator.js.map +0 -1
  73. package/dist/framework/file-content-generator/file-content-generator.test.js.map +0 -1
  74. package/dist/framework/framework.data.js.map +0 -1
  75. package/dist/framework/framework.js.map +0 -1
  76. package/dist/framework/framework.model.js.map +0 -1
  77. package/dist/framework/index-file-generator/index-file-generator.js.map +0 -1
  78. package/dist/framework/interfaces.js.map +0 -1
  79. package/dist/framework/kernel.js.map +0 -1
  80. package/dist/helpers/common-functions/common-functions.js.map +0 -1
  81. package/dist/helpers/common-functions/common-functions.spec.js.map +0 -1
  82. package/dist/helpers/common-functions/common-functions.test.js.map +0 -1
  83. package/dist/helpers/duplicate-helper/duplicate-helper.js.map +0 -1
  84. package/dist/helpers/duplicate-helper/duplicate-helper.spec.js.map +0 -1
  85. package/dist/helpers/duplicate-helper/duplicate-helper.test.js.map +0 -1
  86. package/dist/helpers/output-helper/output-helper.js.map +0 -1
  87. package/dist/helpers/output-helper/output-helper.spec.js.map +0 -1
  88. package/dist/helpers/output-helper/output-helper.test.js.map +0 -1
  89. package/dist/helpers/raw-definition-helper/raw-definition.helper.js.map +0 -1
  90. package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js.map +0 -1
  91. package/dist/helpers/raw-definition-helper/raw-definition.helper.test.js.map +0 -1
  92. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.js.map +0 -1
  93. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js.map +0 -1
  94. package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.js.map +0 -1
  95. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.js.map +0 -1
  96. package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.js.map +0 -1
  97. package/dist/helpers/validator/custom-validators/image.custom-validator.js.map +0 -1
  98. package/dist/helpers/validator/custom-validators/path.custom-validator.js.map +0 -1
  99. package/dist/helpers/validator/custom-validators/position-on-sprite.js.map +0 -1
  100. package/dist/helpers/validator/custom-validators/reference.custom-validator.js.map +0 -1
  101. package/dist/helpers/validator/custom-validators/sprite.custom-validator.js.map +0 -1
  102. package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js.map +0 -1
  103. package/dist/helpers/validator/custom-validators/unique.custom-validator.js.map +0 -1
  104. package/dist/helpers/validator/joi-custom-validators.js.map +0 -1
  105. package/dist/helpers/validator/joi-custom-validators.spec.js.map +0 -1
  106. package/dist/helpers/validator/validator.js.map +0 -1
  107. package/dist/helpers/validator/validator.spec.js.map +0 -1
  108. package/dist/helpers/validator/validator.test.js.map +0 -1
  109. package/dist/index.js.map +0 -1
  110. package/dist/pipeline/1-select-definitions-helper.js.map +0 -1
  111. package/dist/pipeline/1-select-definitions.helper.js.map +0 -1
  112. package/dist/pipeline/1-select-definitions.helper.test.js.map +0 -1
  113. package/dist/pipeline/1-select-definitions.spec.js.map +0 -1
  114. package/dist/pipeline/2-structure-parser.helper.js.map +0 -1
  115. package/dist/pipeline/2-structure-parser.helper.spec.js.map +0 -1
  116. package/dist/pipeline/2-structure-parser.helper.test.js.map +0 -1
  117. package/dist/pipeline/3-config.js.map +0 -1
  118. package/dist/pipeline/_mocks/index.js.map +0 -1
  119. package/dist/pipeline/parsers/array-parser.js.map +0 -1
  120. package/dist/pipeline/parsers/array-parser.spec.js.map +0 -1
  121. package/dist/pipeline/parsers/array-parser.test.js.map +0 -1
  122. package/dist/pipeline/parsers/object-parser.js.map +0 -1
  123. package/dist/pipeline/parsers/object-parser.spec.js.map +0 -1
  124. package/dist/pipeline/parsers/object-parser.test.js.map +0 -1
  125. package/dist/pipeline/parsers/primitive-parser.js.map +0 -1
  126. package/dist/pipeline/parsers/primitive-parser.spec.js.map +0 -1
  127. package/dist/pipeline/parsers/primitive-parser.test.js.map +0 -1
  128. package/dist/pipeline/raw-data-parser.js.map +0 -1
  129. package/dist/pre-made-components/_validators/shape-validators.js.map +0 -1
  130. package/dist/pre-made-components/_validators/sprite-validators.js.map +0 -1
  131. package/dist/pre-made-components/assets/1-sprite.js.map +0 -1
  132. package/dist/pre-made-components/assets/2-sprite-group.js.map +0 -1
  133. package/dist/pre-made-components/assets/3-font.js.map +0 -1
  134. package/dist/pre-made-components/events/1-event.js.map +0 -1
  135. package/dist/pre-made-components/events/1-script.js.map +0 -1
  136. package/dist/pre-made-components/events/2-event-test.js.map +0 -1
  137. package/dist/pre-made-components/events/2-script-test.js.map +0 -1
  138. package/dist/pre-made-components/events/3-event.js.map +0 -1
  139. package/dist/pre-made-components/events/4-event-test.js.map +0 -1
  140. package/dist/pre-made-components/events/event-setup.js.map +0 -1
  141. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.js.map +0 -1
  142. package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.js.map +0 -1
  143. package/dist/pre-made-components/events/helpers/script-testing.helper.js.map +0 -1
  144. package/dist/pre-made-components/events/script-setup.js.map +0 -1
  145. package/dist/pre-made-components/events/scripting-setup.js.map +0 -1
  146. package/dist/pre-made-components/events/validators.js.map +0 -1
  147. package/dist/setup.js.map +0 -1
  148. package/package.json.bak +0 -60
  149. package/scripts/prepare-package-json.ts +0 -23
  150. package/tsconfig.json +0 -24
  151. package/vitest.config.ts +0 -1
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const common_functions_1 = require("./common-functions");
4
+ describe('COMMON FUNCTIONS', () => {
5
+ test('kabab case to camel case', () => {
6
+ expect(common_functions_1.CommonFunctions.kebabCaseToCamelCase('')).toEqual('');
7
+ expect(common_functions_1.CommonFunctions.kebabCaseToCamelCase('text')).toEqual('text');
8
+ expect(common_functions_1.CommonFunctions.kebabCaseToCamelCase('TEXT')).toEqual('text');
9
+ expect(common_functions_1.CommonFunctions.kebabCaseToCamelCase('text-asdf')).toEqual('textAsdf');
10
+ expect(common_functions_1.CommonFunctions.kebabCaseToCamelCase('TEXT-ASDF')).toEqual('textAsdf');
11
+ });
12
+ test('lower case first letter', () => {
13
+ expect(common_functions_1.CommonFunctions.lowerCaseFirstLetter('')).toEqual('');
14
+ expect(common_functions_1.CommonFunctions.lowerCaseFirstLetter('text')).toEqual('text');
15
+ expect(common_functions_1.CommonFunctions.lowerCaseFirstLetter(' ')).toEqual(' ');
16
+ expect(common_functions_1.CommonFunctions.lowerCaseFirstLetter('Text')).toEqual('text');
17
+ expect(common_functions_1.CommonFunctions.lowerCaseFirstLetter(' Text')).toEqual(' Text');
18
+ });
19
+ test('upper case first letter', () => {
20
+ expect(common_functions_1.CommonFunctions.upperCaseFirstLetter('')).toEqual('');
21
+ expect(common_functions_1.CommonFunctions.upperCaseFirstLetter('Text')).toEqual('Text');
22
+ expect(common_functions_1.CommonFunctions.upperCaseFirstLetter(' ')).toEqual(' ');
23
+ expect(common_functions_1.CommonFunctions.upperCaseFirstLetter('text')).toEqual('Text');
24
+ expect(common_functions_1.CommonFunctions.upperCaseFirstLetter(' text')).toEqual(' text');
25
+ });
26
+ test('remove whitespace', () => {
27
+ expect(common_functions_1.CommonFunctions.removeWhiteSpace('')).toEqual('');
28
+ expect(common_functions_1.CommonFunctions.removeWhiteSpace('text')).toEqual('text');
29
+ expect(common_functions_1.CommonFunctions.removeWhiteSpace(' text')).toEqual('text');
30
+ expect(common_functions_1.CommonFunctions.removeWhiteSpace('text ')).toEqual('text');
31
+ expect(common_functions_1.CommonFunctions.removeWhiteSpace('text\n')).toEqual('text');
32
+ expect(common_functions_1.CommonFunctions.removeWhiteSpace('text\r')).toEqual('text');
33
+ expect(common_functions_1.CommonFunctions.removeWhiteSpace('text\r\n')).toEqual('text');
34
+ expect(common_functions_1.CommonFunctions.removeWhiteSpace('text//')).toEqual('text');
35
+ expect(common_functions_1.CommonFunctions.removeWhiteSpace('text //')).toEqual('text');
36
+ expect(common_functions_1.CommonFunctions.removeWhiteSpace('text // asdf')).toEqual('text');
37
+ expect(common_functions_1.CommonFunctions.removeWhiteSpace('text text')).toEqual('text text');
38
+ expect(common_functions_1.CommonFunctions.removeWhiteSpace('text text')).toEqual('text text');
39
+ });
40
+ test('remove comments', () => {
41
+ expect(common_functions_1.CommonFunctions.removeComments('')).toEqual('');
42
+ expect(common_functions_1.CommonFunctions.removeComments('text')).toEqual('text');
43
+ expect(common_functions_1.CommonFunctions.removeComments(' text ')).toEqual(' text');
44
+ expect(common_functions_1.CommonFunctions.removeComments(' text//')).toEqual(' text');
45
+ expect(common_functions_1.CommonFunctions.removeComments(' text //')).toEqual(' text');
46
+ expect(common_functions_1.CommonFunctions.removeComments(' text // asdf')).toEqual(' text');
47
+ expect(common_functions_1.CommonFunctions.removeComments('- Symbol: □ // Dirt\n')).toEqual('- Symbol: □');
48
+ });
49
+ });
50
+ //# sourceMappingURL=common-functions.spec.js.map
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const duplicate_helper_1 = require("./duplicate-helper");
4
+ const mocks_1 = require("../../_mocks/mocks");
5
+ const context_1 = require("../../framework/context");
6
+ describe('Duplicate Helper', () => {
7
+ test('should handle single entry', () => {
8
+ (0, mocks_1.resetContext)();
9
+ let helper = new duplicate_helper_1.DuplicateHelper('ASSET: Name');
10
+ expect(helper.newEntry('identifier', mocks_1.SampleLocation1)).toBeTruthy();
11
+ helper.logDuplicateErrors();
12
+ expect(context_1.Context.errorLogs).toStrictEqual([]);
13
+ });
14
+ test('should detect duplicate', () => {
15
+ (0, mocks_1.resetContext)();
16
+ let helper = new duplicate_helper_1.DuplicateHelper('ASSET: Name');
17
+ expect(helper.newEntry('identifier', mocks_1.SampleLocation1)).toBeTruthy();
18
+ expect(helper.newEntry('identifier', mocks_1.SampleLocation2)).toBeFalsy();
19
+ helper.logDuplicateErrors();
20
+ expect(context_1.Context.errorLogs).toStrictEqual([
21
+ {
22
+ description: 'Value should be singular! Group: "ASSET: Name", Value: "identifier"',
23
+ location: mocks_1.SampleLocation1
24
+ },
25
+ {
26
+ description: 'Value should be singular! Group: "ASSET: Name", Value: "identifier"',
27
+ location: mocks_1.SampleLocation2
28
+ }
29
+ ]);
30
+ });
31
+ test('should detect multiple duplicate', () => {
32
+ (0, mocks_1.resetContext)();
33
+ let helper = new duplicate_helper_1.DuplicateHelper('ASSET: Name');
34
+ expect(helper.newEntry('identifier', mocks_1.SampleLocation1)).toBeTruthy();
35
+ expect(helper.newEntry('identifier', mocks_1.SampleLocation2)).toBeFalsy();
36
+ expect(helper.newEntry('identifier', mocks_1.SampleLocation3)).toBeFalsy();
37
+ helper.logDuplicateErrors();
38
+ expect(context_1.Context.errorLogs).toStrictEqual([
39
+ {
40
+ description: 'Value should be singular! Group: "ASSET: Name", Value: "identifier"',
41
+ location: mocks_1.SampleLocation1
42
+ },
43
+ {
44
+ description: 'Value should be singular! Group: "ASSET: Name", Value: "identifier"',
45
+ location: mocks_1.SampleLocation2
46
+ },
47
+ {
48
+ description: 'Value should be singular! Group: "ASSET: Name", Value: "identifier"',
49
+ location: mocks_1.SampleLocation3
50
+ }
51
+ ]);
52
+ });
53
+ });
54
+ //# sourceMappingURL=duplicate-helper.spec.js.map
@@ -0,0 +1,24 @@
1
+ export declare const Const: {
2
+ type: string;
3
+ material: string;
4
+ maxQuantity: number;
5
+ mainHand: undefined;
6
+ offHand: undefined;
7
+ bothHands: {
8
+ imageOnCharacter: string;
9
+ parryDice: undefined;
10
+ attacks: {
11
+ actionIcon: string;
12
+ attackDices: string[];
13
+ range: string;
14
+ requiresSetup: boolean;
15
+ unparryable: boolean;
16
+ lowersQuantity: boolean;
17
+ projectileType: string;
18
+ sounds: {
19
+ hit: string;
20
+ pre: string;
21
+ };
22
+ }[];
23
+ };
24
+ };
@@ -0,0 +1,249 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Const = void 0;
4
+ const mocks_1 = require("../../_mocks/mocks");
5
+ const context_1 = require("../../framework/context");
6
+ const output_helper_1 = require("./output-helper");
7
+ let complexObject = {
8
+ type: 'bow',
9
+ material: 'WoodenItemMaterial',
10
+ maxQuantity: 10,
11
+ mainHand: undefined,
12
+ offHand: undefined,
13
+ bothHands: {
14
+ imageOnCharacter: 'BodyPartImageNames',
15
+ parryDice: undefined,
16
+ attacks: [
17
+ {
18
+ actionIcon: 'AssetNames.characterActionBowAttack',
19
+ attackDices: ['DiceType.d6', 'DiceType.d6'],
20
+ range: 'WeaponRange.ranged',
21
+ requiresSetup: false,
22
+ unparryable: true,
23
+ lowersQuantity: true,
24
+ projectileType: 'ProjectileType.arrow',
25
+ sounds: {
26
+ hit: 'AssetGroups.battleSoundArrowHit',
27
+ pre: 'AssetGroups.battleSoundArrowShot'
28
+ }
29
+ }
30
+ ]
31
+ }
32
+ };
33
+ let emptyArrayExpected = `export const Groups: any[] = [];
34
+ `;
35
+ let basicArrayExpected = `export const Groups: any[] = [
36
+ { name: 'test1', source: './src/definitions-sample/images/test1.png' },
37
+ { name: 'test2', source: './src/definitions-sample/images/test2.png', pixelPerfectInteraction: true }
38
+ ];
39
+ `;
40
+ let complexArrayExpected = `export const Groups: any[] = [
41
+ {
42
+ type: 'bow',
43
+ material: 'WoodenItemMaterial',
44
+ maxQuantity: 10,
45
+ mainHand: undefined,
46
+ offHand: undefined,
47
+ bothHands: {
48
+ imageOnCharacter: 'BodyPartImageNames',
49
+ parryDice: undefined,
50
+ attacks: [
51
+ {
52
+ actionIcon: 'AssetNames.characterActionBowAttack',
53
+ attackDices: ['DiceType.d6', 'DiceType.d6'],
54
+ range: 'WeaponRange.ranged',
55
+ requiresSetup: false,
56
+ unparryable: true,
57
+ lowersQuantity: true,
58
+ projectileType: 'ProjectileType.arrow',
59
+ sounds: { hit: 'AssetGroups.battleSoundArrowHit', pre: 'AssetGroups.battleSoundArrowShot' }
60
+ }
61
+ ]
62
+ }
63
+ }
64
+ ];
65
+ `;
66
+ let complexArrayReplaceExpected = `export const Groups: any[] = [
67
+ {
68
+ type: 'bow',
69
+ material: 'WoodenItemMaterial',
70
+ maxQuantity: 10,
71
+ mainHand: undefined,
72
+ offHand: undefined,
73
+ bothHands: {
74
+ imageOnCharacter: 'BodyPartImageNames',
75
+ parryDice: undefined,
76
+ attacks: [
77
+ {
78
+ actionIcon: 'AssetNames.characterActionBowAttack',
79
+ attackDices: [DiceType.d6, DiceType.d6],
80
+ range: 'WeaponRange.ranged',
81
+ requiresSetup: false,
82
+ unparryable: true,
83
+ lowersQuantity: true,
84
+ projectileType: 'ProjectileType.arrow',
85
+ sounds: { hit: 'AssetGroups.battleSoundArrowHit', pre: 'AssetGroups.battleSoundArrowShot' }
86
+ }
87
+ ]
88
+ }
89
+ }
90
+ ];
91
+ `;
92
+ exports.Const = {
93
+ type: 'bow',
94
+ material: 'WoodenItemMaterial',
95
+ maxQuantity: 10,
96
+ mainHand: undefined,
97
+ offHand: undefined,
98
+ bothHands: {
99
+ imageOnCharacter: 'BodyPartImageNames',
100
+ parryDice: undefined,
101
+ attacks: [
102
+ {
103
+ actionIcon: 'AssetNames.characterActionBowAttack',
104
+ attackDices: ['DiceType.d6', 'DiceType.d6'],
105
+ range: 'WeaponRange.ranged',
106
+ requiresSetup: false,
107
+ unparryable: true,
108
+ lowersQuantity: true,
109
+ projectileType: 'ProjectileType.arrow',
110
+ sounds: {
111
+ hit: 'AssetGroups.battleSoundArrowHit',
112
+ pre: 'AssetGroups.battleSoundArrowShot'
113
+ }
114
+ }
115
+ ]
116
+ }
117
+ };
118
+ let noTypeExpected = `export const ConstSample = { type: 'item' };
119
+ `;
120
+ let basicConstExpected = `export const ConstSample: string = 'basic';
121
+ `;
122
+ let complexConstExpected = `export const ConstSample: any = {
123
+ type: 'bow',
124
+ material: 'WoodenItemMaterial',
125
+ maxQuantity: 10,
126
+ mainHand: undefined,
127
+ offHand: undefined,
128
+ bothHands: {
129
+ imageOnCharacter: 'BodyPartImageNames',
130
+ parryDice: undefined,
131
+ attacks: [
132
+ {
133
+ actionIcon: 'AssetNames.characterActionBowAttack',
134
+ attackDices: ['DiceType.d6', 'DiceType.d6'],
135
+ range: 'WeaponRange.ranged',
136
+ requiresSetup: false,
137
+ unparryable: true,
138
+ lowersQuantity: true,
139
+ projectileType: 'ProjectileType.arrow',
140
+ sounds: { hit: 'AssetGroups.battleSoundArrowHit', pre: 'AssetGroups.battleSoundArrowShot' }
141
+ }
142
+ ]
143
+ }
144
+ };
145
+ `;
146
+ let complexConstReplaceExpected = `export const ConstSample: any = {
147
+ type: 'bow',
148
+ material: 'WoodenItemMaterial',
149
+ maxQuantity: 10,
150
+ mainHand: undefined,
151
+ offHand: undefined,
152
+ bothHands: {
153
+ imageOnCharacter: 'BodyPartImageNames',
154
+ parryDice: undefined,
155
+ attacks: [
156
+ {
157
+ actionIcon: 'AssetNames.characterActionBowAttack',
158
+ attackDices: ['DiceType.d6', 'DiceType.d6'],
159
+ range: WeaponRange,
160
+ requiresSetup: false,
161
+ unparryable: true,
162
+ lowersQuantity: true,
163
+ projectileType: 'ProjectileType.arrow',
164
+ sounds: { hit: 'AssetGroups.battleSoundArrowHit', pre: 'AssetGroups.battleSoundArrowShot' }
165
+ }
166
+ ]
167
+ }
168
+ };
169
+ `;
170
+ describe('Output Helper: Array Output', () => {
171
+ test('should handle empty array', async () => {
172
+ let output = await output_helper_1.OutputHelper.generateArrayOutput({ variableName: 'Groups', variableType: 'any[]', variable: [] });
173
+ expect(output).toStrictEqual(emptyArrayExpected);
174
+ });
175
+ test('should handle basic array', async () => {
176
+ let output = await output_helper_1.OutputHelper.generateArrayOutput({
177
+ variableName: 'Groups',
178
+ variableType: 'any[]',
179
+ variable: [
180
+ { name: 'test1', source: './src/definitions-sample/images/test1.png' },
181
+ { name: 'test2', source: './src/definitions-sample/images/test2.png', pixelPerfectInteraction: true }
182
+ ]
183
+ });
184
+ expect(output).toStrictEqual(basicArrayExpected);
185
+ });
186
+ test('should handle complex array', async () => {
187
+ let output = await output_helper_1.OutputHelper.generateArrayOutput({
188
+ variableName: 'Groups',
189
+ variableType: 'any[]',
190
+ variable: [complexObject]
191
+ });
192
+ expect(output).toStrictEqual(complexArrayExpected);
193
+ });
194
+ test('should handle replacing complex array', async () => {
195
+ let output = await output_helper_1.OutputHelper.generateArrayOutput({
196
+ variableName: 'Groups',
197
+ variableType: 'any[]',
198
+ variable: [complexObject],
199
+ replaceMap: [{ target: `"DiceType.d6"`, replace: 'DiceType.d6' }]
200
+ });
201
+ expect(output).toStrictEqual(complexArrayReplaceExpected);
202
+ });
203
+ });
204
+ describe('Output Helper: Const Output', () => {
205
+ test('should handle no type', async () => {
206
+ let output = await output_helper_1.OutputHelper.generateOutput({ variableName: 'ConstSample', variable: { type: 'item' } });
207
+ expect(output).toStrictEqual(noTypeExpected);
208
+ });
209
+ test('should handle basic value', async () => {
210
+ let output = await output_helper_1.OutputHelper.generateOutput({ variableName: 'ConstSample', variableType: 'string', variable: 'basic' });
211
+ expect(output).toStrictEqual(basicConstExpected);
212
+ });
213
+ test('should handle complex object', async () => {
214
+ let output = await output_helper_1.OutputHelper.generateOutput({ variableName: 'ConstSample', variableType: 'any', variable: complexObject });
215
+ expect(output).toStrictEqual(complexConstExpected);
216
+ });
217
+ test('should handle replacing complex object', async () => {
218
+ let output = await output_helper_1.OutputHelper.generateOutput({
219
+ variableName: 'ConstSample',
220
+ variableType: 'any',
221
+ variable: complexObject,
222
+ replaceMap: [{ target: `"WeaponRange.ranged"`, replace: 'WeaponRange' }]
223
+ });
224
+ expect(output).toStrictEqual(complexConstReplaceExpected);
225
+ });
226
+ });
227
+ describe('Output Helper: stringify', () => {
228
+ test('should not lose properties with undefined or null value', async () => {
229
+ let output = await output_helper_1.OutputHelper['stringify']({
230
+ a: undefined,
231
+ // eslint-disable-next-line no-null/no-null
232
+ b: null
233
+ });
234
+ expect(output).toStrictEqual('{"a":undefined,"b":undefined}');
235
+ });
236
+ });
237
+ describe('Output Helper: convertToRelativePath', () => {
238
+ test('should convert to relative path', async () => {
239
+ (0, mocks_1.resetContext)();
240
+ context_1.Context.outputPath = 'D:/Projects/Game-Dev/Starfighter/Starfighter-Definitions-Generator/src/.asset-build';
241
+ context_1.Context.config.projectRoot = 'D:/Projects/Game-Dev/Starfighter/Starfighter-Definitions-Generator/';
242
+ let original = '.src/definitions-sample/images/nested/test2.png';
243
+ let desired = '../../../definitions-sample/images/nested/test2.png';
244
+ let filePath = '/0-global-definitions/assets/images.ts';
245
+ let output = output_helper_1.OutputHelper['convertToRelativePath'](filePath, original);
246
+ expect(output).toStrictEqual(desired);
247
+ });
248
+ });
249
+ //# sourceMappingURL=output-helper.spec.js.map
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const mocks_1 = require("../../_mocks/mocks");
4
+ const raw_definition_helper_1 = require("./raw-definition.helper");
5
+ const ComponentName = 'ASSET';
6
+ describe('RAW DEFINITION HELPER', () => {
7
+ describe('Find Parsed Structure', () => {
8
+ test('nested definition', () => {
9
+ let rawDefinition = {
10
+ componentName: ComponentName,
11
+ location: mocks_1.SampleLocation1,
12
+ parsedStructure: {
13
+ line: mocks_1.SampleLocation1.line + 1,
14
+ rawData: {
15
+ obj1: {
16
+ line: mocks_1.SampleLocation1.line + 2,
17
+ rawData: [
18
+ {
19
+ line: mocks_1.SampleLocation1.line + 3,
20
+ rawData: {
21
+ obj2: {
22
+ line: mocks_1.SampleLocation1.line + 4,
23
+ rawData: 'test data'
24
+ }
25
+ }
26
+ }
27
+ ]
28
+ }
29
+ }
30
+ }
31
+ };
32
+ expect(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, [])).toEqual(mocks_1.SampleLocation1.line + 1);
33
+ expect(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['obj1'])).toEqual(mocks_1.SampleLocation1.line + 2);
34
+ expect(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['obj1', 0])).toEqual(mocks_1.SampleLocation1.line + 3);
35
+ expect(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['obj1', 0, 'obj2'])).toEqual(mocks_1.SampleLocation1.line + 4);
36
+ expect(raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, ['notExists'])).toEqual(mocks_1.SampleLocation1.line + 1);
37
+ });
38
+ });
39
+ describe('Flattening', () => {
40
+ test('primitive', () => {
41
+ let rawDefinition = {
42
+ componentName: ComponentName,
43
+ location: mocks_1.SampleLocation1,
44
+ parsedStructure: {
45
+ line: 0,
46
+ rawData: 'test'
47
+ }
48
+ };
49
+ let expected = 'test';
50
+ expect(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition)).toStrictEqual(expected);
51
+ });
52
+ test('array', () => {
53
+ let rawDefinition = {
54
+ componentName: ComponentName,
55
+ location: mocks_1.SampleLocation1,
56
+ parsedStructure: {
57
+ line: 0,
58
+ rawData: [
59
+ {
60
+ line: 0,
61
+ rawData: [
62
+ {
63
+ line: 0,
64
+ rawData: 'orange'
65
+ },
66
+ {
67
+ line: 0,
68
+ rawData: 'banana'
69
+ }
70
+ ]
71
+ },
72
+ {
73
+ line: 0,
74
+ rawData: [
75
+ {
76
+ line: 0,
77
+ rawData: '1'
78
+ },
79
+ {
80
+ line: 0,
81
+ rawData: '2'
82
+ }
83
+ ]
84
+ }
85
+ ]
86
+ }
87
+ };
88
+ let expected = [
89
+ ['orange', 'banana'],
90
+ ['1', '2']
91
+ ];
92
+ expect(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition)).toStrictEqual(expected);
93
+ });
94
+ test('object', () => {
95
+ let rawDefinition = {
96
+ componentName: ComponentName,
97
+ location: mocks_1.SampleLocation1,
98
+ parsedStructure: {
99
+ line: 0,
100
+ rawData: {
101
+ array1: {
102
+ line: 0,
103
+ rawData: [
104
+ {
105
+ line: 0,
106
+ rawData: 'apple'
107
+ },
108
+ {
109
+ line: 0,
110
+ rawData: 'orange'
111
+ }
112
+ ]
113
+ },
114
+ array2: {
115
+ line: 0,
116
+ rawData: [
117
+ {
118
+ line: 0,
119
+ rawData: 'xWing'
120
+ },
121
+ {
122
+ line: 0,
123
+ rawData: 'tieFighter'
124
+ }
125
+ ]
126
+ }
127
+ }
128
+ }
129
+ };
130
+ let expected = { array1: ['apple', 'orange'], array2: ['xWing', 'tieFighter'] };
131
+ expect(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition)).toStrictEqual(expected);
132
+ });
133
+ });
134
+ });
135
+ //# sourceMappingURL=raw-definition.helper.spec.js.map
@@ -0,0 +1 @@
1
+ export declare const AssetComponentName = "ASSET";