aiot-toolkit 2.0.1-alpha.12 → 2.0.1-alpha.13
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 +24 -30
- package/lib/bin.js.map +1 -1
- package/lib/builder/UxBuilder.d.ts +1 -0
- package/lib/builder/UxBuilder.js +20 -7
- package/lib/builder/UxBuilder.js.map +1 -1
- package/lib/builder/XtsBuilder.js +3 -11
- package/lib/builder/XtsBuilder.js.map +1 -1
- package/lib/starter/IStarter.d.ts +23 -0
- package/lib/starter/IStarter.js +47 -0
- package/lib/starter/IStarter.js.map +1 -0
- package/lib/starter/UxStarter.d.ts +10 -0
- package/lib/starter/UxStarter.js +138 -0
- package/lib/starter/UxStarter.js.map +1 -0
- package/lib/starter/XtsStarter.d.ts +9 -0
- package/lib/starter/XtsStarter.js +18 -0
- package/lib/starter/XtsStarter.js.map +1 -0
- package/lib/utils/AdbUtils.js +2 -9
- package/lib/utils/AdbUtils.js.map +1 -1
- package/lib/utils/DeviceUtil.d.ts +1 -1
- package/lib/utils/DeviceUtil.js +22 -91
- package/lib/utils/DeviceUtil.js.map +1 -1
- package/lib/utils/RequestUtils.js +4 -17
- package/lib/utils/RequestUtils.js.map +1 -1
- package/lib/utils/VelaAvdUtils.js +15 -56
- package/lib/utils/VelaAvdUtils.js.map +1 -1
- package/package.json +10 -7
- 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/bin.js
CHANGED
|
@@ -14,20 +14,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
const commander_1 = require("@aiot-toolkit/commander");
|
|
17
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
18
17
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
19
18
|
const XtsBuilder_1 = __importDefault(require("./builder/XtsBuilder"));
|
|
20
|
-
const
|
|
19
|
+
const XtsStarter_1 = __importDefault(require("./starter/XtsStarter"));
|
|
21
20
|
const DeviceUtil_1 = __importDefault(require("./utils/DeviceUtil"));
|
|
22
21
|
const VelaAvdUtils_1 = __importDefault(require("./utils/VelaAvdUtils"));
|
|
23
|
-
|
|
24
|
-
// 配置支持的 builder 类型,新增的项目类型,只需在此处加上类型
|
|
25
|
-
function findBuilder(projectPath) {
|
|
22
|
+
function findBuilder() {
|
|
26
23
|
return new XtsBuilder_1.default();
|
|
27
24
|
}
|
|
28
25
|
function build(command, description) {
|
|
29
|
-
const
|
|
30
|
-
const builder = findBuilder(projectPath);
|
|
26
|
+
const builder = findBuilder();
|
|
31
27
|
const paramList = builder === null || builder === void 0 ? void 0 : builder.params;
|
|
32
28
|
return {
|
|
33
29
|
name: command,
|
|
@@ -36,25 +32,13 @@ function build(command, description) {
|
|
|
36
32
|
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
37
33
|
// 获取对应的 build;如果存在,执行 build 函数,不存在,提示
|
|
38
34
|
const projectPath = process.cwd();
|
|
39
|
-
|
|
40
|
-
if (builder) {
|
|
41
|
-
const { watch } = option;
|
|
42
|
-
yield builder.build(projectPath, option);
|
|
43
|
-
if (watch) {
|
|
44
|
-
waiter_1.default.describe();
|
|
45
|
-
waiter_1.default.start();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
ColorConsole_1.default.log({
|
|
50
|
-
message: `This type of project is not currently supported. The supported projects : xts`,
|
|
51
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
52
|
-
isOnlyPrintError: true
|
|
53
|
-
});
|
|
54
|
-
}
|
|
35
|
+
yield builder.build(projectPath, option);
|
|
55
36
|
})
|
|
56
37
|
};
|
|
57
38
|
}
|
|
39
|
+
function findStarter(command, description) {
|
|
40
|
+
return new XtsStarter_1.default(command, description);
|
|
41
|
+
}
|
|
58
42
|
function main() {
|
|
59
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
44
|
const config = {
|
|
@@ -63,19 +47,29 @@ function main() {
|
|
|
63
47
|
version: '2.0.1',
|
|
64
48
|
commandList: [
|
|
65
49
|
build('build', 'build project'),
|
|
66
|
-
|
|
50
|
+
findStarter('start', 'start project').getCommond(),
|
|
51
|
+
{
|
|
52
|
+
name: 'watch',
|
|
53
|
+
description: 'recompile project while file changes',
|
|
54
|
+
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const projectPath = process.cwd();
|
|
56
|
+
const builder = findBuilder();
|
|
57
|
+
option.watch = true;
|
|
58
|
+
yield builder.build(projectPath, option);
|
|
59
|
+
// waiter.describe()
|
|
60
|
+
// waiter.start()
|
|
61
|
+
})
|
|
62
|
+
},
|
|
67
63
|
{
|
|
68
64
|
name: 'getConnectedDevices',
|
|
69
65
|
description: 'get all connected devices',
|
|
70
66
|
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
71
67
|
try {
|
|
72
68
|
const connectedDevices = yield DeviceUtil_1.default.getAllConnectedDevices();
|
|
73
|
-
ColorConsole_1.default.
|
|
74
|
-
message: `The connected devices are: ${connectedDevices ? connectedDevices.join(', ') : 'null'}`
|
|
75
|
-
});
|
|
69
|
+
ColorConsole_1.default.info(`The connected devices are: ${connectedDevices ? connectedDevices.join(', ') : 'null'}`);
|
|
76
70
|
}
|
|
77
71
|
catch (error) {
|
|
78
|
-
ColorConsole_1.default.
|
|
72
|
+
ColorConsole_1.default.throw(`Error: getConnectedDevices failed`);
|
|
79
73
|
}
|
|
80
74
|
})
|
|
81
75
|
},
|
|
@@ -124,10 +118,10 @@ function main() {
|
|
|
124
118
|
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
125
119
|
try {
|
|
126
120
|
const successMessage = yield DeviceUtil_1.default.installDbgAndMkp(option);
|
|
127
|
-
ColorConsole_1.default.
|
|
121
|
+
ColorConsole_1.default.success(`${successMessage}`);
|
|
128
122
|
}
|
|
129
123
|
catch (error) {
|
|
130
|
-
ColorConsole_1.default.
|
|
124
|
+
ColorConsole_1.default.throw(`installDbgAndMkp failed, errorMessage: ${(error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'}'}`);
|
|
131
125
|
}
|
|
132
126
|
})
|
|
133
127
|
},
|
package/lib/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["bin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,uDAAqE;AACrE
|
|
1
|
+
{"version":3,"sources":["bin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,uDAAqE;AACrE,+FAAsE;AAEtE,sEAA6C;AAC7C,sEAA6C;AAC7C,oEAA2C;AAC3C,wEAA8C;AAE9C,SAAS,WAAW;IAClB,OAAO,IAAI,oBAAU,EAAE,CAAA;AACzB,CAAC;AAED,SAAS,KAAK,CAAC,OAAe,EAAE,WAAmB;IACjD,MAAM,OAAO,GAAG,WAAW,EAAE,CAAA;IAC7B,MAAM,SAAS,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAAA;IAEjC,OAAO;QACL,IAAI,EAAE,OAAO;QACb,WAAW;QACX,SAAS;QACT,MAAM,EAAE,CAAO,MAAW,EAAE,EAAE;YAC5B,sCAAsC;YACtC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;YACjC,MAAM,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;QAC1C,CAAC,CAAA;KACF,CAAA;AACH,CAAC;AAED,SAAS,WAAW,CAAC,OAAe,EAAE,WAAmB;IACvD,OAAO,IAAI,oBAAU,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;AAC7C,CAAC;AAED,SAAe,IAAI;;QACjB,MAAM,MAAM,GAAa;YACvB,IAAI,EAAE,cAAc;YACpB,WAAW,EAAE,8DAA8D;YAC3E,OAAO,EAA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'@aiot-toolkit/commander'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport IBuilder from './builder/IBuilder'\nimport XtsBuilder from './builder/XtsBuilder'\nimport XtsStarter from './starter/XtsStarter'\nimport DeviceUtil from './utils/DeviceUtil'\nimport VelaAvdUtil from './utils/VelaAvdUtils'\n\nfunction findBuilder(): IBuilder {\n return new XtsBuilder()\n}\n\nfunction build(command: string, description: string): ICommand {\n const builder = findBuilder()\n const paramList = builder?.params\n\n return {\n name: command,\n description,\n paramList,\n action: async (option: any) => {\n // 获取对应的 build;如果存在,执行 build 函数,不存在,提示\n const projectPath = process.cwd()\n await builder.build(projectPath, option)\n }\n }\n}\n\nfunction findStarter(command: string, description: string) {\n return new XtsStarter(command, description)\n}\n\nasync function main() {\n const config: IProgram = {\n name: 'aiot-toolkit',\n description: 'contains build, dev, release, etc. commands for aiot toolkit',\n version: '2.0.1',\n commandList: [\n build('build', 'build project'),\n findStarter('start', 'start project').getCommond(),\n {\n name: 'watch',\n description: 'recompile project while file changes',\n action: async (option) => {\n const projectPath = process.cwd()\n const builder = findBuilder()\n option.watch = true\n await builder.build(projectPath, option)\n // waiter.describe()\n // waiter.start()\n }\n },\n {\n name: 'getConnectedDevices',\n description: 'get all connected devices',\n action: async (option) => {\n try {\n const connectedDevices = await DeviceUtil.getAllConnectedDevices()\n ColorConsole.info(\n `The connected devices are: ${\n connectedDevices ? connectedDevices.join(', ') : 'null'\n }`\n )\n } catch (error) {\n ColorConsole.throw(`Error: getConnectedDevices failed`)\n }\n }\n },\n {\n name: 'getPlatforms',\n description: 'get available platform(s) on selected device',\n paramList: [\n {\n name: 'ip',\n description: 'device ip(eg 127.0.0.1)',\n type: 'string',\n enableInquirer: true\n },\n {\n name: 'port',\n description: 'device port(eg 39517)',\n type: 'string',\n enableInquirer: true\n },\n {\n name: 'sn',\n description:\n 'view the serial number of the connected device through the \"adb devices\" command, if it is a device connected via wifi, the format is \"ip address:5555\"',\n type: 'string',\n enableInquirer: true\n }\n ],\n action: async (option) => {\n await DeviceUtil.getAvailablePlatform(option)\n }\n },\n {\n name: 'installDbgAndMkp',\n description: 'install \"org.hapjs.debugger\" & \"org.hapjs.mockup\" ',\n paramList: [\n {\n name: 'ip',\n description: 'device ip(eg 127.0.0.1)',\n type: 'string'\n },\n {\n name: 'port',\n description: 'device ip(eg 5555)',\n type: 'string'\n }\n ],\n action: async (option) => {\n try {\n const successMessage = await DeviceUtil.installDbgAndMkp(option)\n ColorConsole.success(`${successMessage}`)\n } catch (error) {\n ColorConsole.throw(\n `installDbgAndMkp failed, errorMessage: ${error?.toString() || 'unknown error'}'}`\n )\n }\n }\n },\n {\n name: 'createVelaAvd',\n description: 'create a vela avd instance',\n action: async () => {\n VelaAvdUtil.createVelaAvdByInquire()\n }\n }\n ]\n }\n Command.registeProgram(config)\n}\nmain()\n"],"sourceRoot":"../src"}
|
package/lib/builder/UxBuilder.js
CHANGED
|
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
24
|
};
|
|
@@ -15,7 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
26
|
const CompileMode_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/compiler/enum/CompileMode"));
|
|
16
27
|
const JavascriptDefaultCompileOption_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/compiler/javascript/JavascriptDefaultCompileOption"));
|
|
17
28
|
const UxConfig_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/config/UxConfig"));
|
|
18
|
-
const
|
|
29
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
19
30
|
const file_lane_1 = require("file-lane");
|
|
20
31
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
21
32
|
const lodash_1 = __importDefault(require("lodash"));
|
|
@@ -56,10 +67,11 @@ class UxBuilder {
|
|
|
56
67
|
*/
|
|
57
68
|
build(projectPath, options) {
|
|
58
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const
|
|
70
|
+
const watch = options.watch || false;
|
|
60
71
|
// 读取项目中文件的配置
|
|
61
72
|
const quickappConfig = this.readQuickAppConfig(projectPath);
|
|
62
|
-
|
|
73
|
+
const _a = quickappConfig || {}, { cli } = _a, otherConfig = __rest(_a, ["cli"]);
|
|
74
|
+
options = lodash_1.default.merge({}, options, cli);
|
|
63
75
|
// 项目配置
|
|
64
76
|
const uxProjectConfig = new UxConfig_1.default(projectPath);
|
|
65
77
|
// 编译配置
|
|
@@ -67,8 +79,8 @@ class UxBuilder {
|
|
|
67
79
|
projectPath: path_1.default.join(projectPath, uxProjectConfig.output),
|
|
68
80
|
mode: CompileMode_1.default.DEVELOPMENT,
|
|
69
81
|
disabledJSC: options.disabledJsc
|
|
70
|
-
}, JavascriptDefaultCompileOption_1.default,
|
|
71
|
-
|
|
82
|
+
}, JavascriptDefaultCompileOption_1.default, otherConfig);
|
|
83
|
+
ColorConsole_1.default.info('start build: ', {
|
|
72
84
|
word: JSON.stringify({
|
|
73
85
|
step: 'build ux',
|
|
74
86
|
projectPath,
|
|
@@ -84,10 +96,11 @@ class UxBuilder {
|
|
|
84
96
|
const path = path_1.default.join(projectPath, this.QUICKAPP_CONFIG);
|
|
85
97
|
if (fs_extra_1.default.existsSync(path)) {
|
|
86
98
|
try {
|
|
87
|
-
|
|
99
|
+
const data = require(path);
|
|
100
|
+
return data;
|
|
88
101
|
}
|
|
89
102
|
catch (error) {
|
|
90
|
-
|
|
103
|
+
ColorConsole_1.default.throw((error === null || error === void 0 ? void 0 : error.toString()) || '');
|
|
91
104
|
}
|
|
92
105
|
}
|
|
93
106
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["builder/UxBuilder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["builder/UxBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uGAA8E;AAC9E,mJAA0H;AAG1H,0FAAiE;AAEjE,+FAAsE;AAEtE,yCAAoC;AACpC,wDAAyB;AACzB,oDAA2B;AAC3B,gDAAuB;AASvB;;GAEG;AACH,MAAM,SAAS;IAAf;QACW,oBAAe,GAAG,oBAAoB,CAAA;QA4D/C,WAAM,GAAgB;YACpB;gBACE,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,uCAAuC;aACrD;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,mBAAmB;aACjC;YACD;gBACE,IAAI,EAAE,qBAAqB;gBAC3B,WAAW,EAAE,qBAAqB;aACnC;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,cAAc;gBACpB,WAAW,EAAE,qBAAqB;gBAClC,YAAY,EAAE,IAAI;gBAClB,cAAc,EAAE,IAAI;aACrB;SACF,CAAA;IAKH,CAAC;IApFC;;;;;OAKG;IACG,KAAK,CAAC,WAAmB,EAAE,OAAyB;;YACxD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAA;YACpC,aAAa;Y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BACd,sBAAY,CAAC,KAAK,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,EAAE,KAAI,EAAE,CAAC,CAAA;aAC5C;SACF;QACD,OAAM;IACR,CAAC;IAwBD,KAAK,CAAC,WAAmB;QACvB,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACnC,CAAC;;AAzBe,sBAAY,GAAG,cAAH,AAAiB,CAAA;AA2B/C,kBAAe,SAAS,CAAA","file":"UxBuilder.js","sourcesContent":["import CompileMode from '@aiot-toolkit/aiotpack/lib/compiler/enum/CompileMode'\nimport JavascriptDefaultCompileOption from '@aiot-toolkit/aiotpack/lib/compiler/javascript/JavascriptDefaultCompileOption'\nimport IJavascriptCompileOption from '@aiot-toolkit/aiotpack/lib/compiler/javascript/interface/IJavascriptCompileOption'\nimport IQuickAppConfig from '@aiot-toolkit/aiotpack/lib/compiler/javascript/vela/interface/IQuickAppConfig'\nimport UxConfig from '@aiot-toolkit/aiotpack/lib/config/UxConfig'\nimport ParamType from '@aiot-toolkit/commander/lib/interface/IParam'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport { Dictionary } from '@aiot-toolkit/shared-utils/lib/type/Type'\nimport { FileLane } from 'file-lane'\nimport Fs from 'fs-extra'\nimport Lodash from 'lodash'\nimport Path from 'path'\nimport IBuilder from './IBuilder'\n\ninterface IUxBuilderOption extends Dictionary {\n watch?: boolean\n mode: CompileMode\n disabledJsc: boolean\n}\n\n/**\n * UxBuilder\n */\nclass UxBuilder implements IBuilder<IUxBuilderOption> {\n readonly QUICKAPP_CONFIG = 'quickapp.config.js'\n /**\n * ux项目的build函数\n * @param projectPath 项目路径\n * @param options 命令参数\n * @param watch 是否开启监听\n */\n async build(projectPath: string, options: IUxBuilderOption): Promise<void> {\n const watch = options.watch || false\n // 读取项目中文件的配置\n const quickappConfig = this.readQuickAppConfig(projectPath)\n const { cli, ...otherConfig } = quickappConfig || {}\n options = Lodash.merge({}, options, cli)\n // 项目配置\n const uxProjectConfig: UxConfig = new UxConfig(projectPath)\n\n // 编译配置\n const compilerOption: Partial<IJavascriptCompileOption> = Lodash.merge(\n {\n projectPath: Path.join(projectPath, uxProjectConfig.output),\n mode: CompileMode.DEVELOPMENT,\n disabledJSC: options.disabledJsc\n },\n JavascriptDefaultCompileOption,\n otherConfig\n )\n\n ColorConsole.info('start build: ', {\n word: JSON.stringify(\n {\n step: 'build ux',\n projectPath,\n options,\n watch\n },\n null,\n 2\n )\n })\n // 开始编译项目\n await new FileLane<IJavascriptCompileOption>(\n uxProjectConfig,\n projectPath,\n compilerOption as IJavascriptCompileOption\n ).start({ watch })\n }\n\n private readQuickAppConfig(projectPath: string): IQuickAppConfig | undefined {\n const path = Path.join(projectPath, this.QUICKAPP_CONFIG)\n if (Fs.existsSync(path)) {\n try {\n const data = require(path)\n return data\n } catch (error) {\n ColorConsole.throw(error?.toString() || '')\n }\n }\n return\n }\n static readonly PROJECT_TYPE = 'ux quick app'\n params: ParamType[] = [\n {\n name: 'enable-e2e',\n description: 'inject test-suite for current project'\n },\n {\n name: 'devtool',\n description: 'source map config'\n },\n {\n name: 'disable-subpackages',\n description: 'disable subpackages'\n },\n {\n type: 'confirm',\n name: 'disabled-jsc',\n description: 'disabled jsc bundle',\n defaultValue: true,\n enableInquirer: true\n }\n ]\n\n match(projectPath: string): boolean {\n return projectPath.includes('ux')\n }\n}\nexport default UxBuilder\n"],"sourceRoot":"../../src"}
|
|
@@ -52,22 +52,14 @@ class XtsBuilder {
|
|
|
52
52
|
build(projectPath, options) {
|
|
53
53
|
var _a;
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
const
|
|
56
|
-
ColorConsole_1.default.
|
|
57
|
-
message: JSON.stringify({
|
|
58
|
-
projectPath,
|
|
59
|
-
options
|
|
60
|
-
}, undefined, 2),
|
|
61
|
-
level: shared_utils_1.LOG_LEVEL.Success
|
|
62
|
-
});
|
|
55
|
+
const watch = options.watch || false;
|
|
56
|
+
ColorConsole_1.default.success('Start build...\n', { word: 'ProjectPath: ', style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Success) }, projectPath, '\n', { word: 'buildOptions: ', style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Success) }, JSON.stringify(options));
|
|
63
57
|
const compilerOptions = {
|
|
64
58
|
skip: StringUtil_1.default.string2arrayByComma(options.skip)
|
|
65
59
|
};
|
|
66
60
|
const config = new aiotpack_1.XtsConfig();
|
|
67
61
|
if ((_a = compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('xts2ts')) {
|
|
68
|
-
ColorConsole_1.default.
|
|
69
|
-
message: "skip compile xts to ts due to --skip ${compilerOptions?.skip.join(',')}"
|
|
70
|
-
});
|
|
62
|
+
ColorConsole_1.default.info("### skip compile xts to ts due to --skip ${compilerOptions?.skip.join(',')}");
|
|
71
63
|
const context = FileLaneUtil_1.default.createContext(config.output, projectPath);
|
|
72
64
|
const preWorks = config.preWorks || [];
|
|
73
65
|
for (let item of preWorks) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["builder/XtsBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qDAAkD;AAKlD,0FAA+E;AAG/E,6DAAsD;AACtD,+FAAsE;AACtE,iGAAwE;AACxE,yCAAoC;AACpC,oFAA2D;AAC3D,4CAAmB;AACnB,gDAAuB;AAQvB;;GAEG;AACH,MAAM,UAAU;IAAhB;
|
|
1
|
+
{"version":3,"sources":["builder/XtsBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qDAAkD;AAKlD,0FAA+E;AAG/E,6DAAsD;AACtD,+FAAsE;AACtE,iGAAwE;AACxE,yCAAoC;AACpC,oFAA2D;AAC3D,4CAAmB;AACnB,gDAAuB;AAQvB;;GAEG;AACH,MAAM,UAAU;IAAhB;QAoDW,WAAM,GAAa;YAC1B;gBACE,IAAI,EAAE,MAAM;gBACZ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;aAC3E,CAAA;YAED,MAAM,MAAM,GAAG,IAAI,oBAAS,EAAE,CAAA;YAC9B,IAAI,MAAA,eAAe,CAAC,IAAI,0CAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE;gBAC5C,sBAAY,CAAC,IAAI,CACf,6EAA6E,CAC9E,CAAA;gBACD,MAAM,OAAO,GAAG,sBAAY,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;gBAEtE,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAA;gBACtC,KAAK,IAAI,IAAI,IAAI,QAAQ,EAAE;oBACzB,IAAI;wBACF,MAAM,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,eAAe,CAAC,CAAA;qBACjD;oBAAC,OAAO,KAAK,EAAE;wBACd,wBAAwB;qBACzB;iBACF;gBAED,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,IAAI,EAAE,CAAA;gBAE1C,KAAK,IAAI,IAAI,IAAI,SAAS,EAAE;oBAC1B,IAAI;wBACF,MAAM,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,CAAA;qBAC7C;oBAAC,OAAO,KAAK,EAAE;wBACd,wBAAwB;qBACzB;iBACF;aACF;iBAAM;gBACL,OAAO,IAAI,oBAAQ,CAAqB,MAAM,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;aAC/F;;KACF;;AAjDe,uBAAY,GAAG,eAAH,AAAkB,CAAA;AA2EhD,kBAAe,UAAU,CAAA","file":"XtsBuilder.js","sourcesContent":["import { XtsConfig } from '@aiot-toolkit/aiotpack'\nimport type {\n ISkipList,\n IXtsCompileOptions\n} from '@aiot-toolkit/aiotpack/lib/interface/ICompileOptions'\nimport { skipList } from '@aiot-toolkit/aiotpack/lib/interface/ICompileOptions'\n\nimport { IParam } from '@aiot-toolkit/commander'\nimport { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport StringUtil from '@aiot-toolkit/shared-utils/lib/utils/StringUtil'\nimport { FileLane } from 'file-lane'\nimport FileLaneUtil from 'file-lane/lib/utils/FileLaneUtil'\nimport fs from 'fs'\nimport path from 'path'\nimport IBuilder from './IBuilder'\n\nexport interface IBuilderOption {\n watch?: boolean\n skip?: string\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 // app/app.xts 存在视为xts项目\n return fs.existsSync(path.resolve(projectPath, 'app/app.xts'))\n }\n\n async build(projectPath: string, options: IBuilderOption) {\n const watch = options.watch || false\n ColorConsole.success(\n 'Start build...\\n',\n { word: 'ProjectPath: ', style: ColorConsole.getStyle(LOG_LEVEL.Success) },\n projectPath,\n '\\n',\n { word: 'buildOptions: ', style: ColorConsole.getStyle(LOG_LEVEL.Success) },\n JSON.stringify(options)\n )\n const compilerOptions: IXtsCompileOptions = {\n skip: StringUtil.string2arrayByComma(options.skip) as unknown as ISkipList\n }\n\n const config = new XtsConfig()\n if (compilerOptions.skip?.includes('xts2ts')) {\n ColorConsole.info(\n \"### skip compile xts to ts due to --skip ${compilerOptions?.skip.join(',')}\"\n )\n const context = FileLaneUtil.createContext(config.output, projectPath)\n\n const preWorks = config.preWorks || []\n for (let item of preWorks) {\n try {\n await item(context, [], config, compilerOptions)\n } catch (error) {\n // 报错 prework的item error\n }\n }\n\n const follWorks = config.followWorks || []\n\n for (let item of follWorks) {\n try {\n await item(context, config, compilerOptions)\n } catch (error) {\n // 报错 prework的item error\n }\n }\n } else {\n return new FileLane<IXtsCompileOptions>(config, projectPath, compilerOptions).start({ watch })\n }\n }\n\n readonly params: IParam[] = [\n {\n name: 'skip',\n type: 'string',\n description: `Can configure skip steps, comma separated, optional values: ${skipList.join(\n ','\n )}`,\n validate(value: string) {\n // TODO: validate 不起作用\n const res = StringUtil.string2arrayByComma(value) as any as ISkipList\n const unValid = res.find((r) => {\n return !skipList.includes(r)\n })\n\n if (unValid) {\n return `${unValid} is unvalidate, validate value are ${skipList.join(\n ','\n )}, Multiple values separated by commas`\n }\n return true\n }\n }\n ]\n}\nexport default XtsBuilder\n"],"sourceRoot":"../../src"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ICommand, IParam } from '@aiot-toolkit/commander';
|
|
2
|
+
/**
|
|
3
|
+
* IStarter
|
|
4
|
+
*/
|
|
5
|
+
export default class IStarter<O = any> {
|
|
6
|
+
protected name: string;
|
|
7
|
+
protected description: string;
|
|
8
|
+
/**
|
|
9
|
+
* start 的参数列表
|
|
10
|
+
*/
|
|
11
|
+
readonly params: IParam[];
|
|
12
|
+
constructor(name: string, description: string);
|
|
13
|
+
/**
|
|
14
|
+
* start 的命令
|
|
15
|
+
*/
|
|
16
|
+
getCommond(): ICommand;
|
|
17
|
+
/**
|
|
18
|
+
* 运行项目
|
|
19
|
+
* @param projectPath 项目路径
|
|
20
|
+
* @param options 命令参数
|
|
21
|
+
*/
|
|
22
|
+
start(projectPath: string, options: O): void | Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
/**
|
|
13
|
+
* IStarter
|
|
14
|
+
*/
|
|
15
|
+
class IStarter {
|
|
16
|
+
constructor(name, description) {
|
|
17
|
+
this.name = name;
|
|
18
|
+
this.description = description;
|
|
19
|
+
/**
|
|
20
|
+
* start 的参数列表
|
|
21
|
+
*/
|
|
22
|
+
this.params = [];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* start 的命令
|
|
26
|
+
*/
|
|
27
|
+
getCommond() {
|
|
28
|
+
return {
|
|
29
|
+
name: this.name,
|
|
30
|
+
description: this.description,
|
|
31
|
+
paramList: this.params,
|
|
32
|
+
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const projectPath = process.cwd();
|
|
34
|
+
this.start(projectPath, option);
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 运行项目
|
|
40
|
+
* @param projectPath 项目路径
|
|
41
|
+
* @param options 命令参数
|
|
42
|
+
*/
|
|
43
|
+
start(projectPath, options) { }
|
|
44
|
+
}
|
|
45
|
+
exports.default = IStarter;
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=IStarter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["starter/IStarter.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA;;GAEG;AACH,MAAqB,QAAQ;IAO3B,YACY,IAAY,EACZ,WAAmB;QADnB,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAQ;QAP/B;;WAEG;QACM,WAAM,GAAa,EAAE,CAAA;IAK1B,CAAC;IAEL;;OAEG;IACH,UAAU;QACR,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,MAAM;YACtB,MAAM,EAAE,CAAO,MAAM,EAAE,EAAE;gBACvB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;gBACjC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;YACjC,CAAC,CAAA;SACF,CAAA;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAmB,EAAE,OAAU,IAAyB,CAAC;CAChE;AAjCD,2BAiCC","file":"IStarter.js","sourcesContent":["import { ICommand, IParam } from '@aiot-toolkit/commander'\n\n/**\n * IStarter\n */\nexport default class IStarter<O = any> {\n\n /**\n * start 的参数列表\n */\n readonly params: IParam[] = []\n\n constructor(\n protected name: string,\n protected description: string\n ) { }\n\n /**\n * start 的命令\n */\n getCommond(): ICommand {\n return {\n name: this.name,\n description: this.description,\n paramList: this.params,\n action: async (option) => {\n const projectPath = process.cwd()\n this.start(projectPath, option)\n }\n }\n }\n\n /**\n * 运行项目\n * @param projectPath 项目路径\n * @param options 命令参数\n */\n start(projectPath: string, options: O): void | Promise<void> {}\n}\n"],"sourceRoot":"../../src"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import ParamType from '@aiot-toolkit/commander/lib/interface/IParam';
|
|
2
|
+
import { IStartOptions } from '@aiot-toolkit/emulator';
|
|
3
|
+
import UxBuilder from '../builder/UxBuilder';
|
|
4
|
+
import IStarter from './IStarter';
|
|
5
|
+
declare class UxStarter extends IStarter<IStartOptions> {
|
|
6
|
+
builder: UxBuilder;
|
|
7
|
+
params: ParamType[];
|
|
8
|
+
start(projectPath: string, options: any): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export default UxStarter;
|
|
@@ -0,0 +1,138 @@
|
|
|
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;
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=UxStarter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["starter/UxStarter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gJAEsF;AAEtF,qDAAoF;AACpF,2EAA4E;AAC5E,+FAAsE;AACtE,+CAA0C;AAC1C,4CAAmB;AACnB,gDAAuB;AACvB,4DAAmC;AACnC,qEAA4C;AAC5C,yEAAgD;AAChD,0DAAiC;AAEjC,MAAM,SAAU,SAAQ,kBAAuB;IAA/C;;QACE,YAAO,GAAG,IAAI,mBAAS,EAAE,CAAA;QAEzB,WAAM,GAAgB;YACpB;gBACE,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,+BAA+B;gBAC5C,YAAY,EAAE,KAAK;gBACnB,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,sCAAsC;gBACnD,YAAY,EAAE,KAAK;gBACnB,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,UAAU;gBACvB,YAAY,EAAE,KAAK;gBACnB,IAAI,EAAE,SAAS;aAChB;YACD,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM;SACvB,CAAA;IA8DH,CAAC;IA5DO,KAAK,CAAC,WAAmB,EAAE,OAAY;;YAC3C,MAAM,OAAO,GAAiB,sBAAY,CAAC,UAAU,CAAC,cAAc,EAAE,CAAA;YACtE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACxB,sBAAY,CAA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AAU;gBAC9B,UAAU;gBACV,OAAO;aACR,CAAA;YACD,gBAAgB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;YACpC,SAAS;YACT,iEAAiE;YACjE,6CAA6C;YAC7C,eAAe;YACf,QAAQ;YACR,kBAAkB;YAClB,+BAA+B;YAC/B,mBAAmB;YACnB,iCAAiC;YACjC,iCAAiC;YACjC,UAAU;YACV,QAAQ;YACR,MAAM;YACN,KAAK;YACL,yBAAyB;YACzB,sBAAsB;QACxB,CAAC;KAAA;CACF;AAED,kBAAe,SAAS,CAAA","file":"UxStarter.js","sourcesContent":["import JavascriptDefaultCompileOption, {\n setServerPort\n} from '@aiot-toolkit/aiotpack/lib/compiler/javascript/JavascriptDefaultCompileOption'\nimport ParamType from '@aiot-toolkit/commander/lib/interface/IParam'\nimport { GoldfishInstance, IAvdParams, IStartOptions } from '@aiot-toolkit/emulator'\nimport { defaultVncPort } from '@aiot-toolkit/emulator/lib/static/constants'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport { select } from '@inquirer/prompts'\nimport os from 'os'\nimport path from 'path'\nimport portfinder from 'portfinder'\nimport UxBuilder from '../builder/UxBuilder'\nimport VelaAvdUtils from '../utils/VelaAvdUtils'\nimport IStarter from './IStarter'\n\nclass UxStarter extends IStarter<IStartOptions> {\n builder = new UxBuilder()\n\n params: ParamType[] = [\n {\n name: 'disableNSH',\n description: 'disable goldfish NSH terminal',\n defaultValue: false,\n type: 'confirm'\n },\n {\n name: 'watch',\n description: 'recompile project while file changes',\n defaultValue: false,\n type: 'confirm'\n },\n {\n name: 'openVNC',\n description: 'open vnc',\n defaultValue: false,\n type: 'confirm'\n },\n ...this.builder.params\n ]\n\n async start(projectPath: string, options: any) {\n const avdList: IAvdParams[] = VelaAvdUtils.velaAvdCls.getVelaAvdList()\n if (avdList.length === 0) {\n ColorConsole.error(\n '### goldfish start ### No vela emulator available, please create it first.'\n )\n VelaAvdUtils.createVelaAvdByInquire()\n return\n }\n const avdName = await select({\n message: 'name of the avd to start',\n choices: avdList.map((item) => {\n return { value: item.avdName }\n })\n })\n let serverPort: number | undefined\n // watch模型下开启server\n if (options.watch) {\n serverPort = await portfinder.getPortPromise({\n port: JavascriptDefaultCompileOption.serverPort\n })\n setServerPort(serverPort)\n }\n // build\n await this.builder.build(projectPath, options)\n // start\n const goldfishInstance = new GoldfishInstance({\n sdkHome: path.resolve(os.homedir(), '.export'),\n avdHome: path.resolve(os.homedir(), '.android/avd'),\n projectPath\n })\n let vncPort: number | undefined\n if (options.openVNC) {\n vncPort = await portfinder.getPortPromise({port: defaultVncPort, stopPort: defaultVncPort + 100})\n }\n const startOptions: IStartOptions = {\n avdName,\n devtool: options.devtool,\n disableNSH: options.disableNSH,\n serverPort,\n vncPort,\n }\n goldfishInstance.start(startOptions)\n // waiter\n // const startWaiter: PersistentCommand = new PersistentCommand({\n // description: 'aiot-toolkit start 的常驻命令',\n // options: [\n // {\n // key: '?',\n // description: '显示所有命令',\n // action() {\n // startWaiter.clearLog()\n // startWaiter.describe()\n // }\n // }\n // ]\n // })\n // startWaiter.describe()\n // startWaiter.start()\n }\n}\n\nexport default UxStarter\n"],"sourceRoot":"../../src"}
|
|
@@ -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,18 @@
|
|
|
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;
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=XtsStarter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["starter/XtsStarter.ts"],"names":[],"mappings":";;;;;AACA,uEAA+C;AAC/C,0DAAkC;AAElC,MAAM,UAAW,SAAQ,kBAAQ;IAAjC;;QAEE,YAAO,GAAG,IAAI,oBAAU,EAAE,CAAA;QAE1B,WAAM,GAAgB,EAAE,CAAA;IAG1B,CAAC;IADC,KAAK,CAAC,WAAmB,EAAE,OAAY,IAAG,CAAC;CAC5C;AAED,kBAAe,UAAU,CAAA","file":"XtsStarter.js","sourcesContent":["import ParamType from \"@aiot-toolkit/commander/lib/interface/IParam\";\nimport XtsBuilder from \"../builder/XtsBuilder\";\nimport IStarter from \"./IStarter\";\n\nclass XtsStarter extends IStarter {\n\n builder = new XtsBuilder()\n\n params: ParamType[] = []\n\n start(projectPath: string, options: any) {}\n}\n\nexport default XtsStarter"],"sourceRoot":"../../src"}
|
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', () => {
|