@zeppos/zeus-cli 1.6.3 → 1.6.5

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
@@ -50,7 +50,7 @@ var pre_check_1 = require("../utils/pre-check");
50
50
  var index_1 = require("../index");
51
51
  var zeppos_app_utils_1 = require("zeppos-app-utils");
52
52
  var tools_1 = require("../utils/tools");
53
- 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, fetchDevices = zeppos_app_utils_1.modules.fetchDevices;
53
+ 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, devicesData = zeppos_app_utils_1.modules.fetchDevices;
54
54
  var context = {};
55
55
  var yargsCmdBuilderFunc = function (cmdName, useProxy, yargs) {
56
56
  if (useProxy === void 0) { useProxy = false; }
@@ -59,6 +59,17 @@ var yargsCmdBuilderFunc = function (cmdName, useProxy, yargs) {
59
59
  return index_1.yargsCmdBuilders[cmdName](yargs);
60
60
  }
61
61
  };
62
+ var fetchDevices = function () { return __awaiter(void 0, void 0, void 0, function () {
63
+ var zeusVer;
64
+ return __generator(this, function (_a) {
65
+ switch (_a.label) {
66
+ case 0:
67
+ zeusVer = (0, index_1.zeusCurrentVersion)();
68
+ return [4, devicesData(zeusVer)];
69
+ case 1: return [2, _a.sent()];
70
+ }
71
+ });
72
+ }); };
62
73
  var proxy = function (args) { return __awaiter(void 0, void 0, void 0, function () {
63
74
  var res;
64
75
  return __generator(this, function (_a) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  exports.__esModule = true;
4
- exports.version = void 0;
4
+ exports.zeusCurrentVersion = exports.version = void 0;
5
5
  var node_child_process_1 = require("node:child_process");
6
6
  var appUtilPkg = require('zeppos-app-utils/package.json');
7
7
  var zeusVersion = require('../package.json').version;
@@ -34,3 +34,7 @@ function version() {
34
34
  ].join('\n');
35
35
  }
36
36
  exports.version = version;
37
+ function zeusCurrentVersion() {
38
+ return zeusVersion;
39
+ }
40
+ exports.zeusCurrentVersion = zeusCurrentVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeppos/zeus-cli",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
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.1.2",
24
+ "@zeppos/zpm": "^3.1.3",
25
25
  "axios": "^1.7.7",
26
26
  "chalk": "^4.1.2",
27
27
  "chokidar": "^3.6.0",
@@ -82,41 +82,50 @@ var fetchDevicesData = function (cdnUrl) {
82
82
  });
83
83
  });
84
84
  };
85
- var fetchDevices = function () { return __awaiter(void 0, void 0, void 0, function () {
86
- var localContent, now, prodDevices, betaDevices;
87
- return __generator(this, function (_a) {
88
- switch (_a.label) {
89
- case 0:
90
- localContent = {};
91
- if (fs_1["default"].existsSync(LOCAL_CACHE_DEVICE_PATH)) {
92
- try {
93
- localContent = fs_extra_1["default"].readJsonSync(LOCAL_CACHE_DEVICE_PATH);
85
+ var fetchDevices = function (currentVersion) {
86
+ if (currentVersion === void 0) { currentVersion = ''; }
87
+ return __awaiter(void 0, void 0, void 0, function () {
88
+ var localContent, generatedVersion, now, prodDevices, betaDevices;
89
+ return __generator(this, function (_a) {
90
+ switch (_a.label) {
91
+ case 0:
92
+ localContent = {};
93
+ if (fs_1["default"].existsSync(LOCAL_CACHE_DEVICE_PATH)) {
94
+ try {
95
+ localContent = fs_extra_1["default"].readJsonSync(LOCAL_CACHE_DEVICE_PATH);
96
+ }
97
+ catch (_e) { }
94
98
  }
95
- catch (_e) { }
96
- }
97
- now = Date.now().valueOf();
98
- if (!!((0, lodash_1.get)(localContent, 'expiredTime') > now)) return [3, 3];
99
- logger_1.logger.log(chalk_1["default"].hex('#DB8C41')('Updating devices, waiting ...'));
100
- return [4, fetchDevicesData(serverPath)];
101
- case 1:
102
- prodDevices = _a.sent();
103
- return [4, fetchDevicesData(serverPathBeta)];
104
- case 2:
105
- betaDevices = _a.sent();
106
- if (!(0, lodash_1.isEmpty)(prodDevices) || !(0, lodash_1.isEmpty)(betaDevices)) {
107
- fs_extra_1["default"].writeJsonSync(LOCAL_CACHE_DEVICE_PATH, {
108
- devices: prodDevices,
109
- devices_beta: betaDevices,
110
- expiredTime: now + 3 * dayMS
111
- });
112
- }
113
- else {
114
- return [2, {}];
115
- }
116
- return [3, 4];
117
- case 3: return [2, {}];
118
- case 4: return [2];
119
- }
99
+ generatedVersion = (0, lodash_1.get)(localContent, 'version') || '';
100
+ if (generatedVersion === '' || generatedVersion !== currentVersion) {
101
+ fs_extra_1["default"].removeSync(LOCAL_CACHE_DEVICE_PATH);
102
+ localContent = {};
103
+ }
104
+ now = Date.now().valueOf();
105
+ if (!!((0, lodash_1.get)(localContent, 'expiredTime') > now)) return [3, 3];
106
+ logger_1.logger.log(chalk_1["default"].hex('#DB8C41')('Updating devices, waiting ...'));
107
+ return [4, fetchDevicesData(serverPath)];
108
+ case 1:
109
+ prodDevices = _a.sent();
110
+ return [4, fetchDevicesData(serverPathBeta)];
111
+ case 2:
112
+ betaDevices = _a.sent();
113
+ if (!(0, lodash_1.isEmpty)(prodDevices) || !(0, lodash_1.isEmpty)(betaDevices)) {
114
+ fs_extra_1["default"].writeJsonSync(LOCAL_CACHE_DEVICE_PATH, {
115
+ devices: prodDevices,
116
+ devices_beta: [],
117
+ expiredTime: now + 3 * dayMS,
118
+ version: currentVersion
119
+ });
120
+ }
121
+ else {
122
+ return [2, {}];
123
+ }
124
+ return [3, 4];
125
+ case 3: return [2, {}];
126
+ case 4: return [2];
127
+ }
128
+ });
120
129
  });
121
- }); };
130
+ };
122
131
  exports.fetchDevices = fetchDevices;
@@ -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.1.2",
16
+ "@zeppos/zpm": "^3.1.3",
17
17
  "axios": "^1.7.7",
18
18
  "chalk": "^4.1.2",
19
19
  "chokidar": "^3.6.0",