utiller 1.0.185 → 1.0.187
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/exceptioner/index.js
CHANGED
|
@@ -18,7 +18,6 @@ var _lodash = _interopRequireDefault(require("lodash"));
|
|
|
18
18
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
19
19
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
20
20
|
var MyException = /*#__PURE__*/function (_Error) {
|
|
21
|
-
(0, _inherits2["default"])(MyException, _Error);
|
|
22
21
|
function MyException(code) {
|
|
23
22
|
var _this;
|
|
24
23
|
(0, _classCallCheck2["default"])(this, MyException);
|
|
@@ -42,7 +41,8 @@ var MyException = /*#__PURE__*/function (_Error) {
|
|
|
42
41
|
if (_configerer.configerer.MODULE_MSG.SHOW_ERROR) _index.utiller.appendError(_this.message);
|
|
43
42
|
return _this;
|
|
44
43
|
}
|
|
45
|
-
(0,
|
|
44
|
+
(0, _inherits2["default"])(MyException, _Error);
|
|
45
|
+
return (0, _createClass2["default"])(MyException, [{
|
|
46
46
|
key: "getErrorCode",
|
|
47
47
|
value: function getErrorCode() {
|
|
48
48
|
return this.code;
|
|
@@ -58,6 +58,5 @@ var MyException = /*#__PURE__*/function (_Error) {
|
|
|
58
58
|
return JSON.stringify(_msg);
|
|
59
59
|
}
|
|
60
60
|
}]);
|
|
61
|
-
return MyException;
|
|
62
61
|
}( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(Error));
|
|
63
62
|
var _default = exports["default"] = MyException;
|
package/lib/pooller/index.js
CHANGED
|
@@ -698,7 +698,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
698
698
|
_iterator4.f();
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
|
-
(0, _createClass2["default"])(InfinitePool, [{
|
|
701
|
+
return (0, _createClass2["default"])(InfinitePool, [{
|
|
702
702
|
key: "enableQueueTerminateBySleepCount",
|
|
703
703
|
value:
|
|
704
704
|
/**
|
|
@@ -1770,6 +1770,5 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1770
1770
|
return sampleOfEachTaskInFreeMarker;
|
|
1771
1771
|
}()
|
|
1772
1772
|
}]);
|
|
1773
|
-
return InfinitePool;
|
|
1774
1773
|
}();
|
|
1775
1774
|
var _default = exports["default"] = InfinitePool;
|
package/lib/utiller/index.js
CHANGED
|
@@ -159,7 +159,7 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
159
159
|
this.init();
|
|
160
160
|
this.env = "dev";
|
|
161
161
|
}
|
|
162
|
-
(0, _createClass2["default"])(Utiller, [{
|
|
162
|
+
return (0, _createClass2["default"])(Utiller, [{
|
|
163
163
|
key: "removeAttributeBy",
|
|
164
164
|
value: /** Key : idOfSetTimout */
|
|
165
165
|
|
|
@@ -2394,6 +2394,5 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
2394
2394
|
return slices;
|
|
2395
2395
|
}
|
|
2396
2396
|
}]);
|
|
2397
|
-
return Utiller;
|
|
2398
2397
|
}();
|
|
2399
2398
|
var _default = exports["default"] = Utiller;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = void 0;
|
|
8
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
13
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
15
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
16
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
16
17
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
19
|
var _path5 = _interopRequireDefault(require("path"));
|
|
@@ -23,17 +24,18 @@ var _configerer = require("configerer");
|
|
|
23
24
|
var _index = _interopRequireDefault(require("./index"));
|
|
24
25
|
var _index2 = _interopRequireDefault(require("../exceptioner/index"));
|
|
25
26
|
var _pdfParse = _interopRequireDefault(require("pdf-parse"));
|
|
26
|
-
var _del =
|
|
27
|
+
var _del = _interopRequireWildcard(require("del"));
|
|
27
28
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
28
29
|
var _prompt = _interopRequireDefault(require("prompt"));
|
|
29
30
|
var _nodeHtmlParser = require("node-html-parser");
|
|
31
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
32
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(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; }
|
|
30
33
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
31
34
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
32
35
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
33
36
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
34
37
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
35
38
|
var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
36
|
-
(0, _inherits2["default"])(NodeUtiller, _Utiller);
|
|
37
39
|
function NodeUtiller() {
|
|
38
40
|
var _this;
|
|
39
41
|
(0, _classCallCheck2["default"])(this, NodeUtiller);
|
|
@@ -43,7 +45,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
43
45
|
_this = _callSuper(this, NodeUtiller, [].concat(args));
|
|
44
46
|
/**================================= only in node.js ================================= */
|
|
45
47
|
/** 是否把log message 存到 info.txt*/
|
|
46
|
-
(0, _defineProperty2["default"])(
|
|
48
|
+
(0, _defineProperty2["default"])(_this, "isPersistIntoLogFile", true);
|
|
47
49
|
/**
|
|
48
50
|
* 遞回的去找出folder每一個child file, 預設是全部檔案, 可以透過predicate做filter, 可以exclude 指定的 'folder name'
|
|
49
51
|
*
|
|
@@ -58,7 +60,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
58
60
|
dirName: database
|
|
59
61
|
absolute: '/Users/davidtu/cross-achieve/mimi19up/mimi19up-scrapy/database/index.js'}
|
|
60
62
|
] */
|
|
61
|
-
(0, _defineProperty2["default"])(
|
|
63
|
+
(0, _defineProperty2["default"])(_this, "findFilePathBy", function (path) {
|
|
62
64
|
var predicate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (each) {
|
|
63
65
|
return true;
|
|
64
66
|
};
|
|
@@ -95,7 +97,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
95
97
|
return files;
|
|
96
98
|
});
|
|
97
99
|
/** return [...{path: ,fileName: ,extension: ,absolute: ,dirName:}]*/
|
|
98
|
-
(0, _defineProperty2["default"])(
|
|
100
|
+
(0, _defineProperty2["default"])(_this, "findFilePathByExtension", function (rootpath) {
|
|
99
101
|
var _this3;
|
|
100
102
|
var _extension = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
101
103
|
var reg = new RegExp("^[^.].+.(".concat(_lodash["default"].join(_extension, "|"), ")$"));
|
|
@@ -106,13 +108,13 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
106
108
|
return reg.test(item.fileNameExtension);
|
|
107
109
|
}].concat(exclude));
|
|
108
110
|
});
|
|
109
|
-
(0, _defineProperty2["default"])(
|
|
111
|
+
(0, _defineProperty2["default"])(_this, "executeCommandLine", /*#__PURE__*/function () {
|
|
110
112
|
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(command) {
|
|
111
113
|
var self;
|
|
112
114
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
113
115
|
while (1) switch (_context.prev = _context.next) {
|
|
114
116
|
case 0:
|
|
115
|
-
self =
|
|
117
|
+
self = _this;
|
|
116
118
|
_this.appendInfo("\u57F7\u884C\u8173\u672C ".concat(command));
|
|
117
119
|
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
118
120
|
_child_process["default"].exec(command, function (error, stdout, stderr) {
|
|
@@ -138,7 +140,8 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
138
140
|
}());
|
|
139
141
|
return _this;
|
|
140
142
|
}
|
|
141
|
-
(0,
|
|
143
|
+
(0, _inherits2["default"])(NodeUtiller, _Utiller);
|
|
144
|
+
return (0, _createClass2["default"])(NodeUtiller, [{
|
|
142
145
|
key: "findSpecificFolderByPath",
|
|
143
146
|
value: function findSpecificFolderByPath(path, folderName) {
|
|
144
147
|
var absolute = _path5["default"].resolve(path);
|
|
@@ -1303,7 +1306,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1303
1306
|
return _regenerator["default"].wrap(function _callee15$(_context16) {
|
|
1304
1307
|
while (1) switch (_context16.prev = _context16.next) {
|
|
1305
1308
|
case 0:
|
|
1306
|
-
if (!_lodash["default"].isEqual("
|
|
1309
|
+
if (!_lodash["default"].isEqual("json", this.getPathInfo(path).extension)) {
|
|
1307
1310
|
_context16.next = 8;
|
|
1308
1311
|
break;
|
|
1309
1312
|
}
|
|
@@ -1328,31 +1331,218 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1328
1331
|
return _upgradePackageJsonVersion.apply(this, arguments);
|
|
1329
1332
|
}
|
|
1330
1333
|
return upgradePackageJsonVersion;
|
|
1334
|
+
}()
|
|
1335
|
+
/** rewrite file of *.json with attributes => {version:'1.0.1'}, {name:'david'}
|
|
1336
|
+
*
|
|
1337
|
+
* console.log(await utiller.reWriteJsonAttribute(`./test.package.json`,{name:'ugly'},{version:'2.6.101'}));
|
|
1338
|
+
* */
|
|
1339
|
+
)
|
|
1340
|
+
}, {
|
|
1341
|
+
key: "reWriteJsonAttribute",
|
|
1342
|
+
value: (function () {
|
|
1343
|
+
var _reWriteJsonAttribute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee16(path) {
|
|
1344
|
+
var json,
|
|
1345
|
+
_len9,
|
|
1346
|
+
attrs,
|
|
1347
|
+
_key9,
|
|
1348
|
+
_i2,
|
|
1349
|
+
_attrs,
|
|
1350
|
+
attr,
|
|
1351
|
+
_args17 = arguments;
|
|
1352
|
+
return _regenerator["default"].wrap(function _callee16$(_context17) {
|
|
1353
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1354
|
+
case 0:
|
|
1355
|
+
if (!_lodash["default"].isEqual("json", this.getPathInfo(path).extension)) {
|
|
1356
|
+
_context17.next = 17;
|
|
1357
|
+
break;
|
|
1358
|
+
}
|
|
1359
|
+
json = this.getJsonObjByFilePath(path);
|
|
1360
|
+
for (_len9 = _args17.length, attrs = new Array(_len9 > 1 ? _len9 - 1 : 0), _key9 = 1; _key9 < _len9; _key9++) {
|
|
1361
|
+
attrs[_key9 - 1] = _args17[_key9];
|
|
1362
|
+
}
|
|
1363
|
+
_i2 = 0, _attrs = attrs;
|
|
1364
|
+
case 4:
|
|
1365
|
+
if (!(_i2 < _attrs.length)) {
|
|
1366
|
+
_context17.next = 12;
|
|
1367
|
+
break;
|
|
1368
|
+
}
|
|
1369
|
+
attr = _attrs[_i2];
|
|
1370
|
+
if (_lodash["default"].isObject(attr)) {
|
|
1371
|
+
_context17.next = 8;
|
|
1372
|
+
break;
|
|
1373
|
+
}
|
|
1374
|
+
throw new _index2["default"](9999, "84451515 attr is not object, which is 'type=".concat((0, _typeof2["default"])(attr), " => ").concat(attr, "'"));
|
|
1375
|
+
case 8:
|
|
1376
|
+
json[this.getObjectKey(attr)] = this.getObjectValue(attr);
|
|
1377
|
+
case 9:
|
|
1378
|
+
_i2++;
|
|
1379
|
+
_context17.next = 4;
|
|
1380
|
+
break;
|
|
1381
|
+
case 12:
|
|
1382
|
+
_context17.next = 14;
|
|
1383
|
+
return this.writeJsonThanPrettier(path, json);
|
|
1384
|
+
case 14:
|
|
1385
|
+
return _context17.abrupt("return", {
|
|
1386
|
+
version: json.version,
|
|
1387
|
+
moduleName: json.name
|
|
1388
|
+
});
|
|
1389
|
+
case 17:
|
|
1390
|
+
throw new _index2["default"](9999, "reWriteJsonAttribute() => path is not package.json, which is ".concat(path));
|
|
1391
|
+
case 18:
|
|
1392
|
+
case "end":
|
|
1393
|
+
return _context17.stop();
|
|
1394
|
+
}
|
|
1395
|
+
}, _callee16, this);
|
|
1396
|
+
}));
|
|
1397
|
+
function reWriteJsonAttribute(_x17) {
|
|
1398
|
+
return _reWriteJsonAttribute.apply(this, arguments);
|
|
1399
|
+
}
|
|
1400
|
+
return reWriteJsonAttribute;
|
|
1401
|
+
}())
|
|
1402
|
+
}, {
|
|
1403
|
+
key: "getVersionOfPackageJson",
|
|
1404
|
+
value: function getVersionOfPackageJson(path) {
|
|
1405
|
+
return this.getAttributeValueOfJson(path, "version", "1.0.0");
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/** 取得*.json 裡面的file*/
|
|
1409
|
+
}, {
|
|
1410
|
+
key: "getAttributeValueOfJson",
|
|
1411
|
+
value: function getAttributeValueOfJson(path, key) {
|
|
1412
|
+
var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
1413
|
+
if (_lodash["default"].isEqual("json", this.getPathInfo(path).extension)) {
|
|
1414
|
+
var _json$key;
|
|
1415
|
+
var json = this.getJsonObjByFilePath(path);
|
|
1416
|
+
return (_json$key = json[key]) !== null && _json$key !== void 0 ? _json$key : defaultValue;
|
|
1417
|
+
} else {
|
|
1418
|
+
throw new _index2["default"](8020, "path is not package.json, which is ".concat(path));
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
/** 找到 js file 裡面宣告version的value ==> version:'1.0.60'} */
|
|
1423
|
+
}, {
|
|
1424
|
+
key: "getVersionOfJsFile",
|
|
1425
|
+
value: function getVersionOfJsFile(path) {
|
|
1426
|
+
return this.getAttributeValueOfJsFile(path, "version", "project without version notice");
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
/** 找到 js file 裡面宣告attribute的 value ==> 例:version:'1.0.60'} */
|
|
1430
|
+
}, {
|
|
1431
|
+
key: "getAttributeValueOfJsFile",
|
|
1432
|
+
value: function getAttributeValueOfJsFile(path, key) {
|
|
1433
|
+
var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
1434
|
+
if (_lodash["default"].isEqual(this.getExtensionFromPath(path), "js")) {
|
|
1435
|
+
var _source$key;
|
|
1436
|
+
var source = require(_path5["default"].resolve(path))["default"];
|
|
1437
|
+
return (_source$key = source[key]) !== null && _source$key !== void 0 ? _source$key : defaultValue;
|
|
1438
|
+
} else {
|
|
1439
|
+
throw new _index2["default"](8020, "path is not js file, which is ".concat(path));
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
/** 更新js file裏面attribute
|
|
1444
|
+
* attr => {verison:1.0.32}
|
|
1445
|
+
* console.log(await utiller.rewriteAttributeOfSourceJs(`./test.source.js`, {name: 'ugly-tu'}, {version: '3.9.123'}));
|
|
1446
|
+
* */
|
|
1447
|
+
}, {
|
|
1448
|
+
key: "rewriteAttributeOfSourceJs",
|
|
1449
|
+
value: (function () {
|
|
1450
|
+
var _rewriteAttributeOfSourceJs = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee17(path) {
|
|
1451
|
+
var _this8 = this;
|
|
1452
|
+
var _len10,
|
|
1453
|
+
attrs,
|
|
1454
|
+
_key10,
|
|
1455
|
+
_loop2,
|
|
1456
|
+
_i3,
|
|
1457
|
+
_attrs2,
|
|
1458
|
+
_args19 = arguments;
|
|
1459
|
+
return _regenerator["default"].wrap(function _callee17$(_context19) {
|
|
1460
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1461
|
+
case 0:
|
|
1462
|
+
if (this.isPathExist(path)) {
|
|
1463
|
+
_context19.next = 2;
|
|
1464
|
+
break;
|
|
1465
|
+
}
|
|
1466
|
+
throw new _index2["default"](9999, "4849813 ".concat(path, " is not exist"));
|
|
1467
|
+
case 2:
|
|
1468
|
+
for (_len10 = _args19.length, attrs = new Array(_len10 > 1 ? _len10 - 1 : 0), _key10 = 1; _key10 < _len10; _key10++) {
|
|
1469
|
+
attrs[_key10 - 1] = _args19[_key10];
|
|
1470
|
+
}
|
|
1471
|
+
_loop2 = /*#__PURE__*/_regenerator["default"].mark(function _loop2() {
|
|
1472
|
+
var attr, key, value, contents, index;
|
|
1473
|
+
return _regenerator["default"].wrap(function _loop2$(_context18) {
|
|
1474
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1475
|
+
case 0:
|
|
1476
|
+
attr = _attrs2[_i3];
|
|
1477
|
+
if (_lodash["default"].isObject(attr)) {
|
|
1478
|
+
_context18.next = 3;
|
|
1479
|
+
break;
|
|
1480
|
+
}
|
|
1481
|
+
throw new _index2["default"](9999, "4984651 attr is not object, which is 'type=".concat((0, _typeof2["default"])(attr), " => ").concat(attr, "'"));
|
|
1482
|
+
case 3:
|
|
1483
|
+
key = _this8.getObjectKey(attr);
|
|
1484
|
+
value = _this8.getObjectValue(attr);
|
|
1485
|
+
contents = _this8.getFileContextInRaw(path).split("\n");
|
|
1486
|
+
index = _lodash["default"].findIndex(contents, function (each) {
|
|
1487
|
+
return _lodash["default"].startsWith(_lodash["default"].trim(each), "".concat(key));
|
|
1488
|
+
});
|
|
1489
|
+
/** 故意空4格 */
|
|
1490
|
+
contents[index] = " ".concat(key, ": '").concat(value, "',");
|
|
1491
|
+
_this8.appendFile(path, contents.join("\n"), true, true);
|
|
1492
|
+
case 9:
|
|
1493
|
+
case "end":
|
|
1494
|
+
return _context18.stop();
|
|
1495
|
+
}
|
|
1496
|
+
}, _loop2);
|
|
1497
|
+
});
|
|
1498
|
+
_i3 = 0, _attrs2 = attrs;
|
|
1499
|
+
case 5:
|
|
1500
|
+
if (!(_i3 < _attrs2.length)) {
|
|
1501
|
+
_context19.next = 10;
|
|
1502
|
+
break;
|
|
1503
|
+
}
|
|
1504
|
+
return _context19.delegateYield(_loop2(), "t0", 7);
|
|
1505
|
+
case 7:
|
|
1506
|
+
_i3++;
|
|
1507
|
+
_context19.next = 5;
|
|
1508
|
+
break;
|
|
1509
|
+
case 10:
|
|
1510
|
+
return _context19.abrupt("return", attrs);
|
|
1511
|
+
case 11:
|
|
1512
|
+
case "end":
|
|
1513
|
+
return _context19.stop();
|
|
1514
|
+
}
|
|
1515
|
+
}, _callee17, this);
|
|
1516
|
+
}));
|
|
1517
|
+
function rewriteAttributeOfSourceJs(_x18) {
|
|
1518
|
+
return _rewriteAttributeOfSourceJs.apply(this, arguments);
|
|
1519
|
+
}
|
|
1520
|
+
return rewriteAttributeOfSourceJs;
|
|
1331
1521
|
}())
|
|
1332
1522
|
}, {
|
|
1333
1523
|
key: "getAnswerFromPromptQ",
|
|
1334
1524
|
value: function () {
|
|
1335
|
-
var _getAnswerFromPromptQ = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
1525
|
+
var _getAnswerFromPromptQ = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee18() {
|
|
1336
1526
|
var configs,
|
|
1337
|
-
|
|
1338
|
-
return _regenerator["default"].wrap(function
|
|
1339
|
-
while (1) switch (
|
|
1527
|
+
_args20 = arguments;
|
|
1528
|
+
return _regenerator["default"].wrap(function _callee18$(_context20) {
|
|
1529
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1340
1530
|
case 0:
|
|
1341
|
-
configs =
|
|
1531
|
+
configs = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : [{
|
|
1342
1532
|
name: "name",
|
|
1343
1533
|
require: true,
|
|
1344
1534
|
description: "type the name"
|
|
1345
1535
|
}];
|
|
1346
1536
|
_prompt["default"].start();
|
|
1347
|
-
|
|
1537
|
+
_context20.next = 4;
|
|
1348
1538
|
return _prompt["default"].get(configs);
|
|
1349
1539
|
case 4:
|
|
1350
|
-
return
|
|
1540
|
+
return _context20.abrupt("return", _context20.sent);
|
|
1351
1541
|
case 5:
|
|
1352
1542
|
case "end":
|
|
1353
|
-
return
|
|
1543
|
+
return _context20.stop();
|
|
1354
1544
|
}
|
|
1355
|
-
},
|
|
1545
|
+
}, _callee18);
|
|
1356
1546
|
}));
|
|
1357
1547
|
function getAnswerFromPromptQ() {
|
|
1358
1548
|
return _getAnswerFromPromptQ.apply(this, arguments);
|
|
@@ -1362,27 +1552,27 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1362
1552
|
}, {
|
|
1363
1553
|
key: "generateTempFolderWithCleanSrc",
|
|
1364
1554
|
value: (function () {
|
|
1365
|
-
var _generateTempFolderWithCleanSrc = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
1555
|
+
var _generateTempFolderWithCleanSrc = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee19(path) {
|
|
1366
1556
|
var sourceFile, tempFolderPath, _iterator10, _step10, file, tempFilePath, stmts, indexOfStart, indexOfEnd;
|
|
1367
|
-
return _regenerator["default"].wrap(function
|
|
1368
|
-
while (1) switch (
|
|
1557
|
+
return _regenerator["default"].wrap(function _callee19$(_context21) {
|
|
1558
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1369
1559
|
case 0:
|
|
1370
1560
|
this.appendInfo("generateTempFolderWithCleanSrc", path);
|
|
1371
1561
|
sourceFile = _path5["default"].join(path, "src");
|
|
1372
1562
|
tempFolderPath = _path5["default"].join(path, "temp");
|
|
1373
1563
|
if (!_fs["default"].existsSync(sourceFile)) {
|
|
1374
|
-
|
|
1564
|
+
_context21.next = 31;
|
|
1375
1565
|
break;
|
|
1376
1566
|
}
|
|
1377
1567
|
this.appendInfo("generateTempFolderWithCleanSrc", "source", sourceFile);
|
|
1378
1568
|
this.persistByPath(tempFolderPath);
|
|
1379
1569
|
this.copyFromFolderToDestFolder(sourceFile, tempFolderPath);
|
|
1380
1570
|
_iterator10 = _createForOfIteratorHelper(this.findFilePathBy(tempFolderPath));
|
|
1381
|
-
|
|
1571
|
+
_context21.prev = 8;
|
|
1382
1572
|
_iterator10.s();
|
|
1383
1573
|
case 10:
|
|
1384
1574
|
if ((_step10 = _iterator10.n()).done) {
|
|
1385
|
-
|
|
1575
|
+
_context21.next = 23;
|
|
1386
1576
|
break;
|
|
1387
1577
|
}
|
|
1388
1578
|
file = _step10.value;
|
|
@@ -1399,37 +1589,37 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1399
1589
|
return _lodash["default"].isEqual(stmt, "}");
|
|
1400
1590
|
});
|
|
1401
1591
|
if (!(indexOfEnd > 0 && indexOfStart > 0 && indexOfEnd > indexOfStart)) {
|
|
1402
|
-
|
|
1592
|
+
_context21.next = 21;
|
|
1403
1593
|
break;
|
|
1404
1594
|
}
|
|
1405
1595
|
/** 刪除掉 if(configerer.DEBUG) {...........} */
|
|
1406
1596
|
this.dropItemsByIndex(stmts, indexOfStart, indexOfEnd);
|
|
1407
1597
|
this.appendFile(tempFilePath, _lodash["default"].join(stmts, "\n"), true, true);
|
|
1408
|
-
|
|
1598
|
+
_context21.next = 21;
|
|
1409
1599
|
return this.executeCommandLine("cd ".concat(_path5["default"].resolve("".concat(this.getFileDirPath(tempFilePath))), " &&\nnpx prettier --write ").concat(tempFilePath));
|
|
1410
1600
|
case 21:
|
|
1411
|
-
|
|
1601
|
+
_context21.next = 10;
|
|
1412
1602
|
break;
|
|
1413
1603
|
case 23:
|
|
1414
|
-
|
|
1604
|
+
_context21.next = 28;
|
|
1415
1605
|
break;
|
|
1416
1606
|
case 25:
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
_iterator10.e(
|
|
1607
|
+
_context21.prev = 25;
|
|
1608
|
+
_context21.t0 = _context21["catch"](8);
|
|
1609
|
+
_iterator10.e(_context21.t0);
|
|
1420
1610
|
case 28:
|
|
1421
|
-
|
|
1611
|
+
_context21.prev = 28;
|
|
1422
1612
|
_iterator10.f();
|
|
1423
|
-
return
|
|
1613
|
+
return _context21.finish(28);
|
|
1424
1614
|
case 31:
|
|
1425
|
-
return
|
|
1615
|
+
return _context21.abrupt("return", tempFolderPath);
|
|
1426
1616
|
case 32:
|
|
1427
1617
|
case "end":
|
|
1428
|
-
return
|
|
1618
|
+
return _context21.stop();
|
|
1429
1619
|
}
|
|
1430
|
-
},
|
|
1620
|
+
}, _callee19, this, [[8, 25, 28, 31]]);
|
|
1431
1621
|
}));
|
|
1432
|
-
function generateTempFolderWithCleanSrc(
|
|
1622
|
+
function generateTempFolderWithCleanSrc(_x19) {
|
|
1433
1623
|
return _generateTempFolderWithCleanSrc.apply(this, arguments);
|
|
1434
1624
|
}
|
|
1435
1625
|
return generateTempFolderWithCleanSrc;
|
|
@@ -1469,6 +1659,5 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1469
1659
|
return document.toString();
|
|
1470
1660
|
}
|
|
1471
1661
|
}]);
|
|
1472
|
-
return NodeUtiller;
|
|
1473
1662
|
}(_index["default"]);
|
|
1474
1663
|
var _default = exports["default"] = NodeUtiller;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "utiller",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.187",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
"uuid": "^8.3.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@babel/cli": "^7.
|
|
31
|
-
"@babel/core": "^7.
|
|
32
|
-
"@babel/plugin-proposal-
|
|
33
|
-
"@babel/plugin-
|
|
34
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
35
|
-
"@babel/preset-env": "^7.
|
|
36
|
-
"@babel/
|
|
30
|
+
"@babel/cli": "^7.24.1",
|
|
31
|
+
"@babel/core": "^7.24.4",
|
|
32
|
+
"@babel/plugin-proposal-decorators": "^7.24.1",
|
|
33
|
+
"@babel/plugin-transform-class-properties": "^7.24.1",
|
|
34
|
+
"@babel/plugin-transform-runtime": "^7.24.3",
|
|
35
|
+
"@babel/preset-env": "^7.24.4",
|
|
36
|
+
"@babel/preset-react": "^7.24.1",
|
|
37
|
+
"@babel/register": "^7.23.7"
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
presets: [
|
|
3
|
-
"@babel/preset-env"
|
|
3
|
+
"@babel/preset-env",
|
|
4
|
+
"@babel/preset-react"
|
|
4
5
|
],
|
|
5
6
|
plugins: [
|
|
6
7
|
[
|
|
@@ -12,7 +13,7 @@ module.exports = {
|
|
|
12
13
|
["@babel/transform-runtime", {
|
|
13
14
|
"regenerator": true
|
|
14
15
|
}],
|
|
15
|
-
["@babel/plugin-
|
|
16
|
+
["@babel/plugin-transform-class-properties"]
|
|
16
17
|
]
|
|
17
18
|
|
|
18
19
|
};
|
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"configerer": "^1.0.11",
|
|
14
|
-
"utiller": "^1.0.
|
|
14
|
+
"utiller": "^1.0.186",
|
|
15
15
|
"linepayer": "^1.0.4",
|
|
16
|
-
"databazer": "^1.0.
|
|
16
|
+
"databazer": "^1.0.12",
|
|
17
17
|
"lodash": "^4.17.20",
|
|
18
18
|
"moment": "^2.29.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@babel/cli": "^7.
|
|
22
|
-
"@babel/core": "^7.
|
|
23
|
-
"@babel/plugin-proposal-
|
|
24
|
-
"@babel/plugin-
|
|
25
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
26
|
-
"@babel/preset-env": "^7.
|
|
27
|
-
"@babel/
|
|
28
|
-
"@babel/
|
|
21
|
+
"@babel/cli": "^7.24.1",
|
|
22
|
+
"@babel/core": "^7.24.4",
|
|
23
|
+
"@babel/plugin-proposal-decorators": "^7.24.1",
|
|
24
|
+
"@babel/plugin-transform-class-properties": "^7.24.1",
|
|
25
|
+
"@babel/plugin-transform-runtime": "^7.24.3",
|
|
26
|
+
"@babel/preset-env": "^7.24.4",
|
|
27
|
+
"@babel/preset-react": "^7.24.1",
|
|
28
|
+
"@babel/register": "^7.23.7"
|
|
29
29
|
}
|
|
30
30
|
}
|