definition-generator-framework 1.13.1 → 2.0.0-rc1
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/index.d.mts +204 -0
- package/dist/index.d.ts +204 -17
- package/dist/index.js +43 -50
- package/dist/index.mjs +43 -0
- package/package.json +28 -14
- package/dist/_mocks/mocks.d.ts +0 -7
- package/dist/_mocks/mocks.js +0 -44
- package/dist/decorators/definition-component.d.ts +0 -18
- package/dist/decorators/definition-component.js +0 -52
- package/dist/decorators/definition-generator.d.ts +0 -11
- package/dist/decorators/definition-generator.js +0 -30
- package/dist/framework/context.d.ts +0 -24
- package/dist/framework/context.js +0 -64
- package/dist/framework/definition-component.d.ts +0 -20
- package/dist/framework/definition-component.js +0 -29
- package/dist/framework/definition-generator.d.ts +0 -11
- package/dist/framework/definition-generator.js +0 -22
- package/dist/framework/definition-store.d.ts +0 -25
- package/dist/framework/definition-store.js +0 -121
- package/dist/framework/file-content-generator/file-content-generator.d.ts +0 -19
- package/dist/framework/file-content-generator/file-content-generator.js +0 -117
- package/dist/framework/file-content-generator/file-content-generator.test.d.ts +0 -24
- package/dist/framework/file-content-generator/file-content-generator.test.js +0 -161
- package/dist/framework/file-generators/index-file-generator.d.ts +0 -13
- package/dist/framework/file-generators/index-file-generator.js +0 -139
- package/dist/framework/file-generators/types-file-generator.d.ts +0 -6
- package/dist/framework/file-generators/types-file-generator.js +0 -35
- package/dist/framework/framework.d.ts +0 -28
- package/dist/framework/framework.data.d.ts +0 -6
- package/dist/framework/framework.data.js +0 -17
- package/dist/framework/framework.js +0 -51
- package/dist/framework/framework.model.d.ts +0 -32
- package/dist/framework/framework.model.js +0 -3
- package/dist/framework/index-file-generator/index-file-generator.d.ts +0 -10
- package/dist/framework/index-file-generator/index-file-generator.js +0 -118
- package/dist/framework/interfaces.d.ts +0 -46
- package/dist/framework/interfaces.js +0 -3
- package/dist/framework/kernel.d.ts +0 -12
- package/dist/framework/kernel.js +0 -308
- package/dist/helpers/common-functions/common-functions.d.ts +0 -10
- package/dist/helpers/common-functions/common-functions.js +0 -29
- package/dist/helpers/common-functions/common-functions.spec.d.ts +0 -1
- package/dist/helpers/common-functions/common-functions.spec.js +0 -50
- package/dist/helpers/common-functions/common-functions.test.d.ts +0 -1
- package/dist/helpers/common-functions/common-functions.test.js +0 -51
- package/dist/helpers/duplicate-helper/duplicate-helper.d.ts +0 -11
- package/dist/helpers/duplicate-helper/duplicate-helper.js +0 -40
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.d.ts +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +0 -54
- package/dist/helpers/duplicate-helper/duplicate-helper.test.d.ts +0 -1
- package/dist/helpers/duplicate-helper/duplicate-helper.test.js +0 -55
- package/dist/helpers/output-helper/output-helper.d.ts +0 -30
- package/dist/helpers/output-helper/output-helper.js +0 -143
- package/dist/helpers/output-helper/output-helper.spec.d.ts +0 -24
- package/dist/helpers/output-helper/output-helper.spec.js +0 -261
- package/dist/helpers/output-helper/output-helper.test.d.ts +0 -24
- package/dist/helpers/output-helper/output-helper.test.js +0 -262
- package/dist/helpers/raw-definition-helper/raw-definition.helper.d.ts +0 -7
- package/dist/helpers/raw-definition-helper/raw-definition.helper.js +0 -66
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.d.ts +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +0 -143
- package/dist/helpers/raw-definition-helper/raw-definition.helper.test.d.ts +0 -1
- package/dist/helpers/raw-definition-helper/raw-definition.helper.test.js +0 -136
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.d.ts +0 -16
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.js +0 -48
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +0 -191
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.d.ts +0 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.test.js +0 -213
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.d.ts +0 -13
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.js +0 -53
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.d.ts +0 -1
- package/dist/helpers/validator/custom-validators/helpers/sprite-validation.helper.test.js +0 -96
- package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/image.custom-validator.js +0 -44
- package/dist/helpers/validator/custom-validators/path.custom-validator.d.ts +0 -9
- package/dist/helpers/validator/custom-validators/path.custom-validator.js +0 -30
- package/dist/helpers/validator/custom-validators/position-on-sprite.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/position-on-sprite.js +0 -44
- package/dist/helpers/validator/custom-validators/reference.custom-validator.d.ts +0 -22
- package/dist/helpers/validator/custom-validators/reference.custom-validator.js +0 -123
- package/dist/helpers/validator/custom-validators/sprite.custom-validator.d.ts +0 -14
- package/dist/helpers/validator/custom-validators/sprite.custom-validator.js +0 -43
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +0 -9
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +0 -33
- package/dist/helpers/validator/custom-validators/unique.custom-validator.d.ts +0 -8
- package/dist/helpers/validator/custom-validators/unique.custom-validator.js +0 -20
- package/dist/helpers/validator/joi-custom-validators.d.ts +0 -33
- package/dist/helpers/validator/joi-custom-validators.js +0 -54
- package/dist/helpers/validator/joi-custom-validators.spec.d.ts +0 -1
- package/dist/helpers/validator/joi-custom-validators.spec.js +0 -304
- package/dist/helpers/validator/validator.d.ts +0 -21
- package/dist/helpers/validator/validator.js +0 -74
- package/dist/helpers/validator/validator.spec.d.ts +0 -1
- package/dist/helpers/validator/validator.spec.js +0 -332
- package/dist/helpers/validator/validator.test.d.ts +0 -1
- package/dist/helpers/validator/validator.test.js +0 -329
- package/dist/pipeline/1-select-definitions-helper.d.ts +0 -20
- package/dist/pipeline/1-select-definitions-helper.js +0 -76
- package/dist/pipeline/1-select-definitions.helper.d.ts +0 -20
- package/dist/pipeline/1-select-definitions.helper.js +0 -80
- package/dist/pipeline/1-select-definitions.helper.test.d.ts +0 -1
- package/dist/pipeline/1-select-definitions.helper.test.js +0 -141
- package/dist/pipeline/1-select-definitions.spec.d.ts +0 -1
- package/dist/pipeline/1-select-definitions.spec.js +0 -140
- package/dist/pipeline/2-structure-parser.helper.d.ts +0 -11
- package/dist/pipeline/2-structure-parser.helper.js +0 -70
- package/dist/pipeline/2-structure-parser.helper.spec.d.ts +0 -1
- package/dist/pipeline/2-structure-parser.helper.spec.js +0 -280
- package/dist/pipeline/2-structure-parser.helper.test.d.ts +0 -1
- package/dist/pipeline/2-structure-parser.helper.test.js +0 -281
- package/dist/pipeline/3-config.d.ts +0 -9
- package/dist/pipeline/3-config.js +0 -36
- package/dist/pipeline/_mocks/index.d.ts +0 -13
- package/dist/pipeline/_mocks/index.js +0 -52
- package/dist/pipeline/parsers/array-parser.d.ts +0 -4
- package/dist/pipeline/parsers/array-parser.js +0 -69
- package/dist/pipeline/parsers/array-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/array-parser.spec.js +0 -128
- package/dist/pipeline/parsers/array-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/array-parser.test.js +0 -126
- package/dist/pipeline/parsers/object-parser.d.ts +0 -4
- package/dist/pipeline/parsers/object-parser.js +0 -135
- package/dist/pipeline/parsers/object-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/object-parser.spec.js +0 -179
- package/dist/pipeline/parsers/object-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/object-parser.test.js +0 -186
- package/dist/pipeline/parsers/primitive-parser.d.ts +0 -7
- package/dist/pipeline/parsers/primitive-parser.js +0 -111
- package/dist/pipeline/parsers/primitive-parser.spec.d.ts +0 -1
- package/dist/pipeline/parsers/primitive-parser.spec.js +0 -79
- package/dist/pipeline/parsers/primitive-parser.test.d.ts +0 -1
- package/dist/pipeline/parsers/primitive-parser.test.js +0 -85
- package/dist/pipeline/raw-data-parser.d.ts +0 -5
- package/dist/pipeline/raw-data-parser.js +0 -25
- package/dist/pre-made-components/_validators/shape-validators.d.ts +0 -7
- package/dist/pre-made-components/_validators/shape-validators.js +0 -37
- package/dist/pre-made-components/_validators/sprite-validators.d.ts +0 -7
- package/dist/pre-made-components/_validators/sprite-validators.js +0 -43
- package/dist/pre-made-components/assets/1-sprite.d.ts +0 -15
- package/dist/pre-made-components/assets/1-sprite.js +0 -74
- package/dist/pre-made-components/assets/2-sprite-group.d.ts +0 -11
- package/dist/pre-made-components/assets/2-sprite-group.js +0 -41
- package/dist/pre-made-components/assets/3-font.d.ts +0 -17
- package/dist/pre-made-components/assets/3-font.js +0 -71
- package/dist/pre-made-components/events/1-event.d.ts +0 -6
- package/dist/pre-made-components/events/1-event.js +0 -206
- package/dist/pre-made-components/events/1-script.d.ts +0 -8
- package/dist/pre-made-components/events/1-script.js +0 -102
- package/dist/pre-made-components/events/2-event-test.d.ts +0 -18
- package/dist/pre-made-components/events/2-event-test.js +0 -172
- package/dist/pre-made-components/events/2-script-test.d.ts +0 -7
- package/dist/pre-made-components/events/2-script-test.js +0 -102
- package/dist/pre-made-components/events/3-event.d.ts +0 -7
- package/dist/pre-made-components/events/3-event.js +0 -100
- package/dist/pre-made-components/events/4-event-test.d.ts +0 -7
- package/dist/pre-made-components/events/4-event-test.js +0 -89
- package/dist/pre-made-components/events/event-setup.d.ts +0 -13
- package/dist/pre-made-components/events/event-setup.js +0 -20
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.d.ts +0 -3
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.js +0 -24
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.d.ts +0 -1
- package/dist/pre-made-components/events/helpers/quotes-to-tags.helper.test.js +0 -39
- package/dist/pre-made-components/events/helpers/script-testing.helper.d.ts +0 -33
- package/dist/pre-made-components/events/helpers/script-testing.helper.js +0 -79
- package/dist/pre-made-components/events/script-setup.d.ts +0 -8
- package/dist/pre-made-components/events/script-setup.js +0 -16
- package/dist/pre-made-components/events/scripting-setup.d.ts +0 -33
- package/dist/pre-made-components/events/scripting-setup.js +0 -97
- package/dist/pre-made-components/events/validators.d.ts +0 -6
- package/dist/pre-made-components/events/validators.js +0 -96
- package/dist/setup.d.ts +0 -1
- package/dist/setup.js +0 -10
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
declare class OutputHelperClass {
|
|
2
|
-
generateArrayOutput(options: {
|
|
3
|
-
preText?: string;
|
|
4
|
-
variableName: string;
|
|
5
|
-
variableType: string;
|
|
6
|
-
variable: any[];
|
|
7
|
-
filePath?: string;
|
|
8
|
-
assetUrl?: string;
|
|
9
|
-
replaceMap?: {
|
|
10
|
-
target: string;
|
|
11
|
-
replace: string;
|
|
12
|
-
}[];
|
|
13
|
-
}): Promise<string>;
|
|
14
|
-
generateOutput(options: {
|
|
15
|
-
preText?: string;
|
|
16
|
-
variableName: string;
|
|
17
|
-
variableType?: string;
|
|
18
|
-
variable: any;
|
|
19
|
-
replaceMap?: {
|
|
20
|
-
target: string;
|
|
21
|
-
replace: string;
|
|
22
|
-
}[];
|
|
23
|
-
}): Promise<string>;
|
|
24
|
-
private convertToRelativePath;
|
|
25
|
-
private replaceOutput;
|
|
26
|
-
private format;
|
|
27
|
-
private stringify;
|
|
28
|
-
}
|
|
29
|
-
export declare const OutputHelper: OutputHelperClass;
|
|
30
|
-
export {};
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __createBinding =
|
|
3
|
-
(this && this.__createBinding) ||
|
|
4
|
-
(Object.create
|
|
5
|
-
? function (o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () {
|
|
12
|
-
return m[k];
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(o, k2, desc);
|
|
17
|
-
}
|
|
18
|
-
: function (o, m, k, k2) {
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
});
|
|
22
|
-
var __setModuleDefault =
|
|
23
|
-
(this && this.__setModuleDefault) ||
|
|
24
|
-
(Object.create
|
|
25
|
-
? function (o, v) {
|
|
26
|
-
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
27
|
-
}
|
|
28
|
-
: function (o, v) {
|
|
29
|
-
o['default'] = v;
|
|
30
|
-
});
|
|
31
|
-
var __importStar =
|
|
32
|
-
(this && this.__importStar) ||
|
|
33
|
-
function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null)
|
|
37
|
-
for (var k in mod) if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
38
|
-
__setModuleDefault(result, mod);
|
|
39
|
-
return result;
|
|
40
|
-
};
|
|
41
|
-
var __importDefault =
|
|
42
|
-
(this && this.__importDefault) ||
|
|
43
|
-
function (mod) {
|
|
44
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
45
|
-
};
|
|
46
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
47
|
-
exports.OutputHelper = void 0;
|
|
48
|
-
const prettier = __importStar(require('prettier'));
|
|
49
|
-
const path_1 = __importDefault(require('path'));
|
|
50
|
-
const context_1 = require('../../framework/context');
|
|
51
|
-
const helpers_lib_1 = require('helpers-lib');
|
|
52
|
-
class OutputHelperClass {
|
|
53
|
-
async generateArrayOutput(options) {
|
|
54
|
-
let output = '';
|
|
55
|
-
if (options.preText) {
|
|
56
|
-
output += `${options.preText}\n\n`;
|
|
57
|
-
}
|
|
58
|
-
let assetsReplaceMap;
|
|
59
|
-
if (options.assetUrl) {
|
|
60
|
-
if (!options.filePath) {
|
|
61
|
-
throw new Error('filePath is required when using assetUrl');
|
|
62
|
-
}
|
|
63
|
-
let urls = options.variable.map(item => {
|
|
64
|
-
let url = helpers_lib_1.JsonHelper.deepFind(item, options.assetUrl);
|
|
65
|
-
if (!url) {
|
|
66
|
-
throw new Error(
|
|
67
|
-
`OutputHelperClass: Asset url is not found in the given variable! item: "${JSON.stringify(item)}", assetUrl: "${options.assetUrl}"`
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
return url;
|
|
71
|
-
});
|
|
72
|
-
let assetUrlToNameMap = new Map();
|
|
73
|
-
urls.forEach(url => {
|
|
74
|
-
if (!assetUrlToNameMap.has(url)) {
|
|
75
|
-
let name = `asset${assetUrlToNameMap.size}`;
|
|
76
|
-
assetUrlToNameMap.set(url, name);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
let imports = Array.from(assetUrlToNameMap, ([key, value]) => ({ name: value, url: key }))
|
|
80
|
-
.map(item => `import ${item.name} from '${this.convertToRelativePath(options.filePath, item.url)}';`)
|
|
81
|
-
.join('\n');
|
|
82
|
-
output += imports + '\n\n';
|
|
83
|
-
assetsReplaceMap = urls.reduce((map, url) => [...map, { target: `"${url}"`, replace: assetUrlToNameMap.get(url) }], []);
|
|
84
|
-
}
|
|
85
|
-
if (options.variable.reduce) {
|
|
86
|
-
let content = options.variable.reduce((acc, item, index) => `${acc}${index !== 0 ? ',' : ''}${this.stringify(item)}`, '');
|
|
87
|
-
output += `export const ${options.variableName}: ${options.variableType} = [${content}];`;
|
|
88
|
-
} else {
|
|
89
|
-
console.error(
|
|
90
|
-
`Given variable is not an array, do you mean to use "generateOutput()", for the variable "${options.variableName}"?`
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
if (assetsReplaceMap) {
|
|
94
|
-
output = this.replaceOutput(output, assetsReplaceMap);
|
|
95
|
-
}
|
|
96
|
-
if (options.replaceMap) {
|
|
97
|
-
output = this.replaceOutput(output, options.replaceMap);
|
|
98
|
-
}
|
|
99
|
-
return this.format(output);
|
|
100
|
-
}
|
|
101
|
-
async generateOutput(options) {
|
|
102
|
-
let output = '';
|
|
103
|
-
if (options.preText) {
|
|
104
|
-
output += `${options.preText}\n\n`;
|
|
105
|
-
}
|
|
106
|
-
if (options.variableType) {
|
|
107
|
-
output += `export const ${options.variableName}: ${options.variableType} = ${this.stringify(options.variable)}`;
|
|
108
|
-
} else {
|
|
109
|
-
output += `export const ${options.variableName} = ${this.stringify(options.variable)}`;
|
|
110
|
-
}
|
|
111
|
-
if (options.replaceMap) {
|
|
112
|
-
output = this.replaceOutput(output, options.replaceMap);
|
|
113
|
-
}
|
|
114
|
-
return this.format(output);
|
|
115
|
-
}
|
|
116
|
-
convertToRelativePath(filePath, relativePathFromRoot) {
|
|
117
|
-
let fromPath = context_1.Context.outputPath + filePath.substring(0, filePath.lastIndexOf('/'));
|
|
118
|
-
let toPath = context_1.Context.config.projectRoot + relativePathFromRoot.substring(1);
|
|
119
|
-
return path_1.default.relative(fromPath, toPath).replace(/\\/g, '/');
|
|
120
|
-
}
|
|
121
|
-
replaceOutput(output, replaceMap) {
|
|
122
|
-
replaceMap.forEach(item => {
|
|
123
|
-
output = output.replace(new RegExp(item.target, 'g'), item.replace);
|
|
124
|
-
});
|
|
125
|
-
return output;
|
|
126
|
-
}
|
|
127
|
-
async format(str) {
|
|
128
|
-
return prettier.format(str, {
|
|
129
|
-
parser: 'typescript',
|
|
130
|
-
trailingComma: 'none',
|
|
131
|
-
tabWidth: 2,
|
|
132
|
-
printWidth: 130,
|
|
133
|
-
singleQuote: true,
|
|
134
|
-
arrowParens: 'avoid'
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
stringify(obj) {
|
|
138
|
-
// eslint-disable-next-line no-null/no-null
|
|
139
|
-
return JSON.stringify(obj, (k, v) => (v === undefined ? null : v)).replace(/null/gm, 'undefined');
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
exports.OutputHelper = new OutputHelperClass();
|
|
143
|
-
//# sourceMappingURL=output-helper.js.map
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,261 +0,0 @@
|
|
|
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({
|
|
173
|
-
variableName: 'Groups',
|
|
174
|
-
variableType: 'any[]',
|
|
175
|
-
variable: []
|
|
176
|
-
});
|
|
177
|
-
expect(output).toStrictEqual(emptyArrayExpected);
|
|
178
|
-
});
|
|
179
|
-
test('should handle basic array', async () => {
|
|
180
|
-
let output = await output_helper_1.OutputHelper.generateArrayOutput({
|
|
181
|
-
variableName: 'Groups',
|
|
182
|
-
variableType: 'any[]',
|
|
183
|
-
variable: [
|
|
184
|
-
{ name: 'test1', source: './src/definitions-sample/images/test1.png' },
|
|
185
|
-
{ name: 'test2', source: './src/definitions-sample/images/test2.png', pixelPerfectInteraction: true }
|
|
186
|
-
]
|
|
187
|
-
});
|
|
188
|
-
expect(output).toStrictEqual(basicArrayExpected);
|
|
189
|
-
});
|
|
190
|
-
test('should handle complex array', async () => {
|
|
191
|
-
let output = await output_helper_1.OutputHelper.generateArrayOutput({
|
|
192
|
-
variableName: 'Groups',
|
|
193
|
-
variableType: 'any[]',
|
|
194
|
-
variable: [complexObject]
|
|
195
|
-
});
|
|
196
|
-
expect(output).toStrictEqual(complexArrayExpected);
|
|
197
|
-
});
|
|
198
|
-
test('should handle replacing complex array', async () => {
|
|
199
|
-
let output = await output_helper_1.OutputHelper.generateArrayOutput({
|
|
200
|
-
variableName: 'Groups',
|
|
201
|
-
variableType: 'any[]',
|
|
202
|
-
variable: [complexObject],
|
|
203
|
-
replaceMap: [{ target: `"DiceType.d6"`, replace: 'DiceType.d6' }]
|
|
204
|
-
});
|
|
205
|
-
expect(output).toStrictEqual(complexArrayReplaceExpected);
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
describe('Output Helper: Const Output', () => {
|
|
209
|
-
test('should handle no type', async () => {
|
|
210
|
-
let output = await output_helper_1.OutputHelper.generateOutput({ variableName: 'ConstSample', variable: { type: 'item' } });
|
|
211
|
-
expect(output).toStrictEqual(noTypeExpected);
|
|
212
|
-
});
|
|
213
|
-
test('should handle basic value', async () => {
|
|
214
|
-
let output = await output_helper_1.OutputHelper.generateOutput({
|
|
215
|
-
variableName: 'ConstSample',
|
|
216
|
-
variableType: 'string',
|
|
217
|
-
variable: 'basic'
|
|
218
|
-
});
|
|
219
|
-
expect(output).toStrictEqual(basicConstExpected);
|
|
220
|
-
});
|
|
221
|
-
test('should handle complex object', async () => {
|
|
222
|
-
let output = await output_helper_1.OutputHelper.generateOutput({
|
|
223
|
-
variableName: 'ConstSample',
|
|
224
|
-
variableType: 'any',
|
|
225
|
-
variable: complexObject
|
|
226
|
-
});
|
|
227
|
-
expect(output).toStrictEqual(complexConstExpected);
|
|
228
|
-
});
|
|
229
|
-
test('should handle replacing complex object', async () => {
|
|
230
|
-
let output = await output_helper_1.OutputHelper.generateOutput({
|
|
231
|
-
variableName: 'ConstSample',
|
|
232
|
-
variableType: 'any',
|
|
233
|
-
variable: complexObject,
|
|
234
|
-
replaceMap: [{ target: `"WeaponRange.ranged"`, replace: 'WeaponRange' }]
|
|
235
|
-
});
|
|
236
|
-
expect(output).toStrictEqual(complexConstReplaceExpected);
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
describe('Output Helper: stringify', () => {
|
|
240
|
-
test('should not lose properties with undefined or null value', async () => {
|
|
241
|
-
let output = await output_helper_1.OutputHelper['stringify']({
|
|
242
|
-
a: undefined,
|
|
243
|
-
// eslint-disable-next-line no-null/no-null
|
|
244
|
-
b: null
|
|
245
|
-
});
|
|
246
|
-
expect(output).toStrictEqual('{"a":undefined,"b":undefined}');
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
describe('Output Helper: convertToRelativePath', () => {
|
|
250
|
-
test('should convert to relative path', async () => {
|
|
251
|
-
(0, mocks_1.resetContext)();
|
|
252
|
-
context_1.Context.outputPath = 'D:/Projects/Game-Dev/Starfighter/Starfighter-Definitions-Generator/src/.asset-build';
|
|
253
|
-
context_1.Context.config.projectRoot = 'D:/Projects/Game-Dev/Starfighter/Starfighter-Definitions-Generator/';
|
|
254
|
-
let original = '.src/definitions-sample/images/nested/test2.png';
|
|
255
|
-
let desired = '../../../definitions-sample/images/nested/test2.png';
|
|
256
|
-
let filePath = '/0-global-definitions/assets/images.ts';
|
|
257
|
-
let output = output_helper_1.OutputHelper['convertToRelativePath'](filePath, original);
|
|
258
|
-
expect(output).toStrictEqual(desired);
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
//# sourceMappingURL=output-helper.spec.js.map
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
};
|