Implement renovate config generator (#38369)

* reformat renovate.json5 with json5 cli, add header

* add scripts for rengerating renovate config from ts files

* regenerate renovate config

* verify renovate.json5 is up to date in CI

* add description to the build_renovate_config script

* auto-group types packages

* fix typo

* mention version pinning in doc block

* support disabling renovate for package groups

* scan all package paths for @-types deps

* regenerate renovate config

* regenerate renovate config

* name scoped package regexp

* move some of the new logic out of package_groups.ts

* flatMap in one pass
This commit is contained in:
Spencer 2019-06-07 13:30:59 -07:00 committed by GitHub
parent 44fc8c91d7
commit 0f5bd4dfcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 1232 additions and 103 deletions

1
.github/CODEOWNERS vendored
View file

@ -23,6 +23,7 @@
/x-pack/plugins/ml/ @elastic/ml-ui
# Operations
/renovate.json5 @elastic/kibana-operations
/src/dev/ @elastic/kibana-operations
/src/setup_node_env/ @elastic/kibana-operations
/src/optimize/ @elastic/kibana-operations

View file

@ -1,8 +1,13 @@
/**
* PLEASE DO NOT MODIFY
*
* This file is automatically generated by running `node scripts/build_renovate_config`
*
*/
{
extends: [
'config:base'
'config:base',
],
includePaths: [
'package.json',
'x-pack/package.json',
@ -11,22 +16,15 @@
'test/plugin_functional/plugins/*/package.json',
'test/interpreter_functional/plugins/*/package.json',
],
/**
* Only submit PRs to these branches, we will manually backport PRs for now
*/
baseBranches: ['master'],
/**
* Labels added to PRs opened by renovate
*/
baseBranches: [
'master',
],
labels: [
'release_note:skip',
'renovate',
'v8.0.0',
'v7.3.0'
'v7.3.0',
],
major: {
labels: [
'release_note:skip',
@ -34,118 +32,143 @@
'v8.0.0',
'v7.3.0',
'renovate:major',
]
],
},
/**
* Enable creation of a "Master Issue" within the repository. This
* Master Issue is akin to a mini dashboard and contains a list of all
* PRs pending, open, closed (unmerged) or in error.
*/
masterIssue: true,
/**
* Whether updates should require manual approval from within the
* Master Issue before creation.
*
* We can turn this off once we've gotten through the backlog of
* outdated packages.
*/
masterIssueApproval: true,
/**
* Policy for how to modify/update existing ranges
* pin = convert ranges to exact versions, e.g. ^1.0.0 -> 1.1.0
*/
rangeStrategy: 'replace',
npm: {
/**
* This deletes and re-creates the lock file, which we will only want
* to turn on once we've updated all our deps
*/
lockFileMaintenance: { enabled: false },
/**
* Define groups of packages that should be updated/configured together
*/
lockFileMaintenance: {
enabled: false,
},
packageRules: [
{
packagePatterns: ['\\beslint\\b'],
groupName: 'eslint related packages',
groupSlug: 'eslint',
groupName: 'eslint related packages',
packagePatterns: [
'(\\b|_)eslint(\\b|_)',
],
},
{
packagePatterns: ['\\bbabel\\b'],
packageNames: ['core-js'],
groupName: 'babel related packages',
groupSlug: 'babel',
groupName: 'babel related packages',
packagePatterns: [
'(\\b|_)babel(\\b|_)',
],
packageNames: [
'core-js',
'@types/core-js',
],
},
{
packagePatterns: ['\\bjest\\b'],
groupName: 'jest related packages',
groupSlug: 'jest',
groupName: 'jest related packages',
packagePatterns: [
'(\\b|_)jest(\\b|_)',
],
},
{
packagePatterns: ['\\bmocha\\b'],
groupName: 'mocha related packages',
groupSlug: 'mocha',
groupName: 'mocha related packages',
packagePatterns: [
'(\\b|_)mocha(\\b|_)',
],
},
{
packagePatterns: ['\\bkarma\\b'],
groupName: 'karma related packages',
groupSlug: 'karma',
groupName: 'karma related packages',
packagePatterns: [
'(\\b|_)karma(\\b|_)',
],
},
{
packagePatterns: ['\\bgulp\\b'],
groupName: 'gulp related packages',
groupSlug: 'gulp',
groupName: 'gulp related packages',
packagePatterns: [
'(\\b|_)gulp(\\b|_)',
],
},
{
packagePatterns: ['\\bgrunt\\b'],
groupName: 'grunt related packages',
groupSlug: 'grunt',
groupName: 'grunt related packages',
packagePatterns: [
'(\\b|_)grunt(\\b|_)',
],
},
{
packagePatterns: ['\\bangular\\b'],
groupName: 'angular related packages',
groupSlug: 'angular',
recreateClosed: false,
groupName: 'angular related packages',
packagePatterns: [
'(\\b|_)angular(\\b|_)',
],
},
{
packagePatterns: ['\\bd3\\b'],
groupName: 'd3 related packages',
groupSlug: 'd3',
groupName: 'd3 related packages',
packagePatterns: [
'(\\b|_)d3(\\b|_)',
],
},
{
packagePatterns: ['\\breact\\b', '\\bredux\\b', '\\benzyme\\b'],
groupSlug: 'react',
groupName: 'react related packages',
packagePatterns: [
'(\\b|_)react(\\b|_)',
'(\\b|_)redux(\\b|_)',
'(\\b|_)enzyme(\\b|_)',
],
packageNames: [
'ngreact',
'@types/ngreact',
'recompose',
'@types/recompose',
'prop-types',
'@types/prop-types',
'typescript-fsa-reducers',
'reselect'
'@types/typescript-fsa-reducers',
'reselect',
'@types/reselect',
],
groupName: 'react related packages',
groupSlug: 'react',
},
{
packagePatterns: ['\\bgraphql\\b'],
groupName: 'graphql related packages',
groupSlug: 'graphql',
groupName: 'graphql related packages',
packagePatterns: [
'(\\b|_)graphql(\\b|_)',
],
},
{
packagePatterns: ['\\bwebpack\\b', '\\bloader\\b'],
packageNames: ['mini-css-extract-plugin', 'chokidar'],
groupName: 'webpack related packages',
groupSlug: 'webpack',
groupName: 'webpack related packages',
packagePatterns: [
'(\\b|_)webpack(\\b|_)',
'(\\b|_)loader(\\b|_)',
],
packageNames: [
'mini-css-extract-plugin',
'@types/mini-css-extract-plugin',
'chokidar',
'@types/chokidar',
],
},
{
packageNames: ['vscode-jsonrpc', 'vscode-languageserver', 'vscode-languageserver-types'],
groupName: 'language server related packages',
groupSlug: 'language server',
groupName: 'language server related packages',
packageNames: [
'vscode-jsonrpc',
'@types/vscode-jsonrpc',
'vscode-languageserver',
'@types/vscode-languageserver',
'vscode-languageserver-types',
'@types/vscode-languageserver-types',
],
},
{
groupSlug: 'hapi',
groupName: 'hapi related packages',
packagePatterns: [
'(\\b|_)hapi(\\b|_)',
],
packageNames: [
'hapi',
'@types/hapi',
@ -156,51 +179,677 @@
'hoek',
'@types/hoek',
'h2o2',
'@types/h2o2',
'@elastic/good',
'@types/elastic__good',
'good-squeeze',
'inert'
'@types/good-squeeze',
'inert',
'@types/inert',
],
packagePatterns: ['\\bhapi\\b'],
groupName: 'hapi related packages',
groupSlug: 'hapi',
},
// internal/local packages
{
packagePatterns: ['^@kbn/.*'],
enabled: false,
groupSlug: 'dragselect',
groupName: 'dragselect related packages',
packageNames: [
'dragselect',
'@types/dragselect',
],
labels: [
'release_note:skip',
'renovate',
'v8.0.0',
'v7.3.0',
':ml',
],
},
// docs generator
{
groupSlug: 'api-documenter',
groupName: 'api-documenter related packages',
packageNames: [
'@microsoft/api-documenter',
'@microsoft/api-extractor'
'@types/microsoft__api-documenter',
'@microsoft/api-extractor',
'@types/microsoft__api-extractor',
],
enabled: false,
}
},
{
groupSlug: 'json-stable-stringify',
groupName: 'json-stable-stringify related packages',
packageNames: [
'json-stable-stringify',
'@types/json-stable-stringify',
],
},
{
groupSlug: 'lodash.clonedeep',
groupName: 'lodash.clonedeep related packages',
packageNames: [
'lodash.clonedeep',
'@types/lodash.clonedeep',
],
},
{
groupSlug: 'bluebird',
groupName: 'bluebird related packages',
packageNames: [
'bluebird',
'@types/bluebird',
],
},
{
groupSlug: 'chance',
groupName: 'chance related packages',
packageNames: [
'chance',
'@types/chance',
],
},
{
groupSlug: 'cheerio',
groupName: 'cheerio related packages',
packageNames: [
'cheerio',
'@types/cheerio',
],
},
{
groupSlug: 'chromedriver',
groupName: 'chromedriver related packages',
packageNames: [
'chromedriver',
'@types/chromedriver',
],
},
{
groupSlug: 'classnames',
groupName: 'classnames related packages',
packageNames: [
'classnames',
'@types/classnames',
],
},
{
groupSlug: 'dedent',
groupName: 'dedent related packages',
packageNames: [
'dedent',
'@types/dedent',
],
},
{
groupSlug: 'delete-empty',
groupName: 'delete-empty related packages',
packageNames: [
'delete-empty',
'@types/delete-empty',
],
},
{
groupSlug: 'elasticsearch',
groupName: 'elasticsearch related packages',
packageNames: [
'elasticsearch',
'@types/elasticsearch',
],
},
{
groupSlug: 'execa',
groupName: 'execa related packages',
packageNames: [
'execa',
'@types/execa',
],
},
{
groupSlug: 'fetch-mock',
groupName: 'fetch-mock related packages',
packageNames: [
'fetch-mock',
'@types/fetch-mock',
],
},
{
groupSlug: 'getopts',
groupName: 'getopts related packages',
packageNames: [
'getopts',
'@types/getopts',
],
},
{
groupSlug: 'glob',
groupName: 'glob related packages',
packageNames: [
'glob',
'@types/glob',
],
},
{
groupSlug: 'globby',
groupName: 'globby related packages',
packageNames: [
'globby',
'@types/globby',
],
},
{
groupSlug: 'has-ansi',
groupName: 'has-ansi related packages',
packageNames: [
'has-ansi',
'@types/has-ansi',
],
},
{
groupSlug: 'humps',
groupName: 'humps related packages',
packageNames: [
'humps',
'@types/humps',
],
},
{
groupSlug: 'jquery',
groupName: 'jquery related packages',
packageNames: [
'jquery',
'@types/jquery',
],
},
{
groupSlug: 'js-yaml',
groupName: 'js-yaml related packages',
packageNames: [
'js-yaml',
'@types/js-yaml',
],
},
{
groupSlug: 'json5',
groupName: 'json5 related packages',
packageNames: [
'json5',
'@types/json5',
],
},
{
groupSlug: 'license-checker',
groupName: 'license-checker related packages',
packageNames: [
'license-checker',
'@types/license-checker',
],
},
{
groupSlug: 'listr',
groupName: 'listr related packages',
packageNames: [
'listr',
'@types/listr',
],
},
{
groupSlug: 'lodash',
groupName: 'lodash related packages',
packageNames: [
'lodash',
'@types/lodash',
],
},
{
groupSlug: 'lru-cache',
groupName: 'lru-cache related packages',
packageNames: [
'lru-cache',
'@types/lru-cache',
],
},
{
groupSlug: 'markdown-it',
groupName: 'markdown-it related packages',
packageNames: [
'markdown-it',
'@types/markdown-it',
],
},
{
groupSlug: 'minimatch',
groupName: 'minimatch related packages',
packageNames: [
'minimatch',
'@types/minimatch',
],
},
{
groupSlug: 'moment-timezone',
groupName: 'moment-timezone related packages',
packageNames: [
'moment-timezone',
'@types/moment-timezone',
],
},
{
groupSlug: 'mustache',
groupName: 'mustache related packages',
packageNames: [
'mustache',
'@types/mustache',
],
},
{
groupSlug: 'node',
groupName: 'node related packages',
packageNames: [
'node',
'@types/node',
],
},
{
groupSlug: 'opn',
groupName: 'opn related packages',
packageNames: [
'opn',
'@types/opn',
],
},
{
groupSlug: 'podium',
groupName: 'podium related packages',
packageNames: [
'podium',
'@types/podium',
],
},
{
groupSlug: 'puppeteer-core',
groupName: 'puppeteer-core related packages',
packageNames: [
'puppeteer-core',
'@types/puppeteer-core',
],
},
{
groupSlug: 'request',
groupName: 'request related packages',
packageNames: [
'request',
'@types/request',
],
},
{
groupSlug: 'rimraf',
groupName: 'rimraf related packages',
packageNames: [
'rimraf',
'@types/rimraf',
],
},
{
groupSlug: 'selenium-webdriver',
groupName: 'selenium-webdriver related packages',
packageNames: [
'selenium-webdriver',
'@types/selenium-webdriver',
],
},
{
groupSlug: 'semver',
groupName: 'semver related packages',
packageNames: [
'semver',
'@types/semver',
],
},
{
groupSlug: 'sinon',
groupName: 'sinon related packages',
packageNames: [
'sinon',
'@types/sinon',
],
},
{
groupSlug: 'strip-ansi',
groupName: 'strip-ansi related packages',
packageNames: [
'strip-ansi',
'@types/strip-ansi',
],
},
{
groupSlug: 'styled-components',
groupName: 'styled-components related packages',
packageNames: [
'styled-components',
'@types/styled-components',
],
},
{
groupSlug: 'supertest',
groupName: 'supertest related packages',
packageNames: [
'supertest',
'@types/supertest',
],
},
{
groupSlug: 'type-detect',
groupName: 'type-detect related packages',
packageNames: [
'type-detect',
'@types/type-detect',
],
},
{
groupSlug: 'uuid',
groupName: 'uuid related packages',
packageNames: [
'uuid',
'@types/uuid',
],
},
{
groupSlug: 'zen-observable',
groupName: 'zen-observable related packages',
packageNames: [
'zen-observable',
'@types/zen-observable',
],
},
{
groupSlug: 'base64-js',
groupName: 'base64-js related packages',
packageNames: [
'base64-js',
'@types/base64-js',
],
},
{
groupSlug: 'chroma-js',
groupName: 'chroma-js related packages',
packageNames: [
'chroma-js',
'@types/chroma-js',
],
},
{
groupSlug: 'color',
groupName: 'color related packages',
packageNames: [
'color',
'@types/color',
],
},
{
groupSlug: 'file-saver',
groupName: 'file-saver related packages',
packageNames: [
'file-saver',
'@types/file-saver',
],
},
{
groupSlug: 'git-url-parse',
groupName: 'git-url-parse related packages',
packageNames: [
'git-url-parse',
'@types/git-url-parse',
],
},
{
groupSlug: 'history',
groupName: 'history related packages',
packageNames: [
'history',
'@types/history',
],
},
{
groupSlug: 'jsonwebtoken',
groupName: 'jsonwebtoken related packages',
packageNames: [
'jsonwebtoken',
'@types/jsonwebtoken',
],
},
{
groupSlug: 'memoize-one',
groupName: 'memoize-one related packages',
packageNames: [
'memoize-one',
'@types/memoize-one',
],
},
{
groupSlug: 'mime',
groupName: 'mime related packages',
packageNames: [
'mime',
'@types/mime',
],
},
{
groupSlug: 'mkdirp',
groupName: 'mkdirp related packages',
packageNames: [
'mkdirp',
'@types/mkdirp',
],
},
{
groupSlug: 'nock',
groupName: 'nock related packages',
packageNames: [
'nock',
'@types/nock',
],
},
{
groupSlug: 'node-fetch',
groupName: 'node-fetch related packages',
packageNames: [
'node-fetch',
'@types/node-fetch',
],
},
{
groupSlug: 'object-hash',
groupName: 'object-hash related packages',
packageNames: [
'object-hash',
'@types/object-hash',
],
},
{
groupSlug: 'papaparse',
groupName: 'papaparse related packages',
packageNames: [
'papaparse',
'@types/papaparse',
],
},
{
groupSlug: 'pngjs',
groupName: 'pngjs related packages',
packageNames: [
'pngjs',
'@types/pngjs',
],
},
{
groupSlug: 'proper-lockfile',
groupName: 'proper-lockfile related packages',
packageNames: [
'proper-lockfile',
'@types/proper-lockfile',
],
},
{
groupSlug: 'reduce-reducers',
groupName: 'reduce-reducers related packages',
packageNames: [
'reduce-reducers',
'@types/reduce-reducers',
],
},
{
groupSlug: '@storybook/addon-actions',
groupName: '@storybook/addon-actions related packages',
packageNames: [
'@storybook/addon-actions',
'@types/storybook__addon-actions',
],
},
{
groupSlug: '@storybook/addon-info',
groupName: '@storybook/addon-info related packages',
packageNames: [
'@storybook/addon-info',
'@types/storybook__addon-info',
],
},
{
groupSlug: '@storybook/addon-knobs',
groupName: '@storybook/addon-knobs related packages',
packageNames: [
'@storybook/addon-knobs',
'@types/storybook__addon-knobs',
],
},
{
groupSlug: 'tar-fs',
groupName: 'tar-fs related packages',
packageNames: [
'tar-fs',
'@types/tar-fs',
],
},
{
groupSlug: 'tinycolor2',
groupName: 'tinycolor2 related packages',
packageNames: [
'tinycolor2',
'@types/tinycolor2',
],
},
{
groupSlug: 'intl-relativeformat',
groupName: 'intl-relativeformat related packages',
packageNames: [
'intl-relativeformat',
'@types/intl-relativeformat',
],
},
{
groupSlug: 'cmd-shim',
groupName: 'cmd-shim related packages',
packageNames: [
'cmd-shim',
'@types/cmd-shim',
],
},
{
groupSlug: 'cpy',
groupName: 'cpy related packages',
packageNames: [
'cpy',
'@types/cpy',
],
},
{
groupSlug: 'indent-string',
groupName: 'indent-string related packages',
packageNames: [
'indent-string',
'@types/indent-string',
],
},
{
groupSlug: 'lodash.clonedeepwith',
groupName: 'lodash.clonedeepwith related packages',
packageNames: [
'lodash.clonedeepwith',
'@types/lodash.clonedeepwith',
],
},
{
groupSlug: 'log-symbols',
groupName: 'log-symbols related packages',
packageNames: [
'log-symbols',
'@types/log-symbols',
],
},
{
groupSlug: 'ncp',
groupName: 'ncp related packages',
packageNames: [
'ncp',
'@types/ncp',
],
},
{
groupSlug: 'ora',
groupName: 'ora related packages',
packageNames: [
'ora',
'@types/ora',
],
},
{
groupSlug: 'read-pkg',
groupName: 'read-pkg related packages',
packageNames: [
'read-pkg',
'@types/read-pkg',
],
},
{
groupSlug: 'strong-log-transformer',
groupName: 'strong-log-transformer related packages',
packageNames: [
'strong-log-transformer',
'@types/strong-log-transformer',
],
},
{
groupSlug: 'tempy',
groupName: 'tempy related packages',
packageNames: [
'tempy',
'@types/tempy',
],
},
{
groupSlug: 'wrap-ansi',
groupName: 'wrap-ansi related packages',
packageNames: [
'wrap-ansi',
'@types/wrap-ansi',
],
},
{
groupSlug: 'write-pkg',
groupName: 'write-pkg related packages',
packageNames: [
'write-pkg',
'@types/write-pkg',
],
},
{
packagePatterns: [
'^@kbn/.*',
],
enabled: false,
},
],
},
/**
* Limit the number of active PRs renovate will allow
*/
prConcurrentLimit: 6,
/**
* Disable vulnerability alert handling, we handle that separately
*/
vulnerabilityAlerts: {
enabled: false
enabled: false,
},
/**
* Disable automatic rebase on each change to base branch
*/
rebaseStalePrs: false,
/**
* Disable semantic commit formating
*/
semanticCommits: false,
}

