Skip to content

Commit 5cf66eb

Browse files
committed
Bump settings version to V3 even when no migration changes needed
1 parent da8f609 commit 5cf66eb

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎packages/cli/src/config/settings.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,36 @@ describe('Settings Loading and Merging', () => {
634634
expect(settings.merged.general?.enableAutoUpdate).toBe(false);
635635
});
636636

637+
it('should bump version to 3 even when V2 settings already have V3-compatible content', () => {
638+
(mockFsExistsSync as Mock).mockImplementation(
639+
(p: fs.PathLike) => p === USER_SETTINGS_PATH,
640+
);
641+
// V2 settings that already have V3-compatible keys (no migration needed)
642+
const v2SettingsWithV3Content = {
643+
$version: 2,
644+
general: {
645+
enableAutoUpdate: true,
646+
},
647+
};
648+
(fs.readFileSync as Mock).mockImplementation(
649+
(p: fs.PathOrFileDescriptor) => {
650+
if (p === USER_SETTINGS_PATH)
651+
return JSON.stringify(v2SettingsWithV3Content);
652+
return '{}';
653+
},
654+
);
655+
656+
loadSettings(MOCK_WORKSPACE_DIR);
657+
658+
// Version should be bumped to 3 even though no keys needed migration
659+
const writeCall = (fs.writeFileSync as Mock).mock.calls.find(
660+
(call: unknown[]) => call[0] === USER_SETTINGS_PATH,
661+
);
662+
expect(writeCall).toBeDefined();
663+
const writtenContent = JSON.parse(writeCall[1] as string);
664+
expect(writtenContent.$version).toBe(SETTINGS_VERSION);
665+
});
666+
637667
it('should correctly merge and migrate legacy array properties from multiple scopes', () => {
638668
(mockFsExistsSync as Mock).mockReturnValue(true);
639669
const legacyUserSettings = {

‎packages/cli/src/config/settings.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,12 @@ function migrateV2ToV3(
453453
return result;
454454
}
455455

456+
// Even if no changes, bump version to 3 to skip future migration checks
457+
if (typeof version === 'number' && version < SETTINGS_VERSION) {
458+
result[SETTINGS_VERSION_KEY] = SETTINGS_VERSION;
459+
return result;
460+
}
461+
456462
return null;
457463
}
458464

0 commit comments

Comments
 (0)