aiot-toolkit 2.0.2-dev.8 → 2.0.3-beta.1

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.
Files changed (38) hide show
  1. package/README.md +0 -1
  2. package/lib/bin.js +43 -46
  3. package/lib/builder/AndroidUxBuilder.d.ts +10 -0
  4. package/lib/builder/AndroidUxBuilder.js +20 -0
  5. package/lib/builder/UxBuilderBase.d.ts +35 -0
  6. package/lib/builder/{UxBuilder.js → UxBuilderBase.js} +51 -59
  7. package/lib/builder/VelaUxBuilder.d.ts +29 -0
  8. package/lib/builder/VelaUxBuilder.js +66 -0
  9. package/lib/builder/XtsBuilder.js +15 -18
  10. package/lib/index.d.ts +6 -0
  11. package/lib/index.js +14 -0
  12. package/lib/interface/VelaEmulatorInterface.d.ts +7 -6
  13. package/lib/starter/AndroidUxStart.d.ts +40 -0
  14. package/lib/starter/AndroidUxStart.js +171 -0
  15. package/lib/starter/IStarter.d.ts +2 -1
  16. package/lib/starter/IStarter.js +5 -1
  17. package/lib/starter/VelaUxStarter.d.ts +23 -0
  18. package/lib/starter/VelaUxStarter.js +198 -0
  19. package/lib/starter/XtsStarter.d.ts +2 -2
  20. package/lib/starter/androidRouter/LinkMode.d.ts +9 -0
  21. package/lib/starter/androidRouter/LinkMode.js +12 -0
  22. package/lib/starter/androidRouter/PackageRouter.d.ts +55 -0
  23. package/lib/starter/androidRouter/PackageRouter.js +152 -0
  24. package/lib/starter/androidRouter/h5/index.css +167 -0
  25. package/lib/starter/androidRouter/h5/index.html +58 -0
  26. package/lib/starter/androidRouter/h5/index.js +66 -0
  27. package/lib/utils/AdbUtils.d.ts +0 -1
  28. package/lib/utils/AdbUtils.js +3 -14
  29. package/lib/utils/DeviceUtil.js +42 -29
  30. package/lib/utils/RequestUtils.js +5 -5
  31. package/lib/utils/VelaAvdUtils.d.ts +25 -9
  32. package/lib/utils/VelaAvdUtils.js +262 -100
  33. package/package.json +21 -12
  34. package/lib/builder/UxBuilder.d.ts +0 -27
  35. package/lib/starter/UxStarter.d.ts +0 -10
  36. package/lib/starter/UxStarter.js +0 -139
  37. package/lib/utils/UxBuilderUtils.d.ts +0 -8
  38. package/lib/utils/UxBuilderUtils.js +0 -51
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模式 |
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 = '16.0.0';
19
+ const NODE_MINIMUM_VERSION = '18.0.0';
20
20
  checkVersion();
21
- const CompileMode_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/compiler/enum/CompileMode"));
21
+ const aiotpack_1 = require("@aiot-toolkit/aiotpack");
22
22
  const commander_1 = require("@aiot-toolkit/commander");
