From aef018da2272cbbe54a602a8feed1f88feb08ae5 Mon Sep 17 00:00:00 2001 From: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Date: Thu, 8 Jul 2021 17:04:04 +0200 Subject: [PATCH] fix: deprecate use of `renovate.json` as preset (#10678) Co-authored-by: Michael Kriese <michael.kriese@visualon.de> --- docs/development/shareable-configs.md | 18 +++++------ docs/usage/config-presets.md | 43 +++++++++++++++------------ lib/config/presets/util.ts | 4 ++- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/docs/development/shareable-configs.md b/docs/development/shareable-configs.md index 2c661995ac..1412603a90 100644 --- a/docs/development/shareable-configs.md +++ b/docs/development/shareable-configs.md @@ -50,12 +50,12 @@ If you use a non-scoped config, you must use a preset name! In general, GitHub, GitLab or Gitea-based preset hosting is easier than npm because you avoid the "publish" step - simply commit preset code to the default branch and it will be picked up by Renovate the next time it runs. An additional benefit of using source code hosting is that the same token/authentication can be reused by Renovate in case you want to make your config private. -| name | example use | preset | resolves as | filename | -| ----------------------- | -------------------- | --------- | ------------------------------------ | --------------------------------- | -| GitHub default | `github>abc/foo` | `default` | `https://github.com/abc/foo` | `default.json` or `renovate.json` | -| GitHub with preset name | `github>abc/foo:xyz` | `xyz` | `https://github.com/abc/foo` | `xyz.json` | -| GitLab default | `gitlab>abc/foo` | `default` | `https://gitlab.com/abc/foo` | `default.json` or `renovate.json` | -| GitLab with preset name | `gitlab>abc/foo:xyz` | `xyz` | `https://gitlab.com/abc/foo` | `xyz.json` | -| Gitea default | `gitea>abc/foo` | `default` | `https://gitea.com/abc/foo` | `default.json` or `renovate.json` | -| Gitea with preset name | `gitea>abc/foo:xyz` | `xyz` | `https://gitea.com/abc/foo` | `xyz.json` | -| Local default | `local>abc/foo` | `default` | `https://github.company.com/abc/foo` | `default.json` or `renovate.json` | +| name | example use | preset | resolves as | filename | +| ----------------------- | -------------------- | --------- | ------------------------------------ | -------------- | +| GitHub default | `github>abc/foo` | `default` | `https://github.com/abc/foo` | `default.json` | +| GitHub with preset name | `github>abc/foo:xyz` | `xyz` | `https://github.com/abc/foo` | `xyz.json` | +| GitLab default | `gitlab>abc/foo` | `default` | `https://gitlab.com/abc/foo` | `default.json` | +| GitLab with preset name | `gitlab>abc/foo:xyz` | `xyz` | `https://gitlab.com/abc/foo` | `xyz.json` | +| Gitea default | `gitea>abc/foo` | `default` | `https://gitea.com/abc/foo` | `default.json` | +| Gitea with preset name | `gitea>abc/foo:xyz` | `xyz` | `https://gitea.com/abc/foo` | `xyz.json` | +| Local default | `local>abc/foo` | `default` | `https://github.company.com/abc/foo` | `default.json` | diff --git a/docs/usage/config-presets.md b/docs/usage/config-presets.md index d57049436c..9006a61bb9 100644 --- a/docs/usage/config-presets.md +++ b/docs/usage/config-presets.md @@ -16,6 +16,11 @@ In short: Shareable config presets can only be used with the JSON format, other formats are not supported. +**Warning:** `default.json` is intended for use with presets only! +**Warning:** Do not use a `renovate.json` file as a preset. + +**Info:** We've deprecated the use of a `renovate.json` file for presets as this can cause issues if the repository configuration uses a `renovate.json` file as well. + ## Goals of Preset Configs The main reason for supporting preset configs is to decrease duplication. @@ -35,18 +40,18 @@ In order to achieve these goals, preset configs allow for a very modular approac In general, GitHub, GitLab or Gitea-based preset hosting is easier than npm because you avoid the "publish" step - simply commit preset code to the default branch and it will be picked up by Renovate the next time it runs. An additional benefit of using source code hosting is that the same token/authentication can be reused by Renovate in case you want to make your config private. -| name | example use | preset | resolves as | filename | -| ----------------------- | -------------------------- | --------- | ------------------------------------ | --------------------------------- | -| GitHub default | `github>abc/foo` | `default` | `https://github.com/abc/foo` | `default.json` or `renovate.json` | -| GitHub with preset name | `github>abc/foo:xyz` | `xyz` | `https://github.com/abc/foo` | `xyz.json` | -| GitHub with preset path | `github>abc/foo//path/xyz` | `xyz` | `https://github.com/abc/foo` | `path/xyz.json` | -| GitLab default | `gitlab>abc/foo` | `default` | `https://gitlab.com/abc/foo` | `default.json` or `renovate.json` | -| GitLab with preset name | `gitlab>abc/foo:xyz` | `xyz` | `https://gitlab.com/abc/foo` | `xyz.json` | -| GitLab with preset path | `gitlab>abc/foo//path/xyz` | `xyz` | `https://gitlab.com/abc/foo` | `path/xyz.json` | -| Gitea default | `gitea>abc/foo` | `default` | `https://gitea.com/abc/foo` | `default.json` or `renovate.json` | -| Gitea with preset name | `gitea>abc/foo:xyz` | `xyz` | `https://gitea.com/abc/foo` | `xyz.json` | -| Local default | `local>abc/foo` | `default` | `https://github.company.com/abc/foo` | `default.json` or `renovate.json` | -| Local with preset path | `local>abc/foo//path/xyz` | `default` | `https://github.company.com/abc/foo` | `path/xyz.json` | +| name | example use | preset | resolves as | filename | +| ----------------------- | -------------------------- | --------- | ------------------------------------ | --------------- | +| GitHub default | `github>abc/foo` | `default` | `https://github.com/abc/foo` | `default.json` | +| GitHub with preset name | `github>abc/foo:xyz` | `xyz` | `https://github.com/abc/foo` | `xyz.json` | +| GitHub with preset path | `github>abc/foo//path/xyz` | `xyz` | `https://github.com/abc/foo` | `path/xyz.json` | +| GitLab default | `gitlab>abc/foo` | `default` | `https://gitlab.com/abc/foo` | `default.json` | +| GitLab with preset name | `gitlab>abc/foo:xyz` | `xyz` | `https://gitlab.com/abc/foo` | `xyz.json` | +| GitLab with preset path | `gitlab>abc/foo//path/xyz` | `xyz` | `https://gitlab.com/abc/foo` | `path/xyz.json` | +| Gitea default | `gitea>abc/foo` | `default` | `https://gitea.com/abc/foo` | `default.json` | +| Gitea with preset name | `gitea>abc/foo:xyz` | `xyz` | `https://gitea.com/abc/foo` | `xyz.json` | +| Local default | `local>abc/foo` | `default` | `https://github.company.com/abc/foo` | `default.json` | +| Local with preset path | `local>abc/foo//path/xyz` | `default` | `https://github.company.com/abc/foo` | `path/xyz.json` | Note that you can't combine the path and sub-preset syntaxes (i.e. anything in the form `provider>owner/repo//path/to/file:subsubpreset`) is not supported. One workaround is to use distinct files instead of sub-presets. @@ -124,12 +129,12 @@ Or if you think your preset would be valuable for others, please contribute a PR ## GitHub-hosted Presets It is also possible to host your preset config using just a regular GitHub repository and without needing to publish it to npmjs. -In such cases Renovate will simply look for a `renovate.json` file in the default branch, e.g. `main`. +In such cases Renovate will simply look for a `default.json` file in the default branch, e.g. `main`. To host your preset config on GitHub: - Create a new repository. Normally you'd call it `renovate-config` but it can be named anything -- Add configuration files to this new repo for any presets you want to share. For the default preset, `default.json` will be checked first and then `renovate.json`. For named presets, `<preset-name>.json` will be loaded. For example, loading preset `library` would load `library.json`. No other files are necessary. +- Add configuration files to this new repo for any presets you want to share. For the default preset, `default.json` will be checked. For named presets, `<preset-name>.json` will be loaded. For example, loading preset `library` would load `library.json`. No other files are necessary. - In other repos, reference it in an extends array like "github>owner/name", for example: ```json @@ -142,23 +147,23 @@ You do not need to add it as a devDependency or add any other files to the prese ## GitLab-hosted Presets It is also possible to host your preset config using just a regular GitLab repository and without needing to publish it to npmjs. -In such cases Renovate will simply look for a `renovate.json` file in the default branch. +In such cases Renovate will simply look for a `default.json` file in the default branch. To host your preset config on GitLab: - Create a new repository on GitLab. Normally you'd call it `renovate-config` but it can be named anything -- Add a renovate.json to this new repo containing the preset config. No other files are necessary +- Add a `default.json` to this new repo containing the preset config. No other files are necessary - In other repos, reference it in an extends array like "gitlab>owner/name", e.g. "gitlab>rarkins/renovate-config" ## Gitea-hosted Presets It is also possible to host your preset config using just a regular Gitea repository and without needing to publish it to npmjs. -In such cases Renovate will simply look for a `renovate.json` file in the default branch. +In such cases Renovate will simply look for a `default.json` file in the default branch. To host your preset config on Gitea: - Create a new repository on Gitea. Normally you'd call it `renovate-config` but you can use any name you want -- Add a `renovate.json` to this new repository containing the preset config. No other files are necessary +- Add a `default.json` to this new repository containing the preset config. No other files are necessary - In other repositories, reference it in an extends array like `"gitea>owner/name"`, e.g. `"gitea>rarkins/renovate-config"` ## Local presets @@ -187,7 +192,7 @@ Please consider contributing it to the [Renovate](https://github.com/renovatebot Whenever repository onboarding happens, Renovate checks if the current user/group/org contains a default config to extend. It looks for: -- A repository called `renovate-config` under the same user/group/org with either `default.json` or `renovate.json`, or +- A repository called `renovate-config` under the same user/group/org with a `default.json` file or - A repository named like `.{{platform}}` (e.g. `.github`) under the same user/group/org with `renovate-config.json` If found, that repository's preset will be suggested as the sole extended preset, and any existing `onboardingConfig` config will be ignored/overridden. diff --git a/lib/config/presets/util.ts b/lib/config/presets/util.ts index f14573cc37..1203e45927 100644 --- a/lib/config/presets/util.ts +++ b/lib/config/presets/util.ts @@ -34,7 +34,9 @@ export async function fetchPreset({ if (err.message !== PRESET_DEP_NOT_FOUND) { throw err; } - logger.debug('default.json preset not found - trying renovate.json'); + logger.info( + 'Fallback to renovate.json file as a preset is deprecated, please use a default.json file instead.' + ); jsonContent = await fetch( pkgName, buildFilePath('renovate.json'), -- GitLab