fix(npmextra): merge old npmextra keys into new keys during migration, preserving existing new values

This commit is contained in:
2025-12-16 12:58:58 +00:00
parent 773df5268b
commit 55700ad87e
4 changed files with 31 additions and 5 deletions

View File

@@ -16,8 +16,17 @@ const migrateNamespaceKeys = (npmextraJson: any): boolean => {
{ oldKey: 'szci', newKey: '@ship.zone/szci' },
];
for (const { oldKey, newKey } of migrations) {
if (npmextraJson[oldKey] && !npmextraJson[newKey]) {
npmextraJson[newKey] = npmextraJson[oldKey];
if (npmextraJson[oldKey]) {
if (!npmextraJson[newKey]) {
// New key doesn't exist - simple rename
npmextraJson[newKey] = npmextraJson[oldKey];
} else {
// New key exists - merge old into new (old values don't overwrite new)
npmextraJson[newKey] = {
...npmextraJson[oldKey],
...npmextraJson[newKey],
};
}
delete npmextraJson[oldKey];
migrated = true;
}