23
- const fs_1 = __importDefault(require("fs"));
24
- const path_1 = __importDefault(require("path"));
25
- const UxBuilder_1 = __importDefault(require("./builder/UxBuilder"));
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 UxStarter_1 = __importDefault(require("./starter/UxStarter"));
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
- ColorConsole_1.default.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
+ 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
- ux: {
42
- builder: UxBuilder_1.default,
43
- starter: UxStarter_1.default
42
+ [shared_utils_2.ProjectType.VELA_UX]: {
43
+ builder: VelaUxBuilder_1.default,
44
+ starter: VelaUxStarter_1.default
44
45
  },
45
- xts: {
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
- // 获取对应的 build;如果存在,执行 build 函数,不存在,提示
63
- option.mode = command === 'release' ? CompileMode_1.default.PRODUCTION : CompileMode_1.default.DEVELOPMENT;
64
- const projectPath = process.cwd();
65
- yield builder.build(projectPath, option);
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
- ColorConsole_1.default.info(`The connected devices are: ${connectedDevices ? connectedDevices.join(', ') : 'null'}`);
101
+ shared_utils_1.ColorConsole.info(`The connected devices are: ${connectedDevices ? connectedDevices.join(', ') : 'null'}`);
114
102
  }
115
103
  catch (error) {
116
- ColorConsole_1.default.throw(`Error: getConnectedDevices failed`);
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
- ColorConsole_1.default.success(`${successMessage}`);
153
+ shared_utils_1.ColorConsole.success(`${successMessage}`);
166
154
  }
167
155
  catch (error) {
168
- ColorConsole_1.default.throw(`installDbgAndMkp failed, errorMessage: ${(error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'}'}`);
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,35 @@
1
+ import { IJavascriptCompileOption } from '@aiot-toolkit/aiotpack';
2
+ import { Dictionary } from '@aiot-toolkit/shared-utils';
3
+ import IFileLaneEvents, { IFileLaneSuccessData } from 'file-lane/lib/interface/IFileLaneEvents';
4
+ /**
5
+ * UxBuilderBase
6
+ */
7
+ declare class UxBuilderBase<O extends Dictionary = any> {
8
+ events: IFileLaneEvents;
9
+ /**
10
+ * 配置文件
11
+ */
12
+ readonly QUICKAPP_CONFIG = "quickapp.config.js";
13
+ private fileLane?;
14
+ constructor(events?: IFileLaneEvents);
15
+ /**
16
+ * ux项目的build函数
17
+ * @param projectPath 项目路径
18
+ * @param options 命令参数
19
+ * @param watch 是否开启监听
20
+ */
21
+ build(projectPath: string, options: O): Promise<void>;
22
+ /**
23
+ *
24
+ */
25
+ stop(): Promise<void>;
26
+ /**
27
+ * 获取build的编译配置
28
+ * @param projectPath 项目路径
29
+ * @param options 命令参数
30
+ */
31
+ getCompilerOption(projectPath: string, options: O): Partial<IJavascriptCompileOption>;
32
+ private readQuickAppConfig;
33
+ }
34
+ export default UxBuilderBase;
35
+ export { IFileLaneEvents, IFileLaneSuccessData };
@@ -23,49 +23,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- const CompileMode_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/compiler/enum/CompileMode"));
27
- const JavascriptDefaultCompileOption_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/compiler/javascript/JavascriptDefaultCompileOption"));
28
- const UxConfig_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/config/UxConfig"));
26
+ const aiotpack_1 = require("@aiot-toolkit/aiotpack");
29
27
  const shared_utils_1 = require("@aiot-toolkit/shared-utils");
30
- const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
31
- const file_lane_1 = require("file-lane");
28
+ const path_1 = __importDefault(require("path"));
32
29
  const fs_extra_1 = __importDefault(require("fs-extra"));
33
30
  const lodash_1 = __importDefault(require("lodash"));
34
- const path_1 = __importDefault(require("path"));
35
- const UxBuilderUtils_1 = __importDefault(require("../utils/UxBuilderUtils"));
31
+ const file_lane_1 = __importDefault(require("file-lane"));
36
32
  /**
37
- * UxBuilder
33
+ * UxBuilderBase
38
34
  */
39
- class UxBuilder {
40
- constructor() {
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
+ */
41
43
  this.QUICKAPP_CONFIG = 'quickapp.config.js';
42
- this.params = [
43
- {
44
- name: 'enable-e2e',
45
- description: 'inject test-suite for current project'
46
- },
47
- {
48
- type: 'string',
49
- name: 'devtool',
50
- description: 'source map config'
51
- },
52
- {
53
- name: 'disable-subpackages',
54
- description: 'disable subpackages'
55
- },
56
- {
57
- type: 'confirm',
58
- name: 'disabled-jsc',
59
- description: 'disabled jsc bundle',
60
- defaultValue: false
61
- },
62
- {
63
- name: 'enable-protobuf',
64
- description: 'enable protobuf',
65
- type: 'confirm',
66
- defaultValue: false
67
- }
68
- ];
69
44
  }
70
45
  /**
71
46
  * ux项目的build函数
@@ -75,24 +50,17 @@ class UxBuilder {
75
50
  */
76
51
  build(projectPath, options) {
77
52
  return __awaiter(this, void 0, void 0, function* () {
53
+ if (this.fileLane) {
54
+ // 已经在运行中,请先停止
55
+ throw new Error('already running, please stop first: builder.stop()');
56
+ }
78
57
  const watch = options.watch || false;
79
- // 读取项目中文件的配置
80
- const quickappConfig = this.readQuickAppConfig(projectPath);
81
- const _a = quickappConfig || {}, { cli } = _a, otherConfig = __rest(_a, ["cli"]);
82
- options = lodash_1.default.merge({}, options, cli);
83
58
  // 项目配置
84
- const uxProjectConfig = new UxConfig_1.default(projectPath);
59
+ const uxProjectConfig = new aiotpack_1.UxConfig(projectPath);
85
60
  // 编译配置
86
- const compileMode = options.mode || CompileMode_1.default.DEVELOPMENT;
87
- const compilerOption = lodash_1.default.merge({
88
- projectPath: path_1.default.join(projectPath, uxProjectConfig.output),
89
- mode: compileMode,
90
- disabledJSC: options.disabledJsc,
91
- enableProtobuf: options.enableProtobuf,
92
- devtool: UxBuilderUtils_1.default.getDevtoolValue(compileMode, options.devtool)
93
- }, JavascriptDefaultCompileOption_1.default, otherConfig);
94
- ColorConsole_1.default.info('start build: ', {
95
- style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Info),
61
+ const compilerOption = this.getCompilerOption(projectPath, options);
62
+ shared_utils_1.ColorConsole.info('start build: ', {
63
+ style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.INFO),
96
64
  word: JSON.stringify({
97
65
  projectPath,
98
66
  options,
@@ -104,9 +72,37 @@ class UxBuilder {
104
72
  }, null, 2)
105
73
  });
106
74
  // 开始编译项目
107
- yield new file_lane_1.FileLane(uxProjectConfig, projectPath, compilerOption).start({ watch });
75
+ this.fileLane = new file_lane_1.default(uxProjectConfig, projectPath, compilerOption, this.events);
76
+ yield this.fileLane.start({ watch });
108
77
  });
109
78
  }
79
+ /**
80
+ *
81
+ */
82
+ stop() {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ var _a;
85
+ yield ((_a = this.fileLane) === null || _a === void 0 ? void 0 : _a.stop());
86
+ this.fileLane = undefined;
87
+ });
88
+ }
89
+ /**
90
+ * 获取build的编译配置
91
+ * @param projectPath 项目路径
92
+ * @param options 命令参数
93
+ */
94
+ getCompilerOption(projectPath, options) {
95
+ // 读取项目中文件的配置
96
+ const quickappConfig = this.readQuickAppConfig(projectPath);
97
+ const _a = quickappConfig || {}, { cli } = _a, otherConfig = __rest(_a, ["cli"]);
98
+ options = lodash_1.default.merge({}, options, cli);
99
+ // 项目配置
100
+ const uxProjectConfig = new aiotpack_1.UxConfig(projectPath);
101
+ // 编译配置
102
+ const compileMode = options.mode || aiotpack_1.CompileMode.DEVELOPMENT;
103
+ 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);
104
+ return compilerOption;
105
+ }
110
106
  readQuickAppConfig(projectPath) {
111
107
  const path = path_1.default.join(projectPath, this.QUICKAPP_CONFIG);
112
108
  if (fs_extra_1.default.existsSync(path)) {
@@ -115,14 +111,10 @@ class UxBuilder {
115
111
  return data;
116
112
  }
117
113
  catch (error) {
118
- ColorConsole_1.default.throw((error === null || error === void 0 ? void 0 : error.toString()) || '');
114
+ shared_utils_1.ColorConsole.throw((error === null || error === void 0 ? void 0 : error.toString()) || '');
119
115
  }
120
116
  }
121
117
  return;
122
118
  }
123
- match(projectPath) {
124
- return projectPath.includes('ux');
125
- }
126
119
  }
127
- UxBuilder.PROJECT_TYPE = 'ux quick app';
128
- exports.default = UxBuilder;
120
+ exports.default = UxBuilderBase;
@@ -0,0 +1,29 @@
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
+ * 此选项控制是否生成,以及如何生成 source map
13
+ *
14
+ * @see https://www.webpackjs.com/configuration/devtool/#devtool
15
+ */
16
+ devtool?: string;
17
+ /**
18
+ * 是否自动补全 manifest.json 中的 features 配置
19
+ */
20
+ completeFeature?: boolean;
21
+ }
22
+ /**
23
+ * VelaUxBuilder
24
+ */
25
+ declare class VelaUxBuilder extends UxBuilderBase<IUxBuilderOption> implements IBuilder<IUxBuilderOption> {
26
+ params: IParam[];
27
+ match(projectPath: string): boolean;
28
+ }
29
+ 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 ICompileOptions_1 = require("@aiot-toolkit/aiotpack/lib/interface/ICompileOptions");
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: ${ICompileOptions_1.skipList.join(',')}`,
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 = StringUtil_1.default.string2arrayByComma(value);
33
+ const res = shared_utils_1.StringUtil.string2arrayByComma(value);
37
34
  const unValid = res.find((r) => {
38
- return !ICompileOptions_1.skipList.includes(r);
35
+ return !aiotpack_2.skipList.includes(r);
39
36
  });
40
37
  if (unValid) {
41
- return `${unValid} is unvalidate, validate value are ${ICompileOptions_1.skipList.join(',')}, Multiple values separated by commas`;
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
- ColorConsole_1.default.success('Start build...\n', { word: 'ProjectPath: ', style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Success) }, projectPath, '\n', { word: 'buildOptions: ', style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Success) }, JSON.stringify(options));
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: StringUtil_1.default.string2arrayByComma(options.skip)
55
+ skip: shared_utils_1.StringUtil.string2arrayByComma(options.skip)
59
56
  };
60
- const config = new aiotpack_1.XtsConfig();
57
+ const config = new aiotpack_1.XtsConfig(projectPath);
61
58
  if ((_a = compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('xts2ts')) {
62
- ColorConsole_1.default.info("### skip compile xts to ts due to --skip ${compilerOptions?.skip.join(',')}");
63
- const context = FileLaneUtil_1.default.createContext(config.output, projectPath);
64
- const preWorks = config.preWorks || [];
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, [], config, compilerOptions);
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.followWorks || [];
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
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; } });
@@ -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': ISystemImagesVersionInfo;
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;