aiot-toolkit 2.0.1-alpha.8 → 2.0.2-dev.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/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.d.ts +2 -1
- package/lib/builder/XtsBuilder.js +52 -12
- package/lib/interface/CommandInterface.js +0 -2
- 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 +1 -1
- package/lib/utils/VelaAvdUtils.js +22 -61
- 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
package/lib/bin.js
CHANGED
|
@@ -13,22 +13,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
const CompileMode_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/compiler/enum/CompileMode"));
|
|
16
17
|
const commander_1 = require("@aiot-toolkit/commander");
|
|
17
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
18
18
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
19
|
-
const
|
|
19
|
+
const fs_1 = __importDefault(require("fs"));
|
|
20
|
+
const path_1 = __importDefault(require("path"));
|
|
21
|
+
const UxBuilder_1 = __importDefault(require("./builder/UxBuilder"));
|
|
20
22
|
const XtsBuilder_1 = __importDefault(require("./builder/XtsBuilder"));
|
|
21
|
-
const
|
|
23
|
+
const UxStarter_1 = __importDefault(require("./starter/UxStarter"));
|
|
24
|
+
const XtsStarter_1 = __importDefault(require("./starter/XtsStarter"));
|
|
22
25
|
const DeviceUtil_1 = __importDefault(require("./utils/DeviceUtil"));
|
|
23
26
|
const VelaAvdUtils_1 = __importDefault(require("./utils/VelaAvdUtils"));
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
// 配置支持的 builder 类型,新增的项目类型,需在此处加上类型
|
|
28
|
+
const projectMapper = {
|
|
29
|
+
ux: {
|
|
30
|
+
builder: UxBuilder_1.default,
|
|
31
|
+
starter: UxStarter_1.default
|
|
32
|
+
},
|
|
33
|
+
xts: {
|
|
34
|
+
builder: XtsBuilder_1.default,
|
|
35
|
+
starter: XtsStarter_1.default
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
function findBuilder() {
|
|
39
|
+
const projectType = getProjectType();
|
|
40
|
+
return new projectMapper[projectType].builder();
|
|
28
41
|
}
|
|
29
42
|
function build(command, description) {
|
|
30
|
-
const
|
|
31
|
-
const builder = findBuilder(projectPath);
|
|
43
|
+
const builder = findBuilder();
|
|
32
44
|
const paramList = builder === null || builder === void 0 ? void 0 : builder.params;
|
|
33
45
|
return {
|
|
34
46
|
name: command,
|
|
@@ -36,48 +48,60 @@ function build(command, description) {
|
|
|
36
48
|
paramList,
|
|
37
49
|
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
38
50
|
// 获取对应的 build;如果存在,执行 build 函数,不存在,提示
|
|
51
|
+
option.mode = command === 'release' ? CompileMode_1.default.PRODUCTION : CompileMode_1.default.DEVELOPMENT;
|
|
39
52
|
const projectPath = process.cwd();
|
|
40
|
-
|
|
41
|
-
if (builder) {
|
|
42
|
-
const { watch } = option;
|
|
43
|
-
yield builder.build(projectPath, option);
|
|
44
|
-
if (watch) {
|
|
45
|
-
waiter_1.default.describe();
|
|
46
|
-
waiter_1.default.start();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
ColorConsole_1.default.log({
|
|
51
|
-
message: `This type of project is not currently supported. The supported projects : xts`,
|
|
52
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
53
|
-
isOnlyPrintError: true
|
|
54
|
-
});
|
|
55
|
-
}
|
|
53
|
+
yield builder.build(projectPath, option);
|
|
56
54
|
})
|
|
57
55
|
};
|
|
58
56
|
}
|
|
57
|
+
function getProjectType() {
|
|
58
|
+
const projectPath = process.cwd();
|
|
59
|
+
const isXts = fs_1.default.existsSync(path_1.default.resolve(projectPath, 'app/app.xts'));
|
|
60
|
+
const isUx = fs_1.default.existsSync(path_1.default.resolve(projectPath, 'src/app.ux'));
|
|
61
|
+
if (isUx) {
|
|
62
|
+
return "ux" /* ProjectType.UX */;
|
|
63
|
+
}
|
|
64
|
+
else if (isXts) {
|
|
65
|
+
return "xts" /* ProjectType.XTS */;
|
|
66
|
+
}
|
|
67
|
+
ColorConsole_1.default.throw(`Unsupported project type`);
|
|
68
|
+
}
|
|
69
|
+
function findStarter(command, description) {
|
|
70
|
+
const projectType = getProjectType();
|
|
71
|
+
return new projectMapper[projectType].starter(command, description);
|
|
72
|
+
}
|
|
59
73
|
function main() {
|
|
60
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const aiotCreate = yield (0, create_aiot_1.getAiotCreateCommand)();
|
|
62
75
|
const config = {
|
|
63
76
|
name: 'aiot-toolkit',
|
|
64
77
|
description: 'contains build, dev, release, etc. commands for aiot toolkit',
|
|
65
78
|
version: '2.0.1',
|
|
66
79
|
commandList: [
|
|
67
80
|
build('build', 'build project'),
|
|
68
|
-
|
|
81
|
+
build('release', 'release the project'),
|
|
82
|
+
findStarter('start', 'start project').getCommond(),
|
|
83
|
+
{
|
|
84
|
+
name: 'watch',
|
|
85
|
+
description: 'recompile project while file changes',
|
|
86
|
+
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
const projectPath = process.cwd();
|
|
88
|
+
const builder = findBuilder();
|
|
89
|
+
option.watch = true;
|
|
90
|
+
yield builder.build(projectPath, option);
|
|
91
|
+
// waiter.describe()
|
|
92
|
+
// waiter.start()
|
|
93
|
+
})
|
|
94
|
+
},
|
|
69
95
|
{
|
|
70
96
|
name: 'getConnectedDevices',
|
|
71
97
|
description: 'get all connected devices',
|
|
72
|
-
action: (
|
|
98
|
+
action: () => __awaiter(this, void 0, void 0, function* () {
|
|
73
99
|
try {
|
|
74
100
|
const connectedDevices = yield DeviceUtil_1.default.getAllConnectedDevices();
|
|
75
|
-
ColorConsole_1.default.
|
|
76
|
-
message: `The connected devices are: ${connectedDevices ? connectedDevices.join(', ') : 'null'}`
|
|
77
|
-
});
|
|
101
|
+
ColorConsole_1.default.info(`The connected devices are: ${connectedDevices ? connectedDevices.join(', ') : 'null'}`);
|
|
78
102
|
}
|
|
79
103
|
catch (error) {
|
|
80
|
-
ColorConsole_1.default.
|
|
104
|
+
ColorConsole_1.default.throw(`Error: getConnectedDevices failed`);
|
|
81
105
|
}
|
|
82
106
|
})
|
|
83
107
|
},
|
|
@@ -126,10 +150,10 @@ function main() {
|
|
|
126
150
|
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
127
151
|
try {
|
|
128
152
|
const successMessage = yield DeviceUtil_1.default.installDbgAndMkp(option);
|
|
129
|
-
ColorConsole_1.default.
|
|
153
|
+
ColorConsole_1.default.success(`${successMessage}`);
|
|
130
154
|
}
|
|
131
155
|
catch (error) {
|
|
132
|
-
ColorConsole_1.default.
|
|
156
|
+
ColorConsole_1.default.throw(`installDbgAndMkp failed, errorMessage: ${(error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'}'}`);
|
|
133
157
|
}
|
|
134
158
|
})
|
|
135
159
|
},
|
|
@@ -140,12 +164,30 @@ function main() {
|
|
|
140
164
|
VelaAvdUtils_1.default.createVelaAvdByInquire();
|
|
141
165
|
})
|
|
142
166
|
},
|
|
143
|
-
|
|
167
|
+
{
|
|
168
|
+
name: 'deleteVelaAvd',
|
|
169
|
+
description: 'delete vela avd instance(s)',
|
|
170
|
+
paramList: [
|
|
171
|
+
{
|
|
172
|
+
name: 'avdNames',
|
|
173
|
+
description: 'avd names to delete',
|
|
174
|
+
enableInquirer: true,
|
|
175
|
+
type: 'checkbox',
|
|
176
|
+
choices: VelaAvdUtils_1.default.velaAvdCls.getVelaAvdList().map((item) => {
|
|
177
|
+
return { name: item.avdName, value: item.avdName };
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
const { avdNames } = option;
|
|
183
|
+
avdNames.forEach((avdName) => {
|
|
184
|
+
VelaAvdUtils_1.default.velaAvdCls.deleteVelaAvd(avdName);
|
|
185
|
+
});
|
|
186
|
+
})
|
|
187
|
+
}
|
|
144
188
|
]
|
|
145
189
|
};
|
|
146
190
|
commander_1.Command.registeProgram(config);
|
|
147
191
|
});
|
|
148
192
|
}
|
|
149
193
|
main();
|
|
150
|
-
|
|
151
|
-
//# sourceMappingURL=bin.js.map
|
package/lib/builder/IBuilder.js
CHANGED
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,8 @@ 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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
30
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
19
31
|
const file_lane_1 = require("file-lane");
|
|
20
32
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
21
33
|
const lodash_1 = __importDefault(require("lodash"));
|
|
@@ -43,8 +55,14 @@ class UxBuilder {
|
|
|
43
55
|
type: 'confirm',
|
|
44
56
|
name: 'disabled-jsc',
|
|
45
57
|
description: 'disabled jsc bundle',
|
|
46
|
-
defaultValue:
|
|
58
|
+
defaultValue: false,
|
|
47
59
|
enableInquirer: true
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'enable-protobuf',
|
|
63
|
+
description: 'enable protobuf',
|
|
64
|
+
type: 'confirm',
|
|
65
|
+
defaultValue: false
|
|
48
66
|
}
|
|
49
67
|
];
|
|
50
68
|
}
|
|
@@ -56,24 +74,30 @@ class UxBuilder {
|
|
|
56
74
|
*/
|
|
57
75
|
build(projectPath, options) {
|
|
58
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const
|
|
77
|
+
const watch = options.watch || false;
|
|
60
78
|
// 读取项目中文件的配置
|
|
61
79
|
const quickappConfig = this.readQuickAppConfig(projectPath);
|
|
62
|
-
|
|
80
|
+
const _a = quickappConfig || {}, { cli } = _a, otherConfig = __rest(_a, ["cli"]);
|
|
81
|
+
options = lodash_1.default.merge({}, options, cli);
|
|
63
82
|
// 项目配置
|
|
64
83
|
const uxProjectConfig = new UxConfig_1.default(projectPath);
|
|
65
84
|
// 编译配置
|
|
66
85
|
const compilerOption = lodash_1.default.merge({
|
|
67
86
|
projectPath: path_1.default.join(projectPath, uxProjectConfig.output),
|
|
68
|
-
mode: CompileMode_1.default.DEVELOPMENT,
|
|
69
|
-
disabledJSC: options.disabledJsc
|
|
70
|
-
|
|
71
|
-
|
|
87
|
+
mode: options.mode || CompileMode_1.default.DEVELOPMENT,
|
|
88
|
+
disabledJSC: options.disabledJsc,
|
|
89
|
+
enableProtobuf: options.enableProtobuf
|
|
90
|
+
}, JavascriptDefaultCompileOption_1.default, otherConfig);
|
|
91
|
+
ColorConsole_1.default.info('start build: ', {
|
|
92
|
+
style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Info),
|
|
72
93
|
word: JSON.stringify({
|
|
73
|
-
step: 'build ux',
|
|
74
94
|
projectPath,
|
|
75
95
|
options,
|
|
76
|
-
watch
|
|
96
|
+
watch,
|
|
97
|
+
node: process.version,
|
|
98
|
+
platform: process.platform,
|
|
99
|
+
arch: process.arch,
|
|
100
|
+
toolkit: require('../../package.json').version
|
|
77
101
|
}, null, 2)
|
|
78
102
|
});
|
|
79
103
|
// 开始编译项目
|
|
@@ -84,10 +108,11 @@ class UxBuilder {
|
|
|
84
108
|
const path = path_1.default.join(projectPath, this.QUICKAPP_CONFIG);
|
|
85
109
|
if (fs_extra_1.default.existsSync(path)) {
|
|
86
110
|
try {
|
|
87
|
-
|
|
111
|
+
const data = require(path);
|
|
112
|
+
return data;
|
|
88
113
|
}
|
|
89
114
|
catch (error) {
|
|
90
|
-
|
|
115
|
+
ColorConsole_1.default.throw((error === null || error === void 0 ? void 0 : error.toString()) || '');
|
|
91
116
|
}
|
|
92
117
|
}
|
|
93
118
|
return;
|
|
@@ -98,5 +123,3 @@ class UxBuilder {
|
|
|
98
123
|
}
|
|
99
124
|
UxBuilder.PROJECT_TYPE = 'ux quick app';
|
|
100
125
|
exports.default = UxBuilder;
|
|
101
|
-
|
|
102
|
-
//# sourceMappingURL=UxBuilder.js.map
|
|
@@ -13,9 +13,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const aiotpack_1 = require("@aiot-toolkit/aiotpack");
|
|
16
|
+
const ICompileOptions_1 = require("@aiot-toolkit/aiotpack/lib/interface/ICompileOptions");
|
|
16
17
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
17
18
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
19
|
+
const StringUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/StringUtil"));
|
|
18
20
|
const file_lane_1 = require("file-lane");
|
|
21
|
+
const FileLaneUtil_1 = __importDefault(require("file-lane/lib/utils/FileLaneUtil"));
|
|
19
22
|
const fs_1 = __importDefault(require("fs"));
|
|
20
23
|
const path_1 = __importDefault(require("path"));
|
|
21
24
|
/**
|
|
@@ -23,28 +26,65 @@ const path_1 = __importDefault(require("path"));
|
|
|
23
26
|
*/
|
|
24
27
|
class XtsBuilder {
|
|
25
28
|
constructor() {
|
|
26
|
-
this.params = [
|
|
29
|
+
this.params = [
|
|
30
|
+
{
|
|
31
|
+
name: 'skip',
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: `Can configure skip steps, comma separated, optional values: ${ICompileOptions_1.skipList.join(',')}`,
|
|
34
|
+
validate(value) {
|
|
35
|
+
// TODO: validate 不起作用
|
|
36
|
+
const res = StringUtil_1.default.string2arrayByComma(value);
|
|
37
|
+
const unValid = res.find((r) => {
|
|
38
|
+
return !ICompileOptions_1.skipList.includes(r);
|
|
39
|
+
});
|
|
40
|
+
if (unValid) {
|
|
41
|
+
return `${unValid} is unvalidate, validate value are ${ICompileOptions_1.skipList.join(',')}, Multiple values separated by commas`;
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
];
|
|
27
47
|
}
|
|
28
48
|
match(projectPath) {
|
|
29
49
|
// app/app.xts 存在视为xts项目
|
|
30
50
|
return fs_1.default.existsSync(path_1.default.resolve(projectPath, 'app/app.xts'));
|
|
31
51
|
}
|
|
32
52
|
build(projectPath, options) {
|
|
53
|
+
var _a;
|
|
33
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const
|
|
35
|
-
ColorConsole_1.default.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}, undefined, 2),
|
|
40
|
-
level: shared_utils_1.LOG_LEVEL.Success
|
|
41
|
-
});
|
|
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));
|
|
57
|
+
const compilerOptions = {
|
|
58
|
+
skip: StringUtil_1.default.string2arrayByComma(options.skip)
|
|
59
|
+
};
|
|
42
60
|
const config = new aiotpack_1.XtsConfig();
|
|
43
|
-
|
|
61
|
+
if ((_a = compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('xts2ts')) {
|
|
62
|
+
ColorConsole_1.default.info("### skip compile xts to ts due to --skip ${compilerOptions?.skip.join(',')}");
|
|
63
|
+
const context = FileLaneUtil_1.default.createContext(config.output, projectPath);
|
|
64
|
+
const preWorks = config.preWorks || [];
|
|
65
|
+
for (let item of preWorks) {
|
|
66
|
+
try {
|
|
67
|
+
yield item(context, [], config, compilerOptions);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
// 报错 prework的item error
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const follWorks = config.followWorks || [];
|
|
74
|
+
for (let item of follWorks) {
|
|
75
|
+
try {
|
|
76
|
+
yield item(context, config, compilerOptions);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
// 报错 prework的item error
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return new file_lane_1.FileLane(config, projectPath, compilerOptions).start({ watch });
|
|
85
|
+
}
|
|
44
86
|
});
|
|
45
87
|
}
|
|
46
88
|
}
|
|
47
89
|
XtsBuilder.PROJECT_TYPE = 'xts quick app';
|
|
48
90
|
exports.default = XtsBuilder;
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=XtsBuilder.js.map
|
|
@@ -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,45 @@
|
|
|
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;
|
|
@@ -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,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;
|