aiot-toolkit 2.0.2-dev.1 → 2.0.2-dev.3

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,41 +1,44 @@
1
- # `aiot-toolkit`
1
+ # 项目介绍
2
2
 
3
- > aiot-toolkit 命令行工具
3
+ aiot-toolkit 2.0 是将 **源码项目** 转换为 **目标代码项目** 并生成 **目标代码应用** 的命令行工具,同时配备了 **模拟器** 相关功能供开发者使用。
4
4
 
5
- ## 使用
5
+ aiot-toolkit2.0目前支持的打包格式如下:
6
6
 
7
- ## 贡献代码
7
+ - ux:vela 平台下的应用,目前大量使用于小米手表、音箱等智能穿戴及物联网设备
8
8
 
9
- ### 增加打包支持的项目
9
+ ## 安装使用
10
10
 
11
- 1. 在`./src/builder` 中新增类文件 XBuilder,并实现 IBuilder接口
11
+ - 全局安装
12
12
 
13
- ```js
14
- import ParamType from '@aiot-toolkit/commander/lib/interface/IParam'
15
- import IBuild from './IBuild'
13
+ `npm i aiot-toolkit -g`
16
14
 
17
- class XBuilder implements IBuild {
18
- params: ParamType[] = []
19
- build(projectPath: string, options: any): void {
20
- throw new Error('Method not implemented.')
21
- }
22
- match(projectPath: string): boolean {
23
- throw new Error('Method not implemented.')
24
- }
25
- }
26
- export default XBuilder
15
+ `npm i create-aiot -g`
27
16
 
28
- ```
17
+ - 创建项目
29
18
 
30
- 2. 实现对应的方法
31
- 3. 新增静态属性:
19
+ 1. `create-aiot ux`
20
+ 2. 在项目根目录执行:`npm i`
32
21
 
33
- ```js
34
- static readonly PROJECT_TYPE = '项目类型的名称'
35
- ```
22
+ - 本机运行项目
36
23
 
37
- 4. 在`./src/bin.ts` 的 `builderTypeList`中添加 XBuilder
24
+ 在项目根目录执行 `aiot start`,此会启动模拟器,并运行项目
38
25
 
39
- ```js
40
- const builderTypeList = [UxBuild, XtsBuild, XBuilder]
41
- ```
26
+ * 打包项目
27
+
28
+ 在项目根目录执行 `aiot release`
29
+
30
+ ## 常用命令
31
+
32
+ | 命令 | 说明 |
33
+ | ------------------------ | ------------------------ |
34
+ | npm create aiot | 创建并手动选择项目 |
35
+ | npm create aiot xts | 创建xts项目 |
36
+ | npm create aiot ux | 创建ux项目 |
37
+ | aiot build | 构建项目 |
38
+ | aiot release | 构建项目-release模式 |
39
+ | aiot start | 构建项目并运行到模拟器 |
40
+ | aiot getConnectedDevices | 获取已连接设备列表 |
41
+ | aiot getPlatforms | 获取设置平台 |
42
+ | aiot installDbgAndMkp | 在真机上安装快应用调试器 |
43
+ | aiot createVelaAvd | 创建 vela 模拟器 |
44
+ | aiot deleteVelaAvd | 删除 vela 模拟器 |
package/lib/bin.js CHANGED
@@ -64,7 +64,7 @@ function getProjectType() {
64
64
  else if (isXts) {
65
65
  return "xts" /* ProjectType.XTS */;
66
66
  }
67
- ColorConsole_1.default.throw(`Unsupported project type`);
67
+ return "ux" /* ProjectType.UX */;
68
68
  }
