@aiot-toolkit/shared-utils 2.0.6-beta.28 → 2.0.6-beta.29
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/lib/ColorConsole.js +9 -30
- package/lib/enum/ProjectType.js +1 -2
- package/lib/index.js +1 -2
- package/lib/utils/CommonUtil.d.ts +1 -1
- package/lib/utils/CommonUtil.js +1 -2
- package/lib/utils/NetworkUtil.js +1 -2
- package/package.json +2 -11
package/lib/ColorConsole.js
CHANGED
|
@@ -15,7 +15,7 @@ class ColorConsole {
|
|
|
15
15
|
static defaultStyle = {
|
|
16
16
|
color: '#cccccc'
|
|
17
17
|
};
|
|
18
|
-
static styleDic =
|
|
18
|
+
static styleDic = {
|
|
19
19
|
[_ILog.Loglevel.SUCCESS]: {
|
|
20
20
|
color: '#008000',
|
|
21
21
|
icon: '✅'
|
|
@@ -38,44 +38,26 @@ class ColorConsole {
|
|
|
38
38
|
icon: '❌'
|
|
39
39
|
},
|
|
40
40
|
[_ILog.Loglevel.LOG]: ColorConsole.defaultStyle
|
|
41
|
-
}
|
|
41
|
+
};
|
|
42
42
|
static getStyle(logLevel) {
|
|
43
43
|
return ColorConsole.styleDic[logLevel] || ColorConsole.defaultStyle;
|
|
44
44
|
}
|
|
45
|
-
static log() {
|
|
46
|
-
for (var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
47
|
-
message[_key] = arguments[_key];
|
|
48
|
-
}
|
|
45
|
+
static log(...message) {
|
|
49
46
|
return ColorConsole._log(_ILog.Loglevel.LOG, ...message);
|
|
50
47
|
}
|
|
51
|
-
static error() {
|
|
52
|
-
for (var _len2 = arguments.length, message = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
53
|
-
message[_key2] = arguments[_key2];
|
|
54
|
-
}
|
|
48
|
+
static error(...message) {
|
|
55
49
|
return ColorConsole._log(_ILog.Loglevel.ERROR, ...message);
|
|
56
50
|
}
|
|
57
|
-
static info() {
|
|
58
|
-
for (var _len3 = arguments.length, message = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
59
|
-
message[_key3] = arguments[_key3];
|
|
60
|
-
}
|
|
51
|
+
static info(...message) {
|
|
61
52
|
return ColorConsole._log(_ILog.Loglevel.INFO, ...message);
|
|
62
53
|
}
|
|
63
|
-
static success() {
|
|
64
|
-
for (var _len4 = arguments.length, message = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
65
|
-
message[_key4] = arguments[_key4];
|
|
66
|
-
}
|
|
54
|
+
static success(...message) {
|
|
67
55
|
return ColorConsole._log(_ILog.Loglevel.SUCCESS, ...message);
|
|
68
56
|
}
|
|
69
|
-
static throw() {
|
|
70
|
-
for (var _len5 = arguments.length, message = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
71
|
-
message[_key5] = arguments[_key5];
|
|
72
|
-
}
|
|
57
|
+
static throw(...message) {
|
|
73
58
|
ColorConsole._log(_ILog.Loglevel.THROW, ...message);
|
|
74
59
|
}
|
|
75
|
-
static warn() {
|
|
76
|
-
for (var _len6 = arguments.length, message = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
77
|
-
message[_key6] = arguments[_key6];
|
|
78
|
-
}
|
|
60
|
+
static warn(...message) {
|
|
79
61
|
return ColorConsole._log(_ILog.Loglevel.WARN, ...message);
|
|
80
62
|
}
|
|
81
63
|
|
|
@@ -99,11 +81,8 @@ class ColorConsole {
|
|
|
99
81
|
}).join(' ');
|
|
100
82
|
return result;
|
|
101
83
|
}
|
|
102
|
-
static _log(logLevel) {
|
|
84
|
+
static _log(logLevel, ...message) {
|
|
103
85
|
const style = ColorConsole.styleDic[logLevel] || ColorConsole.defaultStyle;
|
|
104
|
-
for (var _len7 = arguments.length, message = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
|
|
105
|
-
message[_key7 - 1] = arguments[_key7];
|
|
106
|
-
}
|
|
107
86
|
console.log(ColorConsole.createDefaultPrefix({
|
|
108
87
|
level: logLevel,
|
|
109
88
|
message
|
package/lib/enum/ProjectType.js
CHANGED
|
@@ -16,8 +16,7 @@ var ProjectType = /*#__PURE__*/function (ProjectType) {
|
|
|
16
16
|
return ProjectType;
|
|
17
17
|
}(ProjectType || {});
|
|
18
18
|
(function (_ProjectType) {
|
|
19
|
-
function getProjectType(projectPath) {
|
|
20
|
-
let src = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'src';
|
|
19
|
+
function getProjectType(projectPath, src = 'src') {
|
|
21
20
|
const isUx = _fsExtra.default.existsSync(_path.default.resolve(projectPath, src, 'app.ux'));
|
|
22
21
|
if (isUx) {
|
|
23
22
|
const mainfest = _fsExtra.default.readJSONSync(_path.default.join(projectPath, src, 'manifest.json'));
|
package/lib/index.js
CHANGED
|
@@ -131,5 +131,4 @@ var _NetworkUtil = _interopRequireDefault(require("./utils/NetworkUtil"));
|
|
|
131
131
|
var _StringUtil = _interopRequireDefault(require("./utils/StringUtil"));
|
|
132
132
|
var _WrapCallback = _interopRequireDefault(require("./utils/WrapCallback"));
|
|
133
133
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
134
|
-
function
|
|
135
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
134
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -11,7 +11,7 @@ declare class CommonUtil {
|
|
|
11
11
|
* @param buffer
|
|
12
12
|
* @returns hash 值
|
|
13
13
|
*/
|
|
14
|
-
static calcDataDigest(buffer: Buffer):
|
|
14
|
+
static calcDataDigest(buffer: Buffer): NonSharedBuffer;
|
|
15
15
|
static calcImageDigest(filePath: string): string;
|
|
16
16
|
/**
|
|
17
17
|
* 从开发者项目的 node_module 中加载指定依赖;
|
package/lib/utils/CommonUtil.js
CHANGED
|
@@ -54,8 +54,7 @@ class CommonUtil {
|
|
|
54
54
|
}, 'to install it'])));
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
static requireModule(path) {
|
|
58
|
-
let throwError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
57
|
+
static requireModule(path, throwError = false) {
|
|
59
58
|
if (!_fs.default.existsSync(path)) {
|
|
60
59
|
if (throwError) {
|
|
61
60
|
throw new Error(`${path} is missing`);
|
package/lib/utils/NetworkUtil.js
CHANGED
|
@@ -24,8 +24,7 @@ class NetworkUtil {
|
|
|
24
24
|
* @param showProgress 是否显示进度条,默认为 true,会在命令行工具中显示绿色进度条
|
|
25
25
|
* @returns
|
|
26
26
|
*/
|
|
27
|
-
static gitClone(url, localPath) {
|
|
28
|
-
let showProgress = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
27
|
+
static gitClone(url, localPath, showProgress = true) {
|
|
29
28
|
return new Promise((resolve, reject) => {
|
|
30
29
|
let bar;
|
|
31
30
|
if (showProgress) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/shared-utils",
|
|
3
|
-
"version": "2.0.6-beta.
|
|
3
|
+
"version": "2.0.6-beta.29",
|
|
4
4
|
"description": "The common method functions of the aiot-toolkit.",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"cli-progress": "^3.12.0",
|
|
24
24
|
"dayjs": "^1.11.9",
|
|
25
25
|
"fs-extra": "^11.2.0",
|
|
26
|
-
"fswin": "
|
|
26
|
+
"fswin": "3.24.829",
|
|
27
27
|
"koa": "^2.15.3",
|
|
28
28
|
"koa-router": "^13.0.1",
|
|
29
29
|
"koa-static": "^5.0.0",
|
|
@@ -32,14 +32,5 @@
|
|
|
32
32
|
"qrcode": "^1.5.4",
|
|
33
33
|
"rimraf": "^5.0.9",
|
|
34
34
|
"simple-git": "^3.25.0"
|
|
35
|
-
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@types/cli-progress": "^3.11.6",
|
|
38
|
-
"@types/fs-extra": "^11.0.4",
|
|
39
|
-
"@types/koa": "^2.15.0",
|
|
40
|
-
"@types/koa-router": "^7.4.8",
|
|
41
|
-
"@types/koa-static": "^4.0.4",
|
|
42
|
-
"@types/minimatch": "^5.1.2",
|
|
43
|
-
"@types/qrcode": "^1.5.5"
|
|
44
35
|
}
|
|
45
36
|
}
|