@zeppos/zeus-cli 1.7.10 → 1.8.1
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 +64 -23
- package/bin/post-command.js +1 -1
- package/index.js +1 -1
- package/modules/bridge.js +43 -33
- package/modules/build.js +72 -36
- package/modules/create.js +213 -216
- package/modules/help.js +21 -11
- package/modules/prune.js +1 -1
- package/modules/run.js +29 -17
- package/modules/version.js +5 -6
- package/modules/yargsCmdBuilders.js +3 -3
- package/package.json +6 -4
- package/private-modules/zeppos-app-utils/dist/api/index.js +18 -20
- package/private-modules/zeppos-app-utils/dist/config/device.js +19 -17
- package/private-modules/zeppos-app-utils/dist/config/index.js +1 -1
- package/private-modules/zeppos-app-utils/dist/config/project.js +14 -14
- package/private-modules/zeppos-app-utils/dist/hm-analytics.js +14 -13
- package/private-modules/zeppos-app-utils/dist/index.js +18 -8
- package/private-modules/zeppos-app-utils/dist/logger/index.js +5 -5
- package/private-modules/zeppos-app-utils/dist/logger/my-logger.js +1 -1
- package/private-modules/zeppos-app-utils/dist/modules/build.js +73 -46
- package/private-modules/zeppos-app-utils/dist/modules/config.js +14 -12
- package/private-modules/zeppos-app-utils/dist/modules/create/index.js +71 -39
- package/private-modules/zeppos-app-utils/dist/modules/create/local-app.js +82 -66
- package/private-modules/zeppos-app-utils/dist/modules/create/yeoman-app.js +6 -6
- package/private-modules/zeppos-app-utils/dist/modules/fetchDevices.js +72 -39
- package/private-modules/zeppos-app-utils/dist/modules/index.js +1 -1
- package/private-modules/zeppos-app-utils/dist/modules/login.js +16 -15
- package/private-modules/zeppos-app-utils/dist/modules/open/index.js +62 -50
- package/private-modules/zeppos-app-utils/dist/modules/prune.js +5 -5
- package/private-modules/zeppos-app-utils/dist/modules/status.js +12 -12
- package/private-modules/zeppos-app-utils/dist/simulator.js +3 -3
- package/private-modules/zeppos-app-utils/dist/storage/index.js +7 -7
- package/private-modules/zeppos-app-utils/dist/tools/index.js +24 -14
- package/private-modules/zeppos-app-utils/dist/tools/tools.js +3 -3
- package/private-modules/zeppos-app-utils/dist/websocket.js +9 -9
- package/private-modules/zeppos-app-utils/package.json +2 -1
- package/utils/pre-check.js +52 -30
- package/utils/tools.js +4 -4
package/bin/main.js
CHANGED
|
@@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
13
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
14
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
15
|
-
return g =
|
|
14
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
15
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
16
16
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
17
17
|
function step(op) {
|
|
18
18
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -40,16 +40,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
40
40
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
41
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
42
|
};
|
|
43
|
-
exports
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.cmdCache = void 0;
|
|
44
45
|
var lodash_1 = __importDefault(require("lodash"));
|
|
45
46
|
var yargs_1 = __importDefault(require("yargs"));
|
|
46
47
|
require("./post-command");
|
|
47
|
-
var hideBin = require('yargs/helpers').hideBin;
|
|
48
|
-
var argv = hideBin(process.argv);
|
|
49
48
|
var pre_check_1 = require("../utils/pre-check");
|
|
50
49
|
var index_1 = require("../index");
|
|
51
50
|
var zeppos_app_utils_1 = require("zeppos-app-utils");
|
|
52
51
|
var tools_1 = require("../utils/tools");
|
|
52
|
+
var hideBin = require('yargs/helpers').hideBin;
|
|
53
|
+
var argv = hideBin(process.argv);
|
|
53
54
|
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
55
|
var context = {};
|
|
55
56
|
var yargsCmdBuilderFunc = function (cmdName, useProxy, yargs) {
|
|
@@ -59,6 +60,7 @@ var yargsCmdBuilderFunc = function (cmdName, useProxy, yargs) {
|
|
|
59
60
|
return index_1.yargsCmdBuilders[cmdName](yargs);
|
|
60
61
|
}
|
|
61
62
|
};
|
|
63
|
+
var yb = function (y) { return y; };
|
|
62
64
|
var fetchDevices = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
63
65
|
var zeusVer;
|
|
64
66
|
return __generator(this, function (_a) {
|
|
@@ -70,7 +72,42 @@ var fetchDevices = function () { return __awaiter(void 0, void 0, void 0, functi
|
|
|
70
72
|
}
|
|
71
73
|
});
|
|
72
74
|
}); };
|
|
73
|
-
var
|
|
75
|
+
var cmdCache = function (argv) { return __awaiter(void 0, void 0, void 0, function () {
|
|
76
|
+
var _argv, _a, command, _b, subCommand, _c, zeusVer;
|
|
77
|
+
return __generator(this, function (_d) {
|
|
78
|
+
switch (_d.label) {
|
|
79
|
+
case 0:
|
|
80
|
+
_argv = argv || { _: [], $0: 'zeus' };
|
|
81
|
+
_a = _argv._, command = _a[0], _b = _a[1], subCommand = _b === void 0 ? '' : _b;
|
|
82
|
+
if (command !== 'cache')
|
|
83
|
+
return [2];
|
|
84
|
+
if (subCommand === '') {
|
|
85
|
+
console.log('usage: zeus cache <clean|update>');
|
|
86
|
+
return [2];
|
|
87
|
+
}
|
|
88
|
+
_c = subCommand;
|
|
89
|
+
switch (_c) {
|
|
90
|
+
case 'clean': return [3, 1];
|
|
91
|
+
case 'update': return [3, 3];
|
|
92
|
+
}
|
|
93
|
+
return [3, 5];
|
|
94
|
+
case 1: return [4, (0, pre_check_1.clearDevicesCache)(true)];
|
|
95
|
+
case 2:
|
|
96
|
+
_d.sent();
|
|
97
|
+
return [3, 6];
|
|
98
|
+
case 3:
|
|
99
|
+
zeusVer = (0, index_1.zeusCurrentVersion)();
|
|
100
|
+
return [4, devicesData(zeusVer, true)];
|
|
101
|
+
case 4:
|
|
102
|
+
_d.sent();
|
|
103
|
+
return [3, 6];
|
|
104
|
+
case 5: return [2];
|
|
105
|
+
case 6: return [2];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}); };
|
|
109
|
+
exports.cmdCache = cmdCache;
|
|
110
|
+
var proxy = function (argv) { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
111
|
var res;
|
|
75
112
|
return __generator(this, function (_a) {
|
|
76
113
|
switch (_a.label) {
|
|
@@ -80,35 +117,39 @@ var proxy = function (args) { return __awaiter(void 0, void 0, void 0, function
|
|
|
80
117
|
return [4, (0, pre_check_1.checkVersion)()];
|
|
81
118
|
case 2:
|
|
82
119
|
_a.sent();
|
|
83
|
-
return [4, (0, pre_check_1.initVariable)(
|
|
120
|
+
return [4, (0, pre_check_1.initVariable)(argv)];
|
|
84
121
|
case 3:
|
|
85
122
|
res = _a.sent();
|
|
86
123
|
Object.assign(context, res);
|
|
87
|
-
(0, zeppos_app_utils_1.HM_Analytics)("ZEPP_CLI_".concat(lodash_1
|
|
124
|
+
(0, zeppos_app_utils_1.HM_Analytics)("ZEPP_CLI_".concat(lodash_1.default.toUpper(lodash_1.default.get(argv, '_[0]')), "_C"));
|
|
88
125
|
return [2];
|
|
89
126
|
}
|
|
90
127
|
});
|
|
91
128
|
}); };
|
|
92
129
|
(0, zeppos_app_utils_1.HM_Analytics)('ZEPP_CLI_V');
|
|
93
|
-
yargs_1
|
|
130
|
+
yargs_1.default
|
|
131
|
+
.usage("Usage: ".concat(process.env.CMD_NAME, " <command> [args?]"))
|
|
94
132
|
.demandCommand(1, 'A command is required. Pass --help to see all available commands and options.')
|
|
95
133
|
.recommendCommands()
|
|
96
134
|
.help()
|
|
97
135
|
.version(false)
|
|
98
136
|
.version((0, index_1.version)())
|
|
99
|
-
.alias('h', 'help')
|
|
100
|
-
.
|
|
101
|
-
.
|
|
102
|
-
.
|
|
103
|
-
.
|
|
104
|
-
.command('login', 'Login to your account.', proxy, login)
|
|
105
|
-
.command('logout', 'Sign out of your account.', proxy, logout)
|
|
106
|
-
.command('
|
|
107
|
-
.command('
|
|
108
|
-
.command('
|
|
109
|
-
.command('
|
|
110
|
-
.command('
|
|
111
|
-
.command('
|
|
112
|
-
.command('
|
|
137
|
+
.alias('h', 'help')
|
|
138
|
+
.describe('help', 'Display help information.')
|
|
139
|
+
.alias('v', 'version')
|
|
140
|
+
.describe('version', 'Display version number.')
|
|
141
|
+
.group(['help', 'version'], 'Base Options')
|
|
142
|
+
.command('login', 'Login to your account.', yb, (0, tools_1.seriesExecTasks)([proxy, login]))
|
|
143
|
+
.command('logout', 'Sign out of your account.', yb, (0, tools_1.seriesExecTasks)([proxy, logout]))
|
|
144
|
+
.command('init', 'Init a new project in current directory.', yb, (0, tools_1.seriesExecTasks)([proxy, fetchDevices, index_1.create]))
|
|
145
|
+
.command('create <projectName>', 'Named the <projectName> project and add to the current directory.', yb, (0, tools_1.seriesExecTasks)([proxy, fetchDevices, index_1.create]))
|
|
146
|
+
.command('dev', 'Run this project in development mode. Use "zeus dev -h" to see more information', yargsCmdBuilderFunc.bind(null, 'dev', true), (0, tools_1.seriesExecTasks)([proxy, tools_1.isProjectRootDir, fetchDevices, index_1.run]))
|
|
147
|
+
.command('preview', 'Preview this project in your device.', yb, (0, tools_1.seriesExecTasks)([proxy, tools_1.isProjectRootDir, fetchDevices, index_1.buildPreview]))
|
|
148
|
+
.command('build', 'Build this project for production.', yb, (0, tools_1.seriesExecTasks)([proxy, tools_1.isProjectRootDir, fetchDevices, index_1.buildProd]))
|
|
149
|
+
.command('prune', 'Prune the intermediate product in the build artifacts.', yb, (0, tools_1.seriesExecTasks)([proxy, tools_1.isProjectRootDir, index_1.prune]))
|
|
150
|
+
.command('status', 'View information such as login and emulator connection status.', yb, (0, tools_1.seriesExecTasks)([proxy, status]))
|
|
151
|
+
.command('bridge', "Connect the online App or Simulator for development and debugging.", yb, (0, tools_1.seriesExecTasks)([proxy, tools_1.isProjectRootDir, fetchDevices, index_1.bridge]))
|
|
152
|
+
.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]", yb, (0, tools_1.seriesExecTasks)([proxy, fetchDevices, modulesConfig]))
|
|
153
|
+
.command('cache', 'Clean or Update the Device caches', yb, (0, tools_1.seriesExecTasks)([proxy, exports.cmdCache]))
|
|
113
154
|
.epilogue('For more information, see https://docs.zepp.com/')
|
|
114
155
|
.parse(argv, context);
|
package/bin/post-command.js
CHANGED
package/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./modules/help"), exports);
|
|
18
18
|
__exportStar(require("./modules/run"), exports);
|
|
19
19
|
__exportStar(require("./modules/build"), exports);
|
package/modules/bridge.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -32,8 +42,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
42
|
});
|
|
33
43
|
};
|
|
34
44
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g =
|
|
45
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
47
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
48
|
function step(op) {
|
|
39
49
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -61,7 +71,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
61
71
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
72
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
73
|
};
|
|
64
|
-
exports
|
|
74
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
75
|
exports.bridge = void 0;
|
|
66
76
|
var chalk_1 = __importDefault(require("chalk"));
|
|
67
77
|
var path = __importStar(require("path"));
|
|
@@ -81,7 +91,7 @@ var connectDevice = function (vorpal) { return __awaiter(void 0, void 0, void 0,
|
|
|
81
91
|
optionalDeviceArr = Object.keys(debugConnectedDevice);
|
|
82
92
|
len = optionalDeviceArr.length;
|
|
83
93
|
if (!(len === 0)) return [3, 1];
|
|
84
|
-
vorpal.log(chalk_1
|
|
94
|
+
vorpal.log(chalk_1.default.yellow('No connectable online App or Simulator.'));
|
|
85
95
|
return [3, 4];
|
|
86
96
|
case 1:
|
|
87
97
|
clientId_1 = debugConnectedDevice[optionalDeviceArr[0]];
|
|
@@ -91,7 +101,7 @@ var connectDevice = function (vorpal) { return __awaiter(void 0, void 0, void 0,
|
|
|
91
101
|
name: 'choiredDevice',
|
|
92
102
|
type: 'list',
|
|
93
103
|
choices: optionalDeviceArr,
|
|
94
|
-
message: 'Which online target would you like to connect?'
|
|
104
|
+
message: 'Which online target would you like to connect?',
|
|
95
105
|
}, function (result) {
|
|
96
106
|
clientId_1 = debugConnectedDevice[result.choiredDevice];
|
|
97
107
|
choiredDevice = result.choiredDevice;
|
|
@@ -113,15 +123,11 @@ var connectWSCB = function () {
|
|
|
113
123
|
var vorpal = require('vorpal')();
|
|
114
124
|
vorpal.find('help').hidden();
|
|
115
125
|
vorpal.find('exit').remove();
|
|
116
|
-
vorpal.command('exit', 'Exits application.')
|
|
117
|
-
.action(function () {
|
|
126
|
+
vorpal.command('exit', 'Exits application.').action(function () {
|
|
118
127
|
process.exit(0);
|
|
119
128
|
});
|
|
120
|
-
vorpal
|
|
121
|
-
|
|
122
|
-
.show();
|
|
123
|
-
vorpal["catch"]('[words...]', 'Catches incorrect commands.')
|
|
124
|
-
.action(function (args, cb) {
|
|
129
|
+
vorpal.delimiter('bridge$').show();
|
|
130
|
+
vorpal.catch('[words...]', 'Catches incorrect commands.').action(function (args, cb) {
|
|
125
131
|
vorpal.log(" - '".concat(args.words.join(' '), "' is not a valid command.Enter 'help' to view Commands."));
|
|
126
132
|
cb();
|
|
127
133
|
});
|
|
@@ -130,17 +136,21 @@ var connectWSCB = function () {
|
|
|
130
136
|
.option('--anchovies')
|
|
131
137
|
.action(function (args, cb) { return __awaiter(void 0, void 0, void 0, function () {
|
|
132
138
|
return __generator(this, function (_a) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
switch (_a.label) {
|
|
140
|
+
case 0: return [4, connectDevice(vorpal)];
|
|
141
|
+
case 1:
|
|
142
|
+
_a.sent();
|
|
143
|
+
(0, zeppos_app_utils_2.HM_Analytics)("ZEPP_CLI_BRIDGE_CONNECT_C");
|
|
144
|
+
cb();
|
|
145
|
+
return [2];
|
|
146
|
+
}
|
|
137
147
|
});
|
|
138
148
|
}); });
|
|
139
149
|
vorpal
|
|
140
150
|
.command('install', 'Install applications or watch faces.')
|
|
141
151
|
.option('-t, --target "<target>"', 'Setting the installation target')
|
|
142
152
|
.types({
|
|
143
|
-
string: ['t', 'target']
|
|
153
|
+
string: ['t', 'target'],
|
|
144
154
|
})
|
|
145
155
|
.action(function (args, cb) { return __awaiter(void 0, void 0, void 0, function () {
|
|
146
156
|
var target;
|
|
@@ -150,14 +160,14 @@ var connectWSCB = function () {
|
|
|
150
160
|
case 0:
|
|
151
161
|
if (!hasConnectDevice) return [3, 2];
|
|
152
162
|
target = ((_a = args === null || args === void 0 ? void 0 : args.options) === null || _a === void 0 ? void 0 : _a.target) || '';
|
|
153
|
-
return [4, (0, build_1.buildPreview)({ _: ['install', "".concat(choiredDevice.toLowerCase())],
|
|
163
|
+
return [4, (0, build_1.buildPreview)({ _: ['install', "".concat(choiredDevice.toLowerCase())], $0: 'zeus', target: target }, function (params) {
|
|
154
164
|
client.sendMessage(params, { method: 'packagePush' });
|
|
155
165
|
})];
|
|
156
166
|
case 1:
|
|
157
167
|
_b.sent();
|
|
158
168
|
return [3, 3];
|
|
159
169
|
case 2:
|
|
160
|
-
vorpal.log(chalk_1
|
|
170
|
+
vorpal.log(chalk_1.default.yellow("No device is connected, please connect the device with the command width 'connect' first."));
|
|
161
171
|
_b.label = 3;
|
|
162
172
|
case 3:
|
|
163
173
|
(0, zeppos_app_utils_2.HM_Analytics)("ZEPP_CLI_BRIDGE_INSTALL_C");
|
|
@@ -173,20 +183,20 @@ var connectWSCB = function () {
|
|
|
173
183
|
return __generator(this, function (_b) {
|
|
174
184
|
if (!args.appid) {
|
|
175
185
|
if (!(0, fs_1.existsSync)('./app.json')) {
|
|
176
|
-
vorpal.log("".concat(chalk_1
|
|
186
|
+
vorpal.log("".concat(chalk_1.default.red('error'), " If the [appid] is blank, this command needs to be executed in the root of the project."));
|
|
177
187
|
}
|
|
178
188
|
else {
|
|
179
|
-
vorpal.log(chalk_1
|
|
189
|
+
vorpal.log(chalk_1.default.blue('Uninstalling...'));
|
|
180
190
|
_a = (0, zeppos_app_utils_2.getInfoFromAppJson)(path.resolve('./app.json')).app, appid = _a.appId, appName = _a.appName, appType = _a.appType;
|
|
181
191
|
client.sendMessage({ type: 'delete', appid: appid, appName: appName, appType: appType }, { method: 'sysSettingPush' });
|
|
182
192
|
}
|
|
183
193
|
}
|
|
184
194
|
else if (args.appid && typeof args.appid === 'number') {
|
|
185
|
-
vorpal.log(chalk_1
|
|
195
|
+
vorpal.log(chalk_1.default.blue('Uninstalling...'));
|
|
186
196
|
client.sendMessage({ type: 'delete', appid: args.appid }, { method: 'sysSettingPush' });
|
|
187
197
|
}
|
|
188
198
|
else if (args.appid) {
|
|
189
|
-
vorpal.log("".concat(chalk_1
|
|
199
|
+
vorpal.log("".concat(chalk_1.default.red('error'), " invalid '").concat(args.appid, "', the 'uninstall' command should be followed by appid or blank."));
|
|
190
200
|
}
|
|
191
201
|
(0, zeppos_app_utils_2.HM_Analytics)("ZEPP_CLI_BRIDGE_UNINSTALL_C");
|
|
192
202
|
cb();
|
|
@@ -198,11 +208,11 @@ var connectWSCB = function () {
|
|
|
198
208
|
.action(function (args, cb) { return __awaiter(void 0, void 0, void 0, function () {
|
|
199
209
|
return __generator(this, function (_a) {
|
|
200
210
|
if (hasConnectDevice) {
|
|
201
|
-
vorpal.log(chalk_1
|
|
211
|
+
vorpal.log(chalk_1.default.blue('Waiting...'));
|
|
202
212
|
client.sendMessage({ type: 'screenshot' }, { method: 'sysSettingPush' });
|
|
203
213
|
}
|
|
204
214
|
else {
|
|
205
|
-
vorpal.log(chalk_1
|
|
215
|
+
vorpal.log(chalk_1.default.yellow("No device is connected, please connect the device with the command width 'connect' first."));
|
|
206
216
|
}
|
|
207
217
|
(0, zeppos_app_utils_2.HM_Analytics)("ZEPP_CLI_BRIDGE_SCREENSHOT_C");
|
|
208
218
|
cb();
|
|
@@ -227,7 +237,7 @@ var bridge = function (args) { return __awaiter(void 0, void 0, void 0, function
|
|
|
227
237
|
client = new zeppos_app_utils_1.WebSocketClass({
|
|
228
238
|
url: "".concat(bridgeWebSocketURL, "?type=development&name=CLI"),
|
|
229
239
|
connectWSCB: connectWSCB,
|
|
230
|
-
disConnectWSCB: disConnectWSCB
|
|
240
|
+
disConnectWSCB: disConnectWSCB,
|
|
231
241
|
});
|
|
232
242
|
zeppos_app_utils_1.logger.log(" - Enter 'help' to view the command.");
|
|
233
243
|
return [3, 6];
|
package/modules/build.js
CHANGED
|
@@ -26,13 +26,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
26
26
|
}) : function(o, v) {
|
|
27
27
|
o["default"] = v;
|
|
28
28
|
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
36
46
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
47
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
48
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -43,8 +53,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
43
53
|
});
|
|
44
54
|
};
|
|
45
55
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g =
|
|
56
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
57
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
58
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
59
|
function step(op) {
|
|
50
60
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -69,10 +79,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
79
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
80
|
}
|
|
71
81
|
};
|
|
82
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
83
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
84
|
+
if (ar || !(i in from)) {
|
|
85
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
86
|
+
ar[i] = from[i];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
90
|
+
};
|
|
72
91
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
73
92
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
74
93
|
};
|
|
75
|
-
exports
|
|
94
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
95
|
exports.buildPreview = exports.buildProd = exports.chooseBuildPackages = exports.BuildMode = void 0;
|
|
77
96
|
var path = __importStar(require("path"));
|
|
78
97
|
var fs_1 = __importDefault(require("fs"));
|
|
@@ -86,13 +105,13 @@ var tools_1 = require("../utils/tools");
|
|
|
86
105
|
var chalk_1 = __importDefault(require("chalk"));
|
|
87
106
|
var AppType = zeppos_app_utils_1.config.AppType, getDeviceConf = zeppos_app_utils_1.config.getDeviceConf;
|
|
88
107
|
var appJsonPath = path.resolve('./app.json');
|
|
89
|
-
var appJsonContent = fs_extra_1
|
|
108
|
+
var appJsonContent = fs_extra_1.default.readJSONSync(appJsonPath, { throws: false });
|
|
90
109
|
var BuildMode;
|
|
91
110
|
(function (BuildMode) {
|
|
92
111
|
BuildMode["DEV"] = "development";
|
|
93
112
|
BuildMode["PREVIEW"] = "preview";
|
|
94
113
|
BuildMode["PROD"] = "production";
|
|
95
|
-
})(BuildMode
|
|
114
|
+
})(BuildMode || (exports.BuildMode = BuildMode = {}));
|
|
96
115
|
var isV2ApiVersion = function (appJson) {
|
|
97
116
|
var minVersion = (0, lodash_1.get)(appJson, 'runtime.apiVersion.minVersion', '');
|
|
98
117
|
var minVersionArr = minVersion.split('.');
|
|
@@ -101,7 +120,7 @@ var isV2ApiVersion = function (appJson) {
|
|
|
101
120
|
var checkAppJson = function () {
|
|
102
121
|
if (!appJsonContent) {
|
|
103
122
|
try {
|
|
104
|
-
fs_1
|
|
123
|
+
fs_1.default.accessSync(appJsonPath, fs_1.default.constants.R_OK);
|
|
105
124
|
zeppos_app_utils_1.logger.warn('Syntax error, malformed JSON in app.json file.');
|
|
106
125
|
}
|
|
107
126
|
catch (err) {
|
|
@@ -110,30 +129,38 @@ var checkAppJson = function () {
|
|
|
110
129
|
process.exit(1);
|
|
111
130
|
}
|
|
112
131
|
};
|
|
113
|
-
var inquirerPrompt = function (
|
|
114
|
-
|
|
115
|
-
|
|
132
|
+
var inquirerPrompt = function (deviceNames_1) {
|
|
133
|
+
var args_1 = [];
|
|
134
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
135
|
+
args_1[_i - 1] = arguments[_i];
|
|
136
|
+
}
|
|
137
|
+
return __awaiter(void 0, __spreadArray([deviceNames_1], args_1, true), void 0, function (deviceNames, mode) {
|
|
116
138
|
var promptParam, defaultDevice;
|
|
139
|
+
if (mode === void 0) { mode = 'development'; }
|
|
117
140
|
return __generator(this, function (_a) {
|
|
118
141
|
promptParam = {
|
|
119
142
|
name: 'device',
|
|
120
143
|
type: 'list',
|
|
121
144
|
message: 'Which device would you like to preview?',
|
|
122
|
-
choices: deviceNames
|
|
145
|
+
choices: deviceNames,
|
|
123
146
|
};
|
|
124
147
|
defaultDevice = zeppos_app_utils_1.globalStorage.get("____zeus_".concat(mode, "_device")) || '';
|
|
125
148
|
if (defaultDevice !== '') {
|
|
126
149
|
promptParam['default'] = defaultDevice;
|
|
127
150
|
}
|
|
128
|
-
return [2, inquirer_1
|
|
151
|
+
return [2, inquirer_1.default.prompt([promptParam])];
|
|
129
152
|
});
|
|
130
153
|
});
|
|
131
154
|
};
|
|
132
|
-
var chooseBuildTargetsV3Config = function (
|
|
133
|
-
|
|
134
|
-
|
|
155
|
+
var chooseBuildTargetsV3Config = function () {
|
|
156
|
+
var args_1 = [];
|
|
157
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
158
|
+
args_1[_i] = arguments[_i];
|
|
159
|
+
}
|
|
160
|
+
return __awaiter(void 0, __spreadArray([], args_1, true), void 0, function (mode, args) {
|
|
135
161
|
var target, deviceTargets, apiLevel, platforms, usefulScreenTypes, usefulDeviceSource, targetDevices, deviceNames, isValidDevice, answers, _a;
|
|
136
162
|
var _b;
|
|
163
|
+
if (mode === void 0) { mode = 'development'; }
|
|
137
164
|
return __generator(this, function (_c) {
|
|
138
165
|
switch (_c.label) {
|
|
139
166
|
case 0:
|
|
@@ -187,16 +214,20 @@ var chooseBuildTargetsV3Config = function (mode, args) {
|
|
|
187
214
|
sources: (0, lodash_1.get)(targetDevices, "[".concat(answers.device, "].platforms"), []).reduce(function (list, item) {
|
|
188
215
|
list.push(Number(item.deviceSource));
|
|
189
216
|
return (0, lodash_1.uniq)((0, lodash_1.compact)(list));
|
|
190
|
-
}, [])
|
|
217
|
+
}, []),
|
|
191
218
|
}];
|
|
192
219
|
}
|
|
193
220
|
});
|
|
194
221
|
});
|
|
195
222
|
};
|
|
196
|
-
var chooseBuildTargetsV2Config = function (
|
|
197
|
-
|
|
198
|
-
|
|
223
|
+
var chooseBuildTargetsV2Config = function () {
|
|
224
|
+
var args_1 = [];
|
|
225
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
226
|
+
args_1[_i] = arguments[_i];
|
|
227
|
+
}
|
|
228
|
+
return __awaiter(void 0, __spreadArray([], args_1, true), void 0, function (mode, args) {
|
|
199
229
|
var OSV2Devices, jsonTargets_1, unsupportedTargets_1, targets, returnRes, _a, promptTarget_1, answers;
|
|
230
|
+
if (mode === void 0) { mode = 'development'; }
|
|
200
231
|
return __generator(this, function (_b) {
|
|
201
232
|
switch (_b.label) {
|
|
202
233
|
case 0:
|
|
@@ -229,7 +260,7 @@ var chooseBuildTargetsV2Config = function (mode, args) {
|
|
|
229
260
|
case 2:
|
|
230
261
|
process.env._targetDeviceToBuild = (args === null || args === void 0 ? void 0 : args.target) || '';
|
|
231
262
|
_a = process.env._targetDeviceToBuild, promptTarget_1 = _a === void 0 ? '' : _a;
|
|
232
|
-
return [4, inquirer_1
|
|
263
|
+
return [4, inquirer_1.default.prompt([
|
|
233
264
|
{
|
|
234
265
|
name: 'target',
|
|
235
266
|
type: 'list',
|
|
@@ -244,7 +275,7 @@ var chooseBuildTargetsV2Config = function (mode, args) {
|
|
|
244
275
|
return mode !== BuildMode.PROD && !bool;
|
|
245
276
|
},
|
|
246
277
|
message: 'Which target would you like to preview?',
|
|
247
|
-
choices: targets
|
|
278
|
+
choices: targets,
|
|
248
279
|
},
|
|
249
280
|
{
|
|
250
281
|
name: 'target',
|
|
@@ -260,9 +291,9 @@ var chooseBuildTargetsV2Config = function (mode, args) {
|
|
|
260
291
|
choices: targets.map(function (item) { return ({
|
|
261
292
|
name: item,
|
|
262
293
|
value: item,
|
|
263
|
-
checked: true
|
|
294
|
+
checked: true,
|
|
264
295
|
}); }),
|
|
265
|
-
message: 'Which targets would you like to build?'
|
|
296
|
+
message: 'Which targets would you like to build?',
|
|
266
297
|
},
|
|
267
298
|
])];
|
|
268
299
|
case 3:
|
|
@@ -278,11 +309,15 @@ var chooseBuildTargetsV2Config = function (mode, args) {
|
|
|
278
309
|
});
|
|
279
310
|
});
|
|
280
311
|
};
|
|
281
|
-
var chooseBuildPackages = function (
|
|
282
|
-
|
|
283
|
-
|
|
312
|
+
var chooseBuildPackages = function () {
|
|
313
|
+
var args_1 = [];
|
|
314
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
315
|
+
args_1[_i] = arguments[_i];
|
|
316
|
+
}
|
|
317
|
+
return __awaiter(void 0, __spreadArray([], args_1, true), void 0, function (mode, args) {
|
|
284
318
|
var configVersion, result, _a, sources, _b, _c, _d, _e, _f, _g;
|
|
285
319
|
var _h;
|
|
320
|
+
if (mode === void 0) { mode = 'development'; }
|
|
286
321
|
return __generator(this, function (_j) {
|
|
287
322
|
switch (_j.label) {
|
|
288
323
|
case 0:
|
|
@@ -368,9 +403,9 @@ var buildPreview = function (args, callback) { return __awaiter(void 0, void 0,
|
|
|
368
403
|
if (!(res.type === 'preview')) return [3, 1];
|
|
369
404
|
zeppos_app_utils_1.logger.info('Generating preview QR code...');
|
|
370
405
|
zeppos_app_utils_1.logger.success("Please use Zepp APP to scan the following QR code to preview your ".concat(appType === AppType.WATCHFACE ? 'WatchFace' : 'Application', "."));
|
|
371
|
-
zeppos_app_utils_1.logger.success("This QR code will expire on ".concat((0, dayjs_1
|
|
372
|
-
zeppos_app_utils_1.logger.log("[".concat(chalk_1
|
|
373
|
-
qrcode_terminal_1
|
|
406
|
+
zeppos_app_utils_1.logger.success("This QR code will expire on ".concat((0, dayjs_1.default)().add(7, 'days').format('YYYY-MM-DD HH:mm:ss'), "."));
|
|
407
|
+
zeppos_app_utils_1.logger.log("[".concat(chalk_1.default.cyan(buildDevice), "] ").concat(appName, "-").concat(appVersion));
|
|
408
|
+
qrcode_terminal_1.default.generate(res.url, { small: true });
|
|
374
409
|
callback && callback(res);
|
|
375
410
|
return [3, 4];
|
|
376
411
|
case 1:
|
|
@@ -385,7 +420,8 @@ var buildPreview = function (args, callback) { return __awaiter(void 0, void 0,
|
|
|
385
420
|
case 4: return [2];
|
|
386
421
|
}
|
|
387
422
|
});
|
|
388
|
-
}); })
|
|
423
|
+
}); })
|
|
424
|
+
.catch(function () {
|
|
389
425
|
zeppos_app_utils_1.logger.error('Generating preview qrcode failed, please check your network.');
|
|
390
426
|
})];
|
|
391
427
|
case 3:
|