aiot-toolkit 2.0.1-alpha.8 → 2.0.2-dev.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 (36) hide show
  1. package/lib/bin.js +79 -37
  2. package/lib/builder/IBuilder.js +0 -2
  3. package/lib/builder/UxBuilder.d.ts +1 -0
  4. package/lib/builder/UxBuilder.js +37 -14
  5. package/lib/builder/XtsBuilder.d.ts +2 -1
  6. package/lib/builder/XtsBuilder.js +52 -12
  7. package/lib/interface/CommandInterface.js +0 -2
  8. package/lib/interface/VelaEmulatorInterface.js +0 -2
  9. package/lib/starter/IStarter.d.ts +23 -0
  10. package/lib/starter/IStarter.js +45 -0
  11. package/lib/starter/UxStarter.d.ts +10 -0
  12. package/lib/starter/UxStarter.js +136 -0
  13. package/lib/starter/XtsStarter.d.ts +9 -0
  14. package/lib/starter/XtsStarter.js +16 -0
  15. package/lib/utils/AdbUtils.js +2 -11
  16. package/lib/utils/DeviceUtil.d.ts +1 -1
  17. package/lib/utils/DeviceUtil.js +22 -93
  18. package/lib/utils/RequestUtils.js +4 -19
  19. package/lib/utils/VelaAvdUtils.d.ts +1 -1
  20. package/lib/utils/VelaAvdUtils.js +22 -61
  21. package/lib/waiter.js +0 -2
  22. package/package.json +11 -7
  23. package/lib/bin.js.map +0 -1
  24. package/lib/builder/IBuilder.js.map +0 -1
  25. package/lib/builder/UxBuilder.js.map +0 -1
  26. package/lib/builder/XtsBuilder.js.map +0 -1
  27. package/lib/interface/CommandInterface.js.map +0 -1
  28. package/lib/interface/VelaEmulatorInterface.js.map +0 -1
  29. package/lib/starter/GoldfishStarter.d.ts +0 -9
  30. package/lib/starter/GoldfishStarter.js +0 -108
  31. package/lib/starter/GoldfishStarter.js.map +0 -1
  32. package/lib/utils/AdbUtils.js.map +0 -1
  33. package/lib/utils/DeviceUtil.js.map +0 -1
  34. package/lib/utils/RequestUtils.js.map +0 -1
  35. package/lib/utils/VelaAvdUtils.js.map +0 -1
  36. package/lib/waiter.js.map +0 -1
@@ -35,7 +35,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- const shared_utils_1 = require("@aiot-toolkit/shared-utils");
39
38
  const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
40
39
  const adbMiwt = __importStar(require("@miwt/adb"));
41
40
  const adb_commander_1 = __importDefault(require("adb-commander"));
