aiot-toolkit 2.0.2 → 2.0.3-beta.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/README.md +2 -1
- package/lib/builder/IBuilder.d.ts +6 -0
- package/lib/builder/UxBuilderBase.d.ts +13 -13
- package/lib/builder/UxBuilderBase.js +57 -17
- package/lib/builder/VelaUxBuilder.d.ts +11 -6
- package/lib/builder/XtsBuilder.d.ts +2 -0
- package/lib/builder/XtsBuilder.js +16 -2
- package/lib/index.d.ts +6 -0
- package/lib/index.js +14 -0
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -32,7 +32,6 @@ aiot-toolkit2.0目前支持的打包格式如下:
|
|
|
32
32
|
| 命令 | 说明 |
|
|
33
33
|
| ------------------------ | ------------------------ |
|
|
34
34
|
| npm create aiot | 创建并手动选择项目 |
|
|
35
|
-
| npm create aiot xts | 创建xts项目 |
|
|
36
35
|
| npm create aiot ux | 创建ux项目 |
|
|
37
36
|
| aiot build | 构建项目 |
|
|
38
37
|
| aiot release | 构建项目-release模式 |
|
|
@@ -42,3 +41,5 @@ aiot-toolkit2.0目前支持的打包格式如下:
|
|
|
42
41
|
| aiot installDbgAndMkp | 在真机上安装快应用调试器 |
|
|
43
42
|
| aiot createVelaAvd | 创建 vela 模拟器 |
|
|
44
43
|
| aiot deleteVelaAvd | 删除 vela 模拟器 |
|
|
44
|
+
|
|
45
|
+
## 函数调用
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import { IJavascriptCompileOption } from '@aiot-toolkit/aiotpack';
|
|
2
|
-
import {
|
|
1
|
+
import { CompileMode, IJavascriptCompileOption } from '@aiot-toolkit/aiotpack';
|
|
2
|
+
import IFileLaneEvents, { IFileLaneSuccessData } from 'file-lane/lib/interface/IFileLaneEvents';
|
|
3
|
+
export interface IUxBuildOption {
|
|
4
|
+
watch?: boolean;
|
|
5
|
+
mode: CompileMode;
|
|
6
|
+
}
|
|
3
7
|
/**
|
|
4
8
|
* UxBuilderBase
|
|
5
9
|
*/
|
|
6
|
-
declare class UxBuilderBase<O extends
|
|
7
|
-
events:
|
|
8
|
-
onBuildSuccess?: (data: {
|
|
9
|
-
costTime: number;
|
|
10
|
-
}) => void;
|
|
11
|
-
};
|
|
10
|
+
declare class UxBuilderBase<O extends IUxBuildOption = IUxBuildOption> {
|
|
11
|
+
events: IFileLaneEvents;
|
|
12
12
|
/**
|
|
13
13
|
* 配置文件
|
|
14
14
|
*/
|
|
15
15
|
readonly QUICKAPP_CONFIG = "quickapp.config.js";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
costTime: number;
|
|
19
|
-
}) => void;
|
|
20
|
-
});
|
|
16
|
+
private fileLane?;
|
|
17
|
+
constructor(events?: IFileLaneEvents);
|
|
21
18
|
/**
|
|
22
19
|
* ux项目的build函数
|
|
23
20
|
* @param projectPath 项目路径
|
|
@@ -25,6 +22,8 @@ declare class UxBuilderBase<O extends Dictionary = any> {
|
|
|
25
22
|
* @param watch 是否开启监听
|
|
26
23
|
*/
|
|
27
24
|
build(projectPath: string, options: O): Promise<void>;
|
|
25
|
+
private handleLogs;
|
|
26
|
+
dispose(): Promise<void>;
|
|
28
27
|
/**
|
|
29
28
|
* 获取build的编译配置
|
|
30
29
|
* @param projectPath 项目路径
|
|
@@ -34,3 +33,4 @@ declare class UxBuilderBase<O extends Dictionary = any> {
|
|
|
34
33
|
private readQuickAppConfig;
|
|
35
34
|
}
|
|
36
35
|
export default UxBuilderBase;
|
|
36
|
+
export { IFileLaneEvents, IFileLaneSuccessData };
|
|
@@ -34,7 +34,9 @@ const file_lane_1 = __importDefault(require("file-lane"));
|
|
|
34
34
|
*/
|
|
35
35
|
class UxBuilderBase {
|
|
36
36
|
constructor(events = {
|
|
37
|
-
onBuildSuccess: (data) => shared_utils_1.ColorConsole.
|
|
37
|
+
onBuildSuccess: (data) => shared_utils_1.ColorConsole.success({
|
|
38
|
+
word: 'build success:'
|
|
39
|
+
}, `${data.costTime}ms`)
|
|
38
40
|
}) {
|
|
39
41
|
this.events = events;
|
|
40
42
|
/**
|
|
@@ -50,25 +52,54 @@ class UxBuilderBase {
|
|
|
50
52
|
*/
|
|
51
53
|
build(projectPath, options) {
|
|
52
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
if (this.fileLane) {
|
|
56
|
+
// 已经在运行中,请先停止
|
|
57
|
+
throw new Error('already running, please stop first: builder.stop()');
|
|
58
|
+
}
|
|
53
59
|
const watch = options.watch || false;
|
|
54
60
|
// 项目配置
|
|
55
61
|
const uxProjectConfig = new aiotpack_1.UxConfig(projectPath);
|
|
56
62
|
// 编译配置
|
|
57
63
|
const compilerOption = this.getCompilerOption(projectPath, options);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
const log = {
|
|
65
|
+
level: shared_utils_1.Loglevel.INFO,
|
|
66
|
+
message: [
|
|
67
|
+
'start build: ',
|
|
68
|
+
{
|
|
69
|
+
word: JSON.stringify({
|
|
70
|
+
projectPath,
|
|
71
|
+
options,
|
|
72
|
+
watch,
|
|
73
|
+
node: process.version,
|
|
74
|
+
platform: process.platform,
|
|
75
|
+
arch: process.arch,
|
|
76
|
+
toolkit: require('../../package.json').version
|
|
77
|
+
}, null, 2)
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
};
|
|
81
|
+
this.handleLogs([log]);
|
|
70
82
|
// 开始编译项目
|
|
71
|
-
|
|
83
|
+
this.fileLane = new file_lane_1.default(uxProjectConfig, projectPath, compilerOption, this.events);
|
|
84
|
+
yield this.fileLane.start({ watch });
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
handleLogs(logs) {
|
|
88
|
+
const { onLog } = this.events;
|
|
89
|
+
if (onLog) {
|
|
90
|
+
onLog(logs);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
logs.forEach((log) => {
|
|
94
|
+
shared_utils_1.ColorConsole.logger(log);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
dispose() {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
var _a;
|
|
101
|
+
yield ((_a = this.fileLane) === null || _a === void 0 ? void 0 : _a.dispose());
|
|
102
|
+
this.fileLane = undefined;
|
|
72
103
|
});
|
|
73
104
|
}
|
|
74
105
|
/**
|
|
@@ -84,8 +115,8 @@ class UxBuilderBase {
|
|
|
84
115
|
// 项目配置
|
|
85
116
|
const uxProjectConfig = new aiotpack_1.UxConfig(projectPath);
|
|
86
117
|
// 编译配置
|
|
87
|
-
const
|
|
88
|
-
const compilerOption = lodash_1.default.merge(aiotpack_1.JavascriptDefaultCompileOption, Object.assign(Object.assign({}, options), { projectPath: path_1.default.join(projectPath, uxProjectConfig.output), mode
|
|
118
|
+
const mode = options.mode || aiotpack_1.CompileMode.DEVELOPMENT;
|
|
119
|
+
const compilerOption = lodash_1.default.merge(aiotpack_1.JavascriptDefaultCompileOption, Object.assign(Object.assign({}, options), { projectPath: path_1.default.join(projectPath, uxProjectConfig.output), mode }), otherConfig);
|
|
89
120
|
return compilerOption;
|
|
90
121
|
}
|
|
91
122
|
readQuickAppConfig(projectPath) {
|
|
@@ -96,7 +127,16 @@ class UxBuilderBase {
|
|
|
96
127
|
return data;
|
|
97
128
|
}
|
|
98
129
|
catch (error) {
|
|
99
|
-
|
|
130
|
+
const log = {
|
|
131
|
+
level: shared_utils_1.Loglevel.ERROR,
|
|
132
|
+
message: [
|
|
133
|
+
'read quickapp.config.js error: ',
|
|
134
|
+
{
|
|
135
|
+
word: (error === null || error === void 0 ? void 0 : error.toString()) || ''
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
};
|
|
139
|
+
this.handleLogs([log]);
|
|
100
140
|
}
|
|
101
141
|
}
|
|
102
142
|
return;
|
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
import { CompileMode } from '@aiot-toolkit/aiotpack';
|
|
2
1
|
import { IParam } from '@aiot-toolkit/commander';
|
|
3
|
-
import { Dictionary } from '@aiot-toolkit/shared-utils';
|
|
4
2
|
import IBuilder from './IBuilder';
|
|
5
|
-
import UxBuilderBase from './UxBuilderBase';
|
|
6
|
-
interface
|
|
3
|
+
import UxBuilderBase, { IUxBuildOption } from './UxBuilderBase';
|
|
4
|
+
interface IVelaUxBuilderOption extends IUxBuildOption {
|
|
7
5
|
watch?: boolean;
|
|
8
|
-
mode: CompileMode;
|
|
9
6
|
enableJsc: boolean;
|
|
10
7
|
enableE2e?: boolean;
|
|
8
|
+
enableStats?: boolean;
|
|
9
|
+
optimizeCssAttr?: boolean;
|
|
11
10
|
/**
|
|
12
11
|
* 是否自动补全 manifest.json 中的 features 配置
|
|
13
12
|
*/
|
|
14
13
|
completeFeature?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 此选项控制是否生成,以及如何生成 source map
|
|
16
|
+
*
|
|
17
|
+
* @see https://www.webpackjs.com/configuration/devtool/#devtool
|
|
18
|
+
*/
|
|
19
|
+
devtool?: string;
|
|
15
20
|
}
|
|
16
21
|
/**
|
|
17
22
|
* VelaUxBuilder
|
|
18
23
|
*/
|
|
19
|
-
declare class VelaUxBuilder extends UxBuilderBase<
|
|
24
|
+
declare class VelaUxBuilder extends UxBuilderBase<IVelaUxBuilderOption> implements IBuilder<IVelaUxBuilderOption> {
|
|
20
25
|
params: IParam[];
|
|
21
26
|
match(projectPath: string): boolean;
|
|
22
27
|
}
|
|
@@ -9,8 +9,10 @@ export interface IBuilderOption {
|
|
|
9
9
|
*/
|
|
10
10
|
declare class XtsBuilder implements IBuilder<IBuilderOption> {
|
|
11
11
|
static readonly PROJECT_TYPE = "xts quick app";
|
|
12
|
+
private fileLane?;
|
|
12
13
|
match(projectPath: string): boolean;
|
|
13
14
|
build(projectPath: string, options: IBuilderOption): Promise<void>;
|
|
15
|
+
dispose(): Promise<void>;
|
|
14
16
|
readonly params: IParam[];
|
|
15
17
|
}
|
|
16
18
|
export default XtsBuilder;
|
|
@@ -49,12 +49,16 @@ class XtsBuilder {
|
|
|
49
49
|
build(projectPath, options) {
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
51
|
var _a;
|
|
52
|
+
if (this.fileLane) {
|
|
53
|
+
// 已经在运行中,请先停止
|
|
54
|
+
throw new Error('already running, please stop first: builder.stop()');
|
|
55
|
+
}
|
|
52
56
|
const watch = options.watch || false;
|
|
53
57
|
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));
|
|
54
58
|
const compilerOptions = {
|
|
55
59
|
skip: shared_utils_1.StringUtil.string2arrayByComma(options.skip)
|
|
56
60
|
};
|
|
57
|
-
const config = new aiotpack_1.XtsConfig();
|
|
61
|
+
const config = new aiotpack_1.XtsConfig(projectPath);
|
|
58
62
|
if ((_a = compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('xts2ts')) {
|
|
59
63
|
shared_utils_1.ColorConsole.info("### skip compile xts to ts due to --skip ${compilerOptions?.skip.join(',')}");
|
|
60
64
|
const context = file_lane_1.FileLaneUtil.createContext(config.output, projectPath);
|
|
@@ -78,10 +82,20 @@ class XtsBuilder {
|
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
84
|
else {
|
|
81
|
-
|
|
85
|
+
this.fileLane = new file_lane_1.FileLane(config, projectPath, compilerOptions);
|
|
86
|
+
this.fileLane.start({
|
|
87
|
+
watch
|
|
88
|
+
});
|
|
82
89
|
}
|
|
83
90
|
});
|
|
84
91
|
}
|
|
92
|
+
dispose() {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
var _a;
|
|
95
|
+
yield ((_a = this.fileLane) === null || _a === void 0 ? void 0 : _a.dispose());
|
|
96
|
+
this.fileLane = undefined;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
85
99
|
}
|
|
86
100
|
XtsBuilder.PROJECT_TYPE = 'xts quick app';
|
|
87
101
|
exports.default = XtsBuilder;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import VelaUxBuilder from './builder/VelaUxBuilder';
|
|
2
|
+
import AndroidUxBuilder from './builder/AndroidUxBuilder';
|
|
3
|
+
import FileLaneTriggerType from 'file-lane/lib/enum/FileLaneTriggerType';
|
|
4
|
+
import { CompileMode } from '@aiot-toolkit/aiotpack';
|
|
5
|
+
import IFileLaneEvents, { IFileLaneSuccessData } from 'file-lane/lib/interface/IFileLaneEvents';
|
|
6
|
+
export { VelaUxBuilder, AndroidUxBuilder, FileLaneTriggerType, CompileMode, IFileLaneEvents, IFileLaneSuccessData };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
exports.CompileMode = exports.FileLaneTriggerType = exports.AndroidUxBuilder = exports.VelaUxBuilder = void 0;
|
|
7
|
+
const VelaUxBuilder_1 = __importDefault(require("./builder/VelaUxBuilder"));
|
|
8
|
+
exports.VelaUxBuilder = VelaUxBuilder_1.default;
|
|
9
|
+
const AndroidUxBuilder_1 = __importDefault(require("./builder/AndroidUxBuilder"));
|
|
10
|
+
exports.AndroidUxBuilder = AndroidUxBuilder_1.default;
|
|
11
|
+
const FileLaneTriggerType_1 = __importDefault(require("file-lane/lib/enum/FileLaneTriggerType"));
|
|
12
|
+
exports.FileLaneTriggerType = FileLaneTriggerType_1.default;
|
|
13
|
+
const aiotpack_1 = require("@aiot-toolkit/aiotpack");
|
|
14
|
+
Object.defineProperty(exports, "CompileMode", { enumerable: true, get: function () { return aiotpack_1.CompileMode; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiot-toolkit",
|
|
3
|
-
"version": "2.0.2",
|
|
3
|
+
"version": "2.0.3-beta.2",
|
|
4
4
|
"description": "Tools for creating, developing, and packaging aiot applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiot"
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"bin": {
|
|
11
11
|
"aiot": "lib/bin.js"
|
|
12
12
|
},
|
|
13
|
+
"main": "lib/index",
|
|
13
14
|
"directories": {
|
|
14
15
|
"lib": "lib",
|
|
15
16
|
"test": "__tests__"
|
|
@@ -21,17 +22,17 @@
|
|
|
21
22
|
"test": "node ./__tests__/aiot-toolkit.test.js"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@aiot-toolkit/aiotpack": "2.0.2",
|
|
25
|
-
"@aiot-toolkit/commander": "2.0.2",
|
|
26
|
-
"@aiot-toolkit/emulator": "2.0.2",
|
|
27
|
-
"@aiot-toolkit/shared-utils": "2.0.2",
|
|
25
|
+
"@aiot-toolkit/aiotpack": "2.0.3-beta.2",
|
|
26
|
+
"@aiot-toolkit/commander": "2.0.3-beta.2",
|
|
27
|
+
"@aiot-toolkit/emulator": "2.0.3-beta.2",
|
|
28
|
+
"@aiot-toolkit/shared-utils": "2.0.3-beta.2",
|
|
28
29
|
"@inquirer/prompts": "^5.3.0",
|
|
29
30
|
"@miwt/adb": "^0.9.0",
|
|
30
31
|
"adm-zip": "^0.5.10",
|
|
31
32
|
"axios": "^1.7.4",
|
|
32
33
|
"cli-progress": "^3.12.0",
|
|
33
34
|
"dayjs": "^1.11.10",
|
|
34
|
-
"file-lane": "2.0.2",
|
|
35
|
+
"file-lane": "2.0.3-beta.2",
|
|
35
36
|
"fs-extra": "^11.2.0",
|
|
36
37
|
"koa-router": "^13.0.1",
|
|
37
38
|
"lodash": "^4.17.21",
|
|
@@ -48,5 +49,5 @@
|
|
|
48
49
|
"@types/semver": "^7.5.8",
|
|
49
50
|
"@types/ws": "^8.5.10"
|
|
50
51
|
},
|
|
51
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "7776973f6a81d7f13eb330be8df5801d9143c83c"
|
|
52
53
|
}
|