@abtnode/core 1.6.24 → 1.6.27

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 (2) hide show
  1. package/lib/util/sysinfo.js +30 -26
  2. package/package.json +14 -16
@@ -1,18 +1,29 @@
1
1
  const EventEmitter = require('events');
2
- const driveList = require('drivelist');
3
- const si = require('systeminformation');
4
- const checkDiskSpace = require('check-disk-space').default;
2
+ const maxBy = require('lodash/maxBy');
3
+ const SysInfo = require('systeminformation');
5
4
 
6
5
  const getSysInfo = async () => {
7
- const [info, drives] = await Promise.all([
8
- si.get({
9
- cpu: 'physicalCores',
10
- mem: '*',
11
- currentLoad: '*',
12
- osInfo: 'platform',
13
- }),
14
- driveList.list(),
15
- ]);
6
+ const info = await SysInfo.get({
7
+ cpu: 'physicalCores',
8
+ mem: '*',
9
+ currentLoad: '*',
10
+ fsSize: '*',
11
+ diskLayout: '*',
12
+ osInfo: 'platform',
13
+ });
14
+
15
+ let drives = info.fsSize;
16
+ if (info.osInfo.platform === 'darwin') {
17
+ const systemDrives = (info.fsSize || []).filter((x) => x.type === 'APFS');
18
+ const rootDrive = systemDrives.find((x) => x.mount === '/');
19
+ if (rootDrive) {
20
+ const maxUsedDrive = maxBy(systemDrives, (x) => x.used);
21
+ rootDrive.used = maxUsedDrive.used;
22
+ drives = [rootDrive];
23
+ } else {
24
+ drives = [];
25
+ }
26
+ }
16
27
 
17
28
  return {
18
29
  cpu: {
@@ -21,20 +32,13 @@ const getSysInfo = async () => {
21
32
  },
22
33
  mem: info.mem,
23
34
  os: info.osInfo,
24
- disks: await Promise.all(
25
- drives
26
- .filter((x) => x.isSystem && x.isVirtual === false && x.mountpoints.length)
27
- .map(async (x) => {
28
- const result = await checkDiskSpace(x.mountpoints[0].path);
29
- return {
30
- device: x.device,
31
- mountPoint: result.diskPath,
32
- total: result.size,
33
- used: result.size - result.free,
34
- free: result.free,
35
- };
36
- })
37
- ),
35
+ disks: drives.map((x) => ({
36
+ device: x.fs,
37
+ mountPoint: x.mount,
38
+ total: x.size,
39
+ used: x.used,
40
+ free: x.size - x.used,
41
+ })),
38
42
  };
39
43
  };
40
44
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.6.24",
6
+ "version": "1.6.27",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,22 +19,22 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@abtnode/certificate-manager": "1.6.24",
23
- "@abtnode/constant": "1.6.24",
24
- "@abtnode/cron": "1.6.24",
25
- "@abtnode/db": "1.6.24",
26
- "@abtnode/logger": "1.6.24",
27
- "@abtnode/queue": "1.6.24",
28
- "@abtnode/rbac": "1.6.24",
29
- "@abtnode/router-provider": "1.6.24",
30
- "@abtnode/static-server": "1.6.24",
31
- "@abtnode/timemachine": "1.6.24",
32
- "@abtnode/util": "1.6.24",
22
+ "@abtnode/certificate-manager": "1.6.27",
23
+ "@abtnode/constant": "1.6.27",
24
+ "@abtnode/cron": "1.6.27",
25
+ "@abtnode/db": "1.6.27",
26
+ "@abtnode/logger": "1.6.27",
27
+ "@abtnode/queue": "1.6.27",
28
+ "@abtnode/rbac": "1.6.27",
29
+ "@abtnode/router-provider": "1.6.27",
30
+ "@abtnode/static-server": "1.6.27",
31
+ "@abtnode/timemachine": "1.6.27",
32
+ "@abtnode/util": "1.6.27",
33
33
  "@arcblock/did": "^1.14.19",
34
34
  "@arcblock/event-hub": "1.14.19",
35
35
  "@arcblock/pm2-events": "^0.0.5",
36
36
  "@arcblock/vc": "^1.14.19",
37
- "@blocklet/meta": "1.6.24",
37
+ "@blocklet/meta": "1.6.27",
38
38
  "@fidm/x509": "^1.2.1",
39
39
  "@nedb/core": "^1.2.2",
40
40
  "@nedb/multi": "^1.2.2",
@@ -45,10 +45,8 @@
45
45
  "axios": "^0.25.0",
46
46
  "axon": "^2.0.3",
47
47
  "chalk": "^4.0.0",
48
- "check-disk-space": "^3.2.0",
49
48
  "deep-diff": "^1.0.2",
50
49
  "detect-port": "^1.3.0",
51
- "drivelist": "^9.2.4",
52
50
  "flat": "^5.0.2",
53
51
  "fs-extra": "^10.0.0",
54
52
  "get-port": "^5.1.1",
@@ -78,5 +76,5 @@
78
76
  "express": "^4.17.1",
79
77
  "jest": "^27.4.5"
80
78
  },
81
- "gitHead": "6bd8792a155ebbbefea6ca3d42c5b59b354d9879"
79
+ "gitHead": "5ec2dbcfa7d9464c0430ea3112e4fe0fbab65414"
82
80
  }