@zeppos/zeus-cli 1.1.3 → 1.1.4

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
@@ -173,7 +173,9 @@ var uploadPackage = function (form, length) { return __awaiter(void 0, void 0, v
173
173
  case 1:
174
174
  _c.trys.push([1, 3, , 4]);
175
175
  return [4, axios_1["default"].post("https://".concat(_subRegionalHost, "/custom/tools/app-dial/upload?userid=").concat(_loginUserId), form, {
176
- headers: __assign(__assign({}, form.getHeaders()), { 'content-length': "".concat(length), apptoken: _loginAppToken })
176
+ headers: __assign(__assign({}, form.getHeaders()), { 'content-length': "".concat(length), apptoken: _loginAppToken }),
177
+ maxContentLength: Infinity,
178
+ maxBodyLength: Infinity
177
179
  })];
178
180
  case 2:
179
181
  packageInfo = _c.sent();
package/config/device.js CHANGED
@@ -7,6 +7,7 @@ var DeviceTarget;
7
7
  DeviceTarget["MADRID"] = "madrid";
8
8
  DeviceTarget["VERONA"] = "verona";
9
9
  DeviceTarget["ZURICH"] = "zurich";
10
+ DeviceTarget["TEIDE"] = "teide";
10
11
  })(DeviceTarget = exports.DeviceTarget || (exports.DeviceTarget = {}));
11
12
  var DevicePlatformName;
12
13
  (function (DevicePlatformName) {
@@ -16,6 +17,8 @@ var DevicePlatformName;
16
17
  DevicePlatformName["VERONAW"] = "gtr3-w";
17
18
  DevicePlatformName["ZURICH"] = "gts3";
18
19
  DevicePlatformName["ZURICHW"] = "gts3-w";
20
+ DevicePlatformName["TEIDE"] = "teide";
21
+ DevicePlatformName["TEIDEW"] = "teide-w";
19
22
  })(DevicePlatformName = exports.DevicePlatformName || (exports.DevicePlatformName = {}));
20
23
  var DeviceSource;
21
24
  (function (DeviceSource) {
@@ -25,6 +28,8 @@ var DeviceSource;
25
28
  DeviceSource[DeviceSource["VERONAW"] = 227] = "VERONAW";
26
29
  DeviceSource[DeviceSource["ZURICH"] = 224] = "ZURICH";
27
30
  DeviceSource[DeviceSource["ZURICHW"] = 225] = "ZURICHW";
31
+ DeviceSource[DeviceSource["TEIDE"] = 418] = "TEIDE";
32
+ DeviceSource[DeviceSource["TEIDEW"] = 419] = "TEIDEW";
28
33
  })(DeviceSource = exports.DeviceSource || (exports.DeviceSource = {}));
29
34
  var DeviceScreenType;
30
35
  (function (DeviceScreenType) {
@@ -86,6 +91,24 @@ exports.deviceTargets = (_a = {},
86
91
  height: 450
87
92
  }
88
93
  },
94
+ _a[DeviceTarget.TEIDE] = {
95
+ deviceName: 'TEIDE',
96
+ platforms: [
97
+ {
98
+ name: DevicePlatformName.TEIDE,
99
+ deviceSource: DeviceSource.TEIDE
100
+ },
101
+ {
102
+ name: DevicePlatformName.TEIDEW,
103
+ deviceSource: DeviceSource.TEIDEW
104
+ }
105
+ ],
106
+ screen: {
107
+ type: DeviceScreenType.R,
108
+ width: 454,
109
+ height: 454
110
+ }
111
+ },
89
112
  _a);
