diff --git a/lib/workers/repository/config-migration/branch/migrated-data.spec.ts b/lib/workers/repository/config-migration/branch/migrated-data.spec.ts index c63ca22f81..38b237c72a 100644 --- a/lib/workers/repository/config-migration/branch/migrated-data.spec.ts +++ b/lib/workers/repository/config-migration/branch/migrated-data.spec.ts @@ -16,8 +16,6 @@ jest.mock('../../../../util/json-writer'); jest.mock('../../init/merge'); jest.mock('detect-indent'); -const rawNonMigrated = Fixtures.get('./renovate.json'); -const rawNonMigratedJson5 = Fixtures.get('./renovate.json5'); const migratedData = Fixtures.getJson('./migrated-data.json'); const migratedDataJson5 = Fixtures.getJson('./migrated-data.json5'); const migratedConfigObj = Fixtures.getJson('./migrated.json'); @@ -35,7 +33,6 @@ describe('workers/repository/config-migration/branch/migrated-data', () => { }); mockedFunction(detectRepoFileConfig).mockResolvedValue({ configFileName: 'renovate.json', - configFileRaw: rawNonMigrated, }); mockedFunction(migrateConfig).mockReturnValue({ isMigrated: true, @@ -102,7 +99,6 @@ describe('workers/repository/config-migration/branch/migrated-data', () => { it('Migrate a JSON5 config file', async () => { mockedFunction(detectRepoFileConfig).mockResolvedValueOnce({ configFileName: 'renovate.json5', - configFileRaw: rawNonMigratedJson5, }); MigratedDataFactory.reset(); await expect(MigratedDataFactory.getAsync()).resolves.toEqual( @@ -131,7 +127,6 @@ describe('workers/repository/config-migration/branch/migrated-data', () => { }); mockedFunction(detectRepoFileConfig).mockResolvedValueOnce({ configFileName: 'renovate.json', - configFileRaw: rawNonMigrated, }); mockedFunction(migrateConfig).mockReturnValueOnce({ isMigrated: true, diff --git a/lib/workers/repository/config-migration/branch/migrated-data.ts b/lib/workers/repository/config-migration/branch/migrated-data.ts index e96a24d9ec..5dd49c6bc5 100644 --- a/lib/workers/repository/config-migration/branch/migrated-data.ts +++ b/lib/workers/repository/config-migration/branch/migrated-data.ts @@ -130,11 +130,8 @@ export class MigratedDataFactory { private static async build(): Promise { let res: MigratedData | null = null; try { - const { - configFileName, - configFileRaw: raw, - configFileParsed = {}, - } = await detectRepoFileConfig(); + const { configFileName, configFileParsed = {} } = + await detectRepoFileConfig(); // get migrated config const { isMigrated, migratedConfig } = migrateConfig(configFileParsed); @@ -147,6 +144,7 @@ export class MigratedDataFactory { // indent defaults to 2 spaces // TODO #22198 + const raw = await readLocalFile(configFileName!, 'utf8'); const indent = detectIndent(raw!); const indentSpace = indent.indent ?? ' '; const filename = configFileName!; diff --git a/lib/workers/repository/init/merge.spec.ts b/lib/workers/repository/init/merge.spec.ts index b8e9bcbbe8..51fb01fe24 100644 --- a/lib/workers/repository/init/merge.spec.ts +++ b/lib/workers/repository/init/merge.spec.ts @@ -124,7 +124,6 @@ describe('workers/repository/init/merge', () => { configFileParsed: { schema: 'https://docs.renovate.com', }, - configFileRaw: undefined, }); }); @@ -199,7 +198,6 @@ describe('workers/repository/init/merge', () => { expect(await detectRepoFileConfig()).toEqual({ configFileName: 'renovate.json5', configFileParsed: {}, - configFileRaw, }); }); @@ -212,7 +210,6 @@ describe('workers/repository/init/merge', () => { expect(await detectRepoFileConfig()).toEqual({ configFileName: '.github/renovate.json', configFileParsed: {}, - configFileRaw: '{}', }); }); @@ -225,7 +222,6 @@ describe('workers/repository/init/merge', () => { expect(await detectRepoFileConfig()).toEqual({ configFileName: '.gitlab/renovate.json', configFileParsed: {}, - configFileRaw: '{}', }); }); @@ -236,14 +232,12 @@ describe('workers/repository/init/merge', () => { expect(await detectRepoFileConfig()).toEqual({ configFileName: '.renovaterc.json', configFileParsed: {}, - configFileRaw: '{}', }); expect(await detectRepoFileConfig()).toEqual({ configFileName: '.renovaterc.json', configFileParsed: { something: 'new', }, - configFileRaw: '{"something":"new"}', }); }); @@ -254,14 +248,12 @@ describe('workers/repository/init/merge', () => { expect(await detectRepoFileConfig()).toEqual({ configFileName: '.renovaterc.json5', configFileParsed: {}, - configFileRaw: '{}', }); expect(await detectRepoFileConfig()).toEqual({ configFileName: '.renovaterc.json5', configFileParsed: { something: 'new', }, - configFileRaw: '{"something":"new"}', }); }); }); diff --git a/lib/workers/repository/init/merge.ts b/lib/workers/repository/init/merge.ts index 9bfcf8fe86..93350d0293 100644 --- a/lib/workers/repository/init/merge.ts +++ b/lib/workers/repository/init/merge.ts @@ -72,7 +72,7 @@ export async function detectRepoFileConfig(): Promise { if (configFileRaw) { let configFileParsed = parseJson(configFileRaw, configFileName) as any; if (configFileName !== 'package.json') { - return { configFileName, configFileRaw, configFileParsed }; + return { configFileName, configFileParsed }; } configFileParsed = configFileParsed.renovate; return { configFileName, configFileParsed }; // don't return raw 'package.json' @@ -103,7 +103,7 @@ export async function detectRepoFileConfig(): Promise { const parsedConfig = cachedConfig ? JSON.parse(cachedConfig) : undefined; if (parsedConfig) { setOnboardingConfigDetails(configFileName, JSON.stringify(parsedConfig)); - return { configFileName, configFileRaw, configFileParsed: parsedConfig }; + return { configFileName, configFileParsed: parsedConfig }; } } @@ -202,7 +202,7 @@ export async function detectRepoFileConfig(): Promise { } setOnboardingConfigDetails(configFileName, JSON.stringify(configFileParsed)); - return { configFileName, configFileRaw, configFileParsed }; + return { configFileName, configFileParsed }; } export function checkForRepoConfigError(repoConfig: RepoFileConfig): void { diff --git a/lib/workers/repository/init/types.ts b/lib/workers/repository/init/types.ts index ebd6a87313..96590b420a 100644 --- a/lib/workers/repository/init/types.ts +++ b/lib/workers/repository/init/types.ts @@ -5,7 +5,6 @@ export interface RepoConfigError { export interface RepoFileConfig { configFileName?: string; - configFileRaw?: string | null; configFileParsed?: any; configFileParseError?: RepoConfigError; }