@ruiapp/rapid-configure-tools 0.5.1 → 0.5.3

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
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var path = require('path');
6
6
  var fs = require('fs');
7
7
  var lodash = require('lodash');
8
+ var rapidCore = require('@ruiapp/rapid-core');
8
9
  var axios = require('axios');
9
10
  var axiosCookiejarSupport = require('axios-cookiejar-support');
10
11
  var toughCookie = require('tough-cookie');
@@ -15,59 +16,12 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
15
16
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
16
17
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
17
18
 
18
- function ensureDirectoryExists(dirPath) {
19
- if (!fs__default["default"].existsSync(dirPath)) {
20
- const parentDirPath = path__default["default"].dirname(dirPath);
21
- ensureDirectoryExists(parentDirPath);
22
- fs__default["default"].mkdirSync(dirPath);
23
- }
24
- }
25
- function enumFileBaseNamesInDirectory(options) {
26
- const { dirPath, prefix, fileNameFilter } = options;
27
- let fileNames = [];
28
- let resolvedDirPath = dirPath;
29
- const isRelative = dirPath.startsWith(".") || dirPath.startsWith("..");
30
- if (isRelative) {
31
- resolvedDirPath = path__default["default"].join(process.cwd(), dirPath);
32
- }
33
- if (!fs__default["default"].existsSync(resolvedDirPath)) {
34
- console.warn(`Directory '${resolvedDirPath}' not found.`);
35
- return [];
36
- }
37
- const files = fs__default["default"].readdirSync(resolvedDirPath);
38
- for (const fileName of files) {
39
- const filePathName = path__default["default"].join(resolvedDirPath, fileName);
40
- const fileStat = fs__default["default"].statSync(filePathName);
41
- if (fileStat.isDirectory()) {
42
- fileNames = fileNames.concat(enumFileBaseNamesInDirectory({
43
- dirPath: filePathName,
44
- prefix: prefix ? `${prefix}/${fileName}` : fileName,
45
- fileNameFilter,
46
- }));
47
- }
48
- else if (fileStat.isFile()) {
49
- if (fileNameFilter && !fileNameFilter(fileName)) {
50
- continue;
51
- }
52
- const baseName = path__default["default"].parse(fileName).name;
53
- if (prefix) {
54
- fileNames.push(`${prefix}/${baseName}`);
55
- }
56
- else {
57
- fileNames.push(baseName);
58
- }
59
- }
60
- }
61
- fileNames.sort();
62
- return fileNames;
63
- }
64
-
65
19
  /**
66
20
  * 用于生成模型索引文件,将模型定义按照类型分别导出。
67
21
  */
