utiller 1.0.74 → 1.0.78
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/pooller/index.js +75 -42
- package/lib/utiller/nodeutiller.js +37 -33
- package/package.json +1 -1
- package/template/sample.package.json +1 -1
package/lib/pooller/index.js
CHANGED
|
@@ -37,8 +37,6 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
37
37
|
|
|
38
38
|
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; }
|
|
39
39
|
|
|
40
|
-
var _run = new WeakMap();
|
|
41
|
-
|
|
42
40
|
/**
|
|
43
41
|
*
|
|
44
42
|
Pooller 有以下特點:
|
|
@@ -50,6 +48,10 @@ Pooller 有以下特點:
|
|
|
50
48
|
6.可以設定taskFailHandler, 這樣遇到錯誤就不會停掉poollers
|
|
51
49
|
*
|
|
52
50
|
*/
|
|
51
|
+
var SPECIFICITY_DEBUG = false;
|
|
52
|
+
|
|
53
|
+
var _run = new WeakMap();
|
|
54
|
+
|
|
53
55
|
var InfinitePool = /*#__PURE__*/function () {
|
|
54
56
|
/** 用來處理Task的延遲,假設要偷網頁東西, 不能太頻繁, 要偽裝成手動只能透過這方式, 如果是multi thread, 延遲是針對worker滿載後,再加進去的那一個 */
|
|
55
57
|
|
|
@@ -59,6 +61,8 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
59
61
|
|
|
60
62
|
/** 用於 runByParam */
|
|
61
63
|
|
|
64
|
+
/** runByTimes 的次數 */
|
|
65
|
+
|
|
62
66
|
/** 裡面放 {high:[], low:[], medium }
|
|
63
67
|
* taskQueue就是指裡面有多少Task!
|
|
64
68
|
* 通常Infinite模式,裡面只會有一個asyncTask
|
|
@@ -88,6 +92,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
88
92
|
(0, _defineProperty2["default"])(this, "maxWorker", void 0);
|
|
89
93
|
(0, _defineProperty2["default"])(this, "ignoreFirstRun", false);
|
|
90
94
|
(0, _defineProperty2["default"])(this, "queueOfWaitingParam", []);
|
|
95
|
+
(0, _defineProperty2["default"])(this, "countsOfRunByTimes", -1);
|
|
91
96
|
(0, _defineProperty2["default"])(this, "queueOfAssignTask", {});
|
|
92
97
|
(0, _defineProperty2["default"])(this, "queueOfExecutingTask", []);
|
|
93
98
|
(0, _defineProperty2["default"])(this, "isQueuePolling", false);
|
|
@@ -139,7 +144,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
139
144
|
(0, _defineProperty2["default"])(this, "isRunning", function () {
|
|
140
145
|
return _this.isQueuePolling;
|
|
141
146
|
});
|
|
142
|
-
(0, _defineProperty2["default"])(this, "
|
|
147
|
+
(0, _defineProperty2["default"])(this, "getCountOfAssignTaskInQueue", function () {
|
|
143
148
|
var size = 0;
|
|
144
149
|
if (_this.state === _configerer.configerer.POOLLER_STATE.RUN_BY_PARAMS) return _this.queueOfWaitingParam.length;
|
|
145
150
|
|
|
@@ -196,13 +201,12 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
196
201
|
task.state = "ING";
|
|
197
202
|
}
|
|
198
203
|
});
|
|
199
|
-
(0, _defineProperty2["default"])(this, "taskWrapper", function (assignedTask, hashOfTask) {
|
|
204
|
+
(0, _defineProperty2["default"])(this, "taskWrapper", function (assignedTask, hashOfTask, param) {
|
|
200
205
|
return function () {
|
|
201
206
|
var self = _this;
|
|
202
207
|
var timeoutHash = "";
|
|
203
208
|
var assignedTaskResult;
|
|
204
209
|
var assignedTaskError;
|
|
205
|
-
var param = self.queueOfWaitingParam.shift();
|
|
206
210
|
var isAssignedTaskCompleted = true;
|
|
207
211
|
/** 用來判斷task 有沒有走到 catch裡面, 不然resolve了但return undefined, task會不知所措 */
|
|
208
212
|
|
|
@@ -354,7 +358,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
354
358
|
break;
|
|
355
359
|
}
|
|
356
360
|
|
|
357
|
-
_this.printLogMessage("415123, runInInfinite() \u6B63\u5728\u7121\u9650Loop\u4E2D,".concat(_this.getLogMessageOfExecutingTaskQueueCount()));
|
|
361
|
+
_this.printLogMessage("415123, runInInfinite() \u6B63\u5728\u7121\u9650Loop\u4E2D, ".concat(_this.getLogMessageOfExecutingTaskQueueCount()));
|
|
358
362
|
|
|
359
363
|
_context2.next = 18;
|
|
360
364
|
return (0, _classPrivateFieldGet2["default"])(_this, _run).call(_this);
|
|
@@ -427,7 +431,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
427
431
|
_this.beforeRun();
|
|
428
432
|
|
|
429
433
|
case 9:
|
|
430
|
-
if (!(_this.ruleOfInfiniteRun() &&
|
|
434
|
+
if (!(_this.ruleOfInfiniteRun() && _lodash["default"].size(_this.queueOfWaitingParam) > 0)) {
|
|
431
435
|
_context3.next = 14;
|
|
432
436
|
break;
|
|
433
437
|
}
|
|
@@ -454,9 +458,10 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
454
458
|
(0, _defineProperty2["default"])(this, "runByEachTaskInBackGround", function () {
|
|
455
459
|
if (_this.atomicBgInstance !== undefined) clearTimeout(_this.atomicBgInstance);
|
|
456
460
|
_this.atomicBgInstance = _this.runInBackGround(_this.runByEachTask);
|
|
457
|
-
/**
|
|
458
|
-
*
|
|
459
|
-
*
|
|
461
|
+
/**
|
|
462
|
+
* 因為偷懶, 所以回傳整個instance, 這樣程式碼就只要寫一行
|
|
463
|
+
* const pool = new InfinitePool(1).runByEachTaskInBackGround();
|
|
464
|
+
*/
|
|
460
465
|
|
|
461
466
|
return _this;
|
|
462
467
|
});
|
|
@@ -486,7 +491,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
486
491
|
return (0, _classPrivateFieldGet2["default"])(_this, _run).call(_this, _this.id);
|
|
487
492
|
|
|
488
493
|
case 8:
|
|
489
|
-
if (_this.
|
|
494
|
+
if (_this.getCountOfAssignTaskInQueue() <= 0) {
|
|
490
495
|
_this.terminate();
|
|
491
496
|
|
|
492
497
|
_this.printLogMessage("788121, runByEachTask() \u56E0\u70BA taskOfWaitingQueue \u6E05\u7A7A\u800C\u505C\u6B62");
|
|
@@ -503,13 +508,15 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
503
508
|
}, _callee4);
|
|
504
509
|
})));
|
|
505
510
|
(0, _defineProperty2["default"])(this, "runByTimes", /*#__PURE__*/function () {
|
|
506
|
-
var _ref5 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(functionOfAsyncTask
|
|
507
|
-
var
|
|
511
|
+
var _ref5 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(functionOfAsyncTask) {
|
|
512
|
+
var times,
|
|
513
|
+
_args5 = arguments;
|
|
508
514
|
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
509
515
|
while (1) {
|
|
510
516
|
switch (_context5.prev = _context5.next) {
|
|
511
517
|
case 0:
|
|
512
|
-
|
|
518
|
+
times = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : 1;
|
|
519
|
+
_this.countsOfRunByTimes = times;
|
|
513
520
|
|
|
514
521
|
_this.add(functionOfAsyncTask);
|
|
515
522
|
|
|
@@ -517,11 +524,9 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
517
524
|
|
|
518
525
|
_this.setState(_configerer.configerer.POOLLER_STATE.RUN_BY_TIMES);
|
|
519
526
|
|
|
520
|
-
index = 0;
|
|
521
|
-
|
|
522
527
|
case 5:
|
|
523
|
-
if (!(
|
|
524
|
-
_context5.next =
|
|
528
|
+
if (!(_this.ruleOfInfiniteRun() && _this.countsOfRunByTimes > 0)) {
|
|
529
|
+
_context5.next = 10;
|
|
525
530
|
break;
|
|
526
531
|
}
|
|
527
532
|
|
|
@@ -529,11 +534,10 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
529
534
|
return (0, _classPrivateFieldGet2["default"])(_this, _run).call(_this);
|
|
530
535
|
|
|
531
536
|
case 8:
|
|
532
|
-
index++;
|
|
533
537
|
_context5.next = 5;
|
|
534
538
|
break;
|
|
535
539
|
|
|
536
|
-
case
|
|
540
|
+
case 10:
|
|
537
541
|
case "end":
|
|
538
542
|
return _context5.stop();
|
|
539
543
|
}
|
|
@@ -541,7 +545,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
541
545
|
}, _callee5);
|
|
542
546
|
}));
|
|
543
547
|
|
|
544
|
-
return function (_x2
|
|
548
|
+
return function (_x2) {
|
|
545
549
|
return _ref5.apply(this, arguments);
|
|
546
550
|
};
|
|
547
551
|
}());
|
|
@@ -600,7 +604,29 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
600
604
|
};
|
|
601
605
|
_this.handlerOfAssignTaskFail = listener;
|
|
602
606
|
});
|
|
607
|
+
(0, _defineProperty2["default"])(this, "rulesOfAppendToExecutingTask", function () {
|
|
608
|
+
switch (_this.state) {
|
|
609
|
+
case _configerer.configerer.POOLLER_STATE.RUN_BY_EACH_TASK:
|
|
610
|
+
return _this.isRunning() && !_this.isExecutingQueueFull() && _this.getCountOfAssignTaskInQueue() > 0;
|
|
611
|
+
|
|
612
|
+
case _configerer.configerer.POOLLER_STATE.RUN_BY_PARAMS:
|
|
613
|
+
return _this.isRunning() && !_this.isExecutingQueueFull() && _lodash["default"].size(_this.queueOfWaitingParam) > 0;
|
|
614
|
+
|
|
615
|
+
case _configerer.configerer.POOLLER_STATE.RUN_BY_TIMES:
|
|
616
|
+
return _this.isRunning() && !_this.isExecutingQueueFull() && _this.countsOfRunByTimes > 0;
|
|
617
|
+
|
|
618
|
+
case _configerer.configerer.POOLLER_STATE.RUN_INFINITE:
|
|
619
|
+
return _this.isRunning() && !_this.isExecutingQueueFull();
|
|
620
|
+
|
|
621
|
+
default:
|
|
622
|
+
throw new _exceptioner["default"](4005, "this.state ==> ".concat(_this.state));
|
|
623
|
+
}
|
|
624
|
+
});
|
|
603
625
|
(0, _defineProperty2["default"])(this, "appendTaskToExecuteQueue", function (hash, promise) {
|
|
626
|
+
if (_lodash["default"].isEqual(_this.state, _configerer.configerer.POOLLER_STATE.RUN_BY_TIMES)) {
|
|
627
|
+
_this.countsOfRunByTimes = _this.countsOfRunByTimes - 1;
|
|
628
|
+
}
|
|
629
|
+
|
|
604
630
|
var task = {
|
|
605
631
|
state: "NOT",
|
|
606
632
|
hash: hash,
|
|
@@ -620,7 +646,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
620
646
|
(0, _defineProperty2["default"])(this, "showState", function () {
|
|
621
647
|
_index2.utiller.appendInfo(_this.getPoollerLogFormat("workerCount: ".concat(_this.maxWorker)));
|
|
622
648
|
|
|
623
|
-
_index2.utiller.appendInfo(_this.getPoollerLogFormat("taskQueue(\u9084\u5728\u6392\u968A\u7684Task): ".concat(_this.
|
|
649
|
+
_index2.utiller.appendInfo(_this.getPoollerLogFormat("taskQueue(\u9084\u5728\u6392\u968A\u7684Task): ".concat(_this.getCountOfAssignTaskInQueue())));
|
|
624
650
|
|
|
625
651
|
_index2.utiller.appendInfo(_this.getPoollerLogFormat("QueueOfExecutingTask(\u6B63\u5728\u57F7\u884C\u7684AsyncTask, \u8D85\u904EworkerCount\u5C31\u662Fbug): ".concat(_lodash["default"].size(_this.queueOfExecutingTask))));
|
|
626
652
|
|
|
@@ -840,7 +866,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
840
866
|
infos[_key5 - 2] = arguments[_key5];
|
|
841
867
|
}
|
|
842
868
|
|
|
843
|
-
_index2.utiller.printLogMessage.apply(_index2.utiller, [this.getPoollerLogFormat(message), error].concat(infos));
|
|
869
|
+
if (SPECIFICITY_DEBUG) _index2.utiller.printLogMessage.apply(_index2.utiller, [this.getPoollerLogFormat(message), error].concat(infos));
|
|
844
870
|
}
|
|
845
871
|
/** return true if task completed, after 15 secs, force leave
|
|
846
872
|
* TODO:應該要設計成當terminate後, 監聽executingTaskInQueue為零時,回傳結束 */
|
|
@@ -924,7 +950,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
924
950
|
}, _callee9, this);
|
|
925
951
|
}));
|
|
926
952
|
|
|
927
|
-
function addTaskAndWait4Result(
|
|
953
|
+
function addTaskAndWait4Result(_x3) {
|
|
928
954
|
return _addTaskAndWait4Result.apply(this, arguments);
|
|
929
955
|
}
|
|
930
956
|
|
|
@@ -1034,7 +1060,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1034
1060
|
}, {
|
|
1035
1061
|
key: "isTaskQueueEmpty",
|
|
1036
1062
|
value: function isTaskQueueEmpty() {
|
|
1037
|
-
return this.
|
|
1063
|
+
return this.getCountOfAssignTaskInQueue() === 0;
|
|
1038
1064
|
}
|
|
1039
1065
|
/** 依照config 把委託任務放置到Queue裡面 */
|
|
1040
1066
|
|
|
@@ -1062,7 +1088,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1062
1088
|
this.printLogMessage("4484121, \u8D70\u5230\u4E00\u5761\u7761\u89BA\u5340 enableOfTaskSleepByInterval:".concat(this.enableOfTaskSleepByInterval, " || ").concat(restInInterval, " ms"));
|
|
1063
1089
|
|
|
1064
1090
|
case 6:
|
|
1065
|
-
if (!
|
|
1091
|
+
if (!this.rulesOfAppendToExecutingTask()) {
|
|
1066
1092
|
_context10.next = 18;
|
|
1067
1093
|
break;
|
|
1068
1094
|
}
|
|
@@ -1074,17 +1100,18 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1074
1100
|
break;
|
|
1075
1101
|
}
|
|
1076
1102
|
|
|
1077
|
-
promise = this.taskWrapper(taskInfo.task, taskInfo.hash);
|
|
1103
|
+
promise = this.taskWrapper(taskInfo.task, taskInfo.hash, this.queueOfWaitingParam.shift());
|
|
1078
1104
|
this.removeTaskMapByHash(taskInfo.hash);
|
|
1079
1105
|
this.appendTaskToExecuteQueue(taskInfo.hash, promise);
|
|
1080
|
-
_context10.next =
|
|
1106
|
+
_context10.next = 16;
|
|
1081
1107
|
break;
|
|
1082
1108
|
|
|
1083
1109
|
case 14:
|
|
1110
|
+
/** 沒有taskInfo, 也許有未知的isssue,保險起見break */
|
|
1111
|
+
this.printLogMessage("848451 \u4E5F\u8A31\u6709\u672A\u77E5\u7684isssue,\u4FDD\u96AA\u8D77\u898Bbreak,\u662F\u4E0D\u662F\u5728\u9019\u88E1\u7121\u9650\u8FF4\u5708\u8DD1\u8DD1\u8DD1", true);
|
|
1084
1112
|
return _context10.abrupt("break", 18);
|
|
1085
1113
|
|
|
1086
|
-
case
|
|
1087
|
-
this.printLogMessage("848451 \u662F\u4E0D\u662F\u5728\u9019\u88E1\u7121\u9650\u8FF4\u5708\u8DD1\u8DD1\u8DD1", true);
|
|
1114
|
+
case 16:
|
|
1088
1115
|
_context10.next = 6;
|
|
1089
1116
|
break;
|
|
1090
1117
|
|
|
@@ -1102,6 +1129,8 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1102
1129
|
|
|
1103
1130
|
return syncTaskDispatcher;
|
|
1104
1131
|
}()
|
|
1132
|
+
/** 把assignedTask 加入到 QueueOfExecutingTask 的規則*/
|
|
1133
|
+
|
|
1105
1134
|
}, {
|
|
1106
1135
|
key: "isWait4ResultTask",
|
|
1107
1136
|
value:
|
|
@@ -1375,9 +1404,10 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1375
1404
|
while (1) {
|
|
1376
1405
|
switch (_context20.prev = _context20.next) {
|
|
1377
1406
|
case 0:
|
|
1378
|
-
pool = new InfinitePool(
|
|
1407
|
+
pool = new InfinitePool(5);
|
|
1379
1408
|
pool.runByParamInBackground( /*#__PURE__*/function () {
|
|
1380
1409
|
var _ref11 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee19(param) {
|
|
1410
|
+
var ms;
|
|
1381
1411
|
return _regenerator["default"].wrap(function _callee19$(_context19) {
|
|
1382
1412
|
while (1) {
|
|
1383
1413
|
switch (_context19.prev = _context19.next) {
|
|
@@ -1386,9 +1416,10 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1386
1416
|
return _index2.utiller.syncDelayRandom();
|
|
1387
1417
|
|
|
1388
1418
|
case 2:
|
|
1389
|
-
|
|
1419
|
+
ms = _context19.sent;
|
|
1420
|
+
console.log("wait ".concat(ms, " ms"), "param", param);
|
|
1390
1421
|
|
|
1391
|
-
case
|
|
1422
|
+
case 4:
|
|
1392
1423
|
case "end":
|
|
1393
1424
|
return _context19.stop();
|
|
1394
1425
|
}
|
|
@@ -1396,7 +1427,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1396
1427
|
}, _callee19);
|
|
1397
1428
|
}));
|
|
1398
1429
|
|
|
1399
|
-
return function (
|
|
1430
|
+
return function (_x4) {
|
|
1400
1431
|
return _ref11.apply(this, arguments);
|
|
1401
1432
|
};
|
|
1402
1433
|
}(), "david", "susan", "golden", "weber", "kevin");
|
|
@@ -1439,9 +1470,10 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1439
1470
|
while (1) {
|
|
1440
1471
|
switch (_context22.prev = _context22.next) {
|
|
1441
1472
|
case 0:
|
|
1442
|
-
pool = new InfinitePool(
|
|
1473
|
+
pool = new InfinitePool(6);
|
|
1443
1474
|
count = 0;
|
|
1444
1475
|
pool.runByTimesInBackground( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee21() {
|
|
1476
|
+
var ms;
|
|
1445
1477
|
return _regenerator["default"].wrap(function _callee21$(_context21) {
|
|
1446
1478
|
while (1) {
|
|
1447
1479
|
switch (_context21.prev = _context21.next) {
|
|
@@ -1450,16 +1482,17 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1450
1482
|
return _index2.utiller.syncDelayRandom();
|
|
1451
1483
|
|
|
1452
1484
|
case 2:
|
|
1485
|
+
ms = _context21.sent;
|
|
1453
1486
|
count++;
|
|
1454
|
-
console.log("
|
|
1487
|
+
console.log("wait for time: ".concat(ms, " ms, count:").concat(count));
|
|
1455
1488
|
|
|
1456
|
-
case
|
|
1489
|
+
case 5:
|
|
1457
1490
|
case "end":
|
|
1458
1491
|
return _context21.stop();
|
|
1459
1492
|
}
|
|
1460
1493
|
}
|
|
1461
1494
|
}, _callee21);
|
|
1462
|
-
})),
|
|
1495
|
+
})), 20);
|
|
1463
1496
|
|
|
1464
1497
|
case 3:
|
|
1465
1498
|
if (!pool.isRunning()) {
|
|
@@ -1500,7 +1533,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1500
1533
|
switch (_context24.prev = _context24.next) {
|
|
1501
1534
|
case 0:
|
|
1502
1535
|
oneToTen = _lodash["default"].range(1, 10);
|
|
1503
|
-
pool = new InfinitePool(
|
|
1536
|
+
pool = new InfinitePool(5);
|
|
1504
1537
|
_context24.next = 4;
|
|
1505
1538
|
return pool.runByParams.apply(pool, [/*#__PURE__*/function () {
|
|
1506
1539
|
var _ref13 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee23(param) {
|
|
@@ -1524,7 +1557,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1524
1557
|
}, _callee23);
|
|
1525
1558
|
}));
|
|
1526
1559
|
|
|
1527
|
-
return function (
|
|
1560
|
+
return function (_x5) {
|
|
1528
1561
|
return _ref13.apply(this, arguments);
|
|
1529
1562
|
};
|
|
1530
1563
|
}()].concat((0, _toConsumableArray2["default"])(oneToTen)));
|
|
@@ -1555,7 +1588,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1555
1588
|
pool = new InfinitePool(1);
|
|
1556
1589
|
time = 0;
|
|
1557
1590
|
_context26.next = 4;
|
|
1558
|
-
return pool.runByTimes(
|
|
1591
|
+
return pool.runByTimes( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee25() {
|
|
1559
1592
|
return _regenerator["default"].wrap(function _callee25$(_context25) {
|
|
1560
1593
|
while (1) {
|
|
1561
1594
|
switch (_context25.prev = _context25.next) {
|
|
@@ -1573,7 +1606,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
1573
1606
|
}
|
|
1574
1607
|
}
|
|
1575
1608
|
}, _callee25);
|
|
1576
|
-
})));
|
|
1609
|
+
})), 20);
|
|
1577
1610
|
|
|
1578
1611
|
case 4:
|
|
1579
1612
|
case "end":
|
|
@@ -1192,7 +1192,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1192
1192
|
switch (_context11.prev = _context11.next) {
|
|
1193
1193
|
case 0:
|
|
1194
1194
|
path = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : "./";
|
|
1195
|
-
deployToNPMServer = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] :
|
|
1195
|
+
deployToNPMServer = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : false;
|
|
1196
1196
|
packagejsons = this.findFilePathByExtension(path, ["json"], "node_modules", "release");
|
|
1197
1197
|
packagejsons = _lodash["default"].filter(packagejsons, function (each) {
|
|
1198
1198
|
return _lodash["default"].isEqual(each.fileName, "package");
|
|
@@ -1208,7 +1208,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1208
1208
|
_iterator8 = _createForOfIteratorHelper(packagejsons);
|
|
1209
1209
|
_context11.prev = 7;
|
|
1210
1210
|
_loop = /*#__PURE__*/_regenerator["default"].mark(function _loop() {
|
|
1211
|
-
var path, tempFolderPath, release, pathOfPackageJson, indexFileName, templatePath, _yield$_this8$upgrade,
|
|
1211
|
+
var path, tempFolderPath, release, pathOfPackageJson, indexFileName, templatePath, _yield$_this8$upgrade, moduleName, version;
|
|
1212
1212
|
|
|
1213
1213
|
return _regenerator["default"].wrap(function _loop$(_context10) {
|
|
1214
1214
|
while (1) {
|
|
@@ -1221,7 +1221,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1221
1221
|
return !_this8.has(path, projectName);
|
|
1222
1222
|
};
|
|
1223
1223
|
})))) {
|
|
1224
|
-
_context10.next =
|
|
1224
|
+
_context10.next = 40;
|
|
1225
1225
|
break;
|
|
1226
1226
|
}
|
|
1227
1227
|
|
|
@@ -1253,67 +1253,71 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1253
1253
|
if (_this8.isPathExist(templatePath)) {
|
|
1254
1254
|
_this8.copyFromFolderToDestFolder(templatePath, _this8.persistByPath(_path5["default"].join(release, "template")));
|
|
1255
1255
|
}
|
|
1256
|
-
/** 把package.json 放進去 */
|
|
1257
1256
|
|
|
1257
|
+
if (!deployToNPMServer) {
|
|
1258
|
+
_context10.next = 22;
|
|
1259
|
+
break;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
_context10.next = 17;
|
|
1263
|
+
return _this8.upgradePackageJsonVersion(pathOfPackageJson);
|
|
1258
1264
|
|
|
1265
|
+
case 17:
|
|
1266
|
+
_yield$_this8$upgrade = _context10.sent;
|
|
1267
|
+
moduleName = _yield$_this8$upgrade.moduleName;
|
|
1268
|
+
version = _yield$_this8$upgrade.version;
|
|
1269
|
+
_context10.next = 22;
|
|
1270
|
+
return _this8.updateVersionOfTemplate(moduleName, version);
|
|
1271
|
+
|
|
1272
|
+
case 22:
|
|
1273
|
+
/** 把package.json release放進去 */
|
|
1259
1274
|
_this8.copySingleFile(pathOfPackageJson, _path5["default"].join(release, "package.json"), undefined, true);
|
|
1260
1275
|
/** 安裝一個沒有devDependency 的node_module */
|
|
1261
1276
|
|
|
1262
1277
|
|
|
1263
|
-
_context10.next =
|
|
1278
|
+
_context10.next = 25;
|
|
1264
1279
|
return _this8.executeCommandLine("\ncd ".concat(release, " && yarn install --production"));
|
|
1265
1280
|
|
|
1266
|
-
case
|
|
1281
|
+
case 25:
|
|
1267
1282
|
_this8.appendInfo("build ".concat(path, " succeed"));
|
|
1268
1283
|
/** 部署到 local server*/
|
|
1269
1284
|
|
|
1270
1285
|
|
|
1271
1286
|
if (!deployToNPMServer) {
|
|
1272
|
-
_context10.next =
|
|
1287
|
+
_context10.next = 29;
|
|
1273
1288
|
break;
|
|
1274
1289
|
}
|
|
1275
1290
|
|
|
1276
|
-
_context10.next =
|
|
1277
|
-
return _this8.upgradePackageJsonVersion(pathOfPackageJson);
|
|
1278
|
-
|
|
1279
|
-
case 21:
|
|
1280
|
-
_yield$_this8$upgrade = _context10.sent;
|
|
1281
|
-
name = _yield$_this8$upgrade.name;
|
|
1282
|
-
version = _yield$_this8$upgrade.version;
|
|
1283
|
-
_context10.next = 26;
|
|
1291
|
+
_context10.next = 29;
|
|
1284
1292
|
return _this8.executeCommandLine("cd ".concat(release, " && npm publish"));
|
|
1285
1293
|
|
|
1286
|
-
case
|
|
1287
|
-
_context10.next =
|
|
1288
|
-
return _this8.updateVersionOfTemplate(name, version);
|
|
1289
|
-
|
|
1290
|
-
case 28:
|
|
1291
|
-
_context10.next = 35;
|
|
1294
|
+
case 29:
|
|
1295
|
+
_context10.next = 36;
|
|
1292
1296
|
break;
|
|
1293
1297
|
|
|
1294
|
-
case
|
|
1295
|
-
_context10.prev =
|
|
1298
|
+
case 31:
|
|
1299
|
+
_context10.prev = 31;
|
|
1296
1300
|
_context10.t0 = _context10["catch"](9);
|
|
1297
|
-
_context10.next =
|
|
1301
|
+
_context10.next = 35;
|
|
1298
1302
|
return _this8.deleteSelfByPath(release, true);
|
|
1299
1303
|
|
|
1300
|
-
case
|
|
1304
|
+
case 35:
|
|
1301
1305
|
throw new _index2["default"](9999, "generatePackage \u5831\u932F, ".concat(_context10.t0.message));
|
|
1302
1306
|
|
|
1303
|
-
case
|
|
1304
|
-
_context10.prev =
|
|
1305
|
-
_context10.next =
|
|
1307
|
+
case 36:
|
|
1308
|
+
_context10.prev = 36;
|
|
1309
|
+
_context10.next = 39;
|
|
1306
1310
|
return _this8.deleteSelfByPath(tempFolderPath, true);
|
|
1307
1311
|
|
|
1308
|
-
case 38:
|
|
1309
|
-
return _context10.finish(35);
|
|
1310
|
-
|
|
1311
1312
|
case 39:
|
|
1313
|
+
return _context10.finish(36);
|
|
1314
|
+
|
|
1315
|
+
case 40:
|
|
1312
1316
|
case "end":
|
|
1313
1317
|
return _context10.stop();
|
|
1314
1318
|
}
|
|
1315
1319
|
}
|
|
1316
|
-
}, _loop, null, [[9,
|
|
1320
|
+
}, _loop, null, [[9, 31, 36, 40]]);
|
|
1317
1321
|
});
|
|
1318
1322
|
|
|
1319
1323
|
_iterator8.s();
|
|
@@ -1630,7 +1634,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1630
1634
|
case 8:
|
|
1631
1635
|
return _context16.abrupt("return", {
|
|
1632
1636
|
version: json.version,
|
|
1633
|
-
|
|
1637
|
+
moduleName: json.name
|
|
1634
1638
|
});
|
|
1635
1639
|
|
|
1636
1640
|
case 11:
|
package/package.json
CHANGED