<commit_before>const axios = require('axios');
const Program = require('commander');
const Chalk = require('chalk');

module.exports = async (pluginInfo) => {
    if (typeof Program.releaseEventURL !== 'undefined') {
        try {
            await axios
                .post(Program.releaseEventURL, {
                    pluginName: pluginInfo.getName(),
                    pluginVersion: pluginInfo.getCurrentVersion(),
                    pluginLabel: {
                        de: pluginInfo.getLabel('de'),
                        en: pluginInfo.getLabel('en'),
                    },
                    pluginChangelog: {
                        de: pluginInfo.getChangelog('de', null),
                        en: pluginInfo.getChangelog('en', null),
                    },
                });
            console.log(Chalk.green.bold('Publish release event succeeded'));
        } catch (err) {
            console.log(Chalk.red.bold(`Publish release event failed: ${err.message}`));
        }
    }

    return true;
};<commit_msg>Move relese event object generation into function<commit_after>const axios = require('axios');
const Program = require('commander');
const Chalk = require('chalk');

/**
 * Create a release event object from a pluginInfo object.
 *
 * @param {Object} pluginInfo
 * @return {Object}
 */
function getReleaseEventInfo(pluginInfo) {
    return {
        pluginName: pluginInfo.getName(),
        pluginVersion: pluginInfo.getCurrentVersion(),
        pluginLabel: {
            de: pluginInfo.getLabel('de'),
            en: pluginInfo.getLabel('en'),
        },
        pluginChangelog: {
            de: pluginInfo.getChangelog('de', null),
            en: pluginInfo.getChangelog('en', null),
        },
    };
}

/**
 * If set call the release event endpoint.
 *
 * @param {Object} pluginInfo
 * @return {Boolean}
 */
module.exports = async (pluginInfo) => {
    if (Program.releaseEventURL) {
        try {
            await axios.post(Program.releaseEventURL, getReleaseEventInfo(pluginInfo));
            console.log(Chalk.green.bold('Publish release event succeeded'));
        } catch (err) {
            console.log(Chalk.red.bold(`Publish release event failed: ${err.message}`));
        }
    }

    return true;
};
{'fraction_non_alphanumeric': 0.12792236435818263, 'fraction_numerical': 0.0, 'mean_word_length': 2.0899182561307903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1188694', 'n_tokens_mistral': 609, 'n_tokens_neox': 599, 'n_words': 131}