ee-core 1.1.0 → 1.1.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/core/lib/ee.js CHANGED
@@ -94,7 +94,8 @@ class EeCore extends KoaApplication {
94
94
  logger: this.console,
95
95
  app: this,
96
96
  env: options.env,
97
- appUserData: options.appUserData
97
+ appUserData: options.appUserData,
98
+ isPackaged: options.isPackaged
98
99
  });
99
100
  }
100
101
 
@@ -38,7 +38,7 @@ class EeLoader {
38
38
  * @see {@link AppInfo#pkg}
39
39
  * @since 1.0.0
40
40
  */
41
- this.pkg = utility.readJSONSync(path.join(this.options.homeDir, 'package.json'));
41
+ this.pkg = this.getPkg();
42
42
 
43
43
  /**
44
44
  * Framework directories
@@ -127,7 +127,7 @@ class EeLoader {
127
127
  debug('Loaded appname(%s) from package.json', this.pkg.name);
128
128
  return this.pkg.name;
129
129
  }
130
- const pkg = path.join(this.options.baseDir, 'package.json');
130
+
131
131
  throw new Error(`name is required from ${pkg}`);
132
132
  }
133
133
 
@@ -407,6 +407,18 @@ class EeLoader {
407
407
 
408
408
  return fullPath;
409
409
  }
410
+
411
+ getPkg() {
412
+ //let filePath = '';
413
+ // let variablePath = 'build'; // 打包前路径
414
+ // if (this.options.isPackaged) {
415
+ // variablePath = '..'; // 打包后路径
416
+ // }
417
+ // filePath = path.join(app.getAppPath(), variablePath, "package.json");
418
+
419
+ const content = utility.readJSONSync(path.join(this.options.homeDir, 'package.json'));
420
+ return content;
421
+ }
410
422
  }
411
423
 
412
424
  /**
@@ -10,19 +10,23 @@ class Appliaction extends EeApp {
10
10
  // const opt = this.initEnv();
11
11
  const { env } = process;
12
12
 
13
+ // 路径不能使用绝对,打包前后有问题
14
+
15
+
13
16
  let options = {
14
17
  env: 'prod',
15
18
  serverScope: '',
16
19
  type: 'application',
17
20
  baseDir: path.join(app.getAppPath(), 'electron'),
18
- homeDir: process.cwd(),
19
- framework: path.join(process.cwd(), 'node_modules/ee-core'),
21
+ homeDir: app.getAppPath(),
22
+ framework: path.join(app.getAppPath(), 'node_modules', 'ee-core'),
20
23
  appName: app.getName(),
21
24
  userHome: app.getPath('home'),
22
25
  appData: app.getPath('appData'),
23
26
  appUserData: app.getPath('userData'),
24
27
  logsDir: app.getPath('logs'),
25
- appVersion: app.getVersion()
28
+ appVersion: app.getVersion(),
29
+ isPackaged: app.isPackaged
26
30
  }
27
31
 
28
32
  // argv
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ee-core",
3
- "version": "1.1.0",
4
- "description": "electron-egg core",
3
+ "version": "1.1.1",
4
+ "description": "ee core",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
package/utils/index.js CHANGED
@@ -50,7 +50,9 @@ exports.chmodPath = function(path, mode) {
50
50
  * 获取项目根目录package.json
51
51
  */
52
52
  exports.getPackage = function() {
53
- const filePath = path.join(process.cwd(), 'package.json');
53
+ const cdb = this.getCoreDB();
54
+ const config = cdb.getItem('config');
55
+ const filePath = path.join(config.homeDir, 'package.json');
54
56
  const json = require(filePath);
55
57
 
56
58
  return json;