90
113
  exports.deviceInternalCodeName = (_b = {},
91
114
  _b[DeviceSource.MADRID] = DeviceTarget.MADRID,
@@ -94,4 +117,6 @@ exports.deviceInternalCodeName = (_b = {},
94
117
  _b[DeviceSource.VERONAW] = DeviceTarget.VERONA,
95
118
  _b[DeviceSource.ZURICH] = DeviceTarget.ZURICH,
96
119
  _b[DeviceSource.ZURICHW] = DeviceTarget.ZURICH,
120
+ _b[DeviceSource.TEIDE] = DeviceTarget.TEIDE,
121
+ _b[DeviceSource.TEIDEW] = DeviceTarget.TEIDE,
97
122
  _b);
package/modules/bridge.js CHANGED
@@ -105,14 +105,14 @@ var connectDevice = function (vorpal) { return __awaiter(void 0, void 0, void 0,
105
105
  _a.label = 3;
106
106
  case 3:
107
107
  project_1.____inner_global_variable.bridgeChoiredDevice = choiredDevice;
108
- client.sendMessage({ clientId: clientId_1 }, 'connectClient');
108
+ client.sendMessage({ clientId: clientId_1 }, { method: 'connectClient' });
109
109
  hasConnectDevice = true;
110
110
  _a.label = 4;
111
111
  case 4: return [2];
112
112
  }
113
113
  });
114
114
  }); };
115
- var connectBridgeWSCallback = function () {
115
+ var connectWSCB = function () {
116
116
  var vorpal = require('vorpal')();
117
117
  vorpal.find('help').hidden();
118
118
  vorpal.find('exit').remove();
@@ -146,7 +146,7 @@ var connectBridgeWSCallback = function () {
146
146
  case 0:
147
147
  if (!hasConnectDevice) return [3, 2];
148
148
  return [4, (0, build_1.buildPreview)({ _: ['install', "".concat(choiredDevice.toLowerCase())], '$0': 'zeus' }, function (params) {
149
- client.sendMessage(params, 'packagePush');
149
+ client.sendMessage(params, { method: 'packagePush' });
150
150
  })];
151
151
  case 1:
152
152
  _a.sent();
@@ -170,14 +170,14 @@ var connectBridgeWSCallback = function () {
170
170
  vorpal.log("".concat(chalk_1["default"].red('error'), " If the [appid] is blank, this command needs to be executed in the root of the project."));
171
171
  }
172
172
  else {
173
- vorpal.log(chalk_1["default"].blue('Uninstalling'));
173
+ vorpal.log(chalk_1["default"].blue('Uninstalling...'));
174
174
  _a = (0, common_1.getDeviceInfoFromAppJson)(), appid = _a.appId, appName = _a.appName, appType = _a.appType;
175
- client.sendMessage({ type: 'delete', appid: appid, appName: appName, appType: appType }, 'sysSettingPush');
175
+ client.sendMessage({ type: 'delete', appid: appid, appName: appName, appType: appType }, { method: 'sysSettingPush' });
176
176
  }
177
177
  }
178
178
  else if (args.appid && typeof args.appid === 'number') {
179
- vorpal.log(chalk_1["default"].blue('Uninstalling'));
180
- client.sendMessage({ type: 'delete', appid: args.appid }, 'sysSettingPush');
179
+ vorpal.log(chalk_1["default"].blue('Uninstalling...'));
180
+ client.sendMessage({ type: 'delete', appid: args.appid }, { method: 'sysSettingPush' });
181
181
  }
182
182
  else if (args.appid) {
183
183
  vorpal.log("".concat(chalk_1["default"].red('error'), " invalid '").concat(args.appid, "', the 'uninstall' command should be followed by appid or blank."));
@@ -186,8 +186,28 @@ var connectBridgeWSCallback = function () {
186
186
  return [2];
187
187
  });
188
188
  }); });
189
+ vorpal
190
+ .command('screenshot', 'Screenshot of the current watch device.').hidden()
191
+ .action(function (args, cb) { return __awaiter(void 0, void 0, void 0, function () {
192
+ return __generator(this, function (_a) {
193
+ if (hasConnectDevice) {
194
+ if (choiredDevice.indexOf('app') > -1) {
195
+ vorpal.log(chalk_1["default"].blue('Waiting...'));
196
+ client.sendMessage({ type: 'screenshot' }, { method: 'sysSettingPush' });
197
+ }
198
+ else {
199
+ vorpal.log(chalk_1["default"].yellow("Only the connected device is an app that can use the screenshot command."));
200
+ }
201
+ }
202
+ else {
203
+ vorpal.log(chalk_1["default"].yellow("No device is connected, please connect the device with the command width 'connect' first."));
204
+ }
205
+ cb();
206
+ return [2];
207
+ });
208
+ }); });
189
209
  };
