@aiot-toolkit/emulator 2.0.2-dev.5 → 2.0.2-dev.6

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/lib/avd/index.js CHANGED
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
6
7
  const fs_1 = __importDefault(require("fs"));
7
8
  const path_1 = __importDefault(require("path"));
8
9
  const constants_1 = require("../static/constants");
@@ -62,7 +63,7 @@ class VelaAvdCls {
62
63
  return true;
63
64
  }
64
65
  catch (e) {
65
- return false;
66
+ throw (`createVelaAvd: ${e.message}`);
66
67
  }
67
68
  }
68
69
  getVelaAvdInfo(avdName) {
@@ -76,24 +77,30 @@ class VelaAvdCls {
76
77
  };
77
78
  const currAvdDir = path_1.default.resolve(this.avdHome, `${avdName}.avd`);
78
79
  const configIni = path_1.default.resolve(currAvdDir, 'config.ini');
79
- const contents = fs_1.default.readFileSync(configIni, 'utf-8');
80
- // 这里需要使用惰性匹配
81
- const archRegex = /hw.cpu.arch = ([\d\D]+?)\n/;
82
- const archMatcher = contents.match(archRegex);
83
- const heightRegex = /hw.lcd.height = ([\d\D]+?)\n/;
84
- const heightMatcher = contents.match(heightRegex);
85
- const widthRegex = /hw.lcd.width = ([\d\D]+?)\n/;
86
- const widthMatcher = contents.match(widthRegex);
87
- const skinRegex = /skin.name = ([\d\D]+?)\n/;
88
- const skinMatcher = contents.match(skinRegex);
89
- const imagePathRegex = /image.sysdir.1 = ([\d\D]+?)\n/;
90
- const imagePathMather = contents.match(imagePathRegex);
91
- archMatcher && (avdInfo.avdArch = archMatcher[1]);
92
- heightMatcher && (avdInfo.avdHeight = heightMatcher[1]);
93
- widthMatcher && (avdInfo.avdWidth = widthMatcher[1]);
94
- skinMatcher && (avdInfo.avdSkin = skinMatcher[1]);
95
- imagePathMather && (avdInfo.avdImagePath = imagePathMather[1]);
96
- return avdInfo;
80
+ try {
81
+ const contents = fs_1.default.readFileSync(configIni, 'utf-8');
82
+ // 这里需要使用惰性匹配
83
+ const archRegex = /hw.cpu.arch = ([\d\D]+?)\n/;
84
+ const archMatcher = contents.match(archRegex);
85
+ const heightRegex = /hw.lcd.height = ([\d\D]+?)\n/;
86
+ const heightMatcher = contents.match(heightRegex);
87
+ const widthRegex = /hw.lcd.width = ([\d\D]+?)\n/;
88
+ const widthMatcher = contents.match(widthRegex);
89
+ const skinRegex = /skin.name = ([\d\D]+?)\n/;
90
+ const skinMatcher = contents.match(skinRegex);
91
+ const imagePathRegex = /image.sysdir.1 = ([\d\D]+?)\n/;
92
+ const imagePathMather = contents.match(imagePathRegex);
93
+ archMatcher && (avdInfo.avdArch = archMatcher[1]);
94
+ heightMatcher && (avdInfo.avdHeight = heightMatcher[1]);
95
+ widthMatcher && (avdInfo.avdWidth = widthMatcher[1]);
96
+ skinMatcher && (avdInfo.avdSkin = skinMatcher[1]);
97
+ imagePathMather && (avdInfo.avdImagePath = imagePathMather[1]);
98
+ return avdInfo;
99
+ }
100
+ catch (err) {
101
+ ColorConsole_1.default.log(`getVelaAvdInfo: ${err.message}`);
102
+ return avdInfo;
103
+ }
97
104
  }
98
105
  deleteVelaAvd(avdName) {
99
106
  const avdDir = path_1.default.resolve(this.avdHome, `${avdName}.avd`);
@@ -108,23 +115,18 @@ class VelaAvdCls {
108
115
  }
109
116
  }
