ee-core 1.5.1 → 1.5.2-beta.2

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.
Files changed (52) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +2 -2
  3. package/addon/window/index.js +91 -91
  4. package/bin/tools.js +18 -18
  5. package/config/config.default.js +280 -280
  6. package/core/index.js +12 -12
  7. package/core/lib/ee.js +218 -218
  8. package/core/lib/loader/context_loader.js +106 -106
  9. package/core/lib/loader/ee_loader.js +457 -457
  10. package/core/lib/loader/file_loader.js +325 -325
  11. package/core/lib/loader/mixin/addon.js +32 -32
  12. package/core/lib/loader/mixin/config.js +135 -135
  13. package/core/lib/loader/mixin/controller.js +124 -124
  14. package/core/lib/loader/mixin/service.js +28 -28
  15. package/core/lib/utils/base_context_class.js +34 -34
  16. package/core/lib/utils/index.js +127 -127
  17. package/core/lib/utils/sequencify.js +59 -59
  18. package/core/lib/utils/timing.js +77 -77
  19. package/index.js +49 -49
  20. package/lib/appLoader.js +53 -53
  21. package/lib/application.js +84 -84
  22. package/lib/baseApp.js +131 -131
  23. package/lib/constant.js +9 -9
  24. package/lib/eeApp.js +359 -359
  25. package/lib/httpclient.js +136 -136
  26. package/lib/logger.js +46 -46
  27. package/lib/socket/httpServer.js +142 -142
  28. package/lib/socket/io.js +23 -23
  29. package/lib/socket/ipcServer.js +108 -108
  30. package/lib/socket/socketClient.js +50 -50
  31. package/lib/socket/socketServer.js +76 -76
  32. package/lib/socket/start.js +22 -22
  33. package/lib/storage/index.js +33 -33
  34. package/lib/storage/lowdb/adapters/Base.js +15 -0
  35. package/lib/storage/lowdb/adapters/FileAsync.js +41 -0
  36. package/lib/storage/lowdb/adapters/FileSync.js +39 -0
  37. package/lib/storage/lowdb/adapters/LocalStorage.js +20 -0
  38. package/lib/storage/lowdb/adapters/Memory.js +8 -0
  39. package/lib/storage/lowdb/adapters/_stringify.js +4 -0
  40. package/lib/storage/lowdb/common.js +33 -0
  41. package/lib/storage/lowdb/fp.js +23 -0
  42. package/lib/storage/lowdb/isPromise.js +6 -0
  43. package/lib/storage/lowdb/main.js +46 -0
  44. package/lib/storage/lowdb/nano.js +5 -0
  45. package/lib/storage/lowdbStorage.js +98 -98
  46. package/lib/storage/sqliteStorage.js +127 -127
  47. package/package.json +48 -45
  48. package/tools/encrypt.js +274 -274
  49. package/tools/replaceDist.js +61 -61
  50. package/utils/common.js +90 -90
  51. package/utils/index.js +246 -246
  52. package/utils/wrap.js +37 -37
