utiller 1.0.49 → 1.0.52
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/utiller/index.js +24 -0
- package/lib/utiller/nodeutiller.js +93 -91
- package/package.json +1 -1
- package/template/sample.package.json +1 -1
package/lib/utiller/index.js
CHANGED
|
@@ -1695,6 +1695,30 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
1695
1695
|
return minor[key] === undefined;
|
|
1696
1696
|
});
|
|
1697
1697
|
}
|
|
1698
|
+
/**
|
|
1699
|
+
*
|
|
1700
|
+
const obj1 = {b:4,c:2};
|
|
1701
|
+
const obj2 = {b:4,c:3};
|
|
1702
|
+
const obj3 = {a:1,b:4,c:3};
|
|
1703
|
+
console.log(util.isObjectContainAndEqual(obj1,obj3)) false
|
|
1704
|
+
console.log(util.isObjectContainAndEqual(obj1,obj3)) true
|
|
1705
|
+
targetObject 是數量比較小那個
|
|
1706
|
+
*/
|
|
1707
|
+
|
|
1708
|
+
}, {
|
|
1709
|
+
key: "isObjectContainAndEqual",
|
|
1710
|
+
value: function isObjectContainAndEqual(targetObject, mainObject) {
|
|
1711
|
+
var equal = true;
|
|
1712
|
+
|
|
1713
|
+
for (var key in targetObject) {
|
|
1714
|
+
if (mainObject[key] === undefined || mainObject[key] !== targetObject[key]) {
|
|
1715
|
+
equal = false;
|
|
1716
|
+
break;
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
return equal;
|
|
1721
|
+
}
|
|
1698
1722
|
}]);
|
|
1699
1723
|
return Utiller;
|
|
1700
1724
|
}();
|
|
@@ -289,6 +289,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
289
289
|
isFile: false,
|
|
290
290
|
isDirectory: true,
|
|
291
291
|
dirName: undefined,
|
|
292
|
+
dirPath: undefined,
|
|
292
293
|
extension: undefined,
|
|
293
294
|
fileName: undefined,
|
|
294
295
|
fileNameExtension: undefined,
|
|
@@ -304,6 +305,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
304
305
|
obj["fileName"] = fileNameStrings.join(".");
|
|
305
306
|
obj["dirName"] = _lodash["default"].nth(absolute.split("/"), -2);
|
|
306
307
|
obj["isFile"] = true;
|
|
308
|
+
obj["dirPath"] = this.getFolderPathOfSpecificPath(absolute);
|
|
307
309
|
obj["isDirectory"] = false;
|
|
308
310
|
obj["fileNameExtension"] = "".concat(obj.fileName, ".").concat(obj.extension);
|
|
309
311
|
obj["lastModifiedTime"] = this.getFileLastModifiedTime(absolute);
|
|
@@ -449,98 +451,124 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
449
451
|
|
|
450
452
|
return deleteSelfByPath;
|
|
451
453
|
}()
|
|
452
|
-
/** absolute=> /acc/bbv/{target}/index.js 檢查有沒有在他下面 */
|
|
453
|
-
|
|
454
454
|
}, {
|
|
455
|
-
key: "
|
|
456
|
-
value: function
|
|
457
|
-
var
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
455
|
+
key: "deleteFileOrFolder",
|
|
456
|
+
value: function () {
|
|
457
|
+
var _deleteFileOrFolder = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(path) {
|
|
458
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
459
|
+
while (1) {
|
|
460
|
+
switch (_context4.prev = _context4.next) {
|
|
461
|
+
case 0:
|
|
462
|
+
this.appendInfo("\u522A\u6389\u4E86 ".concat(path));
|
|
463
|
+
_context4.next = 3;
|
|
464
|
+
return (0, _del["default"])(path);
|
|
461
465
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
466
|
+
case 3:
|
|
467
|
+
case "end":
|
|
468
|
+
return _context4.stop();
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}, _callee4, this);
|
|
472
|
+
}));
|
|
473
|
+
|
|
474
|
+
function deleteFileOrFolder(_x5) {
|
|
475
|
+
return _deleteFileOrFolder.apply(this, arguments);
|
|
467
476
|
}
|
|
468
477
|
|
|
469
|
-
return
|
|
470
|
-
}
|
|
471
|
-
/** 刪掉自己目錄內的孩子, force能夠強制刪除 自己root_dir 以外的path */
|
|
478
|
+
return deleteFileOrFolder;
|
|
479
|
+
}()
|
|
480
|
+
/** 刪掉自己目錄內的孩子, force能夠強制刪除 自己root_dir 以外的path,保留folder的記體體位置 */
|
|
472
481
|
|
|
473
482
|
}, {
|
|
474
483
|
key: "deleteChildByPath",
|
|
475
484
|
value: function () {
|
|
476
|
-
var _deleteChildByPath = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
485
|
+
var _deleteChildByPath = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(path) {
|
|
477
486
|
var force,
|
|
478
487
|
pathes,
|
|
479
488
|
_iterator2,
|
|
480
489
|
_step2,
|
|
481
490
|
_path2,
|
|
482
|
-
|
|
491
|
+
_args5 = arguments;
|
|
483
492
|
|
|
484
|
-
return _regenerator["default"].wrap(function
|
|
493
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
485
494
|
while (1) {
|
|
486
|
-
switch (
|
|
495
|
+
switch (_context5.prev = _context5.next) {
|
|
487
496
|
case 0:
|
|
488
|
-
force =
|
|
497
|
+
force = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : false;
|
|
489
498
|
pathes = this.getChildPathByPath(path);
|
|
490
499
|
_iterator2 = _createForOfIteratorHelper(pathes);
|
|
491
|
-
|
|
500
|
+
_context5.prev = 3;
|
|
492
501
|
|
|
493
502
|
_iterator2.s();
|
|
494
503
|
|
|
495
504
|
case 5:
|
|
496
505
|
if ((_step2 = _iterator2.n()).done) {
|
|
497
|
-
|
|
506
|
+
_context5.next = 11;
|
|
498
507
|
break;
|
|
499
508
|
}
|
|
500
509
|
|
|
501
510
|
_path2 = _step2.value;
|
|
502
|
-
|
|
511
|
+
_context5.next = 9;
|
|
503
512
|
return this.deleteSelfByPath(_path2.absolute, force);
|
|
504
513
|
|
|
505
514
|
case 9:
|
|
506
|
-
|
|
515
|
+
_context5.next = 5;
|
|
507
516
|
break;
|
|
508
517
|
|
|
509
518
|
case 11:
|
|
510
|
-
|
|
519
|
+
_context5.next = 16;
|
|
511
520
|
break;
|
|
512
521
|
|
|
513
522
|
case 13:
|
|
514
|
-
|
|
515
|
-
|
|
523
|
+
_context5.prev = 13;
|
|
524
|
+
_context5.t0 = _context5["catch"](3);
|
|
516
525
|
|
|
517
|
-
_iterator2.e(
|
|
526
|
+
_iterator2.e(_context5.t0);
|
|
518
527
|
|
|
519
528
|
case 16:
|
|
520
|
-
|
|
529
|
+
_context5.prev = 16;
|
|
521
530
|
|
|
522
531
|
_iterator2.f();
|
|
523
532
|
|
|
524
|
-
return
|
|
533
|
+
return _context5.finish(16);
|
|
525
534
|
|
|
526
535
|
case 19:
|
|
527
536
|
case "end":
|
|
528
|
-
return
|
|
537
|
+
return _context5.stop();
|
|
529
538
|
}
|
|
530
539
|
}
|
|
531
|
-
},
|
|
540
|
+
}, _callee5, this, [[3, 13, 16, 19]]);
|
|
532
541
|
}));
|
|
533
542
|
|
|
534
|
-
function deleteChildByPath(
|
|
543
|
+
function deleteChildByPath(_x6) {
|
|
535
544
|
return _deleteChildByPath.apply(this, arguments);
|
|
536
545
|
}
|
|
537
546
|
|
|
538
547
|
return deleteChildByPath;
|
|
539
548
|
}()
|
|
549
|
+
/** absolute=> /acc/bbv/{target}/index.js 檢查有沒有在他下面 */
|
|
550
|
+
|
|
551
|
+
}, {
|
|
552
|
+
key: "isUnderTargetPath",
|
|
553
|
+
value: function isUnderTargetPath(absolute, target) {
|
|
554
|
+
var segments = absolute.split("/");
|
|
555
|
+
return this.has(segments, target);
|
|
556
|
+
}
|
|
557
|
+
/** 取得folder底下的file counts*/
|
|
558
|
+
|
|
559
|
+
}, {
|
|
560
|
+
key: "getFileCountsOfFolder",
|
|
561
|
+
value: function getFileCountsOfFolder(path) {
|
|
562
|
+
if (this.isDirectory(path)) {
|
|
563
|
+
return _fs["default"].readdirSync(path).length;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
return -1;
|
|
567
|
+
}
|
|
540
568
|
}, {
|
|
541
569
|
key: "reinstallNodeModules",
|
|
542
570
|
value: function () {
|
|
543
|
-
var _reinstallNodeModules = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
571
|
+
var _reinstallNodeModules = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|
|
544
572
|
var path,
|
|
545
573
|
_len4,
|
|
546
574
|
exclude,
|
|
@@ -558,16 +586,16 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
558
586
|
_json2,
|
|
559
587
|
_path_module_root,
|
|
560
588
|
_path_gen_node_module,
|
|
561
|
-
|
|
589
|
+
_args6 = arguments;
|
|
562
590
|
|
|
563
|
-
return _regenerator["default"].wrap(function
|
|
591
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
564
592
|
while (1) {
|
|
565
|
-
switch (
|
|
593
|
+
switch (_context6.prev = _context6.next) {
|
|
566
594
|
case 0:
|
|
567
|
-
path =
|
|
595
|
+
path = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : "../";
|
|
568
596
|
|
|
569
|
-
for (_len4 =
|
|
570
|
-
exclude[_key4 - 1] =
|
|
597
|
+
for (_len4 = _args6.length, exclude = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
598
|
+
exclude[_key4 - 1] = _args6[_key4];
|
|
571
599
|
}
|
|
572
600
|
|
|
573
601
|
ex = [].concat(exclude, ["node_modules", "utiller", "configerer"]);
|
|
@@ -577,13 +605,13 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
577
605
|
return _lodash["default"].isEqual(each.fileNameExtension, "package.json");
|
|
578
606
|
}].concat((0, _toConsumableArray2["default"])(ex)));
|
|
579
607
|
_iterator3 = _createForOfIteratorHelper(paths);
|
|
580
|
-
|
|
608
|
+
_context6.prev = 5;
|
|
581
609
|
|
|
582
610
|
_iterator3.s();
|
|
583
611
|
|
|
584
612
|
case 7:
|
|
585
613
|
if ((_step3 = _iterator3.n()).done) {
|
|
586
|
-
|
|
614
|
+
_context6.next = 20;
|
|
587
615
|
break;
|
|
588
616
|
}
|
|
589
617
|
|
|
@@ -591,47 +619,47 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
591
619
|
path_module_root = this.getFileDirPath(_json.absolute);
|
|
592
620
|
path_gen_node_module = "".concat(path_module_root, "node_modules");
|
|
593
621
|
path_lock_json = "".concat(path_module_root, "package-lock.json");
|
|
594
|
-
|
|
622
|
+
_context6.next = 14;
|
|
595
623
|
return (0, _del["default"])(path_lock_json);
|
|
596
624
|
|
|
597
625
|
case 14:
|
|
598
626
|
this.appendInfo("\u522A\u6389\u4E86 ".concat(path_lock_json));
|
|
599
|
-
|
|
627
|
+
_context6.next = 17;
|
|
600
628
|
return (0, _del["default"])(path_gen_node_module);
|
|
601
629
|
|
|
602
630
|
case 17:
|
|
603
631
|
this.appendInfo("\u522A\u6389\u4E86 ".concat(path_gen_node_module));
|
|
604
632
|
|
|
605
633
|
case 18:
|
|
606
|
-
|
|
634
|
+
_context6.next = 7;
|
|
607
635
|
break;
|
|
608
636
|
|
|
609
637
|
case 20:
|
|
610
|
-
|
|
638
|
+
_context6.next = 25;
|
|
611
639
|
break;
|
|
612
640
|
|
|
613
641
|
case 22:
|
|
614
|
-
|
|
615
|
-
|
|
642
|
+
_context6.prev = 22;
|
|
643
|
+
_context6.t0 = _context6["catch"](5);
|
|
616
644
|
|
|
617
|
-
_iterator3.e(
|
|
645
|
+
_iterator3.e(_context6.t0);
|
|
618
646
|
|
|
619
647
|
case 25:
|
|
620
|
-
|
|
648
|
+
_context6.prev = 25;
|
|
621
649
|
|
|
622
650
|
_iterator3.f();
|
|
623
651
|
|
|
624
|
-
return
|
|
652
|
+
return _context6.finish(25);
|
|
625
653
|
|
|
626
654
|
case 28:
|
|
627
655
|
_iterator4 = _createForOfIteratorHelper(paths);
|
|
628
|
-
|
|
656
|
+
_context6.prev = 29;
|
|
629
657
|
|
|
630
658
|
_iterator4.s();
|
|
631
659
|
|
|
632
660
|
case 31:
|
|
633
661
|
if ((_step4 = _iterator4.n()).done) {
|
|
634
|
-
|
|
662
|
+
_context6.next = 40;
|
|
635
663
|
break;
|
|
636
664
|
}
|
|
637
665
|
|
|
@@ -640,40 +668,40 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
640
668
|
_path_gen_node_module = "".concat(_path_module_root, "node_modules");
|
|
641
669
|
|
|
642
670
|
if (_fs["default"].existsSync(_path_gen_node_module)) {
|
|
643
|
-
|
|
671
|
+
_context6.next = 38;
|
|
644
672
|
break;
|
|
645
673
|
}
|
|
646
674
|
|
|
647
|
-
|
|
675
|
+
_context6.next = 38;
|
|
648
676
|
return this.executeCommandLine("cd ".concat(_path_module_root, " && npm install"));
|
|
649
677
|
|
|
650
678
|
case 38:
|
|
651
|
-
|
|
679
|
+
_context6.next = 31;
|
|
652
680
|
break;
|
|
653
681
|
|
|
654
682
|
case 40:
|
|
655
|
-
|
|
683
|
+
_context6.next = 45;
|
|
656
684
|
break;
|
|
657
685
|
|
|
658
686
|
case 42:
|
|
659
|
-
|
|
660
|
-
|
|
687
|
+
_context6.prev = 42;
|
|
688
|
+
_context6.t1 = _context6["catch"](29);
|
|
661
689
|
|
|
662
|
-
_iterator4.e(
|
|
690
|
+
_iterator4.e(_context6.t1);
|
|
663
691
|
|
|
664
692
|
case 45:
|
|
665
|
-
|
|
693
|
+
_context6.prev = 45;
|
|
666
694
|
|
|
667
695
|
_iterator4.f();
|
|
668
696
|
|
|
669
|
-
return
|
|
697
|
+
return _context6.finish(45);
|
|
670
698
|
|
|
671
699
|
case 48:
|
|
672
700
|
case "end":
|
|
673
|
-
return
|
|
701
|
+
return _context6.stop();
|
|
674
702
|
}
|
|
675
703
|
}
|
|
676
|
-
},
|
|
704
|
+
}, _callee6, this, [[5, 22, 25, 28], [29, 42, 45, 48]]);
|
|
677
705
|
}));
|
|
678
706
|
|
|
679
707
|
function reinstallNodeModules() {
|
|
@@ -682,32 +710,6 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
682
710
|
|
|
683
711
|
return reinstallNodeModules;
|
|
684
712
|
}()
|
|
685
|
-
}, {
|
|
686
|
-
key: "deleteFileOrFolder",
|
|
687
|
-
value: function () {
|
|
688
|
-
var _deleteFileOrFolder = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(path) {
|
|
689
|
-
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
690
|
-
while (1) {
|
|
691
|
-
switch (_context6.prev = _context6.next) {
|
|
692
|
-
case 0:
|
|
693
|
-
this.appendInfo("\u522A\u6389\u4E86 ".concat(path));
|
|
694
|
-
_context6.next = 3;
|
|
695
|
-
return (0, _del["default"])(path);
|
|
696
|
-
|
|
697
|
-
case 3:
|
|
698
|
-
case "end":
|
|
699
|
-
return _context6.stop();
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
}, _callee6, this);
|
|
703
|
-
}));
|
|
704
|
-
|
|
705
|
-
function deleteFileOrFolder(_x6) {
|
|
706
|
-
return _deleteFileOrFolder.apply(this, arguments);
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
return deleteFileOrFolder;
|
|
710
|
-
}()
|
|
711
713
|
/** 拿到目錄下的資料夾列表 */
|
|
712
714
|
|
|
713
715
|
}, {
|
package/package.json
CHANGED