aiot-toolkit 1.0.20-importfile-dev.2 → 2.0.1-alpha.1
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 +26 -192
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +229 -0
- package/lib/bin.js.map +1 -0
- package/lib/builder/IBuilder.d.ts +22 -0
- package/lib/builder/IBuilder.js +4 -0
- package/lib/builder/IBuilder.js.map +1 -0
- package/lib/builder/UxBuilder.d.ts +26 -0
- package/lib/builder/UxBuilder.js +102 -0
- package/lib/builder/UxBuilder.js.map +1 -0
- package/lib/builder/XtsBuilder.d.ts +15 -0
- package/lib/builder/XtsBuilder.js +65 -0
- package/lib/builder/XtsBuilder.js.map +1 -0
- package/lib/interface/CommandInterface.d.ts +15 -0
- package/lib/interface/CommandInterface.js +4 -0
- package/lib/interface/CommandInterface.js.map +1 -0
- package/lib/interface/VelaEmulatorInterface.d.ts +8 -0
- package/lib/interface/VelaEmulatorInterface.js +4 -0
- package/lib/interface/VelaEmulatorInterface.js.map +1 -0
- package/lib/utils/AdbUtils.d.ts +14 -0
- package/lib/utils/AdbUtils.js +103 -0
- package/lib/utils/AdbUtils.js.map +1 -0
- package/lib/utils/DeviceUtil.d.ts +62 -0
- package/lib/utils/DeviceUtil.js +366 -0
- package/lib/utils/DeviceUtil.js.map +1 -0
- package/lib/utils/RequestUtils.d.ts +11 -0
- package/lib/utils/RequestUtils.js +90 -0
- package/lib/utils/RequestUtils.js.map +1 -0
- package/lib/utils/VelaAvdUtils.d.ts +39 -0
- package/lib/utils/VelaAvdUtils.js +308 -0
- package/lib/utils/VelaAvdUtils.js.map +1 -0
- package/lib/waiter.d.ts +3 -0
- package/lib/waiter.js +39 -0
- package/lib/waiter.js.map +1 -0
- package/package.json +33 -47
- package/CHANGELOG.md +0 -353
- package/bin/index.js +0 -495
- package/gen-webpack-conf/get-devtool.js +0 -51
- package/gen-webpack-conf/helpers.js +0 -143
- package/gen-webpack-conf/index.js +0 -436
- package/gen-webpack-conf/manifest-schema.js +0 -284
- package/gen-webpack-conf/validate.js +0 -284
- package/lib/commands/compile.js +0 -2
- package/lib/commands/debug.js +0 -2
- package/lib/commands/init.js +0 -2
- package/lib/commands/packages.js +0 -2
- package/lib/commands/preview.js +0 -2
- package/lib/commands/report.js +0 -2
- package/lib/commands/resign.js +0 -2
- package/lib/commands/update.js +0 -2
- package/lib/commands/utils.js +0 -2
- package/lib/index.js +0 -2
- package/lib/plugins/manifest-watch-plugin.js +0 -2
- package/lib/utils.js +0 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IParam } from '@aiot-toolkit/commander';
|
|
2
|
+
import IBuilder from './IBuilder';
|
|
3
|
+
interface IBuilderOption {
|
|
4
|
+
watch?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* XtsBuilder
|
|
8
|
+
*/
|
|
9
|
+
declare class XtsBuilder implements IBuilder<IBuilderOption> {
|
|
10
|
+
static readonly PROJECT_TYPE = "xts quick app";
|
|
11
|
+
match(projectPath: string): boolean;
|
|
12
|
+
build(projectPath: string, options: IBuilderOption): Promise<void>;
|
|
13
|
+
readonly params: IParam[];
|
|
14
|
+
}
|
|
15
|
+
export default XtsBuilder;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const aiotpack_1 = require("@aiot-toolkit/aiotpack");
|
|
16
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
17
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
18
|
+
const file_lane_1 = require("file-lane");
|
|
19
|
+
/**
|
|
20
|
+
* XtsBuilder
|
|
21
|
+
*/
|
|
22
|
+
class XtsBuilder {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.params = [
|
|
25
|
+
{
|
|
26
|
+
name: 'p1',
|
|
27
|
+
description: 'xts 的第1个参数',
|
|
28
|
+
type: 'string'
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'p2',
|
|
32
|
+
description: 'xts 的第2个参数',
|
|
33
|
+
type: 'string',
|
|
34
|
+
enableInquirer: true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'watch',
|
|
38
|
+
description: 'watch file change',
|
|
39
|
+
defaultValue: false,
|
|
40
|
+
type: 'confirm'
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
match(projectPath) {
|
|
45
|
+
return projectPath.includes('xts');
|
|
46
|
+
}
|
|
47
|
+
build(projectPath, options) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const { watch } = options;
|
|
50
|
+
ColorConsole_1.default.log({
|
|
51
|
+
message: JSON.stringify({
|
|
52
|
+
projectPath,
|
|
53
|
+
options
|
|
54
|
+
}, undefined, 2),
|
|
55
|
+
level: shared_utils_1.LOG_LEVEL.Success
|
|
56
|
+
});
|
|
57
|
+
const config = new aiotpack_1.XtsConfig();
|
|
58
|
+
return new file_lane_1.FileLane(config, projectPath).start({ watch });
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
XtsBuilder.PROJECT_TYPE = 'xts quick app';
|
|
63
|
+
exports.default = XtsBuilder;
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=XtsBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["builder/XtsBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qDAAkD;AAElD,6DAAsD;AACtD,+FAAsE;AACtE,yCAAoC;AAOpC;;GAEG;AACH,MAAM,UAAU;IAAhB;QAwBW,WAAM,GAAa;YAC1B;gBACE,IAAI,EAAE,IAAI;gBACV,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,QAAQ;aACf;YACD;gBACE,IAAI,EAAE,IAAI;gBACV,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,QAAQ;gBACd,cAAc,EAAE,IAAI;aACrB;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,mBAAmB;gBAChC,YAAY,EAAE,KAAK;gBACnB,IAAI,EAAE,SAAS;aAChB;SACF,CAAA;IACH,CAAC;IAxCC,KAAK,CAAC,WAAmB;QACvB,OAAO,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IAEK,KAAK,CAAC,WAAmB,EAAE,OAAuB;;YACtD,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;YACzB,sBAAY,CAAC,GAAG,CAAC;gBACf,OAAO,EAAE,IAAI,CAAC,SAAS,CACrB;oBACE,WAAW;oBACX,OAAO;iBACR,EACD,SAAS,EACT,CAAC,CACF;gBACD,KAAK,EAAE,wBAAS,CAAC,OAAO;aACzB,CAAC,CAAA;YACF,MAAM,MAAM,GAAG,IAAI,oBAAS,EAAE,CAAA;YAC9B,OAAO,IAAI,oBAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QAC3D,CAAC;KAAA;;AArBe,uBAAY,GAAG,eAAH,AAAkB,CAAA;AA2ChD,kBAAe,UAAU,CAAA","file":"XtsBuilder.js","sourcesContent":["import { XtsConfig } from '@aiot-toolkit/aiotpack'\nimport { IParam } from '@aiot-toolkit/commander'\nimport { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport { FileLane } from 'file-lane'\nimport IBuilder from './IBuilder'\n\ninterface IBuilderOption {\n watch?: boolean\n}\n\n/**\n * XtsBuilder\n */\nclass XtsBuilder implements IBuilder<IBuilderOption> {\n static readonly PROJECT_TYPE = 'xts quick app'\n\n match(projectPath: string): boolean {\n return projectPath.includes('xts')\n }\n\n async build(projectPath: string, options: IBuilderOption) {\n const { watch } = options\n ColorConsole.log({\n message: JSON.stringify(\n {\n projectPath,\n options\n },\n undefined,\n 2\n ),\n level: LOG_LEVEL.Success\n })\n const config = new XtsConfig()\n return new FileLane(config, projectPath).start({ watch })\n }\n\n readonly params: IParam[] = [\n {\n name: 'p1',\n description: 'xts 的第1个参数',\n type: 'string'\n },\n {\n name: 'p2',\n description: 'xts 的第2个参数',\n type: 'string',\n enableInquirer: true\n },\n {\n name: 'watch',\n description: 'watch file change',\n defaultValue: false,\n type: 'confirm'\n }\n ]\n}\nexport default XtsBuilder\n"],"sourceRoot":"../../src"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IInstallApkAndDbg
|
|
3
|
+
*/
|
|
4
|
+
export interface IInstallApkAndDbg {
|
|
5
|
+
ip?: string;
|
|
6
|
+
port?: string;
|
|
7
|
+
platform?: string;
|
|
8
|
+
apkVersion?: string;
|
|
9
|
+
forceInstall?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface IGetAvailablePlatform {
|
|
12
|
+
ip: string;
|
|
13
|
+
port: string;
|
|
14
|
+
sn: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["interface/CommandInterface.ts"],"names":[],"mappings":"","file":"CommandInterface.js","sourcesContent":["/**\n * IInstallApkAndDbg\n */\nexport interface IInstallApkAndDbg {\n ip?: string\n port?: string\n platform?: string\n apkVersion?: string\n forceInstall?: boolean\n}\nexport interface IGetAvailablePlatform {\n ip: string\n port: string\n sn: string\n}\n"],"sourceRoot":"../../src"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["interface/VelaEmulatorInterface.ts"],"names":[],"mappings":"","file":"VelaEmulatorInterface.js","sourcesContent":["export interface IGoldfishVersionInfo {\n name: string;\n emulator: string;\n 'system-images': string;\n qa: string;\n skins: string;\n tools: string;\n}"],"sourceRoot":"../../src"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdbUtils
|
|
3
|
+
*/
|
|
4
|
+
declare class AdbUtils {
|
|
5
|
+
static connect(ip: string, port: string): Promise<boolean>;
|
|
6
|
+
static getAllConnectedDevices(): Promise<string[]>;
|
|
7
|
+
static getUSBConnectedDevices(): Promise<string[]>;
|
|
8
|
+
static installApk(sn: string, apkPath: string): Promise<{
|
|
9
|
+
status: boolean;
|
|
10
|
+
msg: string;
|
|
11
|
+
}>;
|
|
12
|
+
static startDebugger(deviceSn: string): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export default AdbUtils;
|
|
@@ -0,0 +1,103 @@
|
|
|
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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
39
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
40
|
+
const adbMiwt = __importStar(require("@miwt/adb"));
|
|
41
|
+
const adb_commander_1 = __importDefault(require("adb-commander"));
|
|
42
|
+
/**
|
|
43
|
+
* AdbUtils
|
|
44
|
+
*/
|
|
45
|
+
class AdbUtils {
|
|
46
|
+
// 连接设备
|
|
47
|
+
static connect(ip, port) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const adbConnet = yield adbMiwt.execAdbCmdAsync(`adb connect ${ip}:${port}`);
|
|
50
|
+
return adbConnet.indexOf('connected to') >= 0;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// 获取所有已连接的设备(包含无线连接设备)
|
|
54
|
+
static getAllConnectedDevices() {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const res = yield adbMiwt.getAdbDevices();
|
|
57
|
+
return res.map(({ sn }) => sn);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// 获取USB连接的设备
|
|
61
|
+
static getUSBConnectedDevices() {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const res = yield adb_commander_1.default.deviceList();
|
|
64
|
+
return res.deviceList;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// 安装设备
|
|
68
|
+
static installApk(sn, apkPath) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const result = yield adbMiwt.installApk(sn, apkPath);
|
|
71
|
+
return result;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// 启动调试器
|
|
75
|
+
static startDebugger(deviceSn) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const adbShell = adbMiwt.execAdbCmd(`adb -s ${deviceSn} shell am start -n "org.hapjs.debugger/.MainActivity"`);
|
|
78
|
+
adbShell.stdout.on('data', (data) => {
|
|
79
|
+
// 监听stderr事件,获取输出内容
|
|
80
|
+
ColorConsole_1.default.log({
|
|
81
|
+
message: data
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
adbShell.stderr.on('data', (data) => {
|
|
85
|
+
// 监听stderr事件,获取输出内容
|
|
86
|
+
if (data.indexOf('Error') >= 0) {
|
|
87
|
+
ColorConsole_1.default.log({
|
|
88
|
+
level: shared_utils_1.LOG_LEVEL.Error,
|
|
89
|
+
message: data
|
|
90
|
+
});
|
|
91
|
+
process.exit();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
adbShell.on('close', () => {
|
|
95
|
+
// 处理命令正常结束
|
|
96
|
+
Promise.resolve();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.default = AdbUtils;
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=AdbUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["utils/AdbUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAAsD;AACtD,+FAAsE;AACtE,mDAAoC;AACpC,kEAAwC;AAExC;;GAEG;AACH,MAAM,QAAQ;IACZ,OAAO;IACP,MAAM,CAAO,OAAO,CAAC,EAAU,EAAE,IAAY;;YAC3C,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,eAAe,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;YAC5E,OAAO,SAAS,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;QAC/C,CAAC;KAAA;IACD,uBAAuB;IACvB,MAAM,CAAO,sBAAsB;;YACjC,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,aAAa,EAAE,CAAA;YACzC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAA;QAChC,CAAC;KAAA;IACD,aAAa;IACb,MAAM,CAAO,sBAAsB;;YACjC,MAAM,GAAG,GAAG,MAAM,uBAAY,CAAC,UAAU,EAAE,CAAA;YAC3C,OAAO,GAAG,CAAC,UAAU,CAAA;QACvB,CAAC;KAAA;IACD,OAAO;IACP,MAAM,CAAO,UAAU,CAAC,EAAU,EAAE,OAAe;;YACjD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;YACpD,OAAO,MAAM,CAAA;QACf,CAAC;KAAA;IACD,QAAQ;IACR,MAAM,CAAO,aAAa,CAAC,QAAgB;;YACzC,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CACjC,UAAU,QAAQ,uDAAuD,CAC1E,CAAA;YACD,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;gBAC1C,oBAAoB;gBACpB,sBAAY,CAAC,GAAG,CAAC;oBACf,OAAO,EAAE,IAAI;iBACd,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;YACF,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;gBAC1C,oBAAoB;gBACpB,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;oBAC9B,sBAAY,CAAC,GAAG,CAAC;wBACf,KAAK,EAAE,wBAAS,CAAC,KAAK;wBACtB,OAAO,EAAE,IAAI;qBACd,CAAC,CAAA;oBACF,OAAO,CAAC,IAAI,EAAE,CAAA;iBACf;YACH,CAAC,CAAC,CAAA;YACF,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;gBACxB,WAAW;gBACX,OAAO,CAAC,OAAO,EAAE,CAAA;YACnB,CAAC,CAAC,CAAA;QACJ,CAAC;KAAA;CACF;AACD,kBAAe,QAAQ,CAAA","file":"AdbUtils.js","sourcesContent":["import { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport * as adbMiwt from '@miwt/adb'\nimport adbCommander from 'adb-commander'\n\n/**\n * AdbUtils\n */\nclass AdbUtils {\n // 连接设备\n static async connect(ip: string, port: string) {\n const adbConnet = await adbMiwt.execAdbCmdAsync(`adb connect ${ip}:${port}`)\n return adbConnet.indexOf('connected to') >= 0\n }\n // 获取所有已连接的设备(包含无线连接设备)\n static async getAllConnectedDevices() {\n const res = await adbMiwt.getAdbDevices()\n return res.map(({ sn }) => sn)\n }\n // 获取USB连接的设备\n static async getUSBConnectedDevices() {\n const res = await adbCommander.deviceList()\n return res.deviceList\n }\n // 安装设备\n static async installApk(sn: string, apkPath: string) {\n const result = await adbMiwt.installApk(sn, apkPath)\n return result\n }\n // 启动调试器\n static async startDebugger(deviceSn: string) {\n const adbShell = adbMiwt.execAdbCmd(\n `adb -s ${deviceSn} shell am start -n \"org.hapjs.debugger/.MainActivity\"`\n )\n adbShell.stdout.on('data', (data: string) => {\n // 监听stderr事件,获取输出内容\n ColorConsole.log({\n message: data\n })\n })\n adbShell.stderr.on('data', (data: string) => {\n // 监听stderr事件,获取输出内容\n if (data.indexOf('Error') >= 0) {\n ColorConsole.log({\n level: LOG_LEVEL.Error,\n message: data\n })\n process.exit()\n }\n })\n adbShell.on('close', () => {\n // 处理命令正常结束\n Promise.resolve()\n })\n }\n}\nexport default AdbUtils\n"],"sourceRoot":"../../src"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { IGetAvailablePlatform, IInstallApkAndDbg } from '../interface/CommandInterface';
|
|
2
|
+
/**
|
|
3
|
+
* DeviceUtil
|
|
4
|
+
*/
|
|
5
|
+
declare class DeviceUtil {
|
|
6
|
+
static ipRegExp: RegExp;
|
|
7
|
+
static CLIENT_PORT: number;
|
|
8
|
+
static quickapp_url: string;
|
|
9
|
+
/**
|
|
10
|
+
* 获取连接上的所有设备数组,供IDE使用
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
static getAllConnectedDevices(): Promise<string[]>;
|
|
14
|
+
/**
|
|
15
|
+
* 安装调试器、预览版
|
|
16
|
+
* @param options
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
static installDbgAndMkp(options: IInstallApkAndDbg): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* 如果是TV等AIOT设备,需要通过IP连接
|
|
22
|
+
* 1. 若ip为空,则询问是否要连接新设备
|
|
23
|
+
* 2. 无需连接新设备,返回
|
|
24
|
+
* 3. 连接新设备,输入ip值(可输入多个ip,以逗号隔断)
|
|
25
|
+
* 4. 判断输入值,空则输出info并返回
|
|
26
|
+
* 5. 处理ip,输入每个ip设备的端口号,尝试连接,给出连接结果
|
|
27
|
+
* @param ip
|
|
28
|
+
*/
|
|
29
|
+
static connectDevice(ip: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* 选择一个或者多个设备
|
|
32
|
+
* @param deviceList
|
|
33
|
+
* @param orderText
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
static queryDevice(deviceList: string[] | undefined, orderText?: string): Promise<string[] | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* 下载apk
|
|
39
|
+
* @param options
|
|
40
|
+
* @param isQuickAppDebugger
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
static downloadApk(options: IInstallApkAndDbg, isQuickAppDebugger: boolean): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* 获取设备上的快应用框架(需要先安装调试器)
|
|
46
|
+
* 1. 请求获取平台信息
|
|
47
|
+
* 2. 若获取结果为空或者undefined,则等待3s再次请求
|
|
48
|
+
* 3. 若获取结果不为空,但属性availablePlatforms为空,则等待3s再次请求
|
|
49
|
+
* 4. 若请求次数超过3次,则结束请求
|
|
50
|
+
* 5. 否则打印获取结果
|
|
51
|
+
* @param options
|
|
52
|
+
*/
|
|
53
|
+
static getAvailablePlatform(options: IGetAvailablePlatform): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* 给设备列表中的每个设备安装apk
|
|
56
|
+
* @param deviceList
|
|
57
|
+
* @param apkPath
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
static installApk(deviceList: string[] | undefined, apkPath: string): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
export default DeviceUtil;
|