diff --git a/docs/usage/self-hosted-configuration.md b/docs/usage/self-hosted-configuration.md index 0c884c5baedf3b21097d7fce6e01d7728808f649..a743db4029130a787833e2196c56ac496b535fb4 100644 --- a/docs/usage/self-hosted-configuration.md +++ b/docs/usage/self-hosted-configuration.md @@ -298,6 +298,11 @@ Note that if `commitMessagePrefix` or `semanticCommits` values are defined then If set to one of the valid [config file names](https://docs.renovatebot.com/configuration-options/), the onboarding PR will create a configuration file with the provided name instead of `renovate.json`. Falls back to `renovate.json` if the name provided is not valid. +## onboardingNoDeps + +Set this to true if you want Renovate to create an onboarding PR even if no dependencies are found. +Otherwise, Renovate skips onboarding a repository if it finds no dependencies in it. + ## onboardingPrTitle Similarly to `onboardingBranch`, if you have an existing Renovate installation and you change `onboardingPrTitle` then it's possible that you'll get onboarding PRs for repositories that had previously closed the onboarding PR unmerged. diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index d043910c68a2c05dffb8ced004dab14d8a48ffd6..73c766d2da22f6be2e462559e782e0414ea0c95f 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -99,6 +99,13 @@ const options: RenovateOptions[] = [ globalOnly: true, cli: false, }, + { + name: 'onboardingNoDeps', + description: 'Onboard repository even if no dependencies found.', + type: 'boolean', + default: false, + globalOnly: true, + }, { name: 'onboardingPrTitle', description: diff --git a/lib/config/types.ts b/lib/config/types.ts index c13b6fc752710b592bd5bb4d47d46c5945c93610..15181d87bb3122a9f3dbf01e988e71d5ab876dde 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -117,6 +117,7 @@ export interface LegacyAdminConfig { onboarding?: boolean; onboardingBranch?: string; onboardingCommitMessage?: string; + onboardingNoDeps?: boolean; onboardingPrTitle?: string; onboardingConfig?: RenovateSharedConfig; onboardingConfigFileName?: string; diff --git a/lib/workers/repository/onboarding/branch/index.spec.ts b/lib/workers/repository/onboarding/branch/index.spec.ts index a3c45516a9ae7739c15cf9f7c3fcab8d07631e3d..cea792f305188ef28824e4b51c82ffd386f6758e 100644 --- a/lib/workers/repository/onboarding/branch/index.spec.ts +++ b/lib/workers/repository/onboarding/branch/index.spec.ts @@ -44,6 +44,14 @@ describe('workers/repository/onboarding/branch/index', () => { REPOSITORY_NO_PACKAGE_FILES ); }); + + it("doesn't throw if there are no package files and onboardingNoDeps config option is set", async () => { + config.onboardingNoDeps = true; + await expect(checkOnboardingBranch(config)).resolves.not.toThrow( + REPOSITORY_NO_PACKAGE_FILES + ); + }); + it('throws if fork', async () => { config.isFork = true; await expect(checkOnboardingBranch(config)).rejects.toThrow( diff --git a/lib/workers/repository/onboarding/branch/index.ts b/lib/workers/repository/onboarding/branch/index.ts index 370e668069f38ef5e38065a4cce6eea46a70b514..9910884ef0f026106df07bac0d6056665b2c471e 100644 --- a/lib/workers/repository/onboarding/branch/index.ts +++ b/lib/workers/repository/onboarding/branch/index.ts @@ -56,7 +56,9 @@ export async function checkOnboardingBranch( if ( Object.entries(await extractAllDependencies(mergedConfig)).length === 0 ) { - throw new Error(REPOSITORY_NO_PACKAGE_FILES); + if (!config?.onboardingNoDeps) { + throw new Error(REPOSITORY_NO_PACKAGE_FILES); + } } logger.debug('Need to create onboarding PR'); const commit = await createOnboardingBranch(mergedConfig);