aiot-toolkit 2.0.2-dev.8 → 2.0.2
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/bin.js +43 -46
- package/lib/builder/AndroidUxBuilder.d.ts +10 -0
- package/lib/builder/AndroidUxBuilder.js +20 -0
- package/lib/builder/UxBuilderBase.d.ts +36 -0
- package/lib/builder/UxBuilderBase.js +105 -0
- package/lib/builder/VelaUxBuilder.d.ts +23 -0
- package/lib/builder/VelaUxBuilder.js +66 -0
- package/lib/builder/XtsBuilder.js +14 -17
- package/lib/interface/VelaEmulatorInterface.d.ts +7 -6
- package/lib/starter/AndroidUxStart.d.ts +40 -0
- package/lib/starter/AndroidUxStart.js +171 -0
- package/lib/starter/IStarter.d.ts +2 -1
- package/lib/starter/IStarter.js +5 -1
- package/lib/starter/VelaUxStarter.d.ts +23 -0
- package/lib/starter/VelaUxStarter.js +198 -0
- package/lib/starter/XtsStarter.d.ts +2 -2
- package/lib/starter/androidRouter/LinkMode.d.ts +9 -0
- package/lib/starter/androidRouter/LinkMode.js +12 -0
- package/lib/starter/androidRouter/PackageRouter.d.ts +55 -0
- package/lib/starter/androidRouter/PackageRouter.js +152 -0
- package/lib/starter/androidRouter/h5/index.css +167 -0
- package/lib/starter/androidRouter/h5/index.html +58 -0
- package/lib/starter/androidRouter/h5/index.js +66 -0
- package/lib/utils/AdbUtils.d.ts +0 -1
- package/lib/utils/AdbUtils.js +3 -14
- package/lib/utils/DeviceUtil.js +42 -29
- package/lib/utils/RequestUtils.js +5 -5
- package/lib/utils/VelaAvdUtils.d.ts +25 -9
- package/lib/utils/VelaAvdUtils.js +262 -100
- package/package.json +20 -12
- package/lib/builder/UxBuilder.d.ts +0 -27
- package/lib/builder/UxBuilder.js +0 -128
- package/lib/starter/UxStarter.d.ts +0 -10
- package/lib/starter/UxStarter.js +0 -139
- package/lib/utils/UxBuilderUtils.d.ts +0 -8
- package/lib/utils/UxBuilderUtils.js +0 -51
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
.alert-warning {
|
|
2
|
+
color: #8a6d3b;
|
|
3
|
+
background-color: #fcf8e3;
|
|
4
|
+
border-color: #faebcc;
|
|
5
|
+
text-align: left;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.alert {
|
|
9
|
+
padding: 8px;
|
|
10
|
+
margin: 10px auto;
|
|
11
|
+
width: 400px;
|
|
12
|
+
min-width: 350px;
|
|
13
|
+
border: 1px solid transparent;
|
|
14
|
+
border-radius: 6px;
|
|
15
|
+
box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.alert p {
|
|
19
|
+
margin: 6px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.panel-default {
|
|
23
|
+
border-color: #ddd;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.panel {
|
|
27
|
+
margin-bottom: 20px;
|
|
28
|
+
background-color: #fff;
|
|
29
|
+
border-radius: 4px;
|
|
30
|
+
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
|
31
|
+
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
|
|
32
|
+
margin: 10px auto;
|
|
33
|
+
box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
|
|
34
|
+
width: 400px;
|
|
35
|
+
min-width: 350px;
|
|
36
|
+
padding: 8px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.panel-default > .panel-heading {
|
|
40
|
+
color: #333;
|
|
41
|
+
border-color: #ddd;
|
|
42
|
+
text-align: left;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.panel-heading {
|
|
46
|
+
padding: 8px 15px;
|
|
47
|
+
border-bottom: 1px solid transparent;
|
|
48
|
+
border-top-left-radius: 3px;
|
|
49
|
+
border-top-right-radius: 3px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.table {
|
|
53
|
+
width: 100%;
|
|
54
|
+
max-width: 100%;
|
|
55
|
+
margin: 6px;
|
|
56
|
+
background-color: transparent;
|
|
57
|
+
border-spacing: 0;
|
|
58
|
+
border-collapse: collapse;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.table td {
|
|
62
|
+
color: black;
|
|
63
|
+
text-shadow: none;
|
|
64
|
+
text-align: left;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.table td.tname {
|
|
68
|
+
width: 70%;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
body {
|
|
72
|
+
margin: 0;
|
|
73
|
+
display: block;
|
|
74
|
+
position: absolute;
|
|
75
|
+
top: 0;
|
|
76
|
+
bottom: 0;
|
|
77
|
+
left: 0;
|
|
78
|
+
right: 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.hide {
|
|
82
|
+
display: none !important;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.qr-code-panel {
|
|
86
|
+
text-align: center;
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.qr-code-panel .qr-img {
|
|
92
|
+
margin: 10px 200px;
|
|
93
|
+
min-width: 350px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.bd-bg {
|
|
97
|
+
position: relative;
|
|
98
|
+
padding: 40px 0;
|
|
99
|
+
color: black;
|
|
100
|
+
text-align: center;
|
|
101
|
+
background: #eee;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.updatetip-link {
|
|
105
|
+
padding: 0 5px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
table.tunning tr {
|
|
109
|
+
padding: 8px 15px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.btn {
|
|
113
|
+
display: inline-block;
|
|
114
|
+
padding: 6px 12px;
|
|
115
|
+
margin-bottom: 0;
|
|
116
|
+
font-size: 14px;
|
|
117
|
+
font-weight: 400;
|
|
118
|
+
line-height: 1.42857143;
|
|
119
|
+
text-align: center;
|
|
120
|
+
white-space: nowrap;
|
|
121
|
+
vertical-align: middle;
|
|
122
|
+
-ms-touch-action: manipulation;
|
|
123
|
+
touch-action: manipulation;
|
|
124
|
+
cursor: pointer;
|
|
125
|
+
-webkit-user-select: none;
|
|
126
|
+
-moz-user-select: none;
|
|
127
|
+
-ms-user-select: none;
|
|
128
|
+
user-select: none;
|
|
129
|
+
background-image: none;
|
|
130
|
+
border: 1px solid transparent;
|
|
131
|
+
border-radius: 4px;
|
|
132
|
+
margin-left: 5px;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.btn-default {
|
|
136
|
+
color: #333;
|
|
137
|
+
background-color: #fff;
|
|
138
|
+
border-color: #ccc;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.label {
|
|
142
|
+
display: inline;
|
|
143
|
+
padding: 0.7em;
|
|
144
|
+
font-size: 75%;
|
|
145
|
+
font-weight: 700;
|
|
146
|
+
line-height: 1;
|
|
147
|
+
color: #fff;
|
|
148
|
+
text-align: center;
|
|
149
|
+
text-decoration: none;
|
|
150
|
+
white-space: nowrap;
|
|
151
|
+
vertical-align: baseline;
|
|
152
|
+
border-radius: 0.25em;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.label-info {
|
|
156
|
+
background-color: #5bc0de;
|
|
157
|
+
}
|
|
158
|
+
.block {
|
|
159
|
+
width: 420px;
|
|
160
|
+
}
|
|
161
|
+
.block .block-title {
|
|
162
|
+
font-size: 16px;
|
|
163
|
+
margin: 0.5em 0;
|
|
164
|
+
}
|
|
165
|
+
.block a {
|
|
166
|
+
color: #0055ff;
|
|
167
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<title>调试器</title>
|
|
6
|
+
<link href="./index.css" rel="stylesheet" />
|
|
7
|
+
</head>
|
|
8
|
+
<body class="bd-bg">
|
|
9
|
+
<section class="qr-code-wrapper">
|
|
10
|
+
<div>
|
|
11
|
+
<div class="qr-code-panel">
|
|
12
|
+
<div class="qr-img">
|
|
13
|
+
<img src="" id="j-qr-icon" class="qr-icon" />
|
|
14
|
+
</div>
|
|
15
|
+
<div class="block alert alert-warning updatetip">
|
|
16
|
+
<div class="block">
|
|
17
|
+
<h2 class="block-title" title="在设备上预览">手机预览</h2>
|
|
18
|
+
<p>1. 扫码安装rpk包</p>
|
|
19
|
+
<p>
|
|
20
|
+
2. 在手机的调试器上点击
|
|
21
|
+
<button class="btn btn-default">开始调试</button> ,启动调试界面
|
|
22
|
+
</p>
|
|
23
|
+
</div>
|
|
24
|
+
<!-- <div class="block">
|
|
25
|
+
<h2 class="block-title" title="在浏览器中预览">web 预览</h2>
|
|
26
|
+
<p><a href="/preview" target="_blank">打开 web 预览</a></p>
|
|
27
|
+
</div> -->
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</section>
|
|
32
|
+
<section class="inform-tip-wrapper"></section>
|
|
33
|
+
<section class="result inspector-link-panel hide">
|
|
34
|
+
<div class="panel panel-default">
|
|
35
|
+
<div class="panel-heading">调试</div>
|
|
36
|
+
<div class="panel-body">
|
|
37
|
+
<table class="table tunning">
|
|
38
|
+
<tbody></tbody>
|
|
39
|
+
</table>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</section>
|
|
43
|
+
<script type="text/template" id="j-tpl-appinfo">
|
|
44
|
+
<tr>
|
|
45
|
+
<td class="tname">{{data_app_name}}</td>
|
|
46
|
+
<td class="tlink"><a href='{{data_href_value}}' target='_blank' class="label label-info">{{data_href_name}}</a>
|
|
47
|
+
</td>
|
|
48
|
+
</tr>
|
|
49
|
+
</script>
|
|
50
|
+
<script src="./index.js"></script>
|
|
51
|
+
<script type="text/template" id="j-tpl-updatetip">
|
|
52
|
+
<div class="alert alert-warning updatetip">
|
|
53
|
+
<p>调试器已有重要更新,请更新调试器</p>
|
|
54
|
+
</div>
|
|
55
|
+
</script>
|
|
56
|
+
<script src="/socket.io/socket.io.js"></script>
|
|
57
|
+
</body>
|
|
58
|
+
</html>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2017, hapjs.org. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const $ = (selector, elem) => {
|
|
6
|
+
return typeof elem === 'undefined'
|
|
7
|
+
? document.querySelector(selector)
|
|
8
|
+
: elem.querySelector(selector)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function init() {
|
|
12
|
+
const qrImgId = '#j-qr-icon'
|
|
13
|
+
const $qrCodeImg = $(qrImgId)
|
|
14
|
+
const timeStamp = Date.now() % 1e5
|
|
15
|
+
$qrCodeImg.src = `/qrcode?ws_id=${timeStamp}`
|
|
16
|
+
bindEvents()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function bindEvents() {
|
|
20
|
+
const socket = io(location.origin) // eslint-disable-line no-undef
|
|
21
|
+
|
|
22
|
+
socket.on('appRegistered', (data) => {
|
|
23
|
+
console.info(`on receiving appRegistered message: ${JSON.stringify(data)}`)
|
|
24
|
+
updateTableElement(data)
|
|
25
|
+
})
|
|
26
|
+
socket.on('informUpdate', () => {
|
|
27
|
+
console.info('on receiving informUpdate')
|
|
28
|
+
appendUpdateInfo()
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 更新页面调试信息
|
|
34
|
+
* @param data{ inspectorUrl, application }
|
|
35
|
+
*/
|
|
36
|
+
function updateTableElement(data) {
|
|
37
|
+
const wrapper = '.inspector-link-panel'
|
|
38
|
+
const tplId = '#j-tpl-appinfo'
|
|
39
|
+
const $panelWrapper = $(wrapper)
|
|
40
|
+
const $tplAppInfoElem = $(tplId)
|
|
41
|
+
const $tbodyElem = $('tbody', $panelWrapper)
|
|
42
|
+
let tplTextContent = $tplAppInfoElem.textContent
|
|
43
|
+
|
|
44
|
+
$panelWrapper.classList.add('hide')
|
|
45
|
+
const dataToFill = {
|
|
46
|
+
data_app_name: data.application,
|
|
47
|
+
data_href_value: data.inspectorUrl,
|
|
48
|
+
data_href_name: 'Enter the debug page'
|
|
49
|
+
}
|
|
50
|
+
Object.keys(dataToFill).forEach((key) => {
|
|
51
|
+
tplTextContent = tplTextContent.replace(`{{${key}}}`, dataToFill[key])
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
$tbodyElem.innerHTML = tplTextContent
|
|
55
|
+
$panelWrapper.classList.remove('hide')
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function appendUpdateInfo() {
|
|
59
|
+
const tplId = '#j-tpl-updatetip'
|
|
60
|
+
const wrapper = '.inform-tip-wrapper'
|
|
61
|
+
const $tplUpdateTipElem = $(tplId)
|
|
62
|
+
const $panelWrapper = $(wrapper)
|
|
63
|
+
$panelWrapper.innerHTML = $tplUpdateTipElem.textContent
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
init()
|
package/lib/utils/AdbUtils.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
declare class AdbUtils {
|
|
5
5
|
static connect(ip: string, port: string): Promise<boolean>;
|
|
6
6
|
static getAllConnectedDevices(): Promise<string[]>;
|
|
7
|
-
static getUSBConnectedDevices(): Promise<string[]>;
|
|
8
7
|
static installApk(sn: string, apkPath: string): Promise<{
|
|
9
8
|
status: boolean;
|
|
10
9
|
msg: string;
|
package/lib/utils/AdbUtils.js
CHANGED
|
@@ -31,13 +31,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
const
|
|
35
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
39
36
|
const adbMiwt = __importStar(require("@miwt/adb"));
|
|
40
|
-
const adb_commander_1 = __importDefault(require("adb-commander"));
|
|
41
37
|
/**
|
|
42
38
|
* AdbUtils
|
|
43
39
|
*/
|
|
@@ -56,13 +52,6 @@ class AdbUtils {
|
|
|
56
52
|
return res.map(({ sn }) => sn);
|
|
57
53
|
});
|
|
58
54
|
}
|
|
59
|
-
// 获取USB连接的设备
|
|
60
|
-
static getUSBConnectedDevices() {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
const res = yield adb_commander_1.default.deviceList();
|
|
63
|
-
return res.deviceList;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
55
|
// 安装设备
|
|
67
56
|
static installApk(sn, apkPath) {
|
|
68
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -76,12 +65,12 @@ class AdbUtils {
|
|
|
76
65
|
const adbShell = adbMiwt.execAdbCmd(`adb -s ${deviceSn} shell am start -n "org.hapjs.debugger/.MainActivity"`);
|
|
77
66
|
adbShell.stdout.on('data', (data) => {
|
|
78
67
|
// 监听stderr事件,获取输出内容
|
|
79
|
-
|
|
68
|
+
shared_utils_1.ColorConsole.log(`### startDebugger ### ${data}`);
|
|
80
69
|
});
|
|
81
70
|
adbShell.stderr.on('data', (data) => {
|
|
82
71
|
// 监听stderr事件,获取输出内容
|
|
83
72
|
if (data.indexOf('Error') >= 0) {
|
|
84
|
-
|
|
73
|
+
shared_utils_1.ColorConsole.throw(`### startDebugger ### ${data}`);
|
|
85
74
|
}
|
|
86
75
|
});
|
|
87
76
|
adbShell.on('close', () => {
|
package/lib/utils/DeviceUtil.js
CHANGED
|
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
|
-
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
17
16
|
const prompts_1 = require("@inquirer/prompts");
|
|
18
17
|
const fs_1 = __importDefault(require("fs"));
|
|
19
18
|
const path_1 = __importDefault(require("path"));
|
|
@@ -31,16 +30,16 @@ class DeviceUtil {
|
|
|
31
30
|
try {
|
|
32
31
|
return AdbUtils_1.default.getAllConnectedDevices().then((deviceList) => {
|
|
33
32
|
if (deviceList.length > 0) {
|
|
34
|
-
|
|
33
|
+
shared_utils_1.ColorConsole.info(`Devices connected via adb: ${deviceList.join(', ')}.`);
|
|
35
34
|
return Promise.resolve(deviceList);
|
|
36
35
|
}
|
|
37
36
|
else {
|
|
38
|
-
|
|
37
|
+
shared_utils_1.ColorConsole.throw(`No device is currently connected, please check the following preparations in turn:\n 1. Whether the device is started;\n 2. Whether in the same LAN WI-FI;\n 3. Whether the device can be connected to the computer via USB;`);
|
|
39
38
|
}
|
|
40
39
|
});
|
|
41
40
|
}
|
|
42
41
|
catch (error) {
|
|
43
|
-
|
|
42
|
+
shared_utils_1.ColorConsole.throw('Error getting connection information of adb device');
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
/**
|
|
@@ -56,14 +55,16 @@ class DeviceUtil {
|
|
|
56
55
|
// 1. 判断设备是否连接
|
|
57
56
|
yield this.connectDevice(ip);
|
|
58
57
|
// 2. 获取连接的设备
|
|
59
|
-
const deviceList = yield AdbUtils_1.default.
|
|
58
|
+
const deviceList = yield AdbUtils_1.default.getAllConnectedDevices();
|
|
60
59
|
const finalDeviceList = deviceList.length > 0
|
|
61
60
|
? yield this.queryDevice(deviceList, 'Install Quickapp debugger or previewer ')
|
|
62
61
|
: [];
|
|
63
62
|
connectDeviceList = finalDeviceList ? [...finalDeviceList] : [];
|
|
64
63
|
// 若connectDeviceList为空,应该warn并结束程序
|
|
65
|
-
connectDeviceList.length <= 0
|
|
66
|
-
|
|
64
|
+
if (connectDeviceList.length <= 0) {
|
|
65
|
+
shared_utils_1.ColorConsole.throw({ word: 'No device' }, 'requires debugger or previewer installation');
|
|
66
|
+
return Promise.reject(new Error(`No device requires debugger or previewer installation`));
|
|
67
|
+
}
|
|
67
68
|
// 3. 下载并获取调试器、预览器地址
|
|
68
69
|
const debuggerPath = yield this.downloadApk(options, true);
|
|
69
70
|
const previewPath = yield this.downloadApk(options, false);
|
|
@@ -73,7 +74,7 @@ class DeviceUtil {
|
|
|
73
74
|
return Promise.resolve('All devices successfully installed the Quickapp debugger and previewer');
|
|
74
75
|
}
|
|
75
76
|
catch (error) {
|
|
76
|
-
return Promise.reject(new Error(`Failed to install
|
|
77
|
+
return Promise.reject(new Error(`Failed to install , error message:${(error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'}`));
|
|
77
78
|
}
|
|
78
79
|
});
|
|
79
80
|
}
|
|
@@ -106,14 +107,14 @@ class DeviceUtil {
|
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
if (ip.length === 0) {
|
|
109
|
-
|
|
110
|
+
shared_utils_1.ColorConsole.log(`Since no ip address is entered, the connected device will be connected`);
|
|
110
111
|
return Promise.resolve();
|
|
111
112
|
}
|
|
112
113
|
const ips = ip.trim().split(',');
|
|
113
114
|
const invalidIps = ips.filter((ip) => !this.ipRegExp.test(ip));
|
|
114
115
|
if (invalidIps && invalidIps.length) {
|
|
115
116
|
invalidIps.map((ip) => {
|
|
116
|
-
|
|
117
|
+
shared_utils_1.ColorConsole.throw(`ip: `, { word: ip, style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.THROW) }, ` is invalid IP`);
|
|
117
118
|
});
|
|
118
119
|
}
|
|
119
120
|
else {
|
|
@@ -124,16 +125,16 @@ class DeviceUtil {
|
|
|
124
125
|
});
|
|
125
126
|
return AdbUtils_1.default.connect(ip, devicePort)
|
|
126
127
|
.then(() => {
|
|
127
|
-
|
|
128
|
+
shared_utils_1.ColorConsole.success(`wifi connection ip: The device with ip of "${ip}" succeeded`);
|
|
128
129
|
return Promise.resolve();
|
|
129
130
|
})
|
|
130
131
|
.catch((err) => {
|
|
131
|
-
|
|
132
|
+
shared_utils_1.ColorConsole.throw(`${err}`);
|
|
132
133
|
});
|
|
133
134
|
}));
|
|
134
135
|
return Promise.all(newDeviceListPromiseArray)
|
|
135
136
|
.then(() => {
|
|
136
|
-
|
|
137
|
+
shared_utils_1.ColorConsole.log(`All new WIFI devices are connected`);
|
|
137
138
|
return Promise.resolve();
|
|
138
139
|
})
|
|
139
140
|
.catch(() => {
|
|
@@ -151,10 +152,10 @@ class DeviceUtil {
|
|
|
151
152
|
* @param orderText
|
|
152
153
|
* @returns
|
|
153
154
|
*/
|
|
154
|
-
static queryDevice(
|
|
155
|
-
return __awaiter(this,
|
|
155
|
+
static queryDevice(deviceList_1) {
|
|
156
|
+
return __awaiter(this, arguments, void 0, function* (deviceList, orderText = '') {
|
|
156
157
|
if (!deviceList || deviceList.length === 0) {
|
|
157
|
-
|
|
158
|
+
shared_utils_1.ColorConsole.throw(`No device is connected yet, please confirm and try again`);
|
|
158
159
|
return;
|
|
159
160
|
}
|
|
160
161
|
const ALL_TEXT = 'All connected devices';
|
|
@@ -192,19 +193,19 @@ class DeviceUtil {
|
|
|
192
193
|
const apkPath = path_1.default.join(__dirname, './apk/', fileName);
|
|
193
194
|
if (fs_1.default.existsSync(apkPath)) {
|
|
194
195
|
// apk已下载
|
|
195
|
-
|
|
196
|
+
shared_utils_1.ColorConsole.log(`The installation package has been downloaded, now use the cache file to install`);
|
|
196
197
|
return apkPath;
|
|
197
198
|
}
|
|
198
199
|
else {
|
|
199
200
|
try {
|
|
200
201
|
const result = yield RequestUtils_1.default.downloadFile(url, fileName);
|
|
201
202
|
// 打印出成功信息
|
|
202
|
-
|
|
203
|
+
shared_utils_1.ColorConsole.success(`Success to download, ${result}`);
|
|
203
204
|
return apkPath;
|
|
204
205
|
}
|
|
205
206
|
catch (error) {
|
|
206
207
|
// 打印出错误
|
|
207
|
-
|
|
208
|
+
shared_utils_1.ColorConsole.throw(`Failed to download the installation package, ${error}`);
|
|
208
209
|
return '';
|
|
209
210
|
}
|
|
210
211
|
}
|
|
@@ -227,7 +228,7 @@ class DeviceUtil {
|
|
|
227
228
|
let countTime = 0;
|
|
228
229
|
let data;
|
|
229
230
|
const sleep = () => {
|
|
230
|
-
|
|
231
|
+
shared_utils_1.ColorConsole.error(`Error when the device gets running platforms,request again after 3s delay`);
|
|
231
232
|
return new Promise((resolve) => setTimeout(resolve, 3000));
|
|
232
233
|
};
|
|
233
234
|
const requestPlatform = () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -242,17 +243,17 @@ class DeviceUtil {
|
|
|
242
243
|
const dataObj = JSON.parse(data);
|
|
243
244
|
if (!dataObj.availablePlatforms) {
|
|
244
245
|
// 请求结果不存在平台信息,报错,结束程序
|
|
245
|
-
|
|
246
|
+
shared_utils_1.ColorConsole.throw(`The request result no avaliable platform `);
|
|
246
247
|
}
|
|
247
248
|
else {
|
|
248
249
|
// 打印请求的平台信息
|
|
249
250
|
const availablePlatforms = dataObj.availablePlatforms;
|
|
250
|
-
|
|
251
|
+
shared_utils_1.ColorConsole.log(`The Quickapp engine list of device "${deviceSn}" is:${availablePlatforms.join(',')}`);
|
|
251
252
|
}
|
|
252
253
|
}
|
|
253
254
|
else {
|
|
254
255
|
//请求失败,结束程序
|
|
255
|
-
|
|
256
|
+
shared_utils_1.ColorConsole.throw(`The device gets running platforms error`);
|
|
256
257
|
}
|
|
257
258
|
});
|
|
258
259
|
// 先打开调试器,才能获取运行平台
|
|
@@ -260,7 +261,7 @@ class DeviceUtil {
|
|
|
260
261
|
yield requestPlatform();
|
|
261
262
|
}
|
|
262
263
|
catch (error) {
|
|
263
|
-
|
|
264
|
+
shared_utils_1.ColorConsole.throw(`Error getting the list of Quickapp engines on the device`);
|
|
264
265
|
}
|
|
265
266
|
});
|
|
266
267
|
}
|
|
@@ -270,19 +271,31 @@ class DeviceUtil {
|
|
|
270
271
|
* @param apkPath
|
|
271
272
|
* @returns
|
|
272
273
|
*/
|
|
273
|
-
static installApk(
|
|
274
|
-
return __awaiter(this,
|
|
274
|
+
static installApk() {
|
|
275
|
+
return __awaiter(this, arguments, void 0, function* (deviceList = [], apkPath) {
|
|
275
276
|
try {
|
|
276
277
|
const newDeviceListPromiseArray = Array.from(deviceList, (deviceSn) => {
|
|
277
278
|
return AdbUtils_1.default.installApk(deviceSn, apkPath);
|
|
278
279
|
});
|
|
279
280
|
const apkName = path_1.default.basename(apkPath);
|
|
280
281
|
return Promise.all(newDeviceListPromiseArray)
|
|
281
|
-
.then(() => {
|
|
282
|
-
|
|
282
|
+
.then((results) => {
|
|
283
|
+
let statusAll = true;
|
|
284
|
+
results.forEach((res) => {
|
|
285
|
+
if (!res.status) {
|
|
286
|
+
shared_utils_1.ColorConsole.error(res.msg);
|
|
287
|
+
statusAll = false;
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
if (statusAll) {
|
|
291
|
+
shared_utils_1.ColorConsole.success(`All devices installed ${apkName}`);
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
// TODO 后续从这里抛出异常
|
|
295
|
+
}
|
|
283
296
|
})
|
|
284
297
|
.catch(() => {
|
|
285
|
-
|
|
298
|
+
shared_utils_1.ColorConsole.throw(`Installed ${apkName} failed`);
|
|
286
299
|
});
|
|
287
300
|
}
|
|
288
301
|
catch (error) { }
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const
|
|
15
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
18
|
const path_1 = __importDefault(require("path"));
|
|
@@ -38,16 +38,16 @@ class RequestUtils {
|
|
|
38
38
|
axios_1.default
|
|
39
39
|
.post(requrl, options)
|
|
40
40
|
.then((data) => {
|
|
41
|
-
|
|
41
|
+
shared_utils_1.ColorConsole.log(`### App Server ### Request ${requrl} succeeded`);
|
|
42
42
|
resolve(data.toString());
|
|
43
43
|
})
|
|
44
44
|
.catch((error) => {
|
|
45
45
|
if (error.respose && error.response.status === 408) {
|
|
46
46
|
// 超时处理
|
|
47
|
-
|
|
47
|
+
shared_utils_1.ColorConsole.error(`### App Server ### Request ${requrl} timed out, please try again`);
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
|
-
|
|
50
|
+
shared_utils_1.ColorConsole.error(`### App Server ### Request ${requrl} error message: ${(error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'}`);
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
});
|
|
@@ -56,7 +56,7 @@ class RequestUtils {
|
|
|
56
56
|
static downloadFile(url, fileName) {
|
|
57
57
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
58
58
|
// 开始下载
|
|
59
|
-
|
|
59
|
+
shared_utils_1.ColorConsole.log(`Start downloading file:${fileName}, address:${url}`);
|
|
60
60
|
const response = yield axios_1.default.get(url, {
|
|
61
61
|
responseType: 'arraybuffer'
|
|
62
62
|
});
|
|
@@ -7,6 +7,7 @@ declare class VelaAvdUtils {
|
|
|
7
7
|
static emulatorBaseUrl: string;
|
|
8
8
|
static systemImageBaseUrl: string;
|
|
9
9
|
static velaAvdCls: VelaAvdCls;
|
|
10
|
+
/** 校验AVD名称 */
|
|
10
11
|
static validateAvdName(avdName: string): true | "Please enter avd name" | "The avd name must starts with Vela" | "The avd already exists. Please change avd name";
|
|
11
12
|
/**
|
|
12
13
|
* 从CDN上下载资源文件
|
|
@@ -25,21 +26,36 @@ declare class VelaAvdUtils {
|
|
|
25
26
|
static downloadAndUnzip(downloadUrl: string, targetDir: string): Promise<void>;
|
|
26
27
|
/** 根据host获取模拟器下载地址 */
|
|
27
28
|
static getEmulatorUrl(version?: string): string;
|
|
28
|
-
/**
|
|
29
|
-
static
|
|
30
|
-
/**
|
|
31
|
-
static
|
|
32
|
-
/**
|
|
33
|
-
|
|
29
|
+
/** 获取模拟器平台的名称,darwin-aarch64 linux-aarch64 windows-x86_64等 */
|
|
30
|
+
static getEmulatorPlatform(): string;
|
|
31
|
+
/** 获取各项模拟器资源的根目录 */
|
|
32
|
+
static getEmulatorEnvHome(resourceName: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Vela镜像需要更新
|
|
35
|
+
* @param imageId 镜像id
|
|
36
|
+
* @returns {boolean}
|
|
37
|
+
*/
|
|
38
|
+
static velaImageNeedUpdate(imageId: string): boolean;
|
|
34
39
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
40
|
+
* Vela镜像是否为zip包(是否为0.0.2版本)
|
|
41
|
+
* 只有Vela开发版(dev, 0.0.2)这个版本的镜像不是zip包
|
|
42
|
+
* @param velaImage
|
|
37
43
|
* @returns
|
|
38
44
|
*/
|
|
39
|
-
static
|
|
45
|
+
static isZipInImageUrl(velaImage: string): boolean;
|
|
46
|
+
/** 获取vela镜像的下载地址 */
|
|
47
|
+
static getSystemImageUrl(version?: string): string;
|
|
48
|
+
/** 获取模拟器其他资源的下载地址 */
|
|
49
|
+
static getDownloadUrl(dir: string, version?: string, filename?: string): string;
|
|
50
|
+
/** 根据host获取ya-vm-file-server下载地址 */
|
|
51
|
+
static getv9fsToolUrl(version?: string): string;
|
|
52
|
+
/** 获取镜像构建时间 */
|
|
53
|
+
static getImageBuildTime(imageId: string): string | Date | undefined;
|
|
40
54
|
/**
|
|
41
55
|
* 命令行访问方式创建模拟器
|
|
42
56
|
*/
|
|
43
57
|
static createVelaAvdByInquire(): Promise<void>;
|
|
58
|
+
/** 初始化/重置模拟器环境 */
|
|
59
|
+
static initEmulatorEnv(): Promise<void>;
|
|
44
60
|
}
|
|
45
61
|
export default VelaAvdUtils;
|