aiot-toolkit 2.0.2-beta.12 → 2.0.2-beta.14
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 +18 -20
- 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/{UxBuilder.js → UxBuilderBase.js} +32 -82
- package/lib/builder/VelaUxBuilder.d.ts +23 -0
- package/lib/builder/VelaUxBuilder.js +66 -0
- package/lib/builder/XtsBuilder.js +2 -2
- package/lib/starter/AndroidUxStart.d.ts +3 -2
- package/lib/starter/AndroidUxStart.js +10 -9
- package/lib/starter/{UxStarter.d.ts → VelaUxStarter.d.ts} +7 -6
- package/lib/starter/{UxStarter.js → VelaUxStarter.js} +22 -14
- package/package.json +13 -13
- package/lib/builder/UxBuilder.d.ts +0 -42
package/lib/bin.js
CHANGED
|
@@ -16,15 +16,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
17
17
|
const semver_1 = __importDefault(require("semver"));
|
|
18
18
|
// 支持的最低node版本
|
|
19
|
-
const NODE_MINIMUM_VERSION = '
|
|
19
|
+
const NODE_MINIMUM_VERSION = '18.0.0';
|
|
20
20
|
checkVersion();
|
|
21
21
|
const aiotpack_1 = require("@aiot-toolkit/aiotpack");
|
|
22
22
|
const commander_1 = require("@aiot-toolkit/commander");
|
|
23
23
|
const shared_utils_2 = require("@aiot-toolkit/shared-utils");
|
|
24
|
-
const
|
|
24
|
+
const AndroidUxBuilder_1 = __importDefault(require("./builder/AndroidUxBuilder"));
|
|
25
|
+
const VelaUxBuilder_1 = __importDefault(require("./builder/VelaUxBuilder"));
|
|
25
26
|
const XtsBuilder_1 = __importDefault(require("./builder/XtsBuilder"));
|
|
26
27
|
const AndroidUxStart_1 = __importDefault(require("./starter/AndroidUxStart"));
|
|
27
|
-
const
|
|
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"));
|
|
@@ -39,15 +40,15 @@ function checkVersion() {
|
|
|
39
40
|
// 配置支持的 builder 类型,新增的项目类型,需在此处加上类型
|
|
40
41
|
const projectMapper = {
|
|
41
42
|
[shared_utils_2.ProjectType.VELA_UX]: {
|
|
42
|
-
builder:
|
|
43
|
-
starter:
|
|
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
|
|
48
49
|
},
|
|
49
50
|
[shared_utils_2.ProjectType.ANDDROID_UX]: {
|
|
50
|
-
builder:
|
|
51
|
+
builder: AndroidUxBuilder_1.default,
|
|
51
52
|
starter: AndroidUxStart_1.default
|
|
52
53
|
}
|
|
53
54
|
};
|
|
@@ -63,10 +64,17 @@ function build(command, description) {
|
|
|
63
64
|
description,
|
|
64
65
|
paramList,
|
|
65
66
|
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
+
}
|
|
70
78
|
})
|
|
71
79
|
};
|
|
72
80
|
}
|
|
@@ -84,16 +92,6 @@ function main() {
|
|
|
84
92
|
build('build', 'build project'),
|
|
85
93
|
build('release', 'release the project'),
|
|
86
94
|
findStarter('start', 'start project').getCommond(),
|
|
87
|
-
{
|
|
88
|
-
name: 'watch',
|
|
89
|
-
description: 'recompile project while file changes',
|
|
90
|
-
action: (option) => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
const projectPath = process.cwd();
|
|
92
|
-
const builder = findBuilder();
|
|
93
|
-
option.watch = true;
|
|
94
|
-
yield builder.build(projectPath, option);
|
|
95
|
-
})
|
|
96
|
-
},
|
|
97
95
|
{
|
|
98
96
|
name: 'getConnectedDevices',
|
|
99
97
|
description: 'get all connected devices',
|
|
@@ -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;
|
|
@@ -25,84 +25,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const aiotpack_1 = require("@aiot-toolkit/aiotpack");
|
|
27
27
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
28
|
-
const
|
|
29
|
-
const file_lane_1 = require("file-lane");
|
|
28
|
+
const path_1 = __importDefault(require("path"));
|
|
30
29
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
31
30
|
const lodash_1 = __importDefault(require("lodash"));
|
|
32
|
-
const
|
|
33
|
-
const fs_1 = __importDefault(require("fs"));
|
|
34
|
-
const path_2 = __importDefault(require("path"));
|
|
31
|
+
const file_lane_1 = __importDefault(require("file-lane"));
|
|
35
32
|
/**
|
|
36
|
-
*
|
|
33
|
+
* UxBuilderBase
|
|
37
34
|
*/
|
|
38
|
-
class
|
|
39
|
-
constructor(events
|
|
35
|
+
class UxBuilderBase {
|
|
36
|
+
constructor(events = {
|
|
37
|
+
onBuildSuccess: (data) => shared_utils_1.ColorConsole.info(`build time: ${data.costTime}ms`)
|
|
38
|
+
}) {
|
|
40
39
|
this.events = events;
|
|
40
|
+
/**
|
|
41
|
+
* 配置文件
|
|
42
|
+
*/
|
|
41
43
|
this.QUICKAPP_CONFIG = 'quickapp.config.js';
|
|
42
|
-
this.params = [
|
|
43
|
-
{
|
|
44
|
-
type: 'string',
|
|
45
|
-
name: 'devtool',
|
|
46
|
-
description: 'source map config'
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: 'disable-subpackages',
|
|
50
|
-
description: 'disable subpackages'
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
type: 'confirm',
|
|
54
|
-
name: 'disabled-jsc',
|
|
55
|
-
description: 'disabled jsc bundle',
|
|
56
|
-
defaultValue: false
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
type: 'confirm',
|
|
60
|
-
name: 'enable-protobuf',
|
|
61
|
-
description: 'enable protobuf',
|
|
62
|
-
defaultValue: false
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
type: 'confirm',
|
|
66
|
-
name: 'enable-e2e',
|
|
67
|
-
description: 'inject test-suite for current project',
|
|
68
|
-
defaultValue: false
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
type: 'confirm',
|
|
72
|
-
name: 'enable-stats',
|
|
73
|
-
description: 'analyse time and size of webpack output files',
|
|
74
|
-
defaultValue: false
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
type: 'confirm',
|
|
78
|
-
name: 'optimize-css-attr',
|
|
79
|
-
description: 'optimize css attr',
|
|
80
|
-
defaultValue: false
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
type: 'confirm',
|
|
84
|
-
name: 'complete-feature',
|
|
85
|
-
description: 'auto complete the features are used in the code into the features field of the manifest.json file',
|
|
86
|
-
defaultValue: false
|
|
87
|
-
}
|
|
88
|
-
];
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* 获取build的编译配置
|
|
92
|
-
* @param projectPath 项目路径
|
|
93
|
-
* @param options 命令参数
|
|
94
|
-
*/
|
|
95
|
-
getCompilerOption(projectPath, options) {
|
|
96
|
-
// 读取项目中文件的配置
|
|
97
|
-
const quickappConfig = this.readQuickAppConfig(projectPath);
|
|
98
|
-
const _a = quickappConfig || {}, { cli } = _a, otherConfig = __rest(_a, ["cli"]);
|
|
99
|
-
options = lodash_1.default.merge({}, options, cli);
|
|
100
|
-
// 项目配置
|
|
101
|
-
const uxProjectConfig = new aiotpack_1.UxConfig(projectPath);
|
|
102
|
-
// 编译配置
|
|
103
|
-
const compileMode = options.mode || aiotpack_1.CompileMode.DEVELOPMENT;
|
|
104
|
-
const compilerOption = lodash_1.default.merge(aiotpack_1.JavascriptDefaultCompileOption, Object.assign(Object.assign({}, options), { projectPath: path_1.default.join(projectPath, uxProjectConfig.output), mode: compileMode, enableProtobuf: options.enableProtobuf }), otherConfig);
|
|
105
|
-
return compilerOption;
|
|
106
44
|
}
|
|
107
45
|
/**
|
|
108
46
|
* ux项目的build函数
|
|
@@ -117,8 +55,8 @@ class UxBuilder {
|
|
|
117
55
|
const uxProjectConfig = new aiotpack_1.UxConfig(projectPath);
|
|
118
56
|
// 编译配置
|
|
119
57
|
const compilerOption = this.getCompilerOption(projectPath, options);
|
|
120
|
-
|
|
121
|
-
style:
|
|
58
|
+
shared_utils_1.ColorConsole.info('start build: ', {
|
|
59
|
+
style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.INFO),
|
|
122
60
|
word: JSON.stringify({
|
|
123
61
|
projectPath,
|
|
124
62
|
options,
|
|
@@ -130,9 +68,26 @@ class UxBuilder {
|
|
|
130
68
|
}, null, 2)
|
|
131
69
|
});
|
|
132
70
|
// 开始编译项目
|
|
133
|
-
yield new file_lane_1.
|
|
71
|
+
yield new file_lane_1.default(uxProjectConfig, projectPath, compilerOption, this.events).start({ watch });
|
|
134
72
|
});
|
|
135
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
|
+
}
|
|
136
91
|
readQuickAppConfig(projectPath) {
|
|
137
92
|
const path = path_1.default.join(projectPath, this.QUICKAPP_CONFIG);
|
|
138
93
|
if (fs_extra_1.default.existsSync(path)) {
|
|
@@ -141,15 +96,10 @@ class UxBuilder {
|
|
|
141
96
|
return data;
|
|
142
97
|
}
|
|
143
98
|
catch (error) {
|
|
144
|
-
|
|
99
|
+
shared_utils_1.ColorConsole.throw((error === null || error === void 0 ? void 0 : error.toString()) || '');
|
|
145
100
|
}
|
|
146
101
|
}
|
|
147
102
|
return;
|
|
148
103
|
}
|
|
149
|
-
match(projectPath) {
|
|
150
|
-
// src/app.ux 存在视为ux项目
|
|
151
|
-
return fs_1.default.existsSync(path_2.default.resolve(projectPath, 'src/app.ux'));
|
|
152
|
-
}
|
|
153
104
|
}
|
|
154
|
-
|
|
155
|
-
exports.default = UxBuilder;
|
|
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;
|
|
@@ -58,7 +58,7 @@ class XtsBuilder {
|
|
|
58
58
|
if ((_a = compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('xts2ts')) {
|
|
59
59
|
shared_utils_1.ColorConsole.info("### skip compile xts to ts due to --skip ${compilerOptions?.skip.join(',')}");
|
|
60
60
|
const context = file_lane_1.FileLaneUtil.createContext(config.output, projectPath);
|
|
61
|
-
const preWorks = config.
|
|
61
|
+
const preWorks = config.beforeCompile || [];
|
|
62
62
|
for (let item of preWorks) {
|
|
63
63
|
try {
|
|
64
64
|
yield item(context, [], config, compilerOptions);
|
|
@@ -67,7 +67,7 @@ class XtsBuilder {
|
|
|
67
67
|
// 报错 prework的item error
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
const follWorks = config.
|
|
70
|
+
const follWorks = config.afterCompile || [];
|
|
71
71
|
for (let item of follWorks) {
|
|
72
72
|
try {
|
|
73
73
|
yield item.worker(context, config, compilerOptions);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { IParam, PersistentCommand } from '@aiot-toolkit/commander';
|
|
1
2
|
import IStarter from './IStarter';
|
|
2
|
-
import { PersistentCommand } from '@aiot-toolkit/commander';
|
|
3
3
|
/**
|
|
4
4
|
* AndroidUxStart
|
|
5
5
|
*
|
|
@@ -9,8 +9,9 @@ import { PersistentCommand } from '@aiot-toolkit/commander';
|
|
|
9
9
|
declare class AndroidUxStart extends IStarter {
|
|
10
10
|
private server?;
|
|
11
11
|
private port?;
|
|
12
|
-
private builder
|
|
12
|
+
private builder;
|
|
13
13
|
private projectPath;
|
|
14
|
+
params: IParam[];
|
|
14
15
|
get waiter(): PersistentCommand;
|
|
15
16
|
/**
|
|
16
17
|
* 启动
|
|
@@ -13,14 +13,14 @@ 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 commander_1 = require("@aiot-toolkit/commander");
|
|
16
17
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
17
18
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
19
|
const http_1 = __importDefault(require("http"));
|
|
19
20
|
const path_1 = __importDefault(require("path"));
|
|
20
|
-
const
|
|
21
|
+
const AndroidUxBuilder_1 = __importDefault(require("../builder/AndroidUxBuilder"));
|
|
21
22
|
const IStarter_1 = __importDefault(require("./IStarter"));
|
|
22
23
|
const PackageRouter_1 = __importDefault(require("./androidRouter/PackageRouter"));
|
|
23
|
-
const commander_1 = require("@aiot-toolkit/commander");
|
|
24
24
|
/**
|
|
25
25
|
* AndroidUxStart
|
|
26
26
|
*
|
|
@@ -30,7 +30,9 @@ const commander_1 = require("@aiot-toolkit/commander");
|
|
|
30
30
|
class AndroidUxStart extends IStarter_1.default {
|
|
31
31
|
constructor() {
|
|
32
32
|
super(...arguments);
|
|
33
|
+
this.builder = new AndroidUxBuilder_1.default();
|
|
33
34
|
this.projectPath = '';
|
|
35
|
+
this.params = [...this.builder.params];
|
|
34
36
|
}
|
|
35
37
|
get waiter() {
|
|
36
38
|
return new commander_1.PersistentCommand({
|
|
@@ -115,13 +117,12 @@ class AndroidUxStart extends IStarter_1.default {
|
|
|
115
117
|
}
|
|
116
118
|
build(projectPath, options) {
|
|
117
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
120
|
+
this.builder.events = {
|
|
121
|
+
onBuildSuccess: (data) => {
|
|
122
|
+
shared_utils_1.ColorConsole.info(`build time: ${data.costTime}ms`);
|
|
123
|
+
this.noticeDeviceListUpdate(projectPath, options);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
125
126
|
yield this.builder.build(projectPath, Object.assign(Object.assign({}, options), { watch: true }));
|
|
126
127
|
});
|
|
127
128
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { IParam } from '@aiot-toolkit/commander';
|
|
2
|
-
import { IStartOptions } from '@aiot-toolkit/emulator';
|
|
3
|
-
import
|
|
2
|
+
import { IStartOptions, GoldfishInstance, MiwearInstance, OldGoldfishInstance } from '@aiot-toolkit/emulator';
|
|
3
|
+
import VelaUxBuilder from '../builder/VelaUxBuilder';
|
|
4
4
|
import IStarter from './IStarter';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* VelaUxStarter
|
|
7
7
|
* ux快应用启动器
|
|
8
8
|
*/
|
|
9
|
-
declare class
|
|
9
|
+
declare class VelaUxStarter extends IStarter<IStartOptions> {
|
|
10
10
|
private ws;
|
|
11
|
-
|
|
11
|
+
currentGoldfishInstance: GoldfishInstance | MiwearInstance | OldGoldfishInstance | undefined;
|
|
12
|
+
builder: VelaUxBuilder;
|
|
12
13
|
params: IParam[];
|
|
13
14
|
start(projectPath: string, options: any): Promise<void>;
|
|
14
15
|
/**
|
|
@@ -19,4 +20,4 @@ declare class UxStarter extends IStarter<IStartOptions> {
|
|
|
19
20
|
*/
|
|
20
21
|
isAvailableEmulator(avdName: string): boolean;
|
|
21
22
|
}
|
|
22
|
-
export default
|
|
23
|
+
export default VelaUxStarter;
|
|
@@ -14,31 +14,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const aiotpack_1 = require("@aiot-toolkit/aiotpack");
|
|
16
16
|
const emulator_1 = require("@aiot-toolkit/emulator");
|
|
17
|
-
const constants_1 = require("@aiot-toolkit/emulator/lib/
|
|
17
|
+
const constants_1 = require("@aiot-toolkit/emulator/lib/emulatorutil/constants");
|
|
18
18
|
const index_1 = require("@aiot-toolkit/emulator/lib/utils/index");
|
|
19
19
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
20
20
|
const prompts_1 = require("@inquirer/prompts");
|
|
21
21
|
const os_1 = __importDefault(require("os"));
|
|
22
22
|
const path_1 = __importDefault(require("path"));
|
|
23
23
|
const portfinder_1 = __importDefault(require("portfinder"));
|
|
24
|
-
const
|
|
24
|
+
const VelaUxBuilder_1 = __importDefault(require("../builder/VelaUxBuilder"));
|
|
25
25
|
const VelaAvdUtils_1 = __importDefault(require("../utils/VelaAvdUtils"));
|
|
26
26
|
const IStarter_1 = __importDefault(require("./IStarter"));
|
|
27
27
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
28
28
|
const ws_1 = __importDefault(require("ws"));
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* VelaUxStarter
|
|
31
31
|
* ux快应用启动器
|
|
32
32
|
*/
|
|
33
|
-
class
|
|
33
|
+
class VelaUxStarter extends IStarter_1.default {
|
|
34
34
|
constructor() {
|
|
35
35
|
super(...arguments);
|
|
36
|
-
this.builder = new
|
|
37
|
-
onBuildSuccess: () => {
|
|
36
|
+
this.builder = new VelaUxBuilder_1.default({
|
|
37
|
+
onBuildSuccess: (data) => {
|
|
38
38
|
var _a;
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
shared_utils_1.ColorConsole.info(`build time: ${data.costTime}ms`);
|
|
40
|
+
if (this.ws) {
|
|
41
|
+
this.ws.send(JSON.stringify({
|
|
42
|
+
type: 'restart'
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
(_a = this.currentGoldfishInstance) === null || _a === void 0 ? void 0 : _a.restart();
|
|
47
|
+
}
|
|
42
48
|
}
|
|
43
49
|
});
|
|
44
50
|
this.params = [
|
|
@@ -115,9 +121,11 @@ class UxStarter extends IStarter_1.default {
|
|
|
115
121
|
compilerOption
|
|
116
122
|
};
|
|
117
123
|
// 寻找对应的模拟器instance
|
|
118
|
-
|
|
119
|
-
if (!
|
|
124
|
+
this.currentGoldfishInstance = (0, emulator_1.findInstance)(avdName, params);
|
|
125
|
+
if (!this.currentGoldfishInstance) {
|
|
126
|
+
shared_utils_1.ColorConsole.throw('no corresponding emulator found, please recreate it');
|
|
120
127
|
return;
|
|
128
|
+
}
|
|
121
129
|
let grpcPort;
|
|
122
130
|
// 设置vncPort
|
|
123
131
|
if (options.openVNC) {
|
|
@@ -129,7 +137,7 @@ class UxStarter extends IStarter_1.default {
|
|
|
129
137
|
// 设置adbPort
|
|
130
138
|
const adbPort = yield (0, index_1.getEvenPort)();
|
|
131
139
|
if (!adbPort) {
|
|
132
|
-
shared_utils_1.ColorConsole.throw(`${adbPort},5555
|
|
140
|
+
shared_utils_1.ColorConsole.throw(`${adbPort},the port numbers between 5555 and 5585 are all occupied. please resolve the port conflict before starting the emulator`);
|
|
133
141
|
return;
|
|
134
142
|
}
|
|
135
143
|
// 设置debugPort
|
|
@@ -146,7 +154,7 @@ class UxStarter extends IStarter_1.default {
|
|
|
146
154
|
adbPort,
|
|
147
155
|
debugPort
|
|
148
156
|
};
|
|
149
|
-
yield
|
|
157
|
+
yield this.currentGoldfishInstance.start(startOptions);
|
|
150
158
|
this.ws = new ws_1.default(`ws://localhost:${serverPort}`);
|
|
151
159
|
// waiter
|
|
152
160
|
// const startWaiter: PersistentCommand = new PersistentCommand({
|
|
@@ -187,4 +195,4 @@ class UxStarter extends IStarter_1.default {
|
|
|
187
195
|
return true;
|
|
188
196
|
}
|
|
189
197
|
}
|
|
190
|
-
exports.default =
|
|
198
|
+
exports.default = VelaUxStarter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiot-toolkit",
|
|
3
|
-
"version": "2.0.2-beta.
|
|
3
|
+
"version": "2.0.2-beta.14",
|
|
4
4
|
"description": "Tools for creating, developing, and packaging aiot applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiot"
|
|
@@ -21,33 +21,33 @@
|
|
|
21
21
|
"test": "node ./__tests__/aiot-toolkit.test.js"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@aiot-toolkit/
|
|
25
|
-
"@aiot-toolkit/
|
|
26
|
-
"@aiot-toolkit/
|
|
27
|
-
"@
|
|
24
|
+
"@aiot-toolkit/aiotpack": "2.0.2-beta.14",
|
|
25
|
+
"@aiot-toolkit/commander": "2.0.2-beta.14",
|
|
26
|
+
"@aiot-toolkit/emulator": "2.0.2-beta.14",
|
|
27
|
+
"@aiot-toolkit/shared-utils": "2.0.2-beta.14",
|
|
28
|
+
"@inquirer/prompts": "^5.3.0",
|
|
29
|
+
"@miwt/adb": "^0.9.0",
|
|
28
30
|
"adb-commander": "^0.1.9",
|
|
29
31
|
"adm-zip": "^0.5.10",
|
|
30
|
-
"axios": "^1.
|
|
32
|
+
"axios": "^1.7.4",
|
|
31
33
|
"cli-progress": "^3.12.0",
|
|
32
|
-
"create-aiot": "2.0.2-beta.12",
|
|
33
34
|
"dayjs": "^1.11.10",
|
|
34
|
-
"
|
|
35
|
-
"file-lane": "2.0.2-beta.12",
|
|
35
|
+
"file-lane": "2.0.2-beta.14",
|
|
36
36
|
"fs-extra": "^11.2.0",
|
|
37
|
+
"koa-router": "^12.0.1",
|
|
37
38
|
"lodash": "^4.17.21",
|
|
39
|
+
"portfinder": "^1.0.32",
|
|
38
40
|
"qr-image": "^3.2.0",
|
|
39
|
-
"semver": "^7.6.
|
|
41
|
+
"semver": "^7.6.3",
|
|
40
42
|
"ws": "^8.15.1"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
45
|
"@types/adm-zip": "^0.5.4",
|
|
44
46
|
"@types/fs-extra": "^11.0.4",
|
|
45
|
-
"@types/koa": "^2.15.0",
|
|
46
47
|
"@types/koa-router": "^7.4.8",
|
|
47
|
-
"@types/koa-static": "^4.0.4",
|
|
48
48
|
"@types/qr-image": "^3.2.9",
|
|
49
49
|
"@types/semver": "^7.5.8",
|
|
50
50
|
"@types/ws": "^8.5.10"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "c6093733d0267d2d1359fec0af8f7a253955e3e3"
|
|
53
53
|
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { CompileMode, IJavascriptCompileOption } 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
|
-
interface IUxBuilderOption extends Dictionary {
|
|
6
|
-
watch?: boolean;
|
|
7
|
-
mode: CompileMode;
|
|
8
|
-
disabledJsc: boolean;
|
|
9
|
-
enableE2e?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* 是否自动补全 manifest.json 中的 features 配置
|
|
12
|
-
*/
|
|
13
|
-
completeFeature?: boolean;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* UxBuilder
|
|
17
|
-
*/
|
|
18
|
-
declare class UxBuilder implements IBuilder<IUxBuilderOption> {
|
|
19
|
-
private readonly events?;
|
|
20
|
-
readonly QUICKAPP_CONFIG = "quickapp.config.js";
|
|
21
|
-
constructor(events?: {
|
|
22
|
-
onBuildSuccess?: (() => void) | undefined;
|
|
23
|
-
} | undefined);
|
|
24
|
-
/**
|
|
25
|
-
* 获取build的编译配置
|
|
26
|
-
* @param projectPath 项目路径
|
|
27
|
-
* @param options 命令参数
|
|
28
|
-
*/
|
|
29
|
-
getCompilerOption(projectPath: string, options: IUxBuilderOption): Partial<IJavascriptCompileOption>;
|
|
30
|
-
/**
|
|
31
|
-
* ux项目的build函数
|
|
32
|
-
* @param projectPath 项目路径
|
|
33
|
-
* @param options 命令参数
|
|
34
|
-
* @param watch 是否开启监听
|
|
35
|
-
*/
|
|
36
|
-
build(projectPath: string, options: IUxBuilderOption): Promise<void>;
|
|
37
|
-
private readQuickAppConfig;
|
|
38
|
-
static readonly PROJECT_TYPE = "ux quick app";
|
|
39
|
-
params: IParam[];
|
|
40
|
-
match(projectPath: string): boolean;
|
|
41
|
-
}
|
|
42
|
-
export default UxBuilder;
|