mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 13:48:55 +00:00
5bfa68b8d3
* create file * use class-based migration for packageFiles * add tests * fix errors * fix merge errors * Update lib/config/migrations/custom/package-files-migration.ts Co-authored-by: Jamie Magee <jamie.magee@gmail.com> * Update lib/config/migrations/custom/package-files-migration.ts Co-authored-by: Jamie Magee <jamie.magee@gmail.com> * add test * Update index.ts * modify test * fix type * refactor * Update lib/config/migrations/custom/package-files-migration.ts Co-authored-by: Michael Kriese <michael.kriese@visualon.de> * Update lib/config/migrations/custom/package-files-migration.ts Co-authored-by: Michael Kriese <michael.kriese@visualon.de> * readd todo Co-authored-by: Jamie Magee <jamie.magee@gmail.com> Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import is from '@sindresorhus/is';
|
|
import type { PackageRule } from '../../types';
|
|
import { AbstractMigration } from '../base/abstract-migration';
|
|
|
|
export class PackageFilesMigration extends AbstractMigration {
|
|
override readonly deprecated = true;
|
|
override readonly propertyName = 'packageFiles';
|
|
|
|
override run(value: unknown): void {
|
|
const packageRules: PackageRule[] = this.get('packageRules') ?? [];
|
|
if (is.array(value)) {
|
|
const fileList: string[] = [];
|
|
for (const packageFile of value) {
|
|
if (
|
|
is.nonEmptyObject(packageFile) &&
|
|
'packageFile' in packageFile &&
|
|
is.string(packageFile.packageFile)
|
|
) {
|
|
fileList.push(packageFile.packageFile);
|
|
packageFile.paths = [packageFile.packageFile];
|
|
delete packageFile.packageFile;
|
|
|
|
if (Object.keys(packageFile).length > 1) {
|
|
packageRules.push({
|
|
...packageFile,
|
|
});
|
|
}
|
|
} else if (is.array(packageFile, is.string)) {
|
|
fileList.push(...packageFile);
|
|
} else if (is.string(packageFile)) {
|
|
fileList.push(packageFile);
|
|
}
|
|
}
|
|
if (fileList.length) {
|
|
this.setSafely('includePaths', fileList);
|
|
}
|
|
if (packageRules.length) {
|
|
this.setSafely('packageRules', packageRules);
|
|
}
|
|
}
|
|
}
|
|
}
|