UNPKG

@applitools/bongo

Version:
41 lines (33 loc) 1.3 kB
const {getLatestReleaseEntries} = require('../changelog/query') const fetch = require('node-fetch') const endpoints = { core: 'http://applitools-quality-server.herokuapp.com/send_mail/core_sdk', sdk: 'http://applitools-quality-server.herokuapp.com/send_mail/sdks', preflight: 'https://applitools-quality-server.herokuapp.com/send_mail/preflight', } async function sendReleaseNotification({reportId, name, releaseVersion, recipient, changelogPath}) { if (!changelogPath) changelogPath = process.cwd() const changelog = getLatestReleaseEntries({targetFolder: changelogPath}).join('\n') const notification = { id: reportId, sdk: name, version: releaseVersion, changeLog: changelog, specificRecipient: recipient || undefined, testCoverageGap: 'TODO', } let type if (notification.sdk === 'core') type = 'core' else if (notification.sdk.startsWith('preflight')) type = 'preflight' else type = 'sdk' const response = await fetch(endpoints[type], { method: 'post', body: JSON.stringify(notification), headers: {'Content-Type': 'application/json'}, }) if (response.status !== 200) { console.error(await response.text()) throw new Error(`Request failed with status ${response.status}`) } } module.exports = {sendReleaseNotification}