ee-core 2.1.0-beta.3 → 2.1.0-beta.4

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/ee/application.js CHANGED
@@ -2,8 +2,9 @@ const Exception = require('../exception');
2
2
  const {app} = require('electron');
3
3
  const path = require('path');
4
4
  const debug = require('debug')('ee-core:Appliaction');
5
- const fs = require('fs');
6
5
  const EeApp = require('./eeApp');
6
+ const Utils = require('../utils');
7
+ const Ps = require('../ps');
7
8
 
8
9
  class Appliaction extends EeApp {
9
10
  constructor() {
@@ -43,10 +44,10 @@ class Appliaction extends EeApp {
43
44
  options.execDir = path.dirname(app.getPath('exe'));
44
45
  }
45
46
 
47
+ // Todo app.getAppPath() ??? process.cwd()
46
48
  // Use encryption, base directory is public/electron
47
- const encryptDir = path.join(app.getAppPath(), 'public', 'electron');
48
- if (options.env == 'prod' && fs.existsSync(encryptDir)) {
49
- options.baseDir = encryptDir;
49
+ if (options.env == 'prod' && Utils.isEncrypt(app.getAppPath())) {
50
+ options.baseDir = Ps.getEncryptDir(app.getAppPath());
50
51
  options.isEncrypted = true;
51
52
  }
52
53
 
package/ee/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ const Utils = require('../utils');
1
2
  const EEApplication = Symbol('Ee#Application');
2
3
 
3
4
  const EE = {
@@ -24,7 +25,14 @@ const EE = {
24
25
  */
25
26
  get app() {
26
27
  return this[EEApplication] || null;
27
- },
28
+ },
29
+
30
+ /**
31
+ * 是否加密
32
+ */
33
+ isEncrypt(basePath) {
34
+ return Utils.isEncrypt(basePath);
35
+ },
28
36
  }
29
37
 
30
38
  module.exports = EE;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ee-core",
3
- "version": "2.1.0-beta.3",
3
+ "version": "2.1.0-beta.4",
4
4
  "description": "ee core",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/ps/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  const path = require('path');
2
2
  const eis = require('../utils/is');
3
- const Log = require('../log');
4
3
 
5
4
  /**
6
5
  * 当前进程的所有env
@@ -112,6 +111,15 @@ exports.getLogDir = function () {
112
111
  return dir;
113
112
  }
114
113
 
114
+ /**
115
+ * 获取加密文件路径
116
+ */
117
+ exports.getEncryptDir = function (basePath) {
118
+ const base = basePath || process.cwd();
119
+ const dir = path.join(base, 'public', 'electron');
120
+ return dir;
121
+ }
122
+
115
123
  /**
116
124
  * 获取root目录 (dev-项目根目录,pro-app user data目录)
117
125
  */
package/utils/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const os = require("os");
4
4
  const path = require('path');
5
+ const fs = require('fs');
5
6
  const Ps = require('../ps');
6
7
  const UtilsJson = require('./json');
7
8
 
@@ -57,5 +58,15 @@ exports.isMAC = function(macAddress) {
57
58
  return macRegex.test(macAddress);
58
59
  }
59
60
 
61
+ /**
62
+ * is encrypt
63
+ */
64
+ exports.isEncrypt = function(basePath) {
65
+ const encryptDir = Ps.getEncryptDir(basePath);
66
+ if (fs.existsSync(encryptDir)) {
67
+ return true;
68
+ }
69
+ return false;
70
+ }
60
71
 
61
72