aiot-toolkit 2.0.2-dev.8 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bin.js +43 -46
- package/lib/builder/AndroidUxBuilder.d.ts +10 -0
- package/lib/builder/AndroidUxBuilder.js +20 -0
- package/lib/builder/UxBuilderBase.d.ts +36 -0
- package/lib/builder/UxBuilderBase.js +105 -0
- package/lib/builder/VelaUxBuilder.d.ts +23 -0
- package/lib/builder/VelaUxBuilder.js +66 -0
- package/lib/builder/XtsBuilder.js +14 -17
- package/lib/interface/VelaEmulatorInterface.d.ts +7 -6
- package/lib/starter/AndroidUxStart.d.ts +40 -0
- package/lib/starter/AndroidUxStart.js +171 -0
- package/lib/starter/IStarter.d.ts +2 -1
- package/lib/starter/IStarter.js +5 -1
- package/lib/starter/VelaUxStarter.d.ts +23 -0
- package/lib/starter/VelaUxStarter.js +198 -0
- package/lib/starter/XtsStarter.d.ts +2 -2
- package/lib/starter/androidRouter/LinkMode.d.ts +9 -0
- package/lib/starter/androidRouter/LinkMode.js +12 -0
- package/lib/starter/androidRouter/PackageRouter.d.ts +55 -0
- package/lib/starter/androidRouter/PackageRouter.js +152 -0
- package/lib/starter/androidRouter/h5/index.css +167 -0
- package/lib/starter/androidRouter/h5/index.html +58 -0
- package/lib/starter/androidRouter/h5/index.js +66 -0
- package/lib/utils/AdbUtils.d.ts +0 -1
- package/lib/utils/AdbUtils.js +3 -14
- package/lib/utils/DeviceUtil.js +42 -29
- package/lib/utils/RequestUtils.js +5 -5
- package/lib/utils/VelaAvdUtils.d.ts +25 -9
- package/lib/utils/VelaAvdUtils.js +262 -100
- package/package.json +20 -12
- package/lib/builder/UxBuilder.d.ts +0 -27
- package/lib/builder/UxBuilder.js +0 -128
- package/lib/starter/UxStarter.d.ts +0 -10
- package/lib/starter/UxStarter.js +0 -139
- package/lib/utils/UxBuilderUtils.d.ts +0 -8
- package/lib/utils/UxBuilderUtils.js +0 -51
package/lib/bin.js
CHANGED
|
@@ -13,18 +13,19 @@ 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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
17
|
const semver_1 = __importDefault(require("semver"));
|
|
17
|
-
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
18
18
|
// 支持的最低node版本
|
|
19
|
-
const NODE_MINIMUM_VERSION = '
|
|
19
|
+
const NODE_MINIMUM_VERSION = '18.0.0';
|
|
20
20
|
checkVersion();
|
|
21
|
-
const
|
|
21
|
+
const aiotpack_1 = require("@aiot-toolkit/aiotpack");
|
|
22
22
|
const commander_1 = require("@aiot-toolkit/commander");
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
23
|
+
const shared_utils_2 = require("@aiot-toolkit/shared-utils");
|
|
24
|
+
const AndroidUxBuilder_1 = __importDefault(require("./builder/AndroidUxBuilder"));
|
|
25
|
+
const VelaUxBuilder_1 = __importDefault(require("./builder/VelaUxBuilder"));
|
|
26
26
|
const XtsBuilder_1 = __importDefault(require("./builder/XtsBuilder"));
|
|
27
|
-
const
|
|
27
|
+
const AndroidUxStart_1 = __importDefault(require("./starter/AndroidUxStart"));
|
|
28
|
+
const VelaUxStarter_1 = __importDefault(require("./starter/VelaUxStarter"));
|
|
28
29
|
const XtsStarter_1 = __importDefault(require("./starter/XtsStarter"));
|
|
29
30
|
const DeviceUtil_1 = __importDefault(require("./utils/DeviceUtil"));
|
|
30
31
|
const VelaAvdUtils_1 = __importDefault(require("./utils/VelaAvdUtils"));
|
|
@@ -32,23 +33,27 @@ const VelaAvdUtils_1 = __importDefault(require("./utils/VelaAvdUtils"));
|
|
|
32
33
|
function checkVersion() {
|
|
33
34
|
const currentVersion = process.versions.node;
|
|
34
35
|
if (semver_1.default.lt(currentVersion, NODE_MINIMUM_VERSION)) {
|
|
35
|
-
|
|
36
|
+
shared_utils_1.ColorConsole.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
37
|
process.exit();
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
// 配置支持的 builder 类型,新增的项目类型,需在此处加上类型
|
|
40
41
|
const projectMapper = {
|
|
41
|
-
|
|
42
|
-
builder:
|
|
43
|
-
starter:
|
|
42
|
+
[shared_utils_2.ProjectType.VELA_UX]: {
|
|
43
|
+
builder: VelaUxBuilder_1.default,
|
|
44
|
+
starter: VelaUxStarter_1.default
|
|
44
45
|
},
|
|
45
|
-
|
|
46
|
+
[shared_utils_2.ProjectType.VELA_XTS]: {
|
|
46
47
|
builder: XtsBuilder_1.default,
|
|
47
48
|
starter: XtsStarter_1.default
|
|
49
|
+
},
|
|
50
|
+
[shared_utils_2.ProjectType.ANDDROID_UX]: {
|
|
51
|
+
builder: AndroidUxBuilder_1.default,
|
|
52
|
+
starter: AndroidUxStart_1.default
|
|
48
53
|
}
|
|
49
54
|
};
|
|
50
55
|
function findBuilder() {
|
|
51
|
-
const projectType = getProjectType();
|
|
56
|
+
const projectType = shared_utils_2.ProjectType.getProjectType(process.cwd());
|
|
52
57
|
return new projectMapper[projectType].builder();
|
|
53
58
|
}
|
|
54
59
|
function build(command, description) {
|
|
@@ -59,27 +64,22 @@ function build(command, description) {
|
|
|
59
64
|
description,
|
|
60
65
|
paramList,
|
|
61
66
|
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
try {
|
|
68
|
+
// 获取对应的 build;如果存在,执行 build 函数,不存在,提示
|
|
69
|
+
option.mode = command === 'release' ? aiotpack_1.CompileMode.PRODUCTION : aiotpack_1.CompileMode.DEVELOPMENT;
|
|
70
|
+
const projectPath = process.cwd();
|
|
71
|
+
yield builder.build(projectPath, option);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
shared_utils_1.ColorConsole.error('Build Error:', {
|
|
75
|
+
word: (error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'
|
|
76
|
+
});
|
|
77
|
+
}
|
|
66
78
|
})
|
|
67
79
|
};
|
|
68
80
|
}
|
|
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
81
|
function findStarter(command, description) {
|
|
82
|
-
const projectType = getProjectType();
|
|
82
|
+
const projectType = shared_utils_2.ProjectType.getProjectType(process.cwd());
|
|
83
83
|
return new projectMapper[projectType].starter(command, description);
|
|
84
84
|
}
|
|
85
85
|
function main() {
|
|
@@ -92,28 +92,16 @@ function main() {
|
|
|
92
92
|
build('build', 'build project'),
|
|
93
93
|
build('release', 'release the project'),
|
|
94
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
|
-
},
|
|
107
95
|
{
|
|
108
96
|
name: 'getConnectedDevices',
|
|
109
97
|
description: 'get all connected devices',
|
|
110
98
|
action: () => __awaiter(this, void 0, void 0, function* () {
|
|
111
99
|
try {
|
|
112
100
|
const connectedDevices = yield DeviceUtil_1.default.getAllConnectedDevices();
|
|
113
|
-
|
|
101
|
+
shared_utils_1.ColorConsole.info(`The connected devices are: ${connectedDevices ? connectedDevices.join(', ') : 'null'}`);
|
|
114
102
|
}
|
|
115
103
|
catch (error) {
|
|
116
|
-
|
|
104
|
+
shared_utils_1.ColorConsole.throw(`Error: getConnectedDevices failed`);
|
|
117
105
|
}
|
|
118
106
|
})
|
|
119
107
|
},
|
|
@@ -162,10 +150,12 @@ function main() {
|
|
|
162
150
|
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
163
151
|
try {
|
|
164
152
|
const successMessage = yield DeviceUtil_1.default.installDbgAndMkp(option);
|
|
165
|
-
|
|
153
|
+
shared_utils_1.ColorConsole.success(`${successMessage}`);
|
|
166
154
|
}
|
|
167
155
|
catch (error) {
|
|
168
|
-
|
|
156
|
+
shared_utils_1.ColorConsole.throw(`installDbgAndMkp failed, errorMessage:'}`, {
|
|
157
|
+
word: (error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'
|
|
158
|
+
});
|
|
169
159
|
}
|
|
170
160
|
})
|
|
171
161
|
},
|
|
@@ -196,6 +186,13 @@ function main() {
|
|
|
196
186
|
VelaAvdUtils_1.default.velaAvdCls.deleteVelaAvd(avdName);
|
|
197
187
|
});
|
|
198
188
|
})
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: 'initEmulatorEnv',
|
|
192
|
+
description: 'init/reset emulator environment',
|
|
193
|
+
action: () => __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
VelaAvdUtils_1.default.initEmulatorEnv();
|
|
195
|
+
})
|
|
199
196
|
}
|
|
200
197
|
]
|
|
201
198
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IParam } from '@aiot-toolkit/commander';
|
|
2
|
+
import UxBuilderBase from './UxBuilderBase';
|
|
3
|
+
/**
|
|
4
|
+
* AndroidUxBuilder
|
|
5
|
+
*/
|
|
6
|
+
declare class AndroidUxBuilder extends UxBuilderBase {
|
|
7
|
+
params: IParam[];
|
|
8
|
+
match(projectPath: string): boolean;
|
|
9
|
+
}
|
|
10
|
+
export default AndroidUxBuilder;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
7
|
+
const UxBuilderBase_1 = __importDefault(require("./UxBuilderBase"));
|
|
8
|
+
/**
|
|
9
|
+
* AndroidUxBuilder
|
|
10
|
+
*/
|
|
11
|
+
class AndroidUxBuilder extends UxBuilderBase_1.default {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.params = [];
|
|
15
|
+
}
|
|
16
|
+
match(projectPath) {
|
|
17
|
+
return shared_utils_1.ProjectType.getProjectType(projectPath) === shared_utils_1.ProjectType.ANDDROID_UX;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.default = AndroidUxBuilder;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IJavascriptCompileOption } from '@aiot-toolkit/aiotpack';
|
|
2
|
+
import { Dictionary } from '@aiot-toolkit/shared-utils';
|
|
3
|
+
/**
|
|
4
|
+
* UxBuilderBase
|
|
5
|
+
*/
|
|
6
|
+
declare class UxBuilderBase<O extends Dictionary = any> {
|
|
7
|
+
events: {
|
|
8
|
+
onBuildSuccess?: (data: {
|
|
9
|
+
costTime: number;
|
|
10
|
+
}) => void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* 配置文件
|
|
14
|
+
*/
|
|
15
|
+
readonly QUICKAPP_CONFIG = "quickapp.config.js";
|
|
16
|
+
constructor(events?: {
|
|
17
|
+
onBuildSuccess?: (data: {
|
|
18
|
+
costTime: number;
|
|
19
|
+
}) => void;
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* ux项目的build函数
|
|
23
|
+
* @param projectPath 项目路径
|
|
24
|
+
* @param options 命令参数
|
|
25
|
+
* @param watch 是否开启监听
|
|
26
|
+
*/
|
|
27
|
+
build(projectPath: string, options: O): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* 获取build的编译配置
|
|
30
|
+
* @param projectPath 项目路径
|
|
31
|
+
* @param options 命令参数
|
|
32
|
+
*/
|
|
33
|
+
getCompilerOption(projectPath: string, options: O): Partial<IJavascriptCompileOption>;
|
|
34
|
+
private readQuickAppConfig;
|
|
35
|
+
}
|
|
36
|
+
export default UxBuilderBase;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __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
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const aiotpack_1 = require("@aiot-toolkit/aiotpack");
|
|
27
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
28
|
+
const path_1 = __importDefault(require("path"));
|
|
29
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
30
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
31
|
+
const file_lane_1 = __importDefault(require("file-lane"));
|
|
32
|
+
/**
|
|
33
|
+
* UxBuilderBase
|
|
34
|
+
*/
|
|
35
|
+
class UxBuilderBase {
|
|
36
|
+
constructor(events = {
|
|
37
|
+
onBuildSuccess: (data) => shared_utils_1.ColorConsole.info(`build time: ${data.costTime}ms`)
|
|
38
|
+
}) {
|
|
39
|
+
this.events = events;
|
|
40
|
+
/**
|
|
41
|
+
* 配置文件
|
|
42
|
+
*/
|
|
43
|
+
this.QUICKAPP_CONFIG = 'quickapp.config.js';
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* ux项目的build函数
|
|
47
|
+
* @param projectPath 项目路径
|
|
48
|
+
* @param options 命令参数
|
|
49
|
+
* @param watch 是否开启监听
|
|
50
|
+
*/
|
|
51
|
+
build(projectPath, options) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const watch = options.watch || false;
|
|
54
|
+
// 项目配置
|
|
55
|
+
const uxProjectConfig = new aiotpack_1.UxConfig(projectPath);
|
|
56
|
+
// 编译配置
|
|
57
|
+
const compilerOption = this.getCompilerOption(projectPath, options);
|
|
58
|
+
shared_utils_1.ColorConsole.info('start build: ', {
|
|
59
|
+
style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.INFO),
|
|
60
|
+
word: JSON.stringify({
|
|
61
|
+
projectPath,
|
|
62
|
+
options,
|
|
63
|
+
watch,
|
|
64
|
+
node: process.version,
|
|
65
|
+
platform: process.platform,
|
|
66
|
+
arch: process.arch,
|
|
67
|
+
toolkit: require('../../package.json').version
|
|
68
|
+
}, null, 2)
|
|
69
|
+
});
|
|
70
|
+
// 开始编译项目
|
|
71
|
+
yield new file_lane_1.default(uxProjectConfig, projectPath, compilerOption, this.events).start({ watch });
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 获取build的编译配置
|
|
76
|
+
* @param projectPath 项目路径
|
|
77
|
+
* @param options 命令参数
|
|
78
|
+
*/
|
|
79
|
+
getCompilerOption(projectPath, options) {
|
|
80
|
+
// 读取项目中文件的配置
|
|
81
|
+
const quickappConfig = this.readQuickAppConfig(projectPath);
|
|
82
|
+
const _a = quickappConfig || {}, { cli } = _a, otherConfig = __rest(_a, ["cli"]);
|
|
83
|
+
options = lodash_1.default.merge({}, options, cli);
|
|
84
|
+
// 项目配置
|
|
85
|
+
const uxProjectConfig = new aiotpack_1.UxConfig(projectPath);
|
|
86
|
+
// 编译配置
|
|
87
|
+
const compileMode = options.mode || aiotpack_1.CompileMode.DEVELOPMENT;
|
|
88
|
+
const compilerOption = lodash_1.default.merge(aiotpack_1.JavascriptDefaultCompileOption, Object.assign(Object.assign({}, options), { projectPath: path_1.default.join(projectPath, uxProjectConfig.output), mode: compileMode }), otherConfig);
|
|
89
|
+
return compilerOption;
|
|
90
|
+
}
|
|
91
|
+
readQuickAppConfig(projectPath) {
|
|
92
|
+
const path = path_1.default.join(projectPath, this.QUICKAPP_CONFIG);
|
|
93
|
+
if (fs_extra_1.default.existsSync(path)) {
|
|
94
|
+
try {
|
|
95
|
+
const data = require(path);
|
|
96
|
+
return data;
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
shared_utils_1.ColorConsole.throw((error === null || error === void 0 ? void 0 : error.toString()) || '');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.default = UxBuilderBase;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CompileMode } from '@aiot-toolkit/aiotpack';
|
|
2
|
+
import { IParam } from '@aiot-toolkit/commander';
|
|
3
|
+
import { Dictionary } from '@aiot-toolkit/shared-utils';
|
|
4
|
+
import IBuilder from './IBuilder';
|
|
5
|
+
import UxBuilderBase from './UxBuilderBase';
|
|
6
|
+
interface IUxBuilderOption extends Dictionary {
|
|
7
|
+
watch?: boolean;
|
|
8
|
+
mode: CompileMode;
|
|
9
|
+
enableJsc: boolean;
|
|
10
|
+
enableE2e?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* 是否自动补全 manifest.json 中的 features 配置
|
|
13
|
+
*/
|
|
14
|
+
completeFeature?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* VelaUxBuilder
|
|
18
|
+
*/
|
|
19
|
+
declare class VelaUxBuilder extends UxBuilderBase<IUxBuilderOption> implements IBuilder<IUxBuilderOption> {
|
|
20
|
+
params: IParam[];
|
|
21
|
+
match(projectPath: string): boolean;
|
|
22
|
+
}
|
|
23
|
+
export default VelaUxBuilder;
|
|
@@ -0,0 +1,66 @@
|
|
|
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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
7
|
+
const UxBuilderBase_1 = __importDefault(require("./UxBuilderBase"));
|
|
8
|
+
/**
|
|
9
|
+
* VelaUxBuilder
|
|
10
|
+
*/
|
|
11
|
+
class VelaUxBuilder extends UxBuilderBase_1.default {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.params = [
|
|
15
|
+
{
|
|
16
|
+
type: 'string',
|
|
17
|
+
name: 'devtool',
|
|
18
|
+
description: 'source map config'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'disable-subpackages',
|
|
22
|
+
description: 'disable subpackages'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: 'confirm',
|
|
26
|
+
name: 'enable-jsc',
|
|
27
|
+
description: 'enable jsc bundle',
|
|
28
|
+
defaultValue: false
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: 'confirm',
|
|
32
|
+
name: 'enable-protobuf',
|
|
33
|
+
description: 'enable protobuf',
|
|
34
|
+
defaultValue: false
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'confirm',
|
|
38
|
+
name: 'enable-e2e',
|
|
39
|
+
description: 'inject test-suite for current project',
|
|
40
|
+
defaultValue: false
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: 'confirm',
|
|
44
|
+
name: 'enable-stats',
|
|
45
|
+
description: 'analyse time and size of webpack output files',
|
|
46
|
+
defaultValue: false
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: 'confirm',
|
|
50
|
+
name: 'optimize-css-attr',
|
|
51
|
+
description: 'optimize css attr',
|
|
52
|
+
defaultValue: false
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'confirm',
|
|
56
|
+
name: 'complete-feature',
|
|
57
|
+
description: 'auto complete the features are used in the code into the features field of the manifest.json file',
|
|
58
|
+
defaultValue: false
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
match(projectPath) {
|
|
63
|
+
return shared_utils_1.ProjectType.getProjectType(projectPath) === shared_utils_1.ProjectType.VELA_UX;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.default = VelaUxBuilder;
|
|
@@ -13,12 +13,9 @@ 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
|
|
16
|
+
const aiotpack_2 = require("@aiot-toolkit/aiotpack");
|
|
17
17
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
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"));
|
|
20
18
|
const file_lane_1 = require("file-lane");
|
|
21
|
-
const FileLaneUtil_1 = __importDefault(require("file-lane/lib/utils/FileLaneUtil"));
|
|
22
19
|
const fs_1 = __importDefault(require("fs"));
|
|
23
20
|
const path_1 = __importDefault(require("path"));
|
|
24
21
|
/**
|
|
@@ -30,15 +27,15 @@ class XtsBuilder {
|
|
|
30
27
|
{
|
|
31
28
|
name: 'skip',
|
|
32
29
|
type: 'string',
|
|
33
|
-
description: `Can configure skip steps, comma separated, optional values: ${
|
|
30
|
+
description: `Can configure skip steps, comma separated, optional values: ${aiotpack_2.skipList.join(',')}`,
|
|
34
31
|
validate(value) {
|
|
35
32
|
// TODO: validate 不起作用
|
|
36
|
-
const res =
|
|
33
|
+
const res = shared_utils_1.StringUtil.string2arrayByComma(value);
|
|
37
34
|
const unValid = res.find((r) => {
|
|
38
|
-
return !
|
|
35
|
+
return !aiotpack_2.skipList.includes(r);
|
|
39
36
|
});
|
|
40
37
|
if (unValid) {
|
|
41
|
-
return `${unValid} is unvalidate, validate value are ${
|
|
38
|
+
return `${unValid} is unvalidate, validate value are ${aiotpack_2.skipList.join(',')}, Multiple values separated by commas`;
|
|
42
39
|
}
|
|
43
40
|
return true;
|
|
44
41
|
}
|
|
@@ -50,30 +47,30 @@ class XtsBuilder {
|
|
|
50
47
|
return fs_1.default.existsSync(path_1.default.resolve(projectPath, 'app/app.xts'));
|
|
51
48
|
}
|
|
52
49
|
build(projectPath, options) {
|
|
53
|
-
var _a;
|
|
54
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
var _a;
|
|
55
52
|
const watch = options.watch || false;
|
|
56
|
-
|
|
53
|
+
shared_utils_1.ColorConsole.success('Start build...\n', { word: 'ProjectPath: ', style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.SUCCESS) }, projectPath, '\n', { word: 'buildOptions: ', style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.SUCCESS) }, JSON.stringify(options));
|
|
57
54
|
const compilerOptions = {
|
|
58
|
-
skip:
|
|
55
|
+
skip: shared_utils_1.StringUtil.string2arrayByComma(options.skip)
|
|
59
56
|
};
|
|
60
57
|
const config = new aiotpack_1.XtsConfig();
|
|
61
58
|
if ((_a = compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('xts2ts')) {
|
|
62
|
-
|
|
63
|
-
const context =
|
|
64
|
-
const preWorks = config.
|
|
59
|
+
shared_utils_1.ColorConsole.info("### skip compile xts to ts due to --skip ${compilerOptions?.skip.join(',')}");
|
|
60
|
+
const context = file_lane_1.FileLaneUtil.createContext(config.output, projectPath);
|
|
61
|
+
const preWorks = config.beforeCompile || [];
|
|
65
62
|
for (let item of preWorks) {
|
|
66
63
|
try {
|
|
67
|
-
yield item(context,
|
|
64
|
+
yield item({ context, config, compilerOption: compilerOptions });
|
|
68
65
|
}
|
|
69
66
|
catch (error) {
|
|
70
67
|
// 报错 prework的item error
|
|
71
68
|
}
|
|
72
69
|
}
|
|
73
|
-
const follWorks = config.
|
|
70
|
+
const follWorks = config.afterCompile || [];
|
|
74
71
|
for (let item of follWorks) {
|
|
75
72
|
try {
|
|
76
|
-
yield item(context, config, compilerOptions);
|
|
73
|
+
yield item.worker({ context, config, compilerOption: compilerOptions });
|
|
77
74
|
}
|
|
78
75
|
catch (error) {
|
|
79
76
|
// 报错 prework的item error
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export interface ISystemImagesVersionInfo {
|
|
2
|
-
release: string;
|
|
3
|
-
dev: string;
|
|
4
|
-
}
|
|
5
|
-
export type ISystemImagesType = keyof ISystemImagesVersionInfo;
|
|
6
1
|
export interface IGoldfishVersionInfo {
|
|
7
2
|
name: string;
|
|
8
3
|
emulator: string;
|
|
9
|
-
'system-images':
|
|
4
|
+
'system-images': string;
|
|
10
5
|
qa: string;
|
|
11
6
|
skins: string;
|
|
12
7
|
tools: string;
|
|
8
|
+
modem_simulator: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IVelaImageItem {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
time: string | Date;
|
|
13
14
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { IParam, PersistentCommand } from '@aiot-toolkit/commander';
|
|
2
|
+
import IStarter from './IStarter';
|
|
3
|
+
/**
|
|
4
|
+
* AndroidUxStart
|
|
5
|
+
*
|
|
6
|
+
* 1. 启动本机开发者http服务器,并提供二维码,以下载 rpk
|
|
7
|
+
* 2. 打包 rpk,并监听文件变化,重新打包
|
|
8
|
+
*/
|
|
9
|
+
declare class AndroidUxStart extends IStarter {
|
|
10
|
+
private server?;
|
|
11
|
+
private port?;
|
|
12
|
+
private builder;
|
|
13
|
+
private projectPath;
|
|
14
|
+
params: IParam[];
|
|
15
|
+
get waiter(): PersistentCommand;
|
|
16
|
+
/**
|
|
17
|
+
* 启动
|
|
18
|
+
* 1. build 项目
|
|
19
|
+
* 2. build 成功,则创建http服务器
|
|
20
|
+
*/
|
|
21
|
+
start(projectPath: string, options: any): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* 创建服务器
|
|
24
|
+
*
|
|
25
|
+
* 1. 使用 koa 创建服务器
|
|
26
|
+
* 2. 显示服务器地址和二维码
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
private createServer;
|
|
30
|
+
private showAddress;
|
|
31
|
+
private build;
|
|
32
|
+
dispose(): void;
|
|
33
|
+
/**
|
|
34
|
+
* 通知已知的设备,应用有更新
|
|
35
|
+
* @param projectPath
|
|
36
|
+
* @param options
|
|
37
|
+
*/
|
|
38
|
+
private noticeDeviceListUpdate;
|
|
39
|
+
}
|
|
40
|
+
export default AndroidUxStart;
|