69
69
  function findStarter(command, description) {
70
70
  const projectType = getProjectType();
@@ -75,7 +75,7 @@ function main() {
75
75
  const config = {
76
76
  name: 'aiot-toolkit',
77
77
  description: 'contains build, dev, release, etc. commands for aiot toolkit',
78
- version: '2.0.1',
78
+ version: require('../package.json').version,
79
79
  commandList: [
80
80
  build('build', 'build project'),
81
81
  build('release', 'release the project'),
@@ -1,7 +1,12 @@
1
+ export interface ISystemImagesVersionInfo {
2
+ release: string;
3
+ dev: string;
4
+ }
5
+ export type ISystemImagesType = keyof ISystemImagesVersionInfo;
1
6
  export interface IGoldfishVersionInfo {
2
7
  name: string;
3
8
  emulator: string;
4
- 'system-images': string;
9
+ 'system-images': ISystemImagesVersionInfo;
5
10
  qa: string;
6
11
  skins: string;
7
12
  tools: string;
@@ -26,7 +26,7 @@ declare class VelaAvdUtils {
26
26
  /** 根据host获取模拟器下载地址 */
27
27
  static getEmulatorUrl(version?: string): string;
28
28
  /** 根据host获取vela镜像下载地址 */
29
- static getSystemImageUrl(version?: string, device?: string): string;
29
+ static getSystemImageUrl(version?: string): string;
30
30
  /** 根据host获取ya-vm-file-server下载地址 */
31
31
  static getv9fsToolUrl(version?: string): string;
32
32
  /** 获取资源文件下载地址 */
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const emulator_1 = require("@aiot-toolkit/emulator");
16
+ const constants_1 = require("@aiot-toolkit/emulator/lib/static/constants");
16
17
  const utils_1 = require("@aiot-toolkit/emulator/lib/utils");
17
18
  const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
18
19
  const prompts_1 = require("@inquirer/prompts");
@@ -108,8 +109,8 @@ class VelaAvdUtils {
108
109
  return `${VelaAvdUtils.emulatorBaseUrl}/v${version}/${hostOs}-${hostArch}.zip`;
109
110
  }
110
111
  /** 根据host获取vela镜像下载地址 */
111
- static getSystemImageUrl(version = '0.0.1', device = 'arm') {
112
- return `${VelaAvdUtils.systemImageBaseUrl}/v${version}/${device}/nuttx`;
112
+ static getSystemImageUrl(version = 'vela-release-4.0') {
113
+ return `${VelaAvdUtils.systemImageBaseUrl}/${version}/nuttx`;
113
114
  }
114
115
  /** 根据host获取ya-vm-file-server下载地址 */
115
116
  static getv9fsToolUrl(version = '0.0.1') {
@@ -146,10 +147,7 @@ class VelaAvdUtils {
146
147
  if (versionFileExist) {
147
148
  versionInfo = fs_extra_1.default.readJSONSync(versionFile);
148
149
  }
149
- // 下载version.json,保证每次下载的文件都是最新的版本
150
- yield VelaAvdUtils.downloadFromCdn(VelaAvdUtils.versionUrl, VelaAvdUtils.sdkHome, 'online-version.json');
151
- const onlineVersionFile = path_1.default.resolve(VelaAvdUtils.sdkHome, 'online-version.json');
152
- const onlineVersionInfo = fs_extra_1.default.readJSONSync(onlineVersionFile);
150
+ const onlineVersionInfo = constants_1.emulatorEnvVersion;
153
151
  // avdName
154
152
  const avdName = yield (0, prompts_1.input)({
155
153
  message: 'avd name starting with Vela. (eg. Vela_Virtual_Device)',
@@ -197,9 +195,12 @@ class VelaAvdUtils {
197
195
  });
198
196
  }
199
197
  // 镜像,TODO:后续需要考虑多种设备的镜像
200
- const avdArch = (yield (0, prompts_1.select)({
198
+ const velaImage = (yield (0, prompts_1.select)({
201
199
  message: 'vela image.',
202
- choices: [{ value: 'arm' }, { value: 'arm64' }]
200
+ choices: [
201
+ // { value: 'vela-release-4.0', name: 'vela正式版(4.0)' },
202
+ { value: 'vela-dev-0.0.2', name: 'vela开发版(dev, 0.0.2)' }
203
+ ]
203
204
  }));
204
205
  // 下载模拟器
205
206
  const emulatorDir = path_1.default.resolve(VelaAvdUtils.sdkHome, 'emulator');
@@ -210,11 +211,10 @@ class VelaAvdUtils {
210
211
  ColorConsole_1.default.success(`Download emulator succeed.`);
211
212
  }
212
213
  // 下载镜像
213
- const velaImageDownloadUrl = this.getSystemImageUrl(onlineVersionInfo['system-images'], avdArch);
214
- const imageDir = path_1.default.resolve(VelaAvdUtils.sdkHome, 'system-images', avdArch);
214
+ const velaImageDownloadUrl = this.getSystemImageUrl(velaImage);
215
+ const imageDir = path_1.default.resolve(VelaAvdUtils.sdkHome, 'system-images', velaImage);
215
216
  const imageExists = fs_extra_1.default.existsSync(path_1.default.resolve(imageDir, 'nuttx'));
216
- if (!imageExists ||
217
- (versionInfo && versionInfo['system-images'] < onlineVersionInfo['system-images'])) {
217
+ if (!imageExists) {
218
218
  yield VelaAvdUtils.downloadFromCdn(velaImageDownloadUrl, imageDir, 'nuttx');
219
219
  ColorConsole_1.default.success(`Download vela image succeed.`);
220
220
  }
@@ -240,13 +240,11 @@ class VelaAvdUtils {
240
240
  ColorConsole_1.default.success(`Download tools succeed.`);
241
241
  }
242
242
  // 替换version.json
243
- if (versionFileExist) {
244
- fs_extra_1.default.rmSync(versionFile);
245
- }
246
- fs_extra_1.default.renameSync(onlineVersionFile, versionFile);
243
+ const versionJson = JSON.stringify(onlineVersionInfo, null, 2);
244
+ fs_extra_1.default.writeFileSync(versionFile, versionJson);
247
245
  // 创建avd文本文件
248
246
  const avdImagePath = imageDir;
249
- const avdParams = { avdName, avdSkin, avdWidth, avdHeight, avdArch, avdImagePath };
247
+ const avdParams = { avdName, avdSkin, avdWidth, avdHeight, avdArch: emulator_1.IAvdArchType.arm, avdImagePath };
250
248
  VelaAvdUtils.velaAvdCls.createVelaAvd(avdParams);
251
249
  ColorConsole_1.default.success(`Create avd succeed.`);
252
250
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiot-toolkit",
3
- "version": "2.0.2-dev.1",
3
+ "version": "2.0.2-dev.3",
4
4
  "description": "Tools for creating, developing, and packaging aiot applications.",
5
5
  "keywords": [
6
6
  "aiot"
@@ -17,30 +17,26 @@
17
17
  "files": [
18
18
  "lib"
19
19
  ],
20
- "repository": {
21
- "type": "git",
22
- "url": "ssh://xujunjie1@git.mioffice.cn:29418/vela/aiot-toolkit"
23
- },
24
20
  "scripts": {
25
21
  "test": "node ./__tests__/aiot-toolkit.test.js"
26
22
  },
27
23
  "dependencies": {
28
- "@aiot-toolkit/commander": "2.0.2-dev.1",
29
- "@aiot-toolkit/emulator": "2.0.2-dev.1",
30
- "@aiot-toolkit/shared-utils": "2.0.2-dev.1",
24
+ "@aiot-toolkit/commander": "2.0.2-dev.3",
25
+ "@aiot-toolkit/emulator": "2.0.2-dev.3",
26
+ "@aiot-toolkit/shared-utils": "2.0.2-dev.3",
31
27
  "@miwt/adb": "^0.7.1",
32
28
  "adb-commander": "^0.1.9",
33
29
  "adm-zip": "^0.5.10",
34
30
  "axios": "^1.5.0",
35
31
  "cli-progress": "^3.12.0",
36
- "create-aiot": "2.0.2-dev.1",
32
+ "create-aiot": "2.0.2-dev.3",
37
33
  "fast-glob": "^3.3.2",
38
- "file-lane": "2.0.2-dev.1",
34
+ "file-lane": "2.0.2-dev.3",
39
35
  "ws": "^8.15.1"
40
36
  },
41
37
  "devDependencies": {
42
38
  "@types/adm-zip": "^0.5.4",
43
39
  "@types/ws": "^8.5.10"
44
40
  },
45
- "gitHead": "0beecc786c41b73ab2dabeaad06fb4ad19115f4b"
41
+ "gitHead": "e143a7038d5efaa59f01b2e2eb98422b1ec01097"
46
42
  }