aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-11-26 22:59:27 +0800
committerFabio Berger <me@fabioberger.com>2018-11-26 22:59:27 +0800
commiteefd9d9dd2164c6ff222250934812ac62df9bc15 (patch)
treec1cdb5d0a3ad81994620d1610cc7971b48a3c904 /packages
parentf46a49fd13c88dd86c9661d76bace18844642c04 (diff)
downloaddexon-sol-tools-eefd9d9dd2164c6ff222250934812ac62df9bc15.tar
dexon-sol-tools-eefd9d9dd2164c6ff222250934812ac62df9bc15.tar.gz
dexon-sol-tools-eefd9d9dd2164c6ff222250934812ac62df9bc15.tar.bz2
dexon-sol-tools-eefd9d9dd2164c6ff222250934812ac62df9bc15.tar.lz
dexon-sol-tools-eefd9d9dd2164c6ff222250934812ac62df9bc15.tar.xz
dexon-sol-tools-eefd9d9dd2164c6ff222250934812ac62df9bc15.tar.zst
dexon-sol-tools-eefd9d9dd2164c6ff222250934812ac62df9bc15.zip
Add command-line interface to @0x/migrations
Diffstat (limited to 'packages')
-rwxr-xr-xpackages/migrations/bin/0x-migrate.js2
-rw-r--r--packages/migrations/package.json3
-rw-r--r--packages/migrations/src/cli.ts38
3 files changed, 43 insertions, 0 deletions
diff --git a/packages/migrations/bin/0x-migrate.js b/packages/migrations/bin/0x-migrate.js
new file mode 100755
index 000000000..59778c0fc
--- /dev/null
+++ b/packages/migrations/bin/0x-migrate.js
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('../lib/cli.js');
diff --git a/packages/migrations/package.json b/packages/migrations/package.json
index c1ce7050d..b006a470a 100644
--- a/packages/migrations/package.json
+++ b/packages/migrations/package.json
@@ -21,6 +21,9 @@
"assets": []
}
},
+ "bin": {
+ "0x-migrate": "bin/0x-migrate.js"
+ },
"license": "Apache-2.0",
"devDependencies": {
"@0x/dev-utils": "^1.0.18",
diff --git a/packages/migrations/src/cli.ts b/packages/migrations/src/cli.ts
new file mode 100644
index 000000000..46a524e85
--- /dev/null
+++ b/packages/migrations/src/cli.ts
@@ -0,0 +1,38 @@
+#!/usr/bin/env node
+import { RPCSubprovider, Web3ProviderEngine } from '@0x/subproviders';
+import { logUtils } from '@0x/utils';
+import * as yargs from 'yargs';
+
+import { runMigrationsAsync } from './migration';
+
+const args = yargs
+ .option('node-endpoint', {
+ describe: 'Endpoint where backing Ethereum node is hosted',
+ type: 'string',
+ demandOption: false,
+ default: 'http://localhost:8545',
+ })
+ .option('from', {
+ describe: 'Ethereum address from which to deploy the contracts',
+ type: 'string',
+ demandOption: true,
+ })
+ .example(
+ '$0 --node-endpoiont http://localhost:8545 --from 0x5409ed021d9299bf6814279a6a1411a7e866a631',
+ 'Full usage example',
+ ).argv;
+
+(async () => {
+ const rpcSubprovider = new RPCSubprovider(args['node-endpoint']);
+ const provider = new Web3ProviderEngine();
+ provider.addProvider(rpcSubprovider);
+ provider.start();
+ const txDefaults = {
+ from: args.from,
+ };
+ await runMigrationsAsync(provider, txDefaults);
+ process.exit(0);
+})().catch(err => {
+ logUtils.log(err);
+ process.exit(1);
+});