@easyv/react-component-builder 0.22.3-beta → 0.22.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.
@@ -187,7 +187,7 @@ module.exports = function (content, map, meta) {
187
187
  callback(error);
188
188
  return true;
189
189
  }
190
- /----------- common assets start -------------/
190
+ /----------- common assets start -------------/;
191
191
  let commonAssets;
192
192
  try {
193
193
  let dataJsonFile = fs.existsSync(
@@ -203,7 +203,9 @@ module.exports = function (content, map, meta) {
203
203
  );
204
204
  } else {
205
205
  delete require.cache[
206
- require.resolve(path.resolve(configPath, name + '.common.assets.js'))
206
+ require.resolve(
207
+ path.resolve(configPath, name + '.common.assets.js'),
208
+ )
207
209
  ];
208
210
  commonAssets = require(path.resolve(
209
211
  configPath,
@@ -215,8 +217,7 @@ module.exports = function (content, map, meta) {
215
217
  // error.message += ` in ${configPath}${name}.common.assets.json or ${configPath}${name}.common.assets.js`;
216
218
  // callback(error);
217
219
  }
218
- /----------- common assets end -------------/
219
-
220
+ /----------- common assets end -------------/;
220
221
 
221
222
  if (names.has(config.base.module_name)) {
222
223
  callback(
@@ -359,6 +360,13 @@ module.exports = function (content, map, meta) {
359
360
  item[keys.value] = values;
360
361
  return item;
361
362
  }
363
+ if (item.customField && typeof item.customField === 'function') {
364
+ const newItem = {
365
+ ...item,
366
+ customField: item.customField.toString(),
367
+ };
368
+ return newItem;
369
+ }
362
370
  return item;
363
371
  });
364
372
  if (!updateChart) {
@@ -377,7 +385,7 @@ module.exports = function (content, map, meta) {
377
385
  }
378
386
  // 公共资源配置
379
387
  if (main.commonAssets && Array.isArray(main.commonAssets)) {
380
- mainConfig.commonAssets = main.commonAssets
388
+ mainConfig.commonAssets = main.commonAssets;
381
389
  }
382
390
 
383
391
  // 子组件排序,有配置项则以chilren排序,否则以文件顺序排序
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/react-component-builder",
3
- "version": "0.22.3-beta",
3
+ "version": "0.22.3",
4
4
  "files": [
5
5
  "launcher",
6
6
  "templates",
@@ -18,10 +18,10 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/core": "7.9.0",
21
- "@babel/preset-env": "^7.24.1",
21
+ "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
22
22
  "@babel/register": "^7.10.4",
23
- "@easyv/react-gui": "1.20.6",
24
- "@easyv/simulator": "0.6.2-beta",
23
+ "@easyv/react-gui": "1.20.9",
24
+ "@easyv/simulator": "0.6.2",
25
25
  "@svgr/webpack": "8.1.0",
26
26
  "acorn": "^7.3.1",
27
27
  "acorn-jsx": "^5.2.0",
@@ -54,7 +54,6 @@
54
54
  "webpack-manifest-plugin": "4.1.1"
55
55
  },
56
56
  "devDependencies": {
57
- "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
58
57
  "@easyv/sync-to-mirror": "^0.0.2",
59
58
  "@types/lodash": "^4.14.157",
60
59
  "@types/node": "^12.0.0",
package/utils/index.js CHANGED
@@ -1,37 +1,38 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const chalk = require("chalk");
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const chalk = require('chalk');
4
+ const { appComponents } = require('../config/paths');
4
5
 
5
6
  // todo: 把这个替换掉
6
- require("@babel/register")({
7
- presets: [require.resolve("@babel/preset-env")],
7
+ require('@babel/register')({
8
+ presets: [require.resolve('@babel/preset-env')],
8
9
  });
9
10
 
10
11
  function getConfigContent(componentFolder) {
11
12
  let jsonFileExist = fs.existsSync(
12
- path.join(componentFolder, "config/main.json")
13
+ path.join(componentFolder, 'config/main.json'),
13
14
  );
14
15
  if (jsonFileExist) {
15
16
  return JSON.parse(
16
- fs.readFileSync(path.join(componentFolder, "config/main.json"), {
17
- encoding: "utf8",
18
- })
17
+ fs.readFileSync(path.join(componentFolder, 'config/main.json'), {
18
+ encoding: 'utf8',
19
+ }),
19
20
  );
20
21
  } else {
21
- return require(path.resolve(componentFolder, "config/main.js")).default;
22
+ return require(path.resolve(componentFolder, 'config/main.js')).default;
22
23
  }
23
24
  }
24
25
 
25
26
  function getDataContent(componentFolder) {
26
27
  let jsonFileExist = fs.existsSync(
27
- path.join(componentFolder, "config/main.data.json")
28
+ path.join(componentFolder, 'config/main.data.json'),
28
29
  );
29
30
  if (jsonFileExist) {
30
31
  return JSON.parse(
31
- fs.readFileSync(path.join(componentFolder, "config/main.data.json"))
32
+ fs.readFileSync(path.join(componentFolder, 'config/main.data.json')),
32
33
  );
33
34
  } else {
34
- return require(path.resolve(componentFolder, "config/main.data.js"))
35
+ return require(path.resolve(componentFolder, 'config/main.data.js'))
35
36
  .default;
36
37
  }
37
38
  }
@@ -47,33 +48,33 @@ module.exports.checkComponentFiles = function checkConfigs(folder) {
47
48
  }
48
49
 
49
50
  {
50
- const oldConfigs = ["js/config.js", "mocks/data.js"];
51
+ const oldConfigs = ['js/config.js', 'mocks/data.js'];
51
52
  const exists = oldConfigs.every((file) =>
52
- fs.existsSync(path.join(folder, file))
53
+ fs.existsSync(path.join(folder, file)),
53
54
  );
54
55
  if (exists) {
55
56
  // 垫一下变量名防止js访问变量空指针
56
57
  global.window = {
57
58
  appConfig: {},
58
- ASSETS_URL: "",
59
+ ASSETS_URL: '',
59
60
  };
60
- const base = require(path.resolve(folder, "js/config.js")).config.base;
61
+ const base = require(path.resolve(folder, 'js/config.js')).config.base;
61
62
  return { base };
62
63
  }
63
64
  }
64
65
 
65
- const newConfigs = ["config/main", "config/main.data"];
66
+ const newConfigs = ['config/main', 'config/main.data'];
66
67
  newConfigs.every((file) => {
67
68
  if (
68
69
  !(
69
- fs.existsSync(path.join(folder, file + ".js")) ||
70
- fs.existsSync(path.join(folder, file + ".json"))
70
+ fs.existsSync(path.join(folder, file + '.js')) ||
71
+ fs.existsSync(path.join(folder, file + '.json'))
71
72
  )
72
73
  ) {
73
74
  console.error(
74
75
  chalk.red(
75
- `${file}.js or ${file}.json cannot be found in folder ${folder}, if the folder is not a component folder please move it out.`
76
- )
76
+ `${file}.js or ${file}.json cannot be found in folder ${folder}, if the folder is not a component folder please move it out.`,
77
+ ),
77
78
  );
78
79
  process.exit();
79
80
  }
@@ -87,5 +88,55 @@ module.exports.checkComponentFiles = function checkConfigs(folder) {
87
88
  };
88
89
  };
89
90
 
91
+ function getComponentBase(name) {
92
+ const sourcePath = path.join(appComponents, name);
93
+ if (!fs.existsSync(sourcePath)) {
94
+ console.error(chalk.red(`cannot found folder ${sourcePath}.`));
95
+ process.exit();
96
+ }
97
+
98
+ //旧配置
99
+ if (
100
+ fs.existsSync(path.join(sourcePath, 'js/config.js')) &&
101
+ fs.existsSync(path.join(sourcePath, 'mocks/data.js'))
102
+ ) {
103
+ const base = require(path.resolve(sourcePath, 'js/config.js')).config.base;
104
+ return { base };
105
+ }
106
+
107
+ //新配置
108
+ const newConfigs = ['config/main', 'config/main.data'];
109
+ newConfigs.every((file) => {
110
+ if (
111
+ !(
112
+ fs.existsSync(path.join(sourcePath, file + '.js')) ||
113
+ fs.existsSync(path.join(sourcePath, file + '.json'))
114
+ )
115
+ ) {
116
+ console.error(
117
+ chalk.red(
118
+ `${file}.js or ${file}.json cannot be found in folder ${sourcePath}, if the folder is not a component folder please move it out.`,
119
+ ),
120
+ );
121
+ process.exit();
122
+ }
123
+ return true;
124
+ });
125
+
126
+ let base = {};
127
+ if (fs.existsSync(path.join(sourcePath, 'config/main.json'))) {
128
+ base = JSON.parse(
129
+ fs.readFileSync(path.join(sourcePath, 'config/main.json'), {
130
+ encoding: 'utf8',
131
+ }),
132
+ ).base;
133
+ } else {
134
+ base = require(path.resolve(sourcePath, 'config/main.js')).default.base;
135
+ }
136
+
137
+ return { base };
138
+ }
139
+
90
140
  module.exports.getConfigContent = getConfigContent;
91
141
  module.exports.getDataContent = getDataContent;
142
+ module.exports.getComponentBase = getComponentBase;