aiot-toolkit 2.0.3-beta.6 → 2.0.3-beta.8
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 +158 -184
- package/lib/builder/AndroidUxBuilder.js +14 -15
- package/lib/builder/IBuilder.js +1 -2
- package/lib/builder/UxBuilderBase.js +130 -136
- package/lib/builder/VelaUxBuilder.d.ts +3 -2
- package/lib/builder/VelaUxBuilder.js +65 -75
- package/lib/builder/XtsBuilder.js +85 -92
- package/lib/index.js +48 -13
- package/lib/interface/CommandInterface.js +4 -1
- package/lib/interface/VelaEmulatorInterface.js +4 -1
- package/lib/starter/AndroidUxStart.js +158 -158
- package/lib/starter/IStarter.js +39 -37
- package/lib/starter/VelaUxStarter.d.ts +8 -3
- package/lib/starter/VelaUxStarter.js +155 -196
- package/lib/starter/XtsStarter.js +16 -17
- package/lib/starter/androidRouter/LinkMode.js +12 -8
- package/lib/starter/androidRouter/PackageRouter.js +144 -140
- package/lib/utils/AdbUtils.js +48 -76
- package/lib/utils/DeviceUtil.js +277 -293
- package/lib/utils/RequestUtils.js +54 -68
- package/lib/utils/VelaAvdUtils.d.ts +9 -54
- package/lib/utils/VelaAvdUtils.js +126 -437
- package/lib/waiter.js +35 -35
- package/package.json +9 -15
|
@@ -1,145 +1,139 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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"));
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "IFileLaneEvents", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _IFileLaneEvents.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "IFileLaneSuccessData", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _IFileLaneEvents.IFileLaneSuccessData;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.default = void 0;
|
|
19
|
+
var _aiotpack = require("@aiot-toolkit/aiotpack");
|
|
20
|
+
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
21
|
+
var _path = _interopRequireDefault(require("path"));
|
|
22
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
23
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
24
|
+
var _fileLane = _interopRequireDefault(require("file-lane"));
|
|
25
|
+
var _IFileLaneEvents = _interopRequireWildcard(require("file-lane/lib/interface/IFileLaneEvents"));
|
|
26
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
27
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
28
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
32
29
|
/**
|
|
33
30
|
* UxBuilderBase
|
|
34
31
|
*/
|
|
35
32
|
class UxBuilderBase {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (this.fileLane) {
|
|
56
|
-
// 已经在运行中,请先停止
|
|
57
|
-
throw new Error('already running, please stop first: builder.stop()');
|
|
58
|
-
}
|
|
59
|
-
const watch = options.watch || false;
|
|
60
|
-
// 项目配置
|
|
61
|
-
const uxProjectConfig = new aiotpack_1.UxConfig(projectPath);
|
|
62
|
-
// 编译配置
|
|
63
|
-
const compilerOption = this.getCompilerOption(projectPath, options);
|
|
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]);
|
|
82
|
-
// 开始编译项目
|
|
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
|
-
}
|
|
33
|
+
/**
|
|
34
|
+
* 配置文件
|
|
35
|
+
*/
|
|
36
|
+
QUICKAPP_CONFIG = 'quickapp.config.js';
|
|
37
|
+
constructor() {
|
|
38
|
+
let events = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
39
|
+
this.events = events;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* ux项目的build函数
|
|
44
|
+
* @param projectPath 项目路径
|
|
45
|
+
* @param options 命令参数
|
|
46
|
+
* @param watch 是否开启监听
|
|
47
|
+
*/
|
|
48
|
+
async build(projectPath, options) {
|
|
49
|
+
if (this.fileLane) {
|
|
50
|
+
// 已经在运行中,请先停止
|
|
51
|
+
throw new Error('already running, please stop first: builder.stop()');
|
|
97
52
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
53
|
+
const watch = options.watch || false;
|
|
54
|
+
// 项目配置
|
|
55
|
+
const uxProjectConfig = new _aiotpack.UxConfig(projectPath);
|
|
56
|
+
// 编译配置
|
|
57
|
+
const compilerOption = this.getCompilerOption(projectPath, options);
|
|
58
|
+
const log = {
|
|
59
|
+
level: _sharedUtils.Loglevel.INFO,
|
|
60
|
+
message: ['start build: ', {
|
|
61
|
+
word: JSON.stringify({
|
|
62
|
+
projectPath,
|
|
63
|
+
options,
|
|
64
|
+
watch,
|
|
65
|
+
node: process.version,
|
|
66
|
+
platform: process.platform,
|
|
67
|
+
arch: process.arch,
|
|
68
|
+
toolkit: require('../../package.json').version
|
|
69
|
+
}, null, 2)
|
|
70
|
+
}]
|
|
71
|
+
};
|
|
72
|
+
this.handleLogs([log]);
|
|
73
|
+
// 开始编译项目
|
|
74
|
+
this.fileLane = new _fileLane.default(uxProjectConfig, projectPath, compilerOption, this.events);
|
|
75
|
+
await this.fileLane.start({
|
|
76
|
+
watch
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
handleLogs(logs) {
|
|
80
|
+
const {
|
|
81
|
+
onLog
|
|
82
|
+
} = this.events;
|
|
83
|
+
if (onLog) {
|
|
84
|
+
onLog(logs);
|
|
85
|
+
} else {
|
|
86
|
+
logs.forEach(log => {
|
|
87
|
+
_sharedUtils.ColorConsole.logger(log);
|
|
88
|
+
});
|
|
121
89
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
90
|
+
}
|
|
91
|
+
async dispose() {
|
|
92
|
+
await this.fileLane?.dispose();
|
|
93
|
+
this.fileLane = undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 获取build的编译配置
|
|
98
|
+
* @param projectPath 项目路径
|
|
99
|
+
* @param options 命令参数
|
|
100
|
+
*/
|
|
101
|
+
getCompilerOption(projectPath, options) {
|
|
102
|
+
// 读取项目中文件的配置
|
|
103
|
+
const quickappConfig = this.readQuickAppConfig(projectPath);
|
|
104
|
+
const {
|
|
105
|
+
cli,
|
|
106
|
+
...otherConfig
|
|
107
|
+
} = quickappConfig || {};
|
|
108
|
+
options = _lodash.default.merge({}, options, cli);
|
|
109
|
+
// 项目配置
|
|
110
|
+
const uxProjectConfig = new _aiotpack.UxConfig(projectPath);
|
|
111
|
+
// 编译配置
|
|
112
|
+
const mode = options.mode || _aiotpack.CompileMode.DEVELOPMENT;
|
|
113
|
+
const compilerOption = _lodash.default.merge({}, _aiotpack.JavascriptDefaultCompileOption, {
|
|
114
|
+
...options,
|
|
115
|
+
projectPath: _path.default.join(projectPath, uxProjectConfig.output),
|
|
116
|
+
mode
|
|
117
|
+
}, otherConfig);
|
|
118
|
+
return compilerOption;
|
|
119
|
+
}
|
|
120
|
+
readQuickAppConfig(projectPath) {
|
|
121
|
+
const path = _path.default.join(projectPath, this.QUICKAPP_CONFIG);
|
|
122
|
+
if (_fsExtra.default.existsSync(path)) {
|
|
123
|
+
try {
|
|
124
|
+
const data = require(path);
|
|
125
|
+
return data;
|
|
126
|
+
} catch (error) {
|
|
127
|
+
const log = {
|
|
128
|
+
level: _sharedUtils.Loglevel.ERROR,
|
|
129
|
+
message: ['read quickapp.config.js error: ', {
|
|
130
|
+
word: error?.toString() || ''
|
|
131
|
+
}]
|
|
132
|
+
};
|
|
133
|
+
this.handleLogs([log]);
|
|
134
|
+
}
|
|
143
135
|
}
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
144
138
|
}
|
|
145
|
-
exports.default = UxBuilderBase;
|
|
139
|
+
var _default = exports.default = UxBuilderBase;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IParam } from '@aiot-toolkit/commander';
|
|
2
2
|
import IBuilder from './IBuilder';
|
|
3
3
|
import UxBuilderBase, { IUxBuildOption } from './UxBuilderBase';
|
|
4
|
-
interface IVelaUxBuilderOption extends IUxBuildOption {
|
|
4
|
+
export interface IVelaUxBuilderOption extends IUxBuildOption {
|
|
5
5
|
watch?: boolean;
|
|
6
|
-
enableJsc
|
|
6
|
+
enableJsc: boolean;
|
|
7
7
|
enableE2e?: boolean;
|
|
8
8
|
enableStats?: boolean;
|
|
9
9
|
optimizeCssAttr?: boolean;
|
|
@@ -19,6 +19,7 @@ interface IVelaUxBuilderOption extends IUxBuildOption {
|
|
|
19
19
|
devtool?: string;
|
|
20
20
|
enableProtobuf?: boolean;
|
|
21
21
|
}
|
|
22
|
+
export declare const velaUxBuilderParams: IParam[];
|
|
22
23
|
/**
|
|
23
24
|
* VelaUxBuilder
|
|
24
25
|
*/
|
|
@@ -1,80 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.velaUxBuilderParams = exports.default = void 0;
|
|
7
|
+
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
8
|
+
var _UxBuilderBase = _interopRequireDefault(require("./UxBuilderBase"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const velaUxBuilderParams = exports.velaUxBuilderParams = [{
|
|
11
|
+
type: 'string',
|
|
12
|
+
name: 'devtool',
|
|
13
|
+
description: 'source map config'
|
|
14
|
+
}, {
|
|
15
|
+
name: 'disable-subpackages',
|
|
16
|
+
description: 'disable subpackages'
|
|
17
|
+
}, {
|
|
18
|
+
type: 'confirm',
|
|
19
|
+
name: 'enable-jsc',
|
|
20
|
+
description: 'enable jsc bundle',
|
|
21
|
+
defaultValue: false
|
|
22
|
+
}, {
|
|
23
|
+
type: 'confirm',
|
|
24
|
+
name: 'enable-protobuf',
|
|
25
|
+
description: 'enable protobuf',
|
|
26
|
+
defaultValue: false
|
|
27
|
+
}, {
|
|
28
|
+
type: 'confirm',
|
|
29
|
+
name: 'enable-e2e',
|
|
30
|
+
description: 'inject test-suite for current project',
|
|
31
|
+
defaultValue: false
|
|
32
|
+
}, {
|
|
33
|
+
type: 'confirm',
|
|
34
|
+
name: 'enable-stats',
|
|
35
|
+
description: 'analyse time and size of webpack output files',
|
|
36
|
+
defaultValue: false
|
|
37
|
+
}, {
|
|
38
|
+
type: 'confirm',
|
|
39
|
+
name: 'optimize-css-attr',
|
|
40
|
+
description: 'optimize css attr',
|
|
41
|
+
defaultValue: false
|
|
42
|
+
}, {
|
|
43
|
+
type: 'confirm',
|
|
44
|
+
name: 'complete-feature',
|
|
45
|
+
description: 'auto complete the features are used in the code into the features field of the manifest.json file',
|
|
46
|
+
defaultValue: false
|
|
47
|
+
}, {
|
|
48
|
+
type: 'confirm',
|
|
49
|
+
name: 'enable-custom-component',
|
|
50
|
+
description: 'deprecated',
|
|
51
|
+
deprecated: 'please remove it now',
|
|
52
|
+
deprecatedVersion: '2.1.0'
|
|
53
|
+
}, {
|
|
54
|
+
type: 'confirm',
|
|
55
|
+
name: 'stats',
|
|
56
|
+
description: 'deprecated',
|
|
57
|
+
deprecated: 'please use `enable-stats` instead',
|
|
58
|
+
deprecatedVersion: '2.1.0'
|
|
59
|
+
}];
|
|
60
|
+
|
|
8
61
|
/**
|
|
9
62
|
* VelaUxBuilder
|
|
10
63
|
*/
|
|
11
|
-
class VelaUxBuilder extends
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
type: 'confirm',
|
|
62
|
-
name: 'enable-custom-component',
|
|
63
|
-
description: 'deprecated',
|
|
64
|
-
deprecated: 'please remove it now',
|
|
65
|
-
deprecatedVersion: '2.1.0'
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
type: 'confirm',
|
|
69
|
-
name: 'stats',
|
|
70
|
-
description: 'deprecated',
|
|
71
|
-
deprecated: 'please use `enable-stats` instead',
|
|
72
|
-
deprecatedVersion: '2.1.0'
|
|
73
|
-
}
|
|
74
|
-
];
|
|
75
|
-
}
|
|
76
|
-
match(projectPath) {
|
|
77
|
-
return shared_utils_1.ProjectType.getProjectType(projectPath) === shared_utils_1.ProjectType.VELA_UX;
|
|
78
|
-
}
|
|
64
|
+
class VelaUxBuilder extends _UxBuilderBase.default {
|
|
65
|
+
params = (() => velaUxBuilderParams)();
|
|
66
|
+
match(projectPath) {
|
|
67
|
+
return _sharedUtils.ProjectType.getProjectType(projectPath) === _sharedUtils.ProjectType.VELA_UX;
|
|
68
|
+
}
|
|
79
69
|
}
|
|
80
|
-
exports.default = VelaUxBuilder;
|
|
70
|
+
var _default = exports.default = VelaUxBuilder;
|
|
@@ -1,101 +1,94 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const aiotpack_1 = require("@aiot-toolkit/aiotpack");
|
|
16
|
-
const aiotpack_2 = require("@aiot-toolkit/aiotpack");
|
|
17
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
18
|
-
const file_lane_1 = require("file-lane");
|
|
19
|
-
const fs_1 = __importDefault(require("fs"));
|
|
20
|
-
const path_1 = __importDefault(require("path"));
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _aiotpack = require("@aiot-toolkit/aiotpack");
|
|
8
|
+
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
9
|
+
var _fileLane = require("file-lane");
|
|
10
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
+
var _path = _interopRequireDefault(require("path"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
13
|
/**
|
|
22
14
|
* XtsBuilder
|
|
23
15
|
*/
|
|
24
16
|
class XtsBuilder {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const unValid = res.find((r) => {
|
|
35
|
-
return !aiotpack_2.skipList.includes(r);
|
|
36
|
-
});
|
|
37
|
-
if (unValid) {
|
|
38
|
-
return `${unValid} is unvalidate, validate value are ${aiotpack_2.skipList.join(',')}, Multiple values separated by commas`;
|
|
39
|
-
}
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
];
|
|
17
|
+
static PROJECT_TYPE = 'xts quick app';
|
|
18
|
+
match(projectPath) {
|
|
19
|
+
// app/app.xts 存在视为xts项目
|
|
20
|
+
return _fs.default.existsSync(_path.default.resolve(projectPath, 'app/app.xts'));
|
|
21
|
+
}
|
|
22
|
+
async build(projectPath, options) {
|
|
23
|
+
if (this.fileLane) {
|
|
24
|
+
// 已经在运行中,请先停止
|
|
25
|
+
throw new Error('already running, please stop first: builder.stop()');
|
|
44
26
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
27
|
+
const watch = options.watch || false;
|
|
28
|
+
_sharedUtils.ColorConsole.success('Start build...\n', {
|
|
29
|
+
word: 'ProjectPath: ',
|
|
30
|
+
style: _sharedUtils.ColorConsole.getStyle(_sharedUtils.Loglevel.SUCCESS)
|
|
31
|
+
}, projectPath, '\n', {
|
|
32
|
+
word: 'buildOptions: ',
|
|
33
|
+
style: _sharedUtils.ColorConsole.getStyle(_sharedUtils.Loglevel.SUCCESS)
|
|
34
|
+
}, JSON.stringify(options));
|
|
35
|
+
const compilerOptions = {
|
|
36
|
+
skip: _sharedUtils.StringUtil.string2arrayByComma(options.skip)
|
|
37
|
+
};
|
|
38
|
+
const config = new _aiotpack.XtsConfig(projectPath);
|
|
39
|
+
if (compilerOptions.skip?.includes('xts2ts')) {
|
|
40
|
+
_sharedUtils.ColorConsole.info("### skip compile xts to ts due to --skip ${compilerOptions?.skip.join(',')}");
|
|
41
|
+
const context = _fileLane.FileLaneUtil.createContext(config.output, projectPath);
|
|
42
|
+
const preWorks = config.beforeCompile || [];
|
|
43
|
+
for (let item of preWorks) {
|
|
44
|
+
try {
|
|
45
|
+
await item({
|
|
46
|
+
context,
|
|
47
|
+
config,
|
|
48
|
+
compilerOption: compilerOptions
|
|
49
|
+
});
|
|
50
|
+
} catch (error) {
|
|
51
|
+
// 报错 prework的item error
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const follWorks = config.afterCompile || [];
|
|
55
|
+
for (let item of follWorks) {
|
|
56
|
+
try {
|
|
57
|
+
await item.worker({
|
|
58
|
+
context,
|
|
59
|
+
config,
|
|
60
|
+
compilerOption: compilerOptions
|
|
61
|
+
});
|
|
62
|
+
} catch (error) {
|
|
63
|
+
// 报错 prework的item error
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
this.fileLane = new _fileLane.FileLane(config, projectPath, compilerOptions);
|
|
68
|
+
this.fileLane.start({
|
|
69
|
+
watch
|
|
70
|
+
});
|
|
48
71
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
yield item({ context, config, compilerOption: compilerOptions });
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
// 报错 prework的item error
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
const follWorks = config.afterCompile || [];
|
|
75
|
-
for (let item of follWorks) {
|
|
76
|
-
try {
|
|
77
|
-
yield item.worker({ context, config, compilerOption: compilerOptions });
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
// 报错 prework的item error
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
this.fileLane = new file_lane_1.FileLane(config, projectPath, compilerOptions);
|
|
86
|
-
this.fileLane.start({
|
|
87
|
-
watch
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
});
|
|
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
|
-
});
|
|
72
|
+
}
|
|
73
|
+
async dispose() {
|
|
74
|
+
await this.fileLane?.dispose();
|
|
75
|
+
this.fileLane = undefined;
|
|
76
|
+
}
|
|
77
|
+
params = (() => [{
|
|
78
|
+
name: 'skip',
|
|
79
|
+
type: 'string',
|
|
80
|
+
description: `Can configure skip steps, comma separated, optional values: ${_aiotpack.skipList.join(',')}`,
|
|
81
|
+
validate(value) {
|
|
82
|
+
// TODO: validate 不起作用
|
|
83
|
+
const res = _sharedUtils.StringUtil.string2arrayByComma(value);
|
|
84
|
+
const unValid = res.find(r => {
|
|
85
|
+
return !_aiotpack.skipList.includes(r);
|
|
86
|
+
});
|
|
87
|
+
if (unValid) {
|
|
88
|
+
return `${unValid} is unvalidate, validate value are ${_aiotpack.skipList.join(',')}, Multiple values separated by commas`;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
98
91
|
}
|
|
92
|
+
}])();
|
|
99
93
|
}
|
|
100
|
-
|
|
101
|
-
exports.default = XtsBuilder;
|
|
94
|
+
var _default = exports.default = XtsBuilder;
|