-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2c6cbe
commit 9c322cd
Showing
6 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
lib/config/migrations/custom/match-managers-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,26 @@ | ||
import { MatchManagersMigration } from './match-managers-migration'; | ||
|
||
describe('config/migrations/custom/match-managers-migration', () => { | ||
it('migrates old custom manager syntax to new one', () => { | ||
expect(MatchManagersMigration).toMigrate( | ||
{ | ||
matchManagers: ['npm', 'regex', 'custom.someMgr'], | ||
}, | ||
{ | ||
matchManagers: ['npm', 'custom.regex', 'custom.someMgr'], | ||
} | ||
); | ||
}); | ||
|
||
// coverage | ||
it('only migrates when necessary', () => { | ||
expect(MatchManagersMigration).not.toMigrate( | ||
{ | ||
matchManagers: undefined, | ||
}, | ||
{ | ||
matchManagers: undefined, | ||
} | ||
); | ||
}); | ||
}); |
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,18 @@ | ||
import is from '@sindresorhus/is'; | ||
import { isCustomManager } from '../../../modules/manager/custom'; | ||
import { AbstractMigration } from '../base/abstract-migration'; | ||
|
||
export class MatchManagersMigration extends AbstractMigration { | ||
override readonly propertyName = 'matchManagers'; | ||
|
||
override run(value: unknown): void { | ||
if (!is.array<string>(value, is.string)) { | ||
return; | ||
} | ||
|
||
const newValue = value.map((manager) => | ||
isCustomManager(manager) ? `custom.${manager}` : manager | ||
); | ||
this.rewrite(newValue); | ||
} | ||
} |
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
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
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
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