aiot-toolkit 2.0.5-alpha.1 → 2.0.5-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.
package/README.md CHANGED
@@ -1,3 +1,12 @@
1
+ <!-- 此文档由 tools/createFile.ts 生成, 请勿手动修改 -->
2
+ <!--
3
+
4
+ 生成方法
5
+ 1. 修改 tools/README.template.md
6
+ 2. 修改 tools/VelaBuilderParam.json
7
+ 3. 执行 tools/createFile.ts
8
+ -->
9
+
1
10
  # 项目介绍
2
11
 
3
12
  aiot-toolkit 2.0 是将 **源码项目** 转换为 **目标代码项目** 并生成 **目标代码应用** 的命令行工具,同时配备了 **模拟器** 相关功能供开发者使用。
@@ -29,17 +38,54 @@ aiot-toolkit2.0目前支持的打包格式如下:
29
38
 
30
39
  ## 常用命令
31
40
 
32
- | 命令 | 说明 |
33
- | ------------------------ | ------------------------ |
34
- | npm create aiot | 创建并手动选择项目 |
35
- | npm create aiot ux | 创建ux项目 |
36
- | aiot build | 构建项目 |
37
- | aiot release | 构建项目-release模式 |
38
- | aiot start | 构建项目并运行到模拟器 |
39
- | aiot getConnectedDevices | 获取已连接设备列表 |
40
- | aiot getPlatforms | 获取设置平台 |
41
- | aiot installDbgAndMkp | 在真机上安装快应用调试器 |
42
- | aiot createVelaAvd | 创建 vela 模拟器 |
43
- | aiot deleteVelaAvd | 删除 vela 模拟器 |
44
-
45
- ## 函数调用
41
+ | 命令 | 说明 |
42
+ | ------------------------ | ---------------------------------------------- |
43
+ | npm create aiot | 创建并手动选择项目 |
44
+ | npm create aiot ux | 创建ux项目 |
45
+ | aiot build | 构建项目 |
46
+ | aiot release | 构建项目-release模式 |
47
+ | aiot start | 构建项目并运行到模拟器 |
48
+ | aiot getConnectedDevices | 获取已连接设备列表 |
49
+ | aiot getPlatforms | 获取设置平台 |
50
+ | aiot installDbgAndMkp | 在真机上安装快应用调试器 |
51
+ | aiot createVVD | 创建 vela 模拟器 |
52
+ | aiot deleteVVD | 删除 vela 模拟器 |
53
+ | aiot resign | build目录重新生成rpk, 详情: [resign](#resign) |
54
+
55
+ ## build 参数
56
+
57
+
58
+ | 参数 | 类型 | 描述 | 默认值 | 参考 |
59
+ | --- | --- | --- | --- | --- |
60
+ | *devtool* | string | source map 配置 | | https://www.webpackjs.com/configuration/devtool/#devtool |
61
+ | *enable-jsc* | confirm | 是否启用 jsc bundle | `false` | |
62
+ | *enable-protobuf* | confirm | 是否启用 `protobuf` | `false` | |
63
+ | *enable-e2e* | confirm | 是否为当前项目注入测试套件 | `false` | https://doc.quickapp.cn/tutorial/others/testing.html |
64
+ | *enable-stats* | confirm | 分析 webpack 输出文件的大小 | `false` | |
65
+ | *optimize-css-attr* | confirm | 优化压缩css名称 | `false` | |
66
+ | *complete-feature* | confirm | 自动将代码中使用的功能,补全到 manifest.json 的 features 字段中 | `false` | |
67
+ | *start-page* | string | 启动页面,示例:`--start-page 'pages/index?a=1&b=2'` | | |
68
+ | *~~enable-custom-component~~* | confirm | **已废弃** | | |
69
+ | *~~stats~~* | confirm | **已废弃** | | |
70
+
71
+ ## resign
72
+
73
+ build目录重新生成rpk
74
+
75
+ 步骤
76
+
77
+ 1. 创建任意名称的空目录, 例如 `folder`
78
+ 2. 将 `build` 复制到 `folder`
79
+ 3. (可跳过)如需自定义证书,将证书复制到 `folder/sign`
80
+ 4. 进入 `folder` 目录,执行 `aiot resign`,会在`foler/dist`中生成rpk
81
+ 5. 目录结构如下
82
+
83
+ ```sh
84
+ folder
85
+ build // 用户复制
86
+ sign // 用户复制,可选
87
+ certificate.pem
88
+ private.pem
89
+ dist // 生成
90
+ ***.rpk
91
+ ```
package/lib/bin.js CHANGED
@@ -13,6 +13,8 @@ var _VelaUxStarter = _interopRequireDefault(require("./starter/VelaUxStarter"));
13
13
  var _XtsStarter = _interopRequireDefault(require("./starter/XtsStarter"));
14
14
  var _DeviceUtil = _interopRequireDefault(require("./utils/DeviceUtil"));
15
15
  var _VelaAvdUtils = _interopRequireDefault(require("./utils/VelaAvdUtils"));
16
+ var _ZipUtil = _interopRequireDefault(require("@aiot-toolkit/aiotpack/lib/compiler/javascript/vela/utils/ZipUtil"));
17
+ var _BuildNameFormatType = _interopRequireDefault(require("@aiot-toolkit/aiotpack/lib/compiler/javascript/vela/enum/BuildNameFormatType"));
16
18
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
19
  // 支持的最低node版本
18
20
  const NODE_MINIMUM_VERSION = '18.0.0';
@@ -169,6 +171,22 @@ async function main() {
169
171
  action: async () => {
170
172
  _VelaAvdUtils.default.initEmulatorEnv();
171
173
  }
174
+ }, {
175
+ name: 'resign',
176
+ description: 'resign build folder to dist/rpk',
177
+ action: () => {
178
+ const projectPath = process.cwd();
179
+ const param = {
180
+ signRoot: 'sign',
181
+ mode: _aiotpack.CompileMode.DEVELOPMENT,
182
+ outputPath: 'build',
183
+ releasePath: 'dist',
184
+ projectPath,
185
+ buildNameFormat: _BuildNameFormatType.default.DEFAULT,
186
+ sourceRoot: 'build'
187
+ };
188
+ return _ZipUtil.default.createRpk(projectPath + '/build', param);
189
+ }
172
190
  }]
