aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sra-report/src/index.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-03-06 16:44:18 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-03-06 16:44:18 +0800
commitddad09a93639f9060db69d131a52ef8dbaf4a3fe (patch)
tree5f27d925da45deb7a7456c927f10c17928322ebe /packages/sra-report/src/index.ts
parent551771235bc80209a1f3aafff56438621885f61a (diff)
downloaddexon-sol-tools-ddad09a93639f9060db69d131a52ef8dbaf4a3fe.tar
dexon-sol-tools-ddad09a93639f9060db69d131a52ef8dbaf4a3fe.tar.gz
dexon-sol-tools-ddad09a93639f9060db69d131a52ef8dbaf4a3fe.tar.bz2
dexon-sol-tools-ddad09a93639f9060db69d131a52ef8dbaf4a3fe.tar.lz
dexon-sol-tools-ddad09a93639f9060db69d131a52ef8dbaf4a3fe.tar.xz
dexon-sol-tools-ddad09a93639f9060db69d131a52ef8dbaf4a3fe.tar.zst
dexon-sol-tools-ddad09a93639f9060db69d131a52ef8dbaf4a3fe.zip
Add support for custom environment file
Diffstat (limited to 'packages/sra-report/src/index.ts')
-rw-r--r--packages/sra-report/src/index.ts21
1 files changed, 12 insertions, 9 deletions
diff --git a/packages/sra-report/src/index.ts b/packages/sra-report/src/index.ts
index 4419a3ec8..d292f15e1 100644
--- a/packages/sra-report/src/index.ts
+++ b/packages/sra-report/src/index.ts
@@ -1,6 +1,5 @@
#!/usr/bin/env node
import { assert } from '@0xproject/assert';
-import { HttpClient } from '@0xproject/connect';
import { Schema, schemas } from '@0xproject/json-schemas';
import { promisify } from '@0xproject/utils';
import chalk from 'chalk';
@@ -38,6 +37,13 @@ const args = yargs
type: 'number',
default: DEFAULT_NETWORK_ID,
})
+ .option('environment', {
+ alias: ['env'],
+ describe: 'File path to an environment file for the collection run',
+ type: 'string',
+ normalize: true,
+ demandOption: false,
+ })
.option('export-collection', {
alias: ['ec'],
describe: 'The relative path to write the postman collection file used by the collection run',
@@ -53,7 +59,7 @@ const args = yargs
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'",
+ "$0 --endpoint-url 'http://api.example.com' --out 'path/to/report.json' --network-id 42 --environment 'path/to/custom/environment.json' --export-collection 'path/to/collection.json' --export-environment 'path/to/environment.json'",
'Full usage example',
).argv;
// perform extra validation on command line arguments
@@ -69,12 +75,6 @@ if (!_.includes(SUPPORTED_NETWORK_IDS, args.networkId)) {
process.exit(1);
}
const mainAsync = async () => {
- const httpClient = new HttpClient(args.endpointUrl);
- const orders = await httpClient.getOrdersAsync();
- const firstOrder = _.head(orders);
- if (_.isUndefined(firstOrder)) {
- throw new Error('Could not get any orders from /orders endpoint');
- }
const newmanReporterOptions = !_.isUndefined(args.output)
? {
reporters: 'json',
@@ -87,9 +87,12 @@ const mainAsync = async () => {
: {
reporters: 'cli',
};
+ const environment = !_.isUndefined(args.environment)
+ ? args.environment
+ : await postmanEnvironmentFactory.createPostmanEnvironmentAsync(args.endpointUrl, args.networkId);
const newmanRunOptions = {
collection: sraReportCollectionJSON,
- environment: postmanEnvironmentFactory.createPostmanEnvironment(args.endpointUrl, args.networkId, firstOrder),
+ environment,
exportCollection: args.exportCollection,
exportEnvironment: args.exportEnvironment,
...newmanReporterOptions,