From f50e685fe425ce9c4dfcf439d6edacb4906c49e3 Mon Sep 17 00:00:00 2001
From: Maron <98313426+MaronHatoum@users.noreply.github.com>
Date: Mon, 31 Oct 2022 09:35:07 +0200
Subject: [PATCH] docs(core/config): config options for advanced users only
 (#18505)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
---
 docs/usage/configuration-options.md | 42 ++---------------------------
 lib/config/options/index.ts         |  9 +++++++
 lib/config/types.ts                 |  2 ++
 tools/docs/config.ts                | 12 +++++++++
 4 files changed, 25 insertions(+), 40 deletions(-)

diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md
index cafdc3b4da..0412822337 100644
--- a/docs/usage/configuration-options.md
+++ b/docs/usage/configuration-options.md
@@ -381,8 +381,8 @@ If you want Renovate to signoff its commits, add the [`:gitSignOff` preset](http
 
 <!-- prettier-ignore -->
 !!! warning
-    Editing of `commitMessage` directly is now deprecated and not recommended.
-    Please instead edit the fields such as `commitMessageAction`, `commitMessageExtra`, etc.
+    We deprecated editing the `commitMessage` directly, and we recommend you stop using this config option.
+    Instead use config options like `commitMessageAction`, `commitMessageExtra`, and so on, to create the commit message you want.
 
 ## commitMessageAction
 
@@ -390,46 +390,26 @@ This is used to alter `commitMessage` and `prTitle` without needing to copy/past
 Actions may be like `Update`, `Pin`, `Roll back`, `Refresh`, etc.
 Check out the default value for `commitMessage` to understand how this field is used.
 
-<!-- prettier-ignore -->
-!!! warning
-    Warning, for advanced use only! Use at your own risk!
-
 ## commitMessageExtra
 
 This is used to alter `commitMessage` and `prTitle` without needing to copy/paste the whole string.
 The "extra" is usually an identifier of the new version, e.g. "to v1.3.2" or "to tag 9.2".
 
-<!-- prettier-ignore -->
-!!! warning
-    Warning, for advanced use only! Use at your own risk!
-
 ## commitMessagePrefix
 
 This is used to alter `commitMessage` and `prTitle` without needing to copy/paste the whole string.
 The "prefix" is usually an automatically applied semantic commit prefix, but it can also be statically configured.
 
-<!-- prettier-ignore -->
-!!! warning
-    Warning, for advanced use only! Use at your own risk!
-
 ## commitMessageSuffix
 
 This is used to add a suffix to commit messages.
 Usually left empty except for internal use (multiple base branches, and vulnerability alerts).
 
-<!-- prettier-ignore -->
-!!! warning
-    Warning, for advanced use only! Use at your own risk!
-
 ## commitMessageTopic
 
 This is used to alter `commitMessage` and `prTitle` without needing to copy/paste the whole string.
 The "topic" is usually refers to the dependency being updated, e.g. `"dependency react"`.
 
-<!-- prettier-ignore -->
-!!! warning
-    Warning, for advanced use only! Use at your own risk!
-
 ## composerIgnorePlatformReqs
 
 By default, Renovate will ignore Composer platform requirements as the PHP platform used by Renovate most probably won't match the required PHP environment of your project as configured in your `composer.json` file.
@@ -747,10 +727,6 @@ See [Private module support](https://docs.renovatebot.com/getting-started/privat
 
 ## excludeCommitPaths
 
-<!-- prettier-ignore -->
-!!! warning
-    For advanced users only!
-
 Be careful you know what you're doing with this option.
 The initial intended use is to allow the user to exclude certain dependencies from being added/removed/modified when "vendoring" dependencies.
 Example:
@@ -862,11 +838,6 @@ For now, you can only use this option on the GitLab platform.
 
 ## followTag
 
-<!-- prettier-ignore -->
-!!! warning
-    Advanced functionality.
-    Only use this if you're sure you know what you're doing.
-
 For `followTag` to work, the datasource must support distribution streams or tags, like for example npm does.
 
 The main usecase is to follow a pre-release tag of a dependency, say TypeScripts's `"insiders"` build:
@@ -933,11 +904,6 @@ Also we support the `off` keyword which will stop any fetching immediately.
 
 ## group
 
-<!-- prettier-ignore -->
-!!! warning
-    Advanced functionality only.
-    Do not use unless you know what you're doing.
-
 The default configuration for groups are essentially internal to Renovate and you normally shouldn't need to modify them.
 But you may _add_ settings to any group by defining your own `group` configuration object.
 
@@ -1215,10 +1181,6 @@ You usually don't need to configure it in a host rule if you have already config
 
 ### insecureRegistry
 
-<!-- prettier-ignore -->
-!!! warning
-    Advanced config, use at your own risk.
-
 Enable this option to allow Renovate to connect to an [insecure Docker registry](https://docs.docker.com/registry/insecure/) that is http only.
 This is insecure and is not recommended.
 
diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts
index fea40c2dad..7661889105 100644
--- a/lib/config/options/index.ts
+++ b/lib/config/options/index.ts
@@ -816,6 +816,7 @@ const options: RenovateOptions[] = [
     type: 'array',
     subType: 'string',
     default: [],
+    advancedUse: true,
   },
   {
     name: 'executionTimeout',
@@ -1257,6 +1258,7 @@ const options: RenovateOptions[] = [
     type: 'string',
     cli: false,
     env: false,
+    advancedUse: true,
   },
   {
     name: 'respectLatest',
@@ -1661,6 +1663,7 @@ const options: RenovateOptions[] = [
       'Prefix to add to start of commit messages and PR titles. Uses a semantic prefix if `semanticCommits` is enabled.',
     type: 'string',
     cli: false,
+    advancedUse: true,
   },
   {
     name: 'commitMessageAction',
@@ -1668,6 +1671,7 @@ const options: RenovateOptions[] = [
     type: 'string',
     default: 'Update',
     cli: false,
+    advancedUse: true,
   },
   {
     name: 'commitMessageTopic',
@@ -1676,6 +1680,7 @@ const options: RenovateOptions[] = [
     type: 'string',
     default: 'dependency {{depName}}',
     cli: false,
+    advancedUse: true,
   },
   {
     name: 'commitMessageExtra',
@@ -1685,12 +1690,14 @@ const options: RenovateOptions[] = [
     default:
       'to {{#if isPinDigest}}{{{newDigestShort}}}{{else}}{{#if isMajor}}{{prettyNewMajor}}{{else}}{{#if isSingleVersion}}{{prettyNewVersion}}{{else}}{{#if newValue}}{{{newValue}}}{{else}}{{{newDigestShort}}}{{/if}}{{/if}}{{/if}}{{/if}}',
     cli: false,
+    advancedUse: true,
   },
   {
     name: 'commitMessageSuffix',
     description: 'Suffix to add to end of commit messages and PR titles.',
     type: 'string',
     cli: false,
+    advancedUse: true,
   },
   {
     name: 'prBodyTemplate',
@@ -1778,6 +1785,7 @@ const options: RenovateOptions[] = [
     cli: false,
     env: false,
     mergeable: true,
+    advancedUse: true,
   },
   // Pull Request options
   {
@@ -2058,6 +2066,7 @@ const options: RenovateOptions[] = [
     parent: 'hostRules',
     cli: false,
     env: false,
+    advancedUse: true,
   },
   {
     name: 'abortOnError',
diff --git a/lib/config/types.ts b/lib/config/types.ts
index b6305c8418..3da7735283 100644
--- a/lib/config/types.ts
+++ b/lib/config/types.ts
@@ -357,6 +357,8 @@ export interface RenovateOptionBase {
   experimentalDescription?: string;
 
   experimentalIssues?: number[];
+
+  advancedUse?: boolean;
 }
 
 export interface RenovateArrayOption<
diff --git a/tools/docs/config.ts b/tools/docs/config.ts
index d4c5a2a007..3c207e5e97 100644
--- a/tools/docs/config.ts
+++ b/tools/docs/config.ts
@@ -91,6 +91,7 @@ function genTable(obj: [string, string][], type: string, def: any): string {
     'experimental',
     'experimentalDescription',
     'experimentalIssues',
+    'advancedUse',
   ];
   obj.forEach(([key, val]) => {
     const el = [key, val];
@@ -233,6 +234,10 @@ export async function generateConfig(dist: string, bot = false): Promise<void> {
         `\n${option.description}\n\n` +
         genTable(Object.entries(el), option.type, option.default);
 
+      if (el.advancedUse) {
+        configOptionsRaw[headerIndex] += generateAdvancedUse();
+      }
+
       if (el.experimental) {
         configOptionsRaw[footerIndex] += genExperimentalMsg(el);
       }
@@ -240,3 +245,10 @@ export async function generateConfig(dist: string, bot = false): Promise<void> {
 
   await updateFile(`${dist}/${configFile}`, configOptionsRaw.join('\n'));
 }
+
+function generateAdvancedUse(): string {
+  return (
+    '\n<!-- prettier-ignore -->\n!!! warning\n' +
+    '    For advanced use only! Use at your own risk!\n'
+  );
+}
-- 
GitLab