@zeppos/zeus-cli 1.3.6 → 1.3.7
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 +8 -8
- package/modules/build.js +5 -3
- package/modules/create.js +6 -5
- package/package.json +1 -1
- package/private-modules/zeppos-app-utils/dist/config/device.js +105 -45
- package/private-modules/zeppos-app-utils/dist/modules/create/local-app.js +3 -2
- package/private-modules/zeppos-app-utils/dist/modules/fetchDevices.js +87 -0
- package/private-modules/zeppos-app-utils/dist/modules/index.js +1 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os1.0/app/fetch-api/app-side/index.js +6 -18
- package/private-modules/zeppos-app-utils/dist/public/template/os1.0/app/fetch-api/pages/index.js +6 -6
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/app-side/index.js +6 -18
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/pages/index.js +6 -6
- package/private-modules/zeppos-app-utils/dist/public/template/os3.0/app/fetch-api/app-side/index.js +7 -35
- package/private-modules/zeppos-app-utils/dist/public/template/os3.0/app/fetch-api/page/index.js +1 -1
- package/private-modules/zeppos-app-utils/dist/public/template/os3.0/app/fetch-api/page/index.r.layout.js +8 -8
- package/private-modules/zeppos-app-utils/dist/public/template/os3.0/app/fetch-api/page/index.s.layout.js +1 -1
- package/private-modules/zeppos-app-utils/dist/tools/index.js +2 -1
- package/private-modules/zeppos-app-utils/dist/config/device-server.js +0 -116
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/.prettierrc.js +0 -6
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/app-side/index.js +0 -45
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/app.js +0 -25
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/app.json +0 -64
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/assets/gts/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/page/home/index.page.js +0 -155
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/page/home/index.page.json +0 -1
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/page/home/index.style.js +0 -92
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/page/i18n/en-US.po +0 -9
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/secondary-widget/index.js +0 -160
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/setting/i18n/en-US.po +0 -5
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/setting/index.js +0 -143
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/data.js +0 -67
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/defer.js +0 -35
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/device-polyfill.js +0 -6
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/es6-promise.js +0 -1178
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/event.js +0 -42
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/message-side.js +0 -1190
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/message.js +0 -1196
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/utils/constants.js +0 -1
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/utils/index.js +0 -38
package/bin/main.js
CHANGED
|
@@ -49,7 +49,7 @@ var argv = hideBin(process.argv);
|
|
|
49
49
|
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
|
-
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;
|
|
52
|
+
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, fetchDevicesWrap = zeppos_app_utils_1.modules.fetchDevicesWrap;
|
|
53
53
|
var context = {};
|
|
54
54
|
var yargsCmdBuilderFunc = function (cmdName, useProxy, yargs) {
|
|
55
55
|
if (useProxy === void 0) { useProxy = false; }
|
|
@@ -84,15 +84,15 @@ yargs_1["default"].usage("Usage: ".concat(process.env.CMD_NAME, " <command> [arg
|
|
|
84
84
|
.alias('h', 'help').describe('help', 'Display help information.')
|
|
85
85
|
.alias('v', 'version').describe('version', 'Display version number.')
|
|
86
86
|
.group(['help', 'version'], "Base Options")
|
|
87
|
-
.command('init', 'Init a new project in current directory.', proxy, index_1.create)
|
|
88
|
-
.command('create <projectName>', 'Named the <projectName> project and add to the current directory.', proxy, index_1.create)
|
|
87
|
+
.command('init', 'Init a new project in current directory.', proxy, fetchDevicesWrap(index_1.create))
|
|
88
|
+
.command('create <projectName>', 'Named the <projectName> project and add to the current directory.', proxy, fetchDevicesWrap(index_1.create))
|
|
89
89
|
.command('login', 'Login to your account.', proxy, login)
|
|
90
90
|
.command('logout', 'Sign out of your account.', proxy, logout)
|
|
91
|
-
.command('dev', 'Run this project in development mode. Use "zeus dev -h" to see more information', yargsCmdBuilderFunc.bind(null, 'dev', true), index_1.run)
|
|
92
|
-
.command('preview', 'Preview this project in your device.', proxy, index_1.buildPreview)
|
|
93
|
-
.command('build', 'Build this project for production.', proxy, index_1.buildProd)
|
|
91
|
+
.command('dev', 'Run this project in development mode. Use "zeus dev -h" to see more information', yargsCmdBuilderFunc.bind(null, 'dev', true), fetchDevicesWrap(index_1.run))
|
|
92
|
+
.command('preview', 'Preview this project in your device.', proxy, fetchDevicesWrap(index_1.buildPreview))
|
|
93
|
+
.command('build', 'Build this project for production.', proxy, fetchDevicesWrap(index_1.buildProd))
|
|
94
94
|
.command('status', 'View information such as login and emulator connection status.', proxy, status)
|
|
95
|
-
.command('bridge', "Connect the online App or Simulator for development and debugging.", proxy, index_1.bridge)
|
|
96
|
-
.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, modulesConfig)
|
|
95
|
+
.command('bridge', "Connect the online App or Simulator for development and debugging.", proxy, fetchDevicesWrap(index_1.bridge))
|
|
96
|
+
.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, fetchDevicesWrap(modulesConfig))
|
|
97
97
|
.epilogue('For more information, see https://docs.zepp.com/')
|
|
98
98
|
.parse(argv, context);
|
package/modules/build.js
CHANGED
|
@@ -83,7 +83,7 @@ var qrcode_terminal_1 = __importDefault(require("qrcode-terminal"));
|
|
|
83
83
|
var inquirer_1 = __importDefault(require("inquirer"));
|
|
84
84
|
var zeppos_app_utils_1 = require("zeppos-app-utils");
|
|
85
85
|
var tools_1 = require("../utils/tools");
|
|
86
|
-
var AppType = zeppos_app_utils_1.config.AppType,
|
|
86
|
+
var AppType = zeppos_app_utils_1.config.AppType, getDeviceConf = zeppos_app_utils_1.config.getDeviceConf;
|
|
87
87
|
var appJsonPath = path.resolve('./app.json');
|
|
88
88
|
var appJsonContent = fs_extra_1["default"].readJSONSync(appJsonPath, { throws: false });
|
|
89
89
|
var BuildMode;
|
|
@@ -112,12 +112,13 @@ var checkAppJson = function () {
|
|
|
112
112
|
var chooseBuildTargetsV3Config = function (mode, args) {
|
|
113
113
|
if (mode === void 0) { mode = 'development'; }
|
|
114
114
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
115
|
-
var target, apiLevel, platforms, usefulScreenTypes, usefulDeviceSource, targetDevices, deviceNames, isValidDevice, answers, _a;
|
|
115
|
+
var target, deviceTargets, apiLevel, platforms, usefulScreenTypes, usefulDeviceSource, targetDevices, deviceNames, isValidDevice, answers, _a;
|
|
116
116
|
return __generator(this, function (_b) {
|
|
117
117
|
switch (_b.label) {
|
|
118
118
|
case 0:
|
|
119
119
|
checkAppJson();
|
|
120
120
|
target = args.target;
|
|
121
|
+
deviceTargets = getDeviceConf().deviceTargets;
|
|
121
122
|
apiLevel = (0, lodash_1.get)(appJsonContent, 'runtime.apiVersion.minVersion', '1.0.0');
|
|
122
123
|
platforms = Object.values((0, lodash_1.get)(appJsonContent, 'targets', {})).reduce(function (list, item) {
|
|
123
124
|
return list.concat((0, lodash_1.get)(item, 'platforms', []));
|
|
@@ -174,11 +175,12 @@ var chooseBuildTargetsV3Config = function (mode, args) {
|
|
|
174
175
|
var chooseBuildTargetsV2Config = function (mode, args) {
|
|
175
176
|
if (mode === void 0) { mode = 'development'; }
|
|
176
177
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
177
|
-
var jsonTargets_1, unsupportedTargets_1, targets, returnRes, _a, promptTarget_1, answers;
|
|
178
|
+
var OSV2Devices, jsonTargets_1, unsupportedTargets_1, targets, returnRes, _a, promptTarget_1, answers;
|
|
178
179
|
return __generator(this, function (_b) {
|
|
179
180
|
switch (_b.label) {
|
|
180
181
|
case 0:
|
|
181
182
|
checkAppJson();
|
|
183
|
+
OSV2Devices = getDeviceConf().OSV2Devices;
|
|
182
184
|
if (isV2ApiVersion(appJsonContent)) {
|
|
183
185
|
jsonTargets_1 = (0, lodash_1.get)(appJsonContent, 'targets', {});
|
|
184
186
|
unsupportedTargets_1 = [];
|
package/modules/create.js
CHANGED
|
@@ -53,15 +53,16 @@ var lodash_1 = require("lodash");
|
|
|
53
53
|
var inquirer_1 = __importDefault(require("inquirer"));
|
|
54
54
|
var path_1 = require("path");
|
|
55
55
|
var zeppos_app_utils_1 = require("zeppos-app-utils");
|
|
56
|
-
var AppType = zeppos_app_utils_1.config.AppType,
|
|
56
|
+
var AppType = zeppos_app_utils_1.config.AppType, getDeviceConf = zeppos_app_utils_1.config.getDeviceConf;
|
|
57
57
|
var inquirerFunc = function (args, _a) {
|
|
58
58
|
var appTemplateChoices = _a.appTemplateChoices, watchfaceTemplateChoices = _a.watchfaceTemplateChoices;
|
|
59
59
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
60
|
-
var _b, promptAppType, _c, promptOsVersion, _d, promptTemplate, _e, promptWithAppSide, _f, promptWithSettings, _g, promptBuildTargets, _h, configVersion;
|
|
61
|
-
return __generator(this, function (
|
|
62
|
-
switch (
|
|
60
|
+
var _b, promptAppType, _c, promptOsVersion, _d, promptTemplate, _e, promptWithAppSide, _f, promptWithSettings, _g, promptBuildTargets, _h, configVersion, _j, deviceTargets, OSV2DeviceTargetNames;
|
|
61
|
+
return __generator(this, function (_k) {
|
|
62
|
+
switch (_k.label) {
|
|
63
63
|
case 0:
|
|
64
64
|
_b = args.appType, promptAppType = _b === void 0 ? '' : _b, _c = args.OSVersion, promptOsVersion = _c === void 0 ? '' : _c, _d = args.template, promptTemplate = _d === void 0 ? '' : _d, _e = args.withAppSide, promptWithAppSide = _e === void 0 ? false : _e, _f = args.withSettings, promptWithSettings = _f === void 0 ? false : _f, _g = args.buildTargets, promptBuildTargets = _g === void 0 ? [] : _g, _h = args.configVersion, configVersion = _h === void 0 ? 'v2' : _h;
|
|
65
|
+
_j = getDeviceConf(), deviceTargets = _j.deviceTargets, OSV2DeviceTargetNames = _j.OSV2DeviceTargetNames;
|
|
65
66
|
return [4, inquirer_1["default"].prompt([
|
|
66
67
|
{
|
|
67
68
|
name: 'appType',
|
|
@@ -241,7 +242,7 @@ var inquirerFunc = function (args, _a) {
|
|
|
241
242
|
}
|
|
242
243
|
});
|
|
243
244
|
}); })];
|
|
244
|
-
case 1: return [2,
|
|
245
|
+
case 1: return [2, _k.sent()];
|
|
245
246
|
}
|
|
246
247
|
});
|
|
247
248
|
});
|
package/package.json
CHANGED
|
@@ -1,62 +1,122 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
exports.__esModule = true;
|
|
17
|
-
exports.
|
|
6
|
+
exports.getDeviceConf = exports.DeviceScreenType = void 0;
|
|
18
7
|
var lodash_1 = require("lodash");
|
|
19
|
-
var
|
|
8
|
+
var path_1 = __importDefault(require("path"));
|
|
9
|
+
var os_1 = __importDefault(require("os"));
|
|
10
|
+
var fs_1 = __importDefault(require("fs"));
|
|
11
|
+
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
20
12
|
var tools_1 = require("../tools/tools");
|
|
13
|
+
var LOCAL_CACHE_DEVICE_PATH = path_1["default"].resolve(os_1["default"].homedir(), ".zepp/.zeus_devices");
|
|
21
14
|
var DeviceScreenType;
|
|
22
15
|
(function (DeviceScreenType) {
|
|
23
16
|
DeviceScreenType["R"] = "r";
|
|
24
17
|
DeviceScreenType["S"] = "s";
|
|
25
18
|
DeviceScreenType["B"] = "b";
|
|
26
19
|
})(DeviceScreenType = exports.DeviceScreenType || (exports.DeviceScreenType = {}));
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
var shapeMap = {
|
|
21
|
+
square: DeviceScreenType.S,
|
|
22
|
+
round: DeviceScreenType.R,
|
|
23
|
+
bar: DeviceScreenType.B
|
|
24
|
+
};
|
|
25
|
+
function getDeviceInfo() {
|
|
26
|
+
var localContent = {};
|
|
27
|
+
if (fs_1["default"].existsSync(LOCAL_CACHE_DEVICE_PATH)) {
|
|
28
|
+
try {
|
|
29
|
+
localContent = fs_extra_1["default"].readJsonSync(LOCAL_CACHE_DEVICE_PATH);
|
|
30
|
+
}
|
|
31
|
+
catch (_e) { }
|
|
35
32
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
var deviceList = (0, lodash_1.get)(localContent, 'devices', []);
|
|
34
|
+
var deviceGroup = (0, lodash_1.groupBy)(deviceList, 'productName');
|
|
35
|
+
var deviceInfo = {};
|
|
36
|
+
Object.values(deviceGroup).forEach(function (devices) {
|
|
37
|
+
var _a;
|
|
38
|
+
var info = {
|
|
39
|
+
deviceName: '',
|
|
40
|
+
platforms: [],
|
|
41
|
+
screen: {
|
|
42
|
+
type: DeviceScreenType.R,
|
|
43
|
+
width: 0,
|
|
44
|
+
height: 0
|
|
45
|
+
},
|
|
46
|
+
apiLevelLimit: {
|
|
47
|
+
min: '1.0.0'
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var deviceInnerName = devices.reduce(function (acc, cur) {
|
|
51
|
+
!info.deviceName && (info.deviceName = cur.productName);
|
|
52
|
+
var screenType = (0, lodash_1.get)(shapeMap, (0, lodash_1.get)(cur, 'value.shape'));
|
|
53
|
+
var _a = (0, lodash_1.get)(cur, 'value.screen.size', '').split('*'), width = _a[0], height = _a[1];
|
|
54
|
+
if (screenType) {
|
|
55
|
+
info.screen.type = screenType;
|
|
56
|
+
}
|
|
57
|
+
if (width && height) {
|
|
58
|
+
info.screen.width = Number(width);
|
|
59
|
+
info.screen.height = Number(height);
|
|
60
|
+
}
|
|
61
|
+
info.platforms.push({
|
|
62
|
+
name: cur.code,
|
|
63
|
+
deviceSource: cur.deviceSource
|
|
64
|
+
});
|
|
65
|
+
Object.assign(info.apiLevelLimit, {
|
|
66
|
+
min: (0, lodash_1.get)(cur, 'value.os.apiLevelLimitMin', '1.0.0'),
|
|
67
|
+
max: (0, lodash_1.get)(cur, 'value.os.version', '')
|
|
68
|
+
});
|
|
69
|
+
return cur.code.length < acc.length ? cur.code : acc;
|
|
70
|
+
}, devices[0].code);
|
|
71
|
+
var lowerName = (0, lodash_1.toLower)(deviceInnerName.replace(/[^a-zA-Z]/g, ''));
|
|
72
|
+
lowerName && Object.assign(deviceInfo, (_a = {},
|
|
73
|
+
_a[lowerName] = info,
|
|
74
|
+
_a));
|
|
75
|
+
});
|
|
76
|
+
return deviceInfo;
|
|
77
|
+
}
|
|
78
|
+
var getDeviceConf = function () {
|
|
79
|
+
var deviceTargets = getDeviceInfo();
|
|
80
|
+
var OSV2Devices = Object.values(deviceTargets).reduce(function (targetDevices, target) {
|
|
81
|
+
var _a = target.platforms, platforms = _a === void 0 ? [] : _a, _b = target.apiLevelLimit, apiLevelLimit = _b === void 0 ? {} : _b;
|
|
82
|
+
var min = apiLevelLimit.min, max = apiLevelLimit.max;
|
|
83
|
+
if (!(0, lodash_1.isEmpty)(platforms) &&
|
|
84
|
+
(0, tools_1.compareVersion)(min || '1.0.0', '2.0.0') >= 0 &&
|
|
85
|
+
max && (0, tools_1.compareVersion)(max, '2.0.0') <= 0) {
|
|
86
|
+
targetDevices.push.apply(targetDevices, platforms.reduce(function (list, o) { return (0, lodash_1.compact)(list.concat([o.deviceSource])); }, []));
|
|
87
|
+
}
|
|
88
|
+
return targetDevices;
|
|
89
|
+
}, []);
|
|
90
|
+
var OSV2DeviceTargetNames = Object.keys(deviceTargets).reduce(function (targetNames, target) {
|
|
91
|
+
var flag = true;
|
|
92
|
+
var _a = deviceTargets[target].platforms, platforms = _a === void 0 ? [] : _a;
|
|
93
|
+
if (platforms && platforms.length) {
|
|
94
|
+
platforms.forEach(function (_a) {
|
|
95
|
+
var deviceSource = _a.deviceSource;
|
|
96
|
+
if (!OSV2Devices.includes(deviceSource)) {
|
|
97
|
+
flag = false;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
flag = false;
|
|
103
|
+
}
|
|
104
|
+
flag && targetNames.push(target);
|
|
105
|
+
return targetNames;
|
|
106
|
+
}, []);
|
|
107
|
+
var deviceInternalCodeName = Object.keys(deviceTargets).reduce(function (deviceSources, target) {
|
|
108
|
+
var _a = deviceTargets[target].platforms, platforms = _a === void 0 ? [] : _a;
|
|
42
109
|
platforms.forEach(function (_a) {
|
|
43
110
|
var deviceSource = _a.deviceSource;
|
|
44
|
-
|
|
45
|
-
flag = false;
|
|
46
|
-
}
|
|
111
|
+
deviceSource && (deviceSources[deviceSource] = target);
|
|
47
112
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var deviceSource = _a.deviceSource;
|
|
59
|
-
deviceSource && (deviceSources[deviceSource] = target);
|
|
60
|
-
});
|
|
61
|
-
return deviceSources;
|
|
62
|
-
}, {});
|
|
113
|
+
return deviceSources;
|
|
114
|
+
}, {});
|
|
115
|
+
return {
|
|
116
|
+
deviceTargets: deviceTargets,
|
|
117
|
+
OSV2Devices: OSV2Devices,
|
|
118
|
+
OSV2DeviceTargetNames: OSV2DeviceTargetNames,
|
|
119
|
+
deviceInternalCodeName: deviceInternalCodeName
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
exports.getDeviceConf = getDeviceConf;
|
|
@@ -57,11 +57,12 @@ var path_1 = require("path");
|
|
|
57
57
|
var fs_1 = __importDefault(require("fs"));
|
|
58
58
|
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
59
59
|
var index_1 = require("../../index");
|
|
60
|
-
var TemplateCopyType = index_1.config.TemplateCopyType,
|
|
60
|
+
var TemplateCopyType = index_1.config.TemplateCopyType, getDeviceConf = index_1.config.getDeviceConf;
|
|
61
61
|
var createLocalApp = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
62
|
-
var workDir, templateInfo, withAppSide, withSettings, buildTargets, appType, shapeOfPlatform, appJsonPath, appJson, appID, defaultTarget, targets, shapes, needDelShapeConfig, defaultAssetsPath_1;
|
|
62
|
+
var workDir, templateInfo, withAppSide, withSettings, buildTargets, appType, shapeOfPlatform, deviceTargets, appJsonPath, appJson, appID, defaultTarget, targets, shapes, needDelShapeConfig, defaultAssetsPath_1;
|
|
63
63
|
return __generator(this, function (_a) {
|
|
64
64
|
workDir = args.workDir, templateInfo = args.templateInfo, withAppSide = args.withAppSide, withSettings = args.withSettings, buildTargets = args.buildTargets, appType = args.appType, shapeOfPlatform = args.shapeOfPlatform;
|
|
65
|
+
deviceTargets = getDeviceConf().deviceTargets;
|
|
65
66
|
fs_extra_1["default"].copySync(templateInfo.path, workDir);
|
|
66
67
|
if (fs_extra_1["default"].existsSync((0, path_1.resolve)(workDir, "./_package.json"))) {
|
|
67
68
|
fs_1["default"].renameSync((0, path_1.resolve)(workDir, "./_package.json"), (0, path_1.resolve)(workDir, "./package.json"));
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
exports.__esModule = true;
|
|
29
|
+
exports.fetchDevicesWrap = exports.fetchDevices = exports.DeviceScreenType = void 0;
|
|
30
|
+
var axios_1 = __importDefault(require("axios"));
|
|
31
|
+
var os = __importStar(require("os"));
|
|
32
|
+
var path = __importStar(require("path"));
|
|
33
|
+
var fs = __importStar(require("fs"));
|
|
34
|
+
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
35
|
+
var lodash_1 = require("lodash");
|
|
36
|
+
var LOCAL_CACHE_DEVICE_PATH = path.resolve(os.homedir(), ".zepp/.zeus_devices");
|
|
37
|
+
var serverPath = 'https://upload-cdn.zepp.com/zeppos/devkit/zeus/devices.json';
|
|
38
|
+
var DeviceScreenType;
|
|
39
|
+
(function (DeviceScreenType) {
|
|
40
|
+
DeviceScreenType["R"] = "r";
|
|
41
|
+
DeviceScreenType["S"] = "s";
|
|
42
|
+
DeviceScreenType["B"] = "b";
|
|
43
|
+
})(DeviceScreenType = exports.DeviceScreenType || (exports.DeviceScreenType = {}));
|
|
44
|
+
var fetchDevices = function () {
|
|
45
|
+
var localContent = {};
|
|
46
|
+
if (fs.existsSync(LOCAL_CACHE_DEVICE_PATH)) {
|
|
47
|
+
try {
|
|
48
|
+
localContent = fs_extra_1["default"].readJsonSync(LOCAL_CACHE_DEVICE_PATH);
|
|
49
|
+
}
|
|
50
|
+
catch (_e) { }
|
|
51
|
+
}
|
|
52
|
+
var now = Date.now().valueOf();
|
|
53
|
+
return new Promise(function (resolve) {
|
|
54
|
+
if (!((0, lodash_1.get)(localContent, 'expiredTime') > now)) {
|
|
55
|
+
axios_1["default"].get(serverPath).then(function (res) {
|
|
56
|
+
if (res.status === 200) {
|
|
57
|
+
var data = res.data;
|
|
58
|
+
if (!(0, lodash_1.isEmpty)(data)) {
|
|
59
|
+
fs_extra_1["default"].writeJsonSync(LOCAL_CACHE_DEVICE_PATH, {
|
|
60
|
+
devices: data,
|
|
61
|
+
expiredTime: now + 2 * 60 * 60 * 1000
|
|
62
|
+
});
|
|
63
|
+
resolve({});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
})["catch"](function (e) {
|
|
67
|
+
console.log(e);
|
|
68
|
+
resolve({});
|
|
69
|
+
process.exit(1);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
resolve({});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
exports.fetchDevices = fetchDevices;
|
|
78
|
+
var fetchDevicesWrap = function (func) {
|
|
79
|
+
return function () {
|
|
80
|
+
var args = [];
|
|
81
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
82
|
+
args[_i] = arguments[_i];
|
|
83
|
+
}
|
|
84
|
+
return (0, exports.fetchDevices)().then(function () { return func.apply(void 0, args); });
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
exports.fetchDevicesWrap = fetchDevicesWrap;
|
|
@@ -18,4 +18,5 @@ __exportStar(require("./login"), exports);
|
|
|
18
18
|
__exportStar(require("./config"), exports);
|
|
19
19
|
__exportStar(require("./status"), exports);
|
|
20
20
|
__exportStar(require("./build"), exports);
|
|
21
|
+
__exportStar(require("./fetchDevices"), exports);
|
|
21
22
|
__exportStar(require("./create/index"), exports);
|
package/private-modules/zeppos-app-utils/dist/public/template/os1.0/app/fetch-api/app-side/index.js
CHANGED
|
@@ -2,21 +2,6 @@ import { MessageBuilder } from "../shared/message";
|
|
|
2
2
|
|
|
3
3
|
const messageBuilder = new MessageBuilder();
|
|
4
4
|
|
|
5
|
-
// Simulating an asynchronous network request using Promise
|
|
6
|
-
async function mockAPI() {
|
|
7
|
-
return new Promise((resolve, reject) => {
|
|
8
|
-
setTimeout(() => {
|
|
9
|
-
resolve({
|
|
10
|
-
body: {
|
|
11
|
-
data: {
|
|
12
|
-
text: "HELLO ZEPPOS",
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
}, 1000);
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
|
|
20
5
|
async function fetchData(ctx) {
|
|
21
6
|
try {
|
|
22
7
|
// Requesting network data using the fetch API
|
|
@@ -38,12 +23,15 @@ async function fetchData(ctx) {
|
|
|
38
23
|
// })
|
|
39
24
|
// })
|
|
40
25
|
|
|
41
|
-
// A network request is simulated here
|
|
42
|
-
const res = await
|
|
26
|
+
// A network request is simulated here, Reference documentation: https://jsonplaceholder.typicode.com/
|
|
27
|
+
const res = await fetch({
|
|
28
|
+
url: 'https://jsonplaceholder.typicode.com/todos/1',
|
|
29
|
+
method: 'GET'
|
|
30
|
+
})
|
|
43
31
|
const resBody = typeof res.body === 'string' ? JSON.parse(res.body) : res.body
|
|
44
32
|
|
|
45
33
|
ctx.response({
|
|
46
|
-
data: { result: resBody
|
|
34
|
+
data: { result: resBody },
|
|
47
35
|
})
|
|
48
36
|
|
|
49
37
|
} catch (error) {
|
package/private-modules/zeppos-app-utils/dist/public/template/os1.0/app/fetch-api/pages/index.js
CHANGED
|
@@ -34,19 +34,19 @@ Page({
|
|
|
34
34
|
.then((data) => {
|
|
35
35
|
logger.log("receive data");
|
|
36
36
|
const { result = {} } = data;
|
|
37
|
-
const
|
|
37
|
+
const text = JSON.stringify(result);
|
|
38
38
|
|
|
39
39
|
hmUI.createWidget(hmUI.widget.TEXT, {
|
|
40
|
-
x: px(
|
|
41
|
-
y: px(
|
|
42
|
-
w: px(
|
|
43
|
-
h: px(
|
|
40
|
+
x: px(56),
|
|
41
|
+
y: px(74),
|
|
42
|
+
w: DEVICE_WIDTH - 2 * px(56),
|
|
43
|
+
h: px(200),
|
|
44
44
|
color: 0xffffff,
|
|
45
45
|
text_size: px(36),
|
|
46
46
|
align_h: hmUI.align.CENTER_H,
|
|
47
47
|
align_v: hmUI.align.CENTER_V,
|
|
48
48
|
text_style: hmUI.text_style.NONE,
|
|
49
|
-
text,
|
|
49
|
+
text: text,
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
},
|
package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/app-side/index.js
CHANGED
|
@@ -2,21 +2,6 @@ import { MessageBuilder } from "../shared/message-side";
|
|
|
2
2
|
|
|
3
3
|
const messageBuilder = new MessageBuilder();
|
|
4
4
|
|
|
5
|
-
// Simulating an asynchronous network request using Promise
|
|
6
|
-
async function mockAPI() {
|
|
7
|
-
return new Promise((resolve, reject) => {
|
|
8
|
-
setTimeout(() => {
|
|
9
|
-
resolve({
|
|
10
|
-
body: {
|
|
11
|
-
data: {
|
|
12
|
-
text: "HELLO ZEPPOS",
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
}, 1000);
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
|
|
20
5
|
async function fetchData(ctx) {
|
|
21
6
|
try {
|
|
22
7
|
// Requesting network data using the fetch API
|
|
@@ -38,12 +23,15 @@ async function fetchData(ctx) {
|
|
|
38
23
|
// })
|
|
39
24
|
// })
|
|
40
25
|
|
|
41
|
-
// A network request is simulated here
|
|
42
|
-
const res = await
|
|
26
|
+
// A network request is simulated here, Reference documentation: https://jsonplaceholder.typicode.com/
|
|
27
|
+
const res = await fetch({
|
|
28
|
+
url: 'https://jsonplaceholder.typicode.com/todos/1',
|
|
29
|
+
method: 'GET'
|
|
30
|
+
})
|
|
43
31
|
const resBody = typeof res.body === 'string' ? JSON.parse(res.body) : res.body
|
|
44
32
|
|
|
45
33
|
ctx.response({
|
|
46
|
-
data: { result: resBody
|
|
34
|
+
data: { result: resBody },
|
|
47
35
|
})
|
|
48
36
|
|
|
49
37
|
} catch (error) {
|
package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/pages/index.js
CHANGED
|
@@ -36,13 +36,13 @@ Page({
|
|
|
36
36
|
.then((data) => {
|
|
37
37
|
logger.log("receive data");
|
|
38
38
|
const { result = {} } = data;
|
|
39
|
-
const
|
|
39
|
+
const text = JSON.stringify(result);
|
|
40
40
|
|
|
41
41
|
createWidget(widget.TEXT, {
|
|
42
|
-
x: px(
|
|
43
|
-
y: px(
|
|
44
|
-
w: DEVICE_WIDTH - 2 * px(
|
|
45
|
-
h: px(
|
|
42
|
+
x: px(56),
|
|
43
|
+
y: px(74),
|
|
44
|
+
w: DEVICE_WIDTH - 2 * px(56),
|
|
45
|
+
h: px(200),
|
|
46
46
|
color: 0xffffff,
|
|
47
47
|
text_size: px(36),
|
|
48
48
|
align_h: align.CENTER_H,
|
|
@@ -52,5 +52,5 @@ Page({
|
|
|
52
52
|
})
|
|
53
53
|
.catch((res) => { });
|
|
54
54
|
})
|
|
55
|
-
|
|
55
|
+
}
|
|
56
56
|
})
|
package/private-modules/zeppos-app-utils/dist/public/template/os3.0/app/fetch-api/app-side/index.js
CHANGED
|
@@ -1,37 +1,5 @@
|
|
|
1
1
|
import { BaseSideService } from "@zeppos/zml/base-side";
|
|
2
2
|
|
|
3
|
-
const padStart = (str, maxLength, fillStr = "0") => {
|
|
4
|
-
return str.toString().padStart(maxLength, fillStr);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const formatDate = (date = new Date()) => {
|
|
8
|
-
const y = date.getFullYear();
|
|
9
|
-
const m = date.getMonth() + 1;
|
|
10
|
-
const d = date.getDate();
|
|
11
|
-
const h = date.getHours();
|
|
12
|
-
const mm = date.getMinutes();
|
|
13
|
-
const s = date.getSeconds();
|
|
14
|
-
|
|
15
|
-
return `${y}-${padStart(m, 2)}-${padStart(d, 2)} ${padStart(h, 2)}:${padStart(
|
|
16
|
-
mm,
|
|
17
|
-
2
|
|
18
|
-
)}:${padStart(s, 2)}`;
|
|
19
|
-
};
|
|
20
|
-
// Simulating an asynchronous network request using Promise
|
|
21
|
-
async function mockAPI() {
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
setTimeout(() => {
|
|
24
|
-
resolve({
|
|
25
|
-
body: {
|
|
26
|
-
data: {
|
|
27
|
-
text: "HELLO ZEPPOS: " + formatDate(),
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
}, 1000);
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
3
|
async function fetchData(res) {
|
|
36
4
|
try {
|
|
37
5
|
// Requesting network data using the fetch API
|
|
@@ -53,11 +21,15 @@ async function fetchData(res) {
|
|
|
53
21
|
// })
|
|
54
22
|
// })
|
|
55
23
|
|
|
56
|
-
// A network request is simulated here
|
|
57
|
-
const
|
|
24
|
+
// A network request is simulated here, Reference documentation: https://jsonplaceholder.typicode.com/
|
|
25
|
+
const response = await fetch({
|
|
26
|
+
url: 'https://jsonplaceholder.typicode.com/todos/1',
|
|
27
|
+
method: 'GET'
|
|
28
|
+
})
|
|
29
|
+
const resBody = typeof response.body === 'string' ? JSON.parse(response.body) : response.body
|
|
58
30
|
|
|
59
31
|
res(null, {
|
|
60
|
-
result:
|
|
32
|
+
result: resBody,
|
|
61
33
|
});
|
|
62
34
|
} catch (error) {
|
|
63
35
|
res(null, {
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
import { DEVICE_WIDTH } from "../utils/config/device";
|
|
9
9
|
|
|
10
10
|
export const FETCH_BUTTON = {
|
|
11
|
-
x: (DEVICE_WIDTH - px(
|
|
12
|
-
y: px(
|
|
13
|
-
w: px(
|
|
14
|
-
h: px(
|
|
11
|
+
x: (DEVICE_WIDTH - px(360)) / 2,
|
|
12
|
+
y: px(300),
|
|
13
|
+
w: px(360),
|
|
14
|
+
h: px(80),
|
|
15
15
|
text_size: px(36),
|
|
16
16
|
radius: px(12),
|
|
17
17
|
normal_color: DEFAULT_COLOR,
|
|
@@ -20,10 +20,10 @@ export const FETCH_BUTTON = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export const FETCH_RESULT_TEXT = {
|
|
23
|
-
x: px(
|
|
24
|
-
y: px(
|
|
25
|
-
w: DEVICE_WIDTH - 2 * px(
|
|
26
|
-
h: px(
|
|
23
|
+
x: px(56),
|
|
24
|
+
y: px(74),
|
|
25
|
+
w: DEVICE_WIDTH - 2 * px(56),
|
|
26
|
+
h: px(200),
|
|
27
27
|
color: 0xffffff,
|
|
28
28
|
text_size: px(36),
|
|
29
29
|
align_h: hmUI.align.CENTER_H,
|
|
@@ -67,9 +67,9 @@ var yargs_parser_1 = __importDefault(require("yargs-parser"));
|
|
|
67
67
|
var path = __importStar(require("path"));
|
|
68
68
|
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
69
69
|
var index_1 = require("../index");
|
|
70
|
-
var deviceInternalCodeName = index_1.config.deviceInternalCodeName;
|
|
71
70
|
var fs_1 = require("fs");
|
|
72
71
|
var rd = __importStar(require("rd"));
|
|
72
|
+
var getDeviceConf = index_1.config.getDeviceConf;
|
|
73
73
|
var parserZeusCommand = function (command) {
|
|
74
74
|
return (0, yargs_parser_1["default"])(command.replace(/^(zeus )/, ''));
|
|
75
75
|
};
|
|
@@ -88,6 +88,7 @@ var getDeviceInfoFromAppJson = function (root) {
|
|
|
88
88
|
var deviceSourceArr = platforms.map(function (item) {
|
|
89
89
|
return item.deviceSource;
|
|
90
90
|
});
|
|
91
|
+
var deviceInternalCodeName = getDeviceConf().deviceInternalCodeName;
|
|
91
92
|
return {
|
|
92
93
|
deviceSource: deviceSource,
|
|
93
94
|
appId: appId,
|