From c8a8b851d8e0622559f71843a206a0e6e601cd83 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 13 Mar 2018 18:06:02 -0700 Subject: Consolidate all console.log into the @0xproject/utils package --- packages/abi-gen/src/index.ts | 17 +++++++++-------- packages/abi-gen/src/utils.ts | 3 --- 2 files changed, 9 insertions(+), 11 deletions(-) (limited to 'packages/abi-gen') diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts index 7c29f7d1d..8932e4045 100644 --- a/packages/abi-gen/src/index.ts +++ b/packages/abi-gen/src/index.ts @@ -1,5 +1,6 @@ #!/usr/bin/env node +import { logUtils } from '@0xproject/utils'; import chalk from 'chalk'; import * as fs from 'fs'; import { sync as globSync } from 'glob'; @@ -62,7 +63,7 @@ const args = yargs function registerPartials(partialsGlob: string) { const partialTemplateFileNames = globSync(partialsGlob); - utils.log(`Found ${chalk.green(`${partialTemplateFileNames.length}`)} ${chalk.bold('partial')} templates`); + logUtils.log(`Found ${chalk.green(`${partialTemplateFileNames.length}`)} ${chalk.bold('partial')} templates`); for (const partialTemplateFileName of partialTemplateFileNames) { const namedContent = utils.getNamedContent(partialTemplateFileName); Handlebars.registerPartial(namedContent.name, namedContent.content); @@ -77,7 +78,7 @@ function writeOutputFile(name: string, renderedTsCode: string): void { } const filePath = `${args.output}/${fileName}.ts`; fs.writeFileSync(filePath, renderedTsCode); - utils.log(`Created: ${chalk.bold(filePath)}`); + logUtils.log(`Created: ${chalk.bold(filePath)}`); } Handlebars.registerHelper('parameterType', utils.solTypeToTsType.bind(utils, ParamKind.Input, args.backend)); @@ -91,17 +92,17 @@ const template = Handlebars.compile(mainTemplate.content); const abiFileNames = globSync(args.abis); if (_.isEmpty(abiFileNames)) { - utils.log(`${chalk.red(`No ABI files found.`)}`); - utils.log(`Please make sure you've passed the correct folder name and that the files have + logUtils.log(`${chalk.red(`No ABI files found.`)}`); + logUtils.log(`Please make sure you've passed the correct folder name and that the files have ${chalk.bold('*.json')} extensions`); process.exit(1); } else { - utils.log(`Found ${chalk.green(`${abiFileNames.length}`)} ${chalk.bold('ABI')} files`); + logUtils.log(`Found ${chalk.green(`${abiFileNames.length}`)} ${chalk.bold('ABI')} files`); mkdirp.sync(args.output); } for (const abiFileName of abiFileNames) { const namedContent = utils.getNamedContent(abiFileName); - utils.log(`Processing: ${chalk.bold(namedContent.name)}...`); + logUtils.log(`Processing: ${chalk.bold(namedContent.name)}...`); const parsedContent = JSON.parse(namedContent.content); let ABI; if (_.isArray(parsedContent)) { @@ -112,8 +113,8 @@ for (const abiFileName of abiFileNames) { ABI = parsedContent.networks[args.networkId].abi; // 0x contracts package artifact } if (_.isUndefined(ABI)) { - utils.log(`${chalk.red(`ABI not found in ${abiFileName}.`)}`); - utils.log( + logUtils.log(`${chalk.red(`ABI not found in ${abiFileName}.`)}`); + logUtils.log( `Please make sure your ABI file is either an array with ABI entries or a truffle artifact or 0x deployer artifact`, ); process.exit(1); diff --git a/packages/abi-gen/src/utils.ts b/packages/abi-gen/src/utils.ts index 3e4ff619a..c4520ade0 100644 --- a/packages/abi-gen/src/utils.ts +++ b/packages/abi-gen/src/utils.ts @@ -73,9 +73,6 @@ export const utils = { isObjectType(tsType: string): boolean { return /^{.*}$/.test(tsType); }, - log(...args: any[]): void { - console.log(...args); // tslint:disable-line:no-console - }, getPartialNameFromFileName(filename: string): string { const name = path.parse(filename).name; return name; -- cgit v1.2.3 From 6a8c2cb7172be9b0aadb34904d1d9b3348bed0cc Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 13 Mar 2018 18:16:31 -0700 Subject: Update CHANGELOGs --- packages/abi-gen/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'packages/abi-gen') diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md index 90e82c632..e7581fb10 100644 --- a/packages/abi-gen/CHANGELOG.md +++ b/packages/abi-gen/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v0.2.5 - _TBD, 2018_ + + * Consolidate all `console.log` calls into `logUtils` in the `@0xproject/utils` package (#452) + ## v0.2.4 - _March 4, 2018_ * Add a `backend` parameter that allows you to specify the Ethereum library you use in your templates (`web3` or `ethers`). Ethers auto-converts small ints to numbers whereas Web3 doesn't. Defaults to `web3` (#413) -- cgit v1.2.3