@zeppos/zeus-cli 1.7.8 → 1.7.10

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/modules/build.js CHANGED
@@ -110,12 +110,32 @@ var checkAppJson = function () {
110
110
  process.exit(1);
111
111
  }
112
112
  };
113
+ var inquirerPrompt = function (deviceNames, mode) {
114
+ if (mode === void 0) { mode = 'development'; }
115
+ return __awaiter(void 0, void 0, void 0, function () {
116
+ var promptParam, defaultDevice;
117
+ return __generator(this, function (_a) {
118
+ promptParam = {
119
+ name: 'device',
120
+ type: 'list',
121
+ message: 'Which device would you like to preview?',
122
+ choices: deviceNames
123
+ };
124
+ defaultDevice = zeppos_app_utils_1.globalStorage.get("____zeus_".concat(mode, "_device")) || '';
125
+ if (defaultDevice !== '') {
126
+ promptParam['default'] = defaultDevice;
127
+ }
128
+ return [2, inquirer_1["default"].prompt([promptParam])];
129
+ });
130
+ });
131
+ };
113
132
  var chooseBuildTargetsV3Config = function (mode, args) {
114
133
  if (mode === void 0) { mode = 'development'; }
115
134
  return __awaiter(void 0, void 0, void 0, function () {
116
135
  var target, deviceTargets, apiLevel, platforms, usefulScreenTypes, usefulDeviceSource, targetDevices, deviceNames, isValidDevice, answers, _a;
117
- return __generator(this, function (_b) {
118
- switch (_b.label) {
136
+ var _b;
137
+ return __generator(this, function (_c) {
138
+ switch (_c.label) {
119
139
  case 0:
120
140
  checkAppJson();
121
141
  target = args.target;
@@ -130,7 +150,8 @@ var chooseBuildTargetsV3Config = function (mode, args) {
130
150
  Object.values(deviceTargets).forEach(function (device) {
131
151
  var _a;
132
152
  var _b = device.apiLevelLimit || {}, min = _b.min, max = _b.max;
133
- if (usefulScreenTypes.includes((0, lodash_1.get)(device, 'screen.type', '')) || (0, lodash_1.find)(device.platforms, function (o) { return usefulDeviceSource.includes("".concat(o.deviceSource)); })) {
153
+ if (usefulScreenTypes.includes((0, lodash_1.get)(device, 'screen.type', '')) ||
154
+ (0, lodash_1.find)(device.platforms, function (o) { return usefulDeviceSource.includes("".concat(o.deviceSource)); })) {
134
155
  if ((0, tools_1.compareVersion)(min || '1.0.0', apiLevel) >= 0 && max && (0, tools_1.compareVersion)(max, apiLevel) <= 0) {
135
156
  Object.assign(targetDevices, (_a = {},
136
157
  _a[device.deviceName] = device,
@@ -150,19 +171,17 @@ var chooseBuildTargetsV3Config = function (mode, args) {
150
171
  if (!isValidDevice) return [3, 1];
151
172
  _a = { device: target };
152
173
  return [3, 3];
153
- case 1: return [4, inquirer_1["default"].prompt([
154
- {
155
- name: 'device',
156
- type: 'list',
157
- message: 'Which device would you like to preview?',
158
- choices: deviceNames
159
- },
160
- ])];
174
+ case 1: return [4, inquirerPrompt(deviceNames, mode)];
161
175
  case 2:
162
- _a = _b.sent();
163
- _b.label = 3;
176
+ _a = _c.sent();
177
+ _c.label = 3;
164
178
  case 3:
165
179
  answers = _a;
180
+ if (answers.device) {
181
+ zeppos_app_utils_1.globalStorage.set((_b = {},
182
+ _b["____zeus_".concat(mode, "_device")] = answers.device,
183
+ _b));
184
+ }
166
185
  return [2, {
167
186
  device: answers.device,
168
187
  sources: (0, lodash_1.get)(targetDevices, "[".concat(answers.device, "].platforms"), []).reduce(function (list, item) {
@@ -195,8 +214,7 @@ var chooseBuildTargetsV2Config = function (mode, args) {
195
214
  unsupportedTargets_1.push(target);
196
215
  }
197
216
  });
198
- unsupportedTargets_1.length &&
199
- zeppos_app_utils_1.logger.warn("Unsupported targets(".concat(unsupportedTargets_1.join(', '), ") have been removed."));
217
+ unsupportedTargets_1.length && zeppos_app_utils_1.logger.warn("Unsupported targets(".concat(unsupportedTargets_1.join(', '), ") have been removed."));
200
218
  }
201
219
  targets = Object.keys((0, lodash_1.get)(appJsonContent, 'targets', {}));
202
220
  returnRes = [];
@@ -232,9 +250,7 @@ var chooseBuildTargetsV2Config = function (mode, args) {
232
250
  name: 'target',
233
251
  type: 'checkbox',
234
252
  when: function (args) {
235
- var arr = typeof promptTarget_1 === 'string'
236
- ? (0, lodash_1.intersection)(targets, promptTarget_1.split(','))
237
- : [];
253
+ var arr = typeof promptTarget_1 === 'string' ? (0, lodash_1.intersection)(targets, promptTarget_1.split(',')) : [];
238
254
  var bool = !!arr.length;
239
255
  if (bool) {
240
256
  args.target = arr;
@@ -251,8 +267,7 @@ var chooseBuildTargetsV2Config = function (mode, args) {
251
267
  ])];
252
268
  case 3:
253
269
  answers = _b.sent();
254
- returnRes =
255
- typeof answers.target === 'string' ? [answers.target] : answers.target;
270
+ returnRes = typeof answers.target === 'string' ? [answers.target] : answers.target;
256
271
  _b.label = 4;
257
272
  case 4:
258
273
  if (!process.env._targetDeviceToBuild) {
@@ -275,7 +290,8 @@ var chooseBuildPackages = function (mode, args) {
275
290
  result = {};
276
291
  if (!(configVersion === 'v3')) return [3, 3];
277
292
  _a = args.sources, sources = _a === void 0 ? [] : _a;
278
- if (!(mode !== BuildMode.PROD && (sources.length <= 0))) return [3, 2];
293
+ if (!(sources.length <= 0)) return [3, 2];
294
+ if (!(mode !== BuildMode.PROD || args.target)) return [3, 2];
279
295
  _c = (_b = Object).assign;
280
296
  _d = [result];
281
297
  return [4, chooseBuildTargetsV3Config(mode, args)];
@@ -328,9 +344,7 @@ var buildPreview = function (args, callback) { return __awaiter(void 0, void 0,
328
344
  switch (_e.label) {
329
345
  case 0:
330
346
  _a = args._, curCommand = _a[0], curBridgeTarget = _a[1];
331
- buildMode = curBridgeTarget && curBridgeTarget === 'simulator'
332
- ? BuildMode.DEV
333
- : BuildMode.PREVIEW;
347
+ buildMode = curBridgeTarget && curBridgeTarget === 'simulator' ? BuildMode.DEV : BuildMode.PREVIEW;
334
348
  zeppos_app_utils_1.logger.info('building...');
335
349
  appType = (0, lodash_1.get)(appJsonContent, 'app.appType');
336
350
  appName = (0, lodash_1.get)(appJsonContent, 'app.appName');
@@ -354,9 +368,7 @@ var buildPreview = function (args, callback) { return __awaiter(void 0, void 0,
354
368
  if (!(res.type === 'preview')) return [3, 1];
355
369
  zeppos_app_utils_1.logger.info('Generating preview QR code...');
356
370
  zeppos_app_utils_1.logger.success("Please use Zepp APP to scan the following QR code to preview your ".concat(appType === AppType.WATCHFACE ? 'WatchFace' : 'Application', "."));
357
- zeppos_app_utils_1.logger.success("This QR code will expire on ".concat((0, dayjs_1["default"])()
358
- .add(7, 'days')
359
- .format('YYYY-MM-DD HH:mm:ss'), "."));
371
+ zeppos_app_utils_1.logger.success("This QR code will expire on ".concat((0, dayjs_1["default"])().add(7, 'days').format('YYYY-MM-DD HH:mm:ss'), "."));
360
372
  zeppos_app_utils_1.logger.log("[".concat(chalk_1["default"].cyan(buildDevice), "] ").concat(appName, "-").concat(appVersion));
361
373
  qrcode_terminal_1["default"].generate(res.url, { small: true });
362
374
  callback && callback(res);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeppos/zeus-cli",
3
- "version": "1.7.8",
3
+ "version": "1.7.10",
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.7.2",
24
- "@zeppos/zpm": "^3.2.7",
24
+ "@zeppos/zpm": "^3.2.8",
25
25
  "axios": "1.8.2",
26
26
  "chalk": "^4.1.2",
27
27
  "chokidar": "^3.6.0",
@@ -13,7 +13,7 @@
13
13
  "dev": "nodemon -e ts,tsx --exec \"rimraf dist && tsc && ts-node build.ts\" --ignore types/ --ignore dist/"
14
14
  },
15
15
  "dependencies": {
16
- "@zeppos/zpm": "^3.2.7",
16
+ "@zeppos/zpm": "^3.2.8",
17
17
  "axios": "1.8.2",
18
18
  "chalk": "^4.1.2",
19
19
  "chokidar": "^3.6.0",