Skip to content

Commit

Permalink
refactor(migrations): raiseDeprecationWarnings (renovatebot#13761)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
2 people authored and ademar59 committed Jan 24, 2022
1 parent c47ff24 commit 7b969b1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
7 changes: 0 additions & 7 deletions lib/config/migration.ts
Expand Up @@ -425,13 +425,6 @@ export function migrateConfig(
if (subMigrate.isMigrated) {
migratedConfig[key] = subMigrate.migratedConfig;
}
} else if (key === 'raiseDeprecationWarnings') {
delete migratedConfig.raiseDeprecationWarnings;
if (val === false) {
migratedConfig.suppressNotifications =
migratedConfig.suppressNotifications || [];
migratedConfig.suppressNotifications.push('deprecationWarningIssues');
}
} else if (key === 'azureAutoComplete' || key === 'gitLabAutomerge') {
if (migratedConfig[key] !== undefined) {
migratedConfig.platformAutomerge = migratedConfig[key];
Expand Down
@@ -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,
},
{}
);
});
});
@@ -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']
);
}
}
}
2 changes: 2 additions & 0 deletions lib/config/migrations/migrations-service.ts
Expand Up @@ -8,6 +8,7 @@ import { EnabledManagersMigration } from './custom/enabled-managers-migration';
import { GoModTidyMigration } from './custom/go-mod-tidy-migration';
import { IgnoreNodeModulesMigration } from './custom/ignore-node-modules-migration';
import { PinVersionsMigration } from './custom/pin-versions-migration';
import { RaiseDeprecationWarningsMigration } from './custom/raise-deprecation-warnings-migration';
import { RebaseConflictedPrs } from './custom/rebase-conflicted-prs-migration';
import { RebaseStalePrsMigration } from './custom/rebase-stale-prs-migration';
import { RequiredStatusChecksMigration } from './custom/required-status-checks-migration';
Expand Down Expand Up @@ -51,6 +52,7 @@ export class MigrationsService {
GoModTidyMigration,
IgnoreNodeModulesMigration,
PinVersionsMigration,
RaiseDeprecationWarningsMigration,
RebaseConflictedPrs,
RebaseStalePrsMigration,
RequiredStatusChecksMigration,
Expand Down

0 comments on commit 7b969b1

Please sign in to comment.