@zeppos/zeus-cli 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.1",
3
+ "version": "1.3.3",
4
4
  "description": "zeus mini-program tools",
5
5
  "main": "index.ts",
6
6
  "author": "zepp",
@@ -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
  }
@@ -118,7 +118,7 @@ var DeviceScreenType;
118
118
  DeviceScreenType["B"] = "b";
119
119
  })(DeviceScreenType = exports.DeviceScreenType || (exports.DeviceScreenType = {}));
120
120
  exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
121
- deviceName: 'GTR3 Pro',
121
+ deviceName: 'Amazfit GTR 3 Pro',
122
122
  platforms: [
123
123
  {
124
124
  name: DevicePlatformName.MADRID,
@@ -143,7 +143,7 @@ exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
143
143
  max: '1.99.99'
144
144
  }
145
145
  }, _a[DeviceTarget.VERONA] = {
146
- deviceName: 'GTR3',
146
+ deviceName: 'Amazfit GTR 3',
147
147
  platforms: [
148
148
  {
149
149
  name: DevicePlatformName.VERONA,
@@ -164,7 +164,7 @@ exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
164
164
  max: '1.99.99'
165
165
  }
166
166
  }, _a[DeviceTarget.ZURICH] = {
167
- deviceName: 'GTS3',
167
+ deviceName: 'Amazfit GTS 3',
168
168
  platforms: [
169
169
  {
170
170
  name: DevicePlatformName.ZURICH,
@@ -185,7 +185,7 @@ exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
185
185
  max: '1.99.99'
186
186
  }
187
187
  }, _a[DeviceTarget.TEIDE] = {
188
- deviceName: 'T-Rex2',
188
+ deviceName: 'Amazfit T-Rex 2',
189
189
  platforms: [
190
190
  {
191
191
  name: DevicePlatformName.TEIDE,
@@ -206,7 +206,7 @@ exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
206
206
  max: '1.99.99'
207
207
  }
208
208
  }, _a[DeviceTarget.PROVENCE] = {
209
- deviceName: 'GTS4 mini',
209
+ deviceName: 'Amazfit GTS 4 Mini',
210
210
  platforms: [
211
211
  {
212
212
  name: DevicePlatformName.PROVENCE,
@@ -252,7 +252,7 @@ exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
252
252
  max: '1.99.99'
253
253
  }
254
254
  }, _a[DeviceTarget.BERLIN] = {
255
- deviceName: 'GTR 4',
255
+ deviceName: 'Amazfit GTR 4',
256
256
  platforms: [
257
257
  {
258
258
  name: DevicePlatformName.BERLIN,
@@ -273,7 +273,7 @@ exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
273
273
  max: '2.99.99'
274
274
  }
275
275
  }, _a[DeviceTarget.LILLE] = {
276
- deviceName: 'GTS 4',
276
+ deviceName: 'Amazfit GTS 4',
277
277
  platforms: [
278
278
  {
279
279
  name: DevicePlatformName.LILLE,
@@ -294,7 +294,7 @@ exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
294
294
  max: '2.99.99'
295
295
  }
296
296
  }, _a[DeviceTarget.VIENNA] = {
297
- deviceName: 'Falcon',
297
+ deviceName: 'Amazfit Falcon',
298
298
  platforms: [
299
299
  {
300
300
  name: DevicePlatformName.VIENNA,
@@ -315,7 +315,7 @@ exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
315
315
  max: '1.99.99'
316
316
  }
317
317
  }, _a[DeviceTarget.ANDES] = {
318
- deviceName: 'T-Rex Ultra',
318
+ deviceName: 'Amazfit T-Rex Ultra',
319
319
  platforms: [
320
320
  {
321
321
  name: DevicePlatformName.ANDES,
@@ -361,7 +361,7 @@ exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
361
361
  max: '3.99.99'
362
362
  }
363
363
  }, _a[DeviceTarget.SWIFT] = {
364
- deviceName: 'Runner (Round)',
364
+ deviceName: 'Amazfit Cheetah (Round)',
365
365
  platforms: [
366
366
  {
367
367
  name: DevicePlatformName.SWIFT,
@@ -381,7 +381,7 @@ exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
381
381
  min: '1.0.0'
382
382
  }
383
383
  }, _a[DeviceTarget.SWORDFISH] = {
384
- deviceName: 'Runner (Square)',
384
+ deviceName: 'Amazfit Cheetah (Square)',
385
385
  platforms: [
386
386
  {
387
387
  name: DevicePlatformName.SWORDFISH_W,
@@ -397,7 +397,7 @@ exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
397
397
  min: '1.0.0'
398
398
  }
399
399
  }, _a[DeviceTarget.CHEETAH] = {
400
- deviceName: 'Runner Pro',
400
+ deviceName: 'Amazfit Cheetah Pro',
401
401
  platforms: [
402
402
  {
403
403
  name: DevicePlatformName.CHEETAH_W,
@@ -429,7 +429,7 @@ exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
429
429
  min: '1.0.0'
430
430
  }
431
431
  }, _a[DeviceTarget.ETNA] = {
432
- deviceName: 'GTR Shock',
432
+ deviceName: 'Amazfit Active Edge',
433
433
  platforms: [
434
434
  {
435
435
  name: DevicePlatformName.ETNA,
@@ -449,7 +449,7 @@ exports.deviceTargets = __assign((_a = {}, _a[DeviceTarget.MADRID] = {
449
449
  min: '1.0.0'
450
450
  }
451
451
  }, _a[DeviceTarget.ALTAI] = {
452
- deviceName: 'Bip 5s',
452
+ deviceName: 'Amazfit Bip 5',
453
453
  platforms: [
454
454
  {
455
455
  name: DevicePlatformName.ALTAI,
@@ -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
  })
@@ -12,7 +12,7 @@
12
12
  "vender": "zepp",
13
13
  "description": "empty application"
14
14
  },
15
- "permissions": ["device:os.bg_service"],
15
+ "permissions": [],
16
16
  "runtime": {
17
17
  "apiVersion": {
18
18
  "compatible": "3.0.0",
@@ -21,7 +21,7 @@
21
21
  }
22
22
  },
23
23
  "targets": {
24
- "gt": {
24
+ "default": {
25
25
  "module": {
26
26
  "page": {
27
27
  "pages": [
@@ -33,9 +33,6 @@
33
33
  },
34
34
  "setting": {
35
35
  "path": "setting/index"
36
- },
37
- "app-service": {
38
- "services": ["app-service/index"]
39
36
  }
40
37
  },
41
38
  "platforms": [
@@ -1,8 +0,0 @@
1
- AppService({
2
- onInit(params) {
3
- console.log('====service onInit=======>', new Date().getTime())
4
- },
5
- onEvent(params) {
6
- console.log('index onEvent=', params)
7
- }
8
- })