import is from '@sindresorhus/is' ; import type { RenovateConfig } from '../../types' ; import type { Migration } from '../types' ; export abstract class AbstractMigration implements Migration { readonly deprecated : boolean = false ; abstract readonly propertyName : string ; private readonly originalConfig : RenovateConfig ; private readonly migratedConfig : RenovateConfig ; constructor ( originalConfig , migratedConfig ) { this . originalConfig = originalConfig ; this . migratedConfig = migratedConfig ; } abstract run ( value ) ; protected get < Key extends keyof RenovateConfig > ( key ) { return this . migratedConfig [ key ] ?? this . originalConfig [ key ] ; } protected setSafely < Key extends keyof RenovateConfig > ( key , value ) { if ( is . nullOrUndefined ( this . originalConfig [ key ] ) && is . nullOrUndefined ( this . migratedConfig [ key ] ) ) { this . migratedConfig [ key ] = value ; } } protected setHard < Key extends keyof RenovateConfig > ( key , value ) { this . migratedConfig [ key ] = value ; } protected rewrite ( value ) { this . setHard ( this . propertyName , value ) ; } protected delete ( property ) { delete this . migratedConfig [ property ] ; } }