diff --git a/changelog.md b/changelog.md index ca2dde7..4bfa840 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Changelog +## 2025-12-16 - 2.13.1 - fix(npmextra) +merge old npmextra keys into new keys during migration, preserving existing new values + +- Changed migration logic to merge data when both old and new keys exist instead of skipping the merge. +- Merge preserves existing new-key values (old values do not overwrite new ones) and still deletes the old key after migration. +- Applied the fix in both ts/mod_format/format.npmextra.ts and ts/mod_format/formatters/npmextra.formatter.ts. +- Adds a console log for successful migrations; behavior for single-key rename remains unchanged. + ## 2025-12-16 - 2.13.0 - feat(tests) feat(tests): add sandbox test fixture, CI and editor configs; bump deps diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 3a8b4b6..0034810 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/cli', - version: '2.13.0', + version: '2.13.1', description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.' } diff --git a/ts/mod_format/format.npmextra.ts b/ts/mod_format/format.npmextra.ts index 1f3080c..25423ef 100644 --- a/ts/mod_format/format.npmextra.ts +++ b/ts/mod_format/format.npmextra.ts @@ -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; console.log(`Migrated npmextra.json: ${oldKey} -> ${newKey}`); diff --git a/ts/mod_format/formatters/npmextra.formatter.ts b/ts/mod_format/formatters/npmextra.formatter.ts index c818f7b..9a5e98f 100644 --- a/ts/mod_format/formatters/npmextra.formatter.ts +++ b/ts/mod_format/formatters/npmextra.formatter.ts @@ -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; }