Add options for exporting environment and collection files

This commit is contained in:
Brandon Millman
2018-03-06 00:18:58 -08:00
parent 61ad8d4c10
commit eb201c4084

View File

@@ -27,7 +27,7 @@ const args = yargs
})
.option('output', {
alias: ['o', 'out'],
describe: 'Folder where to write the reports',
describe: 'The relative path to write the report generated by the collection run, prints to console by default',
type: 'string',
normalize: true,
demandOption: false,
@@ -38,7 +38,21 @@ const args = yargs
type: 'number',
default: DEFAULT_NETWORK_ID,
})
.example("$0 --endpoint-url 'http://api.example.com' --out 'src/contracts/generated/' --network-id 42", 'Full usage example')
.option('export-collection', {
alias: ['ec'],
describe: 'The relative path to write the postman collection file used by the collection run',
type: 'string',
normalize: true,
demandOption: false,
})
.option('export-environment', {
alias: ['ee'],
describe: 'The relative path to write the postman environment file used by the collection run',
type: 'string',
normalize: true,
demandOption: false,
})
.example("$0 --endpoint-url 'http://api.example.com' --out 'path/to/report.json' --network-id 42 --export-environment 'path/to/environment.json' --export-collection 'path/to/collection.json'", 'Full usage example')
.argv;
// perform extra validation on command line arguments
try {
@@ -52,7 +66,6 @@ if (!_.includes(SUPPORTED_NETWORK_IDS, args.networkId)) {
utils.log(`${chalk.bold(`Supported network ids:`)} ${SUPPORTED_NETWORK_IDS}`);
process.exit(1);
}
const mainAsync = async () => {
const httpClient = new HttpClient(args.endpointUrl);
const orders = await httpClient.getOrdersAsync();
@@ -75,6 +88,8 @@ const mainAsync = async () => {
const newmanRunOptions = {
collection: sraReportCollectionJSON,
environment: postmanEnvironmentFactory.createPostmanEnvironment(args.endpointUrl, args.networkId, firstOrder),
exportCollection: args.exportCollection,
exportEnvironment: args.exportEnvironment,
...newmanReporterOptions,
};
await newmanRunAsync(newmanRunOptions);