@ruiapp/rapid-configure-tools 0.4.3 → 0.5.1

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/mod.js CHANGED
@@ -22,7 +22,8 @@ function ensureDirectoryExists(dirPath) {
22
22
  fs__default["default"].mkdirSync(dirPath);
23
23
  }
24
24
  }
25
- function enumFileBaseNamesInDirectory(dirPath, prefix = "") {
25
+ function enumFileBaseNamesInDirectory(options) {
26
+ const { dirPath, prefix, fileNameFilter } = options;
26
27
  let fileNames = [];
27
28
  let resolvedDirPath = dirPath;
28
29
  const isRelative = dirPath.startsWith(".") || dirPath.startsWith("..");
@@ -38,9 +39,16 @@ function enumFileBaseNamesInDirectory(dirPath, prefix = "") {
38
39
  const filePathName = path__default["default"].join(resolvedDirPath, fileName);
39
40
  const fileStat = fs__default["default"].statSync(filePathName);
40
41
  if (fileStat.isDirectory()) {
41
- fileNames = fileNames.concat(enumFileBaseNamesInDirectory(filePathName, prefix ? `${prefix}/${fileName}` : fileName));
42
+ fileNames = fileNames.concat(enumFileBaseNamesInDirectory({
43
+ dirPath: filePathName,
44
+ prefix: prefix ? `${prefix}/${fileName}` : fileName,
45
+ fileNameFilter,
46
+ }));
42
47
  }
43
48
  else if (fileStat.isFile()) {
49
+ if (fileNameFilter && !fileNameFilter(fileName)) {
50
+ continue;
51
+ }
44
52
  const baseName = path__default["default"].parse(fileName).name;
45
53
  if (prefix) {
46
54
  fileNames.push(`${prefix}/${baseName}`);
@@ -59,7 +67,12 @@ function enumFileBaseNamesInDirectory(dirPath, prefix = "") {
59
67
  */
60
68
  function generateEntityModelIndexFilesOfTypeDir({ modelsDir, outputDir, typeDefFilePath, categoryDirName, modelTypeName, modelsFileName, extraImports, modelWrapper, flattenModelArray, }) {
61
69
  const filesDir = path__default["default"].join(modelsDir, categoryDirName);
62
- const fileNames = enumFileBaseNamesInDirectory(filesDir);
70
+ const fileNames = enumFileBaseNamesInDirectory({
71
+ dirPath: filesDir,
72
+ fileNameFilter(fileName) {
73
+ return !(fileName.endsWith(".test.js") || fileName.endsWith(".test.ts"));
74
+ },
75
+ });
63
76
  const models = fileNames.map((fileName) => {
64
77
  return {
65
78
  modelName: fileName.replaceAll("/", "$"),
@@ -113,7 +126,12 @@ function generateEntityModelIndexFilesOfTypeDir({ modelsDir, outputDir, typeDefF
113
126
  }
114
127
  function generateModelIndexFilesOfTypeDir({ modelsDir, outputDir, typeDefFilePath, categoryDirName, modelTypeName, modelsFileName, extraImports, modelWrapper, flattenModelArray, }) {
115
128
  const filesDir = path__default["default"].join(modelsDir, categoryDirName);
116
- const fileNames = enumFileBaseNamesInDirectory(filesDir);
129
+ const fileNames = enumFileBaseNamesInDirectory({
130
+ dirPath: filesDir,
131
+ fileNameFilter(fileName) {
132
+ return !(fileName.endsWith(".test.js") || fileName.endsWith(".test.ts"));
133
+ },
134
+ });
117
135
  const models = fileNames.map((fileName) => {
118
136
  return {
119
137
  modelName: fileName.replaceAll("/", "$"),
@@ -665,7 +683,7 @@ function newDictionaryUpdater(rapidConfigApi) {
665
683
  return entity.code === input.code;
666
684
  },
667
685
  isEntityChanged(inputEntity, remoteEntity) {
668
- const changedFieldNames = detectChangedFields(inputEntity, remoteEntity, ["name", "valueType", "description", "locales"]);
686
+ const changedFieldNames = detectChangedFields(inputEntity, remoteEntity, ["name", "valueType", "description", "locales", "deprecated"]);
669
687
  if (changedFieldNames.length) {
670
688
  console.log(`${this.modelType} ${this.inputTitlePrinter(inputEntity)} changed with these fields:`, changedFieldNames);
671
689
  }
@@ -715,7 +733,7 @@ function newDictionaryEntryUpdater(rapidConfigApi) {
715
733
  return entity.name === input.name;
716
734
  },
717
735
  isEntityChanged(inputEntity, remoteEntity) {
718
- const changedFieldNames = detectChangedFields(inputEntity, remoteEntity, ["value", "description", "locales"]);
736
+ const changedFieldNames = detectChangedFields(inputEntity, remoteEntity, ["value", "description", "locales", "deprecated"]);
719
737
  if (changedFieldNames.length) {
720
738
  console.log(`${this.modelType} ${this.inputTitlePrinter(inputEntity)} changed with these fields:`, changedFieldNames);
721
739
  }
@@ -790,6 +808,7 @@ function newModelUpdater(rapidConfigApi) {
790
808
  "permissionPolicies",
791
809
  "softDelete",
792
810
  "locales",
811
+ "deprecated",
793
812
  ]);
794
813
  if (changedFieldNames.length) {
795
814
  console.log(`${this.modelType} ${this.inputTitlePrinter(inputEntity)} changed with these fields:`, changedFieldNames);
@@ -876,6 +895,7 @@ function newPropertyUpdater(rapidConfigApi) {
876
895
  "entityDeletingReaction",
877
896
  "readonly",
878
897
  "locales",
898
+ "deprecated",
879
899
  ]);
880
900
  if (changedFieldNames.length) {
881
901
  console.log(`${this.modelType} ${this.inputTitlePrinter(inputEntity)} changed with these fields:`, changedFieldNames);
@@ -1,2 +1,7 @@
1
1
  export declare function ensureDirectoryExists(dirPath: string): void;
2
- export declare function enumFileBaseNamesInDirectory(dirPath: string, prefix?: string): string[];
2
+ export type EnumFileBaseNamesOptions = {
3
+ dirPath: string;
4
+ prefix?: string;
5
+ fileNameFilter?: (fileName: string) => boolean;
6
+ };
7
+ export declare function enumFileBaseNamesInDirectory(options: EnumFileBaseNamesOptions): string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruiapp/rapid-configure-tools",
3
- "version": "0.4.3",
3
+ "version": "0.5.1",
4
4
  "description": "",
5
5
  "main": "dist/mod.js",
6
6
  "keywords": [],
@@ -20,7 +20,7 @@
20
20
  "axios-cookiejar-support": "^4.0.7",
21
21
  "lodash": "^4.17.21",
22
22
  "tough-cookie": "^4.1.3",
23
- "@ruiapp/rapid-extension": "^0.4.5"
23
+ "@ruiapp/rapid-extension": "^0.5.23"
24
24
  },
25
25
  "dependencies": {},
26
26
  "scripts": {
@@ -50,7 +50,12 @@ function generateEntityModelIndexFilesOfTypeDir({
50
50
  flattenModelArray,
51
51
  }: GenerateModelsIndexFileOption) {
52
52
  const filesDir = path.join(modelsDir, categoryDirName);
53
- const fileNames = enumFileBaseNamesInDirectory(filesDir);
53
+ const fileNames = enumFileBaseNamesInDirectory({
54
+ dirPath: filesDir,
55
+ fileNameFilter(fileName) {
56
+ return !(fileName.endsWith(".test.js") || fileName.endsWith(".test.ts"));
57
+ },
58
+ });
54
59
 
55
60
  const models = fileNames.map((fileName) => {
56
61
  return {
@@ -122,7 +127,12 @@ function generateModelIndexFilesOfTypeDir({
122
127
  flattenModelArray,
123
128
  }: GenerateModelsIndexFileOption) {
124
129
  const filesDir = path.join(modelsDir, categoryDirName);
125
- const fileNames = enumFileBaseNamesInDirectory(filesDir);
130
+ const fileNames = enumFileBaseNamesInDirectory({
131
+ dirPath: filesDir,
132
+ fileNameFilter(fileName) {
133
+ return !(fileName.endsWith(".test.js") || fileName.endsWith(".test.ts"));
134
+ },
135
+ });
126
136
 
127
137
  const models = fileNames.map((fileName) => {
128
138
  return {
@@ -42,7 +42,7 @@ export function newDictionaryEntryUpdater(rapidConfigApi: AxiosInstance) {
42
42
  },
43
43
 
44
44
  isEntityChanged(inputEntity, remoteEntity) {
45
- const changedFieldNames = detectChangedFields(inputEntity, remoteEntity, ["value", "description", "locales"]);
45
+ const changedFieldNames = detectChangedFields(inputEntity, remoteEntity, ["value", "description", "locales", "deprecated"]);
46
46
  if (changedFieldNames.length) {
47
47
  console.log(`${this.modelType} ${this.inputTitlePrinter(inputEntity)} changed with these fields:`, changedFieldNames);
48
48
  }
@@ -30,7 +30,7 @@ export function newDictionaryUpdater(rapidConfigApi: AxiosInstance) {
30
30
  },
31
31
 
32
32
  isEntityChanged(inputEntity, remoteEntity) {
33
- const changedFieldNames = detectChangedFields(inputEntity, remoteEntity, ["name", "valueType", "description", "locales"]);
33
+ const changedFieldNames = detectChangedFields(inputEntity, remoteEntity, ["name", "valueType", "description", "locales", "deprecated"]);
34
34
  if (changedFieldNames.length) {
35
35
  console.log(`${this.modelType} ${this.inputTitlePrinter(inputEntity)} changed with these fields:`, changedFieldNames);
36
36
  }
@@ -46,6 +46,7 @@ export function newModelUpdater(rapidConfigApi: AxiosInstance) {
46
46
  "permissionPolicies",
47
47
  "softDelete",
48
48
  "locales",
49
+ "deprecated",
49
50
  ]);
50
51
  if (changedFieldNames.length) {
51
52
  console.log(`${this.modelType} ${this.inputTitlePrinter(inputEntity)} changed with these fields:`, changedFieldNames);
@@ -56,6 +56,7 @@ export function newPropertyUpdater(rapidConfigApi: AxiosInstance) {
56
56
  "entityDeletingReaction",
57
57
  "readonly",
58
58
  "locales",
59
+ "deprecated",
59
60
  ]);
60
61
  if (changedFieldNames.length) {
61
62
  console.log(`${this.modelType} ${this.inputTitlePrinter(inputEntity)} changed with these fields:`, changedFieldNames);
@@ -10,7 +10,14 @@ export function ensureDirectoryExists(dirPath: string) {
10
10
  }
11
11
  }
12
12
 
13
- export function enumFileBaseNamesInDirectory(dirPath: string, prefix: string = ""): string[] {
13
+ export type EnumFileBaseNamesOptions = {
14
+ dirPath: string;
15
+ prefix?: string;
16
+ fileNameFilter?: (fileName: string) => boolean;
17
+ };
18
+
19
+ export function enumFileBaseNamesInDirectory(options: EnumFileBaseNamesOptions): string[] {
20
+ const { dirPath, prefix, fileNameFilter } = options;
14
21
  let fileNames = [];
15
22
 
16
23
  let resolvedDirPath = dirPath;
@@ -29,8 +36,18 @@ export function enumFileBaseNamesInDirectory(dirPath: string, prefix: string = "
29
36
  const filePathName = path.join(resolvedDirPath, fileName);
30
37
  const fileStat = fs.statSync(filePathName);
31
38
  if (fileStat.isDirectory()) {
32
- fileNames = fileNames.concat(enumFileBaseNamesInDirectory(filePathName, prefix ? `${prefix}/${fileName}` : fileName));
39
+ fileNames = fileNames.concat(
40
+ enumFileBaseNamesInDirectory({
41
+ dirPath: filePathName,
42
+ prefix: prefix ? `${prefix}/${fileName}` : fileName,
43
+ fileNameFilter,
44
+ }),
45
+ );
33
46
  } else if (fileStat.isFile()) {
47
+ if (fileNameFilter && !fileNameFilter(fileName)) {
48
+ continue;
49
+ }
50
+
34
51
  const baseName = path.parse(fileName).name;
35
52
  if (prefix) {
36
53
  fileNames.push(`${prefix}/${baseName}`);