diff --git a/lib/workers/package-file/index.js b/lib/workers/package-file/index.js index ff276804132431f12093333f9d5835b3fcf9dd65..8df9fb6e63af4d02525fd620fdc02dcd7bd92086 100644 --- a/lib/workers/package-file/index.js +++ b/lib/workers/package-file/index.js @@ -10,7 +10,12 @@ module.exports = { async function findUpgrades(config) { logger = config.logger || logger; logger.info(`Processing package file`); - const packageContent = await config.api.getFileJson(config.packageFile); + // If onboarding, use the package.json in onboarding branch + const branchName = config.repoIsOnboarded ? null : 'renovate/configure'; + const packageContent = await config.api.getFileJson( + config.packageFile, + branchName + ); if (!packageContent) { logger.warn('No package.json content found - skipping'); diff --git a/lib/workers/repository/index.js b/lib/workers/repository/index.js index 82b8a3b84e0d2ec735302f04686ccc5073684afd..e9644b614e3791f32d80a53557bf851bd1591497 100644 --- a/lib/workers/repository/index.js +++ b/lib/workers/repository/index.js @@ -15,8 +15,8 @@ async function renovateRepository(packageFileConfig) { try { config = await apis.initApis(config); config = await apis.mergeRenovateJson(config); - const repoIsOnboarded = await onboarding.getOnboardingStatus(config); - if (!repoIsOnboarded) { + config.repoIsOnboarded = await onboarding.getOnboardingStatus(config); + if (!config.repoIsOnboarded) { config = await apis.mergeRenovateJson(config, 'renovate/configure'); } const hasConfiguredPackageFiles = config.packageFiles.length > 0; @@ -35,7 +35,7 @@ async function renovateRepository(packageFileConfig) { config.logger.debug( `Updating ${Object.keys(branchUpgrades).length} branch(es)` ); - if (repoIsOnboarded) { + if (config.repoIsOnboarded) { for (const branchName of Object.keys(branchUpgrades)) { await branchWorker.updateBranch(branchUpgrades[branchName]); } diff --git a/lib/workers/repository/onboarding.js b/lib/workers/repository/onboarding.js index da6be62894d5f6038af336ad525bea98c4a16211..67ee579f202784ae878c9afd7ae5ca3cefd65211 100644 --- a/lib/workers/repository/onboarding.js +++ b/lib/workers/repository/onboarding.js @@ -32,6 +32,7 @@ async function ensurePr(config, branchUpgrades) { let prBody = `Welcome to [Renovate](https://keylocation.sg/our-tech/renovate)! This is an onboarding PR to help you understand and configure Renovate before any changes are made to any \`package.json\` files. Once you close this Pull Request, we will begin keeping your dependencies up-to-date via automated Pull Requests. + --- {{PRDESCRIPTION}} diff --git a/test/workers/package-file/index.spec.js b/test/workers/package-file/index.spec.js index 231e52fe5107ed777f6f721241639e5a349fa1d1..1de452a44357104c9487b5510ea14900a0048e7f 100644 --- a/test/workers/package-file/index.spec.js +++ b/test/workers/package-file/index.spec.js @@ -8,6 +8,7 @@ describe('packageFileWorker', () => { let config; beforeEach(() => { config = { + repoIsOnboarded: true, api: { getFileJson: jest.fn(), }, @@ -23,6 +24,17 @@ describe('packageFileWorker', () => { config.enabled = false; config.api.getFileJson.mockReturnValueOnce({}); const res = await packageFileWorker.findUpgrades(config); + expect(config.api.getFileJson.mock.calls[0][1]).toBe(null); + expect(res).toEqual([]); + }); + it('uses onboarding branch', async () => { + config.enabled = false; + config.repoIsOnboarded = false; + config.api.getFileJson.mockReturnValueOnce({}); + const res = await packageFileWorker.findUpgrades(config); + expect(config.api.getFileJson.mock.calls[0][1]).toEqual( + 'renovate/configure' + ); expect(res).toEqual([]); }); it('returns empty array if config disabled', async () => { diff --git a/test/workers/repository/__snapshots__/onboarding.spec.js.snap b/test/workers/repository/__snapshots__/onboarding.spec.js.snap index 9e171f0f9b3316b54b1261e3b0af69fd80de1c8c..0c471d7f38378dd39bef1a4276cc8a3c4b5c10eb 100644 --- a/test/workers/repository/__snapshots__/onboarding.spec.js.snap +++ b/test/workers/repository/__snapshots__/onboarding.spec.js.snap @@ -8,6 +8,7 @@ Array [ "Welcome to [Renovate](https://keylocation.sg/our-tech/renovate)! This is an onboarding PR to help you understand and configure Renovate before any changes are made to any \`package.json\` files. Once you close this Pull Request, we will begin keeping your dependencies up-to-date via automated Pull Requests. + --- @@ -46,6 +47,7 @@ Array [ "Welcome to [Renovate](https://keylocation.sg/our-tech/renovate)! This is an onboarding PR to help you understand and configure Renovate before any changes are made to any \`package.json\` files. Once you close this Pull Request, we will begin keeping your dependencies up-to-date via automated Pull Requests. + --- It looks like your repository dependencies are already up-to-date and no initial Pull Requests will be necessary. diff --git a/test/workers/repository/onboarding.spec.js b/test/workers/repository/onboarding.spec.js index ee0f2865cddaf9f270bb5597c2ebd1c7af573b35..1b3868cb275584ec7e67ea31cb36df7ac40466a2 100644 --- a/test/workers/repository/onboarding.spec.js +++ b/test/workers/repository/onboarding.spec.js @@ -30,6 +30,7 @@ describe('lib/workers/repository/onboarding', () => { const existingPrBody = `Welcome to [Renovate](https://keylocation.sg/our-tech/renovate)! This is an onboarding PR to help you understand and configure Renovate before any changes are made to any \`package.json\` files. Once you close this Pull Request, we will begin keeping your dependencies up-to-date via automated Pull Requests. + --- It looks like your repository dependencies are already up-to-date and no initial Pull Requests will be necessary.