feat: includePaths (#1896)

Adds a config option `includePaths` that allows the user to specify one or more paths to include in renovation and the rest will be excluded.
This commit is contained in:
Rhys Arkins 2018-04-30 16:13:32 +02:00 committed by GitHub
parent 55c2a4619e
commit 43742467f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 1 deletions

View file

@ -272,6 +272,13 @@ const options = [
type: 'list', type: 'list',
stage: 'branch', stage: 'branch',
}, },
{
name: 'includePaths',
description: 'Include package files only within these defined paths',
type: 'list',
stage: 'repository',
default: [],
},
{ {
name: 'ignorePaths', name: 'ignorePaths',
description: description:

View file

@ -34,7 +34,15 @@ async function detectPackageFiles(config) {
logger.debug('detectPackageFiles()'); logger.debug('detectPackageFiles()');
logger.trace({ config }); logger.trace({ config });
let packageFiles = []; let packageFiles = [];
const fileList = (await platform.getFileList()).filter( let fileList = await platform.getFileList();
if (config.includePaths.length) {
fileList = fileList.filter(file =>
config.includePaths.some(
includePath => file === includePath || minimatch(file, includePath)
)
);
}
fileList = fileList.filter(
file => file =>
!config.ignorePaths.some( !config.ignorePaths.some(
ignorePath => file.includes(ignorePath) || minimatch(file, ignorePath) ignorePath => file.includes(ignorePath) || minimatch(file, ignorePath)

View file

@ -118,6 +118,7 @@ Object {
"**/bower_components/**", "**/bower_components/**",
], ],
"ignoreUnstable": true, "ignoreUnstable": true,
"includePaths": Array [],
"labels": Array [], "labels": Array [],
"lazyGrouping": true, "lazyGrouping": true,
"lockFileMaintenance": Object { "lockFileMaintenance": Object {

View file

@ -80,3 +80,12 @@ exports[`manager detectPackageFiles(config) ignores node modules 2`] = `undefine
exports[`manager detectPackageFiles(config) ignores node modules 3`] = `undefined`; exports[`manager detectPackageFiles(config) ignores node modules 3`] = `undefined`;
exports[`manager detectPackageFiles(config) skips meteor package files with no json 1`] = `Array []`; exports[`manager detectPackageFiles(config) skips meteor package files with no json 1`] = `Array []`;
exports[`manager detectPackageFiles(config) uses includePaths 1`] = `
Array [
Object {
"manager": "npm",
"packageFile": "package.json",
},
]
`;

View file

@ -140,6 +140,16 @@ describe('manager', () => {
expect(res.foundIgnoredPaths).toMatchSnapshot(); expect(res.foundIgnoredPaths).toMatchSnapshot();
expect(res.warnings).toMatchSnapshot(); expect(res.warnings).toMatchSnapshot();
}); });
it('uses includePaths', async () => {
platform.getFileList.mockReturnValueOnce([
'package.json',
'backend/package.json',
]);
config.includePaths = ['package.json'];
const res = await manager.detectPackageFiles(config);
expect(res).toMatchSnapshot();
expect(res).toHaveLength(1);
});
}); });
describe('getManager', () => { describe('getManager', () => {
it('rejects unknown files', () => { it('rejects unknown files', () => {

View file

@ -547,6 +547,19 @@ Ignore versions with unstable semver.
By default, Renovate won't update any packages to unstable versions (e.g. `4.0.0-rc3`) unless the package version was _already_ unstable (e.g. it was already on `4.0.0-rc2`). If for some reason you wish to _force_ unstable updates on Renovate, you can set `ignoreUnstable` to `false`, but this is not recommended for most situations. By default, Renovate won't update any packages to unstable versions (e.g. `4.0.0-rc3`) unless the package version was _already_ unstable (e.g. it was already on `4.0.0-rc2`). If for some reason you wish to _force_ unstable updates on Renovate, you can set `ignoreUnstable` to `false`, but this is not recommended for most situations.
## includePaths
Include package files only within these defined paths.
| name | value |
| ------- | ---------------- |
| type | array of strings |
| default | [] |
If you wish for Renovate to process only select paths in the repository, use `includePaths`.
If instead you need to just exclude/ignore certain paths then consider `ignorePaths` instead.
If you are more interested in including only certain package managers (e.g. `npm`), then consider `enabledManagers` instead.
## labels ## labels
Labels to add to Pull Requests Labels to add to Pull Requests