@zeppos/zeus-cli 1.1.0-beta → 1.1.2
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/api/index.js +80 -103
- package/bin/cli.js +74 -22
- package/bin/post-command.js +8 -0
- package/config/device.js +0 -1
- package/config/project.js +11 -14
- package/font-icon.js +12 -0
- package/index.js +5 -1
- package/modules/bridge.js +88 -54
- package/modules/build.js +89 -75
- package/modules/config.js +15 -14
- package/modules/create/index.js +18 -15
- package/modules/create/local-app.js +2 -3
- package/modules/create/yeoman-app.js +1 -1
- package/modules/help.js +7 -4
- package/modules/login.js +96 -77
- package/modules/run.js +31 -9
- package/modules/simulator.js +6 -2
- package/modules/status.js +48 -17
- package/modules/storage.js +4 -77
- package/modules/websocket.js +7 -9
- package/package.json +7 -2
- package/utils/common.js +37 -17
- package/utils/hm-analytics.js +54 -0
- package/utils/logger.js +1 -13
- package/utils/pre-check.js +169 -0
- package/utils/hm_analytics.js +0 -35
package/api/index.js
CHANGED
|
@@ -12,7 +12,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
};
|
|
13
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
14
|
if (k2 === undefined) k2 = k;
|
|
15
|
-
Object.
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
16
20
|
}) : (function(o, m, k, k2) {
|
|
17
21
|
if (k2 === undefined) k2 = k;
|
|
18
22
|
o[k2] = m[k];
|
|
@@ -69,19 +73,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
69
73
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
70
74
|
};
|
|
71
75
|
exports.__esModule = true;
|
|
72
|
-
exports.downloadPackage = exports.uploadPackage = exports.getConnectDevServerWebSocketCode = exports.getUserInfo =
|
|
76
|
+
exports.downloadPackage = exports.uploadPackage = exports.getConnectDevServerWebSocketCode = exports.getUserInfo = void 0;
|
|
73
77
|
var axios_1 = __importDefault(require("axios"));
|
|
78
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
74
79
|
var qs_1 = __importDefault(require("qs"));
|
|
75
80
|
var project_1 = require("../config/project");
|
|
76
81
|
var logger = __importStar(require("../utils/logger"));
|
|
77
82
|
var storage_1 = require("../modules/storage");
|
|
78
|
-
// import { login } from '../modules/login'
|
|
79
|
-
// process.on('exit', (code) => {
|
|
80
|
-
// console.log(`About to exit with code: ${code}`);
|
|
81
|
-
// });
|
|
82
|
-
var _a = storage_1.instanceStorage.getStorage(), _b = project_1.loginStorageKey.accountToken, _c = _a[_b], apptoken = _c === void 0 ? '' : _c, _d = project_1.loginStorageKey.userid, _e = _a[_d], userid = _e === void 0 ? '' : _e, _f = project_1.loginStorageKey.cname, _g = _a[_f], cname = _g === void 0 ? '' : _g;
|
|
83
|
-
// 分区域名
|
|
84
|
-
exports.subRegionalHost = cname && cname.split(',').filter(function (h) { return h.indexOf('api-mifit') > -1; })[0];
|
|
85
83
|
var postForm = function (url, data) {
|
|
86
84
|
return (0, axios_1["default"])({
|
|
87
85
|
url: url,
|
|
@@ -92,9 +90,8 @@ var postForm = function (url, data) {
|
|
|
92
90
|
data: qs_1["default"].stringify(data)
|
|
93
91
|
});
|
|
94
92
|
};
|
|
95
|
-
// 获取用户信息接口
|
|
96
93
|
var getUserInfo = function (url, token) { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
-
var headers, userInfo, data, error_1;
|
|
94
|
+
var headers, userInfo, data, error_1, message;
|
|
98
95
|
return __generator(this, function (_a) {
|
|
99
96
|
switch (_a.label) {
|
|
100
97
|
case 0:
|
|
@@ -105,146 +102,126 @@ var getUserInfo = function (url, token) { return __awaiter(void 0, void 0, void
|
|
|
105
102
|
_a.label = 1;
|
|
106
103
|
case 1:
|
|
107
104
|
_a.trys.push([1, 3, , 4]);
|
|
108
|
-
return [4
|
|
105
|
+
return [4, axios_1["default"].get(url, {
|
|
109
106
|
headers: headers
|
|
110
107
|
})];
|
|
111
108
|
case 2:
|
|
112
109
|
userInfo = _a.sent();
|
|
113
110
|
data = userInfo.data;
|
|
114
|
-
return [2
|
|
111
|
+
return [2, data];
|
|
115
112
|
case 3:
|
|
116
113
|
error_1 = _a.sent();
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
message = typeof error_1 === 'object' ? error_1.message : error_1;
|
|
115
|
+
if (message.includes('401')) {
|
|
116
|
+
storage_1.globalStorage.deleteStorage(project_1.loginStorageKey.accountToken);
|
|
117
|
+
throw new Error('401');
|
|
120
118
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
case 4: return [2 /*return*/];
|
|
119
|
+
throw new Error('get nickName error');
|
|
120
|
+
case 4: return [2];
|
|
124
121
|
}
|
|
125
122
|
});
|
|
126
123
|
}); };
|
|
127
124
|
exports.getUserInfo = getUserInfo;
|
|
128
|
-
// 获取连接 developer server 的 websocket 连接
|
|
129
125
|
var getConnectDevServerWebSocketCode = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
130
|
-
var
|
|
131
|
-
var
|
|
132
|
-
return __generator(this, function (
|
|
133
|
-
switch (
|
|
126
|
+
var _a, _subRegionalHost, _loginAppToken, thisUrl, url, error_2, message;
|
|
127
|
+
var _b, _c;
|
|
128
|
+
return __generator(this, function (_d) {
|
|
129
|
+
switch (_d.label) {
|
|
134
130
|
case 0:
|
|
135
|
-
if (!
|
|
136
|
-
|
|
137
|
-
throw new Error(
|
|
131
|
+
if (!process.env._subRegionalHost) {
|
|
132
|
+
storage_1.globalStorage.deleteStorage(project_1.loginStorageKey.accountToken);
|
|
133
|
+
throw new Error('401');
|
|
138
134
|
}
|
|
139
|
-
|
|
135
|
+
_d.label = 1;
|
|
140
136
|
case 1:
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
_d.trys.push([1, 3, , 4]);
|
|
138
|
+
_a = process.env, _subRegionalHost = _a._subRegionalHost, _loginAppToken = _a._loginAppToken;
|
|
139
|
+
thisUrl = "https://".concat(_subRegionalHost, "/developerbridge/client/relay");
|
|
140
|
+
return [4, axios_1["default"].get(thisUrl, {
|
|
143
141
|
headers: {
|
|
144
|
-
apptoken:
|
|
142
|
+
apptoken: _loginAppToken
|
|
145
143
|
}
|
|
146
144
|
})];
|
|
147
145
|
case 2:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return [2 /*return*/, url];
|
|
146
|
+
url = (_d.sent()).data.url;
|
|
147
|
+
return [2, url];
|
|
151
148
|
case 3:
|
|
152
|
-
error_2 =
|
|
153
|
-
message = (error_2 === null || error_2 === void 0 ? void 0 : error_2.response) && ((
|
|
154
|
-
if ((message === null || message === void 0 ? void 0 : message.code) === 401 && ((
|
|
155
|
-
storage_1.globalStorage.deleteStorage(
|
|
156
|
-
|
|
157
|
-
throw new Error("Invalid token,please login again with the command 'zeus login'.");
|
|
149
|
+
error_2 = _d.sent();
|
|
150
|
+
message = (error_2 === null || error_2 === void 0 ? void 0 : error_2.response) && ((_b = error_2.response) === null || _b === void 0 ? void 0 : _b.data);
|
|
151
|
+
if ((message === null || message === void 0 ? void 0 : message.code) === 401 && ((_c = message === null || message === void 0 ? void 0 : message.data) === null || _c === void 0 ? void 0 : _c.code) === '0102') {
|
|
152
|
+
storage_1.globalStorage.deleteStorage(project_1.loginStorageKey.accountToken);
|
|
153
|
+
throw new Error('401');
|
|
158
154
|
}
|
|
159
155
|
else {
|
|
160
|
-
msg = project_1.ACCOUNT_ENV === 'production' ? "GetConnectDevServerWebSocketCode error" : "".concat(project_1.ACCOUNT_ENV, ":getConnectDevServerWebSocketCode error ").concat(JSON.stringify(message));
|
|
161
156
|
project_1.____inner_global_variable.bridgeOptionalDevice = '';
|
|
162
157
|
project_1.____inner_global_variable.bridgeChoiredDevice = '';
|
|
163
|
-
throw new Error(
|
|
158
|
+
throw new Error("GetConnectDevServerWebSocketCode error");
|
|
164
159
|
}
|
|
165
|
-
return [3
|
|
166
|
-
case 4: return [2
|
|
160
|
+
return [3, 4];
|
|
161
|
+
case 4: return [2];
|
|
167
162
|
}
|
|
168
163
|
});
|
|
169
164
|
}); };
|
|
170
165
|
exports.getConnectDevServerWebSocketCode = getConnectDevServerWebSocketCode;
|
|
171
|
-
// 上传表盘/应用接口
|
|
172
166
|
var uploadPackage = function (form, length) { return __awaiter(void 0, void 0, void 0, function () {
|
|
173
|
-
var packageInfo, error_3;
|
|
174
|
-
return __generator(this, function (
|
|
175
|
-
switch (
|
|
167
|
+
var _a, _subRegionalHost, _loginAppToken, _loginUserId, packageInfo, _b, protocol, code, error_3, message;
|
|
168
|
+
return __generator(this, function (_c) {
|
|
169
|
+
switch (_c.label) {
|
|
176
170
|
case 0:
|
|
177
|
-
_a.
|
|
178
|
-
|
|
179
|
-
headers: __assign(__assign({}, form.getHeaders()), { 'content-length': "".concat(length), apptoken: apptoken })
|
|
180
|
-
})];
|
|
171
|
+
_a = process.env, _subRegionalHost = _a._subRegionalHost, _loginAppToken = _a._loginAppToken, _loginUserId = _a._loginUserId;
|
|
172
|
+
_c.label = 1;
|
|
181
173
|
case 1:
|
|
182
|
-
|
|
183
|
-
return [
|
|
174
|
+
_c.trys.push([1, 3, , 4]);
|
|
175
|
+
return [4, axios_1["default"].post("https://".concat(_subRegionalHost, "/custom/tools/app-dial/upload?userid=").concat(_loginUserId), form, {
|
|
176
|
+
headers: __assign(__assign({}, form.getHeaders()), { 'content-length': "".concat(length), apptoken: _loginAppToken })
|
|
177
|
+
})];
|
|
184
178
|
case 2:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
return [
|
|
188
|
-
case 3:
|
|
179
|
+
packageInfo = _c.sent();
|
|
180
|
+
_b = lodash_1["default"].get(packageInfo, 'data', {}), protocol = _b.protocol, code = _b.code;
|
|
181
|
+
return [2, { protocol: protocol, code: code }];
|
|
182
|
+
case 3:
|
|
183
|
+
error_3 = _c.sent();
|
|
184
|
+
message = typeof error_3 === 'object' ? error_3.message : error_3;
|
|
185
|
+
if (message.includes('401')) {
|
|
186
|
+
storage_1.globalStorage.deleteStorage(project_1.loginStorageKey.accountToken);
|
|
187
|
+
throw new Error('401');
|
|
188
|
+
}
|
|
189
|
+
throw new Error(message);
|
|
190
|
+
case 4: return [2];
|
|
189
191
|
}
|
|
190
192
|
});
|
|
191
193
|
}); };
|
|
192
194
|
exports.uploadPackage = uploadPackage;
|
|
193
|
-
// 下载表盘/应用接口
|
|
194
195
|
var downloadPackage = function (code, deviceSource, appType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
195
|
-
var host, packageInfo, error_4;
|
|
196
|
-
return __generator(this, function (
|
|
197
|
-
switch (
|
|
196
|
+
var _a, _subRegionalHost, _loginAppToken, _loginUserId, host, packageInfo, error_4, message;
|
|
197
|
+
return __generator(this, function (_b) {
|
|
198
|
+
switch (_b.label) {
|
|
198
199
|
case 0:
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
_b.trys.push([0, 2, , 3]);
|
|
201
|
+
_a = process.env, _subRegionalHost = _a._subRegionalHost, _loginAppToken = _a._loginAppToken, _loginUserId = _a._loginUserId;
|
|
202
|
+
host = "https://".concat(_subRegionalHost, "/custom/tools/app-dial/download/").concat(code);
|
|
201
203
|
if (appType === 'app') {
|
|
202
|
-
return [2
|
|
204
|
+
return [2, host];
|
|
203
205
|
}
|
|
204
|
-
return [4
|
|
206
|
+
return [4, axios_1["default"].get("".concat(host, "?userid=").concat(_loginUserId, "&deviceSource=").concat(deviceSource), {
|
|
205
207
|
headers: {
|
|
206
|
-
apptoken:
|
|
208
|
+
apptoken: _loginAppToken
|
|
207
209
|
}
|
|
208
210
|
})];
|
|
209
211
|
case 1:
|
|
210
|
-
packageInfo =
|
|
211
|
-
return [2
|
|
212
|
+
packageInfo = _b.sent();
|
|
213
|
+
return [2, packageInfo];
|
|
212
214
|
case 2:
|
|
213
|
-
error_4 =
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
error_4 = _b.sent();
|
|
216
|
+
message = typeof error_4 === 'object' ? error_4.message : error_4;
|
|
217
|
+
if (message.includes('401')) {
|
|
218
|
+
storage_1.globalStorage.deleteStorage(project_1.loginStorageKey.accountToken);
|
|
219
|
+
message = "Invalid token,please login again with the command 'zeus login'.";
|
|
220
|
+
}
|
|
221
|
+
logger.error(message);
|
|
222
|
+
return [3, 3];
|
|
223
|
+
case 3: return [2];
|
|
217
224
|
}
|
|
218
225
|
});
|
|
219
226
|
}); };
|
|
220
227
|
exports.downloadPackage = downloadPackage;
|
|
221
|
-
// 登录接口(暂时没有用到)
|
|
222
|
-
// export const loginByLocal = async (account: string, password: string) => {
|
|
223
|
-
// const data = {
|
|
224
|
-
// client_id: 'HuaMi',
|
|
225
|
-
// country_code: 'zh-CN',
|
|
226
|
-
// json_response: 'true',
|
|
227
|
-
// name: '',
|
|
228
|
-
// password: password,
|
|
229
|
-
// phoneOrEmail: account,
|
|
230
|
-
// redirect_uri: 'https://s3-us-west-2.amazonaws.com/hm-registration/successsignin.html',
|
|
231
|
-
// state: 'REDIRECTION',
|
|
232
|
-
// token: 'access'
|
|
233
|
-
// }
|
|
234
|
-
// if (/^[1][0-9]{10}$/.test(account)) {
|
|
235
|
-
// data.phoneOrEmail = encodeURIComponent(`+86${account}`)
|
|
236
|
-
// }
|
|
237
|
-
// data.name = data.phoneOrEmail.split('@')[0]
|
|
238
|
-
// const checkInfo = await postForm(`${CUR_REGISTER_URL}/registrations/${data.phoneOrEmail}/tokens`, data)
|
|
239
|
-
// const { data: loginInfo } = await postForm(`${LOGIN_URL}/v2/client/login`, {
|
|
240
|
-
// app_name: 'com.huami.webapp',
|
|
241
|
-
// app_version: '4.3.0',
|
|
242
|
-
// code: _.get(checkInfo, 'data.access', ''),
|
|
243
|
-
// country_code: 'zh-cn',
|
|
244
|
-
// device_id: '02:00:00:00:00:00',
|
|
245
|
-
// device_model: 'web',
|
|
246
|
-
// grant_type: 'access_token',
|
|
247
|
-
// third_name: 'huami'
|
|
248
|
-
// })
|
|
249
|
-
// return loginInfo
|
|
250
|
-
// }
|
package/bin/cli.js
CHANGED
|
@@ -1,33 +1,85 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (_) try {
|
|
19
|
+
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;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
3
39
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
40
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
41
|
};
|
|
6
42
|
exports.__esModule = true;
|
|
7
43
|
var yargs_1 = __importDefault(require("yargs"));
|
|
44
|
+
require("./post-command");
|
|
45
|
+
var hideBin = require('yargs/helpers').hideBin;
|
|
46
|
+
var argv = hideBin(process.argv);
|
|
47
|
+
var pre_check_1 = require("../utils/pre-check");
|
|
8
48
|
var index_1 = require("../index");
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
var proxy = function (args) {
|
|
12
|
-
|
|
13
|
-
|
|
49
|
+
var hm_analytics_1 = require("../utils/hm-analytics");
|
|
50
|
+
var context = {};
|
|
51
|
+
var proxy = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
52
|
+
var res;
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
switch (_a.label) {
|
|
55
|
+
case 0: return [4, (0, pre_check_1.checkVersion)()];
|
|
56
|
+
case 1:
|
|
57
|
+
_a.sent();
|
|
58
|
+
return [4, (0, pre_check_1.initVariable)(args)];
|
|
59
|
+
case 2:
|
|
60
|
+
res = _a.sent();
|
|
61
|
+
Object.assign(context, res);
|
|
62
|
+
return [2];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}); };
|
|
66
|
+
(0, hm_analytics_1.HM_Analytics)('ZEPP_CLI_V');
|
|
14
67
|
yargs_1["default"].usage('Usage: $0 <command> [args?]')
|
|
15
|
-
.demandCommand(1)
|
|
68
|
+
.demandCommand(1, 'A command is required. Pass --help to see all available commands and options.')
|
|
16
69
|
.recommendCommands()
|
|
17
70
|
.help()
|
|
18
|
-
.alias('h', 'help')
|
|
19
|
-
.alias('v', 'version')
|
|
20
|
-
.
|
|
21
|
-
.command('
|
|
22
|
-
|
|
23
|
-
.command('login', '
|
|
24
|
-
.command('logout', 'Sign out of your account', proxy, index_1.logout)
|
|
25
|
-
.command('dev', '
|
|
26
|
-
.command('preview', '
|
|
27
|
-
|
|
28
|
-
.command('
|
|
29
|
-
.command('
|
|
30
|
-
.command('
|
|
31
|
-
.
|
|
32
|
-
.
|
|
33
|
-
.argv;
|
|
71
|
+
.alias('h', 'help').describe('help', 'Display help information.')
|
|
72
|
+
.alias('v', 'version').describe('version', 'Display version number.')
|
|
73
|
+
.group(['help', 'version'], "Base Options")
|
|
74
|
+
.command('init', 'Init a new project in current directory.', proxy, index_1.create)
|
|
75
|
+
.command('create <projectName>', 'Named the <projectName> project and add to the current directory.', proxy, index_1.create)
|
|
76
|
+
.command('login', 'Login to your account.', proxy, index_1.login)
|
|
77
|
+
.command('logout', 'Sign out of your account.', proxy, index_1.logout)
|
|
78
|
+
.command('dev', 'Run this project in development mode.', proxy, index_1.run)
|
|
79
|
+
.command('preview', 'Preview this project in your device.', proxy, index_1.buildPreview)
|
|
80
|
+
.command('build', 'Build this project for production.', proxy, index_1.buildProd)
|
|
81
|
+
.command('status', 'View information such as login and emulator connection status.', proxy, index_1.status)
|
|
82
|
+
.command('bridge', "Connect the online App or Simulator for development and debugging.", proxy, index_1.bridge)
|
|
83
|
+
.command('config', "Operation config value.\n e.g.\n set <key>=<value> [<key>=<value> ...]\n get <key> [<key> ...]\n delete <key> [<key> ...]\n list [--json]", proxy, index_1.config)
|
|
84
|
+
.epilogue('For more information, see https://docs.zepp.com/')
|
|
85
|
+
.parse(argv, context);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
var storage_1 = require("../modules/storage");
|
|
4
|
+
var bin = require('../package.json').bin;
|
|
5
|
+
var cmdName = Object.keys(bin || {})[0] || 'zeus';
|
|
6
|
+
var account_env = storage_1.globalStorage.get('account_env') || 'production';
|
|
7
|
+
process.env.CMD_NAME = cmdName;
|
|
8
|
+
process.env.ACCOUNT_ENV = account_env;
|
package/config/device.js
CHANGED
package/config/project.js
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
var _a;
|
|
6
5
|
exports.__esModule = true;
|
|
7
|
-
exports.simulatorStorageKey = exports.buildStorageKey = exports.____inner_global_variable = exports.loginStorageKey = exports.loginConfig = exports.analyticsHost = exports.
|
|
6
|
+
exports.simulatorStorageKey = exports.buildStorageKey = exports.____inner_global_variable = exports.analyticsKey = exports.loginStorageKey = exports.loginConfig = exports.analyticsHost = exports.gitignoreDefaultItem = exports.ACCOUNT_ENV_KEY = exports.TemplateCopyType = exports.AppSourceType = exports.AppType = void 0;
|
|
8
7
|
var lodash_1 = __importDefault(require("lodash"));
|
|
9
|
-
var storage_1 = require("../modules/storage");
|
|
10
8
|
var AppType;
|
|
11
9
|
(function (AppType) {
|
|
12
10
|
AppType["APP"] = "app";
|
|
@@ -23,13 +21,10 @@ var TemplateCopyType;
|
|
|
23
21
|
TemplateCopyType["EDIT"] = "edit";
|
|
24
22
|
})(TemplateCopyType = exports.TemplateCopyType || (exports.TemplateCopyType = {}));
|
|
25
23
|
exports.ACCOUNT_ENV_KEY = 'account_env';
|
|
26
|
-
exports.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
var curLoginURL = exports.ACCOUNT_ENV === 'production' ? 'https://user.huami.com/universalLogin/index.html#/login' : 'https://user-testing.huami.com/universalLogin/index.html#/login';
|
|
32
|
-
exports.analyticsHost = exports.ACCOUNT_ENV === 'production' ? 'https://api-analytics.huami.com' : 'https://api-analytics-test.huami.com';
|
|
24
|
+
exports.gitignoreDefaultItem = ['.DS_Store', 'node_modules/**', 'dist/*', 'npm-debug.log', 'yarn-debug.log*', 'yarn-error.log*', 'yarn.lock',
|
|
25
|
+
'package-lock.json', 'selenium-debug.log', '.idea', '.vscode', '*.suo', '*.ntvs*', '*.njsproj', '*.sln'];
|
|
26
|
+
var curLoginURL = process.env.ACCOUNT_ENV !== 'test' ? 'https://user.zepp.com/universalLogin/index.html#/login' : 'https://user-testing.zepp.com/universalLogin/index.html#/login';
|
|
27
|
+
exports.analyticsHost = process.env.ACCOUNT_ENV !== 'test' ? 'https://api-analytics.huami.com' : 'https://api-analytics-test.huami.com';
|
|
33
28
|
var loginUrl = new URL(curLoginURL);
|
|
34
29
|
var accountPrefix = "____".concat(lodash_1["default"].replace(loginUrl.host, /\./g, '_'), "__");
|
|
35
30
|
exports.loginConfig = {
|
|
@@ -38,12 +33,14 @@ exports.loginConfig = {
|
|
|
38
33
|
PLATFORM_APP: 'com.huami.webapp'
|
|
39
34
|
};
|
|
40
35
|
exports.loginStorageKey = {
|
|
41
|
-
nickName: "".concat(accountPrefix, "nickName"),
|
|
42
36
|
accountToken: "".concat(accountPrefix, "token"),
|
|
43
37
|
account: "".concat(accountPrefix, "account"),
|
|
44
38
|
userid: "".concat(accountPrefix, "userid"),
|
|
45
39
|
cname: "".concat(accountPrefix, "cname")
|
|
46
40
|
};
|
|
41
|
+
exports.analyticsKey = {
|
|
42
|
+
id: "".concat(accountPrefix, "analyticsId")
|
|
43
|
+
};
|
|
47
44
|
exports.____inner_global_variable = {
|
|
48
45
|
bridgeOptionalDevice: '',
|
|
49
46
|
bridgeChoiredDevice: ''
|
|
@@ -52,7 +49,7 @@ exports.buildStorageKey = {
|
|
|
52
49
|
targetDeviceToBuild: "".concat(accountPrefix, "targetDeviceToBuild")
|
|
53
50
|
};
|
|
54
51
|
exports.simulatorStorageKey = {
|
|
55
|
-
simulatorHost:
|
|
56
|
-
simulatorPort:
|
|
57
|
-
simulatorConnectStatus: "
|
|
52
|
+
simulatorHost: 'simulator_host',
|
|
53
|
+
simulatorPort: 'simulator_port',
|
|
54
|
+
simulatorConnectStatus: "____simulator_connect_status"
|
|
58
55
|
};
|
package/font-icon.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
+
exports.updateVersion = void 0;
|
|
3
4
|
var fontIcon = [
|
|
4
5
|
'',
|
|
5
6
|
' ********* ******* ******* ******* ',
|
|
@@ -12,4 +13,15 @@ var fontIcon = [
|
|
|
12
13
|
' //////// //////// // // ',
|
|
13
14
|
'',
|
|
14
15
|
].join('\n');
|
|
16
|
+
exports.updateVersion = [
|
|
17
|
+
'',
|
|
18
|
+
'╭──────────────────────────────────────────────────────╮',
|
|
19
|
+
'│ │',
|
|
20
|
+
'│ New version available! │',
|
|
21
|
+
'│ Changelog: https://api.huami.com/t/zeus-cli-doc │',
|
|
22
|
+
'│ Run `npm install @zeppos/zeus-cli -g` to update! │',
|
|
23
|
+
'│ │',
|
|
24
|
+
'╰──────────────────────────────────────────────────────╯',
|
|
25
|
+
'',
|
|
26
|
+
].join('\n');
|
|
15
27
|
exports["default"] = fontIcon;
|
package/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|