From eb201c4084834e06fc8376434e8a7f793f916c24 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 6 Mar 2018 00:18:58 -0800 Subject: Add options for exporting environment and collection files --- packages/sra-report/src/index.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'packages') diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts index 4e93708ee..37c7a8f04 100644 --- a/packages/sra-report/src/index.ts +++ b/packages/sra-report/src/index.ts @@ -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); -- cgit