aboutsummaryrefslogtreecommitdiffstats
path: root/packages/deployer/src/cli.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-04-11 18:00:30 +0800
committerFabio Berger <me@fabioberger.com>2018-04-11 18:00:30 +0800
commit29dc22e208080fa8ff0871b98b530a2deb251a73 (patch)
treedb372a34e85ac8caf4a3f3ed9d7591452df9cb1a /packages/deployer/src/cli.ts
parent6f72fed8b5b37fac5096413b363b533e0a29f7b5 (diff)
parentc44f9e56ada898ffd0d0e57aa228006977fb238c (diff)
downloaddexon-sol-tools-29dc22e208080fa8ff0871b98b530a2deb251a73.tar
dexon-sol-tools-29dc22e208080fa8ff0871b98b530a2deb251a73.tar.gz
dexon-sol-tools-29dc22e208080fa8ff0871b98b530a2deb251a73.tar.bz2
dexon-sol-tools-29dc22e208080fa8ff0871b98b530a2deb251a73.tar.lz
dexon-sol-tools-29dc22e208080fa8ff0871b98b530a2deb251a73.tar.xz
dexon-sol-tools-29dc22e208080fa8ff0871b98b530a2deb251a73.tar.zst
dexon-sol-tools-29dc22e208080fa8ff0871b98b530a2deb251a73.zip
Merge branch 'development' into removeMigrateStep
* development: Fix lint error Fix documentation links in some READMEs Fix relative link Add step to publishing that upload staging doc jsons, deploys staging website, opens every docs page and asks the dev to confirm that each one renders properly before publishing Fix web3Wrapper build command Add top-level `yarn lerna:stage_docs` to upload docJsons to the staging S3 bucket for all packages with a docs page Added a detailed description of `renameOverloadedMethods` (special thanks to @fabioberger). Updated Javascript styles in the Abi-Gen and Utils packages, around support for function overloading. Updated deployer to accept a list of contract directories as input. Contract directories are namespaced to a void clashes. Also in this commit is a fix for overloading contract functions. Refactor publish script to have it's main execution body be lean and discrete steps # Conflicts: # packages/contracts/package.json # packages/deployer/package.json
Diffstat (limited to 'packages/deployer/src/cli.ts')
-rw-r--r--packages/deployer/src/cli.ts37
1 files changed, 30 insertions, 7 deletions
diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts
index f1cf56416..7b32187c4 100644
--- a/packages/deployer/src/cli.ts
+++ b/packages/deployer/src/cli.ts
@@ -11,7 +11,7 @@ import * as yargs from 'yargs';
import { commands } from './commands';
import { constants } from './utils/constants';
import { consoleReporter } from './utils/error_reporter';
-import { CliOptions, CompilerOptions, DeployerOptions } from './utils/types';
+import { CliOptions, CompilerOptions, ContractDirectory, DeployerOptions } from './utils/types';
const DEFAULT_OPTIMIZER_ENABLED = false;
const DEFAULT_CONTRACTS_DIR = path.resolve('src/contracts');
@@ -27,7 +27,7 @@ const DEFAULT_CONTRACTS_LIST = '*';
*/
async function onCompileCommandAsync(argv: CliOptions): Promise<void> {
const opts: CompilerOptions = {
- contractsDir: argv.contractsDir,
+ contractDirs: getContractDirectoriesFromList(argv.contractDirs),
networkId: argv.networkId,
optimizerEnabled: argv.shouldOptimize,
artifactsDir: argv.artifactsDir,
@@ -45,7 +45,7 @@ async function onDeployCommandAsync(argv: CliOptions): Promise<void> {
const web3Wrapper = new Web3Wrapper(provider);
const networkId = await web3Wrapper.getNetworkIdAsync();
const compilerOpts: CompilerOptions = {
- contractsDir: argv.contractsDir,
+ contractDirs: getContractDirectoriesFromList(argv.contractDirs),
networkId,
optimizerEnabled: argv.shouldOptimize,
artifactsDir: argv.artifactsDir,
@@ -69,6 +69,29 @@ async function onDeployCommandAsync(argv: CliOptions): Promise<void> {
}
/**
* Creates a set of contracts to compile.
+ * @param contractDirectoriesList Comma separated list of contract directories
+ * @return Set of contract directories
+ */
+function getContractDirectoriesFromList(contractDirectoriesList: string): Set<ContractDirectory> {
+ const directories = new Set();
+ const possiblyNamespacedDirectories = contractDirectoriesList.split(',');
+ _.forEach(possiblyNamespacedDirectories, namespacedDirectory => {
+ const directoryComponents = namespacedDirectory.split(':');
+ if (directoryComponents.length === 1) {
+ const directory = { namespace: '', path: directoryComponents[0] };
+ directories.add(directory);
+ } else if (directoryComponents.length === 2) {
+ const directory = { namespace: directoryComponents[0], path: directoryComponents[1] };
+ directories.add(directory);
+ } else {
+ throw new Error(`Unable to parse contracts directory: '${namespacedDirectory}'`);
+ }
+ });
+
+ return directories;
+}
+/**
+ * Creates a set of contracts to compile.
* @param contracts Comma separated list of contracts to compile
*/
function getContractsSetFromList(contracts: string): Set<string> {
@@ -78,8 +101,7 @@ function getContractsSetFromList(contracts: string): Set<string> {
}
const contractsArray = contracts.split(',');
_.forEach(contractsArray, contractName => {
- const fileName = `${contractName}${constants.SOLIDITY_FILE_EXTENSION}`;
- specifiedContracts.add(fileName);
+ specifiedContracts.add(contractName);
});
return specifiedContracts;
}
@@ -104,10 +126,11 @@ function deployCommandBuilder(yargsInstance: any) {
(() => {
const identityCommandBuilder = _.identity;
return yargs
- .option('contracts-dir', {
+ .option('contract-dirs', {
type: 'string',
default: DEFAULT_CONTRACTS_DIR,
- description: 'path of contracts directory to compile',
+ description:
+ "comma separated list of contract directories.\nTo avoid filename clashes, directories should be prefixed with a namespace as follows: 'namespace:/path/to/dir'.",
})
.option('network-id', {
type: 'number',