definition-generator-framework 1.12.9 → 1.12.11

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.
@@ -3,6 +3,7 @@ export declare class Kernel {
3
3
  static process(components: DefinitionComponentClassType<any>[], indexFilePretext: string, outputIndexFile: string): Promise<void>;
4
4
  private static readFiles;
5
5
  private static writeFiles;
6
+ private static cleanPath;
6
7
  private static removeEmptyFolders;
7
8
  private static generateOutputFiles;
8
9
  private static iterateOnKeyNames;
@@ -85,12 +85,11 @@ class Kernel {
85
85
  helpers_lib_1.ConsoleHelper.log(`Changes:`, 'gray');
86
86
  helpers_lib_1.ConsoleHelper.newLine();
87
87
  }
88
- let startPathsFrom = context_1.Context.config.projectRoot.length;
89
88
  let erasedFileCount = 0;
90
89
  if (context_1.Context.successful) {
91
90
  filesInOutputFolder.forEach(filePath => {
92
91
  erasedFileCount++;
93
- console.info(`${helpers_lib_1.ConsoleHelper.red}Erasing file:${helpers_lib_1.ConsoleHelper.gray} "${filePath.substring(startPathsFrom).replace(/\//g, '\\')}"${helpers_lib_1.ConsoleHelper.default}`);
92
+ console.info(`${helpers_lib_1.ConsoleHelper.red}Erasing file:${helpers_lib_1.ConsoleHelper.gray} "${this.cleanPath(filePath)}"${helpers_lib_1.ConsoleHelper.default}`);
94
93
  fs.unlinkSync(filePath);
95
94
  });
96
95
  }
@@ -104,11 +103,11 @@ class Kernel {
104
103
  if (content !== outputFile.content) {
105
104
  if (exists) {
106
105
  modifiedFileCount++;
107
- console.info(`${helpers_lib_1.ConsoleHelper.blue}Modifying file:${helpers_lib_1.ConsoleHelper.gray} "${outputFile.path.substring(startPathsFrom).replace(/\//g, '\\')}"${helpers_lib_1.ConsoleHelper.default}`);
106
+ console.info(`${helpers_lib_1.ConsoleHelper.blue}Modifying file:${helpers_lib_1.ConsoleHelper.gray} "${this.cleanPath(outputFile.path)}"${helpers_lib_1.ConsoleHelper.default}`);
108
107
  }
109
108
  else {
110
109
  createdFileCount++;
111
- console.info(`${helpers_lib_1.ConsoleHelper.cyan}Creating file:${helpers_lib_1.ConsoleHelper.gray} "${outputFile.path.substring(startPathsFrom).replace(/\//g, '\\')}"${helpers_lib_1.ConsoleHelper.default}`);
110
+ console.info(`${helpers_lib_1.ConsoleHelper.cyan}Creating file:${helpers_lib_1.ConsoleHelper.gray} "${this.cleanPath(outputFile.path)}"${helpers_lib_1.ConsoleHelper.default}`);
112
111
  }
113
112
  fs.writeFileSync(outputFile.path, outputFile.content);
114
113
  }
@@ -128,6 +127,10 @@ class Kernel {
128
127
  helpers_lib_1.ConsoleHelper.log(`Compilation encountered errors!`, 'red');
129
128
  }
130
129
  }
130
+ static cleanPath(path) {
131
+ let startPathsFrom = context_1.Context.compilerExecutionPath.length;
132
+ return path.substring(startPathsFrom); // .replace(/\//g, '\\');
133
+ }
131
134
  static removeEmptyFolders(dir) {
132
135
  let files = fs.readdirSync(dir);
133
136
  let isEmpty = true;
@@ -12,18 +12,10 @@ class ReferenceCustomValidatorBase {
12
12
  this.regex = /^[a-z]+([a-zA-Z0-9]+)*$/;
13
13
  }
14
14
  validatePropertyExistence(referencedComponent, definitionName, options) {
15
- if (options?.propertyShouldExist) {
16
- let properties = helpers_lib_1.Comparator.isArray(options?.propertyShouldExist)
17
- ? options?.propertyShouldExist
18
- : [options?.propertyShouldExist];
15
+ if (options?.additionalValidation) {
19
16
  let rawDefinition = definition_store_1.DefinitionStore['getRawDefinition'](referencedComponent, definitionName);
20
- properties.forEach(propertyPath => {
21
- let flattenedRawDefinition = rawDefinition ? raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition) : undefined;
22
- let property = helpers_lib_1.JsonHelper.deepFind(flattenedRawDefinition, propertyPath);
23
- if (!property || (helpers_lib_1.Comparator.isArray(property) && property.length === 0)) {
24
- throw new Error(`Property "${propertyPath}" does not exist in definition "${definitionName}"`);
25
- }
26
- });
17
+ let flattenedRawDefinition = rawDefinition ? raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition) : undefined;
18
+ options.additionalValidation.validate(flattenedRawDefinition);
27
19
  }
28
20
  }
29
21
  }
@@ -10,7 +10,7 @@ export interface CustomObjectValidator {
10
10
  readonly validate: Joi.CustomValidator<any, any>;
11
11
  }
12
12
  export interface ReferenceCustomValidatorOptions {
13
- propertyShouldExist?: string | string[];
13
+ additionalValidation?: Joi.Schema;
14
14
  }
15
15
  declare module 'joi' {
16
16
  interface StringSchema {
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "definition-generator-framework",
3
- "version": "1.12.9",
3
+ "version": "1.12.11",
4
4
  "description": "Definition Generator Framework",
5
5
  "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
6
  "files": [
8
7
  "dist/**/*.js",
9
8
  "dist/**/*.d.ts"
10
9
  ],
11
10
  "publishConfig": {
12
- "main": "dist/index.js"
11
+ "main": "dist/index.js",
12
+ "types": "dist/index.d.ts"
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
@@ -56,5 +56,6 @@
56
56
  "ts-node": "10.9.2",
57
57
  "typescript": "5.3.3",
58
58
  "vitest": "1.6.0"
59
- }
59
+ },
60
+ "types": "dist/index.d.ts"
60
61
  }