import { ClientType } from '@wireapp/api-client/src/client/' ; import logdown from 'logdown' ; import { ChangelogBot } from './ChangelogBot' ; import type { ChangelogData , LoginDataBackend , Parameters } from './Interfaces' ; const logger = logdown ( '@wireapp/changelog-bot/Start' , { logger : console , markdown : false , } ) ; export async function start ( parameters ) { const { backend , conversationIds , email , excludeCommitTypes , password , travisRepoSlug , travisTag } = parameters ; let { travisCommitRange , message } = parameters ; const isCustomMessage = ! ! message ; const MAXIMUM_CHARS = 10000 ; const loginData = { backend , clientType : ClientType . TEMPORARY , email , password , } ; if ( ! loginData . email ) { throw new Error ( 'You need to specify an email address. Otherwise this bot will not work.' ) ; } if ( ! loginData . password ) { throw new Error ( 'You need to specify a password. Otherwise this bot will not work.' ) ; } if ( ! travisRepoSlug ) { throw new Error ( 'You need to specify a repository slug. Otherwise this bot will not work.' ) ; } if ( ! travisCommitRange ) { if ( travisTag ) { logger . info ( 'Info: Using the latest tag as commit base since no commit range was specified.' ) ; travisCommitRange = await ChangelogBot . runCommand ( `git describe --abbrev=0 --tags "${ travisTag }^"` ) ; } else { throw new Error ( 'You need to specify a commit range or a tag. Otherwise this bot will not work.' ) ; } } if ( ! message ) { message = await ChangelogBot . generateChangelog ( travisRepoSlug , travisCommitRange , MAXIMUM_CHARS , excludeCommitTypes ) ; } const messageData = { content : message , isCustomMessage , repoSlug : travisRepoSlug , } ; if ( conversationIds ) { messageData . conversationIds = conversationIds . replace ( /\s/g , '' ) . split ( ',' ) ; } const bot = new ChangelogBot ( loginData , messageData ) ; await bot . sendMessage ( ) ; }