View file

@ -0,0 +1,21 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
require('../src/setup_node_env');
require('../src/dev/renovate/run_build_renovate_config_cli');

View file

@ -181,6 +181,22 @@ if [ "$GIT_CHANGES" ]; then
exit 1
fi
###
### rebuild kbn-pm distributable to ensure it's not out of date
###
echo " -- building renovate config"
node scripts/build_renovate_config
###
### verify no git modifications
###
GIT_CHANGES="$(git ls-files --modified)"
if [ "$GIT_CHANGES" ]; then
echo -e "\n${RED}ERROR: 'node scripts/build_renovate_config' caused changes to the following files:${C_RESET}\n"
echo -e "$GIT_CHANGES\n"
exit 1
fi
###
### github-checks-reporter kill switch. Remove to disable
###

119
src/dev/renovate/config.ts Normal file
View file

@ -0,0 +1,119 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { RENOVATE_PACKAGE_GROUPS } from './package_groups';
import { PACKAGE_GLOBS } from './package_globs';
import { wordRegExp, maybeFlatMap, maybeMap, getTypePackageName } from './utils';
const DEFAULT_LABELS = ['release_note:skip', 'renovate', 'v8.0.0', 'v7.3.0'];
export const RENOVATE_CONFIG = {
extends: ['config:base'],
includePaths: PACKAGE_GLOBS,
/**
* Only submit PRs to these branches, we will manually backport PRs for now
*/
baseBranches: ['master'],
/**
* Labels added to PRs opened by renovate
*/
labels: DEFAULT_LABELS,
/**
* Config customizations for major version upgrades
*/
major: {
labels: [...DEFAULT_LABELS, 'renovate:major'],
},
/**
* Enable creation of a "Master Issue" within the repository. This
* Master Issue is akin to a mini dashboard and contains a list of all
* PRs pending, open, closed (unmerged) or in error.
*/
masterIssue: true,
/**
* Whether updates should require manual approval from within the
* Master Issue before creation.
*
* We can turn this off once we've gotten through the backlog of
* outdated packages.
*/
masterIssueApproval: true,
/**
* Policy for how to modify/update existing ranges
* pin = convert ranges to exact versions, e.g. ^1.0.0 -> 1.1.0
*/
rangeStrategy: 'replace',
npm: {
/**
* This deletes and re-creates the lock file, which we will only want
* to turn on once we've updated all our deps and enabled version pinning
*/
lockFileMaintenance: { enabled: false },
/**
* Define groups of packages that should be updated/configured together
*/
packageRules: [
...RENOVATE_PACKAGE_GROUPS.map(group => ({
groupSlug: group.name,
groupName: `${group.name} related packages`,
packagePatterns: maybeMap(group.packageWords, word => wordRegExp(word).source),
packageNames: maybeFlatMap(group.packageNames, name => [name, getTypePackageName(name)]),
labels: group.extraLabels && [...DEFAULT_LABELS, ...group.extraLabels],
enabled: group.enabled === false ? false : undefined,
})),
// internal/local packages
{
packagePatterns: ['^@kbn/.*'],
enabled: false,
},
],
},
/**
* Limit the number of active PRs renovate will allow
*/
prConcurrentLimit: 6,
/**
* Disable vulnerability alert handling, we handle that separately
*/
vulnerabilityAlerts: {
enabled: false,
},
/**
* Disable automatic rebase on each change to base branch
*/
rebaseStalePrs: false,
/**
* Disable semantic commit formating
*/
semanticCommits: false,
};

