utiller 1.0.304 → 1.0.306
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.
|
@@ -289,30 +289,28 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
289
289
|
}, {
|
|
290
290
|
key: "persistByPath",
|
|
291
291
|
value: /** '/a/b/c.js' 把它變成真的 */
|
|
292
|
-
function persistByPath(
|
|
293
|
-
var
|
|
294
|
-
var
|
|
295
|
-
var
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
292
|
+
function persistByPath(targetPath) {
|
|
293
|
+
var isAbsolute = _path4["default"].isAbsolute(targetPath);
|
|
294
|
+
var parts = targetPath.split("/").filter(Boolean);
|
|
295
|
+
var lastPart = parts[parts.length - 1];
|
|
296
|
+
var isFile = _path4["default"].extname(lastPart) !== ""; // ← 正規判斷副檔名
|
|
297
|
+
|
|
298
|
+
var current = isAbsolute ? _path4["default"].sep : "";
|
|
299
|
+
for (var i = 0; i < parts.length; i++) {
|
|
300
|
+
current = _path4["default"].join(current, parts[i]);
|
|
301
|
+
if (!_fs["default"].existsSync(current)) {
|
|
302
|
+
if (i === parts.length - 1 && isFile) {
|
|
303
|
+
// 最後一個而且是檔案 → 建檔案
|
|
304
|
+
_fs["default"].writeFileSync(current, "");
|
|
305
|
+
} else {
|
|
306
|
+
// 其他 → 建資料夾
|
|
307
|
+
_fs["default"].mkdirSync(current, {
|
|
308
|
+
recursive: false
|
|
309
|
+
});
|
|
308
310
|
}
|
|
309
311
|
}
|
|
310
|
-
} catch (err) {
|
|
311
|
-
_iterator2.e(err);
|
|
312
|
-
} finally {
|
|
313
|
-
_iterator2.f();
|
|
314
312
|
}
|
|
315
|
-
return _path4["default"].resolve(
|
|
313
|
+
return _path4["default"].resolve(targetPath);
|
|
316
314
|
}
|
|
317
315
|
|
|
318
316
|
/**
|
|
@@ -427,8 +425,8 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
427
425
|
var _deleteChildByPath = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(path) {
|
|
428
426
|
var force,
|
|
429
427
|
pathes,
|
|
430
|
-
|
|
431
|
-
|
|
428
|
+
_iterator2,
|
|
429
|
+
_step2,
|
|
432
430
|
_path2,
|
|
433
431
|
_args6 = arguments;
|
|
434
432
|
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
@@ -436,15 +434,15 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
436
434
|
case 0:
|
|
437
435
|
force = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : false;
|
|
438
436
|
pathes = this.getChildPathByPath(path);
|
|
439
|
-
|
|
437
|
+
_iterator2 = _createForOfIteratorHelper(pathes);
|
|
440
438
|
_context6.prev = 3;
|
|
441
|
-
|
|
439
|
+
_iterator2.s();
|
|
442
440
|
case 5:
|
|
443
|
-
if ((
|
|
441
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
444
442
|
_context6.next = 11;
|
|
445
443
|
break;
|
|
446
444
|
}
|
|
447
|
-
_path2 =
|
|
445
|
+
_path2 = _step2.value;
|
|
448
446
|
_context6.next = 9;
|
|
449
447
|
return this.deleteSelfByPath(_path2.absolute, force);
|
|
450
448
|
case 9:
|
|
@@ -456,10 +454,10 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
456
454
|
case 13:
|
|
457
455
|
_context6.prev = 13;
|
|
458
456
|
_context6.t0 = _context6["catch"](3);
|
|
459
|
-
|
|
457
|
+
_iterator2.e(_context6.t0);
|
|
460
458
|
case 16:
|
|
461
459
|
_context6.prev = 16;
|
|
462
|
-
|
|
460
|
+
_iterator2.f();
|
|
463
461
|
return _context6.finish(16);
|
|
464
462
|
case 19:
|
|
465
463
|
case "end":
|
|
@@ -490,14 +488,14 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
490
488
|
_key4,
|
|
491
489
|
ex,
|
|
492
490
|
paths,
|
|
493
|
-
|
|
494
|
-
|
|
491
|
+
_iterator3,
|
|
492
|
+
_step3,
|
|
495
493
|
_json,
|
|
496
494
|
path_module_root,
|
|
497
495
|
path_gen_node_module,
|
|
498
496
|
path_lock_json,
|
|
499
|
-
|
|
500
|
-
|
|
497
|
+
_iterator4,
|
|
498
|
+
_step4,
|
|
501
499
|
_json2,
|
|
502
500
|
_path_module_root,
|
|
503
501
|
_path_gen_node_module,
|
|
@@ -514,15 +512,15 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
514
512
|
paths = this.findFilePathBy.apply(this, [path, function (each) {
|
|
515
513
|
return _lodash["default"].isEqual(each.fileNameExtension, "package.json");
|
|
516
514
|
}].concat((0, _toConsumableArray2["default"])(ex)));
|
|
517
|
-
|
|
515
|
+
_iterator3 = _createForOfIteratorHelper(paths);
|
|
518
516
|
_context7.prev = 5;
|
|
519
|
-
|
|
517
|
+
_iterator3.s();
|
|
520
518
|
case 7:
|
|
521
|
-
if ((
|
|
519
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
522
520
|
_context7.next = 20;
|
|
523
521
|
break;
|
|
524
522
|
}
|
|
525
|
-
_json =
|
|
523
|
+
_json = _step3.value;
|
|
526
524
|
path_module_root = this.getFileDirPath(_json.absolute);
|
|
527
525
|
path_gen_node_module = "".concat(path_module_root, "node_modules");
|
|
528
526
|
path_lock_json = "".concat(path_module_root, "package-lock.json");
|
|
@@ -543,21 +541,21 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
543
541
|
case 22:
|
|
544
542
|
_context7.prev = 22;
|
|
545
543
|
_context7.t0 = _context7["catch"](5);
|
|
546
|
-
|
|
544
|
+
_iterator3.e(_context7.t0);
|
|
547
545
|
case 25:
|
|
548
546
|
_context7.prev = 25;
|
|
549
|
-
|
|
547
|
+
_iterator3.f();
|
|
550
548
|
return _context7.finish(25);
|
|
551
549
|
case 28:
|
|
552
|
-
|
|
550
|
+
_iterator4 = _createForOfIteratorHelper(paths);
|
|
553
551
|
_context7.prev = 29;
|
|
554
|
-
|
|
552
|
+
_iterator4.s();
|
|
555
553
|
case 31:
|
|
556
|
-
if ((
|
|
554
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
557
555
|
_context7.next = 40;
|
|
558
556
|
break;
|
|
559
557
|
}
|
|
560
|
-
_json2 =
|
|
558
|
+
_json2 = _step4.value;
|
|
561
559
|
_path_module_root = this.getFileDirPath(_json2.absolute);
|
|
562
560
|
_path_gen_node_module = "".concat(_path_module_root, "node_modules");
|
|
563
561
|
if (_fs["default"].existsSync(_path_gen_node_module)) {
|
|
@@ -575,10 +573,10 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
575
573
|
case 42:
|
|
576
574
|
_context7.prev = 42;
|
|
577
575
|
_context7.t1 = _context7["catch"](29);
|
|
578
|
-
|
|
576
|
+
_iterator4.e(_context7.t1);
|
|
579
577
|
case 45:
|
|
580
578
|
_context7.prev = 45;
|
|
581
|
-
|
|
579
|
+
_iterator4.f();
|
|
582
580
|
return _context7.finish(45);
|
|
583
581
|
case 48:
|
|
584
582
|
case "end":
|
|
@@ -731,8 +729,8 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
731
729
|
var _syncWithExistPackage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
|
|
732
730
|
var path,
|
|
733
731
|
paths,
|
|
734
|
-
|
|
735
|
-
|
|
732
|
+
_iterator5,
|
|
733
|
+
_step5,
|
|
736
734
|
_path3,
|
|
737
735
|
_args9 = arguments;
|
|
738
736
|
return _regenerator["default"].wrap(function _callee9$(_context9) {
|
|
@@ -743,10 +741,10 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
743
741
|
paths = this.findFilePathBy(path, function (each) {
|
|
744
742
|
return _lodash["default"].isEqual(each.fileNameExtension, "package.json");
|
|
745
743
|
}, "node_modules");
|
|
746
|
-
|
|
744
|
+
_iterator5 = _createForOfIteratorHelper(paths);
|
|
747
745
|
try {
|
|
748
|
-
for (
|
|
749
|
-
_path3 =
|
|
746
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
747
|
+
_path3 = _step5.value;
|
|
750
748
|
try {
|
|
751
749
|
if (!_lodash["default"].isEqual(_path3.dirName, "..")) this.insertShellCommand(_configerer.configerer.BASE_SHELL_SCRIPT, "cd_".concat(_path3.dirName), "cd ".concat(this.getFolderPathOfSpecificPath(_path3.absolute)));
|
|
752
750
|
} catch (error) {
|
|
@@ -754,9 +752,9 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
754
752
|
}
|
|
755
753
|
}
|
|
756
754
|
} catch (err) {
|
|
757
|
-
|
|
755
|
+
_iterator5.e(err);
|
|
758
756
|
} finally {
|
|
759
|
-
|
|
757
|
+
_iterator5.f();
|
|
760
758
|
}
|
|
761
759
|
case 4:
|
|
762
760
|
case "end":
|
|
@@ -981,11 +979,11 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
981
979
|
value: function singleFileTemplatify() {
|
|
982
980
|
var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "./";
|
|
983
981
|
var all = this.findFilePathByExtension(path, ["js"], "node_modules");
|
|
984
|
-
var
|
|
985
|
-
|
|
982
|
+
var _iterator6 = _createForOfIteratorHelper(all),
|
|
983
|
+
_step6;
|
|
986
984
|
try {
|
|
987
|
-
for (
|
|
988
|
-
var file =
|
|
985
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
986
|
+
var file = _step6.value;
|
|
989
987
|
var content = this.getFileContextInRaw(file.absolute).trim();
|
|
990
988
|
if (_lodash["default"].isEmpty(content)) {
|
|
991
989
|
this.appendInfo(file.fileName, file.absolute);
|
|
@@ -994,9 +992,9 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
994
992
|
}
|
|
995
993
|
}
|
|
996
994
|
} catch (err) {
|
|
997
|
-
|
|
995
|
+
_iterator6.e(err);
|
|
998
996
|
} finally {
|
|
999
|
-
|
|
997
|
+
_iterator6.f();
|
|
1000
998
|
}
|
|
1001
999
|
}
|
|
1002
1000
|
}, {
|
|
@@ -1082,8 +1080,8 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1082
1080
|
_len8,
|
|
1083
1081
|
exclude,
|
|
1084
1082
|
_key8,
|
|
1085
|
-
|
|
1086
|
-
|
|
1083
|
+
_iterator7,
|
|
1084
|
+
_step7,
|
|
1087
1085
|
_loop,
|
|
1088
1086
|
_args14 = arguments;
|
|
1089
1087
|
return _regenerator["default"].wrap(function _callee13$(_context14) {
|
|
@@ -1102,14 +1100,14 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1102
1100
|
for (_len8 = _args14.length, exclude = new Array(_len8 > 3 ? _len8 - 3 : 0), _key8 = 3; _key8 < _len8; _key8++) {
|
|
1103
1101
|
exclude[_key8 - 3] = _args14[_key8];
|
|
1104
1102
|
}
|
|
1105
|
-
|
|
1103
|
+
_iterator7 = _createForOfIteratorHelper(packagejsons);
|
|
1106
1104
|
_context14.prev = 8;
|
|
1107
1105
|
_loop = /*#__PURE__*/_regenerator["default"].mark(function _loop() {
|
|
1108
1106
|
var path, tempFolderPath, release, pathOfPackageJson, indexFileName, templatePath, _yield$_this7$upgrade, moduleName, version;
|
|
1109
1107
|
return _regenerator["default"].wrap(function _loop$(_context13) {
|
|
1110
1108
|
while (1) switch (_context13.prev = _context13.next) {
|
|
1111
1109
|
case 0:
|
|
1112
|
-
path =
|
|
1110
|
+
path = _step7.value;
|
|
1113
1111
|
if (!_this7.isAndEquals.apply(_this7, (0, _toConsumableArray2["default"])(exclude.map(function (projectName) {
|
|
1114
1112
|
return function () {
|
|
1115
1113
|
return !_this7.has(path, projectName);
|
|
@@ -1203,9 +1201,9 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1203
1201
|
}
|
|
1204
1202
|
}, _loop, null, [[9, 37, 42, 46]]);
|
|
1205
1203
|
});
|
|
1206
|
-
|
|
1204
|
+
_iterator7.s();
|
|
1207
1205
|
case 11:
|
|
1208
|
-
if ((
|
|
1206
|
+
if ((_step7 = _iterator7.n()).done) {
|
|
1209
1207
|
_context14.next = 15;
|
|
1210
1208
|
break;
|
|
1211
1209
|
}
|
|
@@ -1219,10 +1217,10 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1219
1217
|
case 17:
|
|
1220
1218
|
_context14.prev = 17;
|
|
1221
1219
|
_context14.t1 = _context14["catch"](8);
|
|
1222
|
-
|
|
1220
|
+
_iterator7.e(_context14.t1);
|
|
1223
1221
|
case 20:
|
|
1224
1222
|
_context14.prev = 20;
|
|
1225
|
-
|
|
1223
|
+
_iterator7.f();
|
|
1226
1224
|
return _context14.finish(20);
|
|
1227
1225
|
case 23:
|
|
1228
1226
|
case "end":
|
|
@@ -1376,7 +1374,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1376
1374
|
key: "enrichEachPackageJson",
|
|
1377
1375
|
value: (function () {
|
|
1378
1376
|
var _enrichEachPackageJson = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee17(rootPath) {
|
|
1379
|
-
var validNames, jsonFiles, packageFiles,
|
|
1377
|
+
var validNames, jsonFiles, packageFiles, _iterator8, _step8, absolute, json;
|
|
1380
1378
|
return _regenerator["default"].wrap(function _callee17$(_context18) {
|
|
1381
1379
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1382
1380
|
case 0:
|
|
@@ -1391,15 +1389,15 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1391
1389
|
}
|
|
1392
1390
|
return _context18.abrupt("return");
|
|
1393
1391
|
case 5:
|
|
1394
|
-
|
|
1392
|
+
_iterator8 = _createForOfIteratorHelper(packageFiles);
|
|
1395
1393
|
_context18.prev = 6;
|
|
1396
|
-
|
|
1394
|
+
_iterator8.s();
|
|
1397
1395
|
case 8:
|
|
1398
|
-
if ((
|
|
1396
|
+
if ((_step8 = _iterator8.n()).done) {
|
|
1399
1397
|
_context18.next = 17;
|
|
1400
1398
|
break;
|
|
1401
1399
|
}
|
|
1402
|
-
absolute =
|
|
1400
|
+
absolute = _step8.value.absolute;
|
|
1403
1401
|
json = this.getJsonObjByFilePath(absolute);
|
|
1404
1402
|
json.scripts || (json.scripts = {});
|
|
1405
1403
|
json.scripts.updateConfigerer = "npm update configerer --save";
|
|
@@ -1414,10 +1412,10 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1414
1412
|
case 19:
|
|
1415
1413
|
_context18.prev = 19;
|
|
1416
1414
|
_context18.t0 = _context18["catch"](6);
|
|
1417
|
-
|
|
1415
|
+
_iterator8.e(_context18.t0);
|
|
1418
1416
|
case 22:
|
|
1419
1417
|
_context18.prev = 22;
|
|
1420
|
-
|
|
1418
|
+
_iterator8.f();
|
|
1421
1419
|
return _context18.finish(22);
|
|
1422
1420
|
case 25:
|
|
1423
1421
|
case "end":
|
|
@@ -1812,7 +1810,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1812
1810
|
key: "generateTempFolderWithCleanSrc",
|
|
1813
1811
|
value: (function () {
|
|
1814
1812
|
var _generateTempFolderWithCleanSrc = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee24(basePath) {
|
|
1815
|
-
var sourceFile, tempFolderPath, filePaths,
|
|
1813
|
+
var sourceFile, tempFolderPath, filePaths, _iterator9, _step9, tempFilePath, rawLines, trimmedLines, start, end, updatedContent;
|
|
1816
1814
|
return _regenerator["default"].wrap(function _callee24$(_context26) {
|
|
1817
1815
|
while (1) switch (_context26.prev = _context26.next) {
|
|
1818
1816
|
case 0:
|
|
@@ -1831,15 +1829,15 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1831
1829
|
return this.copyFromFolderToDestFolder(sourceFile, tempFolderPath);
|
|
1832
1830
|
case 9:
|
|
1833
1831
|
filePaths = this.findFilePathBy(tempFolderPath);
|
|
1834
|
-
|
|
1832
|
+
_iterator9 = _createForOfIteratorHelper(filePaths);
|
|
1835
1833
|
_context26.prev = 11;
|
|
1836
|
-
|
|
1834
|
+
_iterator9.s();
|
|
1837
1835
|
case 13:
|
|
1838
|
-
if ((
|
|
1836
|
+
if ((_step9 = _iterator9.n()).done) {
|
|
1839
1837
|
_context26.next = 27;
|
|
1840
1838
|
break;
|
|
1841
1839
|
}
|
|
1842
|
-
tempFilePath =
|
|
1840
|
+
tempFilePath = _step9.value.absolute;
|
|
1843
1841
|
rawLines = this.getFileContextInRaw(tempFilePath).split("\n");
|
|
1844
1842
|
trimmedLines = rawLines.map(function (line) {
|
|
1845
1843
|
return line.trim();
|
|
@@ -1869,10 +1867,10 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1869
1867
|
case 29:
|
|
1870
1868
|
_context26.prev = 29;
|
|
1871
1869
|
_context26.t0 = _context26["catch"](11);
|
|
1872
|
-
|
|
1870
|
+
_iterator9.e(_context26.t0);
|
|
1873
1871
|
case 32:
|
|
1874
1872
|
_context26.prev = 32;
|
|
1875
|
-
|
|
1873
|
+
_iterator9.f();
|
|
1876
1874
|
return _context26.finish(32);
|
|
1877
1875
|
case 35:
|
|
1878
1876
|
return _context26.abrupt("return", tempFolderPath);
|
package/package.json
CHANGED