diff --git a/lib/config/migration.ts b/lib/config/migration.ts index cee715845ad9bceb289d8fd2ce677157f67b6c72..2f56ec68e8671ec68880724be86e50becb53e6b5 100644 --- a/lib/config/migration.ts +++ b/lib/config/migration.ts @@ -122,11 +122,6 @@ export function migrateConfig( regEx(/{{depNameShort}}/g), '{{depName}}' ); - } else if (key === 'ignoreNpmrcFile') { - delete migratedConfig.ignoreNpmrcFile; - if (!is.string(migratedConfig.npmrc)) { - migratedConfig.npmrc = ''; - } } else if ( key === 'branchPrefix' && is.string(val) && diff --git a/lib/config/migrations/custom/ignore-npmrc-file-migration.spec.ts b/lib/config/migrations/custom/ignore-npmrc-file-migration.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d32f6619703582974761144c87416f582f3a202 --- /dev/null +++ b/lib/config/migrations/custom/ignore-npmrc-file-migration.spec.ts @@ -0,0 +1,38 @@ +import { IgnoreNpmrcFileMigration } from './ignore-npmrc-file-migration'; + +describe('config/migrations/custom/ignore-npmrc-file-migration', () => { + it('should init npmrc field', () => { + expect(IgnoreNpmrcFileMigration).toMigrate( + { + ignoreNpmrcFile: true, + }, + { + npmrc: '', + } + ); + }); + + it('should not change npmrc field if it represents string value', () => { + expect(IgnoreNpmrcFileMigration).toMigrate( + { + ignoreNpmrcFile: true, + npmrc: '', + }, + { + npmrc: '', + } + ); + }); + + it('should change npmrc field if it not represents string value', () => { + expect(IgnoreNpmrcFileMigration).toMigrate( + { + ignoreNpmrcFile: true, + npmrc: true, + } as any, + { + npmrc: '', + } + ); + }); +}); diff --git a/lib/config/migrations/custom/ignore-npmrc-file-migration.ts b/lib/config/migrations/custom/ignore-npmrc-file-migration.ts new file mode 100644 index 0000000000000000000000000000000000000000..b64b2129a1157c9ddcde742ee11995ac53897395 --- /dev/null +++ b/lib/config/migrations/custom/ignore-npmrc-file-migration.ts @@ -0,0 +1,15 @@ +import is from '@sindresorhus/is'; +import { AbstractMigration } from '../base/abstract-migration'; + +export class IgnoreNpmrcFileMigration extends AbstractMigration { + override readonly deprecated = true; + override readonly propertyName = 'ignoreNpmrcFile'; + + override run(): void { + const npmrc = this.get('npmrc'); + + if (!is.string(npmrc)) { + this.setHard('npmrc', ''); + } + } +} diff --git a/lib/config/migrations/migrations-service.ts b/lib/config/migrations/migrations-service.ts index 69b2cff800b92f5eccaade77af98a8624b77698a..1d0eb9938f9f59faf569190da800374193b6c368 100644 --- a/lib/config/migrations/migrations-service.ts +++ b/lib/config/migrations/migrations-service.ts @@ -16,6 +16,7 @@ import { EnabledManagersMigration } from './custom/enabled-managers-migration'; import { GoModTidyMigration } from './custom/go-mod-tidy-migration'; import { HostRulesMigration } from './custom/host-rules-migration'; import { IgnoreNodeModulesMigration } from './custom/ignore-node-modules-migration'; +import { IgnoreNpmrcFileMigration } from './custom/ignore-npmrc-file-migration'; import { PackageNameMigration } from './custom/package-name-migration'; import { PackagePatternMigration } from './custom/package-pattern-migration'; import { PackagesMigration } from './custom/packages-migration'; @@ -78,6 +79,7 @@ export class MigrationsService { GoModTidyMigration, HostRulesMigration, IgnoreNodeModulesMigration, + IgnoreNpmrcFileMigration, PackageNameMigration, PackagePatternMigration, PackagesMigration,