aiot-toolkit 2.0.3-beta.1 → 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 -0
- package/lib/builder/IBuilder.d.ts +6 -0
- package/lib/builder/UxBuilderBase.d.ts +8 -7
- package/lib/builder/UxBuilderBase.js +46 -21
- package/lib/builder/VelaUxBuilder.d.ts +9 -10
- package/lib/builder/XtsBuilder.d.ts +2 -0
- package/lib/builder/XtsBuilder.js +15 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { IJavascriptCompileOption } from '@aiot-toolkit/aiotpack';
|
|
2
|
-
import { Dictionary } from '@aiot-toolkit/shared-utils';
|
|
1
|
+
import { CompileMode, IJavascriptCompileOption } from '@aiot-toolkit/aiotpack';
|
|
3
2
|
import IFileLaneEvents, { IFileLaneSuccessData } from 'file-lane/lib/interface/IFileLaneEvents';
|
|
3
|
+
export interface IUxBuildOption {
|
|
4
|
+
watch?: boolean;
|
|
5
|
+
mode: CompileMode;
|
|
6
|
+
}
|
|
4
7
|
/**
|
|
5
8
|
* UxBuilderBase
|
|
6
9
|
*/
|
|
7
|
-
declare class UxBuilderBase<O extends
|
|
10
|
+
declare class UxBuilderBase<O extends IUxBuildOption = IUxBuildOption> {
|
|
8
11
|
events: IFileLaneEvents;
|
|
9
12
|
/**
|
|
10
13
|
* 配置文件
|
|
@@ -19,10 +22,8 @@ declare class UxBuilderBase<O extends Dictionary = any> {
|
|
|
19
22
|
* @param watch 是否开启监听
|
|
20
23
|
*/
|
|
21
24
|
build(projectPath: string, options: O): Promise<void>;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
stop(): Promise<void>;
|
|
25
|
+
private handleLogs;
|
|
26
|
+
dispose(): Promise<void>;
|
|
26
27
|
/**
|
|
27
28
|
* 获取build的编译配置
|
|
28
29
|
* @param projectPath 项目路径
|
|
@@ -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
|
/**
|
|
@@ -59,30 +61,44 @@ class UxBuilderBase {
|
|
|
59
61
|
const uxProjectConfig = new aiotpack_1.UxConfig(projectPath);
|
|
60
62
|
// 编译配置
|
|
61
63
|
const compilerOption = this.getCompilerOption(projectPath, options);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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]);
|
|
74
82
|
// 开始编译项目
|
|
75
83
|
this.fileLane = new file_lane_1.default(uxProjectConfig, projectPath, compilerOption, this.events);
|
|
76
84
|
yield this.fileLane.start({ watch });
|
|
77
85
|
});
|
|
78
86
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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() {
|
|
83
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
100
|
var _a;
|
|
85
|
-
yield ((_a = this.fileLane) === null || _a === void 0 ? void 0 : _a.
|
|
101
|
+
yield ((_a = this.fileLane) === null || _a === void 0 ? void 0 : _a.dispose());
|
|
86
102
|
this.fileLane = undefined;
|
|
87
103
|
});
|
|
88
104
|
}
|
|
@@ -99,8 +115,8 @@ class UxBuilderBase {
|
|
|
99
115
|
// 项目配置
|
|
100
116
|
const uxProjectConfig = new aiotpack_1.UxConfig(projectPath);
|
|
101
117
|
// 编译配置
|
|
102
|
-
const
|
|
103
|
-
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);
|
|
104
120
|
return compilerOption;
|
|
105
121
|
}
|
|
106
122
|
readQuickAppConfig(projectPath) {
|
|
@@ -111,7 +127,16 @@ class UxBuilderBase {
|
|
|
111
127
|
return data;
|
|
112
128
|
}
|
|
113
129
|
catch (error) {
|
|
114
|
-
|
|
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]);
|
|
115
140
|
}
|
|
116
141
|
}
|
|
117
142
|
return;
|
|
@@ -1,28 +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;
|
|
10
|
+
/**
|
|
11
|
+
* 是否自动补全 manifest.json 中的 features 配置
|
|
12
|
+
*/
|
|
13
|
+
completeFeature?: boolean;
|
|
11
14
|
/**
|
|
12
15
|
* 此选项控制是否生成,以及如何生成 source map
|
|
13
16
|
*
|
|
14
17
|
* @see https://www.webpackjs.com/configuration/devtool/#devtool
|
|
15
18
|
*/
|
|
16
19
|
devtool?: string;
|
|
17
|
-
/**
|
|
18
|
-
* 是否自动补全 manifest.json 中的 features 配置
|
|
19
|
-
*/
|
|
20
|
-
completeFeature?: boolean;
|
|
21
20
|
}
|
|
22
21
|
/**
|
|
23
22
|
* VelaUxBuilder
|
|
24
23
|
*/
|
|
25
|
-
declare class VelaUxBuilder extends UxBuilderBase<
|
|
24
|
+
declare class VelaUxBuilder extends UxBuilderBase<IVelaUxBuilderOption> implements IBuilder<IVelaUxBuilderOption> {
|
|
26
25
|
params: IParam[];
|
|
27
26
|
match(projectPath: string): boolean;
|
|
28
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,6 +49,10 @@ 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 = {
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiot-toolkit",
|
|
3
|
-
"version": "2.0.3-beta.
|
|
3
|
+
"version": "2.0.3-beta.2",
|
|
4
4
|
"description": "Tools for creating, developing, and packaging aiot applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiot"
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"test": "node ./__tests__/aiot-toolkit.test.js"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@aiot-toolkit/aiotpack": "2.0.3-beta.
|
|
26
|
-
"@aiot-toolkit/commander": "2.0.3-beta.
|
|
27
|
-
"@aiot-toolkit/emulator": "2.0.3-beta.
|
|
28
|
-
"@aiot-toolkit/shared-utils": "2.0.3-beta.
|
|
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",
|
|
29
29
|
"@inquirer/prompts": "^5.3.0",
|
|
30
30
|
"@miwt/adb": "^0.9.0",
|
|
31
31
|
"adm-zip": "^0.5.10",
|
|
32
32
|
"axios": "^1.7.4",
|
|
33
33
|
"cli-progress": "^3.12.0",
|
|
34
34
|
"dayjs": "^1.11.10",
|
|
35
|
-
"file-lane": "2.0.3-beta.
|
|
35
|
+
"file-lane": "2.0.3-beta.2",
|
|
36
36
|
"fs-extra": "^11.2.0",
|
|
37
37
|
"koa-router": "^13.0.1",
|
|
38
38
|
"lodash": "^4.17.21",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"@types/semver": "^7.5.8",
|
|
50
50
|
"@types/ws": "^8.5.10"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "7776973f6a81d7f13eb330be8df5801d9143c83c"
|
|
53
53
|
}
|