feat(migrations): versionStrategy (#13755)

This commit is contained in:
Maksim 2022-01-23 17:30:05 +01:00 коммит произвёл GitHub
Родитель 1e362ceaec
Коммит 9d87ffbe38
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 37 добавлений и 5 удалений

Просмотреть файл

@ -174,11 +174,6 @@ export function migrateConfig(
const templateIndex = val.indexOf(`{{`);
migratedConfig.branchPrefix = val.substring(0, templateIndex);
migratedConfig.additionalBranchPrefix = val.substring(templateIndex);
} else if (key === 'versionStrategy') {
delete migratedConfig.versionStrategy;
if (val === 'widen') {
migratedConfig.rangeStrategy = 'widen';
}
} else if (key === 'semanticPrefix' && is.string(val)) {
delete migratedConfig.semanticPrefix;
let [text] = val.split(':') as any; // TODO: fixme

Просмотреть файл

@ -0,0 +1,23 @@
import { VersionStrategyMigration } from './version-strategy-migration';
describe('config/migrations/custom/version-strategy-migration', () => {
it('should migrate versionStrategy="widen" to rangeStrategy="widen"', () => {
expect(VersionStrategyMigration).toMigrate(
{
versionStrategy: 'widen',
},
{
rangeStrategy: 'widen',
}
);
});
it('should just remove property when versionStrategy not equals to "widen"', () => {
expect(VersionStrategyMigration).toMigrate(
{
versionStrategy: 'test',
},
{}
);
});
});

Просмотреть файл

@ -0,0 +1,12 @@
import { AbstractMigration } from '../base/abstract-migration';
export class VersionStrategyMigration extends AbstractMigration {
override readonly deprecated = true;
readonly propertyName = 'versionStrategy';
override run(value): void {
if (value === 'widen') {
this.setSafely('rangeStrategy', 'widen');
}
}
}

Просмотреть файл

@ -13,6 +13,7 @@ import { RequiredStatusChecksMigration } from './custom/required-status-checks-m
import { SemanticCommitsMigration } from './custom/semantic-commits-migration';
import { TrustLevelMigration } from './custom/trust-level-migration';
import { UpgradeInRangeMigration } from './custom/upgrade-in-range-migration';
import { VersionStrategyMigration } from './custom/version-strategy-migration';
import type { Migration, MigrationConstructor } from './types';
export class MigrationsService {
@ -53,6 +54,7 @@ export class MigrationsService {
SemanticCommitsMigration,
TrustLevelMigration,
UpgradeInRangeMigration,
VersionStrategyMigration,
];
static run(originalConfig: RenovateConfig): RenovateConfig {