@zeppos/zeus-cli 1.4.0 → 1.5.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 +10 -8
- package/index.js +1 -0
- package/modules/help.js +2 -1
- package/modules/prune.js +31 -0
- package/package.json +2 -2
- package/private-modules/zeppos-app-utils/dist/config/device.js +1 -1
- package/private-modules/zeppos-app-utils/dist/modules/build.js +34 -34
- package/private-modules/zeppos-app-utils/dist/modules/fetchDevices.js +1 -11
- package/private-modules/zeppos-app-utils/dist/modules/index.js +1 -0
- package/private-modules/zeppos-app-utils/dist/modules/prune.js +87 -0
- package/private-modules/zeppos-app-utils/dist/tools/tools.js +15 -1
- package/private-modules/zeppos-app-utils/package.json +1 -1
- package/utils/tools.js +83 -1
package/bin/main.js
CHANGED
|
@@ -49,7 +49,8 @@ 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
|
|
52
|
+
var tools_1 = require("../utils/tools");
|
|
53
|
+
var login = zeppos_app_utils_1.modules.login, logout = zeppos_app_utils_1.modules.logout, status = zeppos_app_utils_1.modules.status, modulesConfig = zeppos_app_utils_1.modules.config, fetchDevices = zeppos_app_utils_1.modules.fetchDevices;
|
|
53
54
|
var context = {};
|
|
54
55
|
var yargsCmdBuilderFunc = function (cmdName, useProxy, yargs) {
|
|
55
56
|
if (useProxy === void 0) { useProxy = false; }
|
|
@@ -84,15 +85,16 @@ yargs_1["default"].usage("Usage: ".concat(process.env.CMD_NAME, " <command> [arg
|
|
|
84
85
|
.alias('h', 'help').describe('help', 'Display help information.')
|
|
85
86
|
.alias('v', 'version').describe('version', 'Display version number.')
|
|
86
87
|
.group(['help', 'version'], "Base Options")
|
|
87
|
-
.command('init', 'Init a new project in current directory.', proxy,
|
|
88
|
-
.command('create <projectName>', 'Named the <projectName> project and add to the current directory.', proxy,
|
|
88
|
+
.command('init', 'Init a new project in current directory.', proxy, (0, tools_1.seriesExecTasks)([fetchDevices, index_1.create]))
|
|
89
|
+
.command('create <projectName>', 'Named the <projectName> project and add to the current directory.', proxy, (0, tools_1.seriesExecTasks)([fetchDevices, index_1.create]))
|
|
89
90
|
.command('login', 'Login to your account.', proxy, login)
|
|
90
91
|
.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),
|
|
92
|
-
.command('preview', 'Preview this project in your device.', proxy,
|
|
93
|
-
.command('build', 'Build this project for production.', proxy,
|
|
92
|
+
.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)([tools_1.isProjectRootDir, fetchDevices, index_1.run]))
|
|
93
|
+
.command('preview', 'Preview this project in your device.', proxy, (0, tools_1.seriesExecTasks)([tools_1.isProjectRootDir, fetchDevices, index_1.buildPreview]))
|
|
94
|
+
.command('build', 'Build this project for production.', proxy, (0, tools_1.seriesExecTasks)([tools_1.isProjectRootDir, fetchDevices, index_1.buildProd]))
|
|
95
|
+
.command('prune', 'Prune the intermediate product in the build artifacts.', proxy, (0, tools_1.seriesExecTasks)([tools_1.isProjectRootDir, index_1.prune]))
|
|
94
96
|
.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,
|
|
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,
|
|
97
|
+
.command('bridge', "Connect the online App or Simulator for development and debugging.", proxy, (0, tools_1.seriesExecTasks)([tools_1.isProjectRootDir, fetchDevices, index_1.bridge]))
|
|
98
|
+
.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, (0, tools_1.seriesExecTasks)([fetchDevices, modulesConfig]))
|
|
97
99
|
.epilogue('For more information, see https://docs.zepp.com/')
|
|
98
100
|
.parse(argv, context);
|
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./modules/help"), exports);
|
|
|
18
18
|
__exportStar(require("./modules/run"), exports);
|
|
19
19
|
__exportStar(require("./modules/build"), exports);
|
|
20
20
|
__exportStar(require("./modules/create"), exports);
|
|
21
|
+
__exportStar(require("./modules/prune"), exports);
|
|
21
22
|
__exportStar(require("./modules/bridge"), exports);
|
|
22
23
|
__exportStar(require("./modules/version"), exports);
|
|
23
24
|
__exportStar(require("./modules/yargsCmdBuilders"), exports);
|
package/modules/help.js
CHANGED
|
@@ -80,7 +80,8 @@ var help = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
|
80
80
|
zeppos_app_utils_1.logger.log("".concat(cmd, " dev run this project in development mode"));
|
|
81
81
|
zeppos_app_utils_1.logger.log("".concat(cmd, " preview preview this project in your device"));
|
|
82
82
|
zeppos_app_utils_1.logger.log("".concat(cmd, " build build this project for production"));
|
|
83
|
-
zeppos_app_utils_1.logger.log("".concat(cmd, "
|
|
83
|
+
zeppos_app_utils_1.logger.log("".concat(cmd, " prune prune the intermediate product in the build artifacts"));
|
|
84
|
+
zeppos_app_utils_1.logger.log("".concat(cmd, " config <term> set or get the config value"));
|
|
84
85
|
zeppos_app_utils_1.logger.log("".concat(cmd, " status view information such as login and emulator connection status"));
|
|
85
86
|
zeppos_app_utils_1.logger.log("".concat(cmd, " bridge connect the online App or Simulator for development and debugging"));
|
|
86
87
|
zeppos_app_utils_1.logger.log('');
|
package/modules/prune.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
exports.__esModule = true;
|
|
25
|
+
exports.prune = void 0;
|
|
26
|
+
var zeppos_app_utils_1 = require("zeppos-app-utils");
|
|
27
|
+
var prune = function (args) {
|
|
28
|
+
var _a = args.path, path = _a === void 0 ? './' : _a, _b = args.ip, ip = _b === void 0 ? true : _b, restParams = __rest(args, ["path", "ip"]);
|
|
29
|
+
zeppos_app_utils_1.modules.prune(__assign({ path: path, ip: ip }, restParams));
|
|
30
|
+
};
|
|
31
|
+
exports.prune = prune;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeppos/zeus-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "zeus mini-program tools",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"author": "zepp",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"qrcode-terminal": "^0.12.0",
|
|
22
22
|
"vorpal": "^1.12.0",
|
|
23
23
|
"yargs": "^17.5.1",
|
|
24
|
-
"@zeppos/zpm": "^3.0.
|
|
24
|
+
"@zeppos/zpm": "^3.0.11",
|
|
25
25
|
"axios": "^0.27.2",
|
|
26
26
|
"chalk": "^4.1.2",
|
|
27
27
|
"chokidar": "^3.5.3",
|
|
@@ -64,7 +64,7 @@ function getDeviceInfo() {
|
|
|
64
64
|
});
|
|
65
65
|
Object.assign(info.apiLevelLimit, {
|
|
66
66
|
min: (0, lodash_1.get)(cur, 'value.os.apiLevelLimitMin', '1.0.0'),
|
|
67
|
-
max: (0, lodash_1.get)(cur, 'value.os.version', '')
|
|
67
|
+
max: (0, lodash_1.get)(cur, 'value.os.apiLevelLimitMax') || (0, lodash_1.get)(cur, 'value.os.version', '')
|
|
68
68
|
});
|
|
69
69
|
return cur.code.length < acc.length ? cur.code : acc;
|
|
70
70
|
}, devices[0].code);
|
|
@@ -75,6 +75,7 @@ var lodash_2 = require("lodash");
|
|
|
75
75
|
var chalk_1 = __importDefault(require("chalk"));
|
|
76
76
|
var chokidar_1 = __importDefault(require("chokidar"));
|
|
77
77
|
var parse_gitignore_1 = __importDefault(require("parse-gitignore"));
|
|
78
|
+
var tools_1 = require("../tools/tools");
|
|
78
79
|
var BuildMode;
|
|
79
80
|
(function (BuildMode) {
|
|
80
81
|
BuildMode["DEV"] = "development";
|
|
@@ -88,6 +89,7 @@ var TransformType;
|
|
|
88
89
|
TransformType["C"] = "c";
|
|
89
90
|
TransformType["Bin"] = "bin";
|
|
90
91
|
})(TransformType || (TransformType = {}));
|
|
92
|
+
var INNER_PRODUCT_TIP = "\n\n".concat(chalk_1["default"].yellow.bold('Notice:'), "\n").concat(chalk_1["default"].blue('Please note that if your installation package includes intermediate products, you specifically authorize us to modify, edit, utilize, repackage, and distribute the installation package(including intermediate products) for the following purposes:'), "\n\n").concat(chalk_1["default"].blue.bold('1.'), " Using intermediate products to generate new installation packages and distribute them to new devices;\n").concat(chalk_1["default"].blue.bold('2.'), " Distribute the installation package to devices with the same CPU architecture and screen resolution, not limited to the device you have currently selected.\n\nHowever, we will not distribute intermediate products to user devices directly. If you choose not to include intermediate products in your installation package, use the ").concat(chalk_1["default"].bold.green('zeus prune --ip'), " command to remove it immediately after the build is completed. However, you\u2019ll then have to manually provide a build for each device type.\n\n");
|
|
91
93
|
var gitignoreDefaultItem = [
|
|
92
94
|
'.DS_Store',
|
|
93
95
|
'node_modules/**',
|
|
@@ -109,9 +111,9 @@ var buildSupportV3Config = function (workspace, mode, buildConfigOption) {
|
|
|
109
111
|
if (mode === void 0) { mode = BuildMode.PROD; }
|
|
110
112
|
if (buildConfigOption === void 0) { buildConfigOption = {}; }
|
|
111
113
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
112
|
-
var _a, targets, _b, sources, buildOptions, _c, js2c, _d, js2bin, _e, png2vg, _f, prune, _g, compress, zabName_1, distDir_1, name_1, newName_1, error_1;
|
|
113
|
-
return __generator(this, function (
|
|
114
|
-
switch (
|
|
114
|
+
var _a, targets, _b, sources, buildOptions, _c, js2c, _d, js2bin, _e, png2vg, _f, prune, _g, compress, _h, ip, zabName_1, distDir_1, name_1, newName_1, error_1;
|
|
115
|
+
return __generator(this, function (_j) {
|
|
116
|
+
switch (_j.label) {
|
|
115
117
|
case 0:
|
|
116
118
|
_a = buildConfigOption.targets, targets = _a === void 0 ? [] : _a, _b = buildConfigOption.sources, sources = _b === void 0 ? [] : _b;
|
|
117
119
|
buildOptions = {
|
|
@@ -122,23 +124,21 @@ var buildSupportV3Config = function (workspace, mode, buildConfigOption) {
|
|
|
122
124
|
jsc: TransformType.Default
|
|
123
125
|
};
|
|
124
126
|
if ([BuildMode.PROD, BuildMode.PREVIEW].includes(mode)) {
|
|
125
|
-
_c = buildConfigOption || {}, js2c = _c.js2c, _d = _c.js2bin, js2bin = _d === void 0 ? true : _d, _e = _c.png2vg, png2vg = _e === void 0 ? true : _e, _f = _c.prune, prune = _f === void 0 ? true : _f, _g = _c.compress, compress = _g === void 0 ? true : _g;
|
|
126
|
-
js2c =
|
|
127
|
-
js2bin =
|
|
128
|
-
png2vg = !!(png2vg === 'true' || png2vg === true);
|
|
129
|
-
prune = !!(prune === 'true' || prune === true);
|
|
130
|
-
compress = !!(compress === 'true' || compress === true);
|
|
127
|
+
_c = buildConfigOption || {}, js2c = _c.js2c, _d = _c.js2bin, js2bin = _d === void 0 ? true : _d, _e = _c.png2vg, png2vg = _e === void 0 ? true : _e, _f = _c.prune, prune = _f === void 0 ? true : _f, _g = _c.compress, compress = _g === void 0 ? true : _g, _h = _c.ip, ip = _h === void 0 ? BuildMode.PROD === mode : _h;
|
|
128
|
+
js2c = (0, tools_1.booleanString)(js2c);
|
|
129
|
+
js2bin = (0, tools_1.booleanString)(js2bin);
|
|
131
130
|
js2c && Object.assign(buildOptions, { jsc: TransformType.C });
|
|
132
131
|
js2bin && Object.assign(buildOptions, { jsc: TransformType.Bin });
|
|
133
132
|
Object.assign(buildOptions, {
|
|
134
|
-
png2vg: png2vg,
|
|
135
|
-
prune: prune,
|
|
136
|
-
compress: compress
|
|
133
|
+
png2vg: (0, tools_1.booleanString)(png2vg),
|
|
134
|
+
prune: (0, tools_1.booleanString)(prune),
|
|
135
|
+
compress: (0, tools_1.booleanString)(compress),
|
|
136
|
+
ip: (0, tools_1.booleanString)(ip)
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
_j.label = 1;
|
|
140
140
|
case 1:
|
|
141
|
-
|
|
141
|
+
_j.trys.push([1, 6, , 7]);
|
|
142
142
|
if (targets.length) {
|
|
143
143
|
index_1.logger.info("Start building package, targets: ".concat(targets.join(', '), "."));
|
|
144
144
|
}
|
|
@@ -147,10 +147,10 @@ var buildSupportV3Config = function (workspace, mode, buildConfigOption) {
|
|
|
147
147
|
}
|
|
148
148
|
if (!(mode === BuildMode.DEV && (0, lodash_1.get)(buildConfigOption, '_[0]') !== 'install')) return [3, 3];
|
|
149
149
|
return [4, (0, zpm_1.startWithoutDist)(buildOptions)];
|
|
150
|
-
case 2: return [2,
|
|
150
|
+
case 2: return [2, _j.sent()];
|
|
151
151
|
case 3: return [4, (0, zpm_1.start)(buildOptions)];
|
|
152
152
|
case 4:
|
|
153
|
-
zabName_1 =
|
|
153
|
+
zabName_1 = _j.sent();
|
|
154
154
|
if (buildConfigOption.renameWithAppId) {
|
|
155
155
|
distDir_1 = path.join(workspace, 'dist');
|
|
156
156
|
name_1 = zabName_1.replace(/[\s]/g, '_').split('.zab');
|
|
@@ -164,12 +164,13 @@ var buildSupportV3Config = function (workspace, mode, buildConfigOption) {
|
|
|
164
164
|
fs_1["default"].renameSync(oldName, path.join(distDir_1, newName_1));
|
|
165
165
|
}
|
|
166
166
|
});
|
|
167
|
+
index_1.logger.log(INNER_PRODUCT_TIP);
|
|
167
168
|
return [2, newName_1];
|
|
168
169
|
}
|
|
169
170
|
return [2, zabName_1];
|
|
170
171
|
case 5: return [3, 7];
|
|
171
172
|
case 6:
|
|
172
|
-
error_1 =
|
|
173
|
+
error_1 = _j.sent();
|
|
173
174
|
index_1.logger.error(error_1);
|
|
174
175
|
return [3, 7];
|
|
175
176
|
case 7: return [2];
|
|
@@ -182,9 +183,9 @@ var build = function (workspace, mode, buildConfigOption, packages, appId) {
|
|
|
182
183
|
if (mode === void 0) { mode = BuildMode.PROD; }
|
|
183
184
|
if (appId === void 0) { appId = '10000'; }
|
|
184
185
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
185
|
-
var buildOptions, _a, js2c, _b, js2bin, _c, png2vg, _d, prune, _e, compress, curOpt, productName_1, DistDir_1, name_2, newName_2, error_2;
|
|
186
|
-
return __generator(this, function (
|
|
187
|
-
switch (
|
|
186
|
+
var buildOptions, _a, js2c, _b, js2bin, _c, png2vg, _d, prune, _e, compress, _f, ip, curOpt, productName_1, DistDir_1, name_2, newName_2, error_2;
|
|
187
|
+
return __generator(this, function (_g) {
|
|
188
|
+
switch (_g.label) {
|
|
188
189
|
case 0:
|
|
189
190
|
buildOptions = {
|
|
190
191
|
path: workspace,
|
|
@@ -193,30 +194,28 @@ var build = function (workspace, mode, buildConfigOption, packages, appId) {
|
|
|
193
194
|
jsc: TransformType.Default
|
|
194
195
|
};
|
|
195
196
|
if (mode === BuildMode.PROD || mode === BuildMode.PREVIEW) {
|
|
196
|
-
_a = buildConfigOption || {}, js2c = _a.js2c, _b = _a.js2bin, js2bin = _b === void 0 ? true : _b, _c = _a.png2vg, png2vg = _c === void 0 ? true : _c, _d = _a.prune, prune = _d === void 0 ? true : _d, _e = _a.compress, compress = _e === void 0 ? true : _e;
|
|
197
|
-
js2c =
|
|
198
|
-
js2bin =
|
|
199
|
-
png2vg = !!(png2vg === 'true' || png2vg === true);
|
|
200
|
-
prune = !!(prune === 'true' || prune === true);
|
|
201
|
-
compress = !!(compress === 'true' || compress === true);
|
|
197
|
+
_a = buildConfigOption || {}, js2c = _a.js2c, _b = _a.js2bin, js2bin = _b === void 0 ? true : _b, _c = _a.png2vg, png2vg = _c === void 0 ? true : _c, _d = _a.prune, prune = _d === void 0 ? true : _d, _e = _a.compress, compress = _e === void 0 ? true : _e, _f = _a.ip, ip = _f === void 0 ? (mode === BuildMode.PROD) : _f;
|
|
198
|
+
js2c = (0, tools_1.booleanString)(js2c);
|
|
199
|
+
js2bin = (0, tools_1.booleanString)(js2bin);
|
|
202
200
|
js2c && Object.assign(buildOptions, { jsc: TransformType.C });
|
|
203
201
|
js2bin && Object.assign(buildOptions, { jsc: TransformType.Bin });
|
|
204
202
|
Object.assign(buildOptions, {
|
|
205
|
-
png2vg: png2vg,
|
|
206
|
-
prune: prune,
|
|
207
|
-
compress: compress
|
|
203
|
+
png2vg: (0, tools_1.booleanString)(png2vg),
|
|
204
|
+
prune: (0, tools_1.booleanString)(prune),
|
|
205
|
+
compress: (0, tools_1.booleanString)(compress),
|
|
206
|
+
ip: (0, tools_1.booleanString)(ip)
|
|
208
207
|
});
|
|
209
208
|
}
|
|
210
|
-
|
|
209
|
+
_g.label = 1;
|
|
211
210
|
case 1:
|
|
212
|
-
|
|
211
|
+
_g.trys.push([1, 6, , 7]);
|
|
213
212
|
index_1.logger.info("Start building package, targets: ".concat(packages.join(', '), "."));
|
|
214
213
|
curOpt = (0, lodash_1.get)(buildConfigOption, '_', [])[0];
|
|
215
214
|
if (!(mode !== BuildMode.DEV ||
|
|
216
215
|
(mode === BuildMode.DEV && curOpt === 'install'))) return [3, 3];
|
|
217
216
|
return [4, (0, zpm_1.start)(buildOptions)];
|
|
218
217
|
case 2:
|
|
219
|
-
productName_1 =
|
|
218
|
+
productName_1 = _g.sent();
|
|
220
219
|
if (productName_1) {
|
|
221
220
|
DistDir_1 = path.join(workspace, 'dist');
|
|
222
221
|
name_2 = productName_1.replace(/[\s]/g, '_').split('.zab');
|
|
@@ -232,16 +231,17 @@ var build = function (workspace, mode, buildConfigOption, packages, appId) {
|
|
|
232
231
|
});
|
|
233
232
|
productName_1 = newName_2;
|
|
234
233
|
}
|
|
234
|
+
index_1.logger.log(INNER_PRODUCT_TIP);
|
|
235
235
|
return [2, productName_1];
|
|
236
236
|
case 3:
|
|
237
237
|
if (!(mode === BuildMode.DEV)) return [3, 5];
|
|
238
238
|
return [4, (0, zpm_1.startWithoutDist)(buildOptions)];
|
|
239
239
|
case 4:
|
|
240
|
-
|
|
240
|
+
_g.sent();
|
|
241
241
|
return [2, (0, zpm_1.getZpkBuf)(packages[0])];
|
|
242
242
|
case 5: return [3, 7];
|
|
243
243
|
case 6:
|
|
244
|
-
error_2 =
|
|
244
|
+
error_2 = _g.sent();
|
|
245
245
|
index_1.logger.error(error_2);
|
|
246
246
|
return [3, 7];
|
|
247
247
|
case 7: return [2];
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
exports.__esModule = true;
|
|
29
|
-
exports.
|
|
29
|
+
exports.fetchDevices = exports.DeviceScreenType = void 0;
|
|
30
30
|
var axios_1 = __importDefault(require("axios"));
|
|
31
31
|
var os = __importStar(require("os"));
|
|
32
32
|
var path = __importStar(require("path"));
|
|
@@ -77,13 +77,3 @@ var fetchDevices = function () {
|
|
|
77
77
|
});
|
|
78
78
|
};
|
|
79
79
|
exports.fetchDevices = fetchDevices;
|
|
80
|
-
var fetchDevicesWrap = function (func) {
|
|
81
|
-
return function () {
|
|
82
|
-
var args = [];
|
|
83
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
84
|
-
args[_i] = arguments[_i];
|
|
85
|
-
}
|
|
86
|
-
return (0, exports.fetchDevices)().then(function () { return func.apply(void 0, args); });
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
exports.fetchDevicesWrap = fetchDevicesWrap;
|
|
@@ -18,5 +18,6 @@ __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("./prune"), exports);
|
|
21
22
|
__exportStar(require("./fetchDevices"), exports);
|
|
22
23
|
__exportStar(require("./create/index"), exports);
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
+
var t = {};
|
|
51
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
+
t[p] = s[p];
|
|
53
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
+
t[p[i]] = s[p[i]];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
};
|
|
60
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
61
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
62
|
+
};
|
|
63
|
+
exports.__esModule = true;
|
|
64
|
+
exports.prune = void 0;
|
|
65
|
+
var fs_1 = __importDefault(require("fs"));
|
|
66
|
+
var zpm_1 = require("@zeppos/zpm");
|
|
67
|
+
var index_1 = require("../index");
|
|
68
|
+
var tools_1 = require("../tools/tools");
|
|
69
|
+
var prune = function (pruneParams) { return __awaiter(void 0, void 0, void 0, function () {
|
|
70
|
+
var path, ip, restParams, isExistZab;
|
|
71
|
+
return __generator(this, function (_a) {
|
|
72
|
+
switch (_a.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
path = pruneParams.path, ip = pruneParams.ip, restParams = __rest(pruneParams, ["path", "ip"]);
|
|
75
|
+
isExistZab = fs_1["default"].readdirSync("".concat(path, "/dist")).find(function (fileName) { return fileName.endsWith('.zab'); });
|
|
76
|
+
if (!isExistZab) {
|
|
77
|
+
index_1.logger.error('No zab file to prune');
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
return [4, (0, zpm_1.prune)(__assign({ path: path, ip: (0, tools_1.booleanString)(ip) }, restParams))];
|
|
81
|
+
case 1:
|
|
82
|
+
_a.sent();
|
|
83
|
+
return [2];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}); };
|
|
87
|
+
exports.prune = prune;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.compareVersion = exports.versionToCode = void 0;
|
|
3
|
+
exports.booleanString = exports.compareVersion = exports.versionToCode = void 0;
|
|
4
4
|
var versionToCode = function (version) {
|
|
5
5
|
if (!version)
|
|
6
6
|
return 0;
|
|
@@ -12,3 +12,17 @@ var compareVersion = function (version1, version2) {
|
|
|
12
12
|
return (0, exports.versionToCode)(version2) - (0, exports.versionToCode)(version1);
|
|
13
13
|
};
|
|
14
14
|
exports.compareVersion = compareVersion;
|
|
15
|
+
var booleanString = function (val) {
|
|
16
|
+
var booleanValMap = {
|
|
17
|
+
'false': false,
|
|
18
|
+
'true': true
|
|
19
|
+
};
|
|
20
|
+
if (typeof val === 'string') {
|
|
21
|
+
var boolVal = booleanValMap[val.trim()];
|
|
22
|
+
if (typeof boolVal !== 'undefined')
|
|
23
|
+
return boolVal;
|
|
24
|
+
return !!val;
|
|
25
|
+
}
|
|
26
|
+
return !!val;
|
|
27
|
+
};
|
|
28
|
+
exports.booleanString = booleanString;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dev": "nodemon -e ts,tsx --exec \"rm -rf dist && tsc && ts-node build.ts\" --ignore types/ --ignore dist/"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@zeppos/zpm": "^3.0.
|
|
16
|
+
"@zeppos/zpm": "^3.0.11",
|
|
17
17
|
"axios": "^0.27.2",
|
|
18
18
|
"chalk": "^4.1.2",
|
|
19
19
|
"chokidar": "^3.5.3",
|
package/utils/tools.js
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
2
41
|
exports.__esModule = true;
|
|
3
|
-
exports.compareVersion = exports.versionToCode = void 0;
|
|
42
|
+
exports.seriesExecTasks = exports.isProjectRootDir = exports.compareVersion = exports.versionToCode = void 0;
|
|
43
|
+
var fs_1 = __importDefault(require("fs"));
|
|
44
|
+
var zeppos_app_utils_1 = require("zeppos-app-utils");
|
|
4
45
|
var versionToCode = function (version) {
|
|
5
46
|
if (!version)
|
|
6
47
|
return 0;
|
|
@@ -12,3 +53,44 @@ var compareVersion = function (version1, version2) {
|
|
|
12
53
|
return (0, exports.versionToCode)(version2) - (0, exports.versionToCode)(version1);
|
|
13
54
|
};
|
|
14
55
|
exports.compareVersion = compareVersion;
|
|
56
|
+
var isProjectRootDir = function () {
|
|
57
|
+
var currentDir = process.cwd();
|
|
58
|
+
var isExist = fs_1["default"].existsSync("".concat(currentDir, "/app.json"));
|
|
59
|
+
if (!isExist) {
|
|
60
|
+
zeppos_app_utils_1.logger.error("You must execute the Zeus command in the project's root directory.");
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.isProjectRootDir = isProjectRootDir;
|
|
65
|
+
var seriesExecTasks = function (funcs) {
|
|
66
|
+
return function () {
|
|
67
|
+
var args = [];
|
|
68
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
69
|
+
args[_i] = arguments[_i];
|
|
70
|
+
}
|
|
71
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
var i, func;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
if (!Array.isArray(funcs))
|
|
77
|
+
return [2];
|
|
78
|
+
i = 0;
|
|
79
|
+
_a.label = 1;
|
|
80
|
+
case 1:
|
|
81
|
+
if (!(i < funcs.length)) return [3, 4];
|
|
82
|
+
func = funcs[i];
|
|
83
|
+
return [4, func.apply(void 0, args)];
|
|
84
|
+
case 2:
|
|
85
|
+
_a.sent();
|
|
86
|
+
_a.label = 3;
|
|
87
|
+
case 3:
|
|
88
|
+
i += 1;
|
|
89
|
+
return [3, 1];
|
|
90
|
+
case 4: return [2];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
exports.seriesExecTasks = seriesExecTasks;
|