@zeppos/zeus-cli 1.2.3 → 1.2.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.
Files changed (52) hide show
  1. package/bin/main.js +1 -1
  2. package/modules/bridge.js +1 -1
  3. package/modules/build.js +152 -32
  4. package/modules/create.js +7 -6
  5. package/modules/help.js +1 -1
  6. package/modules/run.js +14 -12
  7. package/package.json +2 -2
  8. package/private-modules/zeppos-app-utils/dist/api/index.js +1 -1
  9. package/private-modules/zeppos-app-utils/dist/config/device.js +391 -213
  10. package/private-modules/zeppos-app-utils/dist/modules/build.js +101 -29
  11. package/private-modules/zeppos-app-utils/dist/modules/config.js +1 -1
  12. package/private-modules/zeppos-app-utils/dist/modules/create/index.js +13 -11
  13. package/private-modules/zeppos-app-utils/dist/modules/create/local-app.js +10 -10
  14. package/private-modules/zeppos-app-utils/dist/modules/create/yeoman-app.js +1 -1
  15. package/private-modules/zeppos-app-utils/dist/modules/login.js +1 -1
  16. package/private-modules/zeppos-app-utils/dist/modules/status.js +1 -1
  17. package/private-modules/zeppos-app-utils/dist/public/template/v2/empty/page/index.js +2 -2
  18. package/private-modules/zeppos-app-utils/dist/tools/index.js +1 -1
  19. package/private-modules/zeppos-app-utils/package.json +1 -1
  20. package/utils/pre-check.js +11 -22
  21. package/utils/tools.js +14 -0
  22. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/consume.png +0 -0
  23. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/food/beer.png +0 -0
  24. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/food/cake.png +0 -0
  25. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/food/chocolate.png +0 -0
  26. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/food/coffee.png +0 -0
  27. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/food/cookies.png +0 -0
  28. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/food/ham.png +0 -0
  29. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/food/hamburger.png +0 -0
  30. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/food/ice cream.png +0 -0
  31. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/food/pizza.png +0 -0
  32. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/food/sausage.png +0 -0
  33. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/icon.png +0 -0
  34. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/multiply.png +0 -0
  35. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/selected.png +0 -0
  36. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/assets/gts/unselected.png +0 -0
  37. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/page/gts/food-list.js +0 -113
  38. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/calories/page/gts/index.js +0 -126
  39. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/fetch-api/assets/common/icon.png +0 -0
  40. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/fetch-api/pages/i18n/en-US.po +0 -2
  41. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/fetch-api/pages/index.js +0 -55
  42. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/hello-world/assets/gtr/icon.png +0 -0
  43. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/hello-world/assets/gtr/image/logo.png +0 -0
  44. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/hello-world/assets/gts/icon.png +0 -0
  45. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/hello-world/assets/gts/image/logo.png +0 -0
  46. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/hello-world/page/gtr/home/index.page.js +0 -20
  47. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/hello-world/page/gtr/home/index.page.json +0 -1
  48. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/hello-world/page/gtr/home/index.style.js +0 -18
  49. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/hello-world/page/gts/home/index.page.js +0 -21
  50. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/hello-world/page/gts/home/index.page.json +0 -1
  51. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/hello-world/page/gts/home/index.style.js +0 -17
  52. package/private-modules/zeppos-app-utils/dist/public/template/config-version-v3/v2/todo-list/assets/gts/icon.png +0 -0
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  function verb(n) { return function (v) { return step([n, v]); }; }
38
38
  function step(op) {
39
39
  if (f) throw new TypeError("Generator is already executing.");
40
- while (_) try {
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
41
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
42
  if (y = 0, t) op = [op[0] & 2, t.value];
43
43
  switch (op[0]) {
@@ -62,7 +62,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
62
62
  return (mod && mod.__esModule) ? mod : { "default": mod };
63
63
  };
64
64
  exports.__esModule = true;
65
- exports.runX = exports.previewBuild = exports.build = exports.BuildMode = void 0;
65
+ exports.runX = exports.previewBuild = exports.build = exports.buildSupportV3Config = exports.BuildMode = void 0;
66
66
  var zpm_1 = require("@zeppos/zpm");
67
67
  var rd = __importStar(require("rd"));
68
68
  var fs_1 = __importDefault(require("fs"));
@@ -105,13 +105,86 @@ var gitignoreDefaultItem = [
105
105
  '*.njsproj',
106
106
  '*.sln',
107
107
  ];
108
+ var buildSupportV3Config = function (workspace, mode, buildConfigOption) {
109
+ if (mode === void 0) { mode = BuildMode.PROD; }
110
+ if (buildConfigOption === void 0) { buildConfigOption = {}; }
111
+ return __awaiter(void 0, void 0, void 0, function () {
112
+ var _a, targets, _b, sources, buildOptions, _c, js2c, _d, js2bin, _e, png2vg, _f, prune, _g, compress, zabName_1, distDir_1, name_1, newName_1, error_1;
113
+ return __generator(this, function (_h) {
114
+ switch (_h.label) {
115
+ case 0:
116
+ _a = buildConfigOption.targets, targets = _a === void 0 ? [] : _a, _b = buildConfigOption.sources, sources = _b === void 0 ? [] : _b;
117
+ buildOptions = {
118
+ path: workspace,
119
+ buildMode: mode,
120
+ targets: targets,
121
+ sources: sources,
122
+ jsc: TransformType.Default
123
+ };
124
+ if ([BuildMode.PROD, BuildMode.PREVIEW].includes(mode)) {
125
+ _c = buildConfigOption || {}, js2c = _c.js2c, _d = _c.js2bin, js2bin = _d === void 0 ? true : _d, _e = _c.png2vg, png2vg = _e === void 0 ? true : _e, _f = _c.prune, prune = _f === void 0 ? true : _f, _g = _c.compress, compress = _g === void 0 ? true : _g;
126
+ js2c = !!(js2c === 'true' || js2c === true);
127
+ js2bin = !!(js2bin === 'true' || js2bin === true);
128
+ png2vg = !!(png2vg === 'true' || png2vg === true);
129
+ prune = !!(prune === 'true' || prune === true);
130
+ compress = !!(compress === 'true' || compress === true);
131
+ js2c && Object.assign(buildOptions, { jsc: TransformType.C });
132
+ js2bin && Object.assign(buildOptions, { jsc: TransformType.Bin });
133
+ Object.assign(buildOptions, {
134
+ png2vg: png2vg,
135
+ prune: prune,
136
+ compress: compress
137
+ });
138
+ }
139
+ _h.label = 1;
140
+ case 1:
141
+ _h.trys.push([1, 6, , 7]);
142
+ if (targets.length) {
143
+ index_1.logger.info("Start building package, targets: ".concat(targets.join(', '), "."));
144
+ }
145
+ else if (sources.length) {
146
+ index_1.logger.info("Start building package, device sources: ".concat(sources.join(', '), "."));
147
+ }
148
+ if (!(mode === BuildMode.DEV && (0, lodash_1.get)(buildConfigOption, '_[0]') !== 'install')) return [3, 3];
149
+ return [4, (0, zpm_1.startWithoutDist)(buildOptions)];
150
+ case 2: return [2, _h.sent()];
151
+ case 3: return [4, (0, zpm_1.start)(buildOptions)];
152
+ case 4:
153
+ zabName_1 = _h.sent();
154
+ if (buildConfigOption.renameWithAppId) {
155
+ distDir_1 = path.join(workspace, 'dist');
156
+ name_1 = zabName_1.replace(/[\s]/g, '_').split('.zab');
157
+ newName_1 = "".concat(buildConfigOption.renameWithAppId, "-").concat(name_1[0], ".zab");
158
+ rd.eachFileSync(distDir_1, function (file) {
159
+ var oldName = path.join(distDir_1, zabName_1);
160
+ if (file !== oldName) {
161
+ fs_extra_1["default"].removeSync(file);
162
+ }
163
+ else {
164
+ fs_1["default"].renameSync(oldName, path.join(distDir_1, newName_1));
165
+ }
166
+ });
167
+ return [2, newName_1];
168
+ }
169
+ return [2, zabName_1];
170
+ case 5: return [3, 7];
171
+ case 6:
172
+ error_1 = _h.sent();
173
+ index_1.logger.error(error_1);
174
+ return [3, 7];
175
+ case 7: return [2];
176
+ }
177
+ });
178
+ });
179
+ };
180
+ exports.buildSupportV3Config = buildSupportV3Config;
108
181
  var build = function (workspace, mode, buildConfigOption, packages, appId) {
109
182
  if (mode === void 0) { mode = BuildMode.PROD; }
110
183
  if (appId === void 0) { appId = '10000'; }
111
184
  return __awaiter(void 0, void 0, void 0, function () {
112
- var buildOptions, _a, js2c, _b, js2bin, _c, png2vg, _d, prune, curOpt, productName_1, DistDir_1, name_1, newName_1, error_1;
113
- return __generator(this, function (_e) {
114
- switch (_e.label) {
185
+ var buildOptions, _a, js2c, _b, js2bin, _c, png2vg, _d, prune, _e, compress, curOpt, productName_1, DistDir_1, name_2, newName_2, error_2;
186
+ return __generator(this, function (_f) {
187
+ switch (_f.label) {
115
188
  case 0:
116
189
  buildOptions = {
117
190
  path: workspace,
@@ -120,54 +193,56 @@ var build = function (workspace, mode, buildConfigOption, packages, appId) {
120
193
  jsc: TransformType.Default
121
194
  };
122
195
  if (mode === BuildMode.PROD || mode === BuildMode.PREVIEW) {
123
- _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;
196
+ _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;
124
197
  js2c = !!(js2c === 'true' || js2c === true);
125
198
  js2bin = !!(js2bin === 'true' || js2bin === true);
126
199
  png2vg = !!(png2vg === 'true' || png2vg === true);
127
200
  prune = !!(prune === 'true' || prune === true);
201
+ compress = !!(compress === 'true' || compress === true);
128
202
  js2c && Object.assign(buildOptions, { jsc: TransformType.C });
129
203
  js2bin && Object.assign(buildOptions, { jsc: TransformType.Bin });
130
204
  Object.assign(buildOptions, {
131
205
  png2vg: png2vg,
132
- prune: prune
206
+ prune: prune,
207
+ compress: compress
133
208
  });
134
209
  }
135
- _e.label = 1;
210
+ _f.label = 1;
136
211
  case 1:
137
- _e.trys.push([1, 6, , 7]);
212
+ _f.trys.push([1, 6, , 7]);
138
213
  index_1.logger.info("Start building package, targets: ".concat(packages.join(', '), "."));
139
- curOpt = (buildConfigOption ? buildConfigOption._ : [''])[0];
214
+ curOpt = (0, lodash_1.get)(buildConfigOption, '_', [])[0];
140
215
  if (!(mode !== BuildMode.DEV ||
141
216
  (mode === BuildMode.DEV && curOpt === 'install'))) return [3, 3];
142
217
  return [4, (0, zpm_1.start)(buildOptions)];
143
218
  case 2:
144
- productName_1 = _e.sent();
219
+ productName_1 = _f.sent();
145
220
  if (productName_1) {
146
221
  DistDir_1 = path.join(workspace, 'dist');
147
- name_1 = productName_1.replace(/[\s]/g, '_').split('.zab');
148
- newName_1 = "".concat(appId, "-").concat(name_1[0], ".zab");
222
+ name_2 = productName_1.replace(/[\s]/g, '_').split('.zab');
223
+ newName_2 = "".concat(appId, "-").concat(name_2[0], ".zab");
149
224
  rd.eachFileSync(DistDir_1, function (file) {
150
225
  var oldName = path.join(DistDir_1, productName_1);
151
226
  if (file !== oldName) {
152
227
  fs_extra_1["default"].removeSync(file);
153
228
  }
154
229
  else {
155
- fs_1["default"].renameSync(oldName, path.join(DistDir_1, newName_1));
230
+ fs_1["default"].renameSync(oldName, path.join(DistDir_1, newName_2));
156
231
  }
157
232
  });
158
- productName_1 = newName_1;
233
+ productName_1 = newName_2;
159
234
  }
160
235
  return [2, productName_1];
161
236
  case 3:
162
237
  if (!(mode === BuildMode.DEV)) return [3, 5];
163
238
  return [4, (0, zpm_1.startWithoutDist)(buildOptions)];
164
239
  case 4:
165
- _e.sent();
240
+ _f.sent();
166
241
  return [2, (0, zpm_1.getZpkBuf)(packages[0])];
167
242
  case 5: return [3, 7];
168
243
  case 6:
169
- error_1 = _e.sent();
170
- index_1.logger.error(error_1);
244
+ error_2 = _f.sent();
245
+ index_1.logger.error(error_2);
171
246
  return [3, 7];
172
247
  case 7: return [2];
173
248
  }
@@ -184,7 +259,7 @@ var previewBuild = function (root, args, workspace, appType, curCommand) { retur
184
259
  form.append('file', fs_1["default"].createReadStream(workspace));
185
260
  form.append('app_type', appType === index_1.config.AppType.WATCHFACE ? '1' : '2');
186
261
  form.getLength(function (err, length) { return __awaiter(void 0, void 0, void 0, function () {
187
- var protocol, code, res, error_2, _subRegionalHost, url, _a, deviceSource, appId, appName, appType_1, deviceSourceArr, targetDeviceInternalName, packageInfo, url, preview, downloadPackageReturn;
262
+ var protocol, code, res, error_3, _subRegionalHost, url, _a, deviceSource, appId, appName, appType_1, deviceSourceArr, targetDeviceInternalName, packageInfo, url, preview, downloadPackageReturn;
188
263
  return __generator(this, function (_b) {
189
264
  switch (_b.label) {
190
265
  case 0:
@@ -204,8 +279,8 @@ var previewBuild = function (root, args, workspace, appType, curCommand) { retur
204
279
  code = res.code;
205
280
  return [3, 7];
206
281
  case 3:
207
- error_2 = _b.sent();
208
- if (!((error_2 === null || error_2 === void 0 ? void 0 : error_2.message) === '401')) return [3, 5];
282
+ error_3 = _b.sent();
283
+ if (!((error_3 === null || error_3 === void 0 ? void 0 : error_3.message) === '401')) return [3, 5];
209
284
  index_1.logger.warn("Login information is invalid. Please login again, or end this service and login again with the command 'zeus login'.");
210
285
  return [4, index_1.modules.login().then(function (res) { return __awaiter(void 0, void 0, void 0, function () {
211
286
  return __generator(this, function (_a) {
@@ -219,7 +294,7 @@ var previewBuild = function (root, args, workspace, appType, curCommand) { retur
219
294
  _b.sent();
220
295
  return [3, 6];
221
296
  case 5:
222
- index_1.logger.error(error_2 === null || error_2 === void 0 ? void 0 : error_2.message);
297
+ index_1.logger.error(error_3 === null || error_3 === void 0 ? void 0 : error_3.message);
223
298
  reject('reTry');
224
299
  return [2];
225
300
  case 6: return [3, 7];
@@ -232,7 +307,7 @@ var previewBuild = function (root, args, workspace, appType, curCommand) { retur
232
307
  case 8:
233
308
  if (!(curCommand === 'install')) return [3, 10];
234
309
  _a = (0, index_1.getDeviceInfoFromAppJson)(root), deviceSource = _a.deviceSource, appId = _a.appId, appName = _a.appName, appType_1 = _a.appType, deviceSourceArr = _a.deviceSourceArr, targetDeviceInternalName = _a.targetDeviceInternalName;
235
- return [4, index_1.api.downloadPackage(code, deviceSource, appType_1)];
310
+ return [4, index_1.api.downloadPackage(code, (0, lodash_1.get)(args, "sources[0]", deviceSource), appType_1)];
236
311
  case 9:
237
312
  packageInfo = _b.sent();
238
313
  url = packageInfo;
@@ -250,7 +325,7 @@ var previewBuild = function (root, args, workspace, appType, curCommand) { retur
250
325
  name: appName,
251
326
  "debugger": true,
252
327
  updatedTime: Math.round(new Date().getTime() / 1000),
253
- devices: deviceSourceArr,
328
+ devices: (0, lodash_1.get)(args, "sources", deviceSourceArr),
254
329
  target: targetDeviceInternalName
255
330
  });
256
331
  _b.label = 10;
@@ -264,7 +339,7 @@ var previewBuild = function (root, args, workspace, appType, curCommand) { retur
264
339
  });
265
340
  }); };
266
341
  exports.previewBuild = previewBuild;
267
- var runX = function (root, args, url, packages, logAfterFunc) { return __awaiter(void 0, void 0, void 0, function () {
342
+ var runX = function (root, args, url, logAfterFunc) { return __awaiter(void 0, void 0, void 0, function () {
268
343
  var logger, simulator, refreshSimulator, gitignorePath, gitignore, ignored;
269
344
  return __generator(this, function (_a) {
270
345
  logger = new index_1.MyLogger();
@@ -278,10 +353,7 @@ var runX = function (root, args, url, packages, logAfterFunc) { return __awaiter
278
353
  switch (_b.label) {
279
354
  case 0:
280
355
  logger.info('rebuilding...');
281
- if (process.env._targetDeviceToBuild && !args.target) {
282
- args.target = process.env._targetDeviceToBuild;
283
- }
284
- return [4, index_1.modules.build(root, BuildMode.DEV, args, packages)];
356
+ return [4, (0, exports.buildSupportV3Config)(root, BuildMode.DEV, args)];
285
357
  case 1:
286
358
  zpkBuffer = _b.sent();
287
359
  if (zpkBuffer) {
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
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.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -48,7 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  function verb(n) { return function (v) { return step([n, v]); }; }
49
49
  function step(op) {
50
50
  if (f) throw new TypeError("Generator is already executing.");
51
- while (_) try {
51
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
52
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
53
  if (y = 0, t) op = [op[0] & 2, t.value];
54
54
  switch (op[0]) {
@@ -101,14 +101,16 @@ var projectPreInstall = function (dir) {
101
101
  var createX = function (cwdPath, args, func, beforeFiles) {
102
102
  if (beforeFiles === void 0) { beforeFiles = []; }
103
103
  return __awaiter(void 0, void 0, void 0, function () {
104
- var cmd, _a, projectName, workDir, V1_TEMPLATE_DIR, V2_TEMPLATE_DIR, localTemplates, localChoices, watchfaceTemplateChoices, appTemplateChoices, templatesInit, env, generatorMate, generatorMateKeys, choicesValueFormat, answer, choosePkg;
105
- return __generator(this, function (_b) {
106
- switch (_b.label) {
104
+ var cmd, _a, projectName, _b, configVersion, workDir, templateDir, V1_TEMPLATE_DIR, V2_TEMPLATE_DIR, localTemplates, localChoices, watchfaceTemplateChoices, appTemplateChoices, templatesInit, env, generatorMate, generatorMateKeys, choicesValueFormat, answer, choosePkg;
105
+ return __generator(this, function (_c) {
106
+ switch (_c.label) {
107
107
  case 0:
108
- cmd = args._[0], _a = args.projectName, projectName = _a === void 0 ? '' : _a;
108
+ cmd = args._[0], _a = args.projectName, projectName = _a === void 0 ? '' : _a, _b = args.configVersion, configVersion = _b === void 0 ? 'v2' : _b;
109
109
  workDir = cwdPath;
110
- V1_TEMPLATE_DIR = (0, path_1.resolve)(__dirname, '../../public/template/v1');
111
- V2_TEMPLATE_DIR = (0, path_1.resolve)(__dirname, '../../public/template/v2');
110
+ args.configVersion = (0, lodash_1.toLower)(configVersion);
111
+ templateDir = (0, path_1.resolve)(__dirname, "../../public/template".concat((0, lodash_1.toLower)(configVersion) === 'v3' ? '/config-version-v3' : ''));
112
+ V1_TEMPLATE_DIR = (0, path_1.resolve)(templateDir, './v1');
113
+ V2_TEMPLATE_DIR = (0, path_1.resolve)(templateDir, './v2');
112
114
  localTemplates = {
113
115
  v1: (0, fs_1.readdirSync)(V1_TEMPLATE_DIR),
114
116
  v2: (0, fs_1.readdirSync)(V2_TEMPLATE_DIR)
@@ -199,7 +201,7 @@ var createX = function (cwdPath, args, func, beforeFiles) {
199
201
  watchfaceTemplateChoices: watchfaceTemplateChoices
200
202
  })];
201
203
  case 1:
202
- answer = _b.sent();
204
+ answer = _c.sent();
203
205
  answer.appType = answer.appType || AppType.APP;
204
206
  answer.workDir = workDir;
205
207
  choosePkg = answer.appType.toLowerCase() === AppType.APP
@@ -208,7 +210,7 @@ var createX = function (cwdPath, args, func, beforeFiles) {
208
210
  index_1.logger.info('fetching template...');
209
211
  return [4, (0, index_1.sleep)(100)];
210
212
  case 2:
211
- _b.sent();
213
+ _c.sent();
212
214
  if (choosePkg.type === AppSourceType.YEOMAN) {
213
215
  index_1.logger.info("".concat((0, lodash_1.upperFirst)(cmd), " application using yeoman template \"").concat(choosePkg.name, "\"."));
214
216
  (0, yeoman_app_1.createYeomanApp)(__assign(__assign({}, answer), { env: env, templateInfo: generatorMate[choosePkg.name] }));
@@ -220,7 +222,7 @@ var createX = function (cwdPath, args, func, beforeFiles) {
220
222
  index_1.logger.log('\n');
221
223
  return [4, (0, index_1.sleep)(50)];
222
224
  case 3:
223
- _b.sent();
225
+ _c.sent();
224
226
  rd.eachFileSync(workDir, function (file) {
225
227
  if ((0, lodash_1.endsWith)(file, '.DS_Store')) {
226
228
  fs_extra_1["default"].remove(file);
@@ -240,7 +242,7 @@ var createX = function (cwdPath, args, func, beforeFiles) {
240
242
  index_1.logger.log('Start installing dependency packages.');
241
243
  return [4, projectPreInstall(workDir)];
242
244
  case 4:
243
- _b.sent();
245
+ _c.sent();
244
246
  index_1.logger.log(chalk_1["default"].hex('#DB8C41')(zeppFontIcon));
245
247
  index_1.logger.log("I'm all done. Now you can start your application.");
246
248
  return [2, [
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -59,12 +59,12 @@ var fs_1 = __importDefault(require("fs"));
59
59
  var index_1 = require("../../index");
60
60
  var TemplateCopyType = index_1.config.TemplateCopyType, AppType = index_1.config.AppType, deviceTargets = index_1.config.deviceTargets;
61
61
  var createLocalApp = function (args) { return __awaiter(void 0, void 0, void 0, function () {
62
- var workDir, templateInfo, OSVersion, withAppSide, withSettings, buildTargets, appType, appJsonPath, appJson, appID, defaultTarget, targets, defaultWatchFaceConfig, defaultAssetsPath_1;
62
+ var workDir, templateInfo, withAppSide, withSettings, buildTargets, appType, appJsonPath, appJson, appID, defaultTarget, targets, defaultWatchFaceConfig, defaultAssetsPath_1;
63
63
  return __generator(this, function (_a) {
64
- workDir = args.workDir, templateInfo = args.templateInfo, OSVersion = args.OSVersion, withAppSide = args.withAppSide, withSettings = args.withSettings, buildTargets = args.buildTargets, appType = args.appType;
64
+ workDir = args.workDir, templateInfo = args.templateInfo, withAppSide = args.withAppSide, withSettings = args.withSettings, buildTargets = args.buildTargets, appType = args.appType;
65
65
  fs_extra_1["default"].copySync(templateInfo.path, workDir);
66
- fs_extra_1["default"].copySync((0, path_1.resolve)(__dirname, "../../public/template/".concat(OSVersion, "/jsconfig.json")), "".concat(workDir, "/jsconfig.json"));
67
- fs_extra_1["default"].copySync((0, path_1.resolve)(__dirname, "../../public/template/".concat(OSVersion, "/_package.json")), "".concat(workDir, "/package.json"));
66
+ fs_extra_1["default"].copySync((0, path_1.resolve)(templateInfo.path, "../jsconfig.json"), "".concat(workDir, "/jsconfig.json"));
67
+ fs_extra_1["default"].copySync((0, path_1.resolve)(templateInfo.path, "../_package.json"), "".concat(workDir, "/package.json"));
68
68
  fs_1["default"].writeFileSync("".concat(workDir, "/global.d.ts"), '/// <reference path="node_modules/@zeppos/device-types/index.d.ts" />');
69
69
  appJsonPath = (0, path_1.resolve)(workDir, './app.json');
70
70
  appJson = fs_extra_1["default"].readJsonSync(appJsonPath);
@@ -81,11 +81,11 @@ var createLocalApp = function (args) { return __awaiter(void 0, void 0, void 0,
81
81
  targets = {};
82
82
  if (appType.toLowerCase() === AppType.WATCHFACE) {
83
83
  defaultWatchFaceConfig = {
84
- "path": "watchface/index",
85
- "main": 1,
86
- "editable": 0,
87
- "lockscreen": 0,
88
- "photoscreen": 0
84
+ path: 'watchface/index',
85
+ main: 1,
86
+ editable: 0,
87
+ lockscreen: 0,
88
+ photoscreen: 0
89
89
  };
90
90
  lodash_1["default"].set(appJson, 'app.appType', AppType.WATCHFACE);
91
91
  lodash_1["default"].set(appJson, 'app.description', 'empty watchface');
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
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.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
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.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
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.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -1,7 +1,7 @@
1
- import { gettext } from 'i18n'
1
+ import { getText } from '@zos/i18n'
2
2
 
3
3
  Page({
4
4
  build() {
5
- console.log(gettext('example'))
5
+ console.log(getText('example'))
6
6
  }
7
7
  })
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  function verb(n) { return function (v) { return step([n, v]); }; }
38
38
  function step(op) {
39
39
  if (f) throw new TypeError("Generator is already executing.");
40
- while (_) try {
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
41
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
42
  if (y = 0, t) op = [op[0] & 2, t.value];
43
43
  switch (op[0]) {
@@ -12,7 +12,7 @@
12
12
  "clean": "rm -rf node_modules && rm -rf dist"
13
13
  },
14
14
  "dependencies": {
15
- "@zeppos/zpm": "^2.6.6",
15
+ "@zeppos/zpm": "^3.0.0",
16
16
  "axios": "^0.27.2",
17
17
  "chalk": "^4.1.2",
18
18
  "chokidar": "^3.5.3",
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
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.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -43,17 +43,12 @@ exports.initVariable = exports.checkVersion = void 0;
43
43
  var chalk_1 = __importDefault(require("chalk"));
44
44
  var packageJson = require('package-json');
45
45
  var zeppos_app_utils_1 = require("zeppos-app-utils");
46
+ var tools_1 = require("./tools");
46
47
  var loginStorageKey = zeppos_app_utils_1.config.getLocalConfig().loginStorageKey;
47
48
  var _a = require('../package.json'), userVersion = _a.version, userName = _a.name;
48
49
  var versionCheckTimeKey = '____inner_version_check_time';
49
50
  var versionKey = '____inner_version';
50
51
  var _b = zeppos_app_utils_1.instanceStorage.getStorage(), _c = versionCheckTimeKey, userVersionCheckTime = _b[_c], _d = versionKey, originVersion = _b[_d], _e = loginStorageKey.accountToken, _f = _b[_e], apptoken = _f === void 0 ? '' : _f, _g = loginStorageKey.userid, _h = _b[_g], userid = _h === void 0 ? '' : _h, _j = loginStorageKey.cname, _k = _b[_j], cname = _k === void 0 ? '' : _k, _l = _b.account_env, _accountEnv = _l === void 0 ? 'production' : _l;
51
- var versionToCode = function (version) {
52
- if (!version)
53
- return 0;
54
- var p = version.split('.').map(function (val) { return Number(val); });
55
- return p[0] * 10000 + p[1] * 100;
56
- };
57
52
  var checkOriginVersion = function () { return __awaiter(void 0, void 0, void 0, function () {
58
53
  var versions, versionList, error_1;
59
54
  var _a;
@@ -61,7 +56,7 @@ var checkOriginVersion = function () { return __awaiter(void 0, void 0, void 0,
61
56
  switch (_b.label) {
62
57
  case 0:
63
58
  _b.trys.push([0, 2, , 3]);
64
- return [4, packageJson(userName, { allVersions: true, registryUrl: 'https://registry.npmjs.org/' })];
59
+ return [4, packageJson(userName, { allVersions: true })];
65
60
  case 1:
66
61
  versions = (_b.sent()).versions;
67
62
  versionList = Object.keys(versions).filter(function (val) { return !val.includes('beta'); });
@@ -83,21 +78,15 @@ var checkOriginVersion = function () { return __awaiter(void 0, void 0, void 0,
83
78
  var checkVersion = function () { return __awaiter(void 0, void 0, void 0, function () {
84
79
  var originVersionCode, userVersionCode;
85
80
  return __generator(this, function (_a) {
86
- switch (_a.label) {
87
- case 0:
88
- if (!(!originVersion || !userVersionCheckTime || (+new Date() - Number(userVersionCheckTime) > 24 * 60 * 60 * 1000))) return [3, 2];
89
- return [4, checkOriginVersion()];
90
- case 1:
91
- _a.sent();
92
- _a.label = 2;
93
- case 2:
94
- originVersionCode = versionToCode(originVersion);
95
- userVersionCode = versionToCode(userVersion);
96
- if (originVersionCode - userVersionCode >= 100) {
97
- zeppos_app_utils_1.logger.log(chalk_1["default"].hex('#DB8C41')(zeppos_app_utils_1.config.updateVersion));
98
- }
99
- return [2];
81
+ if (!originVersion || !userVersionCheckTime || (+new Date() - Number(userVersionCheckTime) > 24 * 60 * 60 * 1000)) {
82
+ checkOriginVersion();
83
+ }
84
+ originVersionCode = (0, tools_1.versionToCode)(originVersion);
85
+ userVersionCode = (0, tools_1.versionToCode)(userVersion);
86
+ if (originVersionCode - userVersionCode >= 100) {
87
+ zeppos_app_utils_1.logger.log(chalk_1["default"].hex('#DB8C41')(zeppos_app_utils_1.config.updateVersion));
100
88
  }
89
+ return [2];
101
90
  });
102
91
  }); };
103
92
  exports.checkVersion = checkVersion;
package/utils/tools.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.compareVersion = exports.versionToCode = void 0;
4
+ var versionToCode = function (version) {
5
+ if (!version)
6
+ return 0;
7
+ var _a = version.split('.').map(function (val) { return Number(val); }), _b = _a[0], p0 = _b === void 0 ? 0 : _b, _c = _a[1], p1 = _c === void 0 ? 0 : _c, _d = _a[2], p2 = _d === void 0 ? 0 : _d;
8
+ return p0 * 10000 + p1 * 100 + p2;
9
+ };
10
+ exports.versionToCode = versionToCode;
11
+ var compareVersion = function (version1, version2) {
12
+ return (0, exports.versionToCode)(version2) - (0, exports.versionToCode)(version1);
13
+ };
14
+ exports.compareVersion = compareVersion;