@zeppos/zeus-cli 1.3.2 → 1.3.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/bin/main.js CHANGED
@@ -51,6 +51,13 @@ var index_1 = require("../index");
51
51
  var zeppos_app_utils_1 = require("zeppos-app-utils");
52
52
  var login = zeppos_app_utils_1.modules.login, logout = zeppos_app_utils_1.modules.logout, status = zeppos_app_utils_1.modules.status, modulesConfig = zeppos_app_utils_1.modules.config;
53
53
  var context = {};
54
+ var yargsCmdBuilderFunc = function (cmdName, useProxy, yargs) {
55
+ if (useProxy === void 0) { useProxy = false; }
56
+ useProxy && proxy(yargs);
57
+ if (cmdName in index_1.yargsCmdBuilders) {
58
+ return index_1.yargsCmdBuilders[cmdName](yargs);
59
+ }
60
+ };
54
61
  var proxy = function (args) { return __awaiter(void 0, void 0, void 0, function () {
55
62
  var res;
56
63
  return __generator(this, function (_a) {
@@ -72,6 +79,8 @@ yargs_1["default"].usage("Usage: ".concat(process.env.CMD_NAME, " <command> [arg
72
79
  .demandCommand(1, 'A command is required. Pass --help to see all available commands and options.')
73
80
  .recommendCommands()
74
81
  .help()
82
+ .version(false)
83
+ .version((0, index_1.version)())
75
84
  .alias('h', 'help').describe('help', 'Display help information.')
76
85
  .alias('v', 'version').describe('version', 'Display version number.')
77
86
  .group(['help', 'version'], "Base Options")
@@ -79,7 +88,7 @@ yargs_1["default"].usage("Usage: ".concat(process.env.CMD_NAME, " <command> [arg
79
88
  .command('create <projectName>', 'Named the <projectName> project and add to the current directory.', proxy, index_1.create)
80
89
  .command('login', 'Login to your account.', proxy, login)
81
90
  .command('logout', 'Sign out of your account.', proxy, logout)
82
- .command('dev', 'Run this project in development mode.', proxy, index_1.run)
91
+ .command('dev', 'Run this project in development mode. Use "zeus dev -h" to see more information', yargsCmdBuilderFunc.bind(null, 'dev', true), index_1.run)
83
92
  .command('preview', 'Preview this project in your device.', proxy, index_1.buildPreview)
84
93
  .command('build', 'Build this project for production.', proxy, index_1.buildProd)
85
94
  .command('status', 'View information such as login and emulator connection status.', proxy, status)
package/index.js CHANGED
@@ -19,3 +19,5 @@ __exportStar(require("./modules/run"), exports);
19
19
  __exportStar(require("./modules/build"), exports);
20
20
  __exportStar(require("./modules/create"), exports);
21
21
  __exportStar(require("./modules/bridge"), exports);
22
+ __exportStar(require("./modules/version"), exports);
23
+ __exportStar(require("./modules/yargsCmdBuilders"), exports);
package/modules/bridge.js CHANGED
@@ -137,21 +137,28 @@ var connectWSCB = function () {
137
137
  });
138
138
  }); });
139
139
  vorpal
140
- .command('install', 'Install applications or watch face.')
140
+ .command('install', 'Install applications or watch faces.')
141
+ .option('-t, --target "<target>"', 'Setting the installation target')
142
+ .types({
143
+ string: ['t', 'target']
144
+ })
141
145
  .action(function (args, cb) { return __awaiter(void 0, void 0, void 0, function () {
142
- return __generator(this, function (_a) {
143
- switch (_a.label) {
146
+ var target;
147
+ var _a;
148
+ return __generator(this, function (_b) {
149
+ switch (_b.label) {
144
150
  case 0:
145
151
  if (!hasConnectDevice) return [3, 2];
146
- return [4, (0, build_1.buildPreview)({ _: ['install', "".concat(choiredDevice.toLowerCase())], '$0': 'zeus' }, function (params) {
152
+ target = ((_a = args === null || args === void 0 ? void 0 : args.options) === null || _a === void 0 ? void 0 : _a.target) || '';
153
+ return [4, (0, build_1.buildPreview)({ _: ['install', "".concat(choiredDevice.toLowerCase())], '$0': 'zeus', target: target }, function (params) {
147
154
  client.sendMessage(params, { method: 'packagePush' });
148
155
  })];
149
156
  case 1:
150
- _a.sent();
157
+ _b.sent();
151
158
  return [3, 3];
152
159
  case 2:
153
160
  vorpal.log(chalk_1["default"].yellow("No device is connected, please connect the device with the command width 'connect' first."));
154
- _a.label = 3;
161
+ _b.label = 3;
155
162
  case 3:
156
163
  (0, zeppos_app_utils_2.HM_Analytics)("ZEPP_CLI_BRIDGE_INSTALL_C");
157
164
  cb();
package/modules/build.js CHANGED
@@ -112,11 +112,12 @@ var checkAppJson = function () {
112
112
  var chooseBuildTargetsV3Config = function (mode, args) {
113
113
  if (mode === void 0) { mode = 'development'; }
114
114
  return __awaiter(void 0, void 0, void 0, function () {
115
- var apiLevel, platforms, usefulScreenTypes, usefulDeviceSource, targetDevices, deviceNames, answers;
116
- return __generator(this, function (_a) {
117
- switch (_a.label) {
115
+ var target, apiLevel, platforms, usefulScreenTypes, usefulDeviceSource, targetDevices, deviceNames, isValidDevice, answers, _a;
116
+ return __generator(this, function (_b) {
117
+ switch (_b.label) {
118
118
  case 0:
119
119
  checkAppJson();
120
+ target = args.target;
120
121
  apiLevel = (0, lodash_1.get)(appJsonContent, 'runtime.apiVersion.minVersion', '1.0.0');
121
122
  platforms = Object.values((0, lodash_1.get)(appJsonContent, 'targets', {})).reduce(function (list, item) {
122
123
  return list.concat((0, lodash_1.get)(item, 'platforms', []));
@@ -140,16 +141,26 @@ var chooseBuildTargetsV3Config = function (mode, args) {
140
141
  zeppos_app_utils_1.logger.error("The current project's API Level version is too high and there is no available device for debugging currently.");
141
142
  process.exit(1);
142
143
  }
143
- return [4, inquirer_1["default"].prompt([
144
- {
145
- name: 'device',
146
- type: 'list',
147
- message: 'Which device would you like to preview?',
148
- choices: deviceNames
149
- },
150
- ])];
151
- case 1:
152
- answers = _a.sent();
144
+ isValidDevice = deviceNames.includes(target);
145
+ if (target && !isValidDevice) {
146
+ zeppos_app_utils_1.logger.warn("'".concat(target, "' is not a valid device, it must be one of ").concat(JSON.stringify(deviceNames)));
147
+ }
148
+ if (!isValidDevice) return [3, 1];
149
+ _a = target;
150
+ return [3, 3];
151
+ case 1: return [4, inquirer_1["default"].prompt([
152
+ {
153
+ name: 'device',
154
+ type: 'list',
155
+ message: 'Which device would you like to preview?',
156
+ choices: deviceNames
157
+ },
158
+ ])];
159
+ case 2:
160
+ _a = _b.sent();
161
+ _b.label = 3;
162
+ case 3:
163
+ answers = _a;
153
164
  return [2, {
154
165
  sources: (0, lodash_1.get)(targetDevices, "[".concat(answers.device, "].platforms"), []).reduce(function (list, item) {
155
166
  list.push(Number(item.deviceSource));
@@ -205,6 +216,9 @@ var chooseBuildTargetsV2Config = function (mode, args) {
205
216
  if (bool) {
206
217
  args.target = promptTarget_1;
207
218
  }
219
+ else if (promptTarget_1) {
220
+ zeppos_app_utils_1.logger.warn("'".concat(promptTarget_1, "' is not a valid target, it must be one of ").concat(JSON.stringify(targets)));
221
+ }
208
222
  return mode !== BuildMode.PROD && !bool;
209
223
  },
210
224
  message: 'Which target would you like to preview?',
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var _a;
3
+ exports.__esModule = true;
4
+ exports.version = void 0;
5
+ var appUtilPkg = require('zeppos-app-utils/package.json');
6
+ var zeusVersion = require('../package.json').version;
7
+ var zpmVersion = ((_a = appUtilPkg === null || appUtilPkg === void 0 ? void 0 : appUtilPkg.dependencies) === null || _a === void 0 ? void 0 : _a['@zeppos/zpm']) || '';
8
+ function version() {
9
+ var versionNum = zpmVersion.match(/(\d+\.){2}\d+/);
10
+ var zpmVersionTip = Array.isArray(versionNum) ? "\u001B[2m(zpm v".concat(versionNum[0], ")\u001B[0m") : '';
11
+ var stdout = "".concat(zeusVersion, " ").concat(zpmVersionTip);
12
+ return stdout;
13
+ }
14
+ exports.version = version;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.yargsCmdBuilders = void 0;
4
+ exports.yargsCmdBuilders = {
5
+ dev: function (yargs) {
6
+ return yargs
7
+ .usage('$0 dev -t, --target "<target>"')
8
+ .option('target', {
9
+ alias: 't',
10
+ type: 'string',
11
+ describe: 'Setting the preview target'
12
+ })
13
+ .help();
14
+ }
15
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeppos/zeus-cli",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "zeus mini-program tools",
5
5
  "main": "index.ts",
6
6
  "author": "zepp",
@@ -21,7 +21,7 @@
21
21
  "qrcode-terminal": "^0.12.0",
22
22
  "vorpal": "^1.12.0",
23
23
  "yargs": "^17.5.1",
24
- "@zeppos/zpm": "^3.0.0",
24
+ "@zeppos/zpm": "^3.0.1",
25
25
  "axios": "^0.27.2",
26
26
  "chalk": "^4.1.2",
27
27
  "chokidar": "^3.5.3",
@@ -33,7 +33,6 @@ var path = __importStar(require("path"));
33
33
  var fs = __importStar(require("fs"));
34
34
  var fs_extra_1 = __importDefault(require("fs-extra"));
35
35
  var lodash_1 = require("lodash");
36
- var logger_1 = require("../logger");
37
36
  var LOCAL_CACHE_DEVICE_PATH = path.resolve(os.homedir(), ".zepp/.zeus_devices");
38
37
  var serverPath = 'https://upload-cdn.zepp.com/zeppos/devkit/zeus/devices.json';
39
38
  var DeviceScreenType;
@@ -66,9 +65,8 @@ if (!((0, lodash_1.get)(localContent, 'expiredTime') > now)) {
66
65
  });
67
66
  }
68
67
  }
69
- })["catch"](function () {
70
- console.log();
71
- logger_1.logger.error('[Fetch remote device list]: please check network status');
68
+ })["catch"](function (e) {
69
+ console.log(e);
72
70
  process.exit(1);
73
71
  });
74
72
  }
@@ -13,459 +13,18 @@ var __assign = (this && this.__assign) || function () {
13
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
- var _a;
17
16
  exports.__esModule = true;
18
- exports.deviceInternalCodeName = exports.OSV2DeviceTargetNames = exports.OSV2Devices = exports.deviceTargets = exports.DeviceScreenType = exports.DeviceSource = exports.DevicePlatformName = exports.DeviceTarget = void 0;
17
+ exports.deviceInternalCodeName = exports.OSV2DeviceTargetNames = exports.OSV2Devices = exports.deviceTargets = exports.DeviceScreenType = void 0;
19
18
  var lodash_1 = require("lodash");
20
19
  var device_server_1 = __importDefault(require("./device-server"));
21
20
  var tools_1 = require("../tools/tools");
22
- var DeviceTarget;
23
- (function (DeviceTarget) {
24
- DeviceTarget["MADRID"] = "madrid";
25
- DeviceTarget["VERONA"] = "verona";
26
- DeviceTarget["ZURICH"] = "zurich";
27
- DeviceTarget["TEIDE"] = "teide";
28
- DeviceTarget["PROVENCE"] = "provence";
29
- DeviceTarget["BARI"] = "bari";
30
- DeviceTarget["BERLIN"] = "berlin";
31
- DeviceTarget["LILLE"] = "lille";
32
- DeviceTarget["VIENNA"] = "vienna";
33
- DeviceTarget["ANDES"] = "andes";
34
- DeviceTarget["MONACO"] = "monaco";
35
- DeviceTarget["SWIFT"] = "swift";
36
- DeviceTarget["SWORDFISH"] = "swordfishw";
37
- DeviceTarget["CHEETAH"] = "cheetahw";
38
- DeviceTarget["HANNOVER"] = "hannover";
39
- DeviceTarget["ETNA"] = "etna";
40
- DeviceTarget["ALTAI"] = "altai";
41
- })(DeviceTarget = exports.DeviceTarget || (exports.DeviceTarget = {}));
42
- var DevicePlatformName;
43
- (function (DevicePlatformName) {
44
- DevicePlatformName["MADRID"] = "gtr3-pro";
45
- DevicePlatformName["MADRIDW"] = "gtr3-pro-w";
46
- DevicePlatformName["Madrid2"] = "gtr3-pro-meilin";
47
- DevicePlatformName["VERONA"] = "gtr3";
48
- DevicePlatformName["VERONAW"] = "gtr3-w";
49
- DevicePlatformName["ZURICH"] = "gts3";
50
- DevicePlatformName["ZURICHW"] = "gts3-w";
51
- DevicePlatformName["TEIDE"] = "t-rex2";
52
- DevicePlatformName["TEIDEW"] = "t-rex2-w";
53
- DevicePlatformName["PROVENCE"] = "gts4-mini";
54
- DevicePlatformName["PROVENCEW"] = "gts4-mini-w";
55
- DevicePlatformName["BARI_NFC"] = "amazfit-band7-nfc";
56
- DevicePlatformName["BARI"] = "amazfit-band7";
57
- DevicePlatformName["BARI_W"] = "amazfit-band7-w";
58
- DevicePlatformName["BERLIN"] = "gtr4";
59
- DevicePlatformName["BERLIN_W"] = "gtr4-w";
60
- DevicePlatformName["LILLE"] = "gts4";
61
- DevicePlatformName["LILLE_W"] = "gts4-w";
62
- DevicePlatformName["VIENNA"] = "falcon";
63
- DevicePlatformName["VIENNA_W"] = "falcon-w";
64
- DevicePlatformName["ANDES"] = "t-rex-ultra";
65
- DevicePlatformName["ANDES_W"] = "t-rex-ultra-w";
66
- DevicePlatformName["MONACO"] = "monaco";
67
- DevicePlatformName["MONACO_WN"] = "monaco-wn";
68
- DevicePlatformName["MONACO_W"] = "monaco-w";
69
- DevicePlatformName["SWIFT"] = "swift";
70
- DevicePlatformName["SWIFT_W"] = "swift-w";
71
- DevicePlatformName["SWORDFISH_W"] = "swordfish-w";
72
- DevicePlatformName["CHEETAH_W"] = "cheetah-w";
73
- DevicePlatformName["HANNOVER"] = "hannover";
74
- DevicePlatformName["ETNA"] = "etna";
75
- DevicePlatformName["ETNA_W"] = "etna-w";
76
- DevicePlatformName["ALTAI"] = "altai";
77
- })(DevicePlatformName = exports.DevicePlatformName || (exports.DevicePlatformName = {}));
78
- var DeviceSource;
79
- (function (DeviceSource) {
80
- DeviceSource[DeviceSource["MADRID"] = 229] = "MADRID";
81
- DeviceSource[DeviceSource["MADRIDW"] = 230] = "MADRIDW";
82
- DeviceSource[DeviceSource["Madrid2"] = 6095106] = "Madrid2";
83
- DeviceSource[DeviceSource["VERONA"] = 226] = "VERONA";
84
- DeviceSource[DeviceSource["VERONAW"] = 227] = "VERONAW";
85
- DeviceSource[DeviceSource["ZURICH"] = 224] = "ZURICH";
86
- DeviceSource[DeviceSource["ZURICHW"] = 225] = "ZURICHW";
87
- DeviceSource[DeviceSource["TEIDE"] = 418] = "TEIDE";
88
- DeviceSource[DeviceSource["TEIDEW"] = 419] = "TEIDEW";
89
- DeviceSource[DeviceSource["PROVENCE"] = 246] = "PROVENCE";
90
- DeviceSource[DeviceSource["PROVENCEW"] = 247] = "PROVENCEW";
91
- DeviceSource[DeviceSource["BARI_NFC"] = 252] = "BARI_NFC";
92
- DeviceSource[DeviceSource["BARI"] = 253] = "BARI";
93
- DeviceSource[DeviceSource["BARI_W"] = 254] = "BARI_W";
94
- DeviceSource[DeviceSource["BERLIN"] = 7930112] = "BERLIN";
95
- DeviceSource[DeviceSource["BERLIN_W"] = 7930113] = "BERLIN_W";
96
- DeviceSource[DeviceSource["LILLE"] = 7995648] = "LILLE";
97
- DeviceSource[DeviceSource["LILLE_W"] = 7995649] = "LILLE_W";
98
- DeviceSource[DeviceSource["VIENNA"] = 414] = "VIENNA";
99
- DeviceSource[DeviceSource["VIENNA_W"] = 415] = "VIENNA_W";
100
- DeviceSource[DeviceSource["ANDES"] = 6553856] = "ANDES";
101
- DeviceSource[DeviceSource["ANDES_W"] = 6553857] = "ANDES_W";
102
- DeviceSource[DeviceSource["MONACO"] = 8519936] = "MONACO";
103
- DeviceSource[DeviceSource["MONACO_WN"] = 8519937] = "MONACO_WN";
104
- DeviceSource[DeviceSource["MONACO_W"] = 8519939] = "MONACO_W";
105
- DeviceSource[DeviceSource["SWIFT"] = 8192256] = "SWIFT";
106
- DeviceSource[DeviceSource["SWIFT_W"] = 8192257] = "SWIFT_W";
107
- DeviceSource[DeviceSource["SWORDFISH_W"] = 8257793] = "SWORDFISH_W";
108
- DeviceSource[DeviceSource["CHEETAH_W"] = 8126721] = "CHEETAH_W";
109
- DeviceSource[DeviceSource["HANNOVER"] = 8323329] = "HANNOVER";
110
- DeviceSource[DeviceSource["ETNA"] = 8388864] = "ETNA";
111
- DeviceSource[DeviceSource["ETNA_W"] = 8388865] = "ETNA_W";
112
- DeviceSource[DeviceSource["ALTAI"] = 8454401] = "ALTAI";
113
- })(DeviceSource = exports.DeviceSource || (exports.DeviceSource = {}));
114
21
  var DeviceScreenType;
115
22
  (function (DeviceScreenType) {
116
23
  DeviceScreenType["R"] = "r";
117
24
  DeviceScreenType["S"] = "s";
118
25
  DeviceScreenType["B"] = "b";
119
26
  })(DeviceScreenType = exports.DeviceScreenType || (exports.DeviceScreenType = {}));
120
- exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
121
- deviceName: 'GTR3 Pro',
122
- platforms: [
123
- {
124
- name: DevicePlatformName.MADRID,
125
- deviceSource: DeviceSource.MADRID
126
- },
127
- {
128
- name: DevicePlatformName.MADRIDW,
129
- deviceSource: DeviceSource.MADRIDW
130
- },
131
- {
132
- name: DevicePlatformName.Madrid2,
133
- deviceSource: DeviceSource.Madrid2
134
- },
135
- ],
136
- screen: {
137
- type: DeviceScreenType.R,
138
- width: 480,
139
- height: 480
140
- },
141
- apiLevelLimit: {
142
- min: '1.0.0',
143
- max: '1.99.99'
144
- }
145
- }, _a[DeviceTarget.VERONA] = {
146
- deviceName: 'GTR3',
147
- platforms: [
148
- {
149
- name: DevicePlatformName.VERONA,
150
- deviceSource: DeviceSource.VERONA
151
- },
152
- {
153
- name: DevicePlatformName.VERONAW,
154
- deviceSource: DeviceSource.VERONAW
155
- },
156
- ],
157
- screen: {
158
- type: DeviceScreenType.R,
159
- width: 454,
160
- height: 454
161
- },
162
- apiLevelLimit: {
163
- min: '1.0.0',
164
- max: '1.99.99'
165
- }
166
- }, _a[DeviceTarget.ZURICH] = {
167
- deviceName: 'GTS3',
168
- platforms: [
169
- {
170
- name: DevicePlatformName.ZURICH,
171
- deviceSource: DeviceSource.ZURICH
172
- },
173
- {
174
- name: DevicePlatformName.ZURICHW,
175
- deviceSource: DeviceSource.ZURICHW
176
- },
177
- ],
178
- screen: {
179
- type: DeviceScreenType.S,
180
- width: 390,
181
- height: 450
182
- },
183
- apiLevelLimit: {
184
- min: '1.0.0',
185
- max: '1.99.99'
186
- }
187
- }, _a[DeviceTarget.TEIDE] = {
188
- deviceName: 'T-Rex2',
189
- platforms: [
190
- {
191
- name: DevicePlatformName.TEIDE,
192
- deviceSource: DeviceSource.TEIDE
193
- },
194
- {
195
- name: DevicePlatformName.TEIDEW,
196
- deviceSource: DeviceSource.TEIDEW
197
- },
198
- ],
199
- screen: {
200
- type: DeviceScreenType.R,
201
- width: 454,
202
- height: 454
203
- },
204
- apiLevelLimit: {
205
- min: '1.0.0',
206
- max: '1.99.99'
207
- }
208
- }, _a[DeviceTarget.PROVENCE] = {
209
- deviceName: 'GTS4 mini',
210
- platforms: [
211
- {
212
- name: DevicePlatformName.PROVENCE,
213
- deviceSource: DeviceSource.PROVENCE
214
- },
215
- {
216
- name: DevicePlatformName.PROVENCEW,
217
- deviceSource: DeviceSource.PROVENCEW
218
- },
219
- ],
220
- screen: {
221
- type: DeviceScreenType.S,
222
- width: 336,
223
- height: 384
224
- },
225
- apiLevelLimit: {
226
- min: '1.0.0',
227
- max: '1.99.99'
228
- }
229
- }, _a[DeviceTarget.BARI] = {
230
- deviceName: 'Amazfit Band 7',
231
- platforms: [
232
- {
233
- name: DevicePlatformName.BARI_NFC,
234
- deviceSource: DeviceSource.BARI_NFC
235
- },
236
- {
237
- name: DevicePlatformName.BARI,
238
- deviceSource: DeviceSource.BARI
239
- },
240
- {
241
- name: DevicePlatformName.BARI_W,
242
- deviceSource: DeviceSource.BARI_W
243
- },
244
- ],
245
- screen: {
246
- type: DeviceScreenType.B,
247
- width: 194,
248
- height: 368
249
- },
250
- apiLevelLimit: {
251
- min: '1.0.0',
252
- max: '1.99.99'
253
- }
254
- }, _a[DeviceTarget.BERLIN] = {
255
- deviceName: 'GTR 4',
256
- platforms: [
257
- {
258
- name: DevicePlatformName.BERLIN,
259
- deviceSource: DeviceSource.BERLIN
260
- },
261
- {
262
- name: DevicePlatformName.BERLIN_W,
263
- deviceSource: DeviceSource.BERLIN_W
264
- },
265
- ],
266
- screen: {
267
- type: DeviceScreenType.R,
268
- width: 466,
269
- height: 466
270
- },
271
- apiLevelLimit: {
272
- min: '1.0.0',
273
- max: '2.99.99'
274
- }
275
- }, _a[DeviceTarget.LILLE] = {
276
- deviceName: 'GTS 4',
277
- platforms: [
278
- {
279
- name: DevicePlatformName.LILLE,
280
- deviceSource: DeviceSource.LILLE
281
- },
282
- {
283
- name: DevicePlatformName.LILLE_W,
284
- deviceSource: DeviceSource.LILLE_W
285
- },
286
- ],
287
- screen: {
288
- type: DeviceScreenType.S,
289
- width: 390,
290
- height: 450
291
- },
292
- apiLevelLimit: {
293
- min: '1.0.0',
294
- max: '2.99.99'
295
- }
296
- }, _a[DeviceTarget.VIENNA] = {
297
- deviceName: 'Falcon',
298
- platforms: [
299
- {
300
- name: DevicePlatformName.VIENNA,
301
- deviceSource: DeviceSource.VIENNA
302
- },
303
- {
304
- name: DevicePlatformName.VIENNA_W,
305
- deviceSource: DeviceSource.VIENNA_W
306
- },
307
- ],
308
- screen: {
309
- type: DeviceScreenType.R,
310
- width: 416,
311
- height: 416
312
- },
313
- apiLevelLimit: {
314
- min: '1.0.0',
315
- max: '1.99.99'
316
- }
317
- }, _a[DeviceTarget.ANDES] = {
318
- deviceName: 'T-Rex Ultra',
319
- platforms: [
320
- {
321
- name: DevicePlatformName.ANDES,
322
- deviceSource: DeviceSource.ANDES
323
- },
324
- {
325
- name: DevicePlatformName.ANDES_W,
326
- deviceSource: DeviceSource.ANDES_W
327
- },
328
- ],
329
- screen: {
330
- type: DeviceScreenType.R,
331
- width: 454,
332
- height: 454
333
- },
334
- apiLevelLimit: {
335
- min: '1.0.0',
336
- max: '2.99.99'
337
- }
338
- }, _a[DeviceTarget.MONACO] = {
339
- deviceName: 'Amazfit Balance',
340
- platforms: [
341
- {
342
- name: DevicePlatformName.MONACO,
343
- deviceSource: DeviceSource.MONACO
344
- },
345
- {
346
- name: DevicePlatformName.MONACO_WN,
347
- deviceSource: DeviceSource.MONACO_WN
348
- },
349
- {
350
- name: DevicePlatformName.MONACO_W,
351
- deviceSource: DeviceSource.MONACO_W
352
- },
353
- ],
354
- screen: {
355
- type: DeviceScreenType.R,
356
- width: 480,
357
- height: 480
358
- },
359
- apiLevelLimit: {
360
- min: '1.0.0',
361
- max: '3.99.99'
362
- }
363
- }, _a[DeviceTarget.SWIFT] = {
364
- deviceName: 'Runner (Round)',
365
- platforms: [
366
- {
367
- name: DevicePlatformName.SWIFT,
368
- deviceSource: DeviceSource.SWIFT
369
- },
370
- {
371
- name: DevicePlatformName.SWIFT_W,
372
- deviceSource: DeviceSource.SWIFT_W
373
- },
374
- ],
375
- screen: {
376
- type: DeviceScreenType.R,
377
- width: 454,
378
- height: 454
379
- },
380
- apiLevelLimit: {
381
- min: '1.0.0'
382
- }
383
- }, _a[DeviceTarget.SWORDFISH] = {
384
- deviceName: 'Runner (Square)',
385
- platforms: [
386
- {
387
- name: DevicePlatformName.SWORDFISH_W,
388
- deviceSource: DeviceSource.SWORDFISH_W
389
- },
390
- ],
391
- screen: {
392
- type: DeviceScreenType.S,
393
- width: 390,
394
- height: 450
395
- },
396
- apiLevelLimit: {
397
- min: '1.0.0'
398
- }
399
- }, _a[DeviceTarget.CHEETAH] = {
400
- deviceName: 'Runner Pro',
401
- platforms: [
402
- {
403
- name: DevicePlatformName.CHEETAH_W,
404
- deviceSource: DeviceSource.CHEETAH_W
405
- },
406
- ],
407
- screen: {
408
- type: DeviceScreenType.R,
409
- width: 480,
410
- height: 480
411
- },
412
- apiLevelLimit: {
413
- min: '1.0.0'
414
- }
415
- }, _a[DeviceTarget.HANNOVER] = {
416
- deviceName: 'Amazfit Active',
417
- platforms: [
418
- {
419
- name: DevicePlatformName.HANNOVER,
420
- deviceSource: DeviceSource.HANNOVER
421
- },
422
- ],
423
- screen: {
424
- type: DeviceScreenType.S,
425
- width: 390,
426
- height: 450
427
- },
428
- apiLevelLimit: {
429
- min: '1.0.0'
430
- }
431
- }, _a[DeviceTarget.ETNA] = {
432
- deviceName: 'GTR Shock',
433
- platforms: [
434
- {
435
- name: DevicePlatformName.ETNA,
436
- deviceSource: DeviceSource.ETNA
437
- },
438
- {
439
- name: DevicePlatformName.ETNA_W,
440
- deviceSource: DeviceSource.ETNA_W
441
- },
442
- ],
443
- screen: {
444
- type: DeviceScreenType.S,
445
- width: 360,
446
- height: 360
447
- },
448
- apiLevelLimit: {
449
- min: '1.0.0'
450
- }
451
- }, _a[DeviceTarget.ALTAI] = {
452
- deviceName: 'Bip 5s',
453
- platforms: [
454
- {
455
- name: DevicePlatformName.ALTAI,
456
- deviceSource: DeviceSource.ALTAI
457
- },
458
- ],
459
- screen: {
460
- type: DeviceScreenType.S,
461
- width: 320,
462
- height: 380
463
- },
464
- apiLevelLimit: {
465
- min: '1.0.0',
466
- max: '2.99.99'
467
- }
468
- }, _a), device_server_1["default"]);
27
+ exports.deviceTargets = __assign({}, device_server_1["default"]);
469
28
  exports.OSV2Devices = Object.values(exports.deviceTargets).reduce(function (targetDevices, target) {
470
29
  var _a = target.platforms, platforms = _a === void 0 ? [] : _a, _b = target.apiLevelLimit, apiLevelLimit = _b === void 0 ? {} : _b;
471
30
  var min = apiLevelLimit.min, max = apiLevelLimit.max;
@@ -71,8 +71,10 @@ var createLocalApp = function (args) { return __awaiter(void 0, void 0, void 0,
71
71
  }
72
72
  appJsonPath = (0, path_1.resolve)(workDir, './app.json');
73
73
  appJson = fs_extra_1["default"].readJsonSync(appJsonPath);
74
- appID = Math.floor(Math.random() * 10001) + 20000;
75
- lodash_1["default"].set(appJson, 'app.appId', appID);
74
+ if (args.OSVersion !== 'v1') {
75
+ appID = Math.floor(Math.random() * 10001) + 20000;
76
+ lodash_1["default"].set(appJson, 'app.appId', appID);
77
+ }
76
78
  if (templateInfo.copyType !== TemplateCopyType.EDIT) {
77
79
  fs_extra_1["default"].writeJson(appJsonPath, appJson, {
78
80
  spaces: 2,
@@ -1,20 +1,27 @@
1
1
  import "./shared/device-polyfill";
2
2
  import { MessageBuilder } from "./shared/message";
3
3
 
4
- const appId = 27280;
5
- const messageBuilder = new MessageBuilder({ appId });
6
-
7
4
  App({
8
5
  globalData: {
9
- messageBuilder: messageBuilder,
6
+ messageBuilder: null
10
7
  },
11
8
  onCreate(options) {
12
9
  console.log("app on create invoke");
13
- messageBuilder.connect();
10
+ let appId;
11
+ if (!hmApp.packageInfo) {
12
+ // appId = XXX // Modify appId
13
+ throw new Error('Set appId, appId needs to be the same as the configuration in app.json');
14
+ } else {
15
+ appId = hmApp.packageInfo().appId;
16
+ }
17
+ this.globalData.messageBuilder = new MessageBuilder({
18
+ appId,
19
+ });
20
+ this.globalData.messageBuilder.connect();
14
21
  },
15
22
 
16
23
  onDestroy(options) {
17
24
  console.log("app on destroy invoke");
18
- messageBuilder.disConnect();
25
+ this.globalData.messageBuilder.disConnect();
19
26
  },
20
27
  });
@@ -207,7 +207,7 @@ export class MessageBuilder extends EventBus {
207
207
  hmBle &&
208
208
  hmBle.createConnect((index, data, size) => {
209
209
  // logger.warn('[RAW] [R] receive index=>%d size=>%d bin=>%s', index, size, this.bin2hex(data))
210
- // console.log('createConnect-------', size)
210
+ console.log('createConnect-------', size)
211
211
  this.onFragmentData(data)
212
212
  })
213
213
 
@@ -384,7 +384,7 @@ export class MessageBuilder extends EventBus {
384
384
  sendBin(buf) {
385
385
  // hmBle 发送消息
386
386
  // logger.warn('[RAW] [S] send size=%d bin=%s', buf.byteLength, this.bin2hex(buf.buffer))
387
- // console.log('sendBin-------', buf.byteLength)
387
+ console.log('sendBin-------', buf.byteLength)
388
388
  hmBle.send(buf.buffer, buf.byteLength)
389
389
  }
390
390
 
@@ -2,26 +2,27 @@ import './shared/device-polyfill'
2
2
  import { MessageBuilder } from './shared/message'
3
3
 
4
4
  const logger = DeviceRuntimeCore.HmLogger.getLogger('todo-list-app')
5
- const appDevicePort = 20
6
- const appSidePort = 0
7
- const appId = 20001
8
- const messageBuilder = new MessageBuilder({
9
- appId,
10
- appDevicePort,
11
- appSidePort
12
- })
13
5
 
14
6
  App({
15
7
  globalData: {
16
- messageBuilder: messageBuilder
8
+ messageBuilder: null
17
9
  },
18
10
  onCreate() {
19
- logger.log('app onCreate invoked')
20
- messageBuilder.connect()
11
+ logger.log('app onCreate invoked');
12
+ let appId;
13
+ if (!hmApp.packageInfo) {
14
+ // appid = XXX // Modify appId
15
+ throw new Error('Set appId, appId needs to be the same as the configuration in app.json');
16
+ } else {
17
+ appId = hmApp.packageInfo().appId;
18
+ }
19
+ this.globalData.messageBuilder = new MessageBuilder({
20
+ appId,
21
+ });
22
+ this.globalData.messageBuilder.connect();
21
23
  },
22
-
23
24
  onDestroy() {
24
- logger.log('app onDestroy invoked')
25
- messageBuilder.disConnect()
25
+ logger.log('app onDestroy invoked');
26
+ this.globalData.messageBuilder.disConnect();
26
27
  }
27
28
  })
@@ -13,7 +13,7 @@
13
13
  "dev": "nodemon -e ts,tsx --exec \"rm -rf dist && tsc && ts-node build.ts\" --ignore types/ --ignore dist/"
14
14
  },
15
15
  "dependencies": {
16
- "@zeppos/zpm": "^3.0.0",
16
+ "@zeppos/zpm": "^3.0.1",
17
17
  "axios": "^0.27.2",
18
18
  "chalk": "^4.1.2",
19
19
  "chokidar": "^3.5.3",