definition-generator-framework 1.13.1 → 2.0.0-rc0
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 +198 -0
- package/dist/index.d.ts +198 -17
- package/dist/index.js +43 -50
- package/dist/index.mjs +43 -0
- package/package.json +27 -13
- 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,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefinitionStore = void 0;
|
|
4
|
-
const helpers_lib_1 = require("helpers-lib");
|
|
5
|
-
const raw_definition_helper_1 = require("../helpers/raw-definition-helper/raw-definition.helper");
|
|
6
|
-
class DefinitionStore {
|
|
7
|
-
static { this.idToRawDefinitionsMap = new Map(); }
|
|
8
|
-
static { this.definitionToRawDefinitionsMap = new Map(); }
|
|
9
|
-
static { this.definitionsMap = new Map(); }
|
|
10
|
-
static { this.componentNameToComponentMap = new Map(); }
|
|
11
|
-
static getDefinitions(definitionClass) {
|
|
12
|
-
let classMap = this.definitionsMap.get(this.getComponentName(definitionClass));
|
|
13
|
-
if (classMap) {
|
|
14
|
-
return Array.from(classMap.values());
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
static getDefinition(definitionClass, key) {
|
|
21
|
-
if (!definitionClass.$meta.keyName) {
|
|
22
|
-
throw new Error(`"${definitionClass.name}" doesn't have a keyName, getDefinition cannot be called on it.`);
|
|
23
|
-
}
|
|
24
|
-
return this.definitionsMap.get(this.getComponentName(definitionClass))?.get(key);
|
|
25
|
-
}
|
|
26
|
-
static getDefinitionOrFail(definitionClass, key) {
|
|
27
|
-
let definition = this.getDefinition(definitionClass, key);
|
|
28
|
-
if (!definition) {
|
|
29
|
-
throw new Error(`No result found for "${key}" in "${definitionClass.name}".`);
|
|
30
|
-
}
|
|
31
|
-
return definition;
|
|
32
|
-
}
|
|
33
|
-
static getSingletonDefinition(definitionClass) {
|
|
34
|
-
return this.definitionsMap.get(this.getComponentName(definitionClass))?.get(this.getComponentName(definitionClass));
|
|
35
|
-
}
|
|
36
|
-
static getSingletonDefinitionOrFail(definitionClass) {
|
|
37
|
-
let definition = this.getSingletonDefinition(definitionClass);
|
|
38
|
-
if (!definition) {
|
|
39
|
-
throw new Error(`No result found for "${definitionClass.name}".`);
|
|
40
|
-
}
|
|
41
|
-
return definition;
|
|
42
|
-
}
|
|
43
|
-
static getLocationInFile(definitionClass, definition, path) {
|
|
44
|
-
let rawDefinition = this.definitionToRawDefinitionsMap.get(definitionClass.name)?.get(definition);
|
|
45
|
-
if (!rawDefinition) {
|
|
46
|
-
throw new Error(`No raw definition found for "${definition}" in "${definitionClass.name}".`);
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
line: raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, path),
|
|
50
|
-
path: rawDefinition.location.path
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
static getLocationInFileById(definitionClass, key, path) {
|
|
54
|
-
let rawDefinition = this.getRawDefinition(definitionClass, key);
|
|
55
|
-
if (!rawDefinition) {
|
|
56
|
-
throw new Error(`No raw definition found for "${key}" in "${definitionClass.name}".`);
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
line: raw_definition_helper_1.RawDefinitionHelper.findLine(rawDefinition, path),
|
|
60
|
-
path: rawDefinition.location.path
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
static isValidComponentName(componentName) {
|
|
64
|
-
return this.definitionsMap.has(componentName);
|
|
65
|
-
}
|
|
66
|
-
static getComponentClass(componentName) {
|
|
67
|
-
let componentClass = this.componentNameToComponentMap.get(componentName);
|
|
68
|
-
if (!componentClass) {
|
|
69
|
-
throw new Error(`No component found for "${componentName}".`);
|
|
70
|
-
}
|
|
71
|
-
return componentClass;
|
|
72
|
-
}
|
|
73
|
-
static setComponents(componentNameToComponentMap) {
|
|
74
|
-
componentNameToComponentMap.forEach((_, componentName) => {
|
|
75
|
-
this.definitionsMap.set(componentName, new Map());
|
|
76
|
-
});
|
|
77
|
-
this.componentNameToComponentMap = componentNameToComponentMap;
|
|
78
|
-
}
|
|
79
|
-
static setDefinition(definitionClass, key, definition) {
|
|
80
|
-
let classMap = this.definitionsMap.get(this.getComponentName(definitionClass));
|
|
81
|
-
if (classMap) {
|
|
82
|
-
classMap.set(key, helpers_lib_1.JsonHelper.deepCopy(definition));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
static setSingletonDefinition(definitionClass, definition) {
|
|
86
|
-
let componentName = this.getComponentName(definitionClass);
|
|
87
|
-
let classMap = this.definitionsMap.get(componentName);
|
|
88
|
-
if (classMap) {
|
|
89
|
-
classMap.set(componentName, helpers_lib_1.JsonHelper.deepCopy(definition));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
static isRawDefinitionExists(definitionClass, key) {
|
|
93
|
-
return this.idToRawDefinitionsMap.get(definitionClass.name)?.has(key) ? true : false;
|
|
94
|
-
}
|
|
95
|
-
static getRawDefinition(definitionClass, key) {
|
|
96
|
-
return this.idToRawDefinitionsMap.get(definitionClass.name)?.get(key);
|
|
97
|
-
}
|
|
98
|
-
static setRawDefinitionByKey(definitionClass, key, rawDefinition) {
|
|
99
|
-
if (!this.idToRawDefinitionsMap.has(definitionClass.name)) {
|
|
100
|
-
this.idToRawDefinitionsMap.set(definitionClass.name, new Map());
|
|
101
|
-
}
|
|
102
|
-
let classMap = this.idToRawDefinitionsMap.get(definitionClass.name);
|
|
103
|
-
if (classMap) {
|
|
104
|
-
classMap.set(key, helpers_lib_1.JsonHelper.deepCopy(rawDefinition));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
static setRawDefinition(definitionClass, definition, rawDefinition) {
|
|
108
|
-
if (!this.definitionToRawDefinitionsMap.has(definitionClass.name)) {
|
|
109
|
-
this.definitionToRawDefinitionsMap.set(definitionClass.name, new Map());
|
|
110
|
-
}
|
|
111
|
-
let classMap = this.definitionToRawDefinitionsMap.get(definitionClass.name);
|
|
112
|
-
if (classMap) {
|
|
113
|
-
classMap.set(definition, helpers_lib_1.JsonHelper.deepCopy(rawDefinition));
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
static getComponentName(definitionClass) {
|
|
117
|
-
return definitionClass.$meta.componentName;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.DefinitionStore = DefinitionStore;
|
|
121
|
-
//# sourceMappingURL=definition-store.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare class FileContentGenerator {
|
|
2
|
-
static generate(options: {
|
|
3
|
-
preText?: string;
|
|
4
|
-
variableName: string;
|
|
5
|
-
variableType?: string;
|
|
6
|
-
variable: any;
|
|
7
|
-
replaceMap?: {
|
|
8
|
-
target: string;
|
|
9
|
-
replace: string;
|
|
10
|
-
}[];
|
|
11
|
-
filePath?: string;
|
|
12
|
-
assetUrl?: string;
|
|
13
|
-
}): Promise<string>;
|
|
14
|
-
static format(str: string): Promise<string>;
|
|
15
|
-
private static convertToRelativePath;
|
|
16
|
-
private static replaceOutput;
|
|
17
|
-
private static convertAssetUrls;
|
|
18
|
-
private static stringify;
|
|
19
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.FileContentGenerator = void 0;
|
|
30
|
-
const helpers_lib_1 = require("helpers-lib");
|
|
31
|
-
const path_1 = __importDefault(require("path"));
|
|
32
|
-
const ESTree = __importStar(require("prettier/plugins/estree"));
|
|
33
|
-
const TsParser = __importStar(require("prettier/plugins/typescript"));
|
|
34
|
-
const standalone_1 = require("prettier/standalone");
|
|
35
|
-
const context_1 = require("../context");
|
|
36
|
-
class FileContentGenerator {
|
|
37
|
-
static generate(options) {
|
|
38
|
-
let output = '';
|
|
39
|
-
if (options.preText) {
|
|
40
|
-
output += `${options.preText}\n\n`;
|
|
41
|
-
}
|
|
42
|
-
let assetsReplaceMap;
|
|
43
|
-
if (options.assetUrl) {
|
|
44
|
-
if (!options.filePath) {
|
|
45
|
-
throw new Error('filePath is required when using assetUrl');
|
|
46
|
-
}
|
|
47
|
-
if (!helpers_lib_1.Comparator.isArray(options.variable)) {
|
|
48
|
-
throw new Error('variable should be an array when using assetUrl');
|
|
49
|
-
}
|
|
50
|
-
let { assetImports, replaceMap } = this.convertAssetUrls(options.variable, options.assetUrl, options.filePath);
|
|
51
|
-
output += assetImports + '\n\n';
|
|
52
|
-
assetsReplaceMap = replaceMap;
|
|
53
|
-
}
|
|
54
|
-
if (options.variableType) {
|
|
55
|
-
output += `export const ${options.variableName}: ${options.variableType} = ${this.stringify(options.variable)}`;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
output += `export const ${options.variableName} = ${this.stringify(options.variable)}`;
|
|
59
|
-
}
|
|
60
|
-
if (assetsReplaceMap) {
|
|
61
|
-
output = this.replaceOutput(output, assetsReplaceMap);
|
|
62
|
-
}
|
|
63
|
-
if (options.replaceMap) {
|
|
64
|
-
output = this.replaceOutput(output, options.replaceMap);
|
|
65
|
-
}
|
|
66
|
-
return this.format(output);
|
|
67
|
-
}
|
|
68
|
-
static async format(str) {
|
|
69
|
-
return (0, standalone_1.format)(str, {
|
|
70
|
-
parser: 'typescript',
|
|
71
|
-
trailingComma: 'none',
|
|
72
|
-
tabWidth: 2,
|
|
73
|
-
printWidth: 130,
|
|
74
|
-
singleQuote: true,
|
|
75
|
-
arrowParens: 'avoid',
|
|
76
|
-
plugins: [TsParser, ESTree]
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
static convertToRelativePath(filePath, relativePathFromRoot) {
|
|
80
|
-
let fromPath = context_1.Context.outputPath + filePath.substring(0, filePath.lastIndexOf('/'));
|
|
81
|
-
let toPath = context_1.Context.config.projectRoot + relativePathFromRoot.substring(1);
|
|
82
|
-
return path_1.default.relative(fromPath, toPath).replace(/\\/g, '/');
|
|
83
|
-
}
|
|
84
|
-
static replaceOutput(output, replaceMap) {
|
|
85
|
-
replaceMap.forEach(item => {
|
|
86
|
-
output = output.replace(new RegExp(item.target, 'g'), item.replace);
|
|
87
|
-
});
|
|
88
|
-
return output;
|
|
89
|
-
}
|
|
90
|
-
static convertAssetUrls(variable, assetUrl, filePath) {
|
|
91
|
-
let urls = variable.map(item => {
|
|
92
|
-
let url = helpers_lib_1.JsonHelper.deepFind(item, assetUrl);
|
|
93
|
-
if (!url) {
|
|
94
|
-
throw new Error(`OutputHelperClass: Asset url is not found in the given variable! item: "${JSON.stringify(item)}", assetUrl: "${assetUrl}"`);
|
|
95
|
-
}
|
|
96
|
-
return url;
|
|
97
|
-
});
|
|
98
|
-
let assetUrlToNameMap = new Map();
|
|
99
|
-
urls.forEach(url => {
|
|
100
|
-
if (!assetUrlToNameMap.has(url)) {
|
|
101
|
-
let name = `asset${assetUrlToNameMap.size}`;
|
|
102
|
-
assetUrlToNameMap.set(url, name);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
let assetImports = Array.from(assetUrlToNameMap, ([key, value]) => ({ name: value, url: key }))
|
|
106
|
-
.map(item => `import ${item.name} from '${this.convertToRelativePath(filePath, item.url)}';`)
|
|
107
|
-
.join('\n');
|
|
108
|
-
let replaceMap = urls.reduce((map, url) => [...map, { target: `"${url}"`, replace: assetUrlToNameMap.get(url) }], []);
|
|
109
|
-
return { assetImports, replaceMap };
|
|
110
|
-
}
|
|
111
|
-
static stringify(obj) {
|
|
112
|
-
// biome-ignore lint:all
|
|
113
|
-
return JSON.stringify(obj, (k, v) => (v === undefined ? null : v)).replace(/null/gm, 'undefined');
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
exports.FileContentGenerator = FileContentGenerator;
|
|
117
|
-
//# sourceMappingURL=file-content-generator.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,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Const = void 0;
|
|
4
|
-
const vitest_1 = require("vitest");
|
|
5
|
-
const mocks_1 = require("../../_mocks/mocks");
|
|
6
|
-
const context_1 = require("../context");
|
|
7
|
-
const file_content_generator_1 = require("./file-content-generator");
|
|
8
|
-
let complexObject = {
|
|
9
|
-
type: 'bow',
|
|
10
|
-
material: 'WoodenItemMaterial',
|
|
11
|
-
maxQuantity: 10,
|
|
12
|
-
mainHand: undefined,
|
|
13
|
-
offHand: undefined,
|
|
14
|
-
bothHands: {
|
|
15
|
-
imageOnCharacter: 'BodyPartImageNames',
|
|
16
|
-
parryDice: undefined,
|
|
17
|
-
attacks: [
|
|
18
|
-
{
|
|
19
|
-
actionIcon: 'AssetNames.characterActionBowAttack',
|
|
20
|
-
attackDices: ['DiceType.d6', 'DiceType.d6'],
|
|
21
|
-
range: 'WeaponRange.ranged',
|
|
22
|
-
requiresSetup: false,
|
|
23
|
-
unparryable: true,
|
|
24
|
-
lowersQuantity: true,
|
|
25
|
-
projectileType: 'ProjectileType.arrow',
|
|
26
|
-
sounds: {
|
|
27
|
-
hit: 'AssetGroups.battleSoundArrowHit',
|
|
28
|
-
pre: 'AssetGroups.battleSoundArrowShot'
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
exports.Const = {
|
|
35
|
-
type: 'bow',
|
|
36
|
-
material: 'WoodenItemMaterial',
|
|
37
|
-
maxQuantity: 10,
|
|
38
|
-
mainHand: undefined,
|
|
39
|
-
offHand: undefined,
|
|
40
|
-
bothHands: {
|
|
41
|
-
imageOnCharacter: 'BodyPartImageNames',
|
|
42
|
-
parryDice: undefined,
|
|
43
|
-
attacks: [
|
|
44
|
-
{
|
|
45
|
-
actionIcon: 'AssetNames.characterActionBowAttack',
|
|
46
|
-
attackDices: ['DiceType.d6', 'DiceType.d6'],
|
|
47
|
-
range: 'WeaponRange.ranged',
|
|
48
|
-
requiresSetup: false,
|
|
49
|
-
unparryable: true,
|
|
50
|
-
lowersQuantity: true,
|
|
51
|
-
projectileType: 'ProjectileType.arrow',
|
|
52
|
-
sounds: {
|
|
53
|
-
hit: 'AssetGroups.battleSoundArrowHit',
|
|
54
|
-
pre: 'AssetGroups.battleSoundArrowShot'
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
]
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
let noTypeExpected = `export const ConstSample = { type: 'item' };
|
|
61
|
-
`;
|
|
62
|
-
let basicConstExpected = `export const ConstSample: string = 'basic';
|
|
63
|
-
`;
|
|
64
|
-
let complexConstExpected = `export const ConstSample: any = {
|
|
65
|
-
type: 'bow',
|
|
66
|
-
material: 'WoodenItemMaterial',
|
|
67
|
-
maxQuantity: 10,
|
|
68
|
-
mainHand: undefined,
|
|
69
|
-
offHand: undefined,
|
|
70
|
-
bothHands: {
|
|
71
|
-
imageOnCharacter: 'BodyPartImageNames',
|
|
72
|
-
parryDice: undefined,
|
|
73
|
-
attacks: [
|
|
74
|
-
{
|
|
75
|
-
actionIcon: 'AssetNames.characterActionBowAttack',
|
|
76
|
-
attackDices: ['DiceType.d6', 'DiceType.d6'],
|
|
77
|
-
range: 'WeaponRange.ranged',
|
|
78
|
-
requiresSetup: false,
|
|
79
|
-
unparryable: true,
|
|
80
|
-
lowersQuantity: true,
|
|
81
|
-
projectileType: 'ProjectileType.arrow',
|
|
82
|
-
sounds: { hit: 'AssetGroups.battleSoundArrowHit', pre: 'AssetGroups.battleSoundArrowShot' }
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
`;
|
|
88
|
-
let complexConstReplaceExpected = `export const ConstSample: any = {
|
|
89
|
-
type: 'bow',
|
|
90
|
-
material: 'WoodenItemMaterial',
|
|
91
|
-
maxQuantity: 10,
|
|
92
|
-
mainHand: undefined,
|
|
93
|
-
offHand: undefined,
|
|
94
|
-
bothHands: {
|
|
95
|
-
imageOnCharacter: 'BodyPartImageNames',
|
|
96
|
-
parryDice: undefined,
|
|
97
|
-
attacks: [
|
|
98
|
-
{
|
|
99
|
-
actionIcon: 'AssetNames.characterActionBowAttack',
|
|
100
|
-
attackDices: ['DiceType.d6', 'DiceType.d6'],
|
|
101
|
-
range: WeaponRange,
|
|
102
|
-
requiresSetup: false,
|
|
103
|
-
unparryable: true,
|
|
104
|
-
lowersQuantity: true,
|
|
105
|
-
projectileType: 'ProjectileType.arrow',
|
|
106
|
-
sounds: { hit: 'AssetGroups.battleSoundArrowHit', pre: 'AssetGroups.battleSoundArrowShot' }
|
|
107
|
-
}
|
|
108
|
-
]
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
`;
|
|
112
|
-
(0, vitest_1.describe)('File Content Generator: Const Output', () => {
|
|
113
|
-
(0, vitest_1.test)('should handle no type', async () => {
|
|
114
|
-
let output = await file_content_generator_1.FileContentGenerator.generate({ variableName: 'ConstSample', variable: { type: 'item' } });
|
|
115
|
-
(0, vitest_1.expect)(output).toStrictEqual(noTypeExpected);
|
|
116
|
-
});
|
|
117
|
-
(0, vitest_1.test)('should handle basic value', async () => {
|
|
118
|
-
let output = await file_content_generator_1.FileContentGenerator.generate({ variableName: 'ConstSample', variableType: 'string', variable: 'basic' });
|
|
119
|
-
(0, vitest_1.expect)(output).toStrictEqual(basicConstExpected);
|
|
120
|
-
});
|
|
121
|
-
(0, vitest_1.test)('should handle complex object', async () => {
|
|
122
|
-
let output = await file_content_generator_1.FileContentGenerator.generate({
|
|
123
|
-
variableName: 'ConstSample',
|
|
124
|
-
variableType: 'any',
|
|
125
|
-
variable: complexObject
|
|
126
|
-
});
|
|
127
|
-
(0, vitest_1.expect)(output).toStrictEqual(complexConstExpected);
|
|
128
|
-
});
|
|
129
|
-
(0, vitest_1.test)('should handle replacing complex object', async () => {
|
|
130
|
-
let output = await file_content_generator_1.FileContentGenerator.generate({
|
|
131
|
-
variableName: 'ConstSample',
|
|
132
|
-
variableType: 'any',
|
|
133
|
-
variable: complexObject,
|
|
134
|
-
replaceMap: [{ target: `"WeaponRange.ranged"`, replace: 'WeaponRange' }]
|
|
135
|
-
});
|
|
136
|
-
(0, vitest_1.expect)(output).toStrictEqual(complexConstReplaceExpected);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
(0, vitest_1.describe)('File Content Generator: stringify', () => {
|
|
140
|
-
(0, vitest_1.test)('should not lose properties with undefined or null value', async () => {
|
|
141
|
-
let output = await file_content_generator_1.FileContentGenerator['stringify']({
|
|
142
|
-
a: undefined,
|
|
143
|
-
// biome-ignore lint:all
|
|
144
|
-
b: null
|
|
145
|
-
});
|
|
146
|
-
(0, vitest_1.expect)(output).toStrictEqual('{"a":undefined,"b":undefined}');
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
(0, vitest_1.describe)('File Content Generator: convertToRelativePath', () => {
|
|
150
|
-
(0, vitest_1.test)('should convert to relative path', async () => {
|
|
151
|
-
(0, mocks_1.resetContext)();
|
|
152
|
-
context_1.Context.outputPath = 'D:/Projects/Game-Dev/Starfighter/Starfighter-Definitions-Generator/src/.asset-build';
|
|
153
|
-
context_1.Context.config.projectRoot = 'D:/Projects/Game-Dev/Starfighter/Starfighter-Definitions-Generator/';
|
|
154
|
-
let original = '.src/definitions-sample/images/nested/test2.png';
|
|
155
|
-
let desired = '../../../definitions-sample/images/nested/test2.png';
|
|
156
|
-
let filePath = '/0-global-definitions/assets/images.ts';
|
|
157
|
-
let output = file_content_generator_1.FileContentGenerator['convertToRelativePath'](filePath, original);
|
|
158
|
-
(0, vitest_1.expect)(output).toStrictEqual(desired);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
//# sourceMappingURL=file-content-generator.test.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare class IndexFileGenerator {
|
|
2
|
-
private static premadeInterfaces;
|
|
3
|
-
private static idTypes;
|
|
4
|
-
static addPremadeInterface(value: string): void;
|
|
5
|
-
static addIdType(constantName: string, keys: string[]): void;
|
|
6
|
-
static generateFile(pretext: string, outputIndexFile: string): Promise<void>;
|
|
7
|
-
private static createIndexFile;
|
|
8
|
-
private static generateFileDevMode;
|
|
9
|
-
private static generateExportsContent;
|
|
10
|
-
private static generateInterfacesContent;
|
|
11
|
-
private static getInterfacesFromFile;
|
|
12
|
-
static generateTypes(): string;
|
|
13
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.IndexFileGenerator = void 0;
|
|
27
|
-
const fs = __importStar(require("fs"));
|
|
28
|
-
const glob = __importStar(require("glob"));
|
|
29
|
-
const helpers_lib_1 = require("helpers-lib");
|
|
30
|
-
const context_1 = require("../context");
|
|
31
|
-
const file_content_generator_1 = require("../file-content-generator/file-content-generator");
|
|
32
|
-
const START_COMMAND = '// ---- INDEX OUTPUT ----';
|
|
33
|
-
const END_COMMAND = '// ---- END ----';
|
|
34
|
-
class IndexFileGenerator {
|
|
35
|
-
static { this.premadeInterfaces = []; }
|
|
36
|
-
static { this.idTypes = []; }
|
|
37
|
-
static addPremadeInterface(value) {
|
|
38
|
-
this.premadeInterfaces.push(value);
|
|
39
|
-
}
|
|
40
|
-
static addIdType(constantName, keys) {
|
|
41
|
-
let value = `export type ${constantName}ID = ${keys.map(key => `'${key}'`).join(' | ')};`;
|
|
42
|
-
this.idTypes.push(value);
|
|
43
|
-
}
|
|
44
|
-
static async generateFile(pretext, outputIndexFile) {
|
|
45
|
-
if (context_1.Context.config.compilerModulesPath) {
|
|
46
|
-
let content = await this.generateFileDevMode(pretext);
|
|
47
|
-
if (content) {
|
|
48
|
-
await this.createIndexFile(content);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
await this.createIndexFile(outputIndexFile);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
static async createIndexFile(outputIndexFile) {
|
|
56
|
-
let outputContent = outputIndexFile;
|
|
57
|
-
let typesContent = this.generateTypes();
|
|
58
|
-
if (typesContent) {
|
|
59
|
-
outputContent += '\n\n' + typesContent;
|
|
60
|
-
}
|
|
61
|
-
context_1.Context.output.push({
|
|
62
|
-
path: '/index.ts',
|
|
63
|
-
content: await file_content_generator_1.FileContentGenerator.format(outputContent)
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
static async generateFileDevMode(pretext) {
|
|
67
|
-
let fileUrls = glob.sync(`${context_1.Context.config.compilerModulesPath}/**/*.ts`).map(filePath => filePath.replace(/\\/g, '/'));
|
|
68
|
-
if (fileUrls.length === 0) {
|
|
69
|
-
helpers_lib_1.ConsoleHelper.log(`No typescript file found to generate index.ts file.`, 'red');
|
|
70
|
-
}
|
|
71
|
-
let exportsContent = this.generateExportsContent();
|
|
72
|
-
let interfacesContent = await this.generateInterfacesContent(fileUrls);
|
|
73
|
-
if (interfacesContent !== undefined) {
|
|
74
|
-
let output = `${pretext}\n${exportsContent}\n\n${interfacesContent}`;
|
|
75
|
-
output = await file_content_generator_1.FileContentGenerator.format(output);
|
|
76
|
-
fs.writeFileSync(`${context_1.Context.compilerExecutionPath}/output-index-file.ts`, `// AUTO GENERATED - CHANGES WILL BE REPLACED\nexport const OutputIndexFile = \`${output}\`;\n`);
|
|
77
|
-
helpers_lib_1.ConsoleHelper.log(`Index content 'output-index-file.ts' is generated.`, 'green');
|
|
78
|
-
return output;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
static generateExportsContent() {
|
|
82
|
-
return context_1.Context.exports
|
|
83
|
-
.map(exportItem => `export { ${exportItem.variableName} } from '.${exportItem.path.substring(0, exportItem.path.lastIndexOf('.'))}';`)
|
|
84
|
-
.join('\n');
|
|
85
|
-
}
|
|
86
|
-
static async generateInterfacesContent(fileUrls) {
|
|
87
|
-
let errorCount = 0;
|
|
88
|
-
let outputs = [];
|
|
89
|
-
fileUrls.forEach(fileUrl => {
|
|
90
|
-
let fileName = fileUrl.substring(fileUrl.lastIndexOf('/') + 1, fileUrl.lastIndexOf('.'));
|
|
91
|
-
let fileContent = fs.readFileSync(fileUrl, 'utf-8');
|
|
92
|
-
try {
|
|
93
|
-
let output = this.getInterfacesFromFile(fileName, fileContent);
|
|
94
|
-
if (output) {
|
|
95
|
-
outputs.push(output);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
errorCount++;
|
|
100
|
-
helpers_lib_1.ConsoleHelper.log(`Error parsing file: ${fileUrl}, error: '${error.message}'`, 'red');
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
let output = `//-------------------------- DEFINITIONS --------------------------\n`;
|
|
104
|
-
if (this.premadeInterfaces.length > 0) {
|
|
105
|
-
output += '// ---- premade ----';
|
|
106
|
-
output += this.premadeInterfaces.join('\n');
|
|
107
|
-
output += '\n\n';
|
|
108
|
-
}
|
|
109
|
-
output += outputs.join('\n');
|
|
110
|
-
return errorCount === 0 ? output : undefined;
|
|
111
|
-
}
|
|
112
|
-
static getInterfacesFromFile(fileName, fileContent) {
|
|
113
|
-
let index = fileContent.indexOf(START_COMMAND);
|
|
114
|
-
let definitionsFound = index !== -1;
|
|
115
|
-
let contents = [];
|
|
116
|
-
while (index !== -1) {
|
|
117
|
-
let endIndex = fileContent.indexOf(END_COMMAND, index);
|
|
118
|
-
if (endIndex === -1) {
|
|
119
|
-
throw new Error(`No end command found.`);
|
|
120
|
-
}
|
|
121
|
-
contents.push(fileContent.substring(fileContent.indexOf('\n', index + START_COMMAND.length) + 1, endIndex));
|
|
122
|
-
index = fileContent.indexOf(START_COMMAND, endIndex);
|
|
123
|
-
}
|
|
124
|
-
if (definitionsFound) {
|
|
125
|
-
return `// ---- ${fileName} ----\n${contents.join('\n')}`;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
static generateTypes() {
|
|
129
|
-
let output = '';
|
|
130
|
-
if (this.idTypes.length > 0) {
|
|
131
|
-
output += `//-------------------------- ID TYPES --------------------------\n`;
|
|
132
|
-
output += this.idTypes.join('\n');
|
|
133
|
-
output += '\n';
|
|
134
|
-
}
|
|
135
|
-
return output;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
exports.IndexFileGenerator = IndexFileGenerator;
|
|
139
|
-
//# sourceMappingURL=index-file-generator.js.map
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TypesFileGenerator = void 0;
|
|
4
|
-
const glob_1 = require("glob");
|
|
5
|
-
const helpers_lib_1 = require("helpers-lib");
|
|
6
|
-
const context_1 = require("../context");
|
|
7
|
-
const file_content_generator_1 = require("../file-content-generator/file-content-generator");
|
|
8
|
-
class TypesFileGenerator {
|
|
9
|
-
static { this.idTypes = []; }
|
|
10
|
-
static addIdType(constantName, keys) {
|
|
11
|
-
let value = `export type ${constantName}ID = ${keys.map(key => `'${key}'`).join(' | ')};`;
|
|
12
|
-
this.idTypes.push(value);
|
|
13
|
-
}
|
|
14
|
-
static async generateFile(pretext) {
|
|
15
|
-
let fileUrls = glob_1.glob.sync(`${context_1.Context.config.compilerModulesPath}/**/*.ts`).map(filePath => filePath.replace(/\\/g, '/'));
|
|
16
|
-
if (fileUrls.length === 0) {
|
|
17
|
-
helpers_lib_1.ConsoleHelper.log(`No typescript file found to generate index.ts file.`, 'red');
|
|
18
|
-
}
|
|
19
|
-
let output = this.generateContent();
|
|
20
|
-
context_1.Context.output.push({
|
|
21
|
-
path: '/types.ts',
|
|
22
|
-
content: await file_content_generator_1.FileContentGenerator.format(output)
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
static generateContent() {
|
|
26
|
-
let output = '';
|
|
27
|
-
if (this.idTypes.length > 0) {
|
|
28
|
-
output += `//-------------------------- ID TYPES --------------------------\n`;
|
|
29
|
-
output += this.idTypes.join('\n');
|
|
30
|
-
}
|
|
31
|
-
return output;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.TypesFileGenerator = TypesFileGenerator;
|
|
35
|
-
//# sourceMappingURL=types-file-generator.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import Joi from 'joi';
|
|
2
|
-
import { Output } from './framework.model';
|
|
3
|
-
export type DefinitionComponentClassType<T> = new (...args: any[]) => DefinitionComponent<T> | SingleDefinitionComponent<T>;
|
|
4
|
-
export interface DefinitionComponentMeta {
|
|
5
|
-
definitionName: string;
|
|
6
|
-
keyName?: string;
|
|
7
|
-
singleton?: boolean;
|
|
8
|
-
validationSchema: Joi.Schema;
|
|
9
|
-
}
|
|
10
|
-
export declare function DefinitionComponentDecorator(
|
|
11
|
-
meta: DefinitionComponentMeta
|
|
12
|
-
): (ComponentClass: DefinitionComponentClassType<any>) => any;
|
|
13
|
-
export declare abstract class DefinitionComponent<T> {
|
|
14
|
-
static getSchema(): Joi.Schema;
|
|
15
|
-
abstract process(definitions: T[], context: Output): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export declare abstract class SingleDefinitionComponent<T> {
|
|
18
|
-
static getSchema(): Joi.Schema;
|
|
19
|
-
abstract process(definitions: T, context: Output): Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
interface DefinitionModuleMeta {
|
|
22
|
-
modules: DefinitionComponentClassType<any>[];
|
|
23
|
-
interfaces: string;
|
|
24
|
-
}
|
|
25
|
-
export declare function DefinitionModuleDecorator(meta: DefinitionModuleMeta): (ModuleClass: DefinitionModuleClassType) => any;
|
|
26
|
-
export type DefinitionModuleClassType = new (...args: any[]) => DefinitionModule;
|
|
27
|
-
export declare abstract class DefinitionModule {}
|
|
28
|
-
export {};
|