@@ -77,18 +76,12 @@ class AdbUtils {
77
76
  const adbShell = adbMiwt.execAdbCmd(`adb -s ${deviceSn} shell am start -n "org.hapjs.debugger/.MainActivity"`);
78
77
  adbShell.stdout.on('data', (data) => {
79
78
  // 监听stderr事件,获取输出内容
80
- ColorConsole_1.default.log({
81
- message: data
82
- });
79
+ ColorConsole_1.default.log(`### startDebugger ### ${data}`);
83
80
  });
84
81
  adbShell.stderr.on('data', (data) => {
85
82
  // 监听stderr事件,获取输出内容
86
83
  if (data.indexOf('Error') >= 0) {
87
- ColorConsole_1.default.log({
88
- level: shared_utils_1.LOG_LEVEL.Error,
89
- message: data
90
- });
91
- process.exit();
84
+ ColorConsole_1.default.throw(`### startDebugger ### ${data}`);
92
85
  }
93
86
  });
94
87
  adbShell.on('close', () => {
@@ -99,5 +92,3 @@ class AdbUtils {
99
92
  }
100
93
  }
101
94
  exports.default = AdbUtils;
102
-
103
- //# sourceMappingURL=AdbUtils.js.map
@@ -10,7 +10,7 @@ declare class DeviceUtil {
10
10
  * 获取连接上的所有设备数组,供IDE使用
11
11
  * @returns
12
12
  */
13
- static getAllConnectedDevices(): Promise<string[]>;
13
+ static getAllConnectedDevices(): Promise<string[] | undefined> | undefined;
14
14
  /**
15
15
  * 安装调试器、预览版
16
16
  * @param options
@@ -31,28 +31,16 @@ class DeviceUtil {
31
31
  try {
32
32
  return AdbUtils_1.default.getAllConnectedDevices().then((deviceList) => {
33
33
  if (deviceList.length > 0) {
34
- ColorConsole_1.default.log({
35
- message: `Devices connected via adb: ${deviceList.join(', ')}.`
36
- });
34
+ ColorConsole_1.default.info(`Devices connected via adb: ${deviceList.join(', ')}.`);
37
35
  return Promise.resolve(deviceList);
38
36
  }
39
37
  else {
40
- ColorConsole_1.default.log({
41
- level: shared_utils_1.LOG_LEVEL.Error,
42
- message: `No device is currently connected, please check the following preparations in turn:\n 1. Whether the device is started;\n 2. Whether in the same LAN WI-FI;\n 3. Whether the device can be connected to the computer via USB;`,
43
- isOnlyPrintError: true
44
- });
45
- process.exit();
38
+ ColorConsole_1.default.throw(`No device is currently connected, please check the following preparations in turn:\n 1. Whether the device is started;\n 2. Whether in the same LAN WI-FI;\n 3. Whether the device can be connected to the computer via USB;`);
46
39
  }
47
40
  });
48
41
  }
49
42
  catch (error) {
50
- ColorConsole_1.default.log({
51
- level: shared_utils_1.LOG_LEVEL.Error,
52
- message: 'Error getting connection information of adb device',
53
- isOnlyPrintError: true
54
- });
55
- process.exit();
43
+ ColorConsole_1.default.throw('Error getting connection information of adb device');
56
44
  }
57
45
  }
58
46
  /**
@@ -75,11 +63,7 @@ class DeviceUtil {
75
63
  connectDeviceList = finalDeviceList ? [...finalDeviceList] : [];
76
64
  // 若connectDeviceList为空,应该warn并结束程序
77
65
  connectDeviceList.length <= 0 &&
78
- ColorConsole_1.default.log({
79
- message: 'No device requires debugger or previewer installation',
80
- level: shared_utils_1.LOG_LEVEL.Warn
81
- }) &&
82
- process.exit();
66
+ ColorConsole_1.default.throw('No device requires debugger or previewer installation');
83
67
  // 3. 下载并获取调试器、预览器地址
84
68
  const debuggerPath = yield this.downloadApk(options, true);
85
69
  const previewPath = yield this.downloadApk(options, false);
@@ -89,7 +73,7 @@ class DeviceUtil {
89
73
  return Promise.resolve('All devices successfully installed the Quickapp debugger and previewer');
90
74
  }
91
75
  catch (error) {
92
- return Promise.reject(new Error(`Failed to install debugger, error message:${error.message}`));
76
+ return Promise.reject(new Error(`Failed to install debugger, error message:${(error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'}`));
93
77
  }
94
78
  });
95
79
  }
@@ -122,21 +106,14 @@ class DeviceUtil {
122
106
  }
123
107
  }
124
108
  if (ip.length === 0) {
125
- ColorConsole_1.default.log({
126
- message: `Since no ip address is entered, the connected device will be connected`
127
- });
109
+ ColorConsole_1.default.log(`Since no ip address is entered, the connected device will be connected`);
128
110
  return Promise.resolve();
129
111
  }
130
112
  const ips = ip.trim().split(',');
131
113
  const invalidIps = ips.filter((ip) => !this.ipRegExp.test(ip));
132
114
  if (invalidIps && invalidIps.length) {
133
115
  invalidIps.map((ip) => {
134
- ColorConsole_1.default.log({
135
- message: `ip: ${ip} is invalid IP`,
136
- level: shared_utils_1.LOG_LEVEL.Error,
137
- isOnlyPrintError: true
138
- });
139
- process.exit();
116
+ ColorConsole_1.default.throw(`ip: `, { word: ip, style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Throw) }, ` is invalid IP`);
140
117
  });
141
118
  }
142
119
  else {
@@ -147,26 +124,16 @@ class DeviceUtil {
147
124
  });
148
125
  return AdbUtils_1.default.connect(ip, devicePort)
149
126
  .then(() => {
150
- ColorConsole_1.default.log({
151
- level: shared_utils_1.LOG_LEVEL.Success,
152
- message: `wifi connection ip: The device with ip of "${ip}" succeeded`
153
- });
127
+ ColorConsole_1.default.success(`wifi connection ip: The device with ip of "${ip}" succeeded`);
154
128
  return Promise.resolve();
155
129
  })
156
130
  .catch((err) => {
157
- ColorConsole_1.default.log({
158
- level: shared_utils_1.LOG_LEVEL.Error,
159
- message: err,
160
- isOnlyPrintError: true
161
- });
162
- process.exit();
131
+ ColorConsole_1.default.throw(`${err}`);
163
132
  });
164
133
  }));
165
134
  return Promise.all(newDeviceListPromiseArray)
166
135
  .then(() => {
167
- ColorConsole_1.default.log({
168
- message: 'All new WIFI devices are connected'
169
- });
136
+ ColorConsole_1.default.log(`All new WIFI devices are connected`);
170
137
  return Promise.resolve();
171
138
  })
172
139
  .catch(() => {
@@ -187,10 +154,7 @@ class DeviceUtil {
187
154
  static queryDevice(deviceList, orderText = '') {
188
155
  return __awaiter(this, void 0, void 0, function* () {
189
156
  if (!deviceList || deviceList.length === 0) {
190
- ColorConsole_1.default.log({
191
- message: `No device is connected yet, please confirm and try again`,
192
- level: shared_utils_1.LOG_LEVEL.Error
193
- });
157
+ ColorConsole_1.default.throw(`No device is connected yet, please confirm and try again`);
194
158
  return;
195
159
  }
196
160
  const ALL_TEXT = 'All connected devices';
@@ -228,29 +192,20 @@ class DeviceUtil {
228
192
  const apkPath = path_1.default.join(__dirname, './apk/', fileName);
229
193
  if (fs_1.default.existsSync(apkPath)) {
230
194
  // apk已下载
231
- ColorConsole_1.default.log({
232
- message: 'The installation package has been downloaded, now use the cache file to install'
233
- });
195
+ ColorConsole_1.default.log(`The installation package has been downloaded, now use the cache file to install`);
234
196
  return apkPath;
235
197
  }
236
198
  else {
237
199
  try {
238
200
  const result = yield RequestUtils_1.default.downloadFile(url, fileName);
239
201
  // 打印出成功信息
240
- ColorConsole_1.default.log({
241
- message: `Success to download, ${result}`,
242
- level: shared_utils_1.LOG_LEVEL.Success
243
- });
202
+ ColorConsole_1.default.success(`Success to download, ${result}`);
244
203
  return apkPath;
245
204
  }
246
205
  catch (error) {
247
206
  // 打印出错误
248
- ColorConsole_1.default.log({
249
- message: `Failed to download the installation package, ${error}`,
250
- level: shared_utils_1.LOG_LEVEL.Error,
251
- isOnlyPrintError: true
252
- });
253
- process.exit();
207
+ ColorConsole_1.default.throw(`Failed to download the installation package, ${error}`);
208
+ return '';
254
209
  }
255
210
  }
256
211
  });
@@ -272,11 +227,7 @@ class DeviceUtil {
272
227
  let countTime = 0;
273
228
  let data;
274
229
  const sleep = () => {
275
- ColorConsole_1.default.log({
276
- level: shared_utils_1.LOG_LEVEL.Error,
277
- message: `Error when the device gets running platforms,request again after 3s delay`,
278
- isOnlyPrintError: true
279
- });
230
+ ColorConsole_1.default.error(`Error when the device gets running platforms,request again after 3s delay`);
280
231
  return new Promise((resolve) => setTimeout(resolve, 3000));
281
232
  };
282
233
  const requestPlatform = () => __awaiter(this, void 0, void 0, function* () {
@@ -291,27 +242,17 @@ class DeviceUtil {
291
242
  const dataObj = JSON.parse(data);
292
243
  if (!dataObj.availablePlatforms) {
293
244
  // 请求结果不存在平台信息,报错,结束程序
294
- ColorConsole_1.default.log({
295
- level: shared_utils_1.LOG_LEVEL.Error,
296
- message: `the request result no avaliable platform `
297
- });
298
- process.exit();
245
+ ColorConsole_1.default.throw(`The request result no avaliable platform `);
299
246
  }
300
247
  else {
301
248
  // 打印请求的平台信息
302
249
  const availablePlatforms = dataObj.availablePlatforms;
303
- ColorConsole_1.default.log({
304
- message: `The Quickapp engine list of device "${deviceSn}" is:${availablePlatforms.join(',')}`
305
- });
250
+ ColorConsole_1.default.log(`The Quickapp engine list of device "${deviceSn}" is:${availablePlatforms.join(',')}`);
306
251
  }
307
252
  }
308
253
  else {
309
254
  //请求失败,结束程序
310
- ColorConsole_1.default.log({
311
- level: shared_utils_1.LOG_LEVEL.Error,
312
- message: `the device gets running platforms error`
313
- });
314
- process.exit();
255
+ ColorConsole_1.default.throw(`The device gets running platforms error`);
315
256
  }
316
257
  });
317
258
  // 先打开调试器,才能获取运行平台
@@ -319,10 +260,7 @@ class DeviceUtil {
319
260
  yield requestPlatform();
320
261
  }
321
262
  catch (error) {
322
- ColorConsole_1.default.log({
323
- level: shared_utils_1.LOG_LEVEL.Error,
324
- message: `Error getting the list of Quickapp engines on the device, error message:${error.message}`
325
- });
263
+ ColorConsole_1.default.throw(`Error getting the list of Quickapp engines on the device`);
326
264
  }
327
265
  });
328
266
  }
@@ -341,17 +279,10 @@ class DeviceUtil {
341
279
  const apkName = path_1.default.basename(apkPath);
342
280
  return Promise.all(newDeviceListPromiseArray)
343
281
  .then(() => {
344
- ColorConsole_1.default.log({
345
- level: shared_utils_1.LOG_LEVEL.Success,
346
- message: `All devices installed ${apkName}`
347
- });
282
+ ColorConsole_1.default.success(`All devices installed ${apkName}`);
348
283
  })
349
284
  .catch(() => {
350
- ColorConsole_1.default.log({
351
- level: shared_utils_1.LOG_LEVEL.Error,
352
- message: `Installed ${apkName} failed`
353
- });
354
- process.exit();
285
+ ColorConsole_1.default.throw(`Installed ${apkName} failed`);
355
286
  });
356
287
  }
357
288
  catch (error) { }
@@ -362,5 +293,3 @@ DeviceUtil.ipRegExp = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0
362
293
  DeviceUtil.CLIENT_PORT = 39517;
363
294
  DeviceUtil.quickapp_url = 'https://statres.quickapp.cn/quickapp/quickapptool/release/platform/';
364
295
  exports.default = DeviceUtil;
365
-
366
- //# sourceMappingURL=DeviceUtil.js.map
@@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const shared_utils_1 = require("@aiot-toolkit/shared-utils");
16
15
  const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
17
16
  const axios_1 = __importDefault(require("axios"));
18
17
  const fs_extra_1 = __importDefault(require("fs-extra"));
@@ -39,26 +38,16 @@ class RequestUtils {
39
38
  axios_1.default
40
39
  .post(requrl, options)
41
40
  .then((data) => {
42
- ColorConsole_1.default.log({
43
- message: `### App Server ### Request ${requrl} succeeded`
44
- });
41
+ ColorConsole_1.default.log(`### App Server ### Request ${requrl} succeeded`);
45
42
  resolve(data.toString());
46
43
  })
47
44
  .catch((error) => {
48
45
  if (error.respose && error.response.status === 408) {
49
46
  // 超时处理
50
- ColorConsole_1.default.log({
51
- level: shared_utils_1.LOG_LEVEL.Error,
52
- message: `### App Server ### Request ${requrl} timed out, please try again`,
53
- isOnlyPrintError: true
54
- });
47
+ ColorConsole_1.default.error(`### App Server ### Request ${requrl} timed out, please try again`);
55
48
  }
56
49
  else {
57
- ColorConsole_1.default.log({
58
- level: shared_utils_1.LOG_LEVEL.Error,
59
- message: `### App Server ### Request ${requrl} error message: ${error.message}`,
60
- isOnlyPrintError: true
61
- });
50
+ ColorConsole_1.default.error(`### App Server ### Request ${requrl} error message: ${(error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'}`);
62
51
  }
63
52
  });
64
53
  });
@@ -67,9 +56,7 @@ class RequestUtils {
67
56
  static downloadFile(url, fileName) {
68
57
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
69
58
  // 开始下载
70
- ColorConsole_1.default.log({
71
- message: `Start downloading file:${fileName}, address:${url}`
72
- });
59
+ ColorConsole_1.default.log(`Start downloading file:${fileName}, address:${url}`);
73
60
  const response = yield axios_1.default.get(url, {
74
61
  responseType: 'arraybuffer'
75
62
  });
@@ -86,5 +73,3 @@ class RequestUtils {
86
73
  }
87
74
  }
88
75
  exports.default = RequestUtils;
89
-
90
- //# sourceMappingURL=RequestUtils.js.map
@@ -30,7 +30,7 @@ declare class VelaAvdUtils {
30
30
  /** 根据host获取ya-vm-file-server下载地址 */
31
31
  static getv9fsToolUrl(version?: string): string;
32
32
  /** 获取资源文件下载地址 */
33
- static getDownloadUrl(file: string, version?: string): string;
33
+ static getDownloadUrl(dir: string, version?: string, filename?: string): string;
34
34
  /**
35
35
  * 命令行访问方式创建模拟器
36
36
  */
@@ -13,7 +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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
16
+ const utils_1 = require("@aiot-toolkit/emulator/lib/utils");
17
17
  const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
18
18
  const prompts_1 = require("@inquirer/prompts");
19
19
  const adm_zip_1 = __importDefault(require("adm-zip"));
@@ -68,11 +68,7 @@ class VelaAvdUtils {
68
68
  });
69
69
  }
70
70
  catch (e) {
71
- ColorConsole_1.default.log({
72
- level: shared_utils_1.LOG_LEVEL.Error,
73
- message: `download ${filename} failed`
74
- });
75
- progress.stop();
71
+ ColorConsole_1.default.throw(`Download ${filename} failed`);
76
72
  reject();
77
73
  }
78
74
  }));
