Skip to content

Commit fee8aa2

Browse files
refactor(migrations): raiseDeprecationWarnings (#13761)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
1 parent d65a1dd commit fee8aa2

File tree

4 files changed

+52
-7
lines changed

4 files changed

+52
-7
lines changed

lib/config/migration.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,6 @@ export function migrateConfig(
425425
if (subMigrate.isMigrated) {
426426
migratedConfig[key] = subMigrate.migratedConfig;
427427
}
428-
} else if (key === 'raiseDeprecationWarnings') {
429-
delete migratedConfig.raiseDeprecationWarnings;
430-
if (val === false) {
431-
migratedConfig.suppressNotifications =
432-
migratedConfig.suppressNotifications || [];
433-
migratedConfig.suppressNotifications.push('deprecationWarningIssues');
434-
}
435428
} else if (key === 'azureAutoComplete' || key === 'gitLabAutomerge') {
436429
if (migratedConfig[key] !== undefined) {
437430
migratedConfig.platformAutomerge = migratedConfig[key];
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { RaiseDeprecationWarningsMigration } from './raise-deprecation-warnings-migration';
2+
3+
describe('config/migrations/custom/raise-deprecation-warnings-migration', () => {
4+
it('should migrate false', () => {
5+
expect(RaiseDeprecationWarningsMigration).toMigrate(
6+
{ raiseDeprecationWarnings: false },
7+
{
8+
suppressNotifications: ['deprecationWarningIssues'],
9+
}
10+
);
11+
});
12+
13+
it('should migrate false and concat with existing value', () => {
14+
expect(RaiseDeprecationWarningsMigration).toMigrate(
15+
{
16+
raiseDeprecationWarnings: false,
17+
suppressNotifications: ['test'],
18+
},
19+
{ suppressNotifications: ['test', 'deprecationWarningIssues'] }
20+
);
21+
});
22+
23+
it('should just remove property when raiseDeprecationWarnings not equals to true', () => {
24+
expect(RaiseDeprecationWarningsMigration).toMigrate(
25+
{
26+
raiseDeprecationWarnings: true,
27+
},
28+
{}
29+
);
30+
});
31+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { AbstractMigration } from '../base/abstract-migration';
2+
3+
export class RaiseDeprecationWarningsMigration extends AbstractMigration {
4+
override readonly deprecated = true;
5+
override readonly propertyName = 'raiseDeprecationWarnings';
6+
7+
override run(value: unknown): void {
8+
const suppressNotifications = this.get('suppressNotifications');
9+
10+
if (value === false) {
11+
this.setHard(
12+
'suppressNotifications',
13+
Array.isArray(suppressNotifications)
14+
? suppressNotifications.concat(['deprecationWarningIssues'])
15+
: ['deprecationWarningIssues']
16+
);
17+
}
18+
}
19+
}

lib/config/migrations/migrations-service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { EnabledManagersMigration } from './custom/enabled-managers-migration';
88
import { GoModTidyMigration } from './custom/go-mod-tidy-migration';
99
import { IgnoreNodeModulesMigration } from './custom/ignore-node-modules-migration';
1010
import { PinVersionsMigration } from './custom/pin-versions-migration';
11+
import { RaiseDeprecationWarningsMigration } from './custom/raise-deprecation-warnings-migration';
1112
import { RebaseConflictedPrs } from './custom/rebase-conflicted-prs-migration';
1213
import { RebaseStalePrsMigration } from './custom/rebase-stale-prs-migration';
1314
import { RequiredStatusChecksMigration } from './custom/required-status-checks-migration';
@@ -51,6 +52,7 @@ export class MigrationsService {
5152
GoModTidyMigration,
5253
IgnoreNodeModulesMigration,
5354
PinVersionsMigration,
55+
RaiseDeprecationWarningsMigration,
5456
RebaseConflictedPrs,
5557
RebaseStalePrsMigration,
5658
RequiredStatusChecksMigration,

0 commit comments

Comments
 (0)