173
191
  };
174
192
  _commander.Command.registeProgram(config);
@@ -1,25 +1,7 @@
1
1
  import { IParam } from '@aiot-toolkit/commander';
2
2
  import IBuilder from './IBuilder';
3
- import UxBuilderBase, { IUxBuildOption } from './UxBuilderBase';
4
- export interface IVelaUxBuilderOption extends IUxBuildOption {
5
- watch?: boolean;
6
- enableJsc?: boolean;
7
- enableE2e?: boolean;
8
- enableStats?: boolean;
9
- optimizeCssAttr?: boolean;
10
- /**
11
- * 是否自动补全 manifest.json 中的 features 配置
12
- */
13
- completeFeature?: boolean;
14
- /**
15
- * 此选项控制是否生成,以及如何生成 source map
16
- *
17
- * @see https://www.webpackjs.com/configuration/devtool/#devtool
18
- */
19
- devtool?: string;
20
- enableProtobuf?: boolean;
21
- }
22
- export declare const velaUxBuilderParams: IParam[];
3
+ import UxBuilderBase from './UxBuilderBase';
4
+ import IVelaUxBuilderOption from '../interface/IVelaUxBuilderOption';
23
5
  /**
24
6
  * VelaUxBuilder
25
7
  */
@@ -3,70 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.velaUxBuilderParams = exports.default = void 0;
6
+ exports.default = void 0;
7
7
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
8
  var _UxBuilderBase = _interopRequireDefault(require("./UxBuilderBase"));
9
+ var _IVelaUxBuilderOption = require("../interface/IVelaUxBuilderOption");
9
10
  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
- type: 'string',
61
- name: 'e2e-config-path',
62
- description: 'e2e config file path, example: absolute=`/Desktop/e2e.config.js` relative project=`./test2/e2e.config.js`'
63
- }];
64
-
65
11
  /**
66
12
  * VelaUxBuilder
67
13
  */
