diff --git a/docs/configuration.md b/docs/configuration.md index 3f06ad851a62ec56b07309fbf1045b8bffb84a59..77a6461b374d01e7d9be472e0421628467ac87eb 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -83,7 +83,7 @@ $ node renovate --help --github-app-id <integer> GitHub App ID (enables GitHub App functionality if set) --github-app-key <string> GitHub App Private Key (.pem file contents) --package-files <list> Package file paths - --ignore-node-modules [boolean] Skip any package.json files found within node_modules folders + --ignore-paths <list> Skip any package.json whose path matches one of these. --ignore-deps <list> Dependencies to ignore --pin-versions [boolean] Convert ranged versions in package.json to pinned versions --separate-major-releases [boolean] If set to false, it will upgrade dependencies to latest release only, and not separate major/minor branches @@ -298,12 +298,12 @@ Obviously, you can't set repository or package file location with this method. <td>`--package-files`<td> </tr> <tr> - <td>`ignoreNodeModules`</td> - <td>Skip any package.json files found within node_modules folders</td> - <td>boolean</td> - <td><pre>true</pre></td> - <td>`RENOVATE_IGNORE_NODE_MODULES`</td> - <td>`--ignore-node-modules`<td> + <td>`ignorePaths`</td> + <td>Skip any package.json whose path matches one of these.</td> + <td>list</td> + <td><pre>["node_modules/"]</pre></td> + <td>`RENOVATE_IGNORE_PATHS`</td> + <td>`--ignore-paths`<td> </tr> <tr> <td>`dependencies`</td> @@ -577,7 +577,6 @@ Obviously, you can't set repository or package file location with this method. <td>json</td> <td><pre>{ "enabled": true, - "groupName": "Lock File Maintenance", "recreateClosed": true, "branchName": "{{branchPrefix}}lock-file-maintenance", "commitMessage": "Update lock file", diff --git a/lib/config/definitions.js b/lib/config/definitions.js index 20a9f07f0df3ec41027716df18945651903a991f..b61be3c58af903e20da4ed463128a64e9ff16fed 100644 --- a/lib/config/definitions.js +++ b/lib/config/definitions.js @@ -153,11 +153,11 @@ const options = [ stage: 'branch', }, { - name: 'ignoreNodeModules', - description: - 'Skip any package.json files found within node_modules folders', - type: 'boolean', + name: 'ignorePaths', + description: 'Skip any package.json whose path matches one of these.', + type: 'list', stage: 'repository', + default: ['node_modules/'], }, { name: 'dependencies', diff --git a/lib/config/migration.js b/lib/config/migration.js index 0cdeab9bce8308910e81c50c4745d361dcf72ba9..ad5131e026d1b07b2af6cb5f6f4f13646487728d 100644 --- a/lib/config/migration.js +++ b/lib/config/migration.js @@ -32,6 +32,10 @@ function migrateConfig(config, parentConfig) { if (removedOptions.includes(key)) { isMigrated = true; delete migratedConfig[key]; + } else if (key === 'ignoreNodeModules') { + isMigrated = true; + delete migratedConfig.ignoreNodeModules; + migratedConfig.ignorePaths = val ? ['node_modules/'] : []; } else if (key === 'semanticCommits') { if (parentConfig && parentConfig[key] === val) { isMigrated = true; diff --git a/lib/workers/repository/apis.js b/lib/workers/repository/apis.js index 649d7591606997325cc2faacb2fb21c613e0f627..a8458b3e18974f667acf46f2bd0d13efbff244b3 100644 --- a/lib/workers/repository/apis.js +++ b/lib/workers/repository/apis.js @@ -1,5 +1,4 @@ const conventionalCommitsDetector = require('conventional-commits-detector'); -const ini = require('ini'); const path = require('path'); const jsonValidator = require('json-dup-key-validator'); const configParser = require('../../config'); @@ -213,20 +212,22 @@ async function detectPackageFiles(input) { { packageFiles: config.packageFiles }, `Found ${config.packageFiles.length} package file(s)` ); - if (config.ignoreNodeModules) { + if (Array.isArray(config.ignorePaths)) { const skippedPackageFiles = []; config.packageFiles = config.packageFiles.filter(packageFile => { - if (packageFile.indexOf('node_modules/') === -1) { - return true; + if ( + config.ignorePaths.some(ignorePath => packageFile.includes(ignorePath)) + ) { + skippedPackageFiles.push(packageFile); + return false; } - skippedPackageFiles.push(packageFile); - return false; + return true; }); if (skippedPackageFiles.length) { - config.foundNodeModules = true; + config.foundIgnoredPaths = true; config.warnings.push({ depName: 'packageFiles', - message: `Skipped package.json files found within node_modules subfolders: \`${skippedPackageFiles}\``, + message: `Skipped package.json files found within ignored paths: \`${skippedPackageFiles}\``, }); config.logger.debug( `Now have ${config.packageFiles.length} package file(s) after filtering` diff --git a/test/config/__snapshots__/migration.spec.js.snap b/test/config/__snapshots__/migration.spec.js.snap index bf0549b8c60c97b0f7182fdf93ae651b263d0d74..601ded54de9756c1f59bff4bd81793e0d020423b 100644 --- a/test/config/__snapshots__/migration.spec.js.snap +++ b/test/config/__snapshots__/migration.spec.js.snap @@ -20,6 +20,9 @@ Object { }, }, "enabled": true, + "ignorePaths": Array [ + "node_modules/", + ], "lockFileConfig": Object { "automerge": true, }, diff --git a/test/config/migration.spec.js b/test/config/migration.spec.js index 1db292bda4ce76306d4af519f683868e4b36a645..a1c5f81672c31f02a26a68105fd8e36e283ff4f0 100644 --- a/test/config/migration.spec.js +++ b/test/config/migration.spec.js @@ -9,6 +9,7 @@ describe('config/migration', () => { maintainYarnLock: true, onboarding: 'false', automerge: 'none', + ignoreNodeModules: true, autodiscover: 'true', schedule: 'on the last day of the month', commitMessage: '{{semanticPrefix}}some commit message', diff --git a/test/workers/repository/__snapshots__/apis.spec.js.snap b/test/workers/repository/__snapshots__/apis.spec.js.snap index 140daabb656658bf2c681784a7fd80673d65064e..d27792d0035d8ce7f29d66035eaf43d4823d0608 100644 --- a/test/workers/repository/__snapshots__/apis.spec.js.snap +++ b/test/workers/repository/__snapshots__/apis.spec.js.snap @@ -54,7 +54,7 @@ exports[`workers/repository/apis detectPackageFiles(config) ignores node modules Array [ Object { "depName": "packageFiles", - "message": "Skipped package.json files found within node_modules subfolders: \`node_modules/backend/package.json\`", + "message": "Skipped package.json files found within ignored paths: \`node_modules/backend/package.json\`", }, ] `; diff --git a/test/workers/repository/apis.spec.js b/test/workers/repository/apis.spec.js index 30998c1eb3ea93998ed761da41aa5fdc3441114b..872bc8ab7c10b341730ef02b6183d54aa6c9cf65 100644 --- a/test/workers/repository/apis.spec.js +++ b/test/workers/repository/apis.spec.js @@ -229,7 +229,7 @@ describe('workers/repository/apis', () => { }); it('ignores node modules', async () => { const config = { - ignoreNodeModules: true, + ignorePaths: ['node_modules/'], api: { findFilePaths: jest.fn(() => [ 'package.json', @@ -241,7 +241,7 @@ describe('workers/repository/apis', () => { }; const res = await apis.detectPackageFiles(config); expect(res.packageFiles).toMatchSnapshot(); - expect(res.foundNodeModules).toMatchSnapshot(); + expect(res.foundIgnoredPaths).toMatchSnapshot(); expect(res.warnings).toMatchSnapshot(); }); it('defaults to package.json if found', async () => { diff --git a/test/workers/repository/onboarding.spec.js b/test/workers/repository/onboarding.spec.js index 823369c154dce1d42229580fed18c7498cc959f6..c45314d2558968be0d6fbbf408efaeb3059911c4 100644 --- a/test/workers/repository/onboarding.spec.js +++ b/test/workers/repository/onboarding.spec.js @@ -230,7 +230,7 @@ describe('lib/workers/repository/onboarding', () => { getPr: jest.fn(() => {}), getCommitMessages: jest.fn(), }; - config.foundNodeModules = true; + config.foundIgnoredPaths = true; config.logger = logger; config.detectedPackageFiles = true; onboarding.isRepoPrivate = jest.fn();