aiot-toolkit 2.0.1-alpha.9 → 2.0.2-dev.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/README.md +38 -29
- package/lib/bin.js +79 -37
- package/lib/builder/IBuilder.js +0 -2
- package/lib/builder/UxBuilder.d.ts +1 -0
- package/lib/builder/UxBuilder.js +37 -14
- package/lib/builder/XtsBuilder.js +30 -12
- package/lib/interface/CommandInterface.js +0 -2
- package/lib/interface/VelaEmulatorInterface.d.ts +6 -1
- package/lib/interface/VelaEmulatorInterface.js +0 -2
- package/lib/starter/IStarter.d.ts +23 -0
- package/lib/starter/IStarter.js +45 -0
- package/lib/starter/UxStarter.d.ts +10 -0
- package/lib/starter/UxStarter.js +136 -0
- package/lib/starter/XtsStarter.d.ts +9 -0
- package/lib/starter/XtsStarter.js +16 -0
- package/lib/utils/AdbUtils.js +2 -11
- package/lib/utils/DeviceUtil.d.ts +1 -1
- package/lib/utils/DeviceUtil.js +22 -93
- package/lib/utils/RequestUtils.js +4 -19
- package/lib/utils/VelaAvdUtils.d.ts +2 -2
- package/lib/utils/VelaAvdUtils.js +37 -78
- package/lib/waiter.js +0 -2
- package/package.json +11 -7
- package/lib/bin.js.map +0 -1
- package/lib/builder/IBuilder.js.map +0 -1
- package/lib/builder/UxBuilder.js.map +0 -1
- package/lib/builder/XtsBuilder.js.map +0 -1
- package/lib/interface/CommandInterface.js.map +0 -1
- package/lib/interface/VelaEmulatorInterface.js.map +0 -1
- package/lib/starter/GoldfishStarter.d.ts +0 -9
- package/lib/starter/GoldfishStarter.js +0 -108
- package/lib/starter/GoldfishStarter.js.map +0 -1
- package/lib/utils/AdbUtils.js.map +0 -1
- package/lib/utils/DeviceUtil.js.map +0 -1
- package/lib/utils/RequestUtils.js.map +0 -1
- package/lib/utils/VelaAvdUtils.js.map +0 -1
- package/lib/waiter.js.map +0 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const JavascriptDefaultCompileOption_1 = __importStar(require("@aiot-toolkit/aiotpack/lib/compiler/javascript/JavascriptDefaultCompileOption"));
|
|
39
|
+
const emulator_1 = require("@aiot-toolkit/emulator");
|
|
40
|
+
const constants_1 = require("@aiot-toolkit/emulator/lib/static/constants");
|
|
41
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
42
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
43
|
+
const os_1 = __importDefault(require("os"));
|
|
44
|
+
const path_1 = __importDefault(require("path"));
|
|
45
|
+
const portfinder_1 = __importDefault(require("portfinder"));
|
|
46
|
+
const UxBuilder_1 = __importDefault(require("../builder/UxBuilder"));
|
|
47
|
+
const VelaAvdUtils_1 = __importDefault(require("../utils/VelaAvdUtils"));
|
|
48
|
+
const IStarter_1 = __importDefault(require("./IStarter"));
|
|
49
|
+
class UxStarter extends IStarter_1.default {
|
|
50
|
+
constructor() {
|
|
51
|
+
super(...arguments);
|
|
52
|
+
this.builder = new UxBuilder_1.default();
|
|
53
|
+
this.params = [
|
|
54
|
+
{
|
|
55
|
+
name: 'disableNSH',
|
|
56
|
+
description: 'disable goldfish NSH terminal',
|
|
57
|
+
defaultValue: false,
|
|
58
|
+
type: 'confirm'
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'watch',
|
|
62
|
+
description: 'recompile project while file changes',
|
|
63
|
+
defaultValue: false,
|
|
64
|
+
type: 'confirm'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'openVNC',
|
|
68
|
+
description: 'open vnc',
|
|
69
|
+
defaultValue: false,
|
|
70
|
+
type: 'confirm'
|
|
71
|
+
},
|
|
72
|
+
...this.builder.params
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
start(projectPath, options) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const avdList = VelaAvdUtils_1.default.velaAvdCls.getVelaAvdList();
|
|
78
|
+
if (avdList.length === 0) {
|
|
79
|
+
ColorConsole_1.default.error('### goldfish start ### No vela emulator available, please create it first.');
|
|
80
|
+
VelaAvdUtils_1.default.createVelaAvdByInquire();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const avdName = yield (0, prompts_1.select)({
|
|
84
|
+
message: 'name of the avd to start',
|
|
85
|
+
choices: avdList.map((item) => {
|
|
86
|
+
return { value: item.avdName };
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
let serverPort;
|
|
90
|
+
// watch模型下开启server
|
|
91
|
+
if (options.watch) {
|
|
92
|
+
serverPort = yield portfinder_1.default.getPortPromise({
|
|
93
|
+
port: JavascriptDefaultCompileOption_1.default.serverPort
|
|
94
|
+
});
|
|
95
|
+
(0, JavascriptDefaultCompileOption_1.setServerPort)(serverPort);
|
|
96
|
+
}
|
|
97
|
+
// build
|
|
98
|
+
yield this.builder.build(projectPath, options);
|
|
99
|
+
// start
|
|
100
|
+
const goldfishInstance = new emulator_1.GoldfishInstance({
|
|
101
|
+
sdkHome: path_1.default.resolve(os_1.default.homedir(), '.export'),
|
|
102
|
+
avdHome: path_1.default.resolve(os_1.default.homedir(), '.android/avd'),
|
|
103
|
+
projectPath
|
|
104
|
+
});
|
|
105
|
+
let vncPort;
|
|
106
|
+
if (options.openVNC) {
|
|
107
|
+
vncPort = yield portfinder_1.default.getPortPromise({ port: constants_1.defaultVncPort, stopPort: constants_1.defaultVncPort + 100 });
|
|
108
|
+
}
|
|
109
|
+
const startOptions = {
|
|
110
|
+
avdName,
|
|
111
|
+
devtool: options.devtool,
|
|
112
|
+
disableNSH: options.disableNSH,
|
|
113
|
+
serverPort,
|
|
114
|
+
vncPort,
|
|
115
|
+
};
|
|
116
|
+
goldfishInstance.start(startOptions);
|
|
117
|
+
// waiter
|
|
118
|
+
// const startWaiter: PersistentCommand = new PersistentCommand({
|
|
119
|
+
// description: 'aiot-toolkit start 的常驻命令',
|
|
120
|
+
// options: [
|
|
121
|
+
// {
|
|
122
|
+
// key: '?',
|
|
123
|
+
// description: '显示所有命令',
|
|
124
|
+
// action() {
|
|
125
|
+
// startWaiter.clearLog()
|
|
126
|
+
// startWaiter.describe()
|
|
127
|
+
// }
|
|
128
|
+
// }
|
|
129
|
+
// ]
|
|
130
|
+
// })
|
|
131
|
+
// startWaiter.describe()
|
|
132
|
+
// startWaiter.start()
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.default = UxStarter;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ParamType from "@aiot-toolkit/commander/lib/interface/IParam";
|
|
2
|
+
import XtsBuilder from "../builder/XtsBuilder";
|
|
3
|
+
import IStarter from "./IStarter";
|
|
4
|
+
declare class XtsStarter extends IStarter {
|
|
5
|
+
builder: XtsBuilder;
|
|
6
|
+
params: ParamType[];
|
|
7
|
+
start(projectPath: string, options: any): void;
|
|
8
|
+
}
|
|
9
|
+
export default XtsStarter;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const XtsBuilder_1 = __importDefault(require("../builder/XtsBuilder"));
|
|
7
|
+
const IStarter_1 = __importDefault(require("./IStarter"));
|
|
8
|
+
class XtsStarter extends IStarter_1.default {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.builder = new XtsBuilder_1.default();
|
|
12
|
+
this.params = [];
|
|
13
|
+
}
|
|
14
|
+
start(projectPath, options) { }
|
|
15
|
+
}
|
|
16
|
+
exports.default = XtsStarter;
|
package/lib/utils/AdbUtils.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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
39
38
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
40
39
|
const adbMiwt = __importStar(require("@miwt/adb"));
|
|
41
40
|
const adb_commander_1 = __importDefault(require("adb-commander"));
|
|
@@ -77,18 +76,12 @@ class AdbUtils {
|
|
|
77
76
|
const adbShell = adbMiwt.execAdbCmd(`adb -s ${deviceSn} shell am start -n "org.hapjs.debugger/.MainActivity"`);
|
|
78
77
|
adbShell.stdout.on('data', (data) => {
|
|
79
78
|
// 监听stderr事件,获取输出内容
|
|
80
|
-
ColorConsole_1.default.log({
|
|
81
|
-
message: data
|
|
82
|
-
});
|
|
79
|
+
ColorConsole_1.default.log(`### startDebugger ### ${data}`);
|
|
83
80
|
});
|
|
84
81
|
adbShell.stderr.on('data', (data) => {
|
|
85
82
|
// 监听stderr事件,获取输出内容
|
|
86
83
|
if (data.indexOf('Error') >= 0) {
|
|
87
|
-
ColorConsole_1.default.
|
|
88
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
89
|
-
message: data
|
|
90
|
-
});
|
|
91
|
-
process.exit();
|
|
84
|
+
ColorConsole_1.default.throw(`### startDebugger ### ${data}`);
|
|
92
85
|
}
|
|
93
86
|
});
|
|
94
87
|
adbShell.on('close', () => {
|
|
@@ -99,5 +92,3 @@ class AdbUtils {
|
|
|
99
92
|
}
|
|
100
93
|
}
|
|
101
94
|
exports.default = AdbUtils;
|
|
102
|
-
|
|
103
|
-
//# sourceMappingURL=AdbUtils.js.map
|
package/lib/utils/DeviceUtil.js
CHANGED
|
@@ -31,28 +31,16 @@ class DeviceUtil {
|
|
|
31
31
|
try {
|
|
32
32
|
return AdbUtils_1.default.getAllConnectedDevices().then((deviceList) => {
|
|
33
33
|
if (deviceList.length > 0) {
|
|
34
|
-
ColorConsole_1.default.
|
|
35
|
-
message: `Devices connected via adb: ${deviceList.join(', ')}.`
|
|
36
|
-
});
|
|
34
|
+
ColorConsole_1.default.info(`Devices connected via adb: ${deviceList.join(', ')}.`);
|
|
37
35
|
return Promise.resolve(deviceList);
|
|
38
36
|
}
|
|
39
37
|
else {
|
|
40
|
-
ColorConsole_1.default.
|
|
41
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
42
|
-
message: `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;`,
|
|
43
|
-
isOnlyPrintError: true
|
|
44
|
-
});
|
|
45
|
-
process.exit();
|
|
38
|
+
ColorConsole_1.default.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;`);
|
|
46
39
|
}
|
|
47
40
|
});
|
|
48
41
|
}
|
|
49
42
|
catch (error) {
|
|
50
|
-
ColorConsole_1.default.
|
|
51
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
52
|
-
message: 'Error getting connection information of adb device',
|
|
53
|
-
isOnlyPrintError: true
|
|
54
|
-
});
|
|
55
|
-
process.exit();
|
|
43
|
+
ColorConsole_1.default.throw('Error getting connection information of adb device');
|
|
56
44
|
}
|
|
57
45
|
}
|
|
58
46
|
/**
|
|
@@ -75,11 +63,7 @@ class DeviceUtil {
|
|
|
75
63
|
connectDeviceList = finalDeviceList ? [...finalDeviceList] : [];
|
|
76
64
|
// 若connectDeviceList为空,应该warn并结束程序
|
|
77
65
|
connectDeviceList.length <= 0 &&
|
|
78
|
-
ColorConsole_1.default.
|
|
79
|
-
message: 'No device requires debugger or previewer installation',
|
|
80
|
-
level: shared_utils_1.LOG_LEVEL.Warn
|
|
81
|
-
}) &&
|
|
82
|
-
process.exit();
|
|
66
|
+
ColorConsole_1.default.throw('No device requires debugger or previewer installation');
|
|
83
67
|
// 3. 下载并获取调试器、预览器地址
|
|
84
68
|
const debuggerPath = yield this.downloadApk(options, true);
|
|
85
69
|
const previewPath = yield this.downloadApk(options, false);
|
|
@@ -89,7 +73,7 @@ class DeviceUtil {
|
|
|
89
73
|
return Promise.resolve('All devices successfully installed the Quickapp debugger and previewer');
|
|
90
74
|
}
|
|
91
75
|
catch (error) {
|
|
92
|
-
return Promise.reject(new Error(`Failed to install debugger, error message:${error.
|
|
76
|
+
return Promise.reject(new Error(`Failed to install debugger, error message:${(error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'}`));
|
|
93
77
|
}
|
|
94
78
|
});
|
|
95
79
|
}
|
|
@@ -122,21 +106,14 @@ class DeviceUtil {
|
|
|
122
106
|
}
|
|
123
107
|
}
|
|
124
108
|
if (ip.length === 0) {
|
|
125
|
-
ColorConsole_1.default.log(
|
|
126
|
-
message: `Since no ip address is entered, the connected device will be connected`
|
|
127
|
-
});
|
|
109
|
+
ColorConsole_1.default.log(`Since no ip address is entered, the connected device will be connected`);
|
|
128
110
|
return Promise.resolve();
|
|
129
111
|
}
|
|
130
112
|
const ips = ip.trim().split(',');
|
|
131
113
|
const invalidIps = ips.filter((ip) => !this.ipRegExp.test(ip));
|
|
132
114
|
if (invalidIps && invalidIps.length) {
|
|
133
115
|
invalidIps.map((ip) => {
|
|
134
|
-
ColorConsole_1.default.
|
|
135
|
-
message: `ip: ${ip} is invalid IP`,
|
|
136
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
137
|
-
isOnlyPrintError: true
|
|
138
|
-
});
|
|
139
|
-
process.exit();
|
|
116
|
+
ColorConsole_1.default.throw(`ip: `, { word: ip, style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Throw) }, ` is invalid IP`);
|
|
140
117
|
});
|
|
141
118
|
}
|
|
142
119
|
else {
|
|
@@ -147,26 +124,16 @@ class DeviceUtil {
|
|
|
147
124
|
});
|
|
148
125
|
return AdbUtils_1.default.connect(ip, devicePort)
|
|
149
126
|
.then(() => {
|
|
150
|
-
ColorConsole_1.default.
|
|
151
|
-
level: shared_utils_1.LOG_LEVEL.Success,
|
|
152
|
-
message: `wifi connection ip: The device with ip of "${ip}" succeeded`
|
|
153
|
-
});
|
|
127
|
+
ColorConsole_1.default.success(`wifi connection ip: The device with ip of "${ip}" succeeded`);
|
|
154
128
|
return Promise.resolve();
|
|
155
129
|
})
|
|
156
130
|
.catch((err) => {
|
|
157
|
-
ColorConsole_1.default.
|
|
158
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
159
|
-
message: err,
|
|
160
|
-
isOnlyPrintError: true
|
|
161
|
-
});
|
|
162
|
-
process.exit();
|
|
131
|
+
ColorConsole_1.default.throw(`${err}`);
|
|
163
132
|
});
|
|
164
133
|
}));
|
|
165
134
|
return Promise.all(newDeviceListPromiseArray)
|
|
166
135
|
.then(() => {
|
|
167
|
-
ColorConsole_1.default.log(
|
|
168
|
-
message: 'All new WIFI devices are connected'
|
|
169
|
-
});
|
|
136
|
+
ColorConsole_1.default.log(`All new WIFI devices are connected`);
|
|
170
137
|
return Promise.resolve();
|
|
171
138
|
})
|
|
172
139
|
.catch(() => {
|
|
@@ -187,10 +154,7 @@ class DeviceUtil {
|
|
|
187
154
|
static queryDevice(deviceList, orderText = '') {
|
|
188
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
189
156
|
if (!deviceList || deviceList.length === 0) {
|
|
190
|
-
ColorConsole_1.default.
|
|
191
|
-
message: `No device is connected yet, please confirm and try again`,
|
|
192
|
-
level: shared_utils_1.LOG_LEVEL.Error
|
|
193
|
-
});
|
|
157
|
+
ColorConsole_1.default.throw(`No device is connected yet, please confirm and try again`);
|
|
194
158
|
return;
|
|
195
159
|
}
|
|
196
160
|
const ALL_TEXT = 'All connected devices';
|
|
@@ -228,29 +192,20 @@ class DeviceUtil {
|
|
|
228
192
|
const apkPath = path_1.default.join(__dirname, './apk/', fileName);
|
|
229
193
|
if (fs_1.default.existsSync(apkPath)) {
|
|
230
194
|
// apk已下载
|
|
231
|
-
ColorConsole_1.default.log(
|
|
232
|
-
message: 'The installation package has been downloaded, now use the cache file to install'
|
|
233
|
-
});
|
|
195
|
+
ColorConsole_1.default.log(`The installation package has been downloaded, now use the cache file to install`);
|
|
234
196
|
return apkPath;
|
|
235
197
|
}
|
|
236
198
|
else {
|
|
237
199
|
try {
|
|
238
200
|
const result = yield RequestUtils_1.default.downloadFile(url, fileName);
|
|
239
201
|
// 打印出成功信息
|
|
240
|
-
ColorConsole_1.default.
|
|
241
|
-
message: `Success to download, ${result}`,
|
|
242
|
-
level: shared_utils_1.LOG_LEVEL.Success
|
|
243
|
-
});
|
|
202
|
+
ColorConsole_1.default.success(`Success to download, ${result}`);
|
|
244
203
|
return apkPath;
|
|
245
204
|
}
|
|
246
205
|
catch (error) {
|
|
247
206
|
// 打印出错误
|
|
248
|
-
ColorConsole_1.default.
|
|
249
|
-
|
|
250
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
251
|
-
isOnlyPrintError: true
|
|
252
|
-
});
|
|
253
|
-
process.exit();
|
|
207
|
+
ColorConsole_1.default.throw(`Failed to download the installation package, ${error}`);
|
|
208
|
+
return '';
|
|
254
209
|
}
|
|
255
210
|
}
|
|
256
211
|
});
|
|
@@ -272,11 +227,7 @@ class DeviceUtil {
|
|
|
272
227
|
let countTime = 0;
|
|
273
228
|
let data;
|
|
274
229
|
const sleep = () => {
|
|
275
|
-
ColorConsole_1.default.
|
|
276
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
277
|
-
message: `Error when the device gets running platforms,request again after 3s delay`,
|
|
278
|
-
isOnlyPrintError: true
|
|
279
|
-
});
|
|
230
|
+
ColorConsole_1.default.error(`Error when the device gets running platforms,request again after 3s delay`);
|
|
280
231
|
return new Promise((resolve) => setTimeout(resolve, 3000));
|
|
281
232
|
};
|
|
282
233
|
const requestPlatform = () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -291,27 +242,17 @@ class DeviceUtil {
|
|
|
291
242
|
const dataObj = JSON.parse(data);
|
|
292
243
|
if (!dataObj.availablePlatforms) {
|
|
293
244
|
// 请求结果不存在平台信息,报错,结束程序
|
|
294
|
-
ColorConsole_1.default.
|
|
295
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
296
|
-
message: `the request result no avaliable platform `
|
|
297
|
-
});
|
|
298
|
-
process.exit();
|
|
245
|
+
ColorConsole_1.default.throw(`The request result no avaliable platform `);
|
|
299
246
|
}
|
|
300
247
|
else {
|
|
301
248
|
// 打印请求的平台信息
|
|
302
249
|
const availablePlatforms = dataObj.availablePlatforms;
|
|
303
|
-
ColorConsole_1.default.log({
|
|
304
|
-
message: `The Quickapp engine list of device "${deviceSn}" is:${availablePlatforms.join(',')}`
|
|
305
|
-
});
|
|
250
|
+
ColorConsole_1.default.log(`The Quickapp engine list of device "${deviceSn}" is:${availablePlatforms.join(',')}`);
|
|
306
251
|
}
|
|
307
252
|
}
|
|
308
253
|
else {
|
|
309
254
|
//请求失败,结束程序
|
|
310
|
-
ColorConsole_1.default.
|
|
311
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
312
|
-
message: `the device gets running platforms error`
|
|
313
|
-
});
|
|
314
|
-
process.exit();
|
|
255
|
+
ColorConsole_1.default.throw(`The device gets running platforms error`);
|
|
315
256
|
}
|
|
316
257
|
});
|
|
317
258
|
// 先打开调试器,才能获取运行平台
|
|
@@ -319,10 +260,7 @@ class DeviceUtil {
|
|
|
319
260
|
yield requestPlatform();
|
|
320
261
|
}
|
|
321
262
|
catch (error) {
|
|
322
|
-
ColorConsole_1.default.
|
|
323
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
324
|
-
message: `Error getting the list of Quickapp engines on the device, error message:${error.message}`
|
|
325
|
-
});
|
|
263
|
+
ColorConsole_1.default.throw(`Error getting the list of Quickapp engines on the device`);
|
|
326
264
|
}
|
|
327
265
|
});
|
|
328
266
|
}
|
|
@@ -341,17 +279,10 @@ class DeviceUtil {
|
|
|
341
279
|
const apkName = path_1.default.basename(apkPath);
|
|
342
280
|
return Promise.all(newDeviceListPromiseArray)
|
|
343
281
|
.then(() => {
|
|
344
|
-
ColorConsole_1.default.
|
|
345
|
-
level: shared_utils_1.LOG_LEVEL.Success,
|
|
346
|
-
message: `All devices installed ${apkName}`
|
|
347
|
-
});
|
|
282
|
+
ColorConsole_1.default.success(`All devices installed ${apkName}`);
|
|
348
283
|
})
|
|
349
284
|
.catch(() => {
|
|
350
|
-
ColorConsole_1.default.
|
|
351
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
352
|
-
message: `Installed ${apkName} failed`
|
|
353
|
-
});
|
|
354
|
-
process.exit();
|
|
285
|
+
ColorConsole_1.default.throw(`Installed ${apkName} failed`);
|
|
355
286
|
});
|
|
356
287
|
}
|
|
357
288
|
catch (error) { }
|
|
@@ -362,5 +293,3 @@ DeviceUtil.ipRegExp = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0
|
|
|
362
293
|
DeviceUtil.CLIENT_PORT = 39517;
|
|
363
294
|
DeviceUtil.quickapp_url = 'https://statres.quickapp.cn/quickapp/quickapptool/release/platform/';
|
|
364
295
|
exports.default = DeviceUtil;
|
|
365
|
-
|
|
366
|
-
//# sourceMappingURL=DeviceUtil.js.map
|
|
@@ -12,7 +12,6 @@ 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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
15
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
17
16
|
const axios_1 = __importDefault(require("axios"));
|
|
18
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -39,26 +38,16 @@ class RequestUtils {
|
|
|
39
38
|
axios_1.default
|
|
40
39
|
.post(requrl, options)
|
|
41
40
|
.then((data) => {
|
|
42
|
-
ColorConsole_1.default.log({
|
|
43
|
-
message: `### App Server ### Request ${requrl} succeeded`
|
|
44
|
-
});
|
|
41
|
+
ColorConsole_1.default.log(`### App Server ### Request ${requrl} succeeded`);
|
|
45
42
|
resolve(data.toString());
|
|
46
43
|
})
|
|
47
44
|
.catch((error) => {
|
|
48
45
|
if (error.respose && error.response.status === 408) {
|
|
49
46
|
// 超时处理
|
|
50
|
-
ColorConsole_1.default.
|
|
51
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
52
|
-
message: `### App Server ### Request ${requrl} timed out, please try again`,
|
|
53
|
-
isOnlyPrintError: true
|
|
54
|
-
});
|
|
47
|
+
ColorConsole_1.default.error(`### App Server ### Request ${requrl} timed out, please try again`);
|
|
55
48
|
}
|
|
56
49
|
else {
|
|
57
|
-
ColorConsole_1.default.
|
|
58
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
59
|
-
message: `### App Server ### Request ${requrl} error message: ${error.message}`,
|
|
60
|
-
isOnlyPrintError: true
|
|
61
|
-
});
|
|
50
|
+
ColorConsole_1.default.error(`### App Server ### Request ${requrl} error message: ${(error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'}`);
|
|
62
51
|
}
|
|
63
52
|
});
|
|
64
53
|
});
|
|
@@ -67,9 +56,7 @@ class RequestUtils {
|
|
|
67
56
|
static downloadFile(url, fileName) {
|
|
68
57
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
69
58
|
// 开始下载
|
|
70
|
-
ColorConsole_1.default.log({
|
|
71
|
-
message: `Start downloading file:${fileName}, address:${url}`
|
|
72
|
-
});
|
|
59
|
+
ColorConsole_1.default.log(`Start downloading file:${fileName}, address:${url}`);
|
|
73
60
|
const response = yield axios_1.default.get(url, {
|
|
74
61
|
responseType: 'arraybuffer'
|
|
75
62
|
});
|
|
@@ -86,5 +73,3 @@ class RequestUtils {
|
|
|
86
73
|
}
|
|
87
74
|
}
|
|
88
75
|
exports.default = RequestUtils;
|
|
89
|
-
|
|
90
|
-
//# sourceMappingURL=RequestUtils.js.map
|
|
@@ -26,11 +26,11 @@ declare class VelaAvdUtils {
|
|
|
26
26
|
/** 根据host获取模拟器下载地址 */
|
|
27
27
|
static getEmulatorUrl(version?: string): string;
|
|
28
28
|
/** 根据host获取vela镜像下载地址 */
|
|
29
|
-
static getSystemImageUrl(version?: string
|
|
29
|
+
static getSystemImageUrl(version?: string): string;
|
|
30
30
|
/** 根据host获取ya-vm-file-server下载地址 */
|
|
31
31
|
static getv9fsToolUrl(version?: string): string;
|
|
32
32
|
/** 获取资源文件下载地址 */
|
|
33
|
-
static getDownloadUrl(
|
|
33
|
+
static getDownloadUrl(dir: string, version?: string, filename?: string): string;
|
|
34
34
|
/**
|
|
35
35
|
* 命令行访问方式创建模拟器
|
|
36
36
|
*/
|