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

Function migrateConfigFields

src/utils/config.ts:932–980  ·  view source on GitHub ↗

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

(config: GlobalConfig)

Source from the content-addressed store, hash-verified

930 * @internal
931 */
932function migrateConfigFields(config: GlobalConfig): GlobalConfig {
933 // Already migrated
934 if (config.installMethod !== undefined) {
935 return config
936 }
937
938 // autoUpdaterStatus is removed from the type but may exist in old configs
939 const legacy = config as GlobalConfig & {
940 autoUpdaterStatus?:
941 | 'migrated'
942 | 'installed'
943 | 'disabled'
944 | 'enabled'
945 | 'no_permissions'
946 | 'not_configured'
947 }
948
949 // Determine install method and auto-update preference from old field
950 let installMethod: InstallMethod = 'unknown'
951 let autoUpdates = config.autoUpdates ?? true // Default to enabled unless explicitly disabled
952
953 switch (legacy.autoUpdaterStatus) {
954 case 'migrated':
955 installMethod = 'local'
956 break
957 case 'installed':
958 installMethod = 'native'
959 break
960 case 'disabled':
961 // When disabled, we don't know the install method
962 autoUpdates = false
963 break
964 case 'enabled':
965 case 'no_permissions':
966 case 'not_configured':
967 // These imply global installation
968 installMethod = 'global'
969 break
970 case undefined:
971 // No old status, keep defaults
972 break
973 }
974
975 return {
976 ...config,
977 installMethod,
978 autoUpdates,
979 }
980}
981
982/**
983 * Removes history field from projects (migrated to history.jsonl)

Callers 2

getGlobalConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected