MCPcopy Create free account
hub / github.com/Noumena-Network/code / migrateConfigFields

Function migrateConfigFields

src/utils/config.ts:986–1034  ·  view source on GitHub ↗

* Migrates old autoUpdaterStatus to new installMethod and autoUpdates fields * @internal

(config: GlobalConfig)

Source from the content-addressed store, hash-verified

984 * @internal
985 */
986function migrateConfigFields(config: GlobalConfig): GlobalConfig {
987 // Already migrated
988 if (config.installMethod !== undefined) {
989 return config
990 }
991
992 // autoUpdaterStatus is removed from the type but may exist in old configs
993 const legacy = config as GlobalConfig & {
994 autoUpdaterStatus?:
995 | 'migrated'
996 | 'installed'
997 | 'disabled'
998 | 'enabled'
999 | 'no_permissions'
1000 | 'not_configured'
1001 }
1002
1003 // Determine install method and auto-update preference from old field
1004 let installMethod: InstallMethod = 'unknown'
1005 let autoUpdates = config.autoUpdates ?? true // Default to enabled unless explicitly disabled
1006
1007 switch (legacy.autoUpdaterStatus) {
1008 case 'migrated':
1009 installMethod = 'local'
1010 break
1011 case 'installed':
1012 installMethod = 'native'
1013 break
1014 case 'disabled':
1015 // When disabled, we don't know the install method
1016 autoUpdates = false
1017 break
1018 case 'enabled':
1019 case 'no_permissions':
1020 case 'not_configured':
1021 // These imply global installation
1022 installMethod = 'global'
1023 break
1024 case undefined:
1025 // No old status, keep defaults
1026 break
1027 }
1028
1029 return {
1030 ...config,
1031 installMethod,
1032 autoUpdates,
1033 }
1034}
1035
1036/**
1037 * Removes history field from projects (migrated to history.jsonl)

Callers 2

getGlobalConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected