"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PackageRulesMigration = exports.renameMap = void 0;
const abstract_migration_1 = require("../base/abstract-migration");
exports.renameMap = {
    paths: 'matchPaths',
    languages: 'matchLanguages',
    baseBranchList: 'matchBaseBranches',
    managers: 'matchManagers',
    datasources: 'matchDatasources',
    depTypeList: 'matchDepTypes',
    packageNames: 'matchPackageNames',
    packagePatterns: 'matchPackagePatterns',
    sourceUrlPrefixes: 'matchSourceUrlPrefixes',
    updateTypes: 'matchUpdateTypes',
};
function renameKeys(packageRule) {
    const newPackageRule = {};
    for (const [key, val] of Object.entries(packageRule)) {
        newPackageRule[exports.renameMap[key] ?? key] = val;
    }
    return newPackageRule;
}
class PackageRulesMigration extends abstract_migration_1.AbstractMigration {
    propertyName = 'packageRules';
    run(value) {
        let packageRules = this.get('packageRules') ?? [];
        packageRules = Array.isArray(packageRules) ? [...packageRules] : [];
        packageRules = packageRules.map(renameKeys);
        this.rewrite(packageRules);
    }
}
exports.PackageRulesMigration = PackageRulesMigration;
//# sourceMappingURL=package-rules-migration.js.map