utiller 1.0.280 → 1.0.282
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/nodeutiller.js +157 -150
- package/package.json +1 -1
- package/template/sample.package.json +1 -1
|
@@ -18,6 +18,7 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
18
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
19
|
var _path5 = _interopRequireDefault(require("path"));
|
|
20
20
|
var _fs = _interopRequireDefault(require("fs"));
|
|
21
|
+
var _promises = _interopRequireDefault(require("fs/promises"));
|
|
21
22
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
22
23
|
var _child_process = _interopRequireDefault(require("child_process"));
|
|
23
24
|
var _configerer = require("configerer");
|
|
@@ -138,35 +139,6 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
138
139
|
return _ref.apply(this, arguments);
|
|
139
140
|
};
|
|
140
141
|
}());
|
|
141
|
-
/** 重複讀取file IO時,要用這個方式,不然IO太吃資源了 */
|
|
142
|
-
(0, _defineProperty2["default"])(_this, "readFileContentByPath", /*#__PURE__*/function () {
|
|
143
|
-
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(path, object) {
|
|
144
|
-
var result;
|
|
145
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
146
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
147
|
-
case 0:
|
|
148
|
-
if (!object[path]) {
|
|
149
|
-
_context2.next = 4;
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
return _context2.abrupt("return", object[path]);
|
|
153
|
-
case 4:
|
|
154
|
-
_context2.next = 6;
|
|
155
|
-
return _fs["default"].readFile(path, "utf-8");
|
|
156
|
-
case 6:
|
|
157
|
-
result = _context2.sent;
|
|
158
|
-
object[path] = result;
|
|
159
|
-
return _context2.abrupt("return", result);
|
|
160
|
-
case 9:
|
|
161
|
-
case "end":
|
|
162
|
-
return _context2.stop();
|
|
163
|
-
}
|
|
164
|
-
}, _callee2);
|
|
165
|
-
}));
|
|
166
|
-
return function (_x2, _x3) {
|
|
167
|
-
return _ref2.apply(this, arguments);
|
|
168
|
-
};
|
|
169
|
-
}());
|
|
170
142
|
return _this;
|
|
171
143
|
}
|
|
172
144
|
(0, _inherits2["default"])(NodeUtiller, _Utiller);
|
|
@@ -185,22 +157,22 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
185
157
|
}, {
|
|
186
158
|
key: "getPDFText",
|
|
187
159
|
value: (function () {
|
|
188
|
-
var _getPDFText = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
160
|
+
var _getPDFText = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(path) {
|
|
189
161
|
var dataBuffer;
|
|
190
|
-
return _regenerator["default"].wrap(function
|
|
191
|
-
while (1) switch (
|
|
162
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
163
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
192
164
|
case 0:
|
|
193
165
|
dataBuffer = _fs["default"].readFileSync(path);
|
|
194
|
-
return
|
|
166
|
+
return _context2.abrupt("return", (0, _pdfParse["default"])(dataBuffer).then(function (data) {
|
|
195
167
|
return data;
|
|
196
168
|
}));
|
|
197
169
|
case 2:
|
|
198
170
|
case "end":
|
|
199
|
-
return
|
|
171
|
+
return _context2.stop();
|
|
200
172
|
}
|
|
201
|
-
},
|
|
173
|
+
}, _callee2);
|
|
202
174
|
}));
|
|
203
|
-
function getPDFText(
|
|
175
|
+
function getPDFText(_x2) {
|
|
204
176
|
return _getPDFText.apply(this, arguments);
|
|
205
177
|
}
|
|
206
178
|
return getPDFText;
|
|
@@ -354,16 +326,16 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
354
326
|
}, {
|
|
355
327
|
key: "deleteSelfByPath",
|
|
356
328
|
value: (function () {
|
|
357
|
-
var _deleteSelfByPath = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
358
|
-
return _regenerator["default"].wrap(function
|
|
359
|
-
while (1) switch (
|
|
329
|
+
var _deleteSelfByPath = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(path, force) {
|
|
330
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
331
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
360
332
|
case 0:
|
|
361
333
|
if (!_fs["default"].existsSync(path)) {
|
|
362
|
-
|
|
334
|
+
_context3.next = 5;
|
|
363
335
|
break;
|
|
364
336
|
}
|
|
365
337
|
this.appendInfo("\u6E96\u5099\u522A\u6389 ".concat(path, ",{force:").concat(force, "}"));
|
|
366
|
-
|
|
338
|
+
_context3.next = 4;
|
|
367
339
|
return (0, _del["default"])(path, {
|
|
368
340
|
force: force
|
|
369
341
|
});
|
|
@@ -371,11 +343,11 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
371
343
|
this.appendInfo("\u6210\u529F\u522A\u6389\u4E86 ".concat(path));
|
|
372
344
|
case 5:
|
|
373
345
|
case "end":
|
|
374
|
-
return
|
|
346
|
+
return _context3.stop();
|
|
375
347
|
}
|
|
376
|
-
},
|
|
348
|
+
}, _callee3, this);
|
|
377
349
|
}));
|
|
378
|
-
function deleteSelfByPath(
|
|
350
|
+
function deleteSelfByPath(_x3, _x4) {
|
|
379
351
|
return _deleteSelfByPath.apply(this, arguments);
|
|
380
352
|
}
|
|
381
353
|
return deleteSelfByPath;
|
|
@@ -383,20 +355,20 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
383
355
|
}, {
|
|
384
356
|
key: "deleteFileOrFolder",
|
|
385
357
|
value: function () {
|
|
386
|
-
var _deleteFileOrFolder = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
387
|
-
return _regenerator["default"].wrap(function
|
|
388
|
-
while (1) switch (
|
|
358
|
+
var _deleteFileOrFolder = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(path) {
|
|
359
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
360
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
389
361
|
case 0:
|
|
390
362
|
this.appendInfo("\u522A\u6389\u4E86 ".concat(path));
|
|
391
|
-
|
|
363
|
+
_context4.next = 3;
|
|
392
364
|
return (0, _del["default"])(path);
|
|
393
365
|
case 3:
|
|
394
366
|
case "end":
|
|
395
|
-
return
|
|
367
|
+
return _context4.stop();
|
|
396
368
|
}
|
|
397
|
-
},
|
|
369
|
+
}, _callee4, this);
|
|
398
370
|
}));
|
|
399
|
-
function deleteFileOrFolder(
|
|
371
|
+
function deleteFileOrFolder(_x5) {
|
|
400
372
|
return _deleteFileOrFolder.apply(this, arguments);
|
|
401
373
|
}
|
|
402
374
|
return deleteFileOrFolder;
|
|
@@ -404,50 +376,50 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
404
376
|
}, {
|
|
405
377
|
key: "deleteChildByPath",
|
|
406
378
|
value: (function () {
|
|
407
|
-
var _deleteChildByPath = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
379
|
+
var _deleteChildByPath = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(path) {
|
|
408
380
|
var force,
|
|
409
381
|
pathes,
|
|
410
382
|
_iterator2,
|
|
411
383
|
_step2,
|
|
412
384
|
_path2,
|
|
413
|
-
|
|
414
|
-
return _regenerator["default"].wrap(function
|
|
415
|
-
while (1) switch (
|
|
385
|
+
_args5 = arguments;
|
|
386
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
387
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
416
388
|
case 0:
|
|
417
|
-
force =
|
|
389
|
+
force = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : false;
|
|
418
390
|
pathes = this.getChildPathByPath(path);
|
|
419
391
|
_iterator2 = _createForOfIteratorHelper(pathes);
|
|
420
|
-
|
|
392
|
+
_context5.prev = 3;
|
|
421
393
|
_iterator2.s();
|
|
422
394
|
case 5:
|
|
423
395
|
if ((_step2 = _iterator2.n()).done) {
|
|
424
|
-
|
|
396
|
+
_context5.next = 11;
|
|
425
397
|
break;
|
|
426
398
|
}
|
|
427
399
|
_path2 = _step2.value;
|
|
428
|
-
|
|
400
|
+
_context5.next = 9;
|
|
429
401
|
return this.deleteSelfByPath(_path2.absolute, force);
|
|
430
402
|
case 9:
|
|
431
|
-
|
|
403
|
+
_context5.next = 5;
|
|
432
404
|
break;
|
|
433
405
|
case 11:
|
|
434
|
-
|
|
406
|
+
_context5.next = 16;
|
|
435
407
|
break;
|
|
436
408
|
case 13:
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
_iterator2.e(
|
|
409
|
+
_context5.prev = 13;
|
|
410
|
+
_context5.t0 = _context5["catch"](3);
|
|
411
|
+
_iterator2.e(_context5.t0);
|
|
440
412
|
case 16:
|
|
441
|
-
|
|
413
|
+
_context5.prev = 16;
|
|
442
414
|
_iterator2.f();
|
|
443
|
-
return
|
|
415
|
+
return _context5.finish(16);
|
|
444
416
|
case 19:
|
|
445
417
|
case "end":
|
|
446
|
-
return
|
|
418
|
+
return _context5.stop();
|
|
447
419
|
}
|
|
448
|
-
},
|
|
420
|
+
}, _callee5, this, [[3, 13, 16, 19]]);
|
|
449
421
|
}));
|
|
450
|
-
function deleteChildByPath(
|
|
422
|
+
function deleteChildByPath(_x6) {
|
|
451
423
|
return _deleteChildByPath.apply(this, arguments);
|
|
452
424
|
}
|
|
453
425
|
return deleteChildByPath;
|
|
@@ -463,7 +435,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
463
435
|
}, {
|
|
464
436
|
key: "reinstallNodeModules",
|
|
465
437
|
value: function () {
|
|
466
|
-
var _reinstallNodeModules = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
438
|
+
var _reinstallNodeModules = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|
|
467
439
|
var path,
|
|
468
440
|
_len4,
|
|
469
441
|
exclude,
|
|
@@ -481,13 +453,13 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
481
453
|
_json2,
|
|
482
454
|
_path_module_root,
|
|
483
455
|
_path_gen_node_module,
|
|
484
|
-
|
|
485
|
-
return _regenerator["default"].wrap(function
|
|
486
|
-
while (1) switch (
|
|
456
|
+
_args6 = arguments;
|
|
457
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
458
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
487
459
|
case 0:
|
|
488
|
-
path =
|
|
489
|
-
for (_len4 =
|
|
490
|
-
exclude[_key4 - 1] =
|
|
460
|
+
path = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : "../";
|
|
461
|
+
for (_len4 = _args6.length, exclude = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
462
|
+
exclude[_key4 - 1] = _args6[_key4];
|
|
491
463
|
}
|
|
492
464
|
ex = [].concat(exclude, ["node_modules", "utiller", "configerer"]);
|
|
493
465
|
/** utiller 不能刪掉,不然就爆了, configer是他的依賴也不能刪 */
|
|
@@ -495,76 +467,76 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
495
467
|
return _lodash["default"].isEqual(each.fileNameExtension, "package.json");
|
|
496
468
|
}].concat((0, _toConsumableArray2["default"])(ex)));
|
|
497
469
|
_iterator3 = _createForOfIteratorHelper(paths);
|
|
498
|
-
|
|
470
|
+
_context6.prev = 5;
|
|
499
471
|
_iterator3.s();
|
|
500
472
|
case 7:
|
|
501
473
|
if ((_step3 = _iterator3.n()).done) {
|
|
502
|
-
|
|
474
|
+
_context6.next = 20;
|
|
503
475
|
break;
|
|
504
476
|
}
|
|
505
477
|
_json = _step3.value;
|
|
506
478
|
path_module_root = this.getFileDirPath(_json.absolute);
|
|
507
479
|
path_gen_node_module = "".concat(path_module_root, "node_modules");
|
|
508
480
|
path_lock_json = "".concat(path_module_root, "package-lock.json");
|
|
509
|
-
|
|
481
|
+
_context6.next = 14;
|
|
510
482
|
return (0, _del["default"])(path_lock_json);
|
|
511
483
|
case 14:
|
|
512
484
|
this.appendInfo("\u522A\u6389\u4E86 ".concat(path_lock_json));
|
|
513
|
-
|
|
485
|
+
_context6.next = 17;
|
|
514
486
|
return (0, _del["default"])(path_gen_node_module);
|
|
515
487
|
case 17:
|
|
516
488
|
this.appendInfo("\u522A\u6389\u4E86 ".concat(path_gen_node_module));
|
|
517
489
|
case 18:
|
|
518
|
-
|
|
490
|
+
_context6.next = 7;
|
|
519
491
|
break;
|
|
520
492
|
case 20:
|
|
521
|
-
|
|
493
|
+
_context6.next = 25;
|
|
522
494
|
break;
|
|
523
495
|
case 22:
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
_iterator3.e(
|
|
496
|
+
_context6.prev = 22;
|
|
497
|
+
_context6.t0 = _context6["catch"](5);
|
|
498
|
+
_iterator3.e(_context6.t0);
|
|
527
499
|
case 25:
|
|
528
|
-
|
|
500
|
+
_context6.prev = 25;
|
|
529
501
|
_iterator3.f();
|
|
530
|
-
return
|
|
502
|
+
return _context6.finish(25);
|
|
531
503
|
case 28:
|
|
532
504
|
_iterator4 = _createForOfIteratorHelper(paths);
|
|
533
|
-
|
|
505
|
+
_context6.prev = 29;
|
|
534
506
|
_iterator4.s();
|
|
535
507
|
case 31:
|
|
536
508
|
if ((_step4 = _iterator4.n()).done) {
|
|
537
|
-
|
|
509
|
+
_context6.next = 40;
|
|
538
510
|
break;
|
|
539
511
|
}
|
|
540
512
|
_json2 = _step4.value;
|
|
541
513
|
_path_module_root = this.getFileDirPath(_json2.absolute);
|
|
542
514
|
_path_gen_node_module = "".concat(_path_module_root, "node_modules");
|
|
543
515
|
if (_fs["default"].existsSync(_path_gen_node_module)) {
|
|
544
|
-
|
|
516
|
+
_context6.next = 38;
|
|
545
517
|
break;
|
|
546
518
|
}
|
|
547
|
-
|
|
519
|
+
_context6.next = 38;
|
|
548
520
|
return this.executeCommandLine("cd ".concat(_path_module_root, " && npm install"));
|
|
549
521
|
case 38:
|
|
550
|
-
|
|
522
|
+
_context6.next = 31;
|
|
551
523
|
break;
|
|
552
524
|
case 40:
|
|
553
|
-
|
|
525
|
+
_context6.next = 45;
|
|
554
526
|
break;
|
|
555
527
|
case 42:
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
_iterator4.e(
|
|
528
|
+
_context6.prev = 42;
|
|
529
|
+
_context6.t1 = _context6["catch"](29);
|
|
530
|
+
_iterator4.e(_context6.t1);
|
|
559
531
|
case 45:
|
|
560
|
-
|
|
532
|
+
_context6.prev = 45;
|
|
561
533
|
_iterator4.f();
|
|
562
|
-
return
|
|
534
|
+
return _context6.finish(45);
|
|
563
535
|
case 48:
|
|
564
536
|
case "end":
|
|
565
|
-
return
|
|
537
|
+
return _context6.stop();
|
|
566
538
|
}
|
|
567
|
-
},
|
|
539
|
+
}, _callee6, this, [[5, 22, 25, 28], [29, 42, 45, 48]]);
|
|
568
540
|
}));
|
|
569
541
|
function reinstallNodeModules() {
|
|
570
542
|
return _reinstallNodeModules.apply(this, arguments);
|
|
@@ -638,7 +610,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
638
610
|
}, {
|
|
639
611
|
key: "cleanChildFiles",
|
|
640
612
|
value: (function () {
|
|
641
|
-
var _cleanChildFiles = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
613
|
+
var _cleanChildFiles = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(path) {
|
|
642
614
|
var predicate,
|
|
643
615
|
_len5,
|
|
644
616
|
exclude,
|
|
@@ -647,66 +619,66 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
647
619
|
_iterator5,
|
|
648
620
|
_step5,
|
|
649
621
|
file,
|
|
650
|
-
|
|
651
|
-
return _regenerator["default"].wrap(function
|
|
652
|
-
while (1) switch (
|
|
622
|
+
_args7 = arguments;
|
|
623
|
+
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
624
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
653
625
|
case 0:
|
|
654
|
-
predicate =
|
|
626
|
+
predicate = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : function (each) {
|
|
655
627
|
return true;
|
|
656
628
|
};
|
|
657
629
|
if (!_fs["default"].existsSync(path)) {
|
|
658
|
-
|
|
630
|
+
_context7.next = 26;
|
|
659
631
|
break;
|
|
660
632
|
}
|
|
661
|
-
for (_len5 =
|
|
662
|
-
exclude[_key5 - 2] =
|
|
633
|
+
for (_len5 = _args7.length, exclude = new Array(_len5 > 2 ? _len5 - 2 : 0), _key5 = 2; _key5 < _len5; _key5++) {
|
|
634
|
+
exclude[_key5 - 2] = _args7[_key5];
|
|
663
635
|
}
|
|
664
636
|
files = this.findFilePathBy.apply(this, [path, predicate].concat(exclude));
|
|
665
637
|
_iterator5 = _createForOfIteratorHelper(files);
|
|
666
|
-
|
|
638
|
+
_context7.prev = 5;
|
|
667
639
|
_iterator5.s();
|
|
668
640
|
case 7:
|
|
669
641
|
if ((_step5 = _iterator5.n()).done) {
|
|
670
|
-
|
|
642
|
+
_context7.next = 15;
|
|
671
643
|
break;
|
|
672
644
|
}
|
|
673
645
|
file = _step5.value;
|
|
674
646
|
if (!this.isImageFile(file)) {
|
|
675
|
-
|
|
647
|
+
_context7.next = 11;
|
|
676
648
|
break;
|
|
677
649
|
}
|
|
678
|
-
return
|
|
650
|
+
return _context7.abrupt("continue", 13);
|
|
679
651
|
case 11:
|
|
680
652
|
this.cleanFileContent(file.absolute);
|
|
681
653
|
this.appendInfo("\u6210\u529F cleanChildFiles() -> '".concat(file.path, "'"));
|
|
682
654
|
case 13:
|
|
683
|
-
|
|
655
|
+
_context7.next = 7;
|
|
684
656
|
break;
|
|
685
657
|
case 15:
|
|
686
|
-
|
|
658
|
+
_context7.next = 20;
|
|
687
659
|
break;
|
|
688
660
|
case 17:
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
_iterator5.e(
|
|
661
|
+
_context7.prev = 17;
|
|
662
|
+
_context7.t0 = _context7["catch"](5);
|
|
663
|
+
_iterator5.e(_context7.t0);
|
|
692
664
|
case 20:
|
|
693
|
-
|
|
665
|
+
_context7.prev = 20;
|
|
694
666
|
_iterator5.f();
|
|
695
|
-
return
|
|
667
|
+
return _context7.finish(20);
|
|
696
668
|
case 23:
|
|
697
|
-
|
|
669
|
+
_context7.next = 25;
|
|
698
670
|
return this.syncDelay(1);
|
|
699
671
|
case 25:
|
|
700
|
-
return
|
|
672
|
+
return _context7.abrupt("return", files);
|
|
701
673
|
case 26:
|
|
702
|
-
return
|
|
674
|
+
return _context7.abrupt("return", false);
|
|
703
675
|
case 27:
|
|
704
676
|
case "end":
|
|
705
|
-
return
|
|
677
|
+
return _context7.stop();
|
|
706
678
|
}
|
|
707
|
-
},
|
|
679
|
+
}, _callee7, this, [[5, 17, 20, 23]]);
|
|
708
680
|
}));
|
|
709
|
-
function cleanChildFiles(
|
|
681
|
+
function cleanChildFiles(_x7) {
|
|
710
682
|
return _cleanChildFiles.apply(this, arguments);
|
|
711
683
|
}
|
|
712
684
|
return cleanChildFiles;
|
|
@@ -723,17 +695,17 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
723
695
|
}, {
|
|
724
696
|
key: "syncWithExistPackage",
|
|
725
697
|
value: function () {
|
|
726
|
-
var _syncWithExistPackage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
698
|
+
var _syncWithExistPackage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
|
|
727
699
|
var path,
|
|
728
700
|
paths,
|
|
729
701
|
_iterator6,
|
|
730
702
|
_step6,
|
|
731
703
|
_path3,
|
|
732
|
-
|
|
733
|
-
return _regenerator["default"].wrap(function
|
|
734
|
-
while (1) switch (
|
|
704
|
+
_args8 = arguments;
|
|
705
|
+
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
706
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
735
707
|
case 0:
|
|
736
|
-
path =
|
|
708
|
+
path = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : "../";
|
|
737
709
|
/** 產生shell_script_腳本 */
|
|
738
710
|
paths = this.findFilePathBy(path, function (each) {
|
|
739
711
|
return _lodash["default"].isEqual(each.fileNameExtension, "package.json");
|
|
@@ -755,9 +727,9 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
755
727
|
}
|
|
756
728
|
case 4:
|
|
757
729
|
case "end":
|
|
758
|
-
return
|
|
730
|
+
return _context8.stop();
|
|
759
731
|
}
|
|
760
|
-
},
|
|
732
|
+
}, _callee8, this);
|
|
761
733
|
}));
|
|
762
734
|
function syncWithExistPackage() {
|
|
763
735
|
return _syncWithExistPackage.apply(this, arguments);
|
|
@@ -767,17 +739,17 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
767
739
|
}, {
|
|
768
740
|
key: "packageTemplatify",
|
|
769
741
|
value: function () {
|
|
770
|
-
var _packageTemplatify = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
742
|
+
var _packageTemplatify = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(path, packageName) {
|
|
771
743
|
var _this5 = this;
|
|
772
744
|
var existFolders, dirPath, packagejson, classBase, ideaWorkspacePath, workspace, splited, indexOfRunManager, indexOfList;
|
|
773
|
-
return _regenerator["default"].wrap(function
|
|
774
|
-
while (1) switch (
|
|
745
|
+
return _regenerator["default"].wrap(function _callee9$(_context9) {
|
|
746
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
775
747
|
case 0:
|
|
776
748
|
existFolders = this.getChildPathByPath(path).map(function (each) {
|
|
777
749
|
return each.absolute.split("/").pop();
|
|
778
750
|
});
|
|
779
751
|
if (!this.has(existFolders, packageName)) {
|
|
780
|
-
|
|
752
|
+
_context9.next = 3;
|
|
781
753
|
break;
|
|
782
754
|
}
|
|
783
755
|
throw new _index2["default"](8004, " packageName ===> '".concat(packageName, "'"));
|
|
@@ -818,17 +790,17 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
818
790
|
} else {
|
|
819
791
|
this.appendError("".concat(ideaWorkspacePath, " not exist"));
|
|
820
792
|
}
|
|
821
|
-
|
|
793
|
+
_context9.next = 17;
|
|
822
794
|
return this.executeCommandLine("cd ".concat(_path5["default"].resolve(dirPath), " && npm install"));
|
|
823
795
|
case 17:
|
|
824
796
|
this.appendInfo("build ".concat(packageName, " succeed!"));
|
|
825
797
|
case 18:
|
|
826
798
|
case "end":
|
|
827
|
-
return
|
|
799
|
+
return _context9.stop();
|
|
828
800
|
}
|
|
829
|
-
},
|
|
801
|
+
}, _callee9, this);
|
|
830
802
|
}));
|
|
831
|
-
function packageTemplatify(
|
|
803
|
+
function packageTemplatify(_x8, _x9) {
|
|
832
804
|
return _packageTemplatify.apply(this, arguments);
|
|
833
805
|
}
|
|
834
806
|
return packageTemplatify;
|
|
@@ -902,27 +874,27 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
902
874
|
}, {
|
|
903
875
|
key: "persistJsonFilePrettier",
|
|
904
876
|
value: (function () {
|
|
905
|
-
var _persistJsonFilePrettier = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
877
|
+
var _persistJsonFilePrettier = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(path, object) {
|
|
906
878
|
var ignoreP,
|
|
907
|
-
|
|
908
|
-
return _regenerator["default"].wrap(function
|
|
909
|
-
while (1) switch (
|
|
879
|
+
_args10 = arguments;
|
|
880
|
+
return _regenerator["default"].wrap(function _callee10$(_context10) {
|
|
881
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
910
882
|
case 0:
|
|
911
|
-
ignoreP =
|
|
883
|
+
ignoreP = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : false;
|
|
912
884
|
this.appendFile(path, JSON.stringify(object), true, true);
|
|
913
885
|
if (ignoreP) {
|
|
914
|
-
|
|
886
|
+
_context10.next = 5;
|
|
915
887
|
break;
|
|
916
888
|
}
|
|
917
|
-
|
|
889
|
+
_context10.next = 5;
|
|
918
890
|
return this.prettier(path, 120);
|
|
919
891
|
case 5:
|
|
920
892
|
case "end":
|
|
921
|
-
return
|
|
893
|
+
return _context10.stop();
|
|
922
894
|
}
|
|
923
|
-
},
|
|
895
|
+
}, _callee10, this);
|
|
924
896
|
}));
|
|
925
|
-
function persistJsonFilePrettier(
|
|
897
|
+
function persistJsonFilePrettier(_x10, _x11) {
|
|
926
898
|
return _persistJsonFilePrettier.apply(this, arguments);
|
|
927
899
|
}
|
|
928
900
|
return persistJsonFilePrettier;
|
|
@@ -935,6 +907,41 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
935
907
|
this.appendFile(fileName, this.deepFlat(collection, " \n\n, "));
|
|
936
908
|
this.appendInfo("collectionToFile succeed, file name ==> ".concat(fileName));
|
|
937
909
|
}
|
|
910
|
+
|
|
911
|
+
/** 重複讀取file IO時,要用這個方式,不然IO太吃資源了 */
|
|
912
|
+
}, {
|
|
913
|
+
key: "readFileContentByPath",
|
|
914
|
+
value: (function () {
|
|
915
|
+
var _readFileContentByPath = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11(path, cache) {
|
|
916
|
+
var _cache$path;
|
|
917
|
+
return _regenerator["default"].wrap(function _callee11$(_context11) {
|
|
918
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
919
|
+
case 0:
|
|
920
|
+
if (!((_cache$path = cache[path]) !== null && _cache$path !== void 0)) {
|
|
921
|
+
_context11.next = 4;
|
|
922
|
+
break;
|
|
923
|
+
}
|
|
924
|
+
_context11.t0 = _cache$path;
|
|
925
|
+
_context11.next = 7;
|
|
926
|
+
break;
|
|
927
|
+
case 4:
|
|
928
|
+
_context11.next = 6;
|
|
929
|
+
return _promises["default"].readFile(path, "utf-8");
|
|
930
|
+
case 6:
|
|
931
|
+
_context11.t0 = cache[path] = _context11.sent;
|
|
932
|
+
case 7:
|
|
933
|
+
return _context11.abrupt("return", _context11.t0);
|
|
934
|
+
case 8:
|
|
935
|
+
case "end":
|
|
936
|
+
return _context11.stop();
|
|
937
|
+
}
|
|
938
|
+
}, _callee11);
|
|
939
|
+
}));
|
|
940
|
+
function readFileContentByPath(_x12, _x13) {
|
|
941
|
+
return _readFileContentByPath.apply(this, arguments);
|
|
942
|
+
}
|
|
943
|
+
return readFileContentByPath;
|
|
944
|
+
}())
|
|
938
945
|
}, {
|
|
939
946
|
key: "singleFileTemplatify",
|
|
940
947
|
value: function singleFileTemplatify() {
|
package/package.json
CHANGED