forked from renovatebot/renovate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(migrations): raiseDeprecationWarnings (renovatebot#13761)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
- Loading branch information
Showing
4 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
lib/config/migrations/custom/raise-deprecation-warnings-migration.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { RaiseDeprecationWarningsMigration } from './raise-deprecation-warnings-migration'; | ||
|
||
describe('config/migrations/custom/raise-deprecation-warnings-migration', () => { | ||
it('should migrate false', () => { | ||
expect(RaiseDeprecationWarningsMigration).toMigrate( | ||
{ raiseDeprecationWarnings: false }, | ||
{ | ||
suppressNotifications: ['deprecationWarningIssues'], | ||
} | ||
); | ||
}); | ||
|
||
it('should migrate false and concat with existing value', () => { | ||
expect(RaiseDeprecationWarningsMigration).toMigrate( | ||
{ | ||
raiseDeprecationWarnings: false, | ||
suppressNotifications: ['test'], | ||
}, | ||
{ suppressNotifications: ['test', 'deprecationWarningIssues'] } | ||
); | ||
}); | ||
|
||
it('should just remove property when raiseDeprecationWarnings not equals to true', () => { | ||
expect(RaiseDeprecationWarningsMigration).toMigrate( | ||
{ | ||
raiseDeprecationWarnings: true, | ||
}, | ||
{} | ||
); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
lib/config/migrations/custom/raise-deprecation-warnings-migration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { AbstractMigration } from '../base/abstract-migration'; | ||
|
||
export class RaiseDeprecationWarningsMigration extends AbstractMigration { | ||
override readonly deprecated = true; | ||
override readonly propertyName = 'raiseDeprecationWarnings'; | ||
|
||
override run(value: unknown): void { | ||
const suppressNotifications = this.get('suppressNotifications'); | ||
|
||
if (value === false) { | ||
this.setHard( | ||
'suppressNotifications', | ||
Array.isArray(suppressNotifications) | ||
? suppressNotifications.concat(['deprecationWarningIssues']) | ||
: ['deprecationWarningIssues'] | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters