import { program as commander } from 'commander' ; import logdown from 'logdown' ; import type { Parameters } from './Interfaces' ; import { start as startChangelogBot } from './Start' ; const { description , version } = require ( '../package.json' ) ; const logger = logdown ( '@wireapp/changelog-bot/cli' , { logger : console , markdown : false , } ) ; logger . state . isEnabled = true ; commander . version ( version ) . description ( description ) . option ( '-c, --conversations <conversationId,...>' , 'The conversation IDs to write in' ) . option ( '-e, --email <email>' , 'Your email address' ) . option ( '-m, --message <message>' , 'Custom message' ) . option ( '-p, --password <password>' , 'Your password' ) . option ( '-b, --backend <type>' , 'Backend type ("production" or "staging")' ) . option ( '-s, --slug <slug>' , 'A repo slug' ) . option ( '-r, --range <range>' , 'The commit range' ) . option ( '-t, --tag <tag>' , 'The commit tag' ) . option ( '-x, --exclude-commit-types <type,...>' , 'Commit types to exclude (e.g. chore,build,...)' ) . parse ( process . argv ) ; const { backend , conversations , email , message , password , range , slug , tag } = commander . opts ( ) ; let excludeCommitTypes = commander . opts ( ) . excludeCommitTypes ?? process . env . EXCLUDE_COMMIT_TYPES ; if ( typeof excludeCommitTypes !== 'undefined' ) { excludeCommitTypes = excludeCommitTypes . includes ( ',' ) ? excludeCommitTypes . split ( ',' ) : [ excludeCommitTypes ] ; } const parameters = { backend : backend , conversationIds : conversations || process . env . WIRE_CHANGELOG_BOT_CONVERSATION_IDS , email : email || process . env . WIRE_CHANGELOG_BOT_EMAIL , excludeCommitTypes , message : message , password : password || process . env . WIRE_CHANGELOG_BOT_PASSWORD , travisCommitRange : range || process . env . TRAVIS_COMMIT_RANGE , travisRepoSlug : slug || process . env . TRAVIS_REPO_SLUG , travisTag : tag || process . env . TRAVIS_TAG , } ; logger . log ( `wire-changelog-bot v${ version }` ) ; startChangelogBot ( parameters ) . catch ( error => { logger . error ( error . stack ) ; process . exit ( 1 ) ; } ) ;