@aiot-toolkit/emulator 2.0.2-beta.3 → 2.0.2-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/lib/instance/miwear.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import CommonInstance from './common';
|
|
|
5
5
|
* 针对 vela4.0 的镜像
|
|
6
6
|
*/
|
|
7
7
|
declare class MiwearInstance extends CommonInstance {
|
|
8
|
+
private params;
|
|
8
9
|
private appPathInEmulator;
|
|
9
10
|
private debugSocket?;
|
|
10
11
|
private reconnectCount;
|
|
@@ -19,7 +20,7 @@ declare class MiwearInstance extends CommonInstance {
|
|
|
19
20
|
startupQuickApp(options: IStartOptions): Promise<void>;
|
|
20
21
|
/** 将快应用安装到应用列表 */
|
|
21
22
|
installRpkToAppList(rpkPath: string, targetDir: string): Promise<void>;
|
|
22
|
-
initDebugSocket(): Promise<void
|
|
23
|
+
initDebugSocket(): Promise<void>;
|
|
23
24
|
/** 通知模拟器更新 */
|
|
24
25
|
handleUpdate(): Promise<void>;
|
|
25
26
|
/** 创建server */
|
package/lib/instance/miwear.js
CHANGED
|
@@ -35,7 +35,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
const JavascriptDefaultCompileOption_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/compiler/javascript/JavascriptDefaultCompileOption"));
|
|
39
38
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
40
39
|
const adbMiwt = __importStar(require("@miwt/adb"));
|
|
41
40
|
const child_process_1 = require("child_process");
|
|
@@ -55,6 +54,7 @@ const MAX_RECONNECT_COUNT = 8;
|
|
|
55
54
|
class MiwearInstance extends common_1.default {
|
|
56
55
|
constructor(params) {
|
|
57
56
|
super(params);
|
|
57
|
+
this.params = params;
|
|
58
58
|
this.appPathInEmulator = '/data/quickapp/app';
|
|
59
59
|
this.reconnectCount = 0;
|
|
60
60
|
}
|
|
@@ -155,8 +155,6 @@ class MiwearInstance extends common_1.default {
|
|
|
155
155
|
ColorConsole_1.default.info(`### Emulator ### Goldfish emulator starts successfully`);
|
|
156
156
|
resolve();
|
|
157
157
|
}, 8000);
|
|
158
|
-
ColorConsole_1.default.info(`### Emulator ### Goldfish emulator starts successfully`);
|
|
159
|
-
resolve();
|
|
160
158
|
}
|
|
161
159
|
});
|
|
162
160
|
});
|
|
@@ -193,13 +191,16 @@ class MiwearInstance extends common_1.default {
|
|
|
193
191
|
}
|
|
194
192
|
/** 在goldfish中启动快应用 */
|
|
195
193
|
startupQuickApp(options) {
|
|
194
|
+
var _a;
|
|
196
195
|
return __awaiter(this, void 0, void 0, function* () {
|
|
197
196
|
const { package: appPackageName } = this.projectInfo;
|
|
198
|
-
const releaseDir =
|
|
197
|
+
const releaseDir = this.isRpk
|
|
198
|
+
? path_1.default.resolve(this.projectPath, '../')
|
|
199
|
+
: path_1.default.resolve(this.projectPath, ((_a = this.params.compilerOption) === null || _a === void 0 ? void 0 : _a.releasePath) || 'dist');
|
|
199
200
|
const files = fs_extra_1.default
|
|
200
201
|
.readdirSync(releaseDir)
|
|
201
202
|
.filter(item => item.includes(appPackageName) && item.endsWith('.rpk'));
|
|
202
|
-
if (files.length
|
|
203
|
+
if (files.length === 0) {
|
|
203
204
|
ColorConsole_1.default.error(`### Emulator the rpk does not exist`);
|
|
204
205
|
}
|
|
205
206
|
const rpkPath = path_1.default.resolve(releaseDir, files[0]);
|
|
@@ -221,7 +222,6 @@ class MiwearInstance extends common_1.default {
|
|
|
221
222
|
try {
|
|
222
223
|
const sn = `127.0.0.1:${this.adbPort}`;
|
|
223
224
|
const { package: packageName } = this.projectInfo;
|
|
224
|
-
const rpkName = path_1.default.basename(rpkPath);
|
|
225
225
|
// 1. 查询应用是否已经安装,如果安装了,则先卸载
|
|
226
226
|
const lsCmd = `adb -s ${sn} shell ls ${this.appPathInEmulator}`;
|
|
227
227
|
const res = yield adbMiwt.execAdbCmdAsync(lsCmd);
|
|
@@ -234,7 +234,7 @@ class MiwearInstance extends common_1.default {
|
|
|
234
234
|
}
|
|
235
235
|
// 2. adb push应用的rpk
|
|
236
236
|
const targetPath = `${targetDir}/${packageName}.rpk`;
|
|
237
|
-
const pushCmd = `adb -s ${sn} push ${rpkPath} ${targetPath}`;
|
|
237
|
+
const pushCmd = `adb -s ${sn} push "${rpkPath}" ${targetPath}`;
|
|
238
238
|
ColorConsole_1.default.info(`### Emulator ### Excuting cmd: ${pushCmd}`);
|
|
239
239
|
yield adbMiwt.execAdbCmdAsync(pushCmd);
|
|
240
240
|
yield (0, utils_1.sleep)(100);
|
|
@@ -243,38 +243,42 @@ class MiwearInstance extends common_1.default {
|
|
|
243
243
|
ColorConsole_1.default.info(`### Emulator ### Excuting cmd: ${installCmd}`);
|
|
244
244
|
adbMiwt.execAdbCmdAsync(installCmd);
|
|
245
245
|
}
|
|
246
|
-
catch (e) {
|
|
246
|
+
catch (e) {
|
|
247
|
+
ColorConsole_1.default.error(`### Emulator ### ${e.message}`);
|
|
248
|
+
}
|
|
247
249
|
});
|
|
248
250
|
}
|
|
249
251
|
initDebugSocket() {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
this.debugSocket = new ws_1.default(`ws://localhost:${this.debugPort}`);
|
|
254
|
-
this.debugSocket.onopen = () => {
|
|
255
|
-
ColorConsole_1.default.info(`### Emulator debugSocket connect success`);
|
|
256
|
-
return Promise.resolve();
|
|
257
|
-
};
|
|
258
|
-
this.debugSocket.onerror = (e) => {
|
|
259
|
-
var _a;
|
|
260
|
-
// 重连机制
|
|
261
|
-
(_a = this.debugSocket) === null || _a === void 0 ? void 0 : _a.terminate();
|
|
262
|
-
if (this.reconnectCount < MAX_RECONNECT_COUNT) {
|
|
263
|
-
ColorConsole_1.default.info(`### Emulator the ${this.reconnectCount + 1}th time to reconnect debug server`);
|
|
264
|
-
this.reconnectCount++;
|
|
265
|
-
setTimeout(() => this.initDebugSocket(), 2000);
|
|
252
|
+
return new Promise((resolve, reject) => {
|
|
253
|
+
if (this.debugSocket && this.debugSocket.OPEN) {
|
|
254
|
+
return resolve();
|
|
266
255
|
}
|
|
267
|
-
|
|
256
|
+
this.debugSocket = new ws_1.default(`ws://localhost:${this.debugPort}`);
|
|
257
|
+
this.debugSocket.onopen = () => {
|
|
258
|
+
ColorConsole_1.default.info(`### Emulator debugSocket connect success`);
|
|
259
|
+
return resolve();
|
|
260
|
+
};
|
|
261
|
+
this.debugSocket.onerror = (errorEvent) => {
|
|
262
|
+
var _a;
|
|
263
|
+
// 重连机制
|
|
264
|
+
(_a = this.debugSocket) === null || _a === void 0 ? void 0 : _a.terminate();
|
|
265
|
+
if (this.reconnectCount < MAX_RECONNECT_COUNT) {
|
|
266
|
+
ColorConsole_1.default.info(`### Emulator the ${this.reconnectCount + 1}th time to reconnect debug server`);
|
|
267
|
+
this.reconnectCount++;
|
|
268
|
+
setTimeout(() => this.initDebugSocket(), 2000);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
this.debugSocket = undefined;
|
|
272
|
+
this.reconnectCount = 0;
|
|
273
|
+
return reject(`### Emulator debugSocket connect failed, ${errorEvent.message}`);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
this.debugSocket.onclose = (closeEvent) => {
|
|
268
277
|
this.debugSocket = undefined;
|
|
269
278
|
this.reconnectCount = 0;
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
this.debugSocket.onclose = (e) => {
|
|
274
|
-
this.debugSocket = undefined;
|
|
275
|
-
this.reconnectCount = 0;
|
|
276
|
-
ColorConsole_1.default.log(`### Emulator debugSocket connect close: ${e.data}`);
|
|
277
|
-
};
|
|
279
|
+
ColorConsole_1.default.log(`### Emulator debugSocket connect close: ${closeEvent.reason}`);
|
|
280
|
+
};
|
|
281
|
+
});
|
|
278
282
|
}
|
|
279
283
|
/** 通知模拟器更新 */
|
|
280
284
|
handleUpdate() {
|
|
@@ -286,12 +290,13 @@ class MiwearInstance extends common_1.default {
|
|
|
286
290
|
// 1. 将整包重新推到miwear中(TODO:增量更新)
|
|
287
291
|
const sn = `127.0.0.1:${this.adbPort}`;
|
|
288
292
|
const { package: appPackageName } = this.projectInfo;
|
|
289
|
-
// windows平台adb push
|
|
290
|
-
|
|
293
|
+
// windows平台adb push时无法使用通配符,需另外处理;
|
|
294
|
+
// 项目路径包含空格时,无法通过加引号来使用 * 通配符
|
|
295
|
+
if (os_1.default.platform() === 'win32' || this.projectPath.indexOf(' ') > 0) {
|
|
291
296
|
const rmCmd = `adb -s ${sn} shell rm -r ${this.appPathInEmulator}/${appPackageName}`;
|
|
292
297
|
yield adbMiwt.execAdbCmdAsync(rmCmd);
|
|
293
298
|
const sourcePath = path_1.default.resolve(this.projectPath, './build');
|
|
294
|
-
const pushCmd = `adb -s ${sn} push ${sourcePath} ${this.appPathInEmulator}/${appPackageName}`;
|
|
299
|
+
const pushCmd = `adb -s ${sn} push "${sourcePath}" ${this.appPathInEmulator}/${appPackageName}`;
|
|
295
300
|
yield adbMiwt.execAdbCmdAsync(pushCmd);
|
|
296
301
|
}
|
|
297
302
|
else {
|
|
@@ -6,14 +6,17 @@ export declare const defaultSkinHome: string;
|
|
|
6
6
|
export declare const defaultQuickappHome: string;
|
|
7
7
|
export declare const defaultToolsHome: string;
|
|
8
8
|
export declare const defaultVncPort = 5900;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const VelaImageVersionList: {
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
time: string;
|
|
13
|
+
}[];
|
|
14
|
+
export declare const EmulatorEnvVersion: {
|
|
10
15
|
name: string;
|
|
11
16
|
emulator: string;
|
|
12
17
|
qa: string;
|
|
13
18
|
skins: string;
|
|
14
|
-
'system-images':
|
|
15
|
-
release: string;
|
|
16
|
-
dev: string;
|
|
17
|
-
};
|
|
19
|
+
'system-images': string;
|
|
18
20
|
tools: string;
|
|
21
|
+
modem_simulator: string;
|
|
19
22
|
};
|
package/lib/static/constants.js
CHANGED
|
@@ -3,7 +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
|
-
exports.
|
|
6
|
+
exports.EmulatorEnvVersion = exports.VelaImageVersionList = exports.defaultVncPort = exports.defaultToolsHome = exports.defaultQuickappHome = exports.defaultSkinHome = exports.defaultEmulatorHome = exports.defaultImageHome = exports.defaultAvdHome = exports.defaultSDKHome = void 0;
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
exports.defaultSDKHome = path_1.default.resolve(os_1.default.homedir(), '.export');
|
|
@@ -14,14 +14,24 @@ exports.defaultSkinHome = path_1.default.resolve(exports.defaultSDKHome, 'skins'
|
|
|
14
14
|
exports.defaultQuickappHome = path_1.default.resolve(exports.defaultSDKHome, 'qa');
|
|
15
15
|
exports.defaultToolsHome = path_1.default.resolve(exports.defaultSDKHome, 'tools');
|
|
16
16
|
exports.defaultVncPort = 5900;
|
|
17
|
-
exports.
|
|
17
|
+
exports.VelaImageVersionList = [
|
|
18
|
+
{
|
|
19
|
+
label: 'vela正式版(4.0)',
|
|
20
|
+
value: 'vela-release-4.0',
|
|
21
|
+
time: '2024-03-28T04:11:00'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: 'vela开发版(dev, 0.0.2)',
|
|
25
|
+
value: 'vela-dev-0.0.2',
|
|
26
|
+
time: '2023-12-04T16:31:00',
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
exports.EmulatorEnvVersion = {
|
|
18
30
|
name: '模拟器资源版本管理',
|
|
19
|
-
emulator: '0.0.
|
|
31
|
+
emulator: '0.0.3',
|
|
20
32
|
qa: '0.0.1',
|
|
21
33
|
skins: '0.0.1',
|
|
22
|
-
'system-images':
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
tools: '0.0.2'
|
|
34
|
+
'system-images': exports.VelaImageVersionList[0].value,
|
|
35
|
+
tools: '0.0.2',
|
|
36
|
+
modem_simulator: '0.0.1'
|
|
27
37
|
};
|
package/lib/typing/Instance.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import IJavascriptCompileOption from "@aiot-toolkit/aiotpack/lib/compiler/javascript/interface/IJavascriptCompileOption";
|
|
2
3
|
import { IAvdResourcePaths } from "./Avd";
|
|
3
4
|
export interface INewGoldfishInstanceParams extends IAvdResourcePaths {
|
|
4
5
|
projectPath: string;
|
|
5
6
|
sourceRoot?: string;
|
|
7
|
+
compilerOption?: Partial<IJavascriptCompileOption>;
|
|
6
8
|
}
|
|
7
9
|
export interface IStartOptions {
|
|
8
10
|
avdName: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/emulator",
|
|
3
|
-
"version": "2.0.2-beta.
|
|
3
|
+
"version": "2.0.2-beta.4",
|
|
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-beta.
|
|
39
|
-
"@aiot-toolkit/shared-utils": "2.0.2-beta.
|
|
38
|
+
"@aiot-toolkit/aiotpack": "2.0.2-beta.4",
|
|
39
|
+
"@aiot-toolkit/shared-utils": "2.0.2-beta.4",
|
|
40
40
|
"find-process": "^1.4.7",
|
|
41
41
|
"portfinder": "^1.0.32"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "656add8e64d8101b9f3886957c5b9ae23e2e854f"
|
|
44
44
|
}
|