import * as yargs from 'yargs'; import { CommandModule } from 'yargs'; import { MessageDiffOptions } from './message-diff-options'; import { MessageDiff } from './msg-diff'; export const msgDiff: CommandModule = { command: 'msg-diff', describe: 'Compares AsyncAPI documents with git for breaking changes.', builder: (yargs) => yargs .option('inputDir', { alias: 'i', describe: 'Path to input directory - AsyncAPI document root.', type: 'string', demandOption: true, }) .option('filePattern', { alias: 'p', describe: 'Regular expression used to include suitable input files.', type: 'string', default: '^.*(-asyncapi).(json|yaml|yml)$', }) .option('excludePattern', { alias: 'e', describe: 'Exclude input files matching a regular expression. Exclusion takes precedence over inclusion.', type: 'string', default: undefined, }) .option('branch', { alias: 'b', description: 'Git branch or commit identifier to compare to.', type: 'string', default: 'origin/master', }) .option('verbose', { alias: 'v', description: 'Verbose output including non-breaking changes.', type: 'boolean', default: false, }), handler: async (argv) => { const diff = new MessageDiff(argv); await diff.run(); console.log('done.'); }, }; // Dev helper. Script can be run directly with command: // ts-node libs/cli/src/commands/msg-diff/index.ts msg-diff -i libs/messages/schemas if (require.main === module) { yargs.command(msgDiff).demandCommand().argv; }