From 2a577e04750f9f90f72f763b45232dd9b5a35d93 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Mon, 17 Dec 2018 12:42:27 +1100 Subject: Add Docker image and Snapshot commands --- packages/migrations/src/migrate_snapshot.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 packages/migrations/src/migrate_snapshot.ts (limited to 'packages/migrations/src') diff --git a/packages/migrations/src/migrate_snapshot.ts b/packages/migrations/src/migrate_snapshot.ts new file mode 100644 index 000000000..f9b7751a5 --- /dev/null +++ b/packages/migrations/src/migrate_snapshot.ts @@ -0,0 +1,23 @@ +#!/usr/bin/env node +import { devConstants, web3Factory } from '@0x/dev-utils'; +import { logUtils } from '@0x/utils'; +import { Provider } from 'ethereum-types'; + +import { runMigrationsAsync } from './migration'; + +(async () => { + let providerConfigs; + let provider: Provider; + let txDefaults; + + providerConfigs = { shouldUseInProcessGanache: true, ganacheDatabasePath: '0x_ganache_snapshot' }; + provider = web3Factory.getRpcProvider(providerConfigs); + txDefaults = { + from: devConstants.TESTRPC_FIRST_ADDRESS, + }; + await runMigrationsAsync(provider, txDefaults); + process.exit(0); +})().catch(err => { + logUtils.log(err); + process.exit(1); +}); -- cgit From 9d5d0dbe144fe63469d2830c6da95940c7a78206 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Thu, 27 Dec 2018 12:45:29 +1100 Subject: Readme, read snapshot name from package.json --- packages/migrations/src/migrate_snapshot.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'packages/migrations/src') diff --git a/packages/migrations/src/migrate_snapshot.ts b/packages/migrations/src/migrate_snapshot.ts index f9b7751a5..13fb063da 100644 --- a/packages/migrations/src/migrate_snapshot.ts +++ b/packages/migrations/src/migrate_snapshot.ts @@ -2,6 +2,9 @@ import { devConstants, web3Factory } from '@0x/dev-utils'; import { logUtils } from '@0x/utils'; import { Provider } from 'ethereum-types'; +import * as fs from 'fs'; +import * as _ from 'lodash'; +import * as path from 'path'; import { runMigrationsAsync } from './migration'; @@ -9,8 +12,14 @@ import { runMigrationsAsync } from './migration'; let providerConfigs; let provider: Provider; let txDefaults; + const packageJsonPath = path.join(__dirname, '..', 'package.json'); + const packageJsonString = fs.readFileSync(packageJsonPath, 'utf8'); + const packageJson = JSON.parse(packageJsonString); + if (_.isUndefined(packageJson.config) || _.isUndefined(packageJson.config.snapshot_name)) { + throw new Error(`Did not find 'snapshot_name' key in package.json config`); + } - providerConfigs = { shouldUseInProcessGanache: true, ganacheDatabasePath: '0x_ganache_snapshot' }; + providerConfigs = { shouldUseInProcessGanache: true, ganacheDatabasePath: packageJson.config.snapshot_name }; provider = web3Factory.getRpcProvider(providerConfigs); txDefaults = { from: devConstants.TESTRPC_FIRST_ADDRESS, -- cgit