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,12 +0,0 @@
|
|
|
1
|
-
import { DefinitionComponentClassType } from '../decorators/definition-component';
|
|
2
|
-
export declare class Kernel {
|
|
3
|
-
static process(components: DefinitionComponentClassType<any>[], indexFilePretext: string, outputIndexFile: string): Promise<void>;
|
|
4
|
-
private static readFiles;
|
|
5
|
-
private static writeFiles;
|
|
6
|
-
private static cleanPath;
|
|
7
|
-
private static removeEmptyFolders;
|
|
8
|
-
private static generateOutputFiles;
|
|
9
|
-
private static iterateOnKeyNames;
|
|
10
|
-
private static registerDefinitions;
|
|
11
|
-
private static getOutputFiles;
|
|
12
|
-
}
|
package/dist/framework/kernel.js
DELETED
|
@@ -1,308 +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.Kernel = void 0;
|
|
27
|
-
const fs = __importStar(require("fs"));
|
|
28
|
-
const glob = __importStar(require("glob"));
|
|
29
|
-
const helpers_lib_1 = require("helpers-lib");
|
|
30
|
-
const path = __importStar(require("path"));
|
|
31
|
-
const custom_validator_helper_1 = require("../helpers/validator/custom-validator-helper/custom-validator.helper");
|
|
32
|
-
const validator_1 = require("../helpers/validator/validator");
|
|
33
|
-
const _3_config_1 = require("../pipeline/3-config");
|
|
34
|
-
const raw_data_parser_1 = require("../pipeline/raw-data-parser");
|
|
35
|
-
const context_1 = require("./context");
|
|
36
|
-
const definition_store_1 = require("./definition-store");
|
|
37
|
-
const index_file_generator_1 = require("./file-generators/index-file-generator");
|
|
38
|
-
const KeyValueRegex = /^[a-z]+([a-zA-Z0-9]+)*$/;
|
|
39
|
-
const HeavySeperator = '======================================================';
|
|
40
|
-
const LightSeperator = '------------------------------------------------------';
|
|
41
|
-
const LocationFileToLink = (location) => location.path.replace(context_1.Context.compilerExecutionPath + '/', '') + ':' + location.line;
|
|
42
|
-
class Kernel {
|
|
43
|
-
static async process(components, indexFilePretext, outputIndexFile) {
|
|
44
|
-
let componentNameToComponentMap = new Map();
|
|
45
|
-
componentNameToComponentMap.set(_3_config_1.ConfigDefinitionComponentName, _3_config_1.Config);
|
|
46
|
-
components.forEach(component => {
|
|
47
|
-
let componentName = component.$meta.componentName;
|
|
48
|
-
if (componentNameToComponentMap.has(componentName)) {
|
|
49
|
-
throw new Error(`Component name "${componentName}" is used more than once.`);
|
|
50
|
-
}
|
|
51
|
-
componentNameToComponentMap.set(componentName, component);
|
|
52
|
-
});
|
|
53
|
-
definition_store_1.DefinitionStore['setComponents'](componentNameToComponentMap);
|
|
54
|
-
helpers_lib_1.ConsoleHelper.log('Compilation is in progress.', 'white');
|
|
55
|
-
this.readFiles();
|
|
56
|
-
let outputFiles = await this.generateOutputFiles(components, indexFilePretext, outputIndexFile);
|
|
57
|
-
this.writeFiles(outputFiles, context_1.Context.outputPath);
|
|
58
|
-
}
|
|
59
|
-
static readFiles() {
|
|
60
|
-
context_1.Context.compilerExecutionPath = path.resolve('./').replace(/\\/g, '/');
|
|
61
|
-
context_1.Context.outputPath = `${context_1.Context.compilerExecutionPath}/.asset-build`;
|
|
62
|
-
context_1.Context.files = glob
|
|
63
|
-
.sync(`${context_1.Context.compilerExecutionPath}/**/*.md`)
|
|
64
|
-
.map(filePath => filePath.replace(/\\/g, '/'))
|
|
65
|
-
.map(filePath => {
|
|
66
|
-
let content = fs.readFileSync(filePath).toString();
|
|
67
|
-
let fileInfo = { path: filePath, content };
|
|
68
|
-
return fileInfo;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
static writeFiles(outputFiles, outputPath) {
|
|
72
|
-
let filesInOutputFolder = new Set();
|
|
73
|
-
glob
|
|
74
|
-
.sync(`${context_1.Context.outputPath}/**/*`, { nodir: true })
|
|
75
|
-
.map(filePath => filePath.replace(/\\/g, '/'))
|
|
76
|
-
.forEach(filePath => {
|
|
77
|
-
filesInOutputFolder.add(filePath);
|
|
78
|
-
});
|
|
79
|
-
outputFiles.forEach(outputFile => {
|
|
80
|
-
outputFile.path = outputPath + outputFile.path;
|
|
81
|
-
filesInOutputFolder.delete(outputFile.path);
|
|
82
|
-
});
|
|
83
|
-
if (context_1.Context.successful) {
|
|
84
|
-
helpers_lib_1.ConsoleHelper.log(HeavySeperator, 'gray');
|
|
85
|
-
helpers_lib_1.ConsoleHelper.log(`Changes:`, 'gray');
|
|
86
|
-
helpers_lib_1.ConsoleHelper.newLine();
|
|
87
|
-
}
|
|
88
|
-
let erasedFileCount = 0;
|
|
89
|
-
if (context_1.Context.successful) {
|
|
90
|
-
filesInOutputFolder.forEach(filePath => {
|
|
91
|
-
erasedFileCount++;
|
|
92
|
-
console.info(`${helpers_lib_1.ConsoleHelper.red}Erasing file:${helpers_lib_1.ConsoleHelper.gray} "${this.cleanPath(filePath)}"${helpers_lib_1.ConsoleHelper.default}`);
|
|
93
|
-
fs.unlinkSync(filePath);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
let modifiedFileCount = 0;
|
|
97
|
-
let createdFileCount = 0;
|
|
98
|
-
outputFiles.forEach(outputFile => {
|
|
99
|
-
let folderPath = outputFile.path.substring(0, outputFile.path.lastIndexOf('/'));
|
|
100
|
-
fs.mkdirSync(folderPath, { recursive: true });
|
|
101
|
-
let exists = fs.existsSync(outputFile.path);
|
|
102
|
-
let content = exists ? fs.readFileSync(outputFile.path).toString() : '';
|
|
103
|
-
if (content !== outputFile.content) {
|
|
104
|
-
if (exists) {
|
|
105
|
-
modifiedFileCount++;
|
|
106
|
-
console.info(`${helpers_lib_1.ConsoleHelper.blue}Modifying file:${helpers_lib_1.ConsoleHelper.gray} "${this.cleanPath(outputFile.path)}"${helpers_lib_1.ConsoleHelper.default}`);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
createdFileCount++;
|
|
110
|
-
console.info(`${helpers_lib_1.ConsoleHelper.cyan}Creating file:${helpers_lib_1.ConsoleHelper.gray} "${this.cleanPath(outputFile.path)}"${helpers_lib_1.ConsoleHelper.default}`);
|
|
111
|
-
}
|
|
112
|
-
fs.writeFileSync(outputFile.path, outputFile.content);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
this.removeEmptyFolders(outputPath);
|
|
116
|
-
if (createdFileCount + modifiedFileCount + erasedFileCount > 0) {
|
|
117
|
-
helpers_lib_1.ConsoleHelper.newLine();
|
|
118
|
-
}
|
|
119
|
-
helpers_lib_1.ConsoleHelper.log(`Created file count: ${createdFileCount}`, 'gray');
|
|
120
|
-
helpers_lib_1.ConsoleHelper.log(`Modified file count: ${modifiedFileCount}`, 'gray');
|
|
121
|
-
helpers_lib_1.ConsoleHelper.log(`Erased file count: ${erasedFileCount}`, 'gray');
|
|
122
|
-
helpers_lib_1.ConsoleHelper.log(HeavySeperator, 'gray');
|
|
123
|
-
if (context_1.Context.successful) {
|
|
124
|
-
helpers_lib_1.ConsoleHelper.log(`Compilation is completed successfuly!`, 'green');
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
helpers_lib_1.ConsoleHelper.log(`Compilation encountered errors!`, 'red');
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
static cleanPath(path) {
|
|
131
|
-
let startPathsFrom = context_1.Context.compilerExecutionPath.length;
|
|
132
|
-
return path.substring(startPathsFrom); // .replace(/\//g, '\\');
|
|
133
|
-
}
|
|
134
|
-
static removeEmptyFolders(dir) {
|
|
135
|
-
let files = fs.readdirSync(dir);
|
|
136
|
-
let isEmpty = true;
|
|
137
|
-
for (let file of files) {
|
|
138
|
-
let fullPath = path.join(dir, file);
|
|
139
|
-
if (fs.statSync(fullPath).isDirectory()) {
|
|
140
|
-
let isSubDirEmpty = this.removeEmptyFolders(fullPath);
|
|
141
|
-
if (isSubDirEmpty) {
|
|
142
|
-
fs.rmdirSync(fullPath);
|
|
143
|
-
console.info(`${helpers_lib_1.ConsoleHelper.red}Erasing folder:${helpers_lib_1.ConsoleHelper.gray} "${fullPath.substring(dir.length).replace(/\\/g, '/')}"${helpers_lib_1.ConsoleHelper.default}`);
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
isEmpty = false;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
isEmpty = false;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return isEmpty;
|
|
154
|
-
}
|
|
155
|
-
static async generateOutputFiles(modules, indexFilePretext, outputIndexFile) {
|
|
156
|
-
raw_data_parser_1.RawDataParser.process();
|
|
157
|
-
context_1.Context.flushErrorLogs();
|
|
158
|
-
let preparedItems = modules.map(ModuleClass => {
|
|
159
|
-
let meta = ModuleClass.$meta;
|
|
160
|
-
context_1.Context.componentInProgressData = {
|
|
161
|
-
meta,
|
|
162
|
-
idToReferencesMap: new Map()
|
|
163
|
-
};
|
|
164
|
-
let output = {
|
|
165
|
-
addFile: (request) => context_1.Context.addFile(request),
|
|
166
|
-
addError: (errorLog) => context_1.Context.addErrorLog(errorLog),
|
|
167
|
-
convertLocationInFileToLink: (location) => LocationFileToLink(location)
|
|
168
|
-
};
|
|
169
|
-
this.iterateOnKeyNames(meta.keyName, meta.componentName, ModuleClass);
|
|
170
|
-
let definitionToProcess;
|
|
171
|
-
if (meta.singleton) {
|
|
172
|
-
let validatedItem = validator_1.Validator.validateAndConvertSingular(meta.componentName, meta.validationSchema);
|
|
173
|
-
if (validatedItem) {
|
|
174
|
-
definitionToProcess = validatedItem.definition;
|
|
175
|
-
definition_store_1.DefinitionStore['setRawDefinition'](ModuleClass, validatedItem.definition, validatedItem.rawDefinition);
|
|
176
|
-
definition_store_1.DefinitionStore['setSingletonDefinition'](ModuleClass, definitionToProcess);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
let validatedItems = validator_1.Validator.validateAndConvert(meta.componentName, meta.validationSchema);
|
|
181
|
-
// Remove the definitions if there are lazy references that has been invalid
|
|
182
|
-
if (context_1.Context.componentInProgressData.idToReferencesMap.size > 0) {
|
|
183
|
-
let keyName = meta.keyName;
|
|
184
|
-
if (!keyName) {
|
|
185
|
-
throw new Error('Unexpected Error: KeyName should be defined for lazy references.');
|
|
186
|
-
}
|
|
187
|
-
let idToReferencesMap = context_1.Context.componentInProgressData.idToReferencesMap;
|
|
188
|
-
let runTheLoop = true;
|
|
189
|
-
while (runTheLoop) {
|
|
190
|
-
let validatedItemCount = validatedItems.length;
|
|
191
|
-
let validatedItemIds = new Set(validatedItems.map(validatedItem => validatedItem.definition[keyName]));
|
|
192
|
-
validatedItems = validatedItems.filter(validatedItem => {
|
|
193
|
-
let id = validatedItem.definition[keyName];
|
|
194
|
-
if (idToReferencesMap.has(id)) {
|
|
195
|
-
let references = idToReferencesMap.get(id);
|
|
196
|
-
let isValid = true;
|
|
197
|
-
references.forEach(reference => validatedItemIds.has(reference) || (isValid = false));
|
|
198
|
-
return isValid;
|
|
199
|
-
}
|
|
200
|
-
return true;
|
|
201
|
-
});
|
|
202
|
-
runTheLoop = validatedItemCount !== validatedItems.length;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
validatedItems.forEach(item => {
|
|
206
|
-
definition_store_1.DefinitionStore['setRawDefinition'](ModuleClass, item.definition, item.rawDefinition);
|
|
207
|
-
});
|
|
208
|
-
definitionToProcess = validatedItems.map(validatedItem => validatedItem.definition);
|
|
209
|
-
this.registerDefinitions(definitionToProcess, meta.keyName, ModuleClass);
|
|
210
|
-
}
|
|
211
|
-
context_1.Context.flushErrorLogs();
|
|
212
|
-
context_1.Context.componentInProgressData = undefined;
|
|
213
|
-
return {
|
|
214
|
-
definitionToProcess,
|
|
215
|
-
output,
|
|
216
|
-
ModuleClass
|
|
217
|
-
};
|
|
218
|
-
});
|
|
219
|
-
for (let preparedItem of preparedItems) {
|
|
220
|
-
if (preparedItem.definitionToProcess) {
|
|
221
|
-
let module = new preparedItem.ModuleClass();
|
|
222
|
-
let keyName = preparedItem.ModuleClass.$meta.keyName;
|
|
223
|
-
if (keyName) {
|
|
224
|
-
index_file_generator_1.IndexFileGenerator.addIdType(preparedItem.ModuleClass.$meta.pascalCaseComponentName, preparedItem.definitionToProcess.map((definition) => definition[keyName]));
|
|
225
|
-
}
|
|
226
|
-
await module.process(preparedItem.definitionToProcess, preparedItem.output);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
context_1.Context.flushErrorLogs(); // Still there might be some errors that customly added
|
|
230
|
-
custom_validator_helper_1.CustomValidatorHelper.logDuplicates();
|
|
231
|
-
if (context_1.Context.successful) {
|
|
232
|
-
await index_file_generator_1.IndexFileGenerator.generateFile(indexFilePretext, outputIndexFile);
|
|
233
|
-
}
|
|
234
|
-
return this.getOutputFiles();
|
|
235
|
-
}
|
|
236
|
-
static iterateOnKeyNames(keyName, componentName, ModuleClass) {
|
|
237
|
-
let rawDefinitions = validator_1.Validator.getRawDefinitions(componentName);
|
|
238
|
-
if (keyName) {
|
|
239
|
-
rawDefinitions.forEach(rawDefinition => {
|
|
240
|
-
let rootRawData = rawDefinition.parsedStructure.rawData;
|
|
241
|
-
if (!helpers_lib_1.Comparator.isObject(rootRawData) || helpers_lib_1.Comparator.isArray(rootRawData)) {
|
|
242
|
-
context_1.Context.addErrorLog({
|
|
243
|
-
description: `KeyName shold not be used with a content which is not an object, keyName: "${keyName}" in "${componentName}"`,
|
|
244
|
-
location: { line: rawDefinition.parsedStructure.line, path: rawDefinition.location.path }
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
let keyValue = rootRawData[keyName]?.rawData;
|
|
249
|
-
if (!helpers_lib_1.Comparator.isString(keyValue)) {
|
|
250
|
-
// Do nothing, joi validation will log the errors
|
|
251
|
-
}
|
|
252
|
-
else if (KeyValueRegex.test(keyValue) === false) {
|
|
253
|
-
context_1.Context.addErrorLog({
|
|
254
|
-
description: `KeyValue should be a valid key, keyValue: "${keyValue}"`,
|
|
255
|
-
location: { line: rootRawData[keyName].line, path: rawDefinition.location.path }
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
else if (definition_store_1.DefinitionStore['isRawDefinitionExists'](ModuleClass, keyValue)) {
|
|
259
|
-
context_1.Context.addErrorLog({
|
|
260
|
-
description: `Definition with key "${keyValue}" already exists`,
|
|
261
|
-
location: { line: rootRawData[keyName].line, path: rawDefinition.location.path }
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
definition_store_1.DefinitionStore['setRawDefinitionByKey'](ModuleClass, keyValue, rawDefinition);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
static registerDefinitions(definitions, keyName, ModuleClass) {
|
|
272
|
-
if (keyName) {
|
|
273
|
-
definitions.forEach((definition) => {
|
|
274
|
-
let definitionName = definition[keyName];
|
|
275
|
-
definition_store_1.DefinitionStore['setDefinition'](ModuleClass, definitionName, definition);
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
static getOutputFiles() {
|
|
280
|
-
if (context_1.Context.successful) {
|
|
281
|
-
return context_1.Context.output;
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
helpers_lib_1.ConsoleHelper.newLine();
|
|
285
|
-
helpers_lib_1.ConsoleHelper.log(`ERROR LOGS:`, 'red');
|
|
286
|
-
helpers_lib_1.ConsoleHelper.log(HeavySeperator, 'gray');
|
|
287
|
-
context_1.Context.errorLogs.forEach((log, index) => {
|
|
288
|
-
if (index > 0) {
|
|
289
|
-
helpers_lib_1.ConsoleHelper.log(LightSeperator, 'gray');
|
|
290
|
-
}
|
|
291
|
-
helpers_lib_1.ConsoleHelper.log(`Error:`, 'red');
|
|
292
|
-
console.info(`${helpers_lib_1.ConsoleHelper.white}Details:${helpers_lib_1.ConsoleHelper.green} ${log.description}`);
|
|
293
|
-
console.info(`${helpers_lib_1.ConsoleHelper.white}Location:${helpers_lib_1.ConsoleHelper.green} ${LocationFileToLink(log.location)}`);
|
|
294
|
-
});
|
|
295
|
-
helpers_lib_1.ConsoleHelper.log(HeavySeperator, 'gray');
|
|
296
|
-
return [
|
|
297
|
-
{
|
|
298
|
-
path: '/error-logs.md',
|
|
299
|
-
content: context_1.Context.errorLogs
|
|
300
|
-
.map(errorLog => `${errorLog.description}\r\nPath: '${errorLog.location.path}', Line: '${errorLog.location.line}'\r\n`)
|
|
301
|
-
.join('\r\n')
|
|
302
|
-
}
|
|
303
|
-
];
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
exports.Kernel = Kernel;
|
|
308
|
-
//# sourceMappingURL=kernel.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare class CommonFunctionsClass {
|
|
2
|
-
decorateDefinitionName(name: string, componentName: string): string;
|
|
3
|
-
kebabCaseToCamelCase(string: string): string;
|
|
4
|
-
lowerCaseFirstLetter(string: string): string;
|
|
5
|
-
upperCaseFirstLetter(string: string): string;
|
|
6
|
-
removeWhiteSpace(row: string): string;
|
|
7
|
-
removeComments(row: string): string;
|
|
8
|
-
}
|
|
9
|
-
export declare const CommonFunctions: CommonFunctionsClass;
|
|
10
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommonFunctions = void 0;
|
|
4
|
-
class CommonFunctionsClass {
|
|
5
|
-
decorateDefinitionName(name, componentName) {
|
|
6
|
-
return `${this.kebabCaseToCamelCase(componentName)}${this.upperCaseFirstLetter(name)}`;
|
|
7
|
-
}
|
|
8
|
-
kebabCaseToCamelCase(string) {
|
|
9
|
-
return string.toLowerCase().replace(/-./g, x => x[1].toUpperCase());
|
|
10
|
-
}
|
|
11
|
-
lowerCaseFirstLetter(string) {
|
|
12
|
-
return string.charAt(0).toLowerCase() + string.slice(1);
|
|
13
|
-
}
|
|
14
|
-
upperCaseFirstLetter(string) {
|
|
15
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
16
|
-
}
|
|
17
|
-
removeWhiteSpace(row) {
|
|
18
|
-
return row
|
|
19
|
-
.replace(/\r?\n|\r/g, '')
|
|
20
|
-
.replace(/\/\/.*$/gm, '')
|
|
21
|
-
.trim()
|
|
22
|
-
.replace(/ {2,}/g, ' ');
|
|
23
|
-
}
|
|
24
|
-
removeComments(row) {
|
|
25
|
-
return row.replace(/\/\/.*$/gm, '').trimEnd();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.CommonFunctions = new CommonFunctionsClass();
|
|
29
|
-
//# sourceMappingURL=common-functions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const vitest_1 = require("vitest");
|
|
4
|
-
const common_functions_1 = require("./common-functions");
|
|
5
|
-
(0, vitest_1.describe)('COMMON FUNCTIONS', () => {
|
|
6
|
-
(0, vitest_1.test)('kabab case to camel case', () => {
|
|
7
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.kebabCaseToCamelCase('')).toEqual('');
|
|
8
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.kebabCaseToCamelCase('text')).toEqual('text');
|
|
9
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.kebabCaseToCamelCase('TEXT')).toEqual('text');
|
|
10
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.kebabCaseToCamelCase('text-asdf')).toEqual('textAsdf');
|
|
11
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.kebabCaseToCamelCase('TEXT-ASDF')).toEqual('textAsdf');
|
|
12
|
-
});
|
|
13
|
-
(0, vitest_1.test)('lower case first letter', () => {
|
|
14
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.lowerCaseFirstLetter('')).toEqual('');
|
|
15
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.lowerCaseFirstLetter('text')).toEqual('text');
|
|
16
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.lowerCaseFirstLetter(' ')).toEqual(' ');
|
|
17
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.lowerCaseFirstLetter('Text')).toEqual('text');
|
|
18
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.lowerCaseFirstLetter(' Text')).toEqual(' Text');
|
|
19
|
-
});
|
|
20
|
-
(0, vitest_1.test)('upper case first letter', () => {
|
|
21
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.upperCaseFirstLetter('')).toEqual('');
|
|
22
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.upperCaseFirstLetter('Text')).toEqual('Text');
|
|
23
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.upperCaseFirstLetter(' ')).toEqual(' ');
|
|
24
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.upperCaseFirstLetter('text')).toEqual('Text');
|
|
25
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.upperCaseFirstLetter(' text')).toEqual(' text');
|
|
26
|
-
});
|
|
27
|
-
(0, vitest_1.test)('remove whitespace', () => {
|
|
28
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeWhiteSpace('')).toEqual('');
|
|
29
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeWhiteSpace('text')).toEqual('text');
|
|
30
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeWhiteSpace(' text')).toEqual('text');
|
|
31
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeWhiteSpace('text ')).toEqual('text');
|
|
32
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeWhiteSpace('text\n')).toEqual('text');
|
|
33
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeWhiteSpace('text\r')).toEqual('text');
|
|
34
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeWhiteSpace('text\r\n')).toEqual('text');
|
|
35
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeWhiteSpace('text//')).toEqual('text');
|
|
36
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeWhiteSpace('text //')).toEqual('text');
|
|
37
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeWhiteSpace('text // asdf')).toEqual('text');
|
|
38
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeWhiteSpace('text text')).toEqual('text text');
|
|
39
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeWhiteSpace('text text')).toEqual('text text');
|
|
40
|
-
});
|
|
41
|
-
(0, vitest_1.test)('remove comments', () => {
|
|
42
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeComments('')).toEqual('');
|
|
43
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeComments('text')).toEqual('text');
|
|
44
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeComments(' text ')).toEqual(' text');
|
|
45
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeComments(' text//')).toEqual(' text');
|
|
46
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeComments(' text //')).toEqual(' text');
|
|
47
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeComments(' text // asdf')).toEqual(' text');
|
|
48
|
-
(0, vitest_1.expect)(common_functions_1.CommonFunctions.removeComments('- Symbol: □ // Dirt\n')).toEqual('- Symbol: □');
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
//# sourceMappingURL=common-functions.test.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { LocationInFile } from '../../framework/interfaces';
|
|
2
|
-
export declare class DuplicateHelper {
|
|
3
|
-
private group;
|
|
4
|
-
private identifiers;
|
|
5
|
-
private identifierToLocation;
|
|
6
|
-
private addedIdentifiers;
|
|
7
|
-
private duplicates;
|
|
8
|
-
constructor(group: string);
|
|
9
|
-
newEntry(identifier: string, location: LocationInFile): boolean;
|
|
10
|
-
logDuplicateErrors(): void;
|
|
11
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DuplicateHelper = void 0;
|
|
4
|
-
const context_1 = require("../../framework/context");
|
|
5
|
-
class DuplicateHelper {
|
|
6
|
-
constructor(group) {
|
|
7
|
-
this.group = group;
|
|
8
|
-
this.identifiers = new Set();
|
|
9
|
-
this.identifierToLocation = new Map();
|
|
10
|
-
this.addedIdentifiers = new Set();
|
|
11
|
-
this.duplicates = [];
|
|
12
|
-
}
|
|
13
|
-
newEntry(identifier, location) {
|
|
14
|
-
if (this.identifiers.has(identifier)) {
|
|
15
|
-
if (!this.addedIdentifiers.has(identifier)) {
|
|
16
|
-
this.addedIdentifiers.add(identifier);
|
|
17
|
-
let firstIdentifierLocation = this.identifierToLocation.get(identifier);
|
|
18
|
-
firstIdentifierLocation && this.duplicates.push({ identifier, location: firstIdentifierLocation });
|
|
19
|
-
}
|
|
20
|
-
this.duplicates.push({ identifier, location });
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
this.identifiers.add(identifier);
|
|
25
|
-
this.identifierToLocation.set(identifier, location);
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
logDuplicateErrors() {
|
|
30
|
-
this.duplicates.forEach(duplicate => {
|
|
31
|
-
let errorLog = {
|
|
32
|
-
description: `Value should be singular! Group: "${this.group}", Value: "${duplicate.identifier}"`,
|
|
33
|
-
location: duplicate.location
|
|
34
|
-
};
|
|
35
|
-
context_1.Context.addErrorLog(errorLog);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.DuplicateHelper = DuplicateHelper;
|
|
40
|
-
//# sourceMappingURL=duplicate-helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const vitest_1 = require("vitest");
|
|
4
|
-
const mocks_1 = require("../../_mocks/mocks");
|
|
5
|
-
const context_1 = require("../../framework/context");
|
|
6
|
-
const duplicate_helper_1 = require("./duplicate-helper");
|
|
7
|
-
(0, vitest_1.describe)('Duplicate Helper', () => {
|
|
8
|
-
(0, vitest_1.test)('should handle single entry', () => {
|
|
9
|
-
(0, mocks_1.resetContext)();
|
|
10
|
-
let helper = new duplicate_helper_1.DuplicateHelper('ASSET: Name');
|
|
11
|
-
(0, vitest_1.expect)(helper.newEntry('identifier', mocks_1.SampleLocation1)).toBeTruthy();
|
|
12
|
-
helper.logDuplicateErrors();
|
|
13
|
-
(0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([]);
|
|
14
|
-
});
|
|
15
|
-
(0, vitest_1.test)('should detect duplicate', () => {
|
|
16
|
-
(0, mocks_1.resetContext)();
|
|
17
|
-
let helper = new duplicate_helper_1.DuplicateHelper('ASSET: Name');
|
|
18
|
-
(0, vitest_1.expect)(helper.newEntry('identifier', mocks_1.SampleLocation1)).toBeTruthy();
|
|
19
|
-
(0, vitest_1.expect)(helper.newEntry('identifier', mocks_1.SampleLocation2)).toBeFalsy();
|
|
20
|
-
helper.logDuplicateErrors();
|
|
21
|
-
(0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([
|
|
22
|
-
{
|
|
23
|
-
description: 'Value should be singular! Group: "ASSET: Name", Value: "identifier"',
|
|
24
|
-
location: mocks_1.SampleLocation1
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
description: 'Value should be singular! Group: "ASSET: Name", Value: "identifier"',
|
|
28
|
-
location: mocks_1.SampleLocation2
|
|
29
|
-
}
|
|
30
|
-
]);
|
|
31
|
-
});
|
|
32
|
-
(0, vitest_1.test)('should detect multiple duplicate', () => {
|
|
33
|
-
(0, mocks_1.resetContext)();
|
|
34
|
-
let helper = new duplicate_helper_1.DuplicateHelper('ASSET: Name');
|
|
35
|
-
(0, vitest_1.expect)(helper.newEntry('identifier', mocks_1.SampleLocation1)).toBeTruthy();
|
|
36
|
-
(0, vitest_1.expect)(helper.newEntry('identifier', mocks_1.SampleLocation2)).toBeFalsy();
|
|
37
|
-
(0, vitest_1.expect)(helper.newEntry('identifier', mocks_1.SampleLocation3)).toBeFalsy();
|
|
38
|
-
helper.logDuplicateErrors();
|
|
39
|
-
(0, vitest_1.expect)(context_1.Context['errorLogBuffer']).toStrictEqual([
|
|
40
|
-
{
|
|
41
|
-
description: 'Value should be singular! Group: "ASSET: Name", Value: "identifier"',
|
|
42
|
-
location: mocks_1.SampleLocation1
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
description: 'Value should be singular! Group: "ASSET: Name", Value: "identifier"',
|
|
46
|
-
location: mocks_1.SampleLocation2
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
description: 'Value should be singular! Group: "ASSET: Name", Value: "identifier"',
|
|
50
|
-
location: mocks_1.SampleLocation3
|
|
51
|
-
}
|
|
52
|
-
]);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
//# sourceMappingURL=duplicate-helper.test.js.map
|