From 89c9cc9178e2b98c949b016ee67c63b7e23393ce Mon Sep 17 00:00:00 2001 From: Viktor Varland Date: Mon, 27 Sep 2021 14:02:51 +0200 Subject: [PATCH] feat(renovate): add renovate configuration setup --- src/commands/actions/renovate.js | 38 ++++++++++++++++++++++++++++++++ src/utils/config.js | 2 ++ templates/renovate-base.json | 4 ++++ 3 files changed, 44 insertions(+) create mode 100644 src/commands/actions/renovate.js create mode 100644 templates/renovate-base.json diff --git a/src/commands/actions/renovate.js b/src/commands/actions/renovate.js new file mode 100644 index 00000000..df0aaafc --- /dev/null +++ b/src/commands/actions/renovate.js @@ -0,0 +1,38 @@ +const log = require('@dhis2/cli-helpers-engine').reporter +const cfg = require('../../utils/config.js') + +exports.command = 'renovate [type]' + +exports.desc = 'Lint file and directory names.' + +exports.builder = yargs => + yargs + .positional('type', { + describe: 'Configuration template to use for Renovate', + type: 'string', + default: 'base', + }) + .option('overwrite', { + describe: 'Overwrite the existing configuration.', + type: 'boolean', + }) + .example( + '$0 add renovate', + 'Adds the standard configuration to renovate.json' + ) + +exports.handler = argv => { + const { add, type, overwrite } = argv + + log.info(`renovate > ${add ? 'add' : 'remove'}`) + + if (add) { + cfg.add({ + tool: 'renovate', + type: type ? type : 'base', + overwrite, + }) + } else { + cfg.remove({ tool: 'renovate', type: type ? type : 'base' }) + } +} diff --git a/src/utils/config.js b/src/utils/config.js index 40c493ef..7685b6e1 100755 --- a/src/utils/config.js +++ b/src/utils/config.js @@ -34,6 +34,7 @@ const projectConfigs = { editorconfig: path.join(PROJECT_ROOT, '.editorconfig'), eslint: path.join(PROJECT_ROOT, '.eslintrc.js'), prettier: path.join(PROJECT_ROOT, '.prettierrc.js'), + renovate: path.join(PROJECT_ROOT, 'renovate.json'), github: { dependabot: path.join(PROJECT_ROOT, '.github', 'dependabot.yml'), semantic: path.join(PROJECT_ROOT, '.github', 'semantic.yml'), @@ -95,6 +96,7 @@ const templateConfigs = { react: path.join(TEMPLATE_DIR, 'eslint-react.js'), }, prettier: path.join(TEMPLATE_DIR, 'prettier-base.js'), + renovate: path.join(TEMPLATE_DIR, 'renovate-base.json'), github: { dependabot: path.join(TEMPLATE_DIR, 'github-dependabot.yml'), semantic: path.join(TEMPLATE_DIR, 'github-semantic.yml'), diff --git a/templates/renovate-base.json b/templates/renovate-base.json new file mode 100644 index 00000000..1decacdb --- /dev/null +++ b/templates/renovate-base.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["local>dhis2/.github:renovate-config"] +}