@@ -1,61 +1,61 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const fs = require('fs');
5
- const fsPro = require('fs-extra');
6
-
7
- /**
8
- * 资源替换
9
- */
10
-
11
- module.exports = {
12
-
13
- /**
14
- * 执行
15
- */
16
- run () {
17
- console.log('[ee-core] [replace_dist] 开始移动资源');
18
- const homeDir = process.cwd();
19
-
20
- // argv
21
- let distDir = '';
22
- for (let i = 0; i < process.argv.length; i++) {
23
- let tmpArgv = process.argv[i]
24
- if (tmpArgv.indexOf('--dist_dir=') !== -1) {
25
- distDir = tmpArgv.substring(11)
26
- }
27
- }
28
-
29
- const fileExist = (filePath) => {
30
- try {
31
- return fs.statSync(filePath).isFile();
32
- } catch (err) {
33
- console.error('[ee-core] [replace_dist] ERROR ', err);
34
- return false;
35
- }
36
- };
37
-
38
- const sourceDir = path.join(homeDir, distDir);
39
- const sourceIndexFile = path.join(sourceDir, 'index.html');
40
-
41
- if (!fileExist(sourceIndexFile)) {
42
- console.error('[ee-core] [replace_dist] ERROR 前端资源不存在,请构建!!!');
43
- return
44
- }
45
-
46
- // 复制到ee资源目录
47
- const eeResourceDir = path.join(homeDir, 'public', 'dist');
48
-
49
- // 清空历史资源
50
- fs.rmdirSync(eeResourceDir, {recursive: true});
51
- console.log('[ee-core] [replace_dist] 清空历史资源:', eeResourceDir);
52
-
53
- fsPro.copySync(sourceDir, eeResourceDir);
54
- console.log('[ee-core] [replace_dist] 复制资源到:', eeResourceDir);
55
-
56
- console.log('[ee-core] [replace_dist] 结束');
57
- }
58
- }
59
-
60
-
61
-
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+ const fsPro = require('fs-extra');
6
+
7
+ /**
8
+ * 资源替换
9
+ */
10
+
11
+ module.exports = {
12
+
13
+ /**
14
+ * 执行
15
+ */
16
+ run () {
17
+ console.log('[ee-core] [replace_dist] 开始移动资源');
18
+ const homeDir = process.cwd();
19
+
20
+ // argv
21
+ let distDir = '';
22
+ for (let i = 0; i < process.argv.length; i++) {
23
+ let tmpArgv = process.argv[i]
24
+ if (tmpArgv.indexOf('--dist_dir=') !== -1) {
25
+ distDir = tmpArgv.substring(11)
26
+ }
27
+ }
28
+
29
+ const fileExist = (filePath) => {
30
+ try {
31
+ return fs.statSync(filePath).isFile();
32
+ } catch (err) {
33
+ console.error('[ee-core] [replace_dist] ERROR ', err);
34
+ return false;
35
+ }
36
+ };
37
+
38
+ const sourceDir = path.join(homeDir, distDir);
39
+ const sourceIndexFile = path.join(sourceDir, 'index.html');
40
+
41
+ if (!fileExist(sourceIndexFile)) {
42
+ console.error('[ee-core] [replace_dist] ERROR 前端资源不存在,请构建!!!');
43
+ return
44
+ }
45
+
46
+ // 复制到ee资源目录
47
+ const eeResourceDir = path.join(homeDir, 'public', 'dist');
48
+
49
+ // 清空历史资源
50
+ fs.rmdirSync(eeResourceDir, {recursive: true});
51
+ console.log('[ee-core] [replace_dist] 清空历史资源:', eeResourceDir);
52
+
53
+ fsPro.copySync(sourceDir, eeResourceDir);
54
+ console.log('[ee-core] [replace_dist] 复制资源到:', eeResourceDir);
55
+
56
+ console.log('[ee-core] [replace_dist] 结束');
57
+ }
58
+ }
59
+
60
+
61
+
package/utils/common.js CHANGED
@@ -1,91 +1,91 @@
1
- 'use strict';
2
-
3
- /**
4
- * ee-core使用
5
- */
6
-
7
- const fs = require('fs');
8
- const path = require('path');
9
-
10
- /**
11
- * 版本号比较
12
- */
13
- exports.compareVersion = function (v1, v2) {
14
- v1 = v1.split('.')
15
- v2 = v2.split('.')
16
- const len = Math.max(v1.length, v2.length)
17
-
18
- while (v1.length < len) {
19
- v1.push('0')
20
- }
21
- while (v2.length < len) {
22
- v2.push('0')
23
- }
24
-
25
- for (let i = 0; i < len; i++) {
26
- const num1 = parseInt(v1[i])
27
- const num2 = parseInt(v2[i])
28
-
29
- if (num1 > num2) {
30
- return 1
31
- } else if (num1 < num2) {
32
- return -1
33
- }
34
- }
35
-
36
- return 0
37
- }
38
-
39
- /**
40
- * 创建文件夹
41
- */
42
- exports.mkdir = function(dirpath, dirname) {
43
- // 判断是否是第一次调用
44
- if (typeof dirname === 'undefined') {
45
- if (fs.existsSync(dirpath)) {
46
- return;
47
- }
48
- this.mkdir(dirpath, path.dirname(dirpath));
49
- } else {
50
- // 判断第二个参数是否正常,避免调用时传入错误参数
51
- if (dirname !== path.dirname(dirpath)) {
52
- this.mkdir(dirpath);
53
- return;
54
- }
55
- if (fs.existsSync(dirname)) {
56
- fs.mkdirSync(dirpath);
57
- } else {
58
- this.mkdir(dirname, path.dirname(dirname));
59
- fs.mkdirSync(dirpath);
60
- }
61
- }
62
- };
63
-
64
- /**
65
- * 修改文件权限
66
- */
67
- exports.chmodPath = function(path, mode) {
68
- let files = [];
69
- if (fs.existsSync(path)) {
70
- files = fs.readdirSync(path);
71
- files.forEach((file, index) => {
72
- const curPath = path + '/' + file;
73
- if (fs.statSync(curPath).isDirectory()) {
74
- this.chmodPath(curPath, mode); // 递归删除文件夹
75
- } else {
76
- fs.chmodSync(curPath, mode);
77
- }
78
- });
79
- fs.chmodSync(path, mode);
80
- }
81
- };
82
-
83
- /**
84
- * 获取数据存储路径
85
- */
86
- exports.getStorageDir = function () {
87
- let env = process.env.EE_SERVER_ENV;
88
- const appDir = env === 'local' || env === 'unittest' ? process.env.EE_HOME : process.env.EE_APP_USER_DATA;
89
- const storageDir = path.join(appDir, 'data');
90
- return storageDir;
1
+ 'use strict';
2
+
3
+ /**
4
+ * ee-core使用
5
+ */
6
+
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+
10
+ /**
11
+ * 版本号比较
12
+ */
13
+ exports.compareVersion = function (v1, v2) {
14
+ v1 = v1.split('.')
15
+ v2 = v2.split('.')
16
+ const len = Math.max(v1.length, v2.length)
17
+
18
+ while (v1.length < len) {
19
+ v1.push('0')
20
+ }
21
+ while (v2.length < len) {
22
+ v2.push('0')
23
+ }
24
+
25
+ for (let i = 0; i < len; i++) {
26
+ const num1 = parseInt(v1[i])
27
+ const num2 = parseInt(v2[i])
28
+
29
+ if (num1 > num2) {
30
+ return 1
31
+ } else if (num1 < num2) {
32
+ return -1
33
+ }
34
+ }
35
+
36
+ return 0
37
+ }
38
+
39
+ /**
40
+ * 创建文件夹
41
+ */
42
+ exports.mkdir = function(dirpath, dirname) {
43
+ // 判断是否是第一次调用
44
+ if (typeof dirname === 'undefined') {
45
+ if (fs.existsSync(dirpath)) {
46
+ return;
47
+ }
48
+ this.mkdir(dirpath, path.dirname(dirpath));
49
+ } else {
50
+ // 判断第二个参数是否正常,避免调用时传入错误参数
51
+ if (dirname !== path.dirname(dirpath)) {
52
+ this.mkdir(dirpath);
53
+ return;
54
+ }
55
+ if (fs.existsSync(dirname)) {
56
+ fs.mkdirSync(dirpath);
57
+ } else {
58
+ this.mkdir(dirname, path.dirname(dirname));
59
+ fs.mkdirSync(dirpath);
60
+ }
61
+ }
62
+ };
63
+
64
+ /**
65
+ * 修改文件权限
66
+ */
67
+ exports.chmodPath = function(path, mode) {
68
+ let files = [];
69
+ if (fs.existsSync(path)) {
70
+ files = fs.readdirSync(path);
71
+ files.forEach((file, index) => {
72
+ const curPath = path + '/' + file;
73
+ if (fs.statSync(curPath).isDirectory()) {
74
+ this.chmodPath(curPath, mode); // 递归删除文件夹
75
+ } else {
76
+ fs.chmodSync(curPath, mode);
77
+ }
78
+ });
79
+ fs.chmodSync(path, mode);
80
+ }
81
+ };
82
+
83
+ /**
84
+ * 获取数据存储路径
85
+ */
86
+ exports.getStorageDir = function () {
87
+ let env = process.env.EE_SERVER_ENV;
88
+ const appDir = env === 'local' || env === 'unittest' ? process.env.EE_HOME : process.env.EE_APP_USER_DATA;
89
+ const storageDir = path.join(appDir, 'data');
90
+ return storageDir;
91
91
  }