190
- var disConnectBridgeWSCallback = function () {
210
+ var disConnectWSCB = function () {
191
211
  hasConnectDevice = false;
192
212
  logger.log('Disconnected');
193
213
  process.exit(1);
@@ -203,8 +223,8 @@ var bridge = function (args) { return __awaiter(void 0, void 0, void 0, function
203
223
  bridgeWebSocketURL = _a.sent();
204
224
  client = new websocket_1["default"]({
205
225
  url: "".concat(bridgeWebSocketURL, "?type=development&name=CLI"),
206
- connectCb: connectBridgeWSCallback,
207
- disconnectCb: disConnectBridgeWSCallback
226
+ connectWSCB: connectWSCB,
227
+ disConnectWSCB: disConnectWSCB
208
228
  });
209
229
  logger.log(" - Enter 'help' to view the command.");
210
230
  return [3, 6];
package/modules/run.js CHANGED
@@ -113,7 +113,7 @@ var run = function (args) { return __awaiter(void 0, void 0, void 0, function ()
113
113
  simulatorWebSocketURL = "http://".concat(simulatorHost, ":").concat(simulatorPort);
114
114
  simulator = new simulator_1.Simulator(simulatorWebSocketURL);
115
115
  refreshSimulator = lodash_1["default"].debounce(function () { return __awaiter(void 0, void 0, void 0, function () {
116
- var zpkBuffer, _a, targetDeviceInternalName, appId, projectName;
116
+ var zpkBuffer, _a, targetDeviceInternalName, appId, devices, projectName;
117
117
  return __generator(this, function (_b) {
118
118
  switch (_b.label) {
119
119
  case 0:
@@ -124,9 +124,9 @@ var run = function (args) { return __awaiter(void 0, void 0, void 0, function ()
124
124
  if (zpkBuffer) {
125
125
  logger.info('rebuild done');
126
126
  logger.info('refreshing simulator...');
127
- _a = (0, common_1.getDeviceInfoFromAppJson)(packages[0]), targetDeviceInternalName = _a.targetDeviceInternalName, appId = _a.appId;
127
+ _a = (0, common_1.getDeviceInfoFromAppJson)(packages[0]), targetDeviceInternalName = _a.targetDeviceInternalName, appId = _a.appId, devices = _a.deviceSourceArr;
128
128
  projectName = path.parse(process.cwd()).base;
129
- simulator.upload(zpkBuffer, projectName, targetDeviceInternalName, appId);
129
+ simulator.upload(zpkBuffer, projectName, targetDeviceInternalName, appId, devices);
130
130
  }
131
131
  else {
132
132
  logger.error('build error');
@@ -51,14 +51,15 @@ var Simulator = (function () {
51
51
  Simulator.prototype.emit = function (space, jsonData) {
52
52
  this.socket.emit(space, jsonData);
53
53
  };
54
- Simulator.prototype.upload = function (data, projectName, target, appid) {
54
+ Simulator.prototype.upload = function (data, projectName, target, appid, devices) {
55
55
  var dataArr = this.uint8ToArray(new Uint8Array(data));
56
56
  var message = this.encodeMessage({
57
57
  target: target,
58
58
  projectName: projectName,
59
59
  appid: appid,
60
60
  size: data.byteLength,
61
- data: dataArr
61
+ data: dataArr,
62
+ devices: devices
62
63
  });
63
64
  this.sendMessage(message);
64
65
  };
@@ -31,7 +31,7 @@ var ws_1 = __importDefault(require("ws"));
31
31
  var common_1 = require("../utils/common");
32
32
  var WebSocketClass = (function () {
33
33
  function WebSocketClass(_a) {
34
- var url = _a.url, connectCb = _a.connectCb, disconnectCb = _a.disconnectCb;
34
+ var url = _a.url, connectWSCB = _a.connectWSCB, disConnectWSCB = _a.disConnectWSCB;
35
35
  var _this = this;
36
36
  this.msgEventIDs = {};
37
37
  this.handleListenMsgEventReturn = function (data) {
@@ -60,11 +60,11 @@ var WebSocketClass = (function () {
60
60
  };
61
61
  this.socket = new ws_1["default"](url);
62
62
  this.socket.on('open', function () {
63
- connectCb();
63
+ connectWSCB();
64
64
  _this.listenEvent();
65
65
  });
66
66
  this.socket.on('close', function () {
67
- disconnectCb();
67
+ disConnectWSCB();
68
68
  });
69
69
  this.socket.on('error', function (error) {
70
70
  logger.error(error);
@@ -79,23 +79,32 @@ var WebSocketClass = (function () {
79
79
  WebSocketClass.prototype.uint8ToArray = function (source) {
80
80
  return Array.prototype.slice.call(source);
81
81
  };
82
- WebSocketClass.prototype.sendMessage = function (params, method) {
82
+ WebSocketClass.prototype.sendMessage = function (params, options) {
83
+ if (options === void 0) { options = {}; }
83
84
  var msgParams;
84
85
  var msg = params;
86
+ var _a = options.method, method = _a === void 0 ? '' : _a;
85
87
  if (method) {
86
88
  msgParams = {
87
89
  method: method,
88
90
  params: params,
89
91
  jsonrpc: '2.0',
90
- id: this.createMsgEventID(method)
92
+ id: this.createMsgEventID(method, params === null || params === void 0 ? void 0 : params.type)
91
93
  };
92
94
  msg = JSON.stringify(msgParams);
93
95
  }
94
96
  this.socket.send(msg, { binary: false });
95
97
  };
96
- WebSocketClass.prototype.createMsgEventID = function (method) {
97
- var id = Math.round(Math.random() * 100);
98
- this.msgEventIDs[method] = id;
98
+ WebSocketClass.prototype.createMsgEventID = function (method, type) {
99
+ var id = parseInt('' + Math.random() * 10000);
100
+ var prop = method;
101
+ var typeMap = {
102
+ 'screenshot': 'screenShot'
103
+ };
104
+ if (type && typeMap[type]) {
105
+ prop = typeMap[type];
106
+ }
107
+ this.msgEventIDs[prop] = id;
99
108
  return id;
100
109
  };
101
110
  return WebSocketClass;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeppos/zeus-cli",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "zeus mini-program tools",
5
5
  "main": "index.js",
6
6
  "author": "zepp",
package/utils/common.js CHANGED
@@ -29,6 +29,7 @@ exports.__esModule = true;
29
29
  exports.getDeviceInfoFromAppJson = exports.handleListenMsgEvent = exports.getOptionalConnectDevice = exports.uint8ToArray = void 0;
30
30
  var path = __importStar(require("path"));
31
31
  var fs_1 = __importDefault(require("fs"));
32
+ var os_1 = __importDefault(require("os"));
32
33
  var logger = __importStar(require("./logger"));
33
34
  var storage_1 = require("../modules/storage");
34
35
  var project_1 = require("../config/project");
@@ -97,6 +98,17 @@ function handleListenMsgEvent(msgEventName, data) {
97
98
  logger.info(str);
98
99
  }
99
100
  break;
101
+ case 'screenShot':
102
+ var path_1 = "".concat(os_1["default"].homedir(), "/desktop/screenShot.png");
103
+ fs_1["default"].writeFile(path_1, Buffer.from(data.result, 'hex'), function (err) {
104
+ if (err) {
105
+ logger.log('screenShot error', err);
106
+ }
107
+ else {
108
+ logger.success("screenShot path:".concat(path_1));
109
+ }
110
+ });
111
+ break;
100
112
  default:
101
113
  break;
102
114
  }