@unisphere/nx 4.5.0 → 4.5.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rename-package.d.ts","sourceRoot":"","sources":["../../../src/generators/rename-package/rename-package.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,IAAI,EAKL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"rename-package.d.ts","sourceRoot":"","sources":["../../../src/generators/rename-package/rename-package.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,IAAI,EAKL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAmexD,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,iBA8GtC;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -250,21 +250,45 @@ function updateProjectJson(tree, newPath, oldPath, oldNxProjectName, newNxProjec
|
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
let updated = false;
|
|
253
|
-
//
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
253
|
+
// Replace old path/name avoiding substring collisions (e.g. renaming "tempo" → "tempopo"
|
|
254
|
+
// where oldPath is a prefix of newPath — a naive replace would match within already-updated
|
|
255
|
+
// values and produce "tempopopo").
|
|
256
|
+
if (content.includes(oldPath) && oldPath !== newPath) {
|
|
257
|
+
const result = safeReplace(content, oldPath, newPath);
|
|
258
|
+
if (result !== content) {
|
|
259
|
+
content = result;
|
|
260
|
+
updated = true;
|
|
261
|
+
}
|
|
257
262
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
if (content.includes(oldNxProjectName) && oldNxProjectName !== newNxProjectName) {
|
|
264
|
+
const result = safeReplace(content, oldNxProjectName, newNxProjectName);
|
|
265
|
+
if (result !== content) {
|
|
266
|
+
content = result;
|
|
267
|
+
updated = true;
|
|
268
|
+
}
|
|
262
269
|
}
|
|
263
270
|
if (updated) {
|
|
264
271
|
tree.write(projectJsonPath, content);
|
|
265
272
|
devkit_1.logger.info(`✅ Updated project.json paths and comments`);
|
|
266
273
|
}
|
|
267
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Replace oldVal with newVal, handling the case where oldVal is a substring of newVal.
|
|
277
|
+
* Shields already-correct newVal occurrences from being matched.
|
|
278
|
+
*/
|
|
279
|
+
function safeReplace(text, oldVal, newVal) {
|
|
280
|
+
if (oldVal === newVal)
|
|
281
|
+
return text;
|
|
282
|
+
if (!newVal.includes(oldVal)) {
|
|
283
|
+
return text.replace(new RegExp(escapeRegExp(oldVal), 'g'), newVal);
|
|
284
|
+
}
|
|
285
|
+
// oldVal is a substring of newVal — use placeholder to protect existing correct values
|
|
286
|
+
const placeholder = `\x00__SAFE_REPLACE_${Date.now()}__\x00`;
|
|
287
|
+
let result = text.replace(new RegExp(escapeRegExp(newVal), 'g'), placeholder);
|
|
288
|
+
result = result.replace(new RegExp(escapeRegExp(oldVal), 'g'), newVal);
|
|
289
|
+
result = result.replace(new RegExp(escapeRegExp(placeholder), 'g'), newVal);
|
|
290
|
+
return result;
|
|
291
|
+
}
|
|
268
292
|
/**
|
|
269
293
|
* Update README.md to reflect the new package name
|
|
270
294
|
* Nx's move generator doesn't update documentation files
|