aiot-toolkit 2.0.1-alpha.8 → 2.0.2-beta.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 +32 -29
- package/lib/bin.js +95 -41
- package/lib/builder/IBuilder.js +0 -2
- package/lib/builder/UxBuilder.d.ts +1 -0
- package/lib/builder/UxBuilder.js +41 -15
- 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.d.ts +6 -1
- package/lib/interface/VelaEmulatorInterface.js +0 -2
- package/lib/starter/IStarter.d.ts +23 -0
- package/lib/starter/IStarter.js +39 -0
- package/lib/starter/UxStarter.d.ts +10 -0
- package/lib/starter/UxStarter.js +139 -0
- package/lib/starter/XtsStarter.d.ts +9 -0
- package/lib/starter/XtsStarter.js +19 -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/UxBuilderUtils.d.ts +8 -0
- package/lib/utils/UxBuilderUtils.js +51 -0
- package/lib/utils/VelaAvdUtils.d.ts +8 -2
- package/lib/utils/VelaAvdUtils.js +54 -79
- package/lib/waiter.js +0 -2
- package/package.json +13 -11
- 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/README.md
CHANGED
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 项目介绍
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
aiot-toolkit 2.0 是将 **源码项目** 转换为 **目标代码项目** 并生成 **目标代码应用** 的命令行工具,同时配备了 **模拟器** 相关功能供开发者使用。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
aiot-toolkit2.0目前支持的打包格式如下:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- ux:vela 平台下的应用,目前大量使用于小米手表、音箱等智能穿戴及物联网设备
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## 安装使用
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
- 全局安装
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
import ParamType from '@aiot-toolkit/commander/lib/interface/IParam'
|
|
15
|
-
import IBuild from './IBuild'
|
|
13
|
+
`npm i aiot-toolkit -g`
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
params: ParamType[] = []
|
|
19
|
-
build(projectPath: string, options: any): void {
|
|
20
|
-
throw new Error('Method not implemented.')
|
|
21
|
-
}
|
|
22
|
-
match(projectPath: string): boolean {
|
|
23
|
-
throw new Error('Method not implemented.')
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export default XBuilder
|
|
15
|
+
`npm i create-aiot -g`
|
|
27
16
|
|
|
28
|
-
|
|
17
|
+
- 创建项目
|
|
29
18
|
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
1. `create-aiot ux`
|
|
20
|
+
2. 在项目根目录执行:`npm i`
|
|
32
21
|
|
|
33
|
-
|
|
34
|
-
static readonly PROJECT_TYPE = '项目类型的名称'
|
|
35
|
-
```
|
|
22
|
+
- 本机运行项目
|
|
36
23
|
|
|
37
|
-
|
|
24
|
+
在项目根目录执行 `aiot start`,此会启动模拟器,并运行项目
|
|
38
25
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
* 打包项目
|
|
27
|
+
|
|
28
|
+
在项目根目录执行 `aiot release`
|
|
29
|
+
|
|
30
|
+
## 常用命令
|
|
31
|
+
|
|
32
|
+
| 命令 | 说明 |
|
|
33
|
+
| ------------------------ | ------------------------ |
|
|
34
|
+
| npm create aiot | 创建并手动选择项目 |
|
|
35
|
+
| npm create aiot xts | 创建xts项目 |
|
|
36
|
+
| npm create aiot ux | 创建ux项目 |
|
|
37
|
+
| aiot build | 构建项目 |
|
|
38
|
+
| aiot release | 构建项目-release模式 |
|
|
39
|
+
| aiot start | 构建项目并运行到模拟器 |
|
|
40
|
+
| aiot getConnectedDevices | 获取已连接设备列表 |
|
|
41
|
+
| aiot getPlatforms | 获取设置平台 |
|
|
42
|
+
| aiot installDbgAndMkp | 在真机上安装快应用调试器 |
|
|
43
|
+
| aiot createVelaAvd | 创建 vela 模拟器 |
|
|
44
|
+
| aiot deleteVelaAvd | 删除 vela 模拟器 |
|
package/lib/bin.js
CHANGED
|
@@ -13,22 +13,46 @@ 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
|
|
17
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
|
+
const semver_1 = __importDefault(require("semver"));
|
|
18
17
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
19
|
-
|
|
18
|
+
// 支持的最低node版本
|
|
19
|
+
const NODE_MINIMUM_VERSION = '16.0.0';
|
|
20
|
+
checkVersion();
|
|
21
|
+
const CompileMode_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/compiler/enum/CompileMode"));
|
|
22
|
+
const commander_1 = require("@aiot-toolkit/commander");
|
|
23
|
+
const fs_1 = __importDefault(require("fs"));
|
|
24
|
+
const path_1 = __importDefault(require("path"));
|
|
25
|
+
const UxBuilder_1 = __importDefault(require("./builder/UxBuilder"));
|
|
20
26
|
const XtsBuilder_1 = __importDefault(require("./builder/XtsBuilder"));
|
|
21
|
-
const
|
|
27
|
+
const UxStarter_1 = __importDefault(require("./starter/UxStarter"));
|
|
28
|
+
const XtsStarter_1 = __importDefault(require("./starter/XtsStarter"));
|
|
22
29
|
const DeviceUtil_1 = __importDefault(require("./utils/DeviceUtil"));
|
|
23
30
|
const VelaAvdUtils_1 = __importDefault(require("./utils/VelaAvdUtils"));
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
// 校验当前环境中的node
|
|
32
|
+
function checkVersion() {
|
|
33
|
+
const currentVersion = process.versions.node;
|
|
34
|
+
if (semver_1.default.lt(currentVersion, NODE_MINIMUM_VERSION)) {
|
|
35
|
+
ColorConsole_1.default.throw('It is detected that the current NodeJS version ', { word: currentVersion }, ' is too low, please upgrade to NodeJS version higher than ', { word: NODE_MINIMUM_VERSION });
|
|
36
|
+
process.exit();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// 配置支持的 builder 类型,新增的项目类型,需在此处加上类型
|
|
40
|
+
const projectMapper = {
|
|
41
|
+
ux: {
|
|
42
|
+
builder: UxBuilder_1.default,
|
|
43
|
+
starter: UxStarter_1.default
|
|
44
|
+
},
|
|
45
|
+
xts: {
|
|
46
|
+
builder: XtsBuilder_1.default,
|
|
47
|
+
starter: XtsStarter_1.default
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
function findBuilder() {
|
|
51
|
+
const projectType = getProjectType();
|
|
52
|
+
return new projectMapper[projectType].builder();
|
|
28
53
|
}
|
|
29
54
|
function build(command, description) {
|
|
30
|
-
const
|
|
31
|
-
const builder = findBuilder(projectPath);
|
|
55
|
+
const builder = findBuilder();
|
|
32
56
|
const paramList = builder === null || builder === void 0 ? void 0 : builder.params;
|
|
33
57
|
return {
|
|
34
58
|
name: command,
|
|
@@ -36,48 +60,60 @@ function build(command, description) {
|
|
|
36
60
|
paramList,
|
|
37
61
|
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
38
62
|
// 获取对应的 build;如果存在,执行 build 函数,不存在,提示
|
|
63
|
+
option.mode = command === 'release' ? CompileMode_1.default.PRODUCTION : CompileMode_1.default.DEVELOPMENT;
|
|
39
64
|
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
|
-
}
|
|
65
|
+
yield builder.build(projectPath, option);
|
|
56
66
|
})
|
|
57
67
|
};
|
|
58
68
|
}
|
|
69
|
+
function getProjectType() {
|
|
70
|
+
const projectPath = process.cwd();
|
|
71
|
+
const isXts = fs_1.default.existsSync(path_1.default.resolve(projectPath, 'app/app.xts'));
|
|
72
|
+
const isUx = fs_1.default.existsSync(path_1.default.resolve(projectPath, 'src/app.ux'));
|
|
73
|
+
if (isUx) {
|
|
74
|
+
return "ux" /* ProjectType.UX */;
|
|
75
|
+
}
|
|
76
|
+
else if (isXts) {
|
|
77
|
+
return "xts" /* ProjectType.XTS */;
|
|
78
|
+
}
|
|
79
|
+
return "ux" /* ProjectType.UX */;
|
|
80
|
+
}
|
|
81
|
+
function findStarter(command, description) {
|
|
82
|
+
const projectType = getProjectType();
|
|
83
|
+
return new projectMapper[projectType].starter(command, description);
|
|
84
|
+
}
|
|
59
85
|
function main() {
|
|
60
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const aiotCreate = yield (0, create_aiot_1.getAiotCreateCommand)();
|
|
62
87
|
const config = {
|
|
63
88
|
name: 'aiot-toolkit',
|
|
64
89
|
description: 'contains build, dev, release, etc. commands for aiot toolkit',
|
|
65
|
-
version: '
|
|
90
|
+
version: require('../package.json').version,
|
|
66
91
|
commandList: [
|
|
67
92
|
build('build', 'build project'),
|
|
68
|
-
|
|
93
|
+
build('release', 'release the project'),
|
|
94
|
+
findStarter('start', 'start project').getCommond(),
|
|
95
|
+
{
|
|
96
|
+
name: 'watch',
|
|
97
|
+
description: 'recompile project while file changes',
|
|
98
|
+
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const projectPath = process.cwd();
|
|
100
|
+
const builder = findBuilder();
|
|
101
|
+
option.watch = true;
|
|
102
|
+
yield builder.build(projectPath, option);
|
|
103
|
+
// waiter.describe()
|
|
104
|
+
// waiter.start()
|
|
105
|
+
})
|
|
106
|
+
},
|
|
69
107
|
{
|
|
70
108
|
name: 'getConnectedDevices',
|
|
71
109
|
description: 'get all connected devices',
|
|
72
|
-
action: (
|
|
110
|
+
action: () => __awaiter(this, void 0, void 0, function* () {
|
|
73
111
|
try {
|
|
74
112
|
const connectedDevices = yield DeviceUtil_1.default.getAllConnectedDevices();
|
|
75
|
-
ColorConsole_1.default.
|
|
76
|
-
message: `The connected devices are: ${connectedDevices ? connectedDevices.join(', ') : 'null'}`
|
|
77
|
-
});
|
|
113
|
+
ColorConsole_1.default.info(`The connected devices are: ${connectedDevices ? connectedDevices.join(', ') : 'null'}`);
|
|
78
114
|
}
|
|
79
115
|
catch (error) {
|
|
80
|
-
ColorConsole_1.default.
|
|
116
|
+
ColorConsole_1.default.throw(`Error: getConnectedDevices failed`);
|
|
81
117
|
}
|
|
82
118
|
})
|
|
83
119
|
},
|
|
@@ -126,26 +162,44 @@ function main() {
|
|
|
126
162
|
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
127
163
|
try {
|
|
128
164
|
const successMessage = yield DeviceUtil_1.default.installDbgAndMkp(option);
|
|
129
|
-
ColorConsole_1.default.
|
|
165
|
+
ColorConsole_1.default.success(`${successMessage}`);
|
|
130
166
|
}
|
|
131
167
|
catch (error) {
|
|
132
|
-
ColorConsole_1.default.
|
|
168
|
+
ColorConsole_1.default.throw(`installDbgAndMkp failed, errorMessage: ${(error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'}'}`);
|
|
133
169
|
}
|
|
134
170
|
})
|
|
135
171
|
},
|
|
136
172
|
{
|
|
137
|
-
name: '
|
|
138
|
-
description: 'create a vela
|
|
173
|
+
name: 'createVVD',
|
|
174
|
+
description: 'create a vela virtual device',
|
|
139
175
|
action: () => __awaiter(this, void 0, void 0, function* () {
|
|
140
176
|
VelaAvdUtils_1.default.createVelaAvdByInquire();
|
|
141
177
|
})
|
|
142
178
|
},
|
|
143
|
-
|
|
179
|
+
{
|
|
180
|
+
name: 'deleteVVD',
|
|
181
|
+
description: 'delete vela virtual device(s)',
|
|
182
|
+
paramList: [
|
|
183
|
+
{
|
|
184
|
+
name: 'avdNames',
|
|
185
|
+
description: 'avd names to delete',
|
|
186
|
+
enableInquirer: true,
|
|
187
|
+
type: 'checkbox',
|
|
188
|
+
choices: VelaAvdUtils_1.default.velaAvdCls.getVelaAvdList().map((item) => {
|
|
189
|
+
return { name: item.avdName, value: item.avdName };
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
const { avdNames } = option;
|
|
195
|
+
avdNames.forEach((avdName) => {
|
|
196
|
+
VelaAvdUtils_1.default.velaAvdCls.deleteVelaAvd(avdName);
|
|
197
|
+
});
|
|
198
|
+
})
|
|
199
|
+
}
|
|
144
200
|
]
|
|
145
201
|
};
|
|
146
202
|
commander_1.Command.registeProgram(config);
|
|
147
203
|
});
|
|
148
204
|
}
|
|
149
205
|
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,11 +26,13 @@ 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"));
|
|
22
34
|
const path_1 = __importDefault(require("path"));
|
|
35
|
+
const UxBuilderUtils_1 = __importDefault(require("../utils/UxBuilderUtils"));
|
|
23
36
|
/**
|
|
24
37
|
* UxBuilder
|
|
25
38
|
*/
|
|
@@ -32,6 +45,7 @@ class UxBuilder {
|
|
|
32
45
|
description: 'inject test-suite for current project'
|
|
33
46
|
},
|
|
34
47
|
{
|
|
48
|
+
type: 'string',
|
|
35
49
|
name: 'devtool',
|
|
36
50
|
description: 'source map config'
|
|
37
51
|
},
|
|
@@ -43,8 +57,13 @@ class UxBuilder {
|
|
|
43
57
|
type: 'confirm',
|
|
44
58
|
name: 'disabled-jsc',
|
|
45
59
|
description: 'disabled jsc bundle',
|
|
46
|
-
defaultValue:
|
|
47
|
-
|
|
60
|
+
defaultValue: false
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'enable-protobuf',
|
|
64
|
+
description: 'enable protobuf',
|
|
65
|
+
type: 'confirm',
|
|
66
|
+
defaultValue: false
|
|
48
67
|
}
|
|
49
68
|
];
|
|
50
69
|
}
|
|
@@ -56,24 +75,32 @@ class UxBuilder {
|
|
|
56
75
|
*/
|
|
57
76
|
build(projectPath, options) {
|
|
58
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const
|
|
78
|
+
const watch = options.watch || false;
|
|
60
79
|
// 读取项目中文件的配置
|
|
61
80
|
const quickappConfig = this.readQuickAppConfig(projectPath);
|
|
62
|
-
|
|
81
|
+
const _a = quickappConfig || {}, { cli } = _a, otherConfig = __rest(_a, ["cli"]);
|
|
82
|
+
options = lodash_1.default.merge({}, options, cli);
|
|
63
83
|
// 项目配置
|
|
64
84
|
const uxProjectConfig = new UxConfig_1.default(projectPath);
|
|
65
85
|
// 编译配置
|
|
86
|
+
const compileMode = options.mode || CompileMode_1.default.DEVELOPMENT;
|
|
66
87
|
const compilerOption = lodash_1.default.merge({
|
|
67
88
|
projectPath: path_1.default.join(projectPath, uxProjectConfig.output),
|
|
68
|
-
mode:
|
|
69
|
-
disabledJSC: options.disabledJsc
|
|
70
|
-
|
|
71
|
-
|
|
89
|
+
mode: compileMode,
|
|
90
|
+
disabledJSC: options.disabledJsc,
|
|
91
|
+
enableProtobuf: options.enableProtobuf,
|
|
92
|
+
devtool: UxBuilderUtils_1.default.getDevtoolValue(compileMode, options.devtool)
|
|
93
|
+
}, JavascriptDefaultCompileOption_1.default, otherConfig);
|
|
94
|
+
ColorConsole_1.default.info('start build: ', {
|
|
95
|
+
style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Info),
|
|
72
96
|
word: JSON.stringify({
|
|
73
|
-
step: 'build ux',
|
|
74
97
|
projectPath,
|
|
75
98
|
options,
|
|
76
|
-
watch
|
|
99
|
+
watch,
|
|
100
|
+
node: process.version,
|
|
101
|
+
platform: process.platform,
|
|
102
|
+
arch: process.arch,
|
|
103
|
+
toolkit: require('../../package.json').version
|
|
77
104
|
}, null, 2)
|
|
78
105
|
});
|
|
79
106
|
// 开始编译项目
|
|
@@ -84,10 +111,11 @@ class UxBuilder {
|
|
|
84
111
|
const path = path_1.default.join(projectPath, this.QUICKAPP_CONFIG);
|
|
85
112
|
if (fs_extra_1.default.existsSync(path)) {
|
|
86
113
|
try {
|
|
87
|
-
|
|
114
|
+
const data = require(path);
|
|
115
|
+
return data;
|
|
88
116
|
}
|
|
89
117
|
catch (error) {
|
|
90
|
-
|
|
118
|
+
ColorConsole_1.default.throw((error === null || error === void 0 ? void 0 : error.toString()) || '');
|
|
91
119
|
}
|
|
92
120
|
}
|
|
93
121
|
return;
|
|
@@ -98,5 +126,3 @@ class UxBuilder {
|
|
|
98
126
|
}
|
|
99
127
|
UxBuilder.PROJECT_TYPE = 'ux quick app';
|
|
100
128
|
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
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
export interface ISystemImagesVersionInfo {
|
|
2
|
+
release: string;
|
|
3
|
+
dev: string;
|
|
4
|
+
}
|
|
5
|
+
export type ISystemImagesType = keyof ISystemImagesVersionInfo;
|
|
1
6
|
export interface IGoldfishVersionInfo {
|
|
2
7
|
name: string;
|
|
3
8
|
emulator: string;
|
|
4
|
-
'system-images':
|
|
9
|
+
'system-images': ISystemImagesVersionInfo;
|
|
5
10
|
qa: string;
|
|
6
11
|
skins: string;
|
|
7
12
|
tools: string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ICommand, IParam } from '@aiot-toolkit/commander';
|
|
2
|
+
/**
|
|
3
|
+
* IStarter
|
|
4
|
+
*/
|
|
5
|
+
export default abstract 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
|
+
abstract start(projectPath: string, options: O): void | Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
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;
|