From d61f203c1b11c856e7fe5e88694b78553f087a53 Mon Sep 17 00:00:00 2001 From: Ashley Date: Wed, 8 Nov 2023 22:37:51 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=89=20Add=20resolve-config.js?= =?UTF-8?q?=20for=20semantic-release-discord?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resolve-config.js | 19 +++++++++++++ .../semantic-release-github-dispatch/index.js | 1 - .../resolve-config.js | 27 ------------------- 3 files changed, 19 insertions(+), 28 deletions(-) create mode 100644 modules/semantic-release-discord/resolve-config.js delete mode 100644 modules/semantic-release-github-dispatch/resolve-config.js diff --git a/modules/semantic-release-discord/resolve-config.js b/modules/semantic-release-discord/resolve-config.js new file mode 100644 index 000000000..622eeda39 --- /dev/null +++ b/modules/semantic-release-discord/resolve-config.js @@ -0,0 +1,19 @@ +/** + * @typedef {import('./types').Context} Context + * @typedef {import('./types').Config} Config + */ + +/** + * @param {Config} pluginConfig -. + * @param {Context} context -. + * @returns {Config} -. + * @example + * resolveConfig(pluginConfig, context) + */ +function resolveConfig({ webhookUrl }, { env }) { + return { + webhookUrl: webhookUrl || env.DISCORD_WEBHOOK, + } +} + +module.exports = resolveConfig; \ No newline at end of file diff --git a/modules/semantic-release-github-dispatch/index.js b/modules/semantic-release-github-dispatch/index.js index 2e97f18aa..14bdc997c 100644 --- a/modules/semantic-release-github-dispatch/index.js +++ b/modules/semantic-release-github-dispatch/index.js @@ -1,4 +1,3 @@ -const core = require('@actions/core'); const github = require('@actions/github'); /** diff --git a/modules/semantic-release-github-dispatch/resolve-config.js b/modules/semantic-release-github-dispatch/resolve-config.js deleted file mode 100644 index eb83359c4..000000000 --- a/modules/semantic-release-github-dispatch/resolve-config.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @typedef {import('./types').Context} Context - * @typedef {import('./types').Config} Config - */ - -/** - * @param {Config} pluginConfig -. - * @param {Context} context -. - * @returns {Config} -. - * @example - * resolveConfig(pluginConfig, context) - */ -function resolveConfig({ githubToken, eventName, payload }, { env }) { - return { - owner: owner || env.GITHUB_OWNER, - repo: repo || env.GITHUB_REPO, - githubToken: githubToken || env.GITHUB_TOKEN, - eventName: eventName || env.GITHUB_EVENT_NAME, - payload: { - version: payload.version, - image: payload.image, - branch: payload.branch || env.CURRENT_BRANCH - } - } -} - -module.exports = resolveConfig; \ No newline at end of file