Add command-line interface to @0x/migrations
This commit is contained in:
2
packages/migrations/bin/0x-migrate.js
Executable file
2
packages/migrations/bin/0x-migrate.js
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
require('../lib/cli.js');
|
@@ -21,6 +21,9 @@
|
|||||||
"assets": []
|
"assets": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"bin": {
|
||||||
|
"0x-migrate": "bin/0x-migrate.js"
|
||||||
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/dev-utils": "^1.0.18",
|
"@0x/dev-utils": "^1.0.18",
|
||||||
|
38
packages/migrations/src/cli.ts
Normal file
38
packages/migrations/src/cli.ts
Normal file
@@ -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);
|
||||||
|
});
|
Reference in New Issue
Block a user