@zeppos/zeus-cli 1.1.0-beta → 1.1.0

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/api/index.js CHANGED
@@ -76,6 +76,8 @@ var project_1 = require("../config/project");
76
76
  var logger = __importStar(require("../utils/logger"));
77
77
  var storage_1 = require("../modules/storage");
78
78
  // import { login } from '../modules/login'
79
+ // import { bridge } from '../modules/bridge'
80
+ // mark 调试时有用
79
81
  // process.on('exit', (code) => {
80
82
  // console.log(`About to exit with code: ${code}`);
81
83
  // });
@@ -133,7 +135,8 @@ var getConnectDevServerWebSocketCode = function () { return __awaiter(void 0, vo
133
135
  switch (_c.label) {
134
136
  case 0:
135
137
  if (!exports.subRegionalHost) {
136
- message = project_1.ACCOUNT_ENV === 'production' ? "Login information is invalid,please login again with the command 'zeus login'" : "".concat(project_1.ACCOUNT_ENV, ":Login information is invalid,please login again with the command 'zeus login'.");
138
+ storage_1.globalStorage.deleteStorage('____login');
139
+ message = project_1.ACCOUNT_ENV === 'production' ? "Login information is invalid,please login again with the command 'zeus login'." : "".concat(project_1.ACCOUNT_ENV, ":Login information is invalid,please login again with the command 'zeus login'.");
137
140
  throw new Error(message);
138
141
  }
139
142
  _c.label = 1;
@@ -153,8 +156,9 @@ var getConnectDevServerWebSocketCode = function () { return __awaiter(void 0, vo
153
156
  message = (error_2 === null || error_2 === void 0 ? void 0 : error_2.response) && ((_a = error_2.response) === null || _a === void 0 ? void 0 : _a.data);
154
157
  if ((message === null || message === void 0 ? void 0 : message.code) === 401 && ((_b = message === null || message === void 0 ? void 0 : message.data) === null || _b === void 0 ? void 0 : _b.code) === "0102") {
155
158
  storage_1.globalStorage.deleteStorage('____login');
156
- // await login() TODO 不中断命令登录
157
- throw new Error("Invalid token,please login again with the command 'zeus login'.");
159
+ // need login
160
+ // await login()
161
+ throw new Error("".concat(project_1.ACCOUNT_ENV === 'production' ? '' : 'test: ', "Invalid token,please login again with the command 'zeus login'."));
158
162
  }
159
163
  else {
160
164
  msg = project_1.ACCOUNT_ENV === 'production' ? "GetConnectDevServerWebSocketCode error" : "".concat(project_1.ACCOUNT_ENV, ":getConnectDevServerWebSocketCode error ").concat(JSON.stringify(message));
@@ -170,7 +174,7 @@ var getConnectDevServerWebSocketCode = function () { return __awaiter(void 0, vo
170
174
  exports.getConnectDevServerWebSocketCode = getConnectDevServerWebSocketCode;
171
175
  // 上传表盘/应用接口
172
176
  var uploadPackage = function (form, length) { return __awaiter(void 0, void 0, void 0, function () {
173
- var packageInfo, error_3;
177
+ var packageInfo, error_3, message;
174
178
  return __generator(this, function (_a) {
175
179
  switch (_a.label) {
176
180
  case 0:
@@ -184,6 +188,12 @@ var uploadPackage = function (form, length) { return __awaiter(void 0, void 0, v
184
188
  case 2:
185
189
  error_3 = _a.sent();
186
190
  logger.error("".concat(error_3));
191
+ if (typeof error_3 === 'string') {
192
+ message = error_3.includes('401') ? "Invalid token,please login again with the command 'zeus login'." : error_3;
193
+ logger.error("".concat(message));
194
+ }
195
+ // need login
196
+ process.exit(1);
187
197
  return [3 /*break*/, 3];
188
198
  case 3: return [2 /*return*/];
189
199
  }
package/config/project.js CHANGED
@@ -28,7 +28,7 @@ if (!exports.ACCOUNT_ENV) {
28
28
  exports.ACCOUNT_ENV = 'production';
29
29
  storage_1.globalStorage.set((_a = {}, _a[exports.ACCOUNT_ENV_KEY] = exports.ACCOUNT_ENV, _a));
30
30
  }
31
- var curLoginURL = exports.ACCOUNT_ENV === 'production' ? 'https://user.huami.com/universalLogin/index.html#/login' : 'https://user-testing.huami.com/universalLogin/index.html#/login';
31
+ var curLoginURL = exports.ACCOUNT_ENV === 'production' ? 'https://user.zepp.com/universalLogin/index.html#/login' : 'https://user-testing.zepp.com/universalLogin/index.html#/login';
32
32
  exports.analyticsHost = exports.ACCOUNT_ENV === 'production' ? 'https://api-analytics.huami.com' : 'https://api-analytics-test.huami.com';
33
33
  var loginUrl = new URL(curLoginURL);
34
34
  var accountPrefix = "____".concat(lodash_1["default"].replace(loginUrl.host, /\./g, '_'), "__");
package/modules/bridge.js CHANGED
@@ -63,18 +63,17 @@ var project_1 = require("../config/project");
63
63
  var index_1 = require("../api/index");
64
64
  var logger = __importStar(require("../utils/logger"));
65
65
  var chalk_1 = __importDefault(require("chalk"));
66
- var inquirer_1 = __importDefault(require("inquirer"));
67
66
  var websocket_1 = __importDefault(require("./websocket"));
68
67
  var build_1 = require("./build");
69
68
  var common_1 = require("../utils/common");
70
- // TODO: 需要在项目根目录执行
69
+ var project_2 = require("../config/project");
71
70
  var client;
72
71
  var hasConnectDevice = false;
73
72
  var choiredDevice;
74
73
  // 连接设备
75
74
  // TODO: 有多个连接的时候退不到可输入状态
76
- var connectDevice = function () { return __awaiter(void 0, void 0, void 0, function () {
77
- var debugConnectedDevice, optionalDeviceArr, len, clientId, answer;
75
+ var connectDevice = function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
76
+ var debugConnectedDevice, optionalDeviceArr, len, clientId_1;
78
77
  return __generator(this, function (_a) {
79
78
  switch (_a.label) {
80
79
  case 0:
@@ -85,24 +84,26 @@ var connectDevice = function () { return __awaiter(void 0, void 0, void 0, funct
85
84
  logger.log(chalk_1["default"].yellow('No connectable online App or Simulator.'));
86
85
  return [3 /*break*/, 4];
87
86
  case 1:
88
- clientId = debugConnectedDevice[optionalDeviceArr[0]];
87
+ clientId_1 = debugConnectedDevice[optionalDeviceArr[0]];
89
88
  choiredDevice = optionalDeviceArr[0];
90
89
  if (!(len > 1)) return [3 /*break*/, 3];
91
- return [4 /*yield*/, inquirer_1["default"].prompt({
90
+ return [4 /*yield*/, vorpal.activeCommand.prompt({
92
91
  name: 'choiredDevice',
93
92
  type: 'list',
94
93
  choices: optionalDeviceArr,
95
94
  message: 'Which online target would you like to connect?'
95
+ }, function (result) {
96
+ clientId_1 = debugConnectedDevice[result.choiredDevice];
97
+ choiredDevice = result.choiredDevice;
98
+ vorpal.delimiter('bridge$').show();
96
99
  })];
97
100
  case 2:
98
- answer = _a.sent();
99
- clientId = debugConnectedDevice[answer.choiredDevice];
100
- choiredDevice = answer.choiredDevice;
101
+ _a.sent();
101
102
  _a.label = 3;
102
103
  case 3:
103
104
  project_1.____inner_global_variable.bridgeChoiredDevice = choiredDevice;
104
105
  // 发送连接请求
105
- client.sendMessage({ clientId: clientId }, 'connectClient');
106
+ client.sendMessage({ clientId: clientId_1 }, 'connectClient');
106
107
  hasConnectDevice = true;
107
108
  _a.label = 4;
108
109
  case 4: return [2 /*return*/];
@@ -130,16 +131,18 @@ var connectBridgeWSCallback = function () {
130
131
  });
131
132
  vorpal
132
133
  .command('connect', 'Connect the online App or Simulator for debugging.')
133
- .action(function () { return __awaiter(void 0, void 0, void 0, function () {
134
+ .option('--anchovies')
135
+ .action(function (args, cb) { return __awaiter(void 0, void 0, void 0, function () {
134
136
  return __generator(this, function (_a) {
135
137
  // TODO: 断开链接怎么监听,需要处理啥吗
136
- connectDevice();
138
+ connectDevice(vorpal);
139
+ cb();
137
140
  return [2 /*return*/];
138
141
  });
139
142
  }); });
140
143
  vorpal
141
144
  .command('install', 'Install applications or watch face.')
142
- .action(function () { return __awaiter(void 0, void 0, void 0, function () {
145
+ .action(function (args, cb) { return __awaiter(void 0, void 0, void 0, function () {
143
146
  return __generator(this, function (_a) {
144
147
  switch (_a.label) {
145
148
  case 0:
@@ -153,19 +156,31 @@ var connectBridgeWSCallback = function () {
153
156
  case 2:
154
157
  logger.log(chalk_1["default"].yellow("No device is connected, please connect the device with the command width 'connect' first."));
155
158
  _a.label = 3;
156
- case 3: return [2 /*return*/];
159
+ case 3:
160
+ cb();
161
+ return [2 /*return*/];
157
162
  }
158
163
  });
159
164
  }); });
160
165
  // 卸载命令
161
166
  vorpal
162
- .command('uninstall', 'Uninstall applications or watch face.')
163
- .action(function () { return __awaiter(void 0, void 0, void 0, function () {
164
- var _a, appid, appname, apptype;
167
+ .command('uninstall [appid]', 'Uninstall applications or watch face.')
168
+ .action(function (args, cb) { return __awaiter(void 0, void 0, void 0, function () {
169
+ var _a, appid, appName, appType;
165
170
  return __generator(this, function (_b) {
166
- logger.info('Uninstalling');
167
- _a = (0, common_1.getDeviceInfoFromAppJson)(), appid = _a.appId, appname = _a.appName, apptype = _a.appType;
168
- client.sendMessage({ type: 'delete', appid: appid, appname: appname, apptype: apptype }, 'sysSettingPush');
171
+ if (!args.appid) {
172
+ logger.info('Uninstalling');
173
+ _a = (0, common_1.getDeviceInfoFromAppJson)(), appid = _a.appId, appName = _a.appName, appType = _a.appType;
174
+ client.sendMessage({ type: 'delete', appid: appid, appName: appName, appType: appType }, 'sysSettingPush');
175
+ }
176
+ else if (args.appid && typeof args.appid === 'number') {
177
+ logger.info('Uninstalling');
178
+ client.sendMessage({ type: 'delete', appid: args.appid }, 'sysSettingPush');
179
+ }
180
+ else if (args.appid) {
181
+ logger.info("invalid '".concat(args.appid, "', the 'uninstall' command should be followed by appid or blank."));
182
+ }
183
+ cb();
169
184
  return [2 /*return*/];
170
185
  });
171
186
  }); });
@@ -174,6 +189,7 @@ var disConnectBridgeWSCallback = function () {
174
189
  // 什么情况下会断开连接?
175
190
  hasConnectDevice = false;
176
191
  logger.log('= 断开连接 =');
192
+ process.exit(1);
177
193
  };
178
194
  var bridge = function () { return __awaiter(void 0, void 0, void 0, function () {
179
195
  var bridgeWebSocketURL, error_1;
@@ -192,7 +208,7 @@ var bridge = function () { return __awaiter(void 0, void 0, void 0, function ()
192
208
  connectCb: connectBridgeWSCallback,
193
209
  disconnectCb: disConnectBridgeWSCallback
194
210
  });
195
- logger.log(" - Enter 'help' to view the command.");
211
+ logger.log("".concat(project_2.ACCOUNT_ENV === 'production' ? '' : 'test:', " - Enter 'help' to view the command."));
196
212
  return [3 /*break*/, 3];
197
213
  case 2:
198
214
  error_1 = _a.sent();
package/modules/build.js CHANGED
@@ -145,7 +145,7 @@ function chooseBuildPackages(mode) {
145
145
  answers = _c.sent();
146
146
  // 存储 deviceSource
147
147
  if (BuildMode.PROD) {
148
- storage_1.globalStorage.set((_b = {}, _b[project_1.buildStorageKey.targetDeviceToBuild] = [answers.target], _b));
148
+ storage_1.globalStorage.set((_b = {}, _b[project_1.buildStorageKey.targetDeviceToBuild] = answers.target, _b));
149
149
  }
150
150
  return [2 /*return*/, mode !== BuildMode.PROD ? [answers.target] : answers.buildTargets];
151
151
  case 4: return [2 /*return*/];
@@ -270,7 +270,7 @@ var buildPreview = function (args, cb) { return __awaiter(void 0, void 0, void 0
270
270
  _a = args._, curCommand = _a[0], curBridgeTarget = _a[1];
271
271
  form = new form_data_1["default"]();
272
272
  buildMode = (curBridgeTarget && curBridgeTarget === 'simulator') ? BuildMode.DEV : BuildMode.PREVIEW;
273
- logger.info('building...');
273
+ logger.info("".concat(project_1.ACCOUNT_ENV === 'production' ? '' : 'test:', " building..."));
274
274
  return [4 /*yield*/, (0, exports.build)(buildMode, [], args)];
275
275
  case 1:
276
276
  buildInfo = _b.sent();
@@ -294,15 +294,15 @@ var buildPreview = function (args, cb) { return __awaiter(void 0, void 0, void 0
294
294
  if (!(curCommand === 'preview')) return [3 /*break*/, 2];
295
295
  url = "".concat(protocol, "://").concat(api_1.subRegionalHost, "/custom/tools/app-dial/download/").concat(code);
296
296
  if (protocol && code) {
297
- logger.info('generating preview qrcode...');
297
+ logger.info('Generating preview qrcode...');
298
298
  logger.success('Below within two hours,please use Zepp APP to scan the qrcode below to preview your app.');
299
299
  qrcode_terminal_1["default"].generate("".concat(protocol, "://").concat(api_1.subRegionalHost, "/custom/tools/app-dial/download/").concat(code), { small: true });
300
300
  }
301
301
  else {
302
302
  if (project_1.ACCOUNT_ENV === 'test') {
303
- console.log('previewUrl', url);
303
+ console.log('test:previewUrl', url);
304
304
  }
305
- logger.error('generating preview qrcode failed, please check your network.');
305
+ logger.error('Generating preview qrcode failed, please check your network.');
306
306
  }
307
307
  return [3 /*break*/, 4];
308
308
  case 2:
@@ -291,7 +291,9 @@ var create = function (args) { return __awaiter(void 0, void 0, void 0, function
291
291
  });
292
292
  logger.log('\n');
293
293
  logger.success("project created successfully by \"".concat(choosePkg.name, "\" template.\n"));
294
- shell.cd("".concat(projectName));
294
+ if (cmd === 'create') {
295
+ shell.cd("".concat(projectName));
296
+ }
295
297
  shell.exec('npm install');
296
298
  return [4 /*yield*/, (0, sleep_1.sleep)(300)];
297
299
  case 4:
package/modules/login.js CHANGED
@@ -74,7 +74,7 @@ var login = function (args) { return __awaiter(void 0, void 0, void 0, function
74
74
  return __generator(this, function (_h) {
75
75
  _a = storage_1.instanceStorage.getStorage(), _b = project_1.loginStorageKey.accountToken, _c = _a[_b], apptoken = _c === void 0 ? '' : _c, _d = project_1.loginStorageKey.userid, _e = _a[_d], userid = _e === void 0 ? '' : _e, _f = project_1.loginStorageKey.cname, _g = _a[_f], cname = _g === void 0 ? '' : _g;
76
76
  if (apptoken && userid && cname) {
77
- message = project_1.ACCOUNT_ENV === 'production' ? "have logged" : "have logged in ".concat(project_1.ACCOUNT_ENV, " with account: ").concat(userid);
77
+ message = project_1.ACCOUNT_ENV === 'production' ? "Have logged" : "test:Have logged with account:".concat(userid);
78
78
  logger.success(message);
79
79
  return [2 /*return*/, { apptoken: apptoken, userid: userid, cname: cname }];
80
80
  }
@@ -107,7 +107,7 @@ var login = function (args) { return __awaiter(void 0, void 0, void 0, function
107
107
  _b[project_1.loginStorageKey.cname] = cname,
108
108
  _b[project_1.loginStorageKey.accountToken] = apptoken,
109
109
  _b));
110
- message = project_1.ACCOUNT_ENV === 'production' ? 'Login success' : "Login success, ".concat(project_1.ACCOUNT_ENV, "\uFF0Cuserid:").concat(userid);
110
+ message = project_1.ACCOUNT_ENV === 'production' ? 'Login success' : "test:Login success with account:".concat(userid);
111
111
  logger.success(message);
112
112
  server.close();
113
113
  process.exit(0);
@@ -148,6 +148,58 @@ exports.login = login;
148
148
  var logout = function () {
149
149
  (0, hm_analytics_1.HM_Analytics)('ZEPP_CLI_LOGOUT_C');
150
150
  storage_1.globalStorage.deleteStorage('____login');
151
- logger.success('Logged out');
151
+ logger.success("".concat(project_1.ACCOUNT_ENV === 'production' ? '' : 'test: ', "Logged out"));
152
+ process.exit(0);
152
153
  };
153
154
  exports.logout = logout;
155
+ // const isLocal = false
156
+ // if(isLocal) {
157
+ // const answer = await inquirer.prompt([
158
+ // {
159
+ // name: 'account',
160
+ // type: 'input',
161
+ // message: `Enter your account (Mobile/E-mail): ${accountInfo ? `(${accountInfo})` : ''}`
162
+ // },
163
+ // {
164
+ // name: 'password',
165
+ // type: 'password',
166
+ // message: 'Enter your password: ',
167
+ // mask: '*'
168
+ // }
169
+ // ])
170
+ // answer.account = answer.account || accountInfo
171
+ // const loginInfo = await loginByLocal(answer.account, answer.password).catch(() => {
172
+ // logger.error('logged in failed, please check your account and password')
173
+ // process.exit(1)
174
+ // })
175
+ // const token = _.get(loginInfo, 'token_info.app_token')
176
+ // if (token) {
177
+ // logger.success(`logged in with account: ${answer.account}`)
178
+ // storage.set(loginStorageKey.account, answer.account)
179
+ // storage.set(loginStorageKey.accountToken, token)
180
+ // }
181
+ // }
182
+ // export const callback = async ({ cname, apptoken, userid }: {cname: string, apptoken: string, userid: string}, fun: () => void) => {
183
+ // if(apptoken && cname) {
184
+ // const userInfoHost = cname && cname.split(',').filter((h: string) => h.indexOf('auth-') > -1)[0]
185
+ // const userInfoURL = `https://${userInfoHost}/v2/developer/account/center`
186
+ // const { userName: nickName = '' } = await getUserInfo(userInfoURL, apptoken)
187
+ // globalStorage.set({
188
+ // [loginStorageKey.nickName]: nickName,
189
+ // [loginStorageKey.userid]: userid,
190
+ // [loginStorageKey.cname]: cname,
191
+ // [loginStorageKey.accountToken]: apptoken
192
+ // })
193
+ // const message = ACCOUNT_ENV === 'production' ? 'Login success' : `test:Login success with account:${userid}`
194
+ // logger.success(message)
195
+ // if (fun) {
196
+ // // 暂时没有实现和调用
197
+ // await fun()
198
+ // } else {
199
+ // process.exit(0)
200
+ // }
201
+ // } else {
202
+ // console.log('cxa')
203
+ // process.exit(1)
204
+ // }
205
+ // }
package/modules/status.js CHANGED
@@ -70,7 +70,7 @@ var status = function () { return __awaiter(void 0, void 0, void 0, function ()
70
70
  return __generator(this, function (_q) {
71
71
  _a = storage_1.instanceStorage.getStorage(), _b = project_1.loginStorageKey.nickName, _c = _a[_b], nickName = _c === void 0 ? '' : _c, _d = project_1.loginStorageKey.accountToken, _e = _a[_d], apptoken = _e === void 0 ? '' : _e, _f = project_1.loginStorageKey.userid, _g = _a[_f], userid = _g === void 0 ? '' : _g, _h = project_1.loginStorageKey.cname, _j = _a[_h], cname = _j === void 0 ? '' : _j, _k = project_1.simulatorStorageKey.simulatorHost, _l = _a[_k], simulatorHost = _l === void 0 ? run_1.DEFAULT_HOST : _l, _m = project_1.simulatorStorageKey.simulatorPort, _o = _a[_m], simulatorPort = _o === void 0 ? run_1.DEFAULT_PORT : _o, _p = project_1.simulatorStorageKey.simulatorConnectStatus, simulatorConnectStatus = _a[_p];
72
72
  loginStatus = (apptoken && userid && cname) ? 'logged' : 'logout';
73
- message = project_1.ACCOUNT_ENV === 'production' ? 'login status:' : "".concat(project_1.ACCOUNT_ENV, " login status: ");
73
+ message = project_1.ACCOUNT_ENV === 'production' ? 'login status:' : "".concat(project_1.ACCOUNT_ENV, ": login status: ");
74
74
  logger.log(message, chalk_1["default"].yellow(loginStatus));
75
75
  if (loginStatus === 'logged') {
76
76
  logger.log('nickName:', chalk_1["default"].yellow(nickName));
@@ -80,6 +80,7 @@ var status = function () { return __awaiter(void 0, void 0, void 0, function ()
80
80
  logger.log('simulator host:', chalk_1["default"].yellow(simulatorHost));
81
81
  logger.log('simulator port:', chalk_1["default"].yellow(simulatorPort));
82
82
  (0, hm_analytics_1.HM_Analytics)('ZEPP_CLI_STATUS_C');
83
+ process.exit(0);
83
84
  return [2 /*return*/];
84
85
  });
85
86
  }); };
@@ -32,6 +32,7 @@ var WebSocketClass = /** @class */ (function () {
32
32
  this.msgEventIDs = {};
33
33
  this.handleListenMsgEventReturn = function (data) {
34
34
  var message = data.toString('utf8');
35
+ // mark 调试时有用
35
36
  // console.log('receivedMessage', message)
36
37
  var me = _this;
37
38
  // TODO: 优化判断字符串是纯字符串还是可转换成对象
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeppos/zeus-cli",
3
- "version": "1.1.0-beta",
3
+ "version": "1.1.0",
4
4
  "description": "zeus mini-program tools",
5
5
  "main": "index.js",
6
6
  "author": "zepp",
package/utils/common.js CHANGED
@@ -47,33 +47,60 @@ function getOptionalConnectDevice(connectDeviceArr) {
47
47
  }
48
48
  exports.getOptionalConnectDevice = getOptionalConnectDevice;
49
49
  function handleListenMsgEvent(msgEventName, data) {
50
- var _a, _b;
50
+ var _a, _b, _c;
51
+ // mark 调试时有用
52
+ // console.log(msgEventName,data)
51
53
  switch (msgEventName) {
52
54
  // 客户端变更推送
53
55
  case 'sysEventPush':
54
- var clients = data.params.clients;
55
- var connectedDevice = getOptionalConnectDevice(clients);
56
- project_1.____inner_global_variable.bridgeOptionalDevice = JSON.stringify(connectedDevice);
56
+ if (typeof data === 'string') {
57
+ logger.info(data);
58
+ }
59
+ else if (typeof data === 'object' && ((_a = data === null || data === void 0 ? void 0 : data.params) === null || _a === void 0 ? void 0 : _a.clients)) {
60
+ var connectedDevice = getOptionalConnectDevice(data.params.clients);
61
+ project_1.____inner_global_variable.bridgeOptionalDevice = JSON.stringify(connectedDevice);
62
+ }
57
63
  break;
58
64
  // 处理连接设备的返回
59
65
  case 'connectClient':
60
- var _c = data.result, result = _c === void 0 ? '' : _c, _d = data.error, error = _d === void 0 ? {} : _d;
66
+ var _d = data.result, result = _d === void 0 ? '' : _d, _e = data.error, error = _e === void 0 ? {} : _e;
61
67
  if (result && result === 'success') {
62
68
  var choiredDevice = project_1.____inner_global_variable.bridgeChoiredDevice;
63
69
  logger.info("successfully connected to ".concat(choiredDevice, "."));
64
70
  }
65
71
  if (error && JSON.stringify(error) !== '{}') {
66
- var _e = data.error, _f = _e.code, code = _f === void 0 ? 0 : _f, _g = _e.message, message = _g === void 0 ? '' : _g;
72
+ var _f = data.error, _g = _f.code, code = _g === void 0 ? 0 : _g, _h = _f.message, message = _h === void 0 ? '' : _h;
67
73
  logger.error("".concat(code, ": ").concat(message));
68
74
  }
69
75
  break;
70
76
  // 监听sysSettingPush消息的返回,如uninstall删除设备(实际走的sysMessagePush)
71
77
  case 'sysSettingPush':
72
- logger.info(typeof data === 'object' ? (_a = data === null || data === void 0 ? void 0 : data.params) === null || _a === void 0 ? void 0 : _a.content : data);
78
+ if (typeof data === 'string') {
79
+ logger.info(data);
80
+ }
81
+ else if (typeof data === 'object' && ((_b = data === null || data === void 0 ? void 0 : data.params) === null || _b === void 0 ? void 0 : _b.content)) {
82
+ logger.info(data.params.content);
83
+ }
73
84
  break;
74
85
  // 监听sysMessagePush消息的返回
75
86
  case 'sysMessagePush':
76
- logger.info(typeof data === 'object' ? (_b = data === null || data === void 0 ? void 0 : data.params) === null || _b === void 0 ? void 0 : _b.content : data);
87
+ if (typeof data === 'string') {
88
+ logger.info(data);
89
+ }
90
+ else if (typeof data === 'object' && ((_c = data === null || data === void 0 ? void 0 : data.params) === null || _c === void 0 ? void 0 : _c.content)) {
91
+ logger.info(data.params.content);
92
+ }
93
+ break;
94
+ // 监听logPush消息的返回
95
+ case 'logPush':
96
+ if (typeof data === 'string') {
97
+ logger.info(data);
98
+ }
99
+ else if (typeof data === 'object' && (data === null || data === void 0 ? void 0 : data.params)) {
100
+ var _j = data.params, level = _j.level, time = _j.time, message = _j.message;
101
+ var str = "[".concat(level.toUpperCase() || 'DEBUG', " - ").concat(new Date(time).toLocaleTimeString(), "] ").concat(message);
102
+ logger.info(str);
103
+ }
77
104
  break;
78
105
  default:
79
106
  break;