@zeppos/zeus-cli 1.7.10 → 1.8.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.
Files changed (39) hide show
  1. package/bin/main.js +85 -30
  2. package/bin/post-command.js +1 -1
  3. package/index.js +1 -1
  4. package/modules/bridge.js +43 -33
  5. package/modules/build.js +72 -36
  6. package/modules/create.js +213 -216
  7. package/modules/help.js +21 -11
  8. package/modules/prune.js +1 -1
  9. package/modules/run.js +29 -17
  10. package/modules/version.js +5 -6
  11. package/modules/yargsCmdBuilders.js +3 -3
  12. package/package.json +6 -4
  13. package/private-modules/zeppos-app-utils/dist/api/index.js +18 -20
  14. package/private-modules/zeppos-app-utils/dist/config/device.js +19 -17
  15. package/private-modules/zeppos-app-utils/dist/config/index.js +1 -1
  16. package/private-modules/zeppos-app-utils/dist/config/project.js +14 -14
  17. package/private-modules/zeppos-app-utils/dist/hm-analytics.js +14 -13
  18. package/private-modules/zeppos-app-utils/dist/index.js +18 -8
  19. package/private-modules/zeppos-app-utils/dist/logger/index.js +5 -5
  20. package/private-modules/zeppos-app-utils/dist/logger/my-logger.js +1 -1
  21. package/private-modules/zeppos-app-utils/dist/modules/build.js +73 -46
  22. package/private-modules/zeppos-app-utils/dist/modules/config.js +14 -12
  23. package/private-modules/zeppos-app-utils/dist/modules/create/index.js +71 -39
  24. package/private-modules/zeppos-app-utils/dist/modules/create/local-app.js +82 -66
  25. package/private-modules/zeppos-app-utils/dist/modules/create/yeoman-app.js +6 -6
  26. package/private-modules/zeppos-app-utils/dist/modules/fetchDevices.js +73 -40
  27. package/private-modules/zeppos-app-utils/dist/modules/index.js +1 -1
  28. package/private-modules/zeppos-app-utils/dist/modules/login.js +16 -15
  29. package/private-modules/zeppos-app-utils/dist/modules/open/index.js +62 -50
  30. package/private-modules/zeppos-app-utils/dist/modules/prune.js +5 -5
  31. package/private-modules/zeppos-app-utils/dist/modules/status.js +12 -12
  32. package/private-modules/zeppos-app-utils/dist/simulator.js +3 -3
  33. package/private-modules/zeppos-app-utils/dist/storage/index.js +7 -7
  34. package/private-modules/zeppos-app-utils/dist/tools/index.js +24 -14
  35. package/private-modules/zeppos-app-utils/dist/tools/tools.js +3 -3
  36. package/private-modules/zeppos-app-utils/dist/websocket.js +9 -9
  37. package/private-modules/zeppos-app-utils/package.json +2 -1
  38. package/utils/pre-check.js +52 -29
  39. package/utils/tools.js +4 -4
@@ -26,13 +26,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
26
26
  }) : function(o, v) {
27
27
  o["default"] = v;
28
28
  });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
36
46
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
47
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
48
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -43,8 +53,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
53
  });
44
54
  };
45
55
  var __generator = (this && this.__generator) || function (thisArg, body) {
46
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
56
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
57
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
58
  function verb(n) { return function (v) { return step([n, v]); }; }
49
59
  function step(op) {
50
60
  if (f) throw new TypeError("Generator is already executing.");
@@ -69,10 +79,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
79
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
80
  }
71
81
  };
82
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
83
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
84
+ if (ar || !(i in from)) {
85
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
86
+ ar[i] = from[i];
87
+ }
88
+ }
89
+ return to.concat(ar || Array.prototype.slice.call(from));
90
+ };
72
91
  var __importDefault = (this && this.__importDefault) || function (mod) {
73
92
  return (mod && mod.__esModule) ? mod : { "default": mod };
74
93
  };
75
- exports.__esModule = true;
94
+ Object.defineProperty(exports, "__esModule", { value: true });
76
95
  exports.runX = exports.previewBuild = exports.build = exports.buildSupportV3Config = exports.BuildMode = void 0;
77
96
  var zpm_1 = require("@zeppos/zpm");
78
97
  var rd = __importStar(require("rd"));
@@ -93,7 +112,7 @@ var BuildMode;
93
112
  BuildMode["DEV"] = "development";
94
113
  BuildMode["PREVIEW"] = "preview";
95
114
  BuildMode["PROD"] = "production";