View file

@ -0,0 +1,58 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { readFileSync } from 'fs';
import globby from 'globby';
import { REPO_ROOT } from '../constants';
export const PACKAGE_GLOBS = [
'package.json',
'x-pack/package.json',
'x-pack/plugins/*/package.json',
'packages/*/package.json',
'test/plugin_functional/plugins/*/package.json',
'test/interpreter_functional/plugins/*/package.json',
];
export function getAllDepNames() {
const depNames = new Set<string>();
for (const glob of PACKAGE_GLOBS) {
const files = globby.sync(glob, {
cwd: REPO_ROOT,
absolute: true,
});
for (const path of files) {
const pkg = JSON.parse(readFileSync(path, 'utf8'));
const deps = [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.devDependencies || {}),
];
for (const dep of deps) {
depNames.add(dep);
}
}
}
return depNames;
}

View file

@ -0,0 +1,168 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { getAllDepNames } from './package_globs';
import { wordRegExp, unwrapTypesPackage } from './utils';
interface PackageGroup {
/**
* The group name, will be used for the branch name and in pr titles
*/
readonly name: string;
/**
* Specific words that, when found in the package name, identify it as part of this group
*/
readonly packageWords?: string[];
/**
* Exact package names that should be included in this group
*/
readonly packageNames?: string[];
/**
* Extra labels to apply to PRs created for packages in this group
*/
readonly extraLabels?: string[];
/**
* A flag that will prevent renovatebot from telling us when there
* are updates. This should only be used in very special cases, like
* when we intend to never update a package. To just prevent a version
* upgrade consider support for the `allowedVersions` config, or just
* closing PRs to communicate to renovate that the specific upgrade
* should be ignored.
*/
readonly enabled?: false;
}
export const RENOVATE_PACKAGE_GROUPS: PackageGroup[] = [
{
name: 'eslint',
packageWords: ['eslint'],
},
{
name: 'babel',
packageWords: ['babel'],
packageNames: ['core-js'],
},
{
name: 'jest',
packageWords: ['jest'],
},
{
name: 'mocha',
packageWords: ['mocha'],
},
{
name: 'karma',
packageWords: ['karma'],
},
{
name: 'gulp',
packageWords: ['gulp'],
},
{
name: 'grunt',
packageWords: ['grunt'],
},
{
name: 'angular',
packageWords: ['angular'],
},
{
name: 'd3',
packageWords: ['d3'],
},
{
name: 'react',
packageWords: ['react', 'redux', 'enzyme'],
packageNames: ['ngreact', 'recompose', 'prop-types', 'typescript-fsa-reducers', 'reselect'],
},
{
name: 'graphql',
packageWords: ['graphql'],
},
{
name: 'webpack',
packageWords: ['webpack', 'loader'],
packageNames: ['mini-css-extract-plugin', 'chokidar'],
},
{
name: 'language server',
packageNames: ['vscode-jsonrpc', 'vscode-languageserver', 'vscode-languageserver-types'],
},
{
name: 'hapi',
packageWords: ['hapi'],
packageNames: ['hapi', 'joi', 'boom', 'hoek', 'h2o2', '@elastic/good', 'good-squeeze', 'inert'],
},
{
name: 'dragselect',
packageNames: ['dragselect'],
extraLabels: [':ml'],
},
{
name: 'api-documenter',
packageNames: ['@microsoft/api-documenter', '@microsoft/api-extractor'],
enabled: false,
},
];
/**
* Auto-define package groups for any `@types/*` deps that are not already in a group
*/
for (const dep of getAllDepNames()) {
const typesFor = unwrapTypesPackage(dep);
if (!typesFor) {
continue;
}
// determine if one of the existing groups has typesFor in its
// packageNames or if any of the packageWords is in typesFor
const existing = RENOVATE_PACKAGE_GROUPS.some(
group =>
(group.packageNames || []).includes(typesFor) ||
(group.packageWords || []).some(word => wordRegExp(word).test(typesFor))
);
if (existing) {
continue;
}
RENOVATE_PACKAGE_GROUPS.push({
name: typesFor,
packageNames: [typesFor],
});
}