68
22
  function generateEntityModelIndexFilesOfTypeDir({ modelsDir, outputDir, typeDefFilePath, categoryDirName, modelTypeName, modelsFileName, extraImports, modelWrapper, flattenModelArray, }) {
69
23
  const filesDir = path__default["default"].join(modelsDir, categoryDirName);
70
- const fileNames = enumFileBaseNamesInDirectory({
24
+ const fileNames = rapidCore.enumFileBaseNamesInDirectory({
71
25
  dirPath: filesDir,
72
26
  fileNameFilter(fileName) {
73
27
  return !(fileName.endsWith(".test.js") || fileName.endsWith(".test.ts"));
@@ -126,7 +80,7 @@ function generateEntityModelIndexFilesOfTypeDir({ modelsDir, outputDir, typeDefF
126
80
  }
127
81
  function generateModelIndexFilesOfTypeDir({ modelsDir, outputDir, typeDefFilePath, categoryDirName, modelTypeName, modelsFileName, extraImports, modelWrapper, flattenModelArray, }) {
128
82
  const filesDir = path__default["default"].join(modelsDir, categoryDirName);
129
- const fileNames = enumFileBaseNamesInDirectory({
83
+ const fileNames = rapidCore.enumFileBaseNamesInDirectory({
130
84
  dirPath: filesDir,
131
85
  fileNameFilter(fileName) {
132
86
  return !(fileName.endsWith(".test.js") || fileName.endsWith(".test.ts"));
@@ -182,7 +136,7 @@ function generateModelIndexFiles(declarationsDirectory) {
182
136
  const modelsDir = path__default["default"].join(declarationsDirectory, "models");
183
137
  const outputDir = path__default["default"].join(declarationsDirectory, "meta");
184
138
  const typeDefFilePath = "@ruiapp/rapid-extension";
185
- ensureDirectoryExists(outputDir);
139
+ rapidCore.ensureDirectoryExists(outputDir);
186
140
  generateEntityModelIndexFilesOfTypeDir({
187
141
  modelsDir,
188
142
  outputDir,
@@ -733,7 +687,7 @@ function newDictionaryEntryUpdater(rapidConfigApi) {
733
687
  return entity.name === input.name;
734
688
  },
735
689
  isEntityChanged(inputEntity, remoteEntity) {
736
- const changedFieldNames = detectChangedFields(inputEntity, remoteEntity, ["value", "description", "locales", "deprecated"]);
690
+ const changedFieldNames = detectChangedFields(inputEntity, remoteEntity, ["value", "description", "color", "icon", "i18n", "locales", "deprecated"]);
737
691
  if (changedFieldNames.length) {
738
692
  console.log(`${this.modelType} ${this.inputTitlePrinter(inputEntity)} changed with these fields:`, changedFieldNames);
739
693
  }
@@ -747,6 +701,9 @@ function newDictionaryEntryUpdater(rapidConfigApi) {
747
701
  color: input.color,
748
702
  icon: input.icon,
749
703
  description: input.description,
704
+ i18n: input.i18n,
705
+ locales: input.locales,
706
+ deprecated: input.deprecated,
750
707
  orderNum: inputIndex + 1,
751
708
  disabled: false,
752
709
  };
@@ -761,6 +718,9 @@ function newDictionaryEntryUpdater(rapidConfigApi) {
761
718
  color: input.color,
762
719
  icon: input.icon,
763
720
  description: input.description,
721
+ i18n: input.i18n,
722
+ locales: input.locales,
723
+ deprecated: input.deprecated,
764
724
  orderNum: inputIndex + 1,
765
725
  disabled: remoteEntity.disabled,
766
726
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruiapp/rapid-configure-tools",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "",
5
5
  "main": "dist/mod.js",
6
6
  "keywords": [],
@@ -20,7 +20,8 @@
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.5.23"
23
+ "@ruiapp/rapid-core": "^0.9.8",
24
+ "@ruiapp/rapid-extension": "^0.5.44"
24
25
  },
25
26
  "dependencies": {},
26
27
  "scripts": {
@@ -5,7 +5,7 @@
5
5
  import fs from "fs";
6
6
  import { forEach } from "lodash";
7
7
  import path from "path";
8
- import { ensureDirectoryExists, enumFileBaseNamesInDirectory } from "../../utils/file-utility";
8
+ import { ensureDirectoryExists, enumFileBaseNamesInDirectory } from "@ruiapp/rapid-core";
9
9
 
10
10
  interface GenerateModelsIndexFileOption {
11
11
  /**
@@ -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", "deprecated"]);
45
+ const changedFieldNames = detectChangedFields(inputEntity, remoteEntity, ["value", "description", "color", "icon", "i18n", "locales", "deprecated"]);
46
46
  if (changedFieldNames.length) {
47
47
  console.log(`${this.modelType} ${this.inputTitlePrinter(inputEntity)} changed with these fields:`, changedFieldNames);
48
48
  }
@@ -57,6 +57,9 @@ export function newDictionaryEntryUpdater(rapidConfigApi: AxiosInstance) {
57
57
  color: input.color,
58
58
  icon: input.icon,
59
59
  description: input.description,
60
+ i18n: input.i18n,
61
+ locales: input.locales,
62
+ deprecated: input.deprecated,
60
63
  orderNum: inputIndex + 1,
61
64
  disabled: false,
62
65
  };
@@ -72,6 +75,9 @@ export function newDictionaryEntryUpdater(rapidConfigApi: AxiosInstance) {
72
75
  color: input.color,
73
76
  icon: input.icon,
74
77
  description: input.description,
78
+ i18n: input.i18n,
79
+ locales: input.locales,
80
+ deprecated: input.deprecated,
75
81
  orderNum: inputIndex + 1,
76
82
  disabled: remoteEntity.disabled,
77
83
  };
@@ -1,7 +0,0 @@
1
- export declare function ensureDirectoryExists(dirPath: string): void;
2
- export type EnumFileBaseNamesOptions = {
3
- dirPath: string;
4
- prefix?: string;
5
- fileNameFilter?: (fileName: string) => boolean;
6
- };
7
- export declare function enumFileBaseNamesInDirectory(options: EnumFileBaseNamesOptions): string[];
@@ -1,62 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
-
4
- export function ensureDirectoryExists(dirPath: string) {
5
- if (!fs.existsSync(dirPath)) {
6
- const parentDirPath = path.dirname(dirPath);
7
- ensureDirectoryExists(parentDirPath);
8
-
9
- fs.mkdirSync(dirPath);
10
- }
11
- }
12
-
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;
21
- let fileNames = [];
22
-
23
- let resolvedDirPath = dirPath;
24
- const isRelative = dirPath.startsWith(".") || dirPath.startsWith("..");
25
- if (isRelative) {
26
- resolvedDirPath = path.join(process.cwd(), dirPath);
27
- }
28
-
29
- if (!fs.existsSync(resolvedDirPath)) {
30
- console.warn(`Directory '${resolvedDirPath}' not found.`);
31
- return [];
32
- }
33
-
34
- const files = fs.readdirSync(resolvedDirPath);
35
- for (const fileName of files) {
36
- const filePathName = path.join(resolvedDirPath, fileName);
37
- const fileStat = fs.statSync(filePathName);
38
- if (fileStat.isDirectory()) {
39
- fileNames = fileNames.concat(
40
- enumFileBaseNamesInDirectory({
41
- dirPath: filePathName,
42
- prefix: prefix ? `${prefix}/${fileName}` : fileName,
43
- fileNameFilter,
44
- }),
45
- );
46
- } else if (fileStat.isFile()) {
47
- if (fileNameFilter && !fileNameFilter(fileName)) {
48
- continue;
49
- }
50
-
51
- const baseName = path.parse(fileName).name;
52
- if (prefix) {
53
- fileNames.push(`${prefix}/${baseName}`);
54
- } else {
55
- fileNames.push(baseName);
56
- }
57
- }
58
- }
59
-
60
- fileNames.sort();
61
- return fileNames;
62
- }