96
- })(BuildMode = exports.BuildMode || (exports.BuildMode = {}));
115
+ })(BuildMode || (exports.BuildMode = BuildMode = {}));
97
116
  var TransformType;
98
117
  (function (TransformType) {
99
118
  TransformType["Default"] = "";
@@ -101,7 +120,7 @@ var TransformType;
101
120
  TransformType["C"] = "c";
102
121
  TransformType["Bin"] = "bin";
103
122
  })(TransformType || (TransformType = {}));
104
- var INNER_PRODUCT_TIP = "\n\n".concat(chalk_1["default"].yellow.bold('Notice:'), "\n").concat(chalk_1["default"].blue('Please note that if your installation package includes intermediate products, you specifically authorize us to modify, edit, utilize, repackage, and distribute the installation package(including intermediate products) for the following purposes:'), "\n\n").concat(chalk_1["default"].blue.bold('1.'), " Using intermediate products to generate new installation packages and distribute them to new devices;\n").concat(chalk_1["default"].blue.bold('2.'), " Distribute the installation package to devices with the same CPU architecture and screen resolution, not limited to the device you have currently selected.\n\nHowever, we will not distribute intermediate products to user devices directly. If you choose not to include intermediate products in your installation package, use the ").concat(chalk_1["default"].bold.green('zeus prune --ip'), " command to remove it immediately after the build is completed. However, you\u2019ll then have to manually provide a build for each device type.\n\n");
123
+ var INNER_PRODUCT_TIP = "\n\n".concat(chalk_1.default.yellow.bold('Notice:'), "\n").concat(chalk_1.default.blue('Please note that if your installation package includes intermediate products, you specifically authorize us to modify, edit, utilize, repackage, and distribute the installation package(including intermediate products) for the following purposes:'), "\n\n").concat(chalk_1.default.blue.bold('1.'), " Using intermediate products to generate new installation packages and distribute them to new devices;\n").concat(chalk_1.default.blue.bold('2.'), " Distribute the installation package to devices with the same CPU architecture and screen resolution, not limited to the device you have currently selected.\n\nHowever, we will not distribute intermediate products to user devices directly. If you choose not to include intermediate products in your installation package, use the ").concat(chalk_1.default.bold.green('zeus prune --ip'), " command to remove it immediately after the build is completed. However, you\u2019ll then have to manually provide a build for each device type.\n\n");
105
124
  var gitignoreDefaultItem = [
106
125
  '.DS_Store',
107
126
  'node_modules/**',
@@ -120,12 +139,12 @@ var gitignoreDefaultItem = [
120
139
  '*.sln',
121
140
  ];
122
141
  function getSimulatorPath() {
123
- var platform = os_1["default"].platform();
142
+ var platform = os_1.default.platform();
124
143
  var newPath;
125
144
  if (platform === 'win32')
126
145
  newPath = process.env.APPDATA || '';
127
146
  else
128
- newPath = path.join(os_1["default"].homedir(), '.config');
147
+ newPath = path.join(os_1.default.homedir(), '.config');
129
148
  return path.join(newPath, 'simulator');
130
149
  }
131
150
  function getSimulatorAppsPath(projectName, appId) {
@@ -144,12 +163,12 @@ function updateLastAppInfo(projectName, appId, userProjectPath) {
144
163
  user_app_path: userProjectPath,
145
164
  project_name: projectName,
146
165
  app_id: appId,
147
- last_updated: new Date().toISOString()
166
+ last_updated: new Date().toISOString(),
148
167
  };
149
168
  var needsUpdate = true;
150
- if (fs_1["default"].existsSync(lastAppInfoPath)) {
169
+ if (fs_1.default.existsSync(lastAppInfoPath)) {
151
170
  try {
152
- var existingContent = fs_1["default"].readFileSync(lastAppInfoPath, 'utf8');
171
+ var existingContent = fs_1.default.readFileSync(lastAppInfoPath, 'utf8');
153
172
  var existingInfo = JSON.parse(existingContent);
154
173
  if (existingInfo.sim_app_path === newAppInfo.sim_app_path &&
155
174
  existingInfo.user_app_path === newAppInfo.user_app_path) {
@@ -162,16 +181,20 @@ function updateLastAppInfo(projectName, appId, userProjectPath) {
162
181
  }
163
182
  }
164
183
  if (needsUpdate) {
165
- fs_1["default"].mkdirSync(simulatorDir, { recursive: true });
166
- fs_1["default"].writeFileSync(lastAppInfoPath, JSON.stringify(newAppInfo, null, 2));
184
+ fs_1.default.mkdirSync(simulatorDir, { recursive: true });
185
+ fs_1.default.writeFileSync(lastAppInfoPath, JSON.stringify(newAppInfo, null, 2));
167
186
  }
168
187
  return newAppInfo;
169
188
  }
170
- var buildSupportV3Config = function (workspace, mode, buildConfigOption) {
171
- if (mode === void 0) { mode = BuildMode.PROD; }
172
- if (buildConfigOption === void 0) { buildConfigOption = {}; }
173
- return __awaiter(void 0, void 0, void 0, function () {
189
+ var buildSupportV3Config = function (workspace_1) {
190
+ var args_1 = [];
191
+ for (var _i = 1; _i < arguments.length; _i++) {
192
+ args_1[_i - 1] = arguments[_i];
193
+ }
194
+ return __awaiter(void 0, __spreadArray([workspace_1], args_1, true), void 0, function (workspace, mode, buildConfigOption) {
174
195
  var _a, sources_1, _b, targets, _c, sources, buildOptions, _d, js2c, _e, js2bin, _f, png2vg, _g, prune, _h, compress, _j, ip, zabName_1, distDir_1, name_1, newName_1, error_1;
196
+ if (mode === void 0) { mode = BuildMode.PROD; }
197
+ if (buildConfigOption === void 0) { buildConfigOption = {}; }
175
198
  return __generator(this, function (_k) {
176
199
  switch (_k.label) {
177
200
  case 0:
@@ -185,7 +208,7 @@ var buildSupportV3Config = function (workspace, mode, buildConfigOption) {
185
208
  buildMode: mode,
186
209
  targets: targets,
187
210
  sources: sources,
188
- jsc: TransformType.Default
211
+ jsc: TransformType.Default,
189
212
  };
190
213
  if ([BuildMode.PROD, BuildMode.PREVIEW].includes(mode)) {
191
214
  _d = buildConfigOption || {}, js2c = _d.js2c, _e = _d.js2bin, js2bin = _e === void 0 ? true : _e, _f = _d.png2vg, png2vg = _f === void 0 ? true : _f, _g = _d.prune, prune = _g === void 0 ? true : _g, _h = _d.compress, compress = _h === void 0 ? true : _h, _j = _d.ip, ip = _j === void 0 ? BuildMode.PROD === mode : _j;
@@ -197,7 +220,7 @@ var buildSupportV3Config = function (workspace, mode, buildConfigOption) {
197
220
  png2vg: (0, tools_1.booleanString)(png2vg),
198
221
  prune: (0, tools_1.booleanString)(prune),
199
222
  compress: (0, tools_1.booleanString)(compress),
200
- ip: (0, tools_1.booleanString)(ip)
223
+ ip: (0, tools_1.booleanString)(ip),
201
224
  });
202
225
  }
203
226
  _k.label = 1;
@@ -226,10 +249,10 @@ var buildSupportV3Config = function (workspace, mode, buildConfigOption) {
226
249
  rd.eachFileSync(distDir_1, function (file) {
227
250
  var oldName = path.join(distDir_1, zabName_1);
228
251
  if (file !== oldName) {
229
- fs_extra_1["default"].removeSync(file);
252
+ fs_extra_1.default.removeSync(file);
230
253
  }
231
254
  else {
232
- fs_1["default"].renameSync(oldName, path.join(distDir_1, newName_1));
255
+ fs_1.default.renameSync(oldName, path.join(distDir_1, newName_1));
233
256
  }
234
257
  });
235
258
  mode === BuildMode.PROD && index_1.logger.log(INNER_PRODUCT_TIP);
@@ -247,11 +270,15 @@ var buildSupportV3Config = function (workspace, mode, buildConfigOption) {
247
270
  });
248
271
  };
249
272
  exports.buildSupportV3Config = buildSupportV3Config;
250
- var build = function (workspace, mode, buildConfigOption, packages, appId) {
251
- if (mode === void 0) { mode = BuildMode.PROD; }
252
- if (appId === void 0) { appId = '10000'; }
253
- return __awaiter(void 0, void 0, void 0, function () {
273
+ var build = function (workspace_1) {
274
+ var args_1 = [];
275
+ for (var _i = 1; _i < arguments.length; _i++) {
276
+ args_1[_i - 1] = arguments[_i];
277
+ }
278
+ return __awaiter(void 0, __spreadArray([workspace_1], args_1, true), void 0, function (workspace, mode, buildConfigOption, packages, appId) {
254
279
  var buildOptions, _a, js2c, _b, js2bin, _c, png2vg, _d, prune, _e, compress, _f, ip, curOpt, productName_1, DistDir_1, name_2, newName_2, error_2;
280
+ if (mode === void 0) { mode = BuildMode.PROD; }
281
+ if (appId === void 0) { appId = '10000'; }
255
282
  return __generator(this, function (_g) {
256
283
  switch (_g.label) {
257
284
  case 0:
@@ -259,7 +286,7 @@ var build = function (workspace, mode, buildConfigOption, packages, appId) {
259
286
  path: workspace,
260
287
  targets: packages,
261
288
  buildMode: mode,
262
- jsc: TransformType.Default
289
+ jsc: TransformType.Default,
263
290
  };
264
291
  if (mode === BuildMode.PROD || mode === BuildMode.PREVIEW) {
265
292
  _a = buildConfigOption || {}, js2c = _a.js2c, _b = _a.js2bin, js2bin = _b === void 0 ? true : _b, _c = _a.png2vg, png2vg = _c === void 0 ? true : _c, _d = _a.prune, prune = _d === void 0 ? true : _d, _e = _a.compress, compress = _e === void 0 ? true : _e, _f = _a.ip, ip = _f === void 0 ? mode === BuildMode.PROD : _f;
@@ -271,7 +298,7 @@ var build = function (workspace, mode, buildConfigOption, packages, appId) {
271
298
  png2vg: (0, tools_1.booleanString)(png2vg),
272
299
  prune: (0, tools_1.booleanString)(prune),
273
300
  compress: (0, tools_1.booleanString)(compress),
274
- ip: (0, tools_1.booleanString)(ip)
301
+ ip: (0, tools_1.booleanString)(ip),
275
302
  });
276
303
  }
277
304
  _g.label = 1;
@@ -290,10 +317,10 @@ var build = function (workspace, mode, buildConfigOption, packages, appId) {
290
317
  rd.eachFileSync(DistDir_1, function (file) {
291
318
  var oldName = path.join(DistDir_1, productName_1);
292
319
  if (file !== oldName) {
293
- fs_extra_1["default"].removeSync(file);
320
+ fs_extra_1.default.removeSync(file);
294
321
  }
295
322
  else {
296
- fs_1["default"].renameSync(oldName, path.join(DistDir_1, newName_2));
323
+ fs_1.default.renameSync(oldName, path.join(DistDir_1, newName_2));
297
324
  }
298
325
  });
299
326
  productName_1 = newName_2;
@@ -321,8 +348,8 @@ var previewBuild = function (root, args, workspace, appType, curCommand) { retur
321
348
  return [2, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
322
349
  var form;
323
350
  return __generator(this, function (_a) {
324
- form = new form_data_1["default"]();
325
- form.append('file', fs_1["default"].createReadStream(workspace));
351
+ form = new form_data_1.default();
352
+ form.append('file', fs_1.default.createReadStream(workspace));
326
353
  form.append('app_type', appType === index_1.config.AppType.WATCHFACE ? '1' : '2');
327
354
  form.getLength(function (err, length) { return __awaiter(void 0, void 0, void 0, function () {
328
355
  var protocol, code, res, error_3, _subRegionalHost, url, _a, deviceSource, appId, appName, appType_1, deviceSourceArr, targetDeviceInternalName, packageInfo, url, preview, downloadPackageReturn;
@@ -389,10 +416,10 @@ var previewBuild = function (root, args, workspace, appType, curCommand) { retur
389
416
  preview: preview,
390
417
  appid: appId,
391
418
  name: appName,
392
- "debugger": true,
419
+ debugger: true,
393
420
  updatedTime: Math.round(new Date().getTime() / 1000),
394
421
  devices: (0, lodash_1.get)(args, "sources", deviceSourceArr),
395
- target: targetDeviceInternalName
422
+ target: targetDeviceInternalName,
396
423
  });
397
424
  _b.label = 10;
398
425
  case 10: return [2];
@@ -433,17 +460,17 @@ var runX = function (root, args, url, logAfterFunc) { return __awaiter(void 0, v
433
460
  else {
434
461
  logger.error('build error');
435
462
  }
436
- logger.info(chalk_1["default"].green("watching the changes in this project..."));
463
+ logger.info(chalk_1.default.green("watching the changes in this project..."));
437
464
  return [2];
438
465
  }
439
466
  });
440
467
  }); }, 150, { maxWait: 1000 });
441
468
  refreshSimulator();
442
469
  gitignorePath = path.resolve(root, '.gitignore');
443
- fs_extra_1["default"].ensureFileSync(gitignorePath);
444
- gitignore = (0, parse_gitignore_1["default"])(fs_extra_1["default"].readFileSync(gitignorePath));
470
+ fs_extra_1.default.ensureFileSync(gitignorePath);
471
+ gitignore = (0, parse_gitignore_1.default)(fs_extra_1.default.readFileSync(gitignorePath));
445
472
  if (!gitignore.length) {
446
- fs_extra_1["default"].writeFileSync(gitignorePath, gitignoreDefaultItem.join('\n'));
473
+ fs_extra_1.default.writeFileSync(gitignorePath, gitignoreDefaultItem.join('\n'));
447
474
  gitignore = gitignoreDefaultItem;
448
475
  }
449
476
  ignored = (0, lodash_2.union)([
@@ -457,15 +484,15 @@ var runX = function (root, args, url, logAfterFunc) { return __awaiter(void 0, v
457
484
  'yarn.lock',
458
485
  'package-lock.json',
459
486
  ], gitignore);
460
- return [2, chokidar_1["default"]
487
+ return [2, chokidar_1.default
461
488
  .watch('.', {
462
489
  ignored: ignored,
463
490
  ignoreInitial: true,
464
491
  interval: 1000,
465
- cwd: root
492
+ cwd: root,
466
493
  })
467
494
  .on('all', function (_type, path) {
468
- logger.info("".concat(path, " ").concat(chalk_1["default"].green(_type)));
495
+ logger.info("".concat(path, " ").concat(chalk_1.default.green(_type)));
469
496
  path && refreshSimulator();
470
497
  })];
471
498
  });
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
@@ -38,7 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
- exports.__esModule = true;
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.config = void 0;
43
43
  var lodash_1 = __importDefault(require("lodash"));
44
44
  var chalk_1 = __importDefault(require("chalk"));
@@ -47,27 +47,27 @@ var config = function (args, logAfterFunc) { return __awaiter(void 0, void 0, vo
47
47
  var cliName, _a, cmd, _b, method, values, allowedMethods, myLogger, commonHandleNotKeyTips, config_1;
48
48
  return __generator(this, function (_c) {
49
49
  cliName = process.env.CMD_NAME || '';
50
- _a = lodash_1["default"].get(args, '_', []), cmd = _a[0], _b = _a[1], method = _b === void 0 ? '' : _b, values = _a.slice(2);
50
+ _a = lodash_1.default.get(args, '_', []), cmd = _a[0], _b = _a[1], method = _b === void 0 ? '' : _b, values = _a.slice(2);
51
51
  allowedMethods = ['get', 'set', 'delete', 'list'];
52
52
  myLogger = new index_1.MyLogger();
53
53
  if (logAfterFunc) {
54
54
  myLogger.addAfterFunc(logAfterFunc);
55
55
  }
56
- if (!lodash_1["default"].includes(allowedMethods, method)) {
56
+ if (!lodash_1.default.includes(allowedMethods, method)) {
57
57
  index_1.logger.error("invalid method: '".concat(method, "'"));
58
- index_1.logger.log(chalk_1["default"].yellow('try to use one of the following:'));
58
+ index_1.logger.log(chalk_1.default.yellow('try to use one of the following:'));
59
59
  index_1.logger.log("- ".concat(cliName, " ").concat(cmd, " set <key>=<value> [<key>=<value> ...]"));
60
60
  index_1.logger.log("- ".concat(cliName, " ").concat(cmd, " get <key> [<key> ...]"));
61
61
  index_1.logger.log("- ".concat(cliName, " ").concat(cmd, " delete <key> [<key> ...]"));
62
62
  index_1.logger.log("- ".concat(cliName, " ").concat(cmd, " list [--json]"));
63
63
  }
64
64
  commonHandleNotKeyTips = function (method) {
65
- index_1.logger.error("Please enter the data in the format: ".concat(chalk_1["default"].yellow("zeus config ".concat(method, " <key>"))));
65
+ index_1.logger.error("Please enter the data in the format: ".concat(chalk_1.default.yellow("zeus config ".concat(method, " <key>"))));
66
66
  };
67
67
  switch (method) {
68
68
  case 'set':
69
69
  if (!values.length) {
70
- myLogger.error("Please enter the data in the format: ".concat(chalk_1["default"].yellow('zeus config set <key>=<value>')));
70
+ myLogger.error("Please enter the data in the format: ".concat(chalk_1.default.yellow('zeus config set <key>=<value>')));
71
71
  break;
72
72
  }
73
73
  values.forEach(function (info) {
@@ -124,15 +124,17 @@ var config = function (args, logAfterFunc) { return __awaiter(void 0, void 0, vo
124
124
  case 'list':
125
125
  config_1 = index_1.instanceStorage.getStorage();
126
126
  Object.keys(config_1).forEach(function (key) {
127
- if (lodash_1["default"].startsWith(key, '____')) {
128
- lodash_1["default"].unset(config_1, key);
127
+ if (lodash_1.default.startsWith(key, '____')) {
128
+ lodash_1.default.unset(config_1, key);
129
129
  }
130
130
  });
131
- if (lodash_1["default"].get(args, 'json', false)) {
131
+ if (lodash_1.default.get(args, 'json', false)) {
132
132
  myLogger.log(JSON.stringify(config_1, null, 2));
133
133
  }
134
134
  else {
135
- myLogger.log(Object.keys(config_1).map(function (key) { return "".concat(key, "=").concat(config_1[key]); }).join('\n'));
135
+ myLogger.log(Object.keys(config_1)
136
+ .map(function (key) { return "".concat(key, "=").concat(config_1[key]); })
137
+ .join('\n'));
136
138
  }
137
139
  break;
138
140
  default:
@@ -26,13 +26,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
26
26
  }) : function(o, v) {
27
27
  o["default"] = v;
28
28
  });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
36
46
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
47
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
48
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -43,8 +53,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
53
  });
44
54
  };
45
55
  var __generator = (this && this.__generator) || function (thisArg, body) {
46
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
56
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
57
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
58
  function verb(n) { return function (v) { return step([n, v]); }; }
49
59
  function step(op) {
50
60
  if (f) throw new TypeError("Generator is already executing.");
@@ -69,10 +79,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
79
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
80
  }
71
81
  };
82
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
83
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
84
+ if (ar || !(i in from)) {
85
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
86
+ ar[i] = from[i];
87
+ }
88
+ }
89
+ return to.concat(ar || Array.prototype.slice.call(from));
90
+ };
72
91
  var __importDefault = (this && this.__importDefault) || function (mod) {
73
92
  return (mod && mod.__esModule) ? mod : { "default": mod };
74
93
  };
75
- exports.__esModule = true;
94
+ Object.defineProperty(exports, "__esModule", { value: true });
76
95
  exports.createX = void 0;
77
96
  var chalk_1 = __importDefault(require("chalk"));
78
97
  var rd = __importStar(require("rd"));
@@ -84,11 +103,11 @@ var yeoman_environment_1 = __importDefault(require("yeoman-environment"));
84
103
  var local_app_1 = require("./local-app");
85
104
  var yeoman_app_1 = require("./yeoman-app");
86
105
  var index_1 = require("../../index");
87
- var AppType = index_1.config.AppType, AppSourceType = index_1.config.AppSourceType, TemplateCopyType = index_1.config.TemplateCopyType, zeppFontIcon = index_1.config.zeppFontIcon;
88
106
  var child_process_1 = require("child_process");
107
+ var AppType = index_1.config.AppType, AppSourceType = index_1.config.AppSourceType, TemplateCopyType = index_1.config.TemplateCopyType, zeppFontIcon = index_1.config.zeppFontIcon;
89
108
  var projectPreInstall = function (dir) {
90
109
  return new Promise(function (resolve) {
91
- if (!fs_extra_1["default"].existsSync((0, path_1.join)(dir, 'package.json'))) {
110
+ if (!fs_extra_1.default.existsSync((0, path_1.join)(dir, 'package.json'))) {
92
111
  resolve(true);
93
112
  return;
94
113
  }
@@ -102,10 +121,14 @@ var projectPreInstall = function (dir) {
102
121
  });
103
122
  });
104
123
  };
105
- var createX = function (cwdPath, args, func, beforeFiles) {
106
- if (beforeFiles === void 0) { beforeFiles = []; }
107
- return __awaiter(void 0, void 0, void 0, function () {
124
+ var createX = function (cwdPath_1, args_1, func_1) {
125
+ var args_2 = [];
126
+ for (var _i = 3; _i < arguments.length; _i++) {
127
+ args_2[_i - 3] = arguments[_i];
128
+ }
129
+ return __awaiter(void 0, __spreadArray([cwdPath_1, args_1, func_1], args_2, true), void 0, function (cwdPath, args, func, beforeFiles) {
108
130
  var cmd, _a, projectName, _b, configVersion, workDir, templateDir, localTemplatesDirMap, localTemplates, allOS, appTypes, genChoices, localChoices, watchfaceTemplateChoices, appTemplateChoices, workoutExtTemplateChoices, getTemplateChoices, templatesInit, env, generatorMate, generatorMateKeys, choicesValueFormat, answer, choosePkg;
131
+ if (beforeFiles === void 0) { beforeFiles = []; }
109
132
  return __generator(this, function (_c) {
110
133
  switch (_c.label) {
111
134
  case 0:
@@ -118,7 +141,7 @@ var createX = function (cwdPath, args, func, beforeFiles) {
118
141
  v2: (0, path_1.resolve)(templateDir, './os2.0'),
119
142
  v3: (0, path_1.resolve)(templateDir, './os3.0'),
120
143
  'v3.5': (0, path_1.resolve)(templateDir, './os3.5'),
121
- v4: (0, path_1.resolve)(templateDir, './os4.0')
144
+ v4: (0, path_1.resolve)(templateDir, './os4.0'),
122
145
  };
123
146
  localTemplates = Object.keys(localTemplatesDirMap).reduce(function (temps, osVersion) {
124
147
  var dir = localTemplatesDirMap[osVersion];
@@ -128,25 +151,30 @@ var createX = function (cwdPath, args, func, beforeFiles) {
128
151
  temps[osVersion] = {
129
152
  app: (0, fs_1.existsSync)(appDir) ? (0, fs_1.readdirSync)(appDir) : [],
130
153
  watchface: (0, fs_1.existsSync)(watchfaceDir) ? (0, fs_1.readdirSync)(watchfaceDir) : [],
131
- 'workout-extension': (0, fs_1.existsSync)(workoutExtensionDir) ? (0, fs_1.readdirSync)(workoutExtensionDir) : []
154
+ 'workout-extension': (0, fs_1.existsSync)(workoutExtensionDir) ? (0, fs_1.readdirSync)(workoutExtensionDir) : [],
132
155
  };
133
156
  return temps;
134
157
  }, {});
135
158
  allOS = ['v1', 'v2', 'v3', 'v3.5', 'v4'];
136
159
  appTypes = ['watchface', 'app', 'workout-extension'];
137
- genChoices = function () { return allOS.reduce(function (pre, osVersion) {
138
- pre[osVersion] = [];
139
- return pre;
140
- }, {}); };
160
+ genChoices = function () {
161
+ return allOS.reduce(function (pre, osVersion) {
162
+ pre[osVersion] = [];
163
+ return pre;
164
+ }, {});
165
+ };
141
166
  localChoices = genChoices();
142
167
  watchfaceTemplateChoices = { v1: [], v2: [] };
143
168
  appTemplateChoices = genChoices();
144
169
  workoutExtTemplateChoices = { 'v3.5': [] };
145
170
  getTemplateChoices = function (appType) {
146
171
  switch (appType) {
147
- case 'app': return appTemplateChoices;
148
- case 'watchface': return watchfaceTemplateChoices;
149
- case 'workout-extension': return workoutExtTemplateChoices;
172
+ case 'app':
173
+ return appTemplateChoices;
174
+ case 'watchface':
175
+ return watchfaceTemplateChoices;
176
+ case 'workout-extension':
177
+ return workoutExtTemplateChoices;
150
178
  }
151
179
  };
152
180
  templatesInit = function (os, dir) {
@@ -156,11 +184,11 @@ var createX = function (cwdPath, args, func, beforeFiles) {
156
184
  var chooseItem = {
157
185
  name: tempName,
158
186
  path: dirPath,
159
- type: AppSourceType.LOCAL
187
+ type: AppSourceType.LOCAL,
160
188
  };
161
189
  if (tempName === 'Empty') {
162
190
  Object.assign(chooseItem, {
163
- copyType: TemplateCopyType.EDIT
191
+ copyType: TemplateCopyType.EDIT,
164
192
  });
165
193
  localChoices[os].unshift(chooseItem);
166
194
  tempChoices[os].unshift(chooseItem);
@@ -184,7 +212,7 @@ var createX = function (cwdPath, args, func, beforeFiles) {
184
212
  templatesInit(osVersion, localTemplatesDirMap[osVersion]);
185
213
  });
186
214
  }
187
- env = yeoman_environment_1["default"].createEnv();
215
+ env = yeoman_environment_1.default.createEnv();
188
216
  env.lookup();
189
217
  generatorMate = env.getGeneratorsMeta();
190
218
  generatorMateKeys = Object.keys(generatorMate);
@@ -194,15 +222,15 @@ var createX = function (cwdPath, args, func, beforeFiles) {
194
222
  allOS.forEach(function (osVersion) {
195
223
  localChoices[osVersion].push({
196
224
  name: name,
197
- type: AppSourceType.YEOMAN
225
+ type: AppSourceType.YEOMAN,
198
226
  });
199
227
  appTemplateChoices[osVersion].push({
200
228
  name: name,
201
- type: AppSourceType.YEOMAN
229
+ type: AppSourceType.YEOMAN,
202
230
  });
203
231
  watchfaceTemplateChoices[osVersion].push({
204
232
  name: name,
205
- type: AppSourceType.YEOMAN
233
+ type: AppSourceType.YEOMAN,
206
234
  });
207
235
  });
208
236
  }
@@ -222,7 +250,7 @@ var createX = function (cwdPath, args, func, beforeFiles) {
222
250
  return [4, func(args, {
223
251
  appTemplateChoices: appTemplateChoices,
224
252
  workoutExtTemplateChoices: workoutExtTemplateChoices,
225
- watchfaceTemplateChoices: watchfaceTemplateChoices
253
+ watchfaceTemplateChoices: watchfaceTemplateChoices,
226
254
  })];
227
255
  case 1:
228
256
  answer = _c.sent();
@@ -230,10 +258,14 @@ var createX = function (cwdPath, args, func, beforeFiles) {
230
258
  answer.workDir = workDir;
231
259
  choosePkg = (function (appType) {
232
260
  switch (appType.toLowerCase()) {
233
- case AppType.APP: return appTemplateChoices[answer.OSVersion][answer.template];
234
- case AppType.WORKOUT_EXTENSION: return workoutExtTemplateChoices[answer.OSVersion][answer.template];
235
- case AppType.WATCHFACE: return watchfaceTemplateChoices[answer.OSVersion][answer.template];
236
- default: return appTemplateChoices[answer.OSVersion][answer.template];
261
+ case AppType.APP:
262
+ return appTemplateChoices[answer.OSVersion][answer.template];
263
+ case AppType.WORKOUT_EXTENSION:
264
+ return workoutExtTemplateChoices[answer.OSVersion][answer.template];
265
+ case AppType.WATCHFACE:
266
+ return watchfaceTemplateChoices[answer.OSVersion][answer.template];
267
+ default:
268
+ return appTemplateChoices[answer.OSVersion][answer.template];
237
269
  }
238
270
  })(answer.appType || AppType.APP);
239
271
  index_1.logger.info('fetching template...');
@@ -254,15 +286,15 @@ var createX = function (cwdPath, args, func, beforeFiles) {
254
286
  _c.sent();
255
287
  rd.eachFileSync(workDir, function (file) {
256
288
  if ((0, lodash_1.endsWith)(file, '.DS_Store')) {
257
- fs_extra_1["default"].remove(file);
289
+ fs_extra_1.default.remove(file);
258
290
  }
259
291
  else {
260
292
  var shortFile = file.replace(cwdPath, '');
261
293
  if (beforeFiles.includes(file)) {
262
- index_1.logger.log(chalk_1["default"].yellow(" ".concat(chalk_1["default"].bold('replace'), " ")), shortFile);
294
+ index_1.logger.log(chalk_1.default.yellow(" ".concat(chalk_1.default.bold('replace'), " ")), shortFile);
263
295
  }
264
296
  else {
265
- index_1.logger.log(chalk_1["default"].green(" ".concat(chalk_1["default"].bold('create'), " ")), shortFile);
297
+ index_1.logger.log(chalk_1.default.green(" ".concat(chalk_1.default.bold('create'), " ")), shortFile);
266
298
  }
267
299
  }
268
300
  });
@@ -272,7 +304,7 @@ var createX = function (cwdPath, args, func, beforeFiles) {
272
304
  return [4, projectPreInstall(workDir)];
273
305
  case 4:
274
306
  _c.sent();
275
- index_1.logger.log(chalk_1["default"].hex('#DB8C41')(zeppFontIcon));
307
+ index_1.logger.log(chalk_1.default.hex('#DB8C41')(zeppFontIcon));
276
308
  index_1.logger.log("I'm all done. Now you can start your application.");
277
309
  return [2, [
278
310
  "Project created successfully by \"".concat(choosePkg.name, "\" template."),