utiller 1.0.211 → 1.0.212

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.
@@ -1153,39 +1153,77 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
1153
1153
  _i = 0, _paths = paths;
1154
1154
  case 2:
1155
1155
  if (!(_i < _paths.length)) {
1156
- _context13.next = 13;
1156
+ _context13.next = 24;
1157
1157
  break;
1158
1158
  }
1159
1159
  path = _paths[_i];
1160
1160
  if (!this.isPathExist(path)) {
1161
- _context13.next = 10;
1161
+ _context13.next = 21;
1162
1162
  break;
1163
1163
  }
1164
1164
  json = this.getJsonObjByFilePath(path);
1165
1165
  if (!(json && json.dependencies && json.dependencies[dependency])) {
1166
- _context13.next = 10;
1166
+ _context13.next = 12;
1167
1167
  break;
1168
1168
  }
1169
1169
  json.dependencies[dependency] = "^".concat(newVersion);
1170
1170
  _context13.next = 10;
1171
1171
  return this.writeJsonThanPrettier(path, json);
1172
1172
  case 10:
1173
+ _context13.next = 21;
1174
+ break;
1175
+ case 12:
1176
+ this.updateFileOfSpecificLine(path, " \"".concat(dependency, "\":\"^").concat(newVersion, "\""), function (each) {
1177
+ return _lodash["default"].startsWith(_lodash["default"].trim(each), "\"\"".concat(dependency, "\"\""));
1178
+ });
1179
+ _context13.prev = 13;
1180
+ _context13.next = 16;
1181
+ return this.prettier(path);
1182
+ case 16:
1183
+ _context13.next = 21;
1184
+ break;
1185
+ case 18:
1186
+ _context13.prev = 18;
1187
+ _context13.t0 = _context13["catch"](13);
1188
+ this.appendError("877744543 ".concat(_context13.t0.message));
1189
+ case 21:
1173
1190
  _i++;
1174
1191
  _context13.next = 2;
1175
1192
  break;
1176
- case 13:
1193
+ case 24:
1177
1194
  this.copyFromFolderToDestFolder("/Users/davidtu/cross-achieve/high/idea-inventer/utiller/template/", "/Users/davidtu/cross-achieve/high/idea-inventer/newp/template/", true, true);
1178
- case 14:
1195
+ case 25:
1179
1196
  case "end":
1180
1197
  return _context13.stop();
1181
1198
  }
1182
- }, _callee12, this);
1199
+ }, _callee12, this, [[13, 18]]);
1183
1200
  }));
1184
1201
  function updateVersionOfTemplate(_x12, _x13) {
1185
1202
  return _updateVersionOfTemplate.apply(this, arguments);
1186
1203
  }
1187
1204
  return updateVersionOfTemplate;
1188
- }())
1205
+ }()
1206
+ /** 把一份文件split(\n),然後透過predicate找出特定的line,再replace成contentOfUpdated
1207
+ *
1208
+ * 例如一份package.json
1209
+ * utiller:1.0.1 => utiller:1.0.1
1210
+ *
1211
+ * */
1212
+ )
1213
+ }, {
1214
+ key: "updateFileOfSpecificLine",
1215
+ value: function updateFileOfSpecificLine(pathOfFile, contentOfUpdated) {
1216
+ var predicate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (line) {
1217
+ return true;
1218
+ };
1219
+ var context = this.getFileContextInRaw(pathOfFile);
1220
+ var split = context.split("\n");
1221
+ var item = _lodash["default"].find(split, function (each) {
1222
+ return predicate(each);
1223
+ });
1224
+ this.replaceArrayByContentIndex(split, item, contentOfUpdated);
1225
+ this.appendFile(pathOfFile, split.join("\n"), true, true);
1226
+ }
1189
1227
  }, {
1190
1228
  key: "writeJsonThanPrettier",
1191
1229
  value: function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utiller",
3
- "version": "1.0.211",
3
+ "version": "1.0.212",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,7 @@
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
13
  "configerer": "^1.0.11",
14
- "utiller": "^1.0.210",
14
+ "utiller": "^1.0.211",
15
15
  "linepayer": "^1.0.4",
16
16
  "databazer": "^1.0.12",
17
17
  "lodash": "^4.17.20",