@@ -107,24 +103,8 @@ class VelaAvdUtils {
107
103
  /** 根据host获取模拟器下载地址 */
108
104
  static getEmulatorUrl(version = '0.0.1') {
109
105
  const systemOs = os_1.default.platform();
110
- const arch = os_1.default.arch();
111
- let hostOs = '';
112
- let hostArch = '';
113
- switch (systemOs) {
114
- case 'linux':
115
- hostOs = 'linux';
116
- hostArch = arch === 'x64' ? 'x86_64' : 'aarch64';
117
- break;
118
- case 'win32':
119
- hostOs = 'windows';
120
- hostArch = arch === 'x64' ? 'x86_64' : 'aarch64';
121
- break;
122
- case 'darwin':
123
- hostOs = 'darwin';
124
- hostArch = arch === 'x64' ? 'x86_64' : 'aarch64';
125
- default:
126
- break;
127
- }
106
+ const hostArch = (0, utils_1.getSystemArch)();
107
+ let hostOs = systemOs === 'win32' ? 'windows' : systemOs;
128
108
  return `${VelaAvdUtils.emulatorBaseUrl}/v${version}/${hostOs}-${hostArch}.zip`;
129
109
  }
130
110
  /** 根据host获取vela镜像下载地址 */
@@ -134,25 +114,25 @@ class VelaAvdUtils {
134
114
  /** 根据host获取ya-vm-file-server下载地址 */
135
115
  static getv9fsToolUrl(version = '0.0.1') {
136
116
  const systemOs = os_1.default.platform();
137
- const arch = os_1.default.arch();
117
+ const arch = (0, utils_1.getSystemArch)();
138
118
  let v9fsTool = '';
139
119
  switch (systemOs) {
140
120
  case 'linux':
141
- v9fsTool = 'ya-vm-file-server-linux-x86_64';
121
+ v9fsTool = `ya-vm-file-server-linux-${arch}`;
142
122
  break;
143
123
  case 'win32':
144
124
  v9fsTool = 'ya-vm-file-server-windows.exe';
145
125
  break;
146
126
  case 'darwin':
147
- v9fsTool = (arch === 'x64') ? 'ya-vm-file-server-darwin-x84_64' : 'ya-vm-file-server-darwin-aarch64';
127
+ v9fsTool = `ya-vm-file-server-darwin-${arch}`;
148
128
  default:
149
129
  break;
150
130
  }
151
131
  return `${VelaAvdUtils.baseUrl}/tools/v${version}/${v9fsTool}`;
152
132
  }
153
133
  /** 获取资源文件下载地址 */
154
- static getDownloadUrl(file, version = '0.0.1') {
155
- return `${VelaAvdUtils.baseUrl}/${file}/v${version}/${file}.zip`;
134
+ static getDownloadUrl(dir, version = '0.0.1', filename = dir) {
135
+ return `${VelaAvdUtils.baseUrl}/${dir}/v${version}/${filename}.zip`;
156
136
  }
157
137
  /**
158
138
  * 命令行访问方式创建模拟器
@@ -192,10 +172,7 @@ class VelaAvdUtils {
192
172
  if (!skinExists || (versionInfo && versionInfo.skins < onlineVersionInfo.skins)) {
193
173
  const skinsUrl = VelaAvdUtils.getDownloadUrl('skins', onlineVersionInfo.skins);
194
174
  yield VelaAvdUtils.downloadAndUnzip(skinsUrl, path_1.default.resolve(VelaAvdUtils.sdkHome, 'skins'));
195
- ColorConsole_1.default.log({
196
- level: shared_utils_1.LOG_LEVEL.Success,
197
- message: `download skins succeed.`
198
- });
175
+ ColorConsole_1.default.success(`Download skins succeed.`);
199
176
  }
200
177
  const skinList = VelaAvdUtils.velaAvdCls.getVelaSkinList();
201
178
  avdSkin = yield (0, prompts_1.select)({
@@ -230,10 +207,7 @@ class VelaAvdUtils {
230
207
  if (!emulatorExists || (versionInfo && versionInfo.emulator < onlineVersionInfo.emulator)) {
231
208
  const emulatorDownloadUrl = VelaAvdUtils.getEmulatorUrl(onlineVersionInfo.emulator);
232
209
  yield VelaAvdUtils.downloadAndUnzip(emulatorDownloadUrl, emulatorDir);
233
- ColorConsole_1.default.log({
234
- level: shared_utils_1.LOG_LEVEL.Success,
235
- message: `download emulator succeed.`
236
- });
210
+ ColorConsole_1.default.success(`Download emulator succeed.`);
237
211
  }
238
212
  // 下载镜像
239
213
  const velaImageDownloadUrl = this.getSystemImageUrl(onlineVersionInfo['system-images'], avdArch);
@@ -242,10 +216,7 @@ class VelaAvdUtils {
242
216
  if (!imageExists ||
243
217
  (versionInfo && versionInfo['system-images'] < onlineVersionInfo['system-images'])) {
244
218
  yield VelaAvdUtils.downloadFromCdn(velaImageDownloadUrl, imageDir, 'nuttx');
245
- ColorConsole_1.default.log({
246
- level: shared_utils_1.LOG_LEVEL.Success,
247
- message: `download vela image succeed.`
248
- });
219
+ ColorConsole_1.default.success(`Download vela image succeed.`);
249
220
  }
250
221
  // 下载快应用qa文件
251
222
  const qaDir = path_1.default.resolve(VelaAvdUtils.sdkHome, 'qa');
@@ -253,22 +224,20 @@ class VelaAvdUtils {
253
224
  if (!qaExists || (versionInfo && versionInfo.qa < onlineVersionInfo.qa)) {
254
225
  const qaUrl = VelaAvdUtils.getDownloadUrl('qa', onlineVersionInfo.qa);
255
226
  yield VelaAvdUtils.downloadAndUnzip(qaUrl, qaDir);
256
- ColorConsole_1.default.log({
257
- level: shared_utils_1.LOG_LEVEL.Success,
258
- message: `download quickapp font succeed.`
259
- });
227
+ ColorConsole_1.default.success(`Download quickapp font succeed.`);
260
228
  }
261
229
  // 下载tools
262
230
  const toolsDir = path_1.default.resolve(VelaAvdUtils.sdkHome, 'tools');
263
231
  const toolsExists = fs_extra_1.default.existsSync(toolsDir);
264
232
  if (!toolsExists || (versionInfo && versionInfo.tools < onlineVersionInfo.tools)) {
265
233
  const v9fsToolUrl = VelaAvdUtils.getv9fsToolUrl();
266
- const filename = (os_1.default.platform() === 'win32') ? 'ya-vm-file-server.exe' : 'ya-vm-file-server';
234
+ const filename = os_1.default.platform() === 'win32' ? 'ya-vm-file-server.exe' : 'ya-vm-file-server';
267
235
  yield VelaAvdUtils.downloadFromCdn(v9fsToolUrl, toolsDir, filename);
268
- ColorConsole_1.default.log({
269
- level: shared_utils_1.LOG_LEVEL.Success,
270
- message: `download tools succeed.`
271
- });
236
+ // 后续使用fatfs+adb push方式需要下载相关镜像
237
+ // const imageUrl = VelaAvdUtils.getDownloadUrl('tools', onlineVersionInfo.tools, 'image')
238
+ // const imageDir = path.resolve(toolsDir, 'image')
239
+ // await VelaAvdUtils.downloadAndUnzip(imageUrl, imageDir)
240
+ ColorConsole_1.default.success(`Download tools succeed.`);
272
241
  }
273
242
  // 替换version.json
274
243
  if (versionFileExist) {
@@ -279,16 +248,10 @@ class VelaAvdUtils {
279
248
  const avdImagePath = imageDir;
280
249
  const avdParams = { avdName, avdSkin, avdWidth, avdHeight, avdArch, avdImagePath };
281
250
  VelaAvdUtils.velaAvdCls.createVelaAvd(avdParams);
282
- ColorConsole_1.default.log({
283
- level: shared_utils_1.LOG_LEVEL.Success,
284
- message: `create avd succeed.`
285
- });
251
+ ColorConsole_1.default.success(`Create avd succeed.`);
286
252
  }
287
253
  catch (e) {
288
- ColorConsole_1.default.log({
289
- level: shared_utils_1.LOG_LEVEL.Error,
290
- message: `create avd failed. Error: ${e.message}`
291
- });
254
+ ColorConsole_1.default.throw(`Create avd failed. Error: ${e.message}`);
292
255
  }
293
256
  });
294
257
  }
@@ -296,7 +259,7 @@ class VelaAvdUtils {
296
259
  VelaAvdUtils.sdkHome = path_1.default.resolve(os_1.default.homedir(), '.export');
297
260
  VelaAvdUtils.avdHome = path_1.default.resolve(os_1.default.homedir(), '.android', 'avd');
298
261
  VelaAvdUtils.baseUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide';
299
- VelaAvdUtils.versionUrl = 'https://cdn.cnbj3-fusion.fds.api.mi-img.com/vela-ide/versions.json';
262
+ VelaAvdUtils.versionUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide/versions.json';
300
263
  VelaAvdUtils.emulatorBaseUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide/emulator';
301
264
  VelaAvdUtils.systemImageBaseUrl = 'https://vela-ide.cnbj3-fusion.mi-fds.com/vela-ide/system-images';
302
265
  VelaAvdUtils.velaAvdCls = new emulator_1.VelaAvdCls({
@@ -304,5 +267,3 @@ VelaAvdUtils.velaAvdCls = new emulator_1.VelaAvdCls({
304
267
  avdHome: VelaAvdUtils.avdHome
305
268
  });
306
269
  exports.default = VelaAvdUtils;
307
-
308
- //# sourceMappingURL=VelaAvdUtils.js.map
package/lib/waiter.js CHANGED
@@ -35,5 +35,3 @@ const waiter = new commander_1.PersistentCommand({
35
35
  ]
36
36
  });
37
37
  exports.default = waiter;
38
-
39
- //# sourceMappingURL=waiter.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiot-toolkit",
3
- "version": "2.0.1-alpha.8",
3
+ "version": "2.0.2-dev.1",
4
4
  "description": "Tools for creating, developing, and packaging aiot applications.",
5
5
  "keywords": [
6
6
  "aiot"
@@ -25,18 +25,22 @@
25
25
  "test": "node ./__tests__/aiot-toolkit.test.js"
26
26
  },
27
27
  "dependencies": {
28
- "@aiot-toolkit/emulator": "2.0.1-alpha.8",
29
- "@aiot-toolkit/shared-utils": "2.0.1-alpha.8",
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",
30
31
  "@miwt/adb": "^0.7.1",
31
32
  "adb-commander": "^0.1.9",
32
33
  "adm-zip": "^0.5.10",
33
34
  "axios": "^1.5.0",
34
35
  "cli-progress": "^3.12.0",
35
- "create-aiot": "2.0.1-alpha.8",
36
- "fast-glob": "^3.3.2"
36
+ "create-aiot": "2.0.2-dev.1",
37
+ "fast-glob": "^3.3.2",
38
+ "file-lane": "2.0.2-dev.1",
39
+ "ws": "^8.15.1"
37
40
  },
38
41
  "devDependencies": {
39
- "@types/adm-zip": "^0.5.4"
42
+ "@types/adm-zip": "^0.5.4",
43
+ "@types/ws": "^8.5.10"
40
44
  },
41
- "gitHead": "67e2c953dfce560a6133656136fe71326140e91c"
45
+ "gitHead": "0beecc786c41b73ab2dabeaad06fb4ad19115f4b"
42
46
  }
package/lib/bin.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"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O,MAAM,EAAE,EAAE;wBACvB,MAAM,oBAAU,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAA;oBAC/C,CAAC,CAAA;iBACF;gBACD;oBACE,IAAI,EAAE,kBAAkB;oBACxB,WAAW,EAAE,oDAAoD;oBACjE,SAAS,EAAE;wBACT;4BACE,IAAI,EAAE,IAAI;4BACV,WAAW,EAAE,yBAAyB;4BACtC,IAAI,EAAE,QAAQ;yBACf;wBACD;4BACE,IAAI,EAAE,MAAM;4BACZ,WAAW,EAAE,oBAAoB;4BACjC,IAAI,EAAE,QAAQ;yBACf;qBACF;oBACD,MAAM,EAAE,CAAO,MAAM,EAAE,EAAE;wBACvB,IAAI;4BACF,MAAM,cAAc,GAAG,MAAM,oBAAU,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;4BAChE,sBAAY,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,wBAAS,CAAC,OAAO,EAAE,CAAC,CAAA;yBACxE;wBAAC,OAAO,KAAK,EAAE;4BACd,sBAAY,CAAC,GAAG,CAAC,EAAE,OAAO,EAAG,KAAe,CAAC,OAAO,EAAE,KAAK,EAAE,wBAAS,CAAC,KAAK,EAAE,CAAC,CAAA;yBAChF;oBACH,CAAC,CAAA;iBACF;gBACD;oBACE,IAAI,EAAE,eAAe;oBACrB,WAAW,EAAE,4BAA4B;oBACzC,MAAM,EAAE,GAAS,EAAE;wBACjB,sBAAW,CAAC,sBAAsB,EAAE,CAAA;oBACtC,CAAC,CAAA;iBACF;gDAEI,UAAU,KACb,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,qBAAqB;aAErC;SACF,CAAA;QACD,mBAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;IAChC,CAAC;CAAA;AACD,IAAI,EAAE,CAAA","file":"bin.js","sourcesContent":["#!/usr/bin/env node\n\nimport { Command, ICommand, IProgram } from '@aiot-toolkit/commander'\nimport { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport { getAiotCreateCommand } from 'create-aiot'\nimport IBuilder from './builder/IBuilder'\nimport XtsBuilder from './builder/XtsBuilder'\nimport GoldfishStarter from './starter/GoldfishStarter'\nimport DeviceUtil from './utils/DeviceUtil'\nimport VelaAvdUtil from './utils/VelaAvdUtils'\nimport waiter from './waiter'\n// 配置支持的 builder 类型,新增的项目类型,只需在此处加上类型\n\nfunction findBuilder(projectPath: string): IBuilder | undefined {\n return new XtsBuilder()\n}\n\nfunction build(command: string, description: string): ICommand {\n const projectPath = process.cwd()\n const builder = findBuilder(projectPath)\n const paramList = builder?.params\n\n return {\n name: command,\n description,\n paramList,\n action: async (option: any) => {\n // 获取对应的 build;如果存在,执行 build 函数,不存在,提示\n const projectPath = process.cwd()\n const builder = findBuilder(projectPath)\n if (builder) {\n const { watch } = option\n await builder.build(projectPath, option)\n if (watch) {\n waiter.describe()\n waiter.start()\n }\n } else {\n ColorConsole.log({\n message: `This type of project is not currently supported. The supported projects : xts`,\n level: LOG_LEVEL.Error,\n isOnlyPrintError: true\n })\n }\n }\n }\n}\n\nasync function main() {\n const aiotCreate = await getAiotCreateCommand()\n const config: IProgram = {\n name: 'aiot-toolkit',\n description: 'contains build, dev, release, etc. commands for aiot toolkit',\n version: '2.0.1',\n commandList: [\n build('build', 'build project'),\n new GoldfishStarter('start', 'start project').getParamList(),\n {\n name: 'getConnectedDevices',\n description: 'get all connected devices',\n action: async (option) => {\n try {\n const connectedDevices = await DeviceUtil.getAllConnectedDevices()\n ColorConsole.log({\n message: `The connected devices are: ${\n connectedDevices ? connectedDevices.join(', ') : 'null'\n }`\n })\n } catch (error) {\n ColorConsole.log({ message: (error as Error).message, level: LOG_LEVEL.Error })\n }\n }\n },\n {\n name: 'getPlatforms',\n description: 'get available platform(s) on selected device',\n paramList: [\n {\n name: 'ip',\n description: 'device ip(eg 127.0.0.1)',\n type: 'string',\n enableInquirer: true\n },\n {\n name: 'port',\n description: 'device port(eg 39517)',\n type: 'string',\n enableInquirer: true\n },\n {\n name: 'sn',\n description:\n 'view the serial number of the connected device through the \"adb devices\" command, if it is a device connected via wifi, the format is \"ip address:5555\"',\n type: 'string',\n enableInquirer: true\n }\n ],\n action: async (option) => {\n await DeviceUtil.getAvailablePlatform(option)\n }\n },\n {\n name: 'installDbgAndMkp',\n description: 'install \"org.hapjs.debugger\" & \"org.hapjs.mockup\" ',\n paramList: [\n {\n name: 'ip',\n description: 'device ip(eg 127.0.0.1)',\n type: 'string'\n },\n {\n name: 'port',\n description: 'device ip(eg 5555)',\n type: 'string'\n }\n ],\n action: async (option) => {\n try {\n const successMessage = await DeviceUtil.installDbgAndMkp(option)\n ColorConsole.log({ message: successMessage, level: LOG_LEVEL.Success })\n } catch (error) {\n ColorConsole.log({ message: (error as Error).message, level: LOG_LEVEL.Error })\n }\n }\n },\n {\n name: 'createVelaAvd',\n description: 'create a vela avd instance',\n action: async () => {\n VelaAvdUtil.createVelaAvdByInquire()\n }\n },\n {\n ...aiotCreate,\n name: 'create',\n description: 'create aiot project'\n }\n ]\n }\n Command.registeProgram(config)\n}\nmain()\n"],"sourceRoot":"../src"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["builder/IBuilder.ts"],"names":[],"mappings":"","file":"IBuilder.js","sourcesContent":["import { IParam } from '@aiot-toolkit/commander'\n\n/**\n * IBuilder\n */\nexport default interface IBuilder<O = any> {\n /**\n * build 的参数列表\n */\n readonly params: IParam[]\n\n /**\n * 打包项目\n * @param projectPath 项目路径\n * @param options 命令参数\n * @param watch 是否监听文件变化并持续打包\n */\n build(projectPath: string, options: O): void | Promise<void>\n\n /**\n * 当前 builder 是否可打包指定目录的项目\n * @param projectPath 项目目录\n */\n match(projectPath: string): boolean\n}\n"],"sourceRoot":"../../src"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["builder/UxBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uGAA8E;AAC9E,mJAA0H;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,IAAI,CAAC;gBACjB,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;oBACE,IAAI,EAAE,UAAU;oBAChB,WAAW;oBACX,OAAO;oBACP,KAAK;iBACN,EACD,IAAI,EACJ,CAAC,CACF;aACF,CAAC,CAAA;YACF,SAAS;YACT,MAAM,IAAI,oBAAQ,CAChB,eAAe,EACf,WAAW,EACX,cAA0C,CAC3C,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QACpB,CAAC;KAAA;IAEO,kBAAkB,CAAC,WAAmB;QAC5C,MAAM,IAAI,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC,CAAA;QACzD,IAAI,kBAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YACvB,IAAI;gBACF,OAAO,kBAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;aAC7B;YAAC,OAAO,KAAK,EAAE;gBACd,uBAAa,CAAC,KAAK,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,EAAE,KAAI,EAAE,CAAC,CAAA;aAC7C;SACF;QACD,OAAM;IACR,CAAC;IAwBD,KAAK,CAAC,WAAmB;QACvB,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACnC,CAAC;;AAzBe,sBAAY,GAAG,cAAH,AAAiB,CAAA;AA2B/C,kBAAe,SAAS,CAAA","file":"UxBuilder.js","sourcesContent":["import CompileMode from '@aiot-toolkit/aiotpack/lib/compiler/enum/CompileMode'\nimport JavascriptDefaultCompileOption from '@aiot-toolkit/aiotpack/lib/compiler/javascript/JavascriptDefaultCompileOption'\nimport IJavascriptCompileOption from '@aiot-toolkit/aiotpack/lib/compiler/javascript/interface/IJavascriptCompileOption'\nimport UxConfig from '@aiot-toolkit/aiotpack/lib/config/UxConfig'\nimport IQuickAppConfig from '@aiot-toolkit/aiotpack/src/compiler/javascript/vela/interface/IQuickAppConfig'\nimport ParamType from '@aiot-toolkit/commander/lib/interface/IParam'\nimport ColorConsole2 from '@aiot-toolkit/shared-utils/lib/ColorConsole2'\nimport { Dictionary } from '@aiot-toolkit/shared-utils/lib/type/Type'\nimport { FileLane } from 'file-lane'\nimport Fs from 'fs-extra'\nimport Lodash from 'lodash'\nimport Path from 'path'\nimport IBuilder from './IBuilder'\n\ninterface IUxBuilderOption extends Dictionary {\n watch?: boolean\n mode: CompileMode\n}\n\n/**\n * UxBuilder\n */\nclass UxBuilder implements IBuilder<IUxBuilderOption> {\n readonly QUICKAPP_CONFIG = 'quickapp.config.js'\n /**\n * ux项目的build函数\n * @param projectPath 项目路径\n * @param options 命令参数\n * @param watch 是否开启监听\n */\n async build(projectPath: string, options: IUxBuilderOption): Promise<void> {\n const { watch } = options\n // 读取项目中文件的配置\n const quickappConfig = this.readQuickAppConfig(projectPath)\n options = Lodash.merge({}, options, quickappConfig?.cli)\n // 项目配置\n const uxProjectConfig: UxConfig = new UxConfig(projectPath)\n\n // 编译配置\n const compilerOption: Partial<IJavascriptCompileOption> = Lodash.merge(\n {\n projectPath: Path.join(projectPath, uxProjectConfig.output),\n mode: CompileMode.DEVELOPMENT,\n disabledJSC: options.disabledJsc\n },\n JavascriptDefaultCompileOption,\n quickappConfig?.webpack\n )\n\n ColorConsole2.info({\n word: JSON.stringify(\n {\n step: 'build ux',\n projectPath,\n options,\n watch\n },\n null,\n 2\n )\n })\n // 开始编译项目\n await new FileLane<IJavascriptCompileOption>(\n uxProjectConfig,\n projectPath,\n compilerOption as IJavascriptCompileOption\n ).start({ watch })\n }\n\n private readQuickAppConfig(projectPath: string): IQuickAppConfig | undefined {\n const path = Path.join(projectPath, this.QUICKAPP_CONFIG)\n if (Fs.existsSync(path)) {\n try {\n return Fs.readJsonSync(path)\n } catch (error) {\n ColorConsole2.throw(error?.toString() || '')\n }\n }\n return\n }\n static readonly PROJECT_TYPE = 'ux quick app'\n params: ParamType[] = [\n {\n name: 'enable-e2e',\n description: 'inject test-suite for current project'\n },\n {\n name: 'devtool',\n description: 'source map config'\n },\n {\n name: 'disable-subpackages',\n description: 'disable subpackages'\n },\n {\n type: 'confirm',\n name: 'disabled-jsc',\n description: 'disabled jsc bundle',\n defaultValue: true,\n enableInquirer: true\n }\n ]\n\n match(projectPath: string): boolean {\n return projectPath.includes('ux')\n }\n}\nexport default UxBuilder\n"],"sourceRoot":"../../src"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["builder/XtsBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qDAAkD;AAElD,6DAAsD;AACtD,+FAAsE;AACtE,yCAAoC;AACpC,4CAAmB;AACnB,gDAAuB;AAOvB;;GAEG;AACH,MAAM,UAAU;IAAhB;QAyBW,WAAM,GAAa,EAAE,CAAA;IAChC,CAAC;IAvBC,KAAK,CAAC,WAAmB;QACvB,wBAAwB;QACxB,OAAO,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,CAAA;IAChE,CAAC;IAEK,KAAK,CAAC,WAAmB,EAAE,OAAuB;;YACtD,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;YACzB,sBAAY,CAAC,GAAG,CAAC;gBACf,OAAO,EAAE,IAAI,CAAC,SAAS,CACrB;oBACE,WAAW;oBACX,OAAO;iBACR,EACD,SAAS,EACT,CAAC,CACF;gBACD,KAAK,EAAE,wBAAS,CAAC,OAAO;aACzB,CAAC,CAAA;YACF,MAAM,MAAM,GAAG,IAAI,oBAAS,EAAE,CAAA;YAC9B,OAAO,IAAI,oBAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QAC3D,CAAC;KAAA;;AAtBe,uBAAY,GAAG,eAAH,AAAkB,CAAA;AA0BhD,kBAAe,UAAU,CAAA","file":"XtsBuilder.js","sourcesContent":["import { XtsConfig } from '@aiot-toolkit/aiotpack'\nimport { IParam } from '@aiot-toolkit/commander'\nimport { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport { FileLane } from 'file-lane'\nimport fs from 'fs'\nimport path from 'path'\nimport IBuilder from './IBuilder'\n\ninterface IBuilderOption {\n watch?: boolean\n}\n\n/**\n * XtsBuilder\n */\nclass XtsBuilder implements IBuilder<IBuilderOption> {\n static readonly PROJECT_TYPE = 'xts quick app'\n\n match(projectPath: string): boolean {\n // app/app.xts 存在视为xts项目\n return fs.existsSync(path.resolve(projectPath, 'app/app.xts'))\n }\n\n async build(projectPath: string, options: IBuilderOption) {\n const { watch } = options\n ColorConsole.log({\n message: JSON.stringify(\n {\n projectPath,\n options\n },\n undefined,\n 2\n ),\n level: LOG_LEVEL.Success\n })\n const config = new XtsConfig()\n return new FileLane(config, projectPath).start({ watch })\n }\n\n readonly params: IParam[] = []\n}\nexport default XtsBuilder\n"],"sourceRoot":"../../src"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["interface/CommandInterface.ts"],"names":[],"mappings":"","file":"CommandInterface.js","sourcesContent":["/**\n * IInstallApkAndDbg\n */\nexport interface IInstallApkAndDbg {\n ip?: string\n port?: string\n platform?: string\n apkVersion?: string\n forceInstall?: boolean\n}\nexport interface IGetAvailablePlatform {\n ip: string\n port: string\n sn: string\n}\n"],"sourceRoot":"../../src"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["interface/VelaEmulatorInterface.ts"],"names":[],"mappings":"","file":"VelaEmulatorInterface.js","sourcesContent":["export interface IGoldfishVersionInfo {\n name: string;\n emulator: string;\n 'system-images': string;\n qa: string;\n skins: string;\n tools: string;\n}"],"sourceRoot":"../../src"}
@@ -1,9 +0,0 @@
1
- import { ICommand } from '@aiot-toolkit/commander';
2
- declare class GoldfishStarter {
3
- private name;
4
- private description;
5
- constructor(name: string, description: string);
6
- getParamList(): ICommand;
7
- start(option: any): Promise<void>;
8
- }
9
- export default GoldfishStarter;