110
117
  getVelaAvdList() {
111
- try {
112
- const avdList = [];
113
- const files = fs_1.default.readdirSync(constants_1.defaultAvdHome);
114
- const regex = /^(Vela[\d\D]*)\.avd$/;
115
- for (const fileName of files) {
116
- const matcher = fileName.match(regex);
117
- if (matcher) {
118
- const avdName = matcher[1];
119
- const avdInfo = this.getVelaAvdInfo(avdName);
120
- avdList.push(avdInfo);
121
- }
118
+ const avdList = [];
119
+ const files = fs_1.default.readdirSync(this.avdHome);
120
+ const regex = /^(Vela[\d\D]*)\.avd$/;
121
+ for (const fileName of files) {
122
+ const matcher = fileName.match(regex);
123
+ if (matcher) {
124
+ const avdName = matcher[1];
125
+ const avdInfo = this.getVelaAvdInfo(avdName);
126
+ avdList.push(avdInfo);
122
127
  }
123
- return avdList;
124
- }
125
- catch (err) {
126
- return [];
127
128
  }
129
+ return avdList;
128
130
  }
129
131
  getVelaSkinList() {
130
132
  try {
@@ -137,7 +137,7 @@ class MiwearInstance extends common_1.default {
137
137
  const msg = data.toString();
138
138
  const stdoutCb = options.stdoutCallback || console.log;
139
139
  stdoutCb(msg);
140
- if (msg.match(/quickapp_rpk_installer_init | rpk installer init done/)) {
140
+ if (msg.match(/quickapp_rpk_installer_init|rpk installer init done/)) {
141
141
  ColorConsole_1.default.info(`### Emulator ### Goldfish emulator starts successfully`);
142
142
  resolve();
143
143
  }
@@ -226,12 +226,12 @@ class MiwearInstance extends common_1.default {
226
226
  yield (0, utils_1.sleep)(2000);
227
227
  }
228
228
  // 2. adb push应用的rpk
229
- const pushCmd = `adb -s ${sn} push ${rpkPath} ${targetDir}`;
229
+ const targetPath = `${targetDir}/${packageName}.rpk`;
230
+ const pushCmd = `adb -s ${sn} push ${rpkPath} ${targetPath}`;
230
231
  ColorConsole_1.default.info(`### Emulator ### Excuting cmd: ${pushCmd}`);
231
232
  yield adbMiwt.execAdbCmdAsync(pushCmd);
232
233
  yield (0, utils_1.sleep)(100);
233
234
  // 3. 安装应用
234
- const targetPath = `${targetDir}/${rpkName}`;
235
235
  const installCmd = `adb -s ${sn} shell pm install ${targetPath}`;
236
236
  ColorConsole_1.default.info(`### Emulator ### Excuting cmd: ${installCmd}`);
237
237
  adbMiwt.execAdbCmdAsync(installCmd);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/emulator",
3
- "version": "2.0.2-dev.5",
3
+ "version": "2.0.2-dev.6",
4
4
  "description": "vela emulator tool.",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -35,10 +35,10 @@
35
35
  "emulator"
36
36
  ],
37
37
  "dependencies": {
38
- "@aiot-toolkit/aiotpack": "2.0.2-dev.5",
39
- "@aiot-toolkit/shared-utils": "2.0.2-dev.5",
38
+ "@aiot-toolkit/aiotpack": "2.0.2-dev.6",
39
+ "@aiot-toolkit/shared-utils": "2.0.2-dev.6",
40
40
  "find-process": "^1.4.7",
41
41
  "portfinder": "^1.0.32"
42
42
  },
43
- "gitHead": "0c123fdd458966a4ca438cca03cc9efc2b5f634c"
43
+ "gitHead": "736a21d4d2f4fcc102766312d2529e426f27b6c4"
44
44
  }