@zeppos/zeus-cli 1.1.1 → 1.1.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.
- package/README.md +1 -1
- package/api/index.js +81 -112
- package/bin/cli.js +74 -22
- package/bin/post-command.js +8 -0
- package/config/device.js +25 -1
- package/config/project.js +8 -11
- package/font-icon.js +12 -0
- package/index.js +5 -1
- package/modules/bridge.js +88 -50
- package/modules/build.js +87 -73
- package/modules/config.js +15 -14
- package/modules/create/index.js +15 -14
- 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 +97 -130
- package/modules/run.js +34 -12
- package/modules/simulator.js +9 -4
- package/modules/status.js +47 -18
- package/modules/storage.js +4 -77
- package/modules/websocket.js +23 -17
- package/package.json +7 -2
- package/utils/common.js +17 -12
- package/utils/hm-analytics.js +55 -0
- package/utils/logger.js +1 -13
- package/utils/pre-check.js +169 -0
- package/utils/hm_analytics.js +0 -35
package/README.md
CHANGED
|
@@ -15,4 +15,4 @@ The Zeus CLI can help you install the development application to your device, wh
|
|
|
15
15
|
|
|
16
16
|
### Help
|
|
17
17
|
|
|
18
|
-
For more help, please visit [Zepp
|
|
18
|
+
For more help, please visit [Zepp Developer](https://developer.zepp.com/) or [Zepp OS Docs](https://docs.zepp.com/)
|
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,21 +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
|
-
// import { bridge } from '../modules/bridge'
|
|
80
|
-
// mark 调试时有用
|
|
81
|
-
// process.on('exit', (code) => {
|
|
82
|
-
// console.log(`About to exit with code: ${code}`);
|
|
83
|
-
// });
|
|
84
|
-
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;
|
|
85
|
-
// 分区域名
|
|
86
|
-
exports.subRegionalHost = cname && cname.split(',').filter(function (h) { return h.indexOf('api-mifit') > -1; })[0];
|
|
87
83
|
var postForm = function (url, data) {
|
|
88
84
|
return (0, axios_1["default"])({
|
|
89
85
|
url: url,
|
|
@@ -94,9 +90,8 @@ var postForm = function (url, data) {
|
|
|
94
90
|
data: qs_1["default"].stringify(data)
|
|
95
91
|
});
|
|
96
92
|
};
|
|
97
|
-
// 获取用户信息接口
|
|
98
93
|
var getUserInfo = function (url, token) { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
|
-
var headers, userInfo, data, error_1;
|
|
94
|
+
var headers, userInfo, data, error_1, message;
|
|
100
95
|
return __generator(this, function (_a) {
|
|
101
96
|
switch (_a.label) {
|
|
102
97
|
case 0:
|
|
@@ -107,154 +102,128 @@ var getUserInfo = function (url, token) { return __awaiter(void 0, void 0, void
|
|
|
107
102
|
_a.label = 1;
|
|
108
103
|
case 1:
|
|
109
104
|
_a.trys.push([1, 3, , 4]);
|
|
110
|
-
return [4
|
|
105
|
+
return [4, axios_1["default"].get(url, {
|
|
111
106
|
headers: headers
|
|
112
107
|
})];
|
|
113
108
|
case 2:
|
|
114
109
|
userInfo = _a.sent();
|
|
115
110
|
data = userInfo.data;
|
|
116
|
-
return [2
|
|
111
|
+
return [2, data];
|
|
117
112
|
case 3:
|
|
118
113
|
error_1 = _a.sent();
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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');
|
|
122
118
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
case 4: return [2 /*return*/];
|
|
119
|
+
throw new Error('get nickName error');
|
|
120
|
+
case 4: return [2];
|
|
126
121
|
}
|
|
127
122
|
});
|
|
128
123
|
}); };
|
|
129
124
|
exports.getUserInfo = getUserInfo;
|
|
130
|
-
// 获取连接 developer server 的 websocket 连接
|
|
131
125
|
var getConnectDevServerWebSocketCode = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
132
|
-
var
|
|
133
|
-
var
|
|
134
|
-
return __generator(this, function (
|
|
135
|
-
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) {
|
|
136
130
|
case 0:
|
|
137
|
-
if (!
|
|
138
|
-
storage_1.globalStorage.deleteStorage(
|
|
139
|
-
|
|
140
|
-
throw new Error(message);
|
|
131
|
+
if (!process.env._subRegionalHost) {
|
|
132
|
+
storage_1.globalStorage.deleteStorage(project_1.loginStorageKey.accountToken);
|
|
133
|
+
throw new Error('401');
|
|
141
134
|
}
|
|
142
|
-
|
|
135
|
+
_d.label = 1;
|
|
143
136
|
case 1:
|
|
144
|
-
|
|
145
|
-
|
|
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, {
|
|
146
141
|
headers: {
|
|
147
|
-
apptoken:
|
|
142
|
+
apptoken: _loginAppToken
|
|
148
143
|
}
|
|
149
144
|
})];
|
|
150
145
|
case 2:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return [2 /*return*/, url];
|
|
146
|
+
url = (_d.sent()).data.url;
|
|
147
|
+
return [2, url];
|
|
154
148
|
case 3:
|
|
155
|
-
error_2 =
|
|
156
|
-
message = (error_2 === null || error_2 === void 0 ? void 0 : error_2.response) && ((
|
|
157
|
-
if ((message === null || message === void 0 ? void 0 : message.code) === 401 && ((
|
|
158
|
-
storage_1.globalStorage.deleteStorage(
|
|
159
|
-
|
|
160
|
-
// await login()
|
|
161
|
-
throw new Error("".concat(project_1.ACCOUNT_ENV === 'production' ? '' : 'test: ', "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');
|
|
162
154
|
}
|
|
163
155
|
else {
|
|
164
|
-
msg = project_1.ACCOUNT_ENV === 'production' ? "GetConnectDevServerWebSocketCode error" : "".concat(project_1.ACCOUNT_ENV, ":getConnectDevServerWebSocketCode error ").concat(JSON.stringify(message));
|
|
165
156
|
project_1.____inner_global_variable.bridgeOptionalDevice = '';
|
|
166
157
|
project_1.____inner_global_variable.bridgeChoiredDevice = '';
|
|
167
|
-
throw new Error(
|
|
158
|
+
throw new Error("GetConnectDevServerWebSocketCode error");
|
|
168
159
|
}
|
|
169
|
-
return [3
|
|
170
|
-
case 4: return [2
|
|
160
|
+
return [3, 4];
|
|
161
|
+
case 4: return [2];
|
|
171
162
|
}
|
|
172
163
|
});
|
|
173
164
|
}); };
|
|
174
165
|
exports.getConnectDevServerWebSocketCode = getConnectDevServerWebSocketCode;
|
|
175
|
-
// 上传表盘/应用接口
|
|
176
166
|
var uploadPackage = function (form, length) { return __awaiter(void 0, void 0, void 0, function () {
|
|
177
|
-
var packageInfo, error_3, message;
|
|
178
|
-
return __generator(this, function (
|
|
179
|
-
switch (
|
|
167
|
+
var _a, _subRegionalHost, _loginAppToken, _loginUserId, packageInfo, _b, protocol, code, error_3, message;
|
|
168
|
+
return __generator(this, function (_c) {
|
|
169
|
+
switch (_c.label) {
|
|
180
170
|
case 0:
|
|
181
|
-
_a.
|
|
182
|
-
|
|
183
|
-
headers: __assign(__assign({}, form.getHeaders()), { 'content-length': "".concat(length), apptoken: apptoken })
|
|
184
|
-
})];
|
|
171
|
+
_a = process.env, _subRegionalHost = _a._subRegionalHost, _loginAppToken = _a._loginAppToken, _loginUserId = _a._loginUserId;
|
|
172
|
+
_c.label = 1;
|
|
185
173
|
case 1:
|
|
186
|
-
|
|
187
|
-
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
|
+
maxContentLength: Infinity,
|
|
178
|
+
maxBodyLength: Infinity
|
|
179
|
+
})];
|
|
188
180
|
case 2:
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
181
|
+
packageInfo = _c.sent();
|
|
182
|
+
_b = lodash_1["default"].get(packageInfo, 'data', {}), protocol = _b.protocol, code = _b.code;
|
|
183
|
+
return [2, { protocol: protocol, code: code }];
|
|
184
|
+
case 3:
|
|
185
|
+
error_3 = _c.sent();
|
|
186
|
+
message = typeof error_3 === 'object' ? error_3.message : error_3;
|
|
187
|
+
if (message.includes('401')) {
|
|
188
|
+
storage_1.globalStorage.deleteStorage(project_1.loginStorageKey.accountToken);
|
|
189
|
+
throw new Error('401');
|
|
194
190
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return [3 /*break*/, 3];
|
|
198
|
-
case 3: return [2 /*return*/];
|
|
191
|
+
throw new Error(message);
|
|
192
|
+
case 4: return [2];
|
|
199
193
|
}
|
|
200
194
|
});
|
|
201
195
|
}); };
|
|
202
196
|
exports.uploadPackage = uploadPackage;
|
|
203
|
-
// 下载表盘/应用接口
|
|
204
197
|
var downloadPackage = function (code, deviceSource, appType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
205
|
-
var host, packageInfo, error_4;
|
|
206
|
-
return __generator(this, function (
|
|
207
|
-
switch (
|
|
198
|
+
var _a, _subRegionalHost, _loginAppToken, _loginUserId, host, packageInfo, error_4, message;
|
|
199
|
+
return __generator(this, function (_b) {
|
|
200
|
+
switch (_b.label) {
|
|
208
201
|
case 0:
|
|
209
|
-
|
|
210
|
-
|
|
202
|
+
_b.trys.push([0, 2, , 3]);
|
|
203
|
+
_a = process.env, _subRegionalHost = _a._subRegionalHost, _loginAppToken = _a._loginAppToken, _loginUserId = _a._loginUserId;
|
|
204
|
+
host = "https://".concat(_subRegionalHost, "/custom/tools/app-dial/download/").concat(code);
|
|
211
205
|
if (appType === 'app') {
|
|
212
|
-
return [2
|
|
206
|
+
return [2, host];
|
|
213
207
|
}
|
|
214
|
-
return [4
|
|
208
|
+
return [4, axios_1["default"].get("".concat(host, "?userid=").concat(_loginUserId, "&deviceSource=").concat(deviceSource), {
|
|
215
209
|
headers: {
|
|
216
|
-
apptoken:
|
|
210
|
+
apptoken: _loginAppToken
|
|
217
211
|
}
|
|
218
212
|
})];
|
|
219
213
|
case 1:
|
|
220
|
-
packageInfo =
|
|
221
|
-
return [2
|
|
214
|
+
packageInfo = _b.sent();
|
|
215
|
+
return [2, packageInfo];
|
|
222
216
|
case 2:
|
|
223
|
-
error_4 =
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
217
|
+
error_4 = _b.sent();
|
|
218
|
+
message = typeof error_4 === 'object' ? error_4.message : error_4;
|
|
219
|
+
if (message.includes('401')) {
|
|
220
|
+
storage_1.globalStorage.deleteStorage(project_1.loginStorageKey.accountToken);
|
|
221
|
+
message = "Invalid token,please login again with the command 'zeus login'.";
|
|
222
|
+
}
|
|
223
|
+
logger.error(message);
|
|
224
|
+
return [3, 3];
|
|
225
|
+
case 3: return [2];
|
|
227
226
|
}
|
|
228
227
|
});
|
|
229
228
|
}); };
|
|
230
229
|
exports.downloadPackage = downloadPackage;
|
|
231
|
-
// 登录接口(暂时没有用到)
|
|
232
|
-
// export const loginByLocal = async (account: string, password: string) => {
|
|
233
|
-
// const data = {
|
|
234
|
-
// client_id: 'HuaMi',
|
|
235
|
-
// country_code: 'zh-CN',
|
|
236
|
-
// json_response: 'true',
|
|
237
|
-
// name: '',
|
|
238
|
-
// password: password,
|
|
239
|
-
// phoneOrEmail: account,
|
|
240
|
-
// redirect_uri: 'https://s3-us-west-2.amazonaws.com/hm-registration/successsignin.html',
|
|
241
|
-
// state: 'REDIRECTION',
|
|
242
|
-
// token: 'access'
|
|
243
|
-
// }
|
|
244
|
-
// if (/^[1][0-9]{10}$/.test(account)) {
|
|
245
|
-
// data.phoneOrEmail = encodeURIComponent(`+86${account}`)
|
|
246
|
-
// }
|
|
247
|
-
// data.name = data.phoneOrEmail.split('@')[0]
|
|
248
|
-
// const checkInfo = await postForm(`${CUR_REGISTER_URL}/registrations/${data.phoneOrEmail}/tokens`, data)
|
|
249
|
-
// const { data: loginInfo } = await postForm(`${LOGIN_URL}/v2/client/login`, {
|
|
250
|
-
// app_name: 'com.huami.webapp',
|
|
251
|
-
// app_version: '4.3.0',
|
|
252
|
-
// code: _.get(checkInfo, 'data.access', ''),
|
|
253
|
-
// country_code: 'zh-cn',
|
|
254
|
-
// device_id: '02:00:00:00:00:00',
|
|
255
|
-
// device_model: 'web',
|
|
256
|
-
// grant_type: 'access_token',
|
|
257
|
-
// third_name: 'huami'
|
|
258
|
-
// })
|
|
259
|
-
// return loginInfo
|
|
260
|
-
// }
|
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
|
@@ -7,6 +7,7 @@ var DeviceTarget;
|
|
|
7
7
|
DeviceTarget["MADRID"] = "madrid";
|
|
8
8
|
DeviceTarget["VERONA"] = "verona";
|
|
9
9
|
DeviceTarget["ZURICH"] = "zurich";
|
|
10
|
+
DeviceTarget["TEIDE"] = "teide";
|
|
10
11
|
})(DeviceTarget = exports.DeviceTarget || (exports.DeviceTarget = {}));
|
|
11
12
|
var DevicePlatformName;
|
|
12
13
|
(function (DevicePlatformName) {
|
|
@@ -16,6 +17,8 @@ var DevicePlatformName;
|
|
|
16
17
|
DevicePlatformName["VERONAW"] = "gtr3-w";
|
|
17
18
|
DevicePlatformName["ZURICH"] = "gts3";
|
|
18
19
|
DevicePlatformName["ZURICHW"] = "gts3-w";
|
|
20
|
+
DevicePlatformName["TEIDE"] = "teide";
|
|
21
|
+
DevicePlatformName["TEIDEW"] = "teide-w";
|
|
19
22
|
})(DevicePlatformName = exports.DevicePlatformName || (exports.DevicePlatformName = {}));
|
|
20
23
|
var DeviceSource;
|
|
21
24
|
(function (DeviceSource) {
|
|
@@ -25,6 +28,8 @@ var DeviceSource;
|
|
|
25
28
|
DeviceSource[DeviceSource["VERONAW"] = 227] = "VERONAW";
|
|
26
29
|
DeviceSource[DeviceSource["ZURICH"] = 224] = "ZURICH";
|
|
27
30
|
DeviceSource[DeviceSource["ZURICHW"] = 225] = "ZURICHW";
|
|
31
|
+
DeviceSource[DeviceSource["TEIDE"] = 418] = "TEIDE";
|
|
32
|
+
DeviceSource[DeviceSource["TEIDEW"] = 419] = "TEIDEW";
|
|
28
33
|
})(DeviceSource = exports.DeviceSource || (exports.DeviceSource = {}));
|
|
29
34
|
var DeviceScreenType;
|
|
30
35
|
(function (DeviceScreenType) {
|
|
@@ -86,8 +91,25 @@ exports.deviceTargets = (_a = {},
|
|
|
86
91
|
height: 450
|
|
87
92
|
}
|
|
88
93
|
},
|
|
94
|
+
_a[DeviceTarget.TEIDE] = {
|
|
95
|
+
deviceName: 'TEIDE',
|
|
96
|
+
platforms: [
|
|
97
|
+
{
|
|
98
|
+
name: DevicePlatformName.TEIDE,
|
|
99
|
+
deviceSource: DeviceSource.TEIDE
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: DevicePlatformName.TEIDEW,
|
|
103
|
+
deviceSource: DeviceSource.TEIDEW
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
screen: {
|
|
107
|
+
type: DeviceScreenType.R,
|
|
108
|
+
width: 454,
|
|
109
|
+
height: 454
|
|
110
|
+
}
|
|
111
|
+
},
|
|
89
112
|
_a);
|
|
90
|
-
// 这个方式获取 deviceSource 是不是会有问题呀, 需要手动补充
|
|
91
113
|
exports.deviceInternalCodeName = (_b = {},
|
|
92
114
|
_b[DeviceSource.MADRID] = DeviceTarget.MADRID,
|
|
93
115
|
_b[DeviceSource.MADRIDW] = DeviceTarget.MADRID,
|
|
@@ -95,4 +117,6 @@ exports.deviceInternalCodeName = (_b = {},
|
|
|
95
117
|
_b[DeviceSource.VERONAW] = DeviceTarget.VERONA,
|
|
96
118
|
_b[DeviceSource.ZURICH] = DeviceTarget.ZURICH,
|
|
97
119
|
_b[DeviceSource.ZURICHW] = DeviceTarget.ZURICH,
|
|
120
|
+
_b[DeviceSource.TEIDE] = DeviceTarget.TEIDE,
|
|
121
|
+
_b[DeviceSource.TEIDEW] = DeviceTarget.TEIDE,
|
|
98
122
|
_b);
|
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.zepp.com/universalLogin/index.html#/login' : 'https://user-testing.zepp.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: ''
|
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];
|