diff options
Diffstat (limited to 'packages/deployer')
-rw-r--r-- | packages/deployer/CHANGELOG.md | 2 | ||||
-rw-r--r-- | packages/deployer/coverage/.gitkeep | 0 | ||||
-rw-r--r-- | packages/deployer/package.json | 5 | ||||
-rw-r--r-- | packages/deployer/src/compiler.ts | 20 | ||||
-rw-r--r-- | packages/deployer/src/deployer.ts | 5 | ||||
-rw-r--r-- | packages/deployer/src/utils/utils.ts | 5 |
6 files changed, 19 insertions, 18 deletions
diff --git a/packages/deployer/CHANGELOG.md b/packages/deployer/CHANGELOG.md index 4b4fd76c7..541e74ae0 100644 --- a/packages/deployer/CHANGELOG.md +++ b/packages/deployer/CHANGELOG.md @@ -10,6 +10,8 @@ * Add `bytecode`, `runtime_bytecode`, `source_map`, `source_map_runtime` and `sources` fields to artifacts (#426) * Remove 0x-specific `migrate` command (#426) * Allow deployer to accept a provider instead of port and host. This makes it possible to run it with in-process ganache-core (#426) + * Consolidate all `console.log` calls into `logUtils` in the `@0xproject/utils` package (#452) + * Add `#!/usr/bin/env node` pragma above `cli.ts` script to fix command-line error. ## v0.2.0 - _March 4, 2018_ diff --git a/packages/deployer/coverage/.gitkeep b/packages/deployer/coverage/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/packages/deployer/coverage/.gitkeep diff --git a/packages/deployer/package.json b/packages/deployer/package.json index d99f6a44a..64852e89d 100644 --- a/packages/deployer/package.json +++ b/packages/deployer/package.json @@ -8,11 +8,13 @@ "build:watch": "tsc -w", "build": "yarn clean && copyfiles 'test/fixtures/contracts/**/*' ./lib && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", "test": "npm run build; mocha lib/test/*_test.js", + "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", + "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", "compile": "npm run build; node lib/src/cli.js compile", "clean": "shx rm -rf lib scripts", "migrate": "npm run build; node lib/src/cli.js migrate", "lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'", - "test:circleci": "yarn test", + "test:circleci": "yarn test:coverage", "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES", "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json" }, @@ -45,6 +47,7 @@ "@types/require-from-string": "^1.2.0", "chai": "^4.0.1", "copyfiles": "^1.2.0", + "nyc": "^11.0.1", "ethers-typescript-typings": "^0.0.2", "mocha": "^4.0.1", "shx": "^0.2.2", diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index ced8063db..83977709b 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -1,4 +1,4 @@ -import { promisify } from '@0xproject/utils'; +import { logUtils, promisify } from '@0xproject/utils'; import * as ethUtil from 'ethereumjs-util'; import * as fs from 'fs'; import 'isomorphic-fetch'; @@ -59,9 +59,9 @@ export class Compiler { }; const source = await fsWrapper.readFileAsync(contentPath, opts); sources[fileName] = source; - utils.consoleLog(`Reading ${fileName} source...`); + logUtils.log(`Reading ${fileName} source...`); } catch (err) { - utils.consoleLog(`Could not find file at ${contentPath}`); + logUtils.log(`Could not find file at ${contentPath}`); } } else { try { @@ -71,7 +71,7 @@ export class Compiler { ...nestedSources, }; } catch (err) { - utils.consoleLog(`${contentPath} is not a directory or ${constants.SOLIDITY_FILE_EXTENSION} file`); + logUtils.log(`${contentPath} is not a directory or ${constants.SOLIDITY_FILE_EXTENSION} file`); } } } @@ -164,7 +164,7 @@ export class Compiler { }); await Promise.all(_.map(fileNames, async fileName => this._compileContractAsync(fileName))); this._solcErrors.forEach(errMsg => { - utils.consoleLog(errMsg); + logUtils.log(errMsg); }); } /** @@ -195,7 +195,7 @@ export class Compiler { if (isCompilerAvailableLocally) { solcjs = fs.readFileSync(compilerBinFilename).toString(); } else { - utils.consoleLog(`Downloading ${fullSolcVersion}...`); + logUtils.log(`Downloading ${fullSolcVersion}...`); const url = `${constants.BASE_COMPILER_URL}${fullSolcVersion}`; const response = await fetch(url); if (response.status !== 200) { @@ -206,7 +206,7 @@ export class Compiler { } const solcInstance = solc.setupMethods(requireFromString(solcjs, compilerBinFilename)); - utils.consoleLog(`Compiling ${fileName}...`); + logUtils.log(`Compiling ${fileName}...`); const source = this._contractSources[fileName]; const input = { [fileName]: source, @@ -270,7 +270,7 @@ export class Compiler { const artifactString = utils.stringifyWithFormatting(newArtifact); const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`; await fsWrapper.writeFileAsync(currentArtifactPath, artifactString); - utils.consoleLog(`${fileName} artifact saved!`); + logUtils.log(`${fileName} artifact saved!`); } /** * Sets the source tree hash for a file and its dependencies. @@ -323,7 +323,7 @@ export class Compiler { */ private async _createArtifactsDirIfDoesNotExistAsync(): Promise<void> { if (!fsWrapper.doesPathExistSync(this._artifactsDir)) { - utils.consoleLog('Creating artifacts directory...'); + logUtils.log('Creating artifacts directory...'); await fsWrapper.mkdirAsync(this._artifactsDir); } } @@ -344,7 +344,7 @@ export class Compiler { contractArtifact = JSON.parse(contractArtifactString); return contractArtifact; } catch (err) { - utils.consoleLog(`Artifact for ${fileName} does not exist`); + logUtils.log(`Artifact for ${fileName} does not exist`); return undefined; } } diff --git a/packages/deployer/src/deployer.ts b/packages/deployer/src/deployer.ts index 27c346524..6c247d328 100644 --- a/packages/deployer/src/deployer.ts +++ b/packages/deployer/src/deployer.ts @@ -1,4 +1,5 @@ import { AbiType, TxData } from '@0xproject/types'; +import { logUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; import * as Web3 from 'web3'; @@ -74,7 +75,7 @@ export class Deployer { ); } const web3ContractInstance = await this._deployFromAbiAsync(abi, args, txData); - utils.consoleLog(`${contractName}.sol successfully deployed at ${web3ContractInstance.address}`); + logUtils.log(`${contractName}.sol successfully deployed at ${web3ContractInstance.address}`); const contractInstance = new Contract(web3ContractInstance, this._defaults); return contractInstance; } @@ -107,7 +108,7 @@ export class Deployer { if (err) { reject(err); } else if (_.isUndefined(res.address) && !_.isUndefined(res.transactionHash)) { - utils.consoleLog(`transactionHash: ${res.transactionHash}`); + logUtils.log(`transactionHash: ${res.transactionHash}`); } else { resolve(res); } diff --git a/packages/deployer/src/utils/utils.ts b/packages/deployer/src/utils/utils.ts index 4390d8813..9b1e59f9d 100644 --- a/packages/deployer/src/utils/utils.ts +++ b/packages/deployer/src/utils/utils.ts @@ -1,9 +1,4 @@ export const utils = { - consoleLog(message: string): void { - /* tslint:disable */ - console.log(message); - /* tslint:enable */ - }, stringifyWithFormatting(obj: any): string { const jsonReplacer: null = null; const numberOfJsonSpaces = 4; |