View file

@ -0,0 +1,49 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { writeFileSync } from 'fs';
import { resolve } from 'path';
import json5 from 'json5';
import dedent from 'dedent';
import { run } from '../run';
import { REPO_ROOT } from '../constants';
import { RENOVATE_CONFIG } from './config';
run(
async () => {
const genInfo = dedent`
/**
* PLEASE DO NOT MODIFY
*
* This file is automatically generated by running \`node scripts/build_renovate_config\`
*
*/
`;
writeFileSync(
resolve(REPO_ROOT, 'renovate.json5'),
`${genInfo}\n${json5.stringify(RENOVATE_CONFIG, null, 2)}\n`
);
},
{
description:
'Regenerate the renovate.json5 file at the root of the repo based on the config in src/dev/renovate',
}
);

48
src/dev/renovate/utils.ts Normal file
View file

@ -0,0 +1,48 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
export const maybeMap = <T, T2>(input: T[] | undefined, fn: (i: T) => T2) =>
input ? input.map(fn) : undefined;
export const maybeFlatMap = <T, T2>(input: T[] | undefined, fn: (i: T) => T2[]) =>
input ? input.reduce((acc, i) => [...acc, ...fn(i)], [] as T2[]) : undefined;
export const wordRegExp = (word: string) => new RegExp(`(\\b|_)${word}(\\b|_)`);
export const getTypePackageName = (pkgName: string) => {
const scopedPkgRe = /^@(.+?)\/(.+?)$/;
const match = pkgName.match(scopedPkgRe);
return `@types/${match ? `${match[1]}__${match[2]}` : pkgName}`;
};
export const unwrapTypesPackage = (pkgName: string) => {
if (!pkgName.startsWith('@types')) {
return;
}
const typesFor = pkgName.slice('@types/'.length);
if (!typesFor.includes('__')) {
return typesFor;
}
// @types packages use a convention for scoped packages, @types/org__name
const [org, name] = typesFor.split('__');
return `@${org}/${name}`;
};