68
14
  class VelaUxBuilder extends _UxBuilderBase.default {
69
- params = (() => velaUxBuilderParams)();
15
+ params = (() => _IVelaUxBuilderOption.velaUxBuilderParams)();
70
16
  match(projectPath) {
71
17
  return _sharedUtils.ProjectType.getProjectType(projectPath) === _sharedUtils.ProjectType.VELA_UX;
72
18
  }
@@ -0,0 +1,56 @@
1
+ /*****
2
+ * 由 tools/createFile.ts 生成, 请勿手动修改
3
+ *
4
+ * 生成方法
5
+ * 1. 修改 tools/VelaBuilderParam.json
6
+ * 2. 执行 tools/createFile.ts
7
+ */
8
+ import { IParam } from '@aiot-toolkit/commander';
9
+ import { IUxBuildOption } from '../builder/UxBuilderBase';
10
+ interface IVelaUxBuilderOption extends IUxBuildOption {
11
+ /**
12
+ * source map 配置
13
+ * @see https://www.webpackjs.com/configuration/devtool/#devtool
14
+ */
15
+ devtool?: string;
16
+ /**
17
+ * 是否启用 jsc bundle
18
+ */
19
+ enableJsc?: boolean;
20
+ /**
21
+ * 是否启用 `protobuf`
22
+ */
23
+ enableProtobuf?: boolean;
24
+ /**
25
+ * 是否为当前项目注入测试套件
26
+ * @see https://doc.quickapp.cn/tutorial/others/testing.html
27
+ */
28
+ enableE2e?: boolean;
29
+ /**
30
+ * 分析 webpack 输出文件的大小
31
+ */
32
+ enableStats?: boolean;
33
+ /**
34
+ * 优化压缩css名称
35
+ */
36
+ optimizeCssAttr?: boolean;
37
+ /**
38
+ * 自动将代码中使用的功能,补全到 manifest.json 的 features 字段中
39
+ */
40
+ completeFeature?: boolean;
41
+ /**
42
+ * 已废弃,请删除
43
+ */
44
+ enableCustomComponent?: boolean;
45
+ /**
46
+ * 已废弃,请使用 `enable-stats` 代替
47
+ */
48
+ stats?: boolean;
49
+ /**
50
+ * 启动页面,示例:`--start-page 'pages/index?a=1&b=2'`
51
+ */
52
+ startPage?: string;
53
+ }
54
+ declare const velaUxBuilderParams: IParam[];
55
+ export { velaUxBuilderParams };
56
+ export default IVelaUxBuilderOption;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.velaUxBuilderParams = void 0;
7
+ /*****
8
+ * 由 tools/createFile.ts 生成, 请勿手动修改
9
+ *
10
+ * 生成方法
11
+ * 1. 修改 tools/VelaBuilderParam.json
12
+ * 2. 执行 tools/createFile.ts
13
+ */
14
+
15
+ const velaUxBuilderParams = exports.velaUxBuilderParams = [{
16
+ "type": "string",
17
+ "name": "devtool",
18
+ "description": "source map config"
19
+ }, {
20
+ "type": "confirm",
21
+ "name": "enable-jsc",
22
+ "description": "enable jsc bundle",
23
+ "defaultValue": false
24
+ }, {
25
+ "type": "confirm",
26
+ "name": "enable-protobuf",
27
+ "description": "enable protobuf",
28
+ "defaultValue": false
29
+ }, {
30
+ "type": "confirm",
31
+ "name": "enable-e2e",
32
+ "description": "inject test-suite for current project",
33
+ "defaultValue": false
34
+ }, {
35
+ "type": "confirm",
36
+ "name": "enable-stats",
37
+ "description": "analyse time and size of webpack output files",
38
+ "defaultValue": false
39
+ }, {
40
+ "type": "confirm",
41
+ "name": "optimize-css-attr",
42
+ "description": "optimize css attr",
43
+ "defaultValue": false
44
+ }, {
45
+ "type": "confirm",
46
+ "name": "complete-feature",
47
+ "description": "auto complete the features are used in the code into the features field of the manifest.json file",
48
+ "defaultValue": false
49
+ }, {
50
+ "type": "confirm",
51
+ "name": "enable-custom-component",
52
+ "description": "deprecated",
53
+ "deprecated": "please remove it now",
54
+ "deprecatedVersion": "2.1.0"
55
+ }, {
56
+ "type": "confirm",
57
+ "name": "stats",
58
+ "description": "deprecated",
59
+ "deprecated": "please use `enable-stats` instead",
60
+ "deprecatedVersion": "2.1.0"
61
+ }, {
62
+ "type": "string",
63
+ "name": "start-page",
64
+ "description": "start page of current project, example: --start-page 'pages/index?a=1&b=2'"
65
+ }];
@@ -10,15 +10,14 @@ var _sharedUtils = require("@aiot-toolkit/shared-utils");
10
10
  var _prompts = require("@inquirer/prompts");
11
11
  var _path = _interopRequireDefault(require("path"));
12
12
  var _portfinder = _interopRequireDefault(require("portfinder"));
13
- var _VelaUxBuilder = _interopRequireWildcard(require("../builder/VelaUxBuilder"));
13
+ var _VelaUxBuilder = _interopRequireDefault(require("../builder/VelaUxBuilder"));
14
14
  var _VelaAvdUtils = _interopRequireDefault(require("../utils/VelaAvdUtils"));
15
15
  var _IStarter = _interopRequireDefault(require("./IStarter"));
16
16
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
17
17
  var _aiotpack = require("@aiot-toolkit/aiotpack");
18
18
  var _events = _interopRequireDefault(require("events"));
19
19
  var _FileLaneTriggerType = _interopRequireDefault(require("file-lane/lib/enum/FileLaneTriggerType"));
20
- 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); }
21
- 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; }
20
+ var _IVelaUxBuilderOption = require("../interface/IVelaUxBuilderOption");
22
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
23
22
  /**
24
23
  * VelaUxStarter
@@ -61,7 +60,7 @@ class VelaUxStarter extends _IStarter.default {
61
60
  description: 'deprecated',
62
61
  deprecated: 'please remove it now',
63
62
  deprecatedVersion: '2.1.0'
64
- }, ..._VelaUxBuilder.velaUxBuilderParams])();
63
+ }, ..._IVelaUxBuilderOption.velaUxBuilderParams])();
65
64
  async start(projectPath, options) {
66
65
  const check = await _VelaAvdUtils.default.checkEmulatorEnv();
67
66
  if (!check) {
@@ -126,7 +125,7 @@ class VelaUxStarter extends _IStarter.default {
126
125
  if (!this.emulatorInstance) {
127
126
  throw new Error('emulatorInstance is undefined');
128
127
  }
129
- const projectInfo = _aiotpack.UxFileUtils.getMainfestInfo(projectPath, compilerOption.sourceRoot);
128
+ const projectInfo = _aiotpack.UxFileUtils.getManifestInfo(projectPath, compilerOption.sourceRoot);
130
129
  if (this.lastRpk && _fsExtra.default.existsSync(this.lastRpk)) {
131
130
  const targetPath = await this.emulatorInstance?.pushRpk(this.lastRpk, projectInfo.package);
132
131
  await this.emulatorInstance?.install(targetPath, projectInfo.package);
@@ -61,7 +61,7 @@ class VelaVvdUtils {
61
61
  let width = '466';
62
62
  let height = '466';
63
63
  // vela4.0不允许自定义分辨率
64
- if (velaImage === _emulator.VelaImageType.REL) {
64
+ if ((0, _emulator.isMiwearImageType)(velaImage)) {
65
65
  const needSkin = await (0, _prompts.confirm)({
66
66
  message: 'need vvd skin?',
67
67
  default: true
@@ -94,6 +94,7 @@ class VelaVvdUtils {
94
94
  });
95
95
  if ((await vvdManager.hasSDKPartUpdate()).length > 0) {
96
96
  const downloder = await vvdManager.downloadSDK({
97
+ imageTypeArr: [velaImage],
97
98
  force: false,
98
99
  cliProgress: true,
99
100
  parallelDownloads: 6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiot-toolkit",
3
- "version": "2.0.5-alpha.1",
3
+ "version": "2.0.5-beta.1",
4
4
  "description": "Tools for creating, developing, and packaging aiot applications.",
5
5
  "keywords": [
6
6
  "aiot"
@@ -22,14 +22,14 @@
22
22
  "test": "node ./__tests__/aiot-toolkit.test.js"
23
23
  },
24
24
  "dependencies": {
25
- "@aiot-toolkit/aiotpack": "2.0.5-alpha.1",
26
- "@aiot-toolkit/commander": "2.0.5-alpha.1",
27
- "@aiot-toolkit/emulator": "2.0.5-alpha.1",
28
- "@aiot-toolkit/shared-utils": "2.0.5-alpha.1",
25
+ "@aiot-toolkit/aiotpack": "2.0.5-beta.1",
26
+ "@aiot-toolkit/commander": "2.0.5-beta.1",
27
+ "@aiot-toolkit/emulator": "2.0.5-beta.1",
28
+ "@aiot-toolkit/shared-utils": "2.0.5-beta.1",
29
29
  "@inquirer/prompts": "^5.3.0",
30
30
  "@miwt/adb": "^0.9.0",
31
31
  "axios": "^1.7.4",
32
- "file-lane": "2.0.5-alpha.1",
32
+ "file-lane": "2.0.5-beta.1",
33
33
  "fs-extra": "^11.2.0",
34
34
  "koa-router": "^13.0.1",
35
35
  "lodash": "^4.17.21",
@@ -43,5 +43,5 @@
43
43
  "@types/qr-image": "^3.2.9",
44
44
  "@types/semver": "^7.5.8"
45
45
  },
46
- "gitHead": "8c8033a7a52e7cdb83606298ed8c4d6a585ba3ec"
46
+ "gitHead": "44f8c6ee763bc01bd53c655b93e09c698